PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 3.4.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v3.4.2
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 | includes/class-wp-convertkit.php +127 -72 2.3.2 → 3.4.2 View file →
@@ -39,18 +39,34 @@
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();
48 66 $this->initialize_global();
67 + $this->initialize_mcp();
49 68
50 - // Load language files.
51 - add_action( 'init', array( $this, 'load_language_files' ) );
52 -
53 69 }
54 70
55 71 /**
56 72 * Initialize classes for the WordPress Administration interface
@@ -63,21 +79,27 @@
63 79 if ( ! is_admin() ) {
64 80 return;
65 81 }
66 82
67 - $this->classes['admin_bulk_edit'] = new ConvertKit_Admin_Bulk_Edit();
68 - $this->classes['admin_cache_plugins'] = new ConvertKit_Admin_Cache_Plugins();
69 - $this->classes['admin_category'] = new ConvertKit_Admin_Category();
70 - $this->classes['admin_notices'] = new ConvertKit_Admin_Notices();
71 - $this->classes['admin_post'] = new ConvertKit_Admin_Post();
72 - $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit();
73 - $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources();
74 - $this->classes['admin_restrict_content'] = new ConvertKit_Admin_Restrict_Content();
75 - $this->classes['admin_settings'] = new ConvertKit_Admin_Settings();
76 - $this->classes['admin_setup_wizard_plugin'] = new ConvertKit_Admin_Setup_Wizard_Plugin();
77 - $this->classes['admin_setup_wizard_restrict_content'] = new ConvertKit_Admin_Setup_Wizard_Restrict_Content();
78 - $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE();
79 - $this->classes['admin_user'] = new ConvertKit_Admin_User();
83 + $this->classes['admin_bulk_edit'] = new ConvertKit_Admin_Bulk_Edit();
84 + $this->classes['admin_cache_plugins'] = new ConvertKit_Admin_Cache_Plugins();
85 + $this->classes['admin_category'] = new ConvertKit_Admin_Category();
86 + $this->classes['admin_landing_page'] = new ConvertKit_Admin_Landing_Page();
87 + $this->classes['admin_legacy_resource_notice'] = new ConvertKit_Admin_Legacy_Resource_Notice();
88 + $this->classes['admin_importer_activecampaign'] = new ConvertKit_Admin_Importer_ActiveCampaign();
89 + $this->classes['admin_importer_aweber'] = new ConvertKit_Admin_Importer_AWeber();
90 + $this->classes['admin_importer_campaignmonitor'] = new ConvertKit_Admin_Importer_CampaignMonitor();
91 + $this->classes['admin_importer_convertkit_legacy_forms'] = new ConvertKit_Admin_Importer_ConvertKit_Legacy_Forms();
92 + $this->classes['admin_importer_mc4wp'] = new ConvertKit_Admin_Importer_MC4WP();
93 + $this->classes['admin_importer_mailpoet'] = new ConvertKit_Admin_Importer_Mailpoet();
94 + $this->classes['admin_importer_newsletter'] = new ConvertKit_Admin_Importer_Newsletter();
95 + $this->classes['admin_post'] = new ConvertKit_Admin_Post();
96 + $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit();
97 + $this->classes['admin_restrict_content'] = new ConvertKit_Admin_Restrict_Content();
98 + $this->classes['admin_settings'] = new ConvertKit_Admin_Settings();
99 + $this->classes['admin_setup_wizard_landing_page'] = new ConvertKit_Admin_Setup_Wizard_Landing_Page();
100 + $this->classes['admin_setup_wizard_plugin'] = new ConvertKit_Admin_Setup_Wizard_Plugin();
101 + $this->classes['admin_setup_wizard_restrict_content'] = new ConvertKit_Admin_Setup_Wizard_Restrict_Content();
80 102
81 103 /**
82 104 * Initialize integration classes for the WordPress Administration interface.
83 105 *
@@ -140,10 +162,11 @@
140 162 if ( is_admin() ) {
141 163 return;
142 164 }
143 165
144 - $this->classes['output'] = new ConvertKit_Output();
145 - $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
166 + $this->classes['cache_plugins'] = new ConvertKit_Cache_Plugins();
167 + $this->classes['output'] = new ConvertKit_Output();
168 + $this->classes['output_broadcasts'] = new ConvertKit_Output_Broadcasts();
146 169
147 170 /**
148 171 * Initialize integration classes for the frontend web site.
149 172 *
@@ -160,31 +183,37 @@
160 183 * @since 1.9.6
161 184 */
162 185 private function initialize_global() {
163 186
164 - $this->classes['ajax'] = new ConvertKit_AJAX();
165 - $this->classes['blocks_convertkit_broadcasts'] = new ConvertKit_Block_Broadcasts();
166 - $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content();
167 - $this->classes['blocks_convertkit_formtrigger'] = new ConvertKit_Block_Form_Trigger();
168 - $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form();
169 - $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product();
170 - $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link();
171 - $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link();
172 - $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer();
173 - $this->classes['elementor'] = new ConvertKit_Elementor();
174 - $this->classes['gutenberg'] = new ConvertKit_Gutenberg();
175 - $this->classes['media_library'] = new ConvertKit_Media_Library();
176 - $this->classes['review_request'] = new ConvertKit_Review_Request( 'ConvertKit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
177 - $this->classes['preview_output'] = new ConvertKit_Preview_Output();
178 - $this->classes['setup'] = new ConvertKit_Setup();
179 - $this->classes['shortcodes'] = new ConvertKit_Shortcodes();
180 - $this->classes['widgets'] = new ConvertKit_Widgets();
187 + $this->classes['admin_notices'] = new ConvertKit_Admin_Notices();
188 + $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE();
189 + $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources();
190 + $this->classes['blocks_convertkit_broadcasts'] = new ConvertKit_Block_Broadcasts();
191 + $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content();
192 + $this->classes['blocks_convertkit_formtrigger'] = new ConvertKit_Block_Form_Trigger();
193 + $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form();
194 + $this->classes['blocks_convertkit_form_builder'] = new ConvertKit_Block_Form_Builder();
195 + $this->classes['blocks_convertkit_form_builder_field_email'] = new ConvertKit_Block_Form_Builder_Field_Email();
196 + $this->classes['blocks_convertkit_form_builder_field_name'] = new ConvertKit_Block_Form_Builder_Field_Name();
197 + $this->classes['blocks_convertkit_form_builder_field_custom'] = new ConvertKit_Block_Form_Builder_Field_Custom();
198 + $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product();
199 + $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link();
200 + $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link();
201 + $this->classes['pre_publish_action_broadcast_export'] = new ConvertKit_Pre_Publish_Action_Broadcast_Export();
202 + $this->classes['plugin_sidebar_post_settings'] = new ConvertKit_Plugin_Sidebar_Post_Settings();
203 + $this->classes['broadcasts_exporter'] = new ConvertKit_Broadcasts_Exporter();
204 + $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer();
205 + $this->classes['elementor'] = new ConvertKit_Elementor();
206 + $this->classes['gutenberg'] = new ConvertKit_Gutenberg();
207 + $this->classes['mcp'] = new ConvertKit_MCP();
208 + $this->classes['media_library'] = new ConvertKit_Media_Library();
209 + $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content();
210 + $this->classes['restrict_content_cache'] = new ConvertKit_Restrict_Content_Cache();
211 + $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH );
212 + $this->classes['preview_output'] = new ConvertKit_Preview_Output();
213 + $this->classes['setup'] = new ConvertKit_Setup();
214 + $this->classes['shortcodes'] = new ConvertKit_Shortcodes();
181 215
182 - // Run the setup's update process on WordPress' init hook.
183 - // Doing this sooner may result in errors with WordPress functions that are not yet
184 - // available to the update routine.
185 - add_action( 'init', array( $this, 'update' ) );
186 -
187 216 /**
188 217 * Initialize integration classes for the frontend web site.
189 218 *
190 219 * @since 1.9.6
@@ -193,16 +222,63 @@
193 222
194 223 }
195 224
196 225 /**
197 - * Runs the Plugin's update routine, which checks if
226 + * Initializes the MCP server if enabled in the Plugin's settings.
227 + *
228 + * @since 3.4.0
229 + */
230 + public function initialize_mcp() {
231 +
232 + // Bail if the MCP server is not enabled.
233 + $settings = new ConvertKit_Settings_MCP();
234 + if ( ! $settings->enabled() ) {
235 + return;
236 + }
237 +
238 + // Bail if the Abilities API is unavailable (WordPress < 6.9).
239 + if ( ! function_exists( 'wp_register_ability' ) ) {
240 + return;
241 + }
242 +
243 + // Bail if PHP 7.4+ is not installed, as this is required for the MCP Adapter classes.
244 + if ( version_compare( PHP_VERSION, '7.4', '<' ) ) {
245 + return;
246 + }
247 +
248 + // Load MCP Adapter if another Plugin hasn't already loaded it.
249 + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) {
250 + // Bail if the WordPress MCP Adapter autoloader is missing.
251 + if ( ! file_exists( CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php' ) ) {
252 + return;
253 + }
254 +
255 + // Load MCP Adapter.
256 + require_once CONVERTKIT_PLUGIN_PATH . '/vendor/autoload.php';
257 +
258 + // Bail if the MCP Adapter class doesn't exist - something went wrong with the autoloader.
259 + if ( ! class_exists( 'WP\\MCP\\Core\\McpAdapter' ) ) { // @phpstan-ignore-line
260 + return;
261 + }
262 + }
263 +
264 + // Bootstrap the MCP Adapter, per WordPress/mcp-adapter's recommended
265 + // integration pattern.
266 + // @see https://github.com/WordPress/mcp-adapter#using-mcp-adapter-in-your-plugin.
267 + \WP\MCP\Core\McpAdapter::instance();
268 +
269 + }
270 +
271 + /**
272 + * Runs the Plugin's initialization and update routines, which checks if
198 273 * the Plugin has just been updated to a newer version,
199 274 * and if so runs any specific processes that might be needed.
200 275 *
201 276 * @since 1.9.7.4
202 277 */
203 - public function update() {
278 + public function setup() {
204 279
280 + $this->get_class( 'setup' )->initialize();
205 281 $this->get_class( 'setup' )->update();
206 282
207 283 }
208 284
@@ -222,15 +298,15 @@
222 298 }
223 299
224 300 // Pro.
225 301 if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) {
226 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/pro/' ) !== false ) {
302 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/pro/' ) !== false ) {
227 303 return true;
228 304 }
229 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/x/' ) !== false ) {
305 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/x/' ) !== false ) {
230 306 return true;
231 307 }
232 - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'cornerstone-endpoint' ) !== false ) {
308 + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'cornerstone-endpoint' ) !== false ) {
233 309 return true;
234 310 }
235 311 }
236 312
@@ -262,9 +338,9 @@
262 338 return true;
263 339 }
264 340
265 341 // Elementor.
266 - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'elementor' ) {
342 + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'elementor' ) {
267 343 return true;
268 344 }
269 345
270 346 // Kallyas.
@@ -292,9 +368,9 @@
292 368 return true;
293 369 }
294 370
295 371 // Zion Builder.
296 - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'zion_builder_active' ) {
372 + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'zion_builder_active' ) {
297 373 return true;
298 374 }
299 375
300 376 // Assume we're not in the Administration interface.
@@ -346,34 +422,13 @@
346 422 * @return bool Is WP CRON Request
347 423 */
348 424 public function is_cron() {
349 425
350 - if ( ! defined( 'DOING_CRON' ) ) {
351 - return false;
352 - }
353 - if ( ! DOING_CRON ) {
354 - return false;
355 - }
426 + return wp_doing_cron();
356 427
357 - return true;
358 -
359 428 }
360 429
361 430 /**
362 - * Loads the plugin's translated strings, if available.
363 - *
364 - * @since 1.0.0
365 - */
366 - public function load_language_files() {
367 -
368 - // If the .mo file for a given language is available in WP_LANG_DIR/convertkit
369 - // i.e. it's available as a translation at https://translate.wordpress.org/projects/wp-plugins/convertkit/,
370 - // it will be used instead of the .mo file in convertkit/languages.
371 - load_plugin_textdomain( 'convertkit', false, 'convertkit/languages' );
372 -
373 - }
374 -
375 - /**
376 431 * Returns the given class
377 432 *
378 433 * @since 1.9.6
379 434 *
@@ -389,9 +444,9 @@
389 444 $error = new WP_Error(
390 445 'convertkit_get_class',
391 446 sprintf(
392 447 /* translators: %1$s: PHP class name */
393 - __( 'ConvertKit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ),
448 + __( 'Kit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ),
394 449 $name
395 450 )
396 451 );
397 452
@@ -399,9 +454,9 @@
399 454 // Admin UI.
400 455 if ( is_admin() ) {
401 456 wp_die(
402 457 esc_attr( $error->get_error_message() ),
403 - esc_html__( 'ConvertKit Error', 'convertkit' ),
458 + esc_html__( 'Kit Error', 'convertkit' ),
404 459 array(
405 460 'back_link' => true,
406 461 )
407 462 );