← All changes
|
admin/section/class-convertkit-admin-section-general.php
+45
-4
3.3.8
→
3.4.6
View file →
| @@ -43,10 +43,10 @@ | ||
| 43 | 43 | // Define the settings key. |
| 44 | 44 | $this->settings_key = $this->settings::SETTINGS_NAME; |
| 45 | 45 | |
| 46 | 46 | // Define the programmatic name, Title and Tab Text. |
| 47 | - $this->name = 'general'; | |
| 48 | - $this->title = __( 'General Settings', 'convertkit' ); | |
| 47 | + $this->name = $this->settings->get_name(); | |
| 48 | + $this->title = $this->settings->get_title(); | |
| 49 | 49 | $this->tab_text = __( 'General', 'convertkit' ); |
| 50 | 50 | |
| 51 | 51 | // Define settings sections. |
| 52 | 52 | $this->settings_sections = array( |
| @@ -77,8 +77,9 @@ | ||
| 77 | 77 | // Register and maybe output notices for this settings screen, and the Intercom messenger. |
| 78 | 78 | if ( $this->on_settings_screen( $this->name ) ) { |
| 79 | 79 | add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) ); |
| 80 | 80 | add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_notices' ) ); |
| 81 | + add_action( 'convertkit_settings_base_render_before', array( $this, 'maybe_output_legacy_form_notice' ) ); | |
| 81 | 82 | } |
| 82 | 83 | |
| 83 | 84 | // Enqueue scripts and CSS. |
| 84 | 85 | add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
| @@ -110,8 +111,43 @@ | ||
| 110 | 111 | |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | 114 | /** |
| 115 | + * Outputs a non-dismissible warning when one or more Default Form settings | |
| 116 | + * reference Legacy Forms. | |
| 117 | + * | |
| 118 | + * @since 3.3.9 | |
| 119 | + */ | |
| 120 | + public function maybe_output_legacy_form_notice() { | |
| 121 | + | |
| 122 | + // Get warnings. | |
| 123 | + $warnings = WP_ConvertKit()->get_class( 'admin_legacy_resource_notice' )->get_legacy_warnings_for_plugin_settings( $this->settings->get() ); | |
| 124 | + | |
| 125 | + // Bail if no warnings are found. | |
| 126 | + if ( empty( $warnings ) ) { | |
| 127 | + return; | |
| 128 | + } | |
| 129 | + | |
| 130 | + // Output warnings. | |
| 131 | + ?> | |
| 132 | + <div id="convertkit-legacy-settings-warning" class="notice notice-warning"> | |
| 133 | + <p> | |
| 134 | + <strong><?php esc_html_e( 'Kit', 'convertkit' ); ?>:</strong> | |
| 135 | + <?php esc_html_e( 'Your Default Form settings reference Legacy Forms. They still work, but should be migrated:', 'convertkit' ); ?> | |
| 136 | + </p> | |
| 137 | + <ul> | |
| 138 | + <?php | |
| 139 | + foreach ( $warnings as $warning ) { | |
| 140 | + echo '<li>' . esc_html( $warning ) . '</li>'; | |
| 141 | + } | |
| 142 | + ?> | |
| 143 | + </ul> | |
| 144 | + </div> | |
| 145 | + <?php | |
| 146 | + | |
| 147 | + } | |
| 148 | + | |
| 149 | + /** | |
| 114 | 150 | * Test the access token, if it exists. |
| 115 | 151 | * If the access token has been revoked or is invalid, remove it from the settings now. |
| 116 | 152 | * |
| 117 | 153 | * @since 2.5.0 |
| @@ -166,13 +202,18 @@ | ||
| 166 | 202 | if ( ! $this->on_settings_screen( $this->name ) ) { |
| 167 | 203 | return; |
| 168 | 204 | } |
| 169 | 205 | |
| 206 | + // Bail if the user is not permitted to disconnect the Plugin from a Kit account. | |
| 207 | + if ( ! current_user_can( 'manage_options' ) ) { | |
| 208 | + return; | |
| 209 | + } | |
| 210 | + | |
| 170 | 211 | // Bail if nonce verification fails. |
| 171 | 212 | if ( ! isset( $_REQUEST['_convertkit_settings_oauth_disconnect'] ) ) { |
| 172 | 213 | return; |
| 173 | 214 | } |
| 174 | - if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_oauth_disconnect'] ), 'convertkit-oauth-disconnect' ) ) { | |
| 215 | + if ( ! wp_verify_nonce( sanitize_key( $_REQUEST['_convertkit_settings_oauth_disconnect'] ), CONVERTKIT_NONCE_ACTION_OAUTH_DISCONNECT ) ) { | |
| 175 | 216 | return; |
| 176 | 217 | } |
| 177 | 218 | |
| 178 | 219 | // Get Settings class. |
| @@ -635,9 +676,9 @@ | ||
| 635 | 676 | esc_url( |
| 636 | 677 | add_query_arg( |
| 637 | 678 | array( |
| 638 | 679 | 'page' => '_wp_convertkit_settings', |
| 639 | - '_convertkit_settings_oauth_disconnect' => wp_create_nonce( 'convertkit-oauth-disconnect' ), | |
| 680 | + '_convertkit_settings_oauth_disconnect' => wp_create_nonce( CONVERTKIT_NONCE_ACTION_OAUTH_DISCONNECT ), | |
| 640 | 681 | ), |
| 641 | 682 | 'options-general.php' |
| 642 | 683 | ) |
| 643 | 684 | ), |