| @@ -22,8 +22,9 @@ | ||
| 22 | 22 | * @since 1.9.6 |
| 23 | 23 | */ |
| 24 | 24 | public function __construct() { |
| 25 | 25 | |
| 26 | + add_action( 'post_submitbox_misc_actions', array( $this, 'output_pre_publish_actions' ) ); | |
| 26 | 27 | add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); |
| 27 | 28 | add_action( 'save_post', array( $this, 'save_post_meta' ) ); |
| 28 | 29 | |
| 29 | 30 | } |
| @@ -72,8 +73,39 @@ | ||
| 72 | 73 | |
| 73 | 74 | } |
| 74 | 75 | |
| 75 | 76 | /** |
| 77 | + * Registers actions in the pre-publish actions section of the Publish metabox | |
| 78 | + * in the Classic Editor. | |
| 79 | + * | |
| 80 | + * @since 2.4.0 | |
| 81 | + * | |
| 82 | + * @param WP_Post $post WordPress Post. | |
| 83 | + */ | |
| 84 | + public function output_pre_publish_actions( $post ) { | |
| 85 | + | |
| 86 | + // Bail if no actions registered. | |
| 87 | + $pre_publish_actions = convertkit_get_pre_publish_actions(); | |
| 88 | + if ( ! count( $pre_publish_actions ) ) { | |
| 89 | + return; | |
| 90 | + } | |
| 91 | + | |
| 92 | + // Bail if Post is not a supported Post Type. | |
| 93 | + if ( get_post_type( $post ) !== 'post' ) { | |
| 94 | + return; | |
| 95 | + } | |
| 96 | + | |
| 97 | + // Bail if Post is not a draft. | |
| 98 | + if ( ! in_array( $post->post_status, array( 'draft', 'auto-draft' ), true ) ) { | |
| 99 | + return; | |
| 100 | + } | |
| 101 | + | |
| 102 | + // Load pre-publish actions view. | |
| 103 | + include CONVERTKIT_PLUGIN_PATH . '/views/backend/post/pre-publish-actions.php'; | |
| 104 | + | |
| 105 | + } | |
| 106 | + | |
| 107 | + /** | |
| 76 | 108 | * Adds a meta box for the given Post Type. |
| 77 | 109 | * |
| 78 | 110 | * @since 1.9.6 |
| 79 | 111 | * |
| @@ -204,9 +236,9 @@ | ||
| 204 | 236 | $new_value = sanitize_text_field( wp_unslash( $settings[ $key ] ) ); |
| 205 | 237 | |
| 206 | 238 | // Skip if the setting value is -2, as this means it's a Bulk Edit request and this setting |
| 207 | 239 | // is set as 'No Change'. |
| 208 | - if ( $new_value == '-2' ) { // phpcs:ignore WordPress.PHP.StrictComparisons | |
| 240 | + if ( $new_value == '-2' ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual | |
| 209 | 241 | continue; |
| 210 | 242 | } |
| 211 | 243 | |
| 212 | 244 | // Update setting using posted value. |