PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.13
Elementor Website Builder – more than just a page builder v3.0.13
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 +104 -257 4.1.23.0.13 View file →
@@ -1,32 +1,27 @@
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\Elementor_3_Re_Migrate_Globals;
18 +use Elementor\Core\Upgrade\Manager as Upgrades_Manager;
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 + public $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,51 @@
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 - * @var Experiments_Manager
514 - */
515 - public $experiments;
516 -
517 - /**
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 446 * Clone.
557 447 *
558 448 * Disable class cloning and throw an error on object clone.
559 449 *
@@ -563,13 +453,10 @@
563 453 * @access public
564 454 * @since 1.0.0
565 455 */
566 456 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 - );
457 + // Cloning instances of the class is forbidden.
458 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
572 459 }
573 460
574 461 /**
575 462 * Wakeup.
@@ -579,13 +466,10 @@
579 466 * @access public
580 467 * @since 1.0.0
581 468 */
582 469 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 - );
470 + // Unserializing instances of the class is forbidden.
471 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
588 472 }
589 473
590 474 /**
591 475 * Instance.
@@ -631,12 +515,11 @@
631 515
632 516 /**
633 517 * Elementor init.
634 518 *
635 - * Fires when Elementor components are initialized.
519 + * Fires on Elementor init, after Elementor has finished loading but
520 + * before any headers are sent.
636 521 *
637 - * After Elementor finished loading but before any headers are sent.
638 - *
639 522 * @since 1.0.0
640 523 */
641 524 do_action( 'elementor/init' );
642 525 }
@@ -685,11 +568,10 @@
685 568 * @since 1.0.0
686 569 * @access private
687 570 */
688 571 private function init_components() {
689 - $this->experiments = new Experiments_Manager();
690 - $this->breakpoints = new Breakpoints_Manager();
691 572 $this->inspector = new Inspector();
573 + $this->debugger = $this->inspector;
692 574
693 575 Settings_Manager::run();
694 576
695 577 $this->db = new DB();
@@ -695,8 +577,9 @@
695 577 $this->db = new DB();
696 578 $this->controls_manager = new Controls_Manager();
697 579 $this->documents = new Documents_Manager();
698 580 $this->kits_manager = new Kits_Manager();
581 + $this->schemes_manager = new Schemes_Manager();
699 582 $this->elements_manager = new Elements_Manager();
700 583 $this->widgets_manager = new Widgets_Manager();
701 584 $this->skins_manager = new Skins_Manager();
702 585 $this->files_manager = new Files_Manager();
@@ -701,37 +584,33 @@
701 584 $this->skins_manager = new Skins_Manager();
702 585 $this->files_manager = new Files_Manager();
703 586 $this->assets_manager = new Assets_Manager();
704 587 $this->icons_manager = new Icons_Manager();
588 + /*
589 + * @TODO: Remove deprecated alias
590 + */
591 + $this->posts_css_manager = $this->files_manager;
705 592 $this->settings = new Settings();
706 593 $this->tools = new Tools();
707 594 $this->editor = new Editor();
708 595 $this->preview = new Preview();
709 596 $this->frontend = new Frontend();
597 + $this->templates_manager = new TemplateLibrary\Manager();
710 598 $this->maintenance_mode = new Maintenance_Mode();
711 599 $this->dynamic_tags = new Dynamic_Tags_Manager();
712 600 $this->modules_manager = new Modules_Manager();
713 - $this->templates_manager = new TemplateLibrary\Manager();
714 601 $this->role_manager = new Core\RoleManager\Role_Manager();
715 602 $this->system_info = new System_Info_Module();
716 603 $this->revisions_manager = new Revisions_Manager();
717 604 $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 605
722 - $this->admin_menu_manager = new Admin_Menu_Manager();
723 - $this->admin_menu_manager->register_actions();
724 -
725 606 User::init();
726 - User_Data::init();
727 607 Api::init();
728 608 Tracker::init();
729 609
730 610 $this->upgrade = new Core\Upgrade\Manager();
731 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
732 611
733 - $this->app = new App\App();
612 + $this->app = new Core\App\App();
734 613
735 614 if ( is_admin() ) {
736 615 $this->heartbeat = new Heartbeat();
737 616 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -736,8 +615,9 @@
736 615 $this->heartbeat = new Heartbeat();
737 616 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
738 617 $this->admin = new Admin();
739 618 $this->beta_testers = new Beta_Testers();
619 + new Elementor_3_Re_Migrate_Globals();
740 620 }
741 621 }
742 622
743 623 /**
@@ -747,10 +627,39 @@
747 627 public function init_common() {
748 628 $this->common = new CommonApp();
749 629
750 630 $this->common->init_components();
631 +
632 + $this->ajax = $this->common->get_component( 'ajax' );
751 633 }
752 634
635 + public function get_legacy_mode( $mode_name = null ) {
636 + if ( ! $this->legacy_mode ) {
637 + $optimized_dom_output = get_option( 'elementor_optimized_dom_output' );
638 +
639 + if ( $optimized_dom_output ) {
640 + $element_wrappers_legacy_mode = 'disabled' === $optimized_dom_output;
641 + } else {
642 + $element_wrappers_legacy_mode = true;
643 + }
644 +
645 + $this->legacy_mode = [
646 + 'elementWrappers' => $element_wrappers_legacy_mode,
647 + ];
648 + }
649 +
650 + if ( ! $mode_name ) {
651 + return $this->legacy_mode;
652 + }
653 +
654 + if ( isset( $this->legacy_mode[ $mode_name ] ) ) {
655 + return $this->legacy_mode[ $mode_name ];
656 + }
657 +
658 + // If there is no legacy mode with the given mode name;
659 + return false;
660 + }
661 +
753 662 /**
754 663 * Add custom post type support.
755 664 *
756 665 * Register Elementor support for all the supported post types defined by
@@ -763,9 +672,9 @@
763 672 * @since 1.0.0
764 673 * @access private
765 674 */
766 675 private function add_cpt_support() {
767 - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
676 + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
768 677
769 678 foreach ( $cpt_support as $cpt_slug ) {
770 679 add_post_type_support( $cpt_slug, 'elementor' );
771 680 }
@@ -785,36 +694,8 @@
785 694 Autoloader::run();
786 695 }
787 696
788 697 /**
789 - * Magic getter for accessing certain properties.
790 - *
791 - * @since 3.1.0
792 - * @access public
793 - *
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.
797 - */
798 - public function __get( $property ) {
799 - if ( 'posts_css_manager' === $property ) {
800 - self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
801 -
802 - return $this->files_manager;
803 - }
804 -
805 - if ( 'data_manager' === $property ) {
806 - return Data_Manager::instance();
807 - }
808 -
809 - if ( property_exists( $this, $property ) ) {
810 - throw new \Exception( 'Cannot access private property.' );
811 - }
812 -
813 - return null;
814 - }
815 -
816 - /**
817 698 * Plugin constructor.
818 699 *
819 700 * Initializing Elementor plugin.
820 701 *
@@ -824,53 +705,19 @@
824 705 private function __construct() {
825 706 $this->register_autoloader();
826 707
827 708 $this->logger = Log_Manager::instance();
828 - $this->data_manager_v2 = Data_Manager_V2::instance();
709 + $this->data_manager = Data_Manager::instance();
829 710
830 711 Maintenance::init();
831 712 Compatibility::register_actions();
832 713
833 714 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 );
715 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
836 716 }
837 717
838 718 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;
719 + return __( 'Elementor', 'elementor' );
873 720 }
874 721 }
875 722
876 723 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {