| @@ -1,32 +1,27 @@ | ||
| 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 | -use Elementor\Core\Experiments\Manager as Experiments_Manager; | |
| 13 | 9 | use Elementor\Core\Kits\Manager as Kits_Manager; |
| 14 | 10 | use Elementor\Core\Editor\Editor; |
| 15 | 11 | use Elementor\Core\Files\Manager as Files_Manager; |
| 16 | 12 | use Elementor\Core\Files\Assets\Manager as Assets_Manager; |
| 17 | 13 | use Elementor\Core\Modules_Manager; |
| 14 | +use Elementor\Core\Schemes\Manager as Schemes_Manager; | |
| 18 | 15 | use Elementor\Core\Settings\Manager as Settings_Manager; |
| 19 | 16 | use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager; |
| 17 | +use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals; | |
| 18 | +use Elementor\Core\Upgrade\Manager as Upgrades_Manager; | |
| 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 | + public $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,51 @@ | ||
| 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 | - * @var Experiments_Manager | |
| 513 | - */ | |
| 514 | - public $experiments; | |
| 515 | - | |
| 516 | - /** | |
| 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 | 446 | * Clone. |
| 556 | 447 | * |
| 557 | 448 | * Disable class cloning and throw an error on object clone. |
| 558 | 449 | * |
| @@ -562,13 +453,10 @@ | ||
| 562 | 453 | * @access public |
| 563 | 454 | * @since 1.0.0 |
| 564 | 455 | */ |
| 565 | 456 | 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 | - ); | |
| 457 | + // Cloning instances of the class is forbidden. | |
| 458 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 571 | 459 | } |
| 572 | 460 | |
| 573 | 461 | /** |
| 574 | 462 | * Wakeup. |
| @@ -578,13 +466,10 @@ | ||
| 578 | 466 | * @access public |
| 579 | 467 | * @since 1.0.0 |
| 580 | 468 | */ |
| 581 | 469 | 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 | - ); | |
| 470 | + // Unserializing instances of the class is forbidden. | |
| 471 | + _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); | |
| 587 | 472 | } |
| 588 | 473 | |
| 589 | 474 | /** |
| 590 | 475 | * Instance. |
| @@ -630,12 +515,11 @@ | ||
| 630 | 515 | |
| 631 | 516 | /** |
| 632 | 517 | * Elementor init. |
| 633 | 518 | * |
| 634 | - * Fires when Elementor components are initialized. | |
| 519 | + * Fires on Elementor init, after Elementor has finished loading but | |
| 520 | + * before any headers are sent. | |
| 635 | 521 | * |
| 636 | - * After Elementor finished loading but before any headers are sent. | |
| 637 | - * | |
| 638 | 522 | * @since 1.0.0 |
| 639 | 523 | */ |
| 640 | 524 | do_action( 'elementor/init' ); |
| 641 | 525 | } |
| @@ -684,11 +568,10 @@ | ||
| 684 | 568 | * @since 1.0.0 |
| 685 | 569 | * @access private |
| 686 | 570 | */ |
| 687 | 571 | private function init_components() { |
| 688 | - $this->experiments = new Experiments_Manager(); | |
| 689 | - $this->breakpoints = new Breakpoints_Manager(); | |
| 690 | 572 | $this->inspector = new Inspector(); |
| 573 | + $this->debugger = $this->inspector; | |
| 691 | 574 | |
| 692 | 575 | Settings_Manager::run(); |
| 693 | 576 | |
| 694 | 577 | $this->db = new DB(); |
| @@ -694,8 +577,9 @@ | ||
| 694 | 577 | $this->db = new DB(); |
| 695 | 578 | $this->controls_manager = new Controls_Manager(); |
| 696 | 579 | $this->documents = new Documents_Manager(); |
| 697 | 580 | $this->kits_manager = new Kits_Manager(); |
| 581 | + $this->schemes_manager = new Schemes_Manager(); | |
| 698 | 582 | $this->elements_manager = new Elements_Manager(); |
| 699 | 583 | $this->widgets_manager = new Widgets_Manager(); |
| 700 | 584 | $this->skins_manager = new Skins_Manager(); |
| 701 | 585 | $this->files_manager = new Files_Manager(); |
| @@ -700,37 +584,33 @@ | ||
| 700 | 584 | $this->skins_manager = new Skins_Manager(); |
| 701 | 585 | $this->files_manager = new Files_Manager(); |
| 702 | 586 | $this->assets_manager = new Assets_Manager(); |
| 703 | 587 | $this->icons_manager = new Icons_Manager(); |
| 588 | + /* | |
| 589 | + * @TODO: Remove deprecated alias | |
| 590 | + */ | |
| 591 | + $this->posts_css_manager = $this->files_manager; | |
| 704 | 592 | $this->settings = new Settings(); |
| 705 | 593 | $this->tools = new Tools(); |
| 706 | 594 | $this->editor = new Editor(); |
| 707 | 595 | $this->preview = new Preview(); |
| 708 | 596 | $this->frontend = new Frontend(); |
| 597 | + $this->templates_manager = new TemplateLibrary\Manager(); | |
| 709 | 598 | $this->maintenance_mode = new Maintenance_Mode(); |
| 710 | 599 | $this->dynamic_tags = new Dynamic_Tags_Manager(); |
| 711 | 600 | $this->modules_manager = new Modules_Manager(); |
| 712 | - $this->templates_manager = new TemplateLibrary\Manager(); | |
| 713 | 601 | $this->role_manager = new Core\RoleManager\Role_Manager(); |
| 714 | 602 | $this->system_info = new System_Info_Module(); |
| 715 | 603 | $this->revisions_manager = new Revisions_Manager(); |
| 716 | 604 | $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 | 605 | |
| 721 | - $this->admin_menu_manager = new Admin_Menu_Manager(); | |
| 722 | - $this->admin_menu_manager->register_actions(); | |
| 723 | - | |
| 724 | 606 | User::init(); |
| 725 | - User_Data::init(); | |
| 726 | 607 | Api::init(); |
| 727 | 608 | Tracker::init(); |
| 728 | 609 | |
| 729 | 610 | $this->upgrade = new Core\Upgrade\Manager(); |
| 730 | - $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager(); | |
| 731 | 611 | |
| 732 | - $this->app = new App\App(); | |
| 612 | + $this->app = new Core\App\App(); | |
| 733 | 613 | |
| 734 | 614 | if ( is_admin() ) { |
| 735 | 615 | $this->heartbeat = new Heartbeat(); |
| 736 | 616 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| @@ -735,8 +615,9 @@ | ||
| 735 | 615 | $this->heartbeat = new Heartbeat(); |
| 736 | 616 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| 737 | 617 | $this->admin = new Admin(); |
| 738 | 618 | $this->beta_testers = new Beta_Testers(); |
| 619 | + new Elementor_3_Re_Migrate_Globals(); | |
| 739 | 620 | } |
| 740 | 621 | } |
| 741 | 622 | |
| 742 | 623 | /** |
| @@ -746,10 +627,39 @@ | ||
| 746 | 627 | public function init_common() { |
| 747 | 628 | $this->common = new CommonApp(); |
| 748 | 629 | |
| 749 | 630 | $this->common->init_components(); |
| 631 | + | |
| 632 | + $this->ajax = $this->common->get_component( 'ajax' ); | |
| 750 | 633 | } |
| 751 | 634 | |
| 635 | + public function get_legacy_mode( $mode_name = null ) { | |
| 636 | + if ( ! $this->legacy_mode ) { | |
| 637 | + $optimized_dom_output = get_option( 'elementor_optimized_dom_output' ); | |
| 638 | + | |
| 639 | + if ( $optimized_dom_output ) { | |
| 640 | + $element_wrappers_legacy_mode = 'disabled' === $optimized_dom_output; | |
| 641 | + } else { | |
| 642 | + $element_wrappers_legacy_mode = true; | |
| 643 | + } | |
| 644 | + | |
| 645 | + $this->legacy_mode = [ | |
| 646 | + 'elementWrappers' => $element_wrappers_legacy_mode, | |
| 647 | + ]; | |
| 648 | + } | |
| 649 | + | |
| 650 | + if ( ! $mode_name ) { | |
| 651 | + return $this->legacy_mode; | |
| 652 | + } | |
| 653 | + | |
| 654 | + if ( isset( $this->legacy_mode[ $mode_name ] ) ) { | |
| 655 | + return $this->legacy_mode[ $mode_name ]; | |
| 656 | + } | |
| 657 | + | |
| 658 | + // If there is no legacy mode with the given mode name; | |
| 659 | + return false; | |
| 660 | + } | |
| 661 | + | |
| 752 | 662 | /** |
| 753 | 663 | * Add custom post type support. |
| 754 | 664 | * |
| 755 | 665 | * Register Elementor support for all the supported post types defined by |
| @@ -762,9 +672,9 @@ | ||
| 762 | 672 | * @since 1.0.0 |
| 763 | 673 | * @access private |
| 764 | 674 | */ |
| 765 | 675 | private function add_cpt_support() { |
| 766 | - $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES ); | |
| 676 | + $cpt_support = get_option( 'elementor_cpt_support', [ 'page', 'post' ] ); | |
| 767 | 677 | |
| 768 | 678 | foreach ( $cpt_support as $cpt_slug ) { |
| 769 | 679 | add_post_type_support( $cpt_slug, 'elementor' ); |
| 770 | 680 | } |
| @@ -784,36 +694,8 @@ | ||
| 784 | 694 | Autoloader::run(); |
| 785 | 695 | } |
| 786 | 696 | |
| 787 | 697 | /** |
| 788 | - * Magic getter for accessing certain properties. | |
| 789 | - * | |
| 790 | - * @since 3.1.0 | |
| 791 | - * @access public | |
| 792 | - * | |
| 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. | |
| 796 | - */ | |
| 797 | - public function __get( $property ) { | |
| 798 | - if ( 'posts_css_manager' === $property ) { | |
| 799 | - self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); | |
| 800 | - | |
| 801 | - return $this->files_manager; | |
| 802 | - } | |
| 803 | - | |
| 804 | - if ( 'data_manager' === $property ) { | |
| 805 | - return Data_Manager::instance(); | |
| 806 | - } | |
| 807 | - | |
| 808 | - if ( property_exists( $this, $property ) ) { | |
| 809 | - throw new \Exception( 'Cannot access private property.' ); | |
| 810 | - } | |
| 811 | - | |
| 812 | - return null; | |
| 813 | - } | |
| 814 | - | |
| 815 | - /** | |
| 816 | 698 | * Plugin constructor. |
| 817 | 699 | * |
| 818 | 700 | * Initializing Elementor plugin. |
| 819 | 701 | * |
| @@ -823,53 +705,19 @@ | ||
| 823 | 705 | private function __construct() { |
| 824 | 706 | $this->register_autoloader(); |
| 825 | 707 | |
| 826 | 708 | $this->logger = Log_Manager::instance(); |
| 827 | - $this->data_manager_v2 = Data_Manager_V2::instance(); | |
| 709 | + $this->data_manager = Data_Manager::instance(); | |
| 828 | 710 | |
| 829 | 711 | Maintenance::init(); |
| 830 | 712 | Compatibility::register_actions(); |
| 831 | 713 | |
| 832 | 714 | 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 ); | |
| 715 | + add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] ); | |
| 835 | 716 | } |
| 836 | 717 | |
| 837 | 718 | 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; | |
| 719 | + return __( 'Elementor', 'elementor' ); | |
| 872 | 720 | } |
| 873 | 721 | } |
| 874 | 722 | |
| 875 | 723 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |