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