PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.3.0
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.3.0
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 | includes/class-wp-convertkit.php +70 -60 2.2.03.3.0 View file →
@@ -20,9 +20,9 @@
20 20 * @since 1.9.6
21 21 *
22 22 * @var object
23 23 */
24 - public static $instance;
24 + private static $instance;
25 25
26 26 /**
27 27 * Holds singleton initialized classes that include
28 28 * action and filter hooks.
@@ -39,9 +39,27 @@
39 39 * @since 1.9.6
40 40 */
41 41 public function __construct() {
42 42
43 - // Initialize class(es) to register hooks.
43 + // Initialize classes that have hooks prior to the `init` hook.
44 + // Divi Theme requires us to do this, although the Divi Builder Plugin works fine when loading
45 + // our integration on `init`.
46 + $this->classes['divi'] = new ConvertKit_Divi();
47 + $this->classes['widgets'] = new ConvertKit_Widgets();
48 +
49 + // Initialize Plugin classes on init, so the `_load_textdomain_just_in_time` warning isn't triggered.
50 + add_action( 'init', array( $this, 'initialize' ), 1 );
51 + add_action( 'init', array( $this, 'setup' ), 2 );
52 +
53 + }
54 +
55 + /**
56 + * Initialize classes.
57 + *
58 + * @since 2.7.7
59 + */
60 + public function initialize() {
61 +
44 62 $this->initialize_admin();
45 63 $this->initialize_admin_or_frontend_editor();
46 64 $this->initialize_cli_cron();
47 65 $this->initialize_frontend();
@@ -46,11 +64,8 @@
46 64 $this->initialize_cli_cron();
47 65 $this->initialize_frontend();
48 66 $this->initialize_global();
49 67
50 - // Load language files.
51 - add_action( 'init', array( $this, 'load_language_files' ) );
52 -
53 68 }
54 69
55 70 /**
56 71 * Initialize classes for the WordPress Administration interface
@@ -64,19 +79,24 @@
64 79 return;
65 80 }
66 81
67 82 $this->classes['admin_bulk_edit'] = new ConvertKit_Admin_Bulk_Edit();
83 + $this->classes['admin_cache_plugins'] = new ConvertKit_Admin_Cache_Plugins();
68 84 $this->classes['admin_category'] = new ConvertKit_Admin_Category();
69 - $this->classes['admin_notices'] = new ConvertKit_Admin_Notices();
85 + $this->classes['admin_landing_page'] = new ConvertKit_Admin_Landing_Page();
86 + $this->classes['admin_importer_activecampaign'] = new ConvertKit_Admin_Importer_ActiveCampaign();
87 + $this->classes['admin_importer_aweber'] = new ConvertKit_Admin_Importer_AWeber();
88 + $this->classes['admin_importer_campaignmonitor'] = new ConvertKit_Admin_Importer_CampaignMonitor();
89 + $this->classes['admin_importer_mc4wp'] = new ConvertKit_Admin_Importer_MC4WP();
90 + $this->classes['admin_importer_mailpoet'] = new ConvertKit_Admin_Importer_Mailpoet();
91 + $this->classes['admin_importer_newsletter'] = new ConvertKit_Admin_Importer_Newsletter();
70 92 $this->classes['admin_post'] = new ConvertKit_Admin_Post();
71 93 $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit();
72 - $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources();
73 94 $this->classes['admin_restrict_content'] = new ConvertKit_Admin_Restrict_Content();
74 95 $this->classes['admin_settings'] = new ConvertKit_Admin_Settings();
96 + $this->classes['admin_setup_wizard_landing_page'] = new ConvertKit_Admin_Setup_Wizard_Landing_Page();
75 97 $this->classes['admin_setup_wizard_plugin'] = new ConvertKit_Admin_Setup_Wizard_Plugin();
76 98 $this->classes['admin_setup_wizard_restrict_content'] = new ConvertKit_Admin_Setup_Wizard_Restrict_Content();
77 - $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE();
78 - $this->classes['admin_user'] = new ConvertKit_Admin_User();
79 99
80 100 /**
81 101 * Initialize integration classes for the WordPress Administration interface.
82 102 *
@@ -139,10 +159,11 @@
139 159 if ( is_admin() ) {
140 160 return;
141 161 }
142 162
143 - $this->classes['output'] = new ConvertKit_Output();
144 - $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
163 + $this->classes['cache_plugins'] = new ConvertKit_Cache_Plugins();
164 + $this->classes['output'] = new ConvertKit_Output();
165 + $this->classes['output_broadcasts'] = new ConvertKit_Output_Broadcasts();
145 166
146 167 /**
147 168 * Initialize integration classes for the frontend web site.
148 169 *
@@ -159,29 +180,35 @@
159 180 * @since 1.9.6
160 181 */
161 182 private function initialize_global() {
162 183
163 - $this->classes['ajax'] = new ConvertKit_AJAX();
164 - $this->classes['blocks_convertkit_broadcasts'] = new ConvertKit_Block_Broadcasts();
165 - $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content();
166 - $this->classes['blocks_convertkit_form_trigger'] = new ConvertKit_Block_Form_Trigger();
167 - $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form();
168 - $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product();
169 - $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link();
170 - $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link();
171 - $this->classes['elementor'] = new ConvertKit_Elementor();
172 - $this->classes['gutenberg'] = new ConvertKit_Gutenberg();
173 - $this->classes['review_request'] = new ConvertKit_Review_Request( 'ConvertKit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
174 - $this->classes['preview_output'] = new ConvertKit_Preview_Output();
175 - $this->classes['setup'] = new ConvertKit_Setup();
176 - $this->classes['shortcodes'] = new ConvertKit_Shortcodes();
177 - $this->classes['widgets'] = new ConvertKit_Widgets();
184 + $this->classes['admin_notices'] = new ConvertKit_Admin_Notices();
185 + $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE();
186 + $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources();
187 + $this->classes['blocks_convertkit_broadcasts'] = new ConvertKit_Block_Broadcasts();
188 + $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content();
189 + $this->classes['blocks_convertkit_formtrigger'] = new ConvertKit_Block_Form_Trigger();
190 + $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form();
191 + $this->classes['blocks_convertkit_form_builder'] = new ConvertKit_Block_Form_Builder();
192 + $this->classes['blocks_convertkit_form_builder_field_email'] = new ConvertKit_Block_Form_Builder_Field_Email();
193 + $this->classes['blocks_convertkit_form_builder_field_name'] = new ConvertKit_Block_Form_Builder_Field_Name();
194 + $this->classes['blocks_convertkit_form_builder_field_custom'] = new ConvertKit_Block_Form_Builder_Field_Custom();
195 + $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product();
196 + $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link();
197 + $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link();
198 + $this->classes['pre_publish_action_broadcast_export'] = new ConvertKit_Pre_Publish_Action_Broadcast_Export();
199 + $this->classes['plugin_sidebar_post_settings'] = new ConvertKit_Plugin_Sidebar_Post_Settings();
200 + $this->classes['broadcasts_exporter'] = new ConvertKit_Broadcasts_Exporter();
201 + $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer();
202 + $this->classes['elementor'] = new ConvertKit_Elementor();
203 + $this->classes['gutenberg'] = new ConvertKit_Gutenberg();
204 + $this->classes['media_library'] = new ConvertKit_Media_Library();
205 + $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
206 + $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
207 + $this->classes['preview_output'] = new ConvertKit_Preview_Output();
208 + $this->classes['setup'] = new ConvertKit_Setup();
209 + $this->classes['shortcodes'] = new ConvertKit_Shortcodes();
178 210
179 - // Run the setup's update process on WordPress' init hook.
180 - // Doing this sooner may result in errors with WordPress functions that are not yet
181 - // available to the update routine.
182 - add_action( 'init', array( $this, 'update' ) );
183 -
184 211 /**
185 212 * Initialize integration classes for the frontend web site.
186 213 *
187 214 * @since 1.9.6
@@ -190,16 +217,17 @@
190 217
191 218 }
192 219
193 220 /**
194 - * Runs the Plugin's update routine, which checks if
221 + * Runs the Plugin's initialization and update routines, which checks if
195 222 * the Plugin has just been updated to a newer version,
196 223 * and if so runs any specific processes that might be needed.
197 224 *
198 225 * @since 1.9.7.4
199 226 */
200 - public function update() {
227 + public function setup() {
201 228
229 + $this->get_class( 'setup' )->initialize();
202 230 $this->get_class( 'setup' )->update();
203 231
204 232 }
205 233
@@ -219,15 +247,15 @@
219 247 }
220 248
221 249 // Pro.
222 250 if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) {
223 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/pro/' ) !== false ) {
251 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/pro/' ) !== false ) {
224 252 return true;
225 253 }
226 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/x/' ) !== false ) {
254 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/x/' ) !== false ) {
227 255 return true;
228 256 }
229 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'cornerstone-endpoint' ) !== false ) {
257 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'cornerstone-endpoint' ) !== false ) {
230 258 return true;
231 259 }
232 260 }
233 261
@@ -259,9 +287,9 @@
259 287 return true;
260 288 }
261 289
262 290 // Elementor.
263 - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'elementor' ) {
291 + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'elementor' ) {
264 292 return true;
265 293 }
266 294
267 295 // Kallyas.
@@ -289,9 +317,9 @@
289 317 return true;
290 318 }
291 319
292 320 // Zion Builder.
293 - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'zion_builder_active' ) {
321 + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'zion_builder_active' ) {
294 322 return true;
295 323 }
296 324
297 325 // Assume we're not in the Administration interface.
@@ -343,31 +371,13 @@
343 371 * @return bool Is WP CRON Request
344 372 */
345 373 public function is_cron() {
346 374
347 - if ( ! defined( 'DOING_CRON' ) ) {
348 - return false;
349 - }
350 - if ( ! DOING_CRON ) {
351 - return false;
352 - }
375 + return wp_doing_cron();
353 376
354 - return true;
355 -
356 377 }
357 378
358 379 /**
359 - * Loads plugin textdomain
360 - *
361 - * @since 1.0.0
362 - */
363 - public function load_language_files() {
364 -
365 - load_plugin_textdomain( 'convertkit', false, basename( dirname( CONVERTKIT_PLUGIN_FILE ) ) . '/languages/' ); // @phpstan-ignore-line.
366 -
367 - }
368 -
369 - /**
370 380 * Returns the given class
371 381 *
372 382 * @since 1.9.6
373 383 *
@@ -383,9 +393,9 @@
383 393 $error = new WP_Error(
384 394 'convertkit_get_class',
385 395 sprintf(
386 396 /* translators: %1$s: PHP class name */
387 - __( 'ConvertKit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ),
397 + __( 'Kit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ),
388 398 $name
389 399 )
390 400 );
391 401
@@ -393,9 +403,9 @@
393 403 // Admin UI.
394 404 if ( is_admin() ) {
395 405 wp_die(
396 406 esc_attr( $error->get_error_message() ),
397 - esc_html__( 'ConvertKit Error', 'convertkit' ),
407 + esc_html__( 'Kit Error', 'convertkit' ),
398 408 array(
399 409 'back_link' => true,
400 410 )
401 411 );
@@ -418,9 +428,9 @@
418 428 * @return object Class.
419 429 */
420 430 public static function get_instance() {
421 431
422 - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { // @phpstan-ignore-line.
432 + if ( null === self::$instance ) {
423 433 self::$instance = new self();
424 434 }
425 435
426 436 return self::$instance;