PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.1
Elementor Website Builder – more than just a page builder v3.3.1
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/plugin.php +111 -201 4.1.53.3.1 View file →
@@ -1,12 +1,11 @@
1 1 <?php
2 -
3 2 namespace Elementor;
4 3
5 -use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 4 use Elementor\Core\Wp_Api;
7 5 use Elementor\Core\Admin\Admin;
8 6 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
7 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
9 8 use Elementor\Core\Common\App as CommonApp;
10 9 use Elementor\Core\Debug\Inspector;
11 10 use Elementor\Core\Documents_Manager;
12 11 use Elementor\Core\Experiments\Manager as Experiments_Manager;
@@ -14,10 +13,12 @@
14 13 use Elementor\Core\Editor\Editor;
15 14 use Elementor\Core\Files\Manager as Files_Manager;
16 15 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 16 use Elementor\Core\Modules_Manager;
17 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 18 use Elementor\Core\Settings\Manager as Settings_Manager;
19 19 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
20 +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
20 21 use Elementor\Modules\History\Revisions_Manager;
21 22 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 23 use Elementor\Core\Logger\Manager as Log_Manager;
23 24 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
@@ -22,11 +23,10 @@
22 23 use Elementor\Core\Logger\Manager as Log_Manager;
23 24 use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 25 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 26 use Elementor\Data\Manager as Data_Manager;
26 -use Elementor\Data\V2\Manager as Data_Manager_V2;
27 -use Elementor\Core\Files\Uploads_Manager;
28 -use WP_REST_Request;
27 +use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools;
28 +use Elementor\Core\Files\Uploads_Manager as Uploads_Manager;
29 29
30 30 if ( ! defined( 'ABSPATH' ) ) {
31 31 exit;
32 32 }
@@ -40,16 +40,8 @@
40 40 * @since 1.0.0
41 41 */
42 42 class Plugin {
43 43
44 - const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ];
45 -
46 - private const SANITIZABLE_META_KEYS = [
47 - '_elementor_data',
48 - '_elementor_page_settings',
49 - '_elementor_global_class_data',
50 - ];
51 -
52 44 /**
53 45 * Instance.
54 46 *
55 47 * Holds the plugin instance.
@@ -64,10 +56,9 @@
64 56
65 57 /**
66 58 * Database.
67 59 *
68 - * Holds the plugin database handler which is responsible for communicating
69 - * with the database.
60 + * Holds the plugin database.
70 61 *
71 62 * @since 1.0.0
72 63 * @access public
73 64 *
@@ -75,12 +66,24 @@
75 66 */
76 67 public $db;
77 68
78 69 /**
70 + * Ajax Manager.
71 + *
72 + * Holds the plugin ajax manager.
73 + *
74 + * @since 1.9.0
75 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
76 + * @access public
77 + *
78 + * @var Ajax
79 + */
80 + public $ajax;
81 +
82 + /**
79 83 * Controls manager.
80 84 *
81 - * Holds the plugin controls manager handler is responsible for registering
82 - * and initializing controls.
85 + * Holds the plugin controls manager.
83 86 *
84 87 * @since 1.0.0
85 88 * @access public
86 89 *
@@ -100,8 +103,20 @@
100 103 */
101 104 public $documents;
102 105
103 106 /**
107 + * Schemes manager.
108 + *
109 + * Holds the plugin schemes manager.
110 + *
111 + * @since 1.0.0
112 + * @access public
113 + *
114 + * @var Schemes_Manager
115 + */
116 + public $schemes_manager;
117 +
118 + /**
104 119 * Elements manager.
105 120 *
106 121 * Holds the plugin elements manager.
107 122 *
@@ -114,10 +129,9 @@
114 129
115 130 /**
116 131 * Widgets manager.
117 132 *
118 - * Holds the plugin widgets manager which is responsible for registering and
119 - * initializing widgets.
133 + * Holds the plugin widgets manager.
120 134 *
121 135 * @since 1.0.0
122 136 * @access public
123 137 *
@@ -127,10 +141,9 @@
127 141
128 142 /**
129 143 * Revisions manager.
130 144 *
131 - * Holds the plugin revisions manager which handles history and revisions
132 - * functionality.
145 + * Holds the plugin revisions manager.
133 146 *
134 147 * @since 1.0.0
135 148 * @access public
136 149 *
@@ -140,10 +153,9 @@
140 153
141 154 /**
142 155 * Images manager.
143 156 *
144 - * Holds the plugin images manager which is responsible for retrieving image
145 - * details.
157 + * Holds the plugin images manager.
146 158 *
147 159 * @since 2.9.0
148 160 * @access public
149 161 *
@@ -153,10 +165,9 @@
153 165
154 166 /**
155 167 * Maintenance mode.
156 168 *
157 - * Holds the maintenance mode manager responsible for the "Maintenance Mode"
158 - * and the "Coming Soon" features.
169 + * Holds the plugin maintenance mode.
159 170 *
160 171 * @since 1.0.0
161 172 * @access public
162 173 *
@@ -202,14 +213,14 @@
202 213
203 214 /**
204 215 * Role Manager.
205 216 *
206 - * Holds the plugin role manager.
217 + * Holds the plugin Role Manager
207 218 *
208 219 * @since 2.0.0
209 220 * @access public
210 221 *
211 - * @var Core\RoleManager\Role_Manager
222 + * @var \Elementor\Core\RoleManager\Role_Manager
212 223 */
213 224 public $role_manager;
214 225
215 226 /**
@@ -320,11 +331,11 @@
320 331 */
321 332 public $skins_manager;
322 333
323 334 /**
324 - * Files manager.
335 + * Files Manager.
325 336 *
326 - * Holds the plugin files manager.
337 + * Holds the files manager.
327 338 *
328 339 * @since 2.1.0
329 340 * @access public
330 341 *
@@ -332,11 +343,11 @@
332 343 */
333 344 public $files_manager;
334 345
335 346 /**
336 - * Assets manager.
347 + * Assets Manager.
337 348 *
338 - * Holds the plugin assets manager.
349 + * Holds the Assets manager.
339 350 *
340 351 * @since 2.6.0
341 352 * @access public
342 353 *
@@ -344,17 +355,19 @@
344 355 */
345 356 public $assets_manager;
346 357
347 358 /**
348 - * Icons Manager.
359 + * Files Manager.
349 360 *
350 - * Holds the plugin icons manager.
361 + * Holds the files manager.
351 362 *
363 + * @since 1.0.0
352 364 * @access public
365 + * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
353 366 *
354 - * @var Icons_Manager
367 + * @var Files_Manager
355 368 */
356 - public $icons_manager;
369 + private $posts_css_manager;
357 370
358 371 /**
359 372 * WordPress widgets manager.
360 373 *
@@ -369,9 +382,9 @@
369 382
370 383 /**
371 384 * Modules manager.
372 385 *
373 - * Holds the plugin modules manager.
386 + * Holds the modules manager.
374 387 *
375 388 * @since 1.0.0
376 389 * @access public
377 390 *
@@ -391,164 +404,76 @@
391 404 */
392 405 public $beta_testers;
393 406
394 407 /**
395 - * Inspector.
396 - *
397 - * Holds the plugin inspector data.
398 - *
399 - * @since 2.1.2
400 - * @access public
401 - *
402 408 * @var Inspector
409 + * @deprecated 2.1.2 Use $inspector.
403 410 */
404 - public $inspector;
411 + public $debugger;
405 412
406 413 /**
407 - * @var Admin_Menu_Manager
414 + * @var Inspector
408 415 */
409 - public $admin_menu_manager;
416 + public $inspector;
410 417
411 418 /**
412 - * Common functionality.
413 - *
414 - * Holds the plugin common functionality.
415 - *
416 - * @since 2.3.0
417 - * @access public
418 - *
419 419 * @var CommonApp
420 420 */
421 421 public $common;
422 422
423 423 /**
424 - * Log manager.
425 - *
426 - * Holds the plugin log manager.
427 - *
428 - * @access public
429 - *
430 424 * @var Log_Manager
431 425 */
432 426 public $logger;
433 427
434 428 /**
435 - * Upgrade manager.
436 - *
437 - * Holds the plugin upgrade manager.
438 - *
439 - * @access public
440 - *
441 - * @var Core\Upgrade\Manager
429 + * @var Dev_Tools
442 430 */
443 - public $upgrade;
431 + private $dev_tools;
444 432
445 433 /**
446 - * Tasks manager.
447 - *
448 - * Holds the plugin tasks manager.
449 - *
450 - * @var Core\Upgrade\Custom_Tasks_Manager
434 + * @var Core\Upgrade\Manager
451 435 */
452 - public $custom_tasks;
436 + public $upgrade;
453 437
454 438 /**
455 - * Kits manager.
456 - *
457 - * Holds the plugin kits manager.
458 - *
459 - * @access public
460 - *
461 439 * @var Core\Kits\Manager
462 440 */
463 441 public $kits_manager;
464 442
465 443 /**
466 - * @var \Elementor\Data\V2\Manager
444 + * @var \Core\Data\Manager
467 445 */
468 - public $data_manager_v2;
446 + public $data_manager;
469 447
470 - /**
471 - * Legacy mode.
472 - *
473 - * Holds the plugin legacy mode data.
474 - *
475 - * @access public
476 - *
477 - * @var array
478 - */
479 448 public $legacy_mode;
480 449
481 450 /**
482 - * App.
483 - *
484 - * Holds the plugin app data.
485 - *
486 - * @since 3.0.0
487 - * @access public
488 - *
489 - * @var App\App
451 + * @var Core\App\App
490 452 */
491 453 public $app;
492 454
493 455 /**
494 - * WordPress API.
495 - *
496 - * Holds the methods that interact with WordPress Core API.
497 - *
498 - * @since 3.0.0
499 - * @access public
500 - *
501 456 * @var Wp_Api
502 457 */
503 458 public $wp;
504 459
505 460 /**
506 - * Experiments manager.
507 - *
508 - * Holds the plugin experiments manager.
509 - *
510 - * @since 3.1.0
511 - * @access public
512 - *
513 461 * @var Experiments_Manager
514 462 */
515 463 public $experiments;
516 464
517 465 /**
518 - * Uploads manager.
519 - *
520 - * Holds the plugin uploads manager responsible for handling file uploads
521 - * that are not done with WordPress Media.
522 - *
523 - * @since 3.3.0
524 - * @access public
525 - *
526 466 * @var Uploads_Manager
527 467 */
528 468 public $uploads_manager;
529 469
530 470 /**
531 - * Breakpoints manager.
532 - *
533 - * Holds the plugin breakpoints manager.
534 - *
535 - * @since 3.2.0
536 - * @access public
537 - *
538 471 * @var Breakpoints_Manager
539 472 */
540 473 public $breakpoints;
541 474
542 475 /**
543 - * Assets loader.
544 - *
545 - * Holds the plugin assets loader responsible for conditionally enqueuing
546 - * styles and script assets that were pre-enabled.
547 - *
548 - * @since 3.3.0
549 - * @access public
550 - *
551 476 * @var Assets_Loader
552 477 */
553 478 public $assets_loader;
554 479
@@ -563,13 +488,10 @@
563 488 * @access public
564 489 * @since 1.0.0
565 490 */
566 491 public function __clone() {
567 - _doing_it_wrong(
568 - __FUNCTION__,
569 - sprintf( 'Cloning instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
570 - '1.0.0'
571 - );
492 + // Cloning instances of the class is forbidden.
493 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
572 494 }
573 495
574 496 /**
575 497 * Wakeup.
@@ -579,13 +501,10 @@
579 501 * @access public
580 502 * @since 1.0.0
581 503 */
582 504 public function __wakeup() {
583 - _doing_it_wrong(
584 - __FUNCTION__,
585 - sprintf( 'Unserializing instances of the singleton "%s" class is forbidden.', get_class( $this ) ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
586 - '1.0.0'
587 - );
505 + // Unserializing instances of the class is forbidden.
506 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
588 507 }
589 508
590 509 /**
591 510 * Instance.
@@ -631,12 +550,11 @@
631 550
632 551 /**
633 552 * Elementor init.
634 553 *
635 - * Fires when Elementor components are initialized.
554 + * Fires on Elementor init, after Elementor has finished loading but
555 + * before any headers are sent.
636 556 *
637 - * After Elementor finished loading but before any headers are sent.
638 - *
639 557 * @since 1.0.0
640 558 */
641 559 do_action( 'elementor/init' );
642 560 }
@@ -688,8 +606,9 @@
688 606 private function init_components() {
689 607 $this->experiments = new Experiments_Manager();
690 608 $this->breakpoints = new Breakpoints_Manager();
691 609 $this->inspector = new Inspector();
610 + $this->debugger = $this->inspector;
692 611
693 612 Settings_Manager::run();
694 613
695 614 $this->db = new DB();
@@ -695,8 +614,9 @@
695 614 $this->db = new DB();
696 615 $this->controls_manager = new Controls_Manager();
697 616 $this->documents = new Documents_Manager();
698 617 $this->kits_manager = new Kits_Manager();
618 + $this->schemes_manager = new Schemes_Manager();
699 619 $this->elements_manager = new Elements_Manager();
700 620 $this->widgets_manager = new Widgets_Manager();
701 621 $this->skins_manager = new Skins_Manager();
702 622 $this->files_manager = new Files_Manager();
@@ -718,20 +638,15 @@
718 638 $this->wp = new Wp_Api();
719 639 $this->assets_loader = new Assets_Loader();
720 640 $this->uploads_manager = new Uploads_Manager();
721 641
722 - $this->admin_menu_manager = new Admin_Menu_Manager();
723 - $this->admin_menu_manager->register_actions();
724 -
725 642 User::init();
726 - User_Data::init();
727 643 Api::init();
728 644 Tracker::init();
729 645
730 646 $this->upgrade = new Core\Upgrade\Manager();
731 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
732 647
733 - $this->app = new App\App();
648 + $this->app = new Core\App\App();
734 649
735 650 if ( is_admin() ) {
736 651 $this->heartbeat = new Heartbeat();
737 652 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -736,8 +651,9 @@
736 651 $this->heartbeat = new Heartbeat();
737 652 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
738 653 $this->admin = new Admin();
739 654 $this->beta_testers = new Beta_Testers();
655 + new Elementor_3_Re_Migrate_Globals();
740 656 }
741 657 }
742 658
743 659 /**
@@ -747,11 +663,43 @@
747 663 public function init_common() {
748 664 $this->common = new CommonApp();
749 665
750 666 $this->common->init_components();
667 +
668 + $this->ajax = $this->common->get_component( 'ajax' );
751 669 }
752 670
753 671 /**
672 + * Get Legacy Mode
673 + *
674 + * @since 3.0.0
675 + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
676 + *
677 + * @param string $mode_name Optional. Default is null
678 + *
679 + * @return bool|bool[]
680 + */
681 + public function get_legacy_mode( $mode_name = null ) {
682 + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
683 + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
684 +
685 + $legacy_mode = [
686 + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
687 + ];
688 +
689 + if ( ! $mode_name ) {
690 + return $legacy_mode;
691 + }
692 +
693 + if ( isset( $legacy_mode[ $mode_name ] ) ) {
694 + return $legacy_mode[ $mode_name ];
695 + }
696 +
697 + // If there is no legacy mode with the given mode name;
698 + return false;
699 + }
700 +
701 + /**
754 702 * Add custom post type support.
755 703 *
756 704 * Register Elementor support for all the supported post types defined by
757 705 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -763,9 +711,9 @@
763 711 * @since 1.0.0
764 712 * @access private
765 713 */
766 714 private function add_cpt_support() {
767 - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
715 + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
768 716
769 717 foreach ( $cpt_support as $cpt_slug ) {
770 718 add_post_type_support( $cpt_slug, 'elementor' );
771 719 }
@@ -785,16 +733,16 @@
785 733 Autoloader::run();
786 734 }
787 735
788 736 /**
789 - * Magic getter for accessing certain properties.
737 + * Plugin Magic Getter
790 738 *
791 739 * @since 3.1.0
792 740 * @access public
793 741 *
794 - * @param string $property The property name.
795 - * @return mixed The property value or null if not found.
796 - * @throws \Exception If trying to access a private property.
742 + * @param $property
743 + * @return mixed
744 + * @throws \Exception
797 745 */
798 746 public function __get( $property ) {
799 747 if ( 'posts_css_manager' === $property ) {
800 748 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -801,14 +749,10 @@
801 749
802 750 return $this->files_manager;
803 751 }
804 752
805 - if ( 'data_manager' === $property ) {
806 - return Data_Manager::instance();
807 - }
808 -
809 753 if ( property_exists( $this, $property ) ) {
810 - throw new \Exception( 'Cannot access private property.' );
754 + throw new \Exception( 'Cannot access private property' );
811 755 }
812 756
813 757 return null;
814 758 }
@@ -824,53 +768,19 @@
824 768 private function __construct() {
825 769 $this->register_autoloader();
826 770
827 771 $this->logger = Log_Manager::instance();
828 - $this->data_manager_v2 = Data_Manager_V2::instance();
772 + $this->data_manager = Data_Manager::instance();
829 773
830 774 Maintenance::init();
831 775 Compatibility::register_actions();
832 776
833 777 add_action( 'init', [ $this, 'init' ], 0 );
834 - add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ], 9 );
835 - add_filter( 'rest_pre_insert_post', [ $this, 'sanitize_post_data' ], 10, 2 );
778 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
836 779 }
837 780
838 781 final public static function get_title() {
839 - return esc_html__( 'Elementor', 'elementor' );
840 - }
841 -
842 - public function sanitize_post_data( $post, WP_REST_Request $request ) {
843 - if ( current_user_can( 'unfiltered_html' ) ) {
844 - return $post;
845 - }
846 -
847 - $meta = $request->get_param( 'meta' );
848 - if ( empty( $meta ) || ! is_array( $meta ) ) {
849 - return $post;
850 - }
851 -
852 - foreach ( self::SANITIZABLE_META_KEYS as $meta_key ) {
853 - $elementor_data = $meta[ $meta_key ] ?? null;
854 - if ( is_null( $elementor_data ) ) {
855 - continue;
856 - }
857 - if ( is_string( $elementor_data ) ) {
858 - $elementor_data = json_decode( $elementor_data, true );
859 - }
860 - if ( empty( $elementor_data ) ) {
861 - continue;
862 - }
863 -
864 - $elementor_data = map_deep($elementor_data, function ( $value ) {
865 - return is_bool( $value ) || is_null( $value ) ? $value : wp_kses_post( $value );
866 - });
867 -
868 - $meta[ $meta_key ] = wp_json_encode( $elementor_data );
869 - }
870 -
871 - $request->set_param( 'meta', $meta );
872 - return $post;
782 + return __( 'Elementor', 'elementor' );
873 783 }
874 784 }
875 785
876 786 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {