| @@ -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 |
| @@ -66,18 +81,22 @@ | ||
| 66 | 81 | |
| 67 | 82 | $this->classes['admin_bulk_edit'] = new ConvertKit_Admin_Bulk_Edit(); |
| 68 | 83 | $this->classes['admin_cache_plugins'] = new ConvertKit_Admin_Cache_Plugins(); |
| 69 | 84 | $this->classes['admin_category'] = new ConvertKit_Admin_Category(); |
| 70 | - $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(); | |
| 71 | 92 | $this->classes['admin_post'] = new ConvertKit_Admin_Post(); |
| 72 | 93 | $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit(); |
| 73 | - $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources(); | |
| 74 | 94 | $this->classes['admin_restrict_content'] = new ConvertKit_Admin_Restrict_Content(); |
| 75 | 95 | $this->classes['admin_settings'] = new ConvertKit_Admin_Settings(); |
| 96 | + $this->classes['admin_setup_wizard_landing_page'] = new ConvertKit_Admin_Setup_Wizard_Landing_Page(); | |
| 76 | 97 | $this->classes['admin_setup_wizard_plugin'] = new ConvertKit_Admin_Setup_Wizard_Plugin(); |
| 77 | 98 | $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(); | |
| 80 | 99 | |
| 81 | 100 | /** |
| 82 | 101 | * Initialize integration classes for the WordPress Administration interface. |
| 83 | 102 | * |
| @@ -140,10 +159,11 @@ | ||
| 140 | 159 | if ( is_admin() ) { |
| 141 | 160 | return; |
| 142 | 161 | } |
| 143 | 162 | |
| 144 | - $this->classes['output'] = new ConvertKit_Output(); | |
| 145 | - $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(); | |
| 146 | 166 | |
| 147 | 167 | /** |
| 148 | 168 | * Initialize integration classes for the frontend web site. |
| 149 | 169 | * |
| @@ -160,31 +180,34 @@ | ||
| 160 | 180 | * @since 1.9.6 |
| 161 | 181 | */ |
| 162 | 182 | private function initialize_global() { |
| 163 | 183 | |
| 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(); | |
| 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['broadcasts_exporter'] = new ConvertKit_Broadcasts_Exporter(); | |
| 200 | + $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer(); | |
| 201 | + $this->classes['elementor'] = new ConvertKit_Elementor(); | |
| 202 | + $this->classes['gutenberg'] = new ConvertKit_Gutenberg(); | |
| 203 | + $this->classes['media_library'] = new ConvertKit_Media_Library(); | |
| 204 | + $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 205 | + $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH ); | |
| 206 | + $this->classes['preview_output'] = new ConvertKit_Preview_Output(); | |
| 207 | + $this->classes['setup'] = new ConvertKit_Setup(); | |
| 208 | + $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 181 | 209 | |
| 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 | 210 | /** |
| 188 | 211 | * Initialize integration classes for the frontend web site. |
| 189 | 212 | * |
| 190 | 213 | * @since 1.9.6 |
| @@ -193,16 +216,17 @@ | ||
| 193 | 216 | |
| 194 | 217 | } |
| 195 | 218 | |
| 196 | 219 | /** |
| 197 | - * Runs the Plugin's update routine, which checks if | |
| 220 | + * Runs the Plugin's initialization and update routines, which checks if | |
| 198 | 221 | * the Plugin has just been updated to a newer version, |
| 199 | 222 | * and if so runs any specific processes that might be needed. |
| 200 | 223 | * |
| 201 | 224 | * @since 1.9.7.4 |
| 202 | 225 | */ |
| 203 | - public function update() { | |
| 226 | + public function setup() { | |
| 204 | 227 | |
| 228 | + $this->get_class( 'setup' )->initialize(); | |
| 205 | 229 | $this->get_class( 'setup' )->update(); |
| 206 | 230 | |
| 207 | 231 | } |
| 208 | 232 | |
| @@ -222,15 +246,15 @@ | ||
| 222 | 246 | } |
| 223 | 247 | |
| 224 | 248 | // Pro. |
| 225 | 249 | if ( array_key_exists( 'REQUEST_URI', $_SERVER ) ) { |
| 226 | - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/pro/' ) !== false ) { | |
| 250 | + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/pro/' ) !== false ) { | |
| 227 | 251 | return true; |
| 228 | 252 | } |
| 229 | - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), '/x/' ) !== false ) { | |
| 253 | + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), '/x/' ) !== false ) { | |
| 230 | 254 | return true; |
| 231 | 255 | } |
| 232 | - if ( strpos( sanitize_text_field( $_SERVER['REQUEST_URI'] ), 'cornerstone-endpoint' ) !== false ) { | |
| 256 | + if ( strpos( sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ), 'cornerstone-endpoint' ) !== false ) { | |
| 233 | 257 | return true; |
| 234 | 258 | } |
| 235 | 259 | } |
| 236 | 260 | |
| @@ -262,9 +286,9 @@ | ||
| 262 | 286 | return true; |
| 263 | 287 | } |
| 264 | 288 | |
| 265 | 289 | // Elementor. |
| 266 | - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'elementor' ) { | |
| 290 | + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'elementor' ) { | |
| 267 | 291 | return true; |
| 268 | 292 | } |
| 269 | 293 | |
| 270 | 294 | // Kallyas. |
| @@ -292,9 +316,9 @@ | ||
| 292 | 316 | return true; |
| 293 | 317 | } |
| 294 | 318 | |
| 295 | 319 | // Zion Builder. |
| 296 | - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'zion_builder_active' ) { | |
| 320 | + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( wp_unslash( $_REQUEST['action'] ) ) === 'zion_builder_active' ) { | |
| 297 | 321 | return true; |
| 298 | 322 | } |
| 299 | 323 | |
| 300 | 324 | // Assume we're not in the Administration interface. |
| @@ -346,34 +370,13 @@ | ||
| 346 | 370 | * @return bool Is WP CRON Request |
| 347 | 371 | */ |
| 348 | 372 | public function is_cron() { |
| 349 | 373 | |
| 350 | - if ( ! defined( 'DOING_CRON' ) ) { | |
| 351 | - return false; | |
| 352 | - } | |
| 353 | - if ( ! DOING_CRON ) { | |
| 354 | - return false; | |
| 355 | - } | |
| 374 | + return wp_doing_cron(); | |
| 356 | 375 | |
| 357 | - return true; | |
| 358 | - | |
| 359 | 376 | } |
| 360 | 377 | |
| 361 | 378 | /** |
| 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 | 379 | * Returns the given class |
| 377 | 380 | * |
| 378 | 381 | * @since 1.9.6 |
| 379 | 382 | * |
| @@ -389,9 +392,9 @@ | ||
| 389 | 392 | $error = new WP_Error( |
| 390 | 393 | 'convertkit_get_class', |
| 391 | 394 | sprintf( |
| 392 | 395 | /* translators: %1$s: PHP class name */ |
| 393 | - __( 'ConvertKit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ), | |
| 396 | + __( 'Kit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ), | |
| 394 | 397 | $name |
| 395 | 398 | ) |
| 396 | 399 | ); |
| 397 | 400 | |
| @@ -399,9 +402,9 @@ | ||
| 399 | 402 | // Admin UI. |
| 400 | 403 | if ( is_admin() ) { |
| 401 | 404 | wp_die( |
| 402 | 405 | esc_attr( $error->get_error_message() ), |
| 403 | - esc_html__( 'ConvertKit Error', 'convertkit' ), | |
| 406 | + esc_html__( 'Kit Error', 'convertkit' ), | |
| 404 | 407 | array( |
| 405 | 408 | 'back_link' => true, |
| 406 | 409 | ) |
| 407 | 410 | ); |