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