PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.3
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.3
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 2.2.9 2.3.0 2.3.1 All 196 releases
← All changes | admin/section/class-convertkit-admin-section-general.php +58 -23 3.3.73.4.3 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;
@@ -223,8 +241,9 @@
223 241 return;
224 242 }
225 243
226 244 // Delete cached resources.
245 + $account = new ConvertKit_Resource_Account();
227 246 $creator_network = new ConvertKit_Resource_Creator_Network_Recommendations();
228 247 $custom_fields = new ConvertKit_Resource_Custom_Fields();
229 248 $forms = new ConvertKit_Resource_Forms();
230 249 $landing_pages = new ConvertKit_Resource_Landing_Pages();
@@ -231,8 +250,9 @@
231 250 $posts = new ConvertKit_Resource_Posts();
232 251 $products = new ConvertKit_Resource_Products();
233 252 $sequences = new ConvertKit_Resource_Sequences();
234 253 $tags = new ConvertKit_Resource_Tags();
254 + $account->delete();
235 255 $creator_network->delete();
236 256 $custom_fields->delete();
237 257 $forms->delete();
238 258 $landing_pages->delete();
@@ -694,10 +714,21 @@
694 714 if ( is_wp_error( $result ) ) {
695 715 return;
696 716 }
697 717
698 - // Also refresh Landing Pages, Tags and Posts. Whilst not displayed in the Plugin Settings, this ensures up to date
718 + // Also refresh other resources. Whilst not displayed in the Plugin Settings, this ensures up to date
699 719 // lists are stored for when editing e.g. Pages.
720 +
721 + // Refresh Custom Fields.
722 + $custom_fields = new ConvertKit_Resource_Custom_Fields( 'settings' );
723 + $result = $custom_fields->refresh();
724 +
725 + // Bail if an error occured.
726 + if ( is_wp_error( $result ) ) {
727 + return;
728 + }
729 +
730 + // Refresh Landing Pages.
700 731 $landing_pages = new ConvertKit_Resource_Landing_Pages( 'settings' );
701 732 $result = $landing_pages->refresh();
702 733
703 734 // Bail if an error occured.
@@ -704,8 +735,9 @@
704 735 if ( is_wp_error( $result ) ) {
705 736 return;
706 737 }
707 738
739 + // Refresh Posts.
708 740 remove_all_actions( 'convertkit_resource_refreshed_posts' );
709 741 $posts = new ConvertKit_Resource_Posts( 'settings' );
710 742 $result = $posts->refresh();
711 743
@@ -713,8 +745,9 @@
713 745 if ( is_wp_error( $result ) ) {
714 746 return;
715 747 }
716 748
749 + // Refresh Products.
717 750 $products = new ConvertKit_Resource_Products( 'settings' );
718 751 $result = $products->refresh();
719 752
720 753 // Bail if an error occured.
@@ -721,8 +754,9 @@
721 754 if ( is_wp_error( $result ) ) {
722 755 return;
723 756 }
724 757
758 + // Refresh Sequences.
725 759 $sequences = new ConvertKit_Resource_Sequences( 'settings' );
726 760 $result = $sequences->refresh();
727 761
728 762 // Bail if an error occured.
@@ -729,8 +763,9 @@
729 763 if ( is_wp_error( $result ) ) {
730 764 return;
731 765 }
732 766
767 + // Refresh Tags.
733 768 $tags = new ConvertKit_Resource_Tags( 'settings' );
734 769 $result = $tags->refresh();
735 770
736 771 // Bail if an error occured.