| @@ -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 | * |
| @@ -111,10 +143,11 @@ | ||
| 111 | 143 | } |
| 112 | 144 | |
| 113 | 145 | // Show a warning if the API credentials haven't been set. |
| 114 | 146 | $settings = new ConvertKit_Settings(); |
| 115 | - if ( ! $settings->has_api_key_and_secret() ) { | |
| 147 | + if ( ! $settings->has_access_and_refresh_token() ) { | |
| 116 | 148 | $post_type = get_post_type_object( $post->post_type ); |
| 149 | + $api = new ConvertKit_API_V4( CONVERTKIT_OAUTH_CLIENT_ID, CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI ); | |
| 117 | 150 | include CONVERTKIT_PLUGIN_PATH . '/views/backend/post/no-api-key.php'; |
| 118 | 151 | return; |
| 119 | 152 | } |
| 120 | 153 | |
| @@ -204,9 +237,9 @@ | ||
| 204 | 237 | $new_value = sanitize_text_field( wp_unslash( $settings[ $key ] ) ); |
| 205 | 238 | |
| 206 | 239 | // Skip if the setting value is -2, as this means it's a Bulk Edit request and this setting |
| 207 | 240 | // is set as 'No Change'. |
| 208 | - if ( $new_value == '-2' ) { // phpcs:ignore WordPress.PHP.StrictComparisons | |
| 241 | + if ( $new_value == '-2' ) { // phpcs:ignore Universal.Operators.StrictComparisons.LooseEqual | |
| 209 | 242 | continue; |
| 210 | 243 | } |
| 211 | 244 | |
| 212 | 245 | // Update setting using posted value. |