| @@ -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. |
| @@ -63,22 +63,18 @@ | ||
| 63 | 63 | if ( ! is_admin() ) { |
| 64 | 64 | return; |
| 65 | 65 | } |
| 66 | 66 | |
| 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(); | |
| 67 | + $this->classes['admin_category'] = new ConvertKit_Admin_Category(); | |
| 68 | + $this->classes['admin_post'] = new ConvertKit_Admin_Post(); | |
| 69 | + $this->classes['admin_settings'] = new ConvertKit_Admin_Settings(); | |
| 70 | + $this->classes['admin_tinymce'] = new ConvertKit_Admin_TinyMCE(); | |
| 71 | + $this->classes['admin_upgrade'] = new ConvertKit_Admin_Upgrade(); | |
| 72 | + $this->classes['admin_user'] = new ConvertKit_Admin_User(); | |
| 80 | 73 | |
| 74 | + // Run upgrade routine. | |
| 75 | + add_action( 'init', array( $this->classes['admin_upgrade'], 'run' ), 2 ); | |
| 76 | + | |
| 81 | 77 | /** |
| 82 | 78 | * Initialize integration classes for the WordPress Administration interface. |
| 83 | 79 | * |
| 84 | 80 | * @since 1.9.6 |
| @@ -140,10 +136,9 @@ | ||
| 140 | 136 | if ( is_admin() ) { |
| 141 | 137 | return; |
| 142 | 138 | } |
| 143 | 139 | |
| 144 | - $this->classes['output'] = new ConvertKit_Output(); | |
| 145 | - $this->classes['output_restrict_content'] = new ConvertKit_Output_Restrict_Content(); | |
| 140 | + $this->classes['output'] = new ConvertKit_Output(); | |
| 146 | 141 | |
| 147 | 142 | /** |
| 148 | 143 | * Initialize integration classes for the frontend web site. |
| 149 | 144 | * |
| @@ -160,29 +155,16 @@ | ||
| 160 | 155 | * @since 1.9.6 |
| 161 | 156 | */ |
| 162 | 157 | private function initialize_global() { |
| 163 | 158 | |
| 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['elementor'] = new ConvertKit_Elementor(); | |
| 173 | - $this->classes['gutenberg'] = new ConvertKit_Gutenberg(); | |
| 174 | - $this->classes['review_request'] = new ConvertKit_Review_Request( 'ConvertKit', 'convertkit', CONVERTKIT_PLUGIN_PATH ); | |
| 175 | - $this->classes['preview_output'] = new ConvertKit_Preview_Output(); | |
| 176 | - $this->classes['setup'] = new ConvertKit_Setup(); | |
| 177 | - $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 178 | - $this->classes['widgets'] = new ConvertKit_Widgets(); | |
| 159 | + $this->classes['ajax'] = new ConvertKit_AJAX(); | |
| 160 | + $this->classes['blocks_convertkit_content'] = new ConvertKit_Block_Content(); | |
| 161 | + $this->classes['blocks_convertkit_form'] = new ConvertKit_Block_Form(); | |
| 162 | + $this->classes['gutenberg'] = new ConvertKit_Gutenberg(); | |
| 163 | + $this->classes['review_request'] = new ConvertKit_Review_Request( 'ConvertKit', 'convertkit' ); | |
| 164 | + $this->classes['shortcodes'] = new ConvertKit_Shortcodes(); | |
| 165 | + $this->classes['widgets'] = new ConvertKit_Widgets(); | |
| 179 | 166 | |
| 180 | - // Run the setup's update process on WordPress' init hook. | |
| 181 | - // Doing this sooner may result in errors with WordPress functions that are not yet | |
| 182 | - // available to the update routine. | |
| 183 | - add_action( 'init', array( $this, 'update' ) ); | |
| 184 | - | |
| 185 | 167 | /** |
| 186 | 168 | * Initialize integration classes for the frontend web site. |
| 187 | 169 | * |
| 188 | 170 | * @since 1.9.6 |
| @@ -191,21 +173,8 @@ | ||
| 191 | 173 | |
| 192 | 174 | } |
| 193 | 175 | |
| 194 | 176 | /** |
| 195 | - * Runs the Plugin's update routine, which checks if | |
| 196 | - * the Plugin has just been updated to a newer version, | |
| 197 | - * and if so runs any specific processes that might be needed. | |
| 198 | - * | |
| 199 | - * @since 1.9.7.4 | |
| 200 | - */ | |
| 201 | - public function update() { | |
| 202 | - | |
| 203 | - $this->get_class( 'setup' )->update(); | |
| 204 | - | |
| 205 | - } | |
| 206 | - | |
| 207 | - /** | |
| 208 | 177 | * Improved version of WordPress' is_admin(), which includes whether we're |
| 209 | 178 | * editing on the frontend using a Page Builder. |
| 210 | 179 | * |
| 211 | 180 | * @since 1.9.6 |
| @@ -234,65 +203,64 @@ | ||
| 234 | 203 | |
| 235 | 204 | // If the request global exists, check for specific request keys which tell us |
| 236 | 205 | // that we're using a frontend editor. |
| 237 | 206 | // Avada Live. |
| 238 | - // phpcs:disable WordPress.Security.NonceVerification.Recommended | |
| 239 | - if ( array_key_exists( 'fb-edit', $_REQUEST ) ) { | |
| 207 | + if ( array_key_exists( 'fb-edit', $_REQUEST ) ) { // phpcs:ignore | |
| 240 | 208 | return true; |
| 241 | 209 | } |
| 242 | 210 | |
| 243 | 211 | // Beaver Builder. |
| 244 | - if ( array_key_exists( 'fl_builder', $_REQUEST ) ) { | |
| 212 | + if ( array_key_exists( 'fl_builder', $_REQUEST ) ) { // phpcs:ignore | |
| 245 | 213 | return true; |
| 246 | 214 | } |
| 247 | 215 | |
| 248 | 216 | // Brizy. |
| 249 | - if ( array_key_exists( 'brizy-edit', $_REQUEST ) ) { | |
| 217 | + if ( array_key_exists( 'brizy-edit', $_REQUEST ) ) { // phpcs:ignore | |
| 250 | 218 | return true; |
| 251 | 219 | } |
| 252 | 220 | |
| 253 | 221 | // Cornerstone (AJAX). |
| 254 | - if ( array_key_exists( '_cs_nonce', $_REQUEST ) ) { | |
| 222 | + if ( array_key_exists( '_cs_nonce', $_REQUEST ) ) { // phpcs:ignore | |
| 255 | 223 | return true; |
| 256 | 224 | } |
| 257 | 225 | |
| 258 | 226 | // Divi. |
| 259 | - if ( array_key_exists( 'et_fb', $_REQUEST ) ) { | |
| 227 | + if ( array_key_exists( 'et_fb', $_REQUEST ) ) { // phpcs:ignore | |
| 260 | 228 | return true; |
| 261 | 229 | } |
| 262 | 230 | |
| 263 | 231 | // Elementor. |
| 264 | - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'elementor' ) { | |
| 232 | + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'elementor' ) { // phpcs:ignore | |
| 265 | 233 | return true; |
| 266 | 234 | } |
| 267 | 235 | |
| 268 | 236 | // Kallyas. |
| 269 | - if ( array_key_exists( 'zn_pb_edit', $_REQUEST ) ) { | |
| 237 | + if ( array_key_exists( 'zn_pb_edit', $_REQUEST ) ) { // phpcs:ignore | |
| 270 | 238 | return true; |
| 271 | 239 | } |
| 272 | 240 | |
| 273 | 241 | // Oxygen. |
| 274 | - if ( array_key_exists( 'ct_builder', $_REQUEST ) ) { | |
| 242 | + if ( array_key_exists( 'ct_builder', $_REQUEST ) ) { // phpcs:ignore | |
| 275 | 243 | return true; |
| 276 | 244 | } |
| 277 | 245 | |
| 278 | 246 | // Thrive Architect. |
| 279 | - if ( array_key_exists( 'tve', $_REQUEST ) ) { | |
| 247 | + if ( array_key_exists( 'tve', $_REQUEST ) ) { // phpcs:ignore | |
| 280 | 248 | return true; |
| 281 | 249 | } |
| 282 | 250 | |
| 283 | 251 | // Visual Composer. |
| 284 | - if ( array_key_exists( 'vcv-editable', $_REQUEST ) ) { | |
| 252 | + if ( array_key_exists( 'vcv-editable', $_REQUEST ) ) { // phpcs:ignore | |
| 285 | 253 | return true; |
| 286 | 254 | } |
| 287 | 255 | |
| 288 | 256 | // WPBakery Page Builder. |
| 289 | - if ( array_key_exists( 'vc_editable', $_REQUEST ) ) { | |
| 257 | + if ( array_key_exists( 'vc_editable', $_REQUEST ) ) { // phpcs:ignore | |
| 290 | 258 | return true; |
| 291 | 259 | } |
| 292 | 260 | |
| 293 | 261 | // Zion Builder. |
| 294 | - if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'zion_builder_active' ) { | |
| 262 | + if ( array_key_exists( 'action', $_REQUEST ) && sanitize_text_field( $_REQUEST['action'] ) === 'zion_builder_active' ) { // phpcs:ignore | |
| 295 | 263 | return true; |
| 296 | 264 | } |
| 297 | 265 | |
| 298 | 266 | // Assume we're not in the Administration interface. |
| @@ -306,12 +274,10 @@ | ||
| 306 | 274 | * @since 1.9.6 |
| 307 | 275 | * |
| 308 | 276 | * @param bool $is_admin_or_frontend_editor Is WordPress Administration / Frontend Editor request. |
| 309 | 277 | */ |
| 310 | - $is_admin_or_frontend_editor = apply_filters( 'convertkit_is_admin_or_frontend_editor', $is_admin_or_frontend_editor ); | |
| 278 | + $is_admin_or_frontend_editor = apply_filters( 'convertkit_is_admin_or_frontend_editor', $is_admin_or_frontend_editor ); // phpcs:ignore | |
| 311 | 279 | |
| 312 | - // phpcs:enable | |
| 313 | - | |
| 314 | 280 | // Return filtered result. |
| 315 | 281 | return $is_admin_or_frontend_editor; |
| 316 | 282 | |
| 317 | 283 | } |
| @@ -356,18 +322,15 @@ | ||
| 356 | 322 | |
| 357 | 323 | } |
| 358 | 324 | |
| 359 | 325 | /** |
| 360 | - * Loads the plugin's translated strings, if available. | |
| 326 | + * Loads plugin textdomain | |
| 361 | 327 | * |
| 362 | 328 | * @since 1.0.0 |
| 363 | 329 | */ |
| 364 | 330 | public function load_language_files() { |
| 365 | 331 | |
| 366 | - // If the .mo file for a given language is available in WP_LANG_DIR/convertkit | |
| 367 | - // i.e. it's available as a translation at https://translate.wordpress.org/projects/wp-plugins/convertkit/, | |
| 368 | - // it will be used instead of the .mo file in convertkit/languages. | |
| 369 | - load_plugin_textdomain( 'convertkit', false, 'convertkit/languages' ); | |
| 332 | + load_plugin_textdomain( 'convertkit', false, basename( dirname( CONVERTKIT_PLUGIN_FILE ) ) . '/languages/' ); // @phpstan-ignore-line. | |
| 370 | 333 | |
| 371 | 334 | } |
| 372 | 335 | |
| 373 | 336 | /** |
| @@ -422,9 +385,9 @@ | ||
| 422 | 385 | * @return object Class. |
| 423 | 386 | */ |
| 424 | 387 | public static function get_instance() { |
| 425 | 388 | |
| 426 | - if ( null === self::$instance ) { | |
| 389 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof self ) ) { // @phpstan-ignore-line. | |
| 427 | 390 | self::$instance = new self(); |
| 428 | 391 | } |
| 429 | 392 | |
| 430 | 393 | return self::$instance; |