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