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