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