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 -200 4.1.0-dev13.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,15 +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 - ];
50 -
51 44 /**
52 45 * Instance.
53 46 *
54 47 * Holds the plugin instance.
@@ -63,10 +56,9 @@
63 56
64 57 /**
65 58 * Database.
66 59 *
67 - * Holds the plugin database handler which is responsible for communicating
68 - * with the database.
60 + * Holds the plugin database.
69 61 *
70 62 * @since 1.0.0
71 63 * @access public
72 64 *
@@ -74,12 +66,24 @@
74 66 */
75 67 public $db;
76 68
77 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 + /**
78 83 * Controls manager.
79 84 *
80 - * Holds the plugin controls manager handler is responsible for registering
81 - * and initializing controls.
85 + * Holds the plugin controls manager.
82 86 *
83 87 * @since 1.0.0
84 88 * @access public
85 89 *
@@ -99,8 +103,20 @@
99 103 */
100 104 public $documents;
101 105
102 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 + /**
103 119 * Elements manager.
104 120 *
105 121 * Holds the plugin elements manager.
106 122 *
@@ -113,10 +129,9 @@
113 129
114 130 /**
115 131 * Widgets manager.
116 132 *
117 - * Holds the plugin widgets manager which is responsible for registering and
118 - * initializing widgets.
133 + * Holds the plugin widgets manager.
119 134 *
120 135 * @since 1.0.0
121 136 * @access public
122 137 *
@@ -126,10 +141,9 @@
126 141
127 142 /**
128 143 * Revisions manager.
129 144 *
130 - * Holds the plugin revisions manager which handles history and revisions
131 - * functionality.
145 + * Holds the plugin revisions manager.
132 146 *
133 147 * @since 1.0.0
134 148 * @access public
135 149 *
@@ -139,10 +153,9 @@
139 153
140 154 /**
141 155 * Images manager.
142 156 *
143 - * Holds the plugin images manager which is responsible for retrieving image
144 - * details.
157 + * Holds the plugin images manager.
145 158 *
146 159 * @since 2.9.0
147 160 * @access public
148 161 *
@@ -152,10 +165,9 @@
152 165
153 166 /**
154 167 * Maintenance mode.
155 168 *
156 - * Holds the maintenance mode manager responsible for the "Maintenance Mode"
157 - * and the "Coming Soon" features.
169 + * Holds the plugin maintenance mode.
158 170 *
159 171 * @since 1.0.0
160 172 * @access public
161 173 *
@@ -201,14 +213,14 @@
201 213
202 214 /**
203 215 * Role Manager.
204 216 *
205 - * Holds the plugin role manager.
217 + * Holds the plugin Role Manager
206 218 *
207 219 * @since 2.0.0
208 220 * @access public
209 221 *
210 - * @var Core\RoleManager\Role_Manager
222 + * @var \Elementor\Core\RoleManager\Role_Manager
211 223 */
212 224 public $role_manager;
213 225
214 226 /**
@@ -319,11 +331,11 @@
319 331 */
320 332 public $skins_manager;
321 333
322 334 /**
323 - * Files manager.
335 + * Files Manager.
324 336 *
325 - * Holds the plugin files manager.
337 + * Holds the files manager.
326 338 *
327 339 * @since 2.1.0
328 340 * @access public
329 341 *
@@ -331,11 +343,11 @@
331 343 */
332 344 public $files_manager;
333 345
334 346 /**
335 - * Assets manager.
347 + * Assets Manager.
336 348 *
337 - * Holds the plugin assets manager.
349 + * Holds the Assets manager.
338 350 *
339 351 * @since 2.6.0
340 352 * @access public
341 353 *
@@ -343,17 +355,19 @@
343 355 */
344 356 public $assets_manager;
345 357
346 358 /**
347 - * Icons Manager.
359 + * Files Manager.
348 360 *
349 - * Holds the plugin icons manager.
361 + * Holds the files manager.
350 362 *
363 + * @since 1.0.0
351 364 * @access public
365 + * @deprecated 2.1.0 Use `Plugin::$files_manager` instead
352 366 *
353 - * @var Icons_Manager
367 + * @var Files_Manager
354 368 */
355 - public $icons_manager;
369 + private $posts_css_manager;
356 370
357 371 /**
358 372 * WordPress widgets manager.
359 373 *
@@ -368,9 +382,9 @@
368 382
369 383 /**
370 384 * Modules manager.
371 385 *
372 - * Holds the plugin modules manager.
386 + * Holds the modules manager.
373 387 *
374 388 * @since 1.0.0
375 389 * @access public
376 390 *
@@ -390,164 +404,76 @@
390 404 */
391 405 public $beta_testers;
392 406
393 407 /**
394 - * Inspector.
395 - *
396 - * Holds the plugin inspector data.
397 - *
398 - * @since 2.1.2
399 - * @access public
400 - *
401 408 * @var Inspector
409 + * @deprecated 2.1.2 Use $inspector.
402 410 */
403 - public $inspector;
411 + public $debugger;
404 412
405 413 /**
406 - * @var Admin_Menu_Manager
414 + * @var Inspector
407 415 */
408 - public $admin_menu_manager;
416 + public $inspector;
409 417
410 418 /**
411 - * Common functionality.
412 - *
413 - * Holds the plugin common functionality.
414 - *
415 - * @since 2.3.0
416 - * @access public
417 - *
418 419 * @var CommonApp
419 420 */
420 421 public $common;
421 422
422 423 /**
423 - * Log manager.
424 - *
425 - * Holds the plugin log manager.
426 - *
427 - * @access public
428 - *
429 424 * @var Log_Manager
430 425 */
431 426 public $logger;
432 427
433 428 /**
434 - * Upgrade manager.
435 - *
436 - * Holds the plugin upgrade manager.
437 - *
438 - * @access public
439 - *
440 - * @var Core\Upgrade\Manager
429 + * @var Dev_Tools
441 430 */
442 - public $upgrade;
431 + private $dev_tools;
443 432
444 433 /**
445 - * Tasks manager.
446 - *
447 - * Holds the plugin tasks manager.
448 - *
449 - * @var Core\Upgrade\Custom_Tasks_Manager
434 + * @var Core\Upgrade\Manager
450 435 */
451 - public $custom_tasks;
436 + public $upgrade;
452 437
453 438 /**
454 - * Kits manager.
455 - *
456 - * Holds the plugin kits manager.
457 - *
458 - * @access public
459 - *
460 439 * @var Core\Kits\Manager
461 440 */
462 441 public $kits_manager;
463 442
464 443 /**
465 - * @var \Elementor\Data\V2\Manager
444 + * @var \Core\Data\Manager
466 445 */
467 - public $data_manager_v2;
446 + public $data_manager;
468 447
469 - /**
470 - * Legacy mode.
471 - *
472 - * Holds the plugin legacy mode data.
473 - *
474 - * @access public
475 - *
476 - * @var array
477 - */
478 448 public $legacy_mode;
479 449
480 450 /**
481 - * App.
482 - *
483 - * Holds the plugin app data.
484 - *
485 - * @since 3.0.0
486 - * @access public
487 - *
488 - * @var App\App
451 + * @var Core\App\App
489 452 */
490 453 public $app;
491 454
492 455 /**
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 456 * @var Wp_Api
501 457 */
502 458 public $wp;
503 459
504 460 /**
505 - * Experiments manager.
506 - *
507 - * Holds the plugin experiments manager.
508 - *
509 - * @since 3.1.0
510 - * @access public
511 - *
512 461 * @var Experiments_Manager
513 462 */
514 463 public $experiments;
515 464
516 465 /**
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 466 * @var Uploads_Manager
526 467 */
527 468 public $uploads_manager;
528 469
529 470 /**
530 - * Breakpoints manager.
531 - *
532 - * Holds the plugin breakpoints manager.
533 - *
534 - * @since 3.2.0
535 - * @access public
536 - *
537 471 * @var Breakpoints_Manager
538 472 */
539 473 public $breakpoints;
540 474
541 475 /**
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 476 * @var Assets_Loader
551 477 */
552 478 public $assets_loader;
553 479
@@ -562,13 +488,10 @@
562 488 * @access public
563 489 * @since 1.0.0
564 490 */
565 491 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 - );
492 + // Cloning instances of the class is forbidden.
493 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
571 494 }
572 495
573 496 /**
574 497 * Wakeup.
@@ -578,13 +501,10 @@
578 501 * @access public
579 502 * @since 1.0.0
580 503 */
581 504 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 - );
505 + // Unserializing instances of the class is forbidden.
506 + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' );
587 507 }
588 508
589 509 /**
590 510 * Instance.
@@ -630,12 +550,11 @@
630 550
631 551 /**
632 552 * Elementor init.
633 553 *
634 - * Fires when Elementor components are initialized.
554 + * Fires on Elementor init, after Elementor has finished loading but
555 + * before any headers are sent.
635 556 *
636 - * After Elementor finished loading but before any headers are sent.
637 - *
638 557 * @since 1.0.0
639 558 */
640 559 do_action( 'elementor/init' );
641 560 }
@@ -687,8 +606,9 @@
687 606 private function init_components() {
688 607 $this->experiments = new Experiments_Manager();
689 608 $this->breakpoints = new Breakpoints_Manager();
690 609 $this->inspector = new Inspector();
610 + $this->debugger = $this->inspector;
691 611
692 612 Settings_Manager::run();
693 613
694 614 $this->db = new DB();
@@ -694,8 +614,9 @@
694 614 $this->db = new DB();
695 615 $this->controls_manager = new Controls_Manager();
696 616 $this->documents = new Documents_Manager();
697 617 $this->kits_manager = new Kits_Manager();
618 + $this->schemes_manager = new Schemes_Manager();
698 619 $this->elements_manager = new Elements_Manager();
699 620 $this->widgets_manager = new Widgets_Manager();
700 621 $this->skins_manager = new Skins_Manager();
701 622 $this->files_manager = new Files_Manager();
@@ -717,20 +638,15 @@
717 638 $this->wp = new Wp_Api();
718 639 $this->assets_loader = new Assets_Loader();
719 640 $this->uploads_manager = new Uploads_Manager();
720 641
721 - $this->admin_menu_manager = new Admin_Menu_Manager();
722 - $this->admin_menu_manager->register_actions();
723 -
724 642 User::init();
725 - User_Data::init();
726 643 Api::init();
727 644 Tracker::init();
728 645
729 646 $this->upgrade = new Core\Upgrade\Manager();
730 - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager();
731 647
732 - $this->app = new App\App();
648 + $this->app = new Core\App\App();
733 649
734 650 if ( is_admin() ) {
735 651 $this->heartbeat = new Heartbeat();
736 652 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
@@ -735,8 +651,9 @@
735 651 $this->heartbeat = new Heartbeat();
736 652 $this->wordpress_widgets_manager = new WordPress_Widgets_Manager();
737 653 $this->admin = new Admin();
738 654 $this->beta_testers = new Beta_Testers();
655 + new Elementor_3_Re_Migrate_Globals();
739 656 }
740 657 }
741 658
742 659 /**
@@ -746,11 +663,43 @@
746 663 public function init_common() {
747 664 $this->common = new CommonApp();
748 665
749 666 $this->common->init_components();
667 +
668 + $this->ajax = $this->common->get_component( 'ajax' );
750 669 }
751 670
752 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 + /**
753 702 * Add custom post type support.
754 703 *
755 704 * Register Elementor support for all the supported post types defined by
756 705 * the user in the admin screen and saved as `elementor_cpt_support` option
@@ -762,9 +711,9 @@
762 711 * @since 1.0.0
763 712 * @access private
764 713 */
765 714 private function add_cpt_support() {
766 - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES );
715 + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] );
767 716
768 717 foreach ( $cpt_support as $cpt_slug ) {
769 718 add_post_type_support( $cpt_slug, 'elementor' );
770 719 }
@@ -784,16 +733,16 @@
784 733 Autoloader::run();
785 734 }
786 735
787 736 /**
788 - * Magic getter for accessing certain properties.
737 + * Plugin Magic Getter
789 738 *
790 739 * @since 3.1.0
791 740 * @access public
792 741 *
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.
742 + * @param $property
743 + * @return mixed
744 + * @throws \Exception
796 745 */
797 746 public function __get( $property ) {
798 747 if ( 'posts_css_manager' === $property ) {
799 748 self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' );
@@ -800,14 +749,10 @@
800 749
801 750 return $this->files_manager;
802 751 }
803 752
804 - if ( 'data_manager' === $property ) {
805 - return Data_Manager::instance();
806 - }
807 -
808 753 if ( property_exists( $this, $property ) ) {
809 - throw new \Exception( 'Cannot access private property.' );
754 + throw new \Exception( 'Cannot access private property' );
810 755 }
811 756
812 757 return null;
813 758 }
@@ -823,53 +768,19 @@
823 768 private function __construct() {
824 769 $this->register_autoloader();
825 770
826 771 $this->logger = Log_Manager::instance();
827 - $this->data_manager_v2 = Data_Manager_V2::instance();
772 + $this->data_manager = Data_Manager::instance();
828 773
829 774 Maintenance::init();
830 775 Compatibility::register_actions();
831 776
832 777 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 );
778 + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] );
835 779 }
836 780
837 781 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;
782 + return __( 'Elementor', 'elementor' );
872 783 }
873 784 }
874 785
875 786 if ( ! defined( 'ELEMENTOR_TESTS' ) ) {