| @@ -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. |
| @@ -64,9 +64,11 @@ | ||
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | $this->classes['admin_bulk_edit'] = new ConvertKit_Admin_Bulk_Edit(); |
| 68 | + $this->classes['admin_cache_plugins'] = new ConvertKit_Admin_Cache_Plugins(); | |
| 68 | 69 | $this->classes['admin_category'] = new ConvertKit_Admin_Category(); |
| 70 | + $this->classes['admin_landing_page'] = new ConvertKit_Admin_Landing_Page(); | |
| 69 | 71 | $this->classes['admin_notices'] = new ConvertKit_Admin_Notices(); |
| 70 | 72 | $this->classes['admin_post'] = new ConvertKit_Admin_Post(); |
| 71 | 73 | $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit(); |
| 72 | 74 | $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources(); |
| @@ -71,8 +73,9 @@ | ||
| 71 | 73 | $this->classes['admin_quick_edit'] = new ConvertKit_Admin_Quick_Edit(); |
| 72 | 74 | $this->classes['admin_refresh_resources'] = new ConvertKit_Admin_Refresh_Resources(); |
| 73 | 75 | $this->classes['admin_restrict_content'] = new ConvertKit_Admin_Restrict_Content(); |
| 74 | 76 | $this->classes['admin_settings'] = new ConvertKit_Admin_Settings(); |
| 77 | + $this->classes['admin_setup_wizard_landing_page'] = new ConvertKit_Admin_Setup_Wizard_Landing_Page(); | |
| 75 | 78 | $this->classes['admin_setup_wizard_plugin'] = new ConvertKit_Admin_Setup_Wizard_Plugin(); |
| 76 | 79 | $this->classes['admin_setup_wizard_restrict_content'] = new ConvertKit_Admin_Setup_Wizard_Restrict_Content(); |
| 77 | 80 | $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE(); |
| 78 | 81 | $this->classes['admin_user'] = new ConvertKit_Admin_User(); |
| @@ -139,10 +142,11 @@ | ||
| 139 | 142 | if ( is_admin() ) { |
| 140 | 143 | return; |
| 141 | 144 | } |
| 142 | 145 | |
| 143 | - $this->classes['output'] = new ConvertKit_Output(); | |
| 144 | - $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 146 | + $this->classes['cache_plugins'] = new ConvertKit_Cache_Plugins(); | |
| 147 | + $this->classes['output'] = new ConvertKit_Output(); | |
| 148 | + $this->classes['output_broadcasts'] = new ConvertKit_Output_Broadcasts(); | |
| 145 | 149 | |
| 146 | 150 | /** |
| 147 | 151 | * Initialize integration classes for the frontend web site. |
| 148 | 152 | * |
| @@ -159,28 +163,34 @@ | ||
| 159 | 163 | * @since 1.9.6 |
| 160 | 164 | */ |
| 161 | 165 | private function initialize_global() { |
| 162 | 166 | |
| 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(); | |
| 167 | + $this->classes['ajax'] = new ConvertKit_AJAX(); | |
| 168 | + $this->classes['blocks_convertkit_broadcasts'] = new ConvertKit_Block_Broadcasts(); | |
| 169 | + $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content(); | |
| 170 | + $this->classes['blocks_convertkit_formtrigger'] = new ConvertKit_Block_Form_Trigger(); | |
| 171 | + $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form(); | |
| 172 | + $this->classes['blocks_convertkit_product'] = new ConvertKit_Block_Product(); | |
| 173 | + $this->classes['block_formatter_form_link'] = new ConvertKit_Block_Formatter_Form_Link(); | |
| 174 | + $this->classes['block_formatter_product_link'] = new ConvertKit_Block_Formatter_Product_Link(); | |
| 175 | + $this->classes['pre_publish_action_broadcast_export'] = new ConvertKit_Pre_Publish_Action_Broadcast_Export(); | |
| 176 | + $this->classes['broadcasts_exporter'] = new ConvertKit_Broadcasts_Exporter(); | |
| 177 | + $this->classes['broadcasts_importer'] = new ConvertKit_Broadcasts_Importer(); | |
| 178 | + $this->classes['divi'] = new ConvertKit_Divi(); | |
| 179 | + $this->classes['elementor'] = new ConvertKit_Elementor(); | |
| 180 | + $this->classes['gutenberg'] = new ConvertKit_Gutenberg(); | |
| 181 | + $this->classes['media_library'] = new ConvertKit_Media_Library(); | |
| 182 | + $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 183 | + $this->classes['review_request'] = new ConvertKit_Review_Request( 'Kit', 'convertkit', CONVERTKIT_PLUGIN_PATH ); | |
| 184 | + $this->classes['preview_output'] = new ConvertKit_Preview_Output(); | |
| 185 | + $this->classes['setup'] = new ConvertKit_Setup(); | |
| 186 | + $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 187 | + $this->classes['widgets'] = new ConvertKit_Widgets(); | |
| 178 | 188 | |
| 179 | 189 | // Run the setup's update process on WordPress' init hook. |
| 180 | 190 | // Doing this sooner may result in errors with WordPress functions that are not yet |
| 181 | 191 | // available to the update routine. |
| 182 | - add_action( 'init', array( $this, 'update' ) ); | |
| 192 | + add_action( 'init', array( $this, 'init' ) ); | |
| 183 | 193 | |
| 184 | 194 | /** |
| 185 | 195 | * Initialize integration classes for the frontend web site. |
| 186 | 196 | * |
| @@ -190,16 +200,17 @@ | ||
| 190 | 200 | |
| 191 | 201 | } |
| 192 | 202 | |
| 193 | 203 | /** |
| 194 | - * Runs the Plugin's update routine, which checks if | |
| 204 | + * Runs the Plugin's initialization and update routines, which checks if | |
| 195 | 205 | * the Plugin has just been updated to a newer version, |
| 196 | 206 | * and if so runs any specific processes that might be needed. |
| 197 | 207 | * |
| 198 | 208 | * @since 1.9.7.4 |
| 199 | 209 | */ |
| 200 | - public function update() { | |
| 210 | + public function init() { | |
| 201 | 211 | |
| 212 | + $this->get_class( 'setup' )->initialize(); | |
| 202 | 213 | $this->get_class( 'setup' )->update(); |
| 203 | 214 | |
| 204 | 215 | } |
| 205 | 216 | |
| @@ -355,15 +366,18 @@ | ||
| 355 | 366 | |
| 356 | 367 | } |
| 357 | 368 | |
| 358 | 369 | /** |
| 359 | - * Loads plugin textdomain | |
| 370 | + * Loads the plugin's translated strings, if available. | |
| 360 | 371 | * |
| 361 | 372 | * @since 1.0.0 |
| 362 | 373 | */ |
| 363 | 374 | public function load_language_files() { |
| 364 | 375 | |
| 365 | - load_plugin_textdomain( 'convertkit', false, basename( dirname( CONVERTKIT_PLUGIN_FILE ) ) . '/languages/' ); // @phpstan-ignore-line. | |
| 376 | + // If the .mo file for a given language is available in WP_LANG_DIR/convertkit | |
| 377 | + // i.e. it's available as a translation at https://translate.wordpress.org/projects/wp-plugins/convertkit/, | |
| 378 | + // it will be used instead of the .mo file in convertkit/languages. | |
| 379 | + load_plugin_textdomain( 'convertkit', false, 'convertkit/languages' ); | |
| 366 | 380 | |
| 367 | 381 | } |
| 368 | 382 | |
| 369 | 383 | /** |
| @@ -383,9 +397,9 @@ | ||
| 383 | 397 | $error = new WP_Error( |
| 384 | 398 | 'convertkit_get_class', |
| 385 | 399 | sprintf( |
| 386 | 400 | /* translators: %1$s: PHP class name */ |
| 387 | - __( 'ConvertKit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ), | |
| 401 | + __( 'Kit Error: Could not load Plugin class <strong>%1$s</strong>', 'convertkit' ), | |
| 388 | 402 | $name |
| 389 | 403 | ) |
| 390 | 404 | ); |
| 391 | 405 | |
| @@ -393,9 +407,9 @@ | ||
| 393 | 407 | // Admin UI. |
| 394 | 408 | if ( is_admin() ) { |
| 395 | 409 | wp_die( |
| 396 | 410 | esc_attr( $error->get_error_message() ), |
| 397 | - esc_html__( 'ConvertKit Error', 'convertkit' ), | |
| 411 | + esc_html__( 'Kit Error', 'convertkit' ), | |
| 398 | 412 | array( |
| 399 | 413 | 'back_link' => true, |
| 400 | 414 | ) |
| 401 | 415 | ); |
| @@ -418,9 +432,9 @@ | ||
| 418 | 432 | * @return object Class. |
| 419 | 433 | */ |
| 420 | 434 | public static function get_instance() { |
| 421 | 435 | |
| 422 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { // @phpstan-ignore-line. | |
| 436 | + if ( null === self::$instance ) { | |
| 423 | 437 | self::$instance = new self(); |
| 424 | 438 | } |
| 425 | 439 | |
| 426 | 440 | return self::$instance; |