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