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