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