PluginProbe
Elementor Website Builder – more than just a page builder / 3.1.0-dev2
Elementor Website Builder – more than just a page builder v3.1.0-dev2
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 +107 -231 4.1.23.1.0-dev2 View file →
@@ -1,12 +1,9 @@
1 1 <?php
2 -
3 2 namespace Elementor;
4 3
5 -use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
6 -use Elementor\Core\Wp_Api;
7 4 use Elementor\Core\Admin\Admin;
8 -use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
9 6 use Elementor\Core\Common\App as CommonApp;
10 7 use Elementor\Core\Debug\Inspector;
11 8 use Elementor\Core\Documents_Manager;
12 9 use Elementor\Core\Experiments\Manager as Experiments_Manager;
@@ -14,19 +11,17 @@
14 11 use Elementor\Core\Editor\Editor;
15 12 use Elementor\Core\Files\Manager as Files_Manager;
16 13 use Elementor\Core\Files\Assets\Manager as Assets_Manager;
17 14 use Elementor\Core\Modules_Manager;
15 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
18 16 use Elementor\Core\Settings\Manager as Settings_Manager;
19 17 use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager;
18 +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals;
20 19 use Elementor\Modules\History\Revisions_Manager;
21 20 use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager;
22 21 use Elementor\Core\Logger\Manager as Log_Manager;
23 -use Elementor\Core\Page_Assets\Loader as Assets_Loader;
24 22 use Elementor\Modules\System_Info\Module as System_Info_Module;
25 23 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;
29 24
30 25 if ( ! defined( 'ABSPATH' ) ) {
31 26 exit;
32 27 }
@@ -40,16 +35,8 @@
40 35 * @since 1.0.0
41 36 */
42 37 class Plugin {
43 38
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 39 /**
53 40 * Instance.
54 41 *
55 42 * Holds the plugin instance.
@@ -64,10 +51,9 @@
64 51
65 52 /**
66 53 * Database.
67 54 *
68 - * Holds the plugin database handler which is responsible for communicating
69 - * with the database.
55 + * Holds the plugin database.
70 56 *
71 57 * @since 1.0.0
72 58 * @access public
73 59 *
@@ -75,12 +61,24 @@
75 61 */
76 62 public $db;
77 63
78 64 /**
65 + * Ajax Manager.
66 + *
67 + * Holds the plugin ajax manager.
68 + *
69 + * @since 1.9.0
70 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )` instead
71 + * @access public
72 + *
73 + * @var Ajax
74 + */
75 + public $ajax;
76 +
77 + /**
79 78 * Controls manager.
80 79 *
81 - * Holds the plugin controls manager handler is responsible for registering
82 - * and initializing controls.
80 + * Holds the plugin controls manager.
83 81 *
84 82 * @since 1.0.0
85 83 * @access public
86 84 *
@@ -100,8 +98,20 @@
100 98 */
101 99 public $documents;
102 100
103 101 /**
102 + * Schemes manager.
103 + *
104 + * Holds the plugin schemes manager.
105 + *
106 + * @since 1.0.0
107 + * @access public
108 + *
109 + * @var Schemes_Manager
110 + */
111 + public $schemes_manager;
112 +
113 + /**
104 114 * Elements manager.
105 115 *
106 116 * Holds the plugin elements manager.
107 117 *
@@ -114,10 +124,9 @@
114 124
115 125 /**
116 126 * Widgets manager.
117 127 *
118 - * Holds the plugin widgets manager which is responsible for registering and
119 - * initializing widgets.
128 + * Holds the plugin widgets manager.
120 129 *
121 130 * @since 1.0.0
122 131 * @access public
123 132 *
@@ -127,10 +136,9 @@
127 136
128 137 /**
129 138 * Revisions manager.
130 139 *
131 - * Holds the plugin revisions manager which handles history and revisions
132 - * functionality.
140 + * Holds the plugin revisions manager.
133 141 *
134 142 * @since 1.0.0
135 143 * @access public
136 144 *
@@ -140,10 +148,9 @@
140 148
141 149 /**
142 150 * Images manager.
143 151 *
144 - * Holds the plugin images manager which is responsible for retrieving image
145 - * details.
152 + * Holds the plugin images manager.
146 153 *
147 154 * @since 2.9.0
148 155 * @access public
149 156 *
@@ -153,10 +160,9 @@
153 160
154 161 /**
155 162 * Maintenance mode.
156 163 *
157 - * Holds the maintenance mode manager responsible for the "Maintenance Mode"
158 - * and the "Coming Soon" features.
164 + * Holds the plugin maintenance mode.
159 165 *
160 166 * @since 1.0.0
161 167 * @access public
162 168 *
@@ -202,14 +208,14 @@
202 208
203 209 /**
204 210 * Role Manager.
205 211 *
206 - * Holds the plugin role manager.
212 + * Holds the plugin Role Manager
207 213 *
208 214 * @since 2.0.0
209 215 * @access public
210 216 *
211 - * @var Core\RoleManager\Role_Manager
217 + * @var \Elementor\Core\RoleManager\Role_Manager
212 218 */
213 219 public $role_manager;
214 220
215 221 /**
@@ -291,9 +297,9 @@
291 297 *
292 298 * @since 1.0.0
293 299 * @access public
294 300 *
295 - * @var System_Info_Module
301 + * @var System_Info\Main
296 302 */
297 303 public $system_info;
298 304
299 305 /**
@@ -320,11 +326,11 @@
320 326 */
321 327 public $skins_manager;
322 328
323 329 /**
324 - * Files manager.
330 + * Files Manager.
325 331 *
326 - * Holds the plugin files manager.
332 + * Holds the files manager.
327 333 *
328 334 * @since 2.1.0
329 335 * @access public
330 336 *
@@ -332,11 +338,11 @@
332 338 */
333 339 public $files_manager;
334 340
335 341 /**
336 - * Assets manager.
342 + * Assets Manager.
337 343 *
338 - * Holds the plugin assets manager.
344 + * Holds the Assets manager.
339 345 *
340 346 * @since 2.6.0
341 347 * @access public
342 348 *
@@ -344,17 +350,19 @@
344 350 */
345 351 public $assets_manager;
346 352
347 353 /**
348 - * Icons Manager.
354 + * Files Manager.
349 355 *
350 - * Holds the plugin icons manager.
356 + * Holds the files manager.
351 357 *
358 + * @since 1.0.0
352 359 * @access public
360 + * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
353 361 *
354 - * @var Icons_Manager
362 + * @var Files_Manager
355 363 */
356 - public $icons_manager;
364 + private $posts_css_manager;
357 365
358 366 /**
359 367 * WordPress widgets manager.
360 368 *
@@ -369,9 +377,9 @@
369 377
370 378 /**
371 379 * Modules manager.
372 380 *
373 - * Holds the plugin modules manager.
381 + * Holds the modules manager.
374 382 *
375 383 * @since 1.0.0
376 384 * @access public
377 385 *
@@ -391,169 +399,56 @@
391 399 */
392 400 public $beta_testers;
393 401
394 402 /**
395 - * Inspector.
396 - *
397 - * Holds the plugin inspector data.
398 - *
399 - * @since 2.1.2
400 - * @access public
401 - *
402 403 * @var Inspector
404 + * @deprecated 2.1.2 Use $inspector.
403 405 */
404 - public $inspector;
406 + public $debugger;
405 407
406 408 /**
407 - * @var Admin_Menu_Manager
409 + * @var Inspector
408 410 */
409 - public $admin_menu_manager;
411 + public $inspector;
410 412
411 413 /**
412 - * Common functionality.
413 - *
414 - * Holds the plugin common functionality.
415 - *
416 - * @since 2.3.0
417 - * @access public
418 - *
419 414 * @var CommonApp
420 415 */
421 416 public $common;
422 417
423 418 /**
424 - * Log manager.
425 - *
426 - * Holds the plugin log manager.
427 - *
428 - * @access public
429 - *
430 419 * @var Log_Manager
431 420 */
432 421 public $logger;
433 422
434 423 /**
435 - * Upgrade manager.
436 - *
437 - * Holds the plugin upgrade manager.
438 - *
439 - * @access public
440 - *
441 424 * @var Core\Upgrade\Manager
442 425 */
443 426 public $upgrade;
444 427
445 428 /**
446 - * Tasks manager.
447 - *
448 - * Holds the plugin tasks manager.
449 - *
450 - * @var Core\Upgrade\Custom_Tasks_Manager
451 - */
452 - public $custom_tasks;
453 -
454 - /**
455 - * Kits manager.
456 - *
457 - * Holds the plugin kits manager.
458 - *
459 - * @access public
460 - *
461 429 * @var Core\Kits\Manager
462 430 */
463 431 public $kits_manager;
464 432
465 433 /**
466 - * @var \Elementor\Data\V2\Manager
434 + * @var \Core\Data\Manager
467 435 */
468 - public $data_manager_v2;
436 + public $data_manager;
469 437
470 - /**
471 - * Legacy mode.
472 - *
473 - * Holds the plugin legacy mode data.
474 - *
475 - * @access public
476 - *
477 - * @var array
478 - */
479 438 public $legacy_mode;
480 439
481 440 /**
482 - * App.
483 - *
484 - * Holds the plugin app data.
485 - *
486 - * @since 3.0.0
487 - * @access public
488 - *
489 - * @var App\App
441 + * @var Core\App\App
490 442 */
491 443 public $app;
492 444
493 445 /**
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 - * @var Wp_Api
502 - */
503 - public $wp;
504 -
505 - /**
506 - * Experiments manager.
507 - *
508 - * Holds the plugin experiments manager.
509 - *
510 - * @since 3.1.0
511 - * @access public
512 - *
513 446 * @var Experiments_Manager
514 447 */
515 448 public $experiments;
516 449
517 450 /**
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 - * @var Uploads_Manager
527 - */
528 - public $uploads_manager;
529 -
530 - /**
531 - * Breakpoints manager.
532 - *
533 - * Holds the plugin breakpoints manager.
534 - *
535 - * @since 3.2.0
536 - * @access public
537 - *
538 - * @var Breakpoints_Manager
539 - */
540 - public $breakpoints;
541 -
542 - /**
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 - * @var Assets_Loader
552 - */
553 - public $assets_loader;
554 -
555 - /**
556 451 * Clone.
557 452 *
558 453 * Disable class cloning and throw an error on object clone.
559 454 *
@@ -563,13 +458,10 @@
563 458 * @access public
564 459 * @since 1.0.0
565 460 */
566 461 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 - );
462 + // Cloning instances of the class is forbidden.
463 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
572 464 }
573 465
574 466 /**
575 467 * Wakeup.
@@ -579,13 +471,10 @@
579 471 * @access public
580 472 * @since 1.0.0
581 473 */
582 474 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 - );
475 + // Unserializing instances of the class is forbidden.
476 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
588 477 }
589 478
590 479 /**
591 480 * Instance.
@@ -631,12 +520,11 @@
631 520
632 521 /**
633 522 * Elementor init.
634 523 *
635 - * Fires when Elementor components are initialized.
524 + * Fires on Elementor init, after Elementor has finished loading but
525 + * before any headers are sent.
636 526 *
637 - * After Elementor finished loading but before any headers are sent.
638 - *
639 527 * @since 1.0.0
640 528 */
641 529 do_action( 'elementor/init' );
642 530 }
@@ -686,10 +574,10 @@
686 574 * @access private
687 575 */
688 576 private function init_components() {
689 577 $this->experiments = new Experiments_Manager();
690 - $this->breakpoints = new Breakpoints_Manager();
691 578 $this->inspector = new Inspector();
579 + $this->debugger = $this->inspector;
692 580
693 581 Settings_Manager::run();
694 582
695 583 $this->db = new DB();
@@ -695,8 +583,9 @@
695 583 $this->db = new DB();
696 584 $this->controls_manager = new Controls_Manager();
697 585 $this->documents = new Documents_Manager();
698 586 $this->kits_manager = new Kits_Manager();
587 + $this->schemes_manager = new Schemes_Manager();
699 588 $this->elements_manager = new Elements_Manager();
700 589 $this->widgets_manager = new Widgets_Manager();
701 590 $this->skins_manager = new Skins_Manager();
702 591 $this->files_manager = new Files_Manager();
@@ -706,32 +595,24 @@
706 595 $this->tools = new Tools();
707 596 $this->editor = new Editor();
708 597 $this->preview = new Preview();
709 598 $this->frontend = new Frontend();
599 + $this->templates_manager = new TemplateLibrary\Manager();
710 600 $this->maintenance_mode = new Maintenance_Mode();
711 601 $this->dynamic_tags = new Dynamic_Tags_Manager();
712 602 $this->modules_manager = new Modules_Manager();
713 - $this->templates_manager = new TemplateLibrary\Manager();
714 603 $this->role_manager = new Core\RoleManager\Role_Manager();
715 604 $this->system_info = new System_Info_Module();
716 605 $this->revisions_manager = new Revisions_Manager();
717 606 $this->images_manager = new Images_Manager();
718 - $this->wp = new Wp_Api();
719 - $this->assets_loader = new Assets_Loader();
720 - $this->uploads_manager = new Uploads_Manager();
721 607
722 - $this->admin_menu_manager = new Admin_Menu_Manager();
723 - $this->admin_menu_manager->register_actions();
724 -
725 608 User::init();
726 - User_Data::init();
727 609 Api::init();
728 610 Tracker::init();
729 611
730 612 $this->upgrade = new Core\Upgrade\Manager();
731 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
732 613
733 - $this->app = new App\App();
614 + $this->app = new Core\App\App();
734 615
735 616 if ( is_admin() ) {
736 617 $this->heartbeat = new Heartbeat();
737 618 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -736,8 +617,9 @@
736 617 $this->heartbeat = new Heartbeat();
737 618 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
738 619 $this->admin = new Admin();
739 620 $this->beta_testers = new Beta_Testers();
621 + new Elementor_3_Re_Migrate_Globals();
740 622 }
741 623 }
742 624
743 625 /**
@@ -747,11 +629,43 @@
747 629 public function init_common() {
748 630 $this->common = new CommonApp();
749 631
750 632 $this->common->init_components();
633 +
634 + $this->ajax = $this->common->get_component( 'ajax' );
751 635 }
752 636
753 637 /**
638 + * Get Legacy Mode
639 + *
640 + * @since 3.0.0
641 + * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead
642 + *
643 + * @param string $mode_name Optional. Default is null
644 + *
645 + * @return bool|bool[]
646 + */
647 + public function get_legacy_mode( $mode_name = null ) {
648 + self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation
649 + ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' );
650 +
651 + $legacy_mode = [
652 + 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ),
653 + ];
654 +
655 + if ( ! $mode_name ) {
656 + return $legacy_mode;
657 + }
658 +
659 + if ( isset( $legacy_mode[ $mode_name ] ) ) {
660 + return $legacy_mode[ $mode_name ];
661 + }
662 +
663 + // If there is no legacy mode with the given mode name;
664 + return false;
665 + }
666 +
667 + /**
754 668 * Add custom post type support.
755 669 *
756 670 * Register Elementor support for all the supported post types defined by
757 671 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -763,9 +677,9 @@
763 677 * @since 1.0.0
764 678 * @access private
765 679 */
766 680 private function add_cpt_support() {
767 - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
681 + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
768 682
769 683 foreach ( $cpt_support as $cpt_slug ) {
770 684 add_post_type_support( $cpt_slug, 'elementor' );
771 685 }
@@ -785,16 +699,16 @@
785 699 Autoloader::run();
786 700 }
787 701
788 702 /**
789 - * Magic getter for accessing certain properties.
703 + * Plugin Magic Getter
790 704 *
791 705 * @since 3.1.0
792 706 * @access public
793 707 *
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.
708 + * @param $property
709 + * @return mixed
710 + * @throws \Exception
797 711 */
798 712 public function __get( $property ) {
799 713 if ( 'posts_css_manager' === $property ) {
800 714 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 +715,10 @@
801 715
802 716 return $this->files_manager;
803 717 }
804 718
805 - if ( 'data_manager' === $property ) {
806 - return Data_Manager::instance();
807 - }
808 -
809 719 if ( property_exists( $this, $property ) ) {
810 - throw new \Exception( 'Cannot access private property.' );
720 + throw new \Exception( 'Cannot access private property' );
811 721 }
812 722
813 723 return null;
814 724 }
@@ -824,53 +734,19 @@
824 734 private function __construct() {
825 735 $this->register_autoloader();
826 736
827 737 $this->logger = Log_Manager::instance();
828 - $this->data_manager_v2 = Data_Manager_V2::instance();
738 + $this->data_manager = Data_Manager::instance();
829 739
830 740 Maintenance::init();
831 741 Compatibility::register_actions();
832 742
833 743 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 );
744 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
836 745 }
837 746
838 747 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;
748 + return __( 'Elementor', 'elementor' );
873 749 }
874 750 }
875 751
876 752 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {