PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.6
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.6
3.4.6 3.4.5 3.4.4 3.4.3 3.4.2 3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 All 199 releases
← All changes | admin/section/class-convertkit-admin-section-general.php +65 -25 3.3.7 → 3.4.6 View file →
@@ -14,17 +14,8 @@
14 14 */
15 15 class ConvertKit_Admin_Section_General extends ConvertKit_Admin_Section_Base {
16 16
17 17 /**
18 - * Holds the API instance.
19 - *
20 - * @since 1.9.6
21 - *
22 - * @var ConvertKit_API_V4
23 - */
24 - private $api;
25 -
26 - /**
27 18 * Holds the ConvertKit Account Name.
28 19 *
29 20 * @since 1.9.6
30 21 *
@@ -52,10 +43,10 @@
52 43 // Define the settings key.
53 44 $this->settings_key = $this->settings::SETTINGS_NAME;
54 45
55 46 // Define the programmatic name, Title and Tab Text.
56 - $this->name = 'general';
57 - $this->title = __( 'General Settings', 'convertkit' );
47 + $this->name = $this->settings->get_name();
48 + $this->title = $this->settings->get_title();
58 49 $this->tab_text = __( 'General', 'convertkit' );
59 50
60 51 // Define settings sections.
61 52 $this->settings_sections = array(
@@ -86,8 +77,9 @@
86 77 // Register and maybe output notices for this settings screen, and the Intercom messenger.
87 78 if ( $this->on_settings_screen( $this->name ) ) {
88 79 add_filter( 'convertkit_settings_base_register_notices', array( $this, 'register_notices' ) );
89 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' ) );
90 82 }
91 83
92 84 // Enqueue scripts and CSS.
93 85 add_action( 'convertkit_admin_settings_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -119,8 +111,43 @@
119 111
120 112 }
121 113
122 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 + /**
123 150 * Test the access token, if it exists.
124 151 * If the access token has been revoked or is invalid, remove it from the settings now.
125 152 *
126 153 * @since 2.5.0
@@ -146,21 +173,12 @@
146 173 );
147 174 exit();
148 175 }
149 176
150 - // Initialize the API.
151 - $this->api = new ConvertKit_API_V4(
152 - CONVERTKIT_OAUTH_CLIENT_ID,
153 - CONVERTKIT_OAUTH_CLIENT_REDIRECT_URI,
154 - $this->settings->get_access_token(),
155 - $this->settings->get_refresh_token(),
156 - $this->settings->debug_enabled(),
157 - 'settings'
158 - );
159 -
160 177 // Get Account Details, which we'll use in account_name_callback(), but also lets us test
161 178 // whether the API credentials are valid.
162 - $this->account = $this->api->get_account();
179 + $account = new ConvertKit_Resource_Account();
180 + $this->account = $account->refresh();
163 181
164 182 // If the request succeeded, no need to perform further actions.
165 183 if ( ! is_wp_error( $this->account ) ) {
166 184 return;
@@ -184,13 +202,18 @@
184 202 if ( ! $this->on_settings_screen( $this->name ) ) {
185 203 return;
186 204 }
187 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 +
188 211 // Bail if nonce verification fails.
189 212 if ( ! isset( $_REQUEST['_convertkit_settings_oauth_disconnect'] ) ) {
190 213 return;
191 214 }
192 - 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 ) ) {
193 216 return;
194 217 }
195 218
196 219 // Get Settings class.
@@ -223,8 +246,9 @@
223 246 return;
224 247 }
225 248
226 249 // Delete cached resources.
250 + $account = new ConvertKit_Resource_Account();
227 251 $creator_network = new ConvertKit_Resource_Creator_Network_Recommendations();
228 252 $custom_fields = new ConvertKit_Resource_Custom_Fields();
229 253 $forms = new ConvertKit_Resource_Forms();
230 254 $landing_pages = new ConvertKit_Resource_Landing_Pages();
@@ -231,8 +255,9 @@
231 255 $posts = new ConvertKit_Resource_Posts();
232 256 $products = new ConvertKit_Resource_Products();
233 257 $sequences = new ConvertKit_Resource_Sequences();
234 258 $tags = new ConvertKit_Resource_Tags();
259 + $account->delete();
235 260 $creator_network->delete();
236 261 $custom_fields->delete();
237 262 $forms->delete();
238 263 $landing_pages->delete();
@@ -651,9 +676,9 @@
651 676 esc_url(
652 677 add_query_arg(
653 678 array(
654 679 'page' => '_wp_convertkit_settings',
655 - '_convertkit_settings_oauth_disconnect' => wp_create_nonce( 'convertkit-oauth-disconnect' ),
680 + '_convertkit_settings_oauth_disconnect' => wp_create_nonce( CONVERTKIT_NONCE_ACTION_OAUTH_DISCONNECT ),
656 681 ),
657 682 'options-general.php'
658 683 )
659 684 ),
@@ -694,10 +719,21 @@
694 719 if ( is_wp_error( $result ) ) {
695 720 return;
696 721 }
697 722
698 - // Also refresh Landing Pages, Tags and Posts. Whilst not displayed in the Plugin Settings, this ensures up to date
723 + // Also refresh other resources. Whilst not displayed in the Plugin Settings, this ensures up to date
699 724 // lists are stored for when editing e.g. Pages.
725 +
726 + // Refresh Custom Fields.
727 + $custom_fields = new ConvertKit_Resource_Custom_Fields( 'settings' );
728 + $result = $custom_fields->refresh();
729 +
730 + // Bail if an error occured.
731 + if ( is_wp_error( $result ) ) {
732 + return;
733 + }
734 +
735 + // Refresh Landing Pages.
700 736 $landing_pages = new ConvertKit_Resource_Landing_Pages( 'settings' );
701 737 $result = $landing_pages->refresh();
702 738
703 739 // Bail if an error occured.
@@ -704,8 +740,9 @@
704 740 if ( is_wp_error( $result ) ) {
705 741 return;
706 742 }
707 743
744 + // Refresh Posts.
708 745 remove_all_actions( 'convertkit_resource_refreshed_posts' );
709 746 $posts = new ConvertKit_Resource_Posts( 'settings' );
710 747 $result = $posts->refresh();
711 748
@@ -713,8 +750,9 @@
713 750 if ( is_wp_error( $result ) ) {
714 751 return;
715 752 }
716 753
754 + // Refresh Products.
717 755 $products = new ConvertKit_Resource_Products( 'settings' );
718 756 $result = $products->refresh();
719 757
720 758 // Bail if an error occured.
@@ -721,8 +759,9 @@
721 759 if ( is_wp_error( $result ) ) {
722 760 return;
723 761 }
724 762
763 + // Refresh Sequences.
725 764 $sequences = new ConvertKit_Resource_Sequences( 'settings' );
726 765 $result = $sequences->refresh();
727 766
728 767 // Bail if an error occured.
@@ -729,8 +768,9 @@
729 768 if ( is_wp_error( $result ) ) {
730 769 return;
731 770 }
732 771
772 + // Refresh Tags.
733 773 $tags = new ConvertKit_Resource_Tags( 'settings' );
734 774 $result = $tags->refresh();
735 775
736 776 // Bail if an error occured.