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