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