admin-templates
4 years ago
base
4 years ago
controls
4 years ago
editor-templates
4 years ago
elements
4 years ago
interfaces
6 years ago
libraries
5 years ago
managers
4 years ago
settings
4 years ago
template-library
4 years ago
widgets
4 years ago
api.php
4 years ago
autoloader.php
4 years ago
beta-testers.php
6 years ago
compatibility.php
4 years ago
conditions.php
6 years ago
db.php
5 years ago
embed.php
4 years ago
fonts.php
4 years ago
frontend.php
4 years ago
heartbeat.php
7 years ago
maintenance-mode.php
4 years ago
maintenance.php
4 years ago
plugin.php
4 years ago
preview.php
4 years ago
rollback.php
4 years ago
shapes.php
6 years ago
stylesheet.php
4 years ago
tracker.php
4 years ago
user.php
4 years ago
utils.php
4 years ago
plugin.php
880 lines
| 1 | <?php |
| 2 | namespace Elementor; |
| 3 | |
| 4 | use Elementor\Core\Wp_Api; |
| 5 | use Elementor\Core\Admin\Admin; |
| 6 | use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; |
| 7 | use Elementor\Core\Common\Modules\Ajax\Module as Ajax; |
| 8 | use Elementor\Core\Common\App as CommonApp; |
| 9 | use Elementor\Core\Debug\Inspector; |
| 10 | use Elementor\Core\Documents_Manager; |
| 11 | use Elementor\Core\Experiments\Manager as Experiments_Manager; |
| 12 | use Elementor\Core\Kits\Manager as Kits_Manager; |
| 13 | use Elementor\Core\Editor\Editor; |
| 14 | use Elementor\Core\Files\Manager as Files_Manager; |
| 15 | use Elementor\Core\Files\Assets\Manager as Assets_Manager; |
| 16 | use Elementor\Core\Modules_Manager; |
| 17 | use Elementor\Core\Schemes\Manager as Schemes_Manager; |
| 18 | use Elementor\Core\Settings\Manager as Settings_Manager; |
| 19 | use Elementor\Core\Settings\Page\Manager as Page_Settings_Manager; |
| 20 | use Elementor\Core\Upgrade\Elementor_3_Re_Migrate_Globals; |
| 21 | use Elementor\Modules\History\Revisions_Manager; |
| 22 | use Elementor\Core\DynamicTags\Manager as Dynamic_Tags_Manager; |
| 23 | use Elementor\Core\Logger\Manager as Log_Manager; |
| 24 | use Elementor\Core\Page_Assets\Loader as Assets_Loader; |
| 25 | use Elementor\Modules\System_Info\Module as System_Info_Module; |
| 26 | use Elementor\Data\Manager as Data_Manager; |
| 27 | use Elementor\Data\V2\Manager as Data_Manager_V2; |
| 28 | use Elementor\Core\Common\Modules\DevTools\Module as Dev_Tools; |
| 29 | use Elementor\Core\Files\Uploads_Manager as Uploads_Manager; |
| 30 | |
| 31 | if ( ! defined( 'ABSPATH' ) ) { |
| 32 | exit; |
| 33 | } |
| 34 | |
| 35 | /** |
| 36 | * Elementor plugin. |
| 37 | * |
| 38 | * The main plugin handler class is responsible for initializing Elementor. The |
| 39 | * class registers and all the components required to run the plugin. |
| 40 | * |
| 41 | * @since 1.0.0 |
| 42 | */ |
| 43 | class Plugin { |
| 44 | const ELEMENTOR_DEFAULT_POST_TYPES = [ 'page', 'post' ]; |
| 45 | |
| 46 | /** |
| 47 | * Instance. |
| 48 | * |
| 49 | * Holds the plugin instance. |
| 50 | * |
| 51 | * @since 1.0.0 |
| 52 | * @access public |
| 53 | * @static |
| 54 | * |
| 55 | * @var Plugin |
| 56 | */ |
| 57 | public static $instance = null; |
| 58 | |
| 59 | /** |
| 60 | * Database. |
| 61 | * |
| 62 | * Holds the plugin database handler which is responsible for communicating |
| 63 | * with the database. |
| 64 | * |
| 65 | * @since 1.0.0 |
| 66 | * @access public |
| 67 | * |
| 68 | * @var DB |
| 69 | */ |
| 70 | public $db; |
| 71 | |
| 72 | /** |
| 73 | * Controls manager. |
| 74 | * |
| 75 | * Holds the plugin controls manager handler is responsible for registering |
| 76 | * and initializing controls. |
| 77 | * |
| 78 | * @since 1.0.0 |
| 79 | * @access public |
| 80 | * |
| 81 | * @var Controls_Manager |
| 82 | */ |
| 83 | public $controls_manager; |
| 84 | |
| 85 | /** |
| 86 | * Documents manager. |
| 87 | * |
| 88 | * Holds the documents manager. |
| 89 | * |
| 90 | * @since 2.0.0 |
| 91 | * @access public |
| 92 | * |
| 93 | * @var Documents_Manager |
| 94 | */ |
| 95 | public $documents; |
| 96 | |
| 97 | /** |
| 98 | * Schemes manager. |
| 99 | * |
| 100 | * Holds the plugin schemes manager. |
| 101 | * |
| 102 | * @since 1.0.0 |
| 103 | * @access public |
| 104 | * |
| 105 | * @var Schemes_Manager |
| 106 | */ |
| 107 | public $schemes_manager; |
| 108 | |
| 109 | /** |
| 110 | * Elements manager. |
| 111 | * |
| 112 | * Holds the plugin elements manager. |
| 113 | * |
| 114 | * @since 1.0.0 |
| 115 | * @access public |
| 116 | * |
| 117 | * @var Elements_Manager |
| 118 | */ |
| 119 | public $elements_manager; |
| 120 | |
| 121 | /** |
| 122 | * Widgets manager. |
| 123 | * |
| 124 | * Holds the plugin widgets manager which is responsible for registering and |
| 125 | * initializing widgets. |
| 126 | * |
| 127 | * @since 1.0.0 |
| 128 | * @access public |
| 129 | * |
| 130 | * @var Widgets_Manager |
| 131 | */ |
| 132 | public $widgets_manager; |
| 133 | |
| 134 | /** |
| 135 | * Revisions manager. |
| 136 | * |
| 137 | * Holds the plugin revisions manager which handles history and revisions |
| 138 | * functionality. |
| 139 | * |
| 140 | * @since 1.0.0 |
| 141 | * @access public |
| 142 | * |
| 143 | * @var Revisions_Manager |
| 144 | */ |
| 145 | public $revisions_manager; |
| 146 | |
| 147 | /** |
| 148 | * Images manager. |
| 149 | * |
| 150 | * Holds the plugin images manager which is responsible for retrieving image |
| 151 | * details. |
| 152 | * |
| 153 | * @since 2.9.0 |
| 154 | * @access public |
| 155 | * |
| 156 | * @var Images_Manager |
| 157 | */ |
| 158 | public $images_manager; |
| 159 | |
| 160 | /** |
| 161 | * Maintenance mode. |
| 162 | * |
| 163 | * Holds the maintenance mode manager responsible for the "Maintenance Mode" |
| 164 | * and the "Coming Soon" features. |
| 165 | * |
| 166 | * @since 1.0.0 |
| 167 | * @access public |
| 168 | * |
| 169 | * @var Maintenance_Mode |
| 170 | */ |
| 171 | public $maintenance_mode; |
| 172 | |
| 173 | /** |
| 174 | * Page settings manager. |
| 175 | * |
| 176 | * Holds the page settings manager. |
| 177 | * |
| 178 | * @since 1.0.0 |
| 179 | * @access public |
| 180 | * |
| 181 | * @var Page_Settings_Manager |
| 182 | */ |
| 183 | public $page_settings_manager; |
| 184 | |
| 185 | /** |
| 186 | * Dynamic tags manager. |
| 187 | * |
| 188 | * Holds the dynamic tags manager. |
| 189 | * |
| 190 | * @since 1.0.0 |
| 191 | * @access public |
| 192 | * |
| 193 | * @var Dynamic_Tags_Manager |
| 194 | */ |
| 195 | public $dynamic_tags; |
| 196 | |
| 197 | /** |
| 198 | * Settings. |
| 199 | * |
| 200 | * Holds the plugin settings. |
| 201 | * |
| 202 | * @since 1.0.0 |
| 203 | * @access public |
| 204 | * |
| 205 | * @var Settings |
| 206 | */ |
| 207 | public $settings; |
| 208 | |
| 209 | /** |
| 210 | * Role Manager. |
| 211 | * |
| 212 | * Holds the plugin role manager. |
| 213 | * |
| 214 | * @since 2.0.0 |
| 215 | * @access public |
| 216 | * |
| 217 | * @var Core\RoleManager\Role_Manager |
| 218 | */ |
| 219 | public $role_manager; |
| 220 | |
| 221 | /** |
| 222 | * Admin. |
| 223 | * |
| 224 | * Holds the plugin admin. |
| 225 | * |
| 226 | * @since 1.0.0 |
| 227 | * @access public |
| 228 | * |
| 229 | * @var Admin |
| 230 | */ |
| 231 | public $admin; |
| 232 | |
| 233 | /** |
| 234 | * Tools. |
| 235 | * |
| 236 | * Holds the plugin tools. |
| 237 | * |
| 238 | * @since 1.0.0 |
| 239 | * @access public |
| 240 | * |
| 241 | * @var Tools |
| 242 | */ |
| 243 | public $tools; |
| 244 | |
| 245 | /** |
| 246 | * Preview. |
| 247 | * |
| 248 | * Holds the plugin preview. |
| 249 | * |
| 250 | * @since 1.0.0 |
| 251 | * @access public |
| 252 | * |
| 253 | * @var Preview |
| 254 | */ |
| 255 | public $preview; |
| 256 | |
| 257 | /** |
| 258 | * Editor. |
| 259 | * |
| 260 | * Holds the plugin editor. |
| 261 | * |
| 262 | * @since 1.0.0 |
| 263 | * @access public |
| 264 | * |
| 265 | * @var Editor |
| 266 | */ |
| 267 | public $editor; |
| 268 | |
| 269 | /** |
| 270 | * Frontend. |
| 271 | * |
| 272 | * Holds the plugin frontend. |
| 273 | * |
| 274 | * @since 1.0.0 |
| 275 | * @access public |
| 276 | * |
| 277 | * @var Frontend |
| 278 | */ |
| 279 | public $frontend; |
| 280 | |
| 281 | /** |
| 282 | * Heartbeat. |
| 283 | * |
| 284 | * Holds the plugin heartbeat. |
| 285 | * |
| 286 | * @since 1.0.0 |
| 287 | * @access public |
| 288 | * |
| 289 | * @var Heartbeat |
| 290 | */ |
| 291 | public $heartbeat; |
| 292 | |
| 293 | /** |
| 294 | * System info. |
| 295 | * |
| 296 | * Holds the system info data. |
| 297 | * |
| 298 | * @since 1.0.0 |
| 299 | * @access public |
| 300 | * |
| 301 | * @var System_Info_Module |
| 302 | */ |
| 303 | public $system_info; |
| 304 | |
| 305 | /** |
| 306 | * Template library manager. |
| 307 | * |
| 308 | * Holds the template library manager. |
| 309 | * |
| 310 | * @since 1.0.0 |
| 311 | * @access public |
| 312 | * |
| 313 | * @var TemplateLibrary\Manager |
| 314 | */ |
| 315 | public $templates_manager; |
| 316 | |
| 317 | /** |
| 318 | * Skins manager. |
| 319 | * |
| 320 | * Holds the skins manager. |
| 321 | * |
| 322 | * @since 1.0.0 |
| 323 | * @access public |
| 324 | * |
| 325 | * @var Skins_Manager |
| 326 | */ |
| 327 | public $skins_manager; |
| 328 | |
| 329 | /** |
| 330 | * Files manager. |
| 331 | * |
| 332 | * Holds the plugin files manager. |
| 333 | * |
| 334 | * @since 2.1.0 |
| 335 | * @access public |
| 336 | * |
| 337 | * @var Files_Manager |
| 338 | */ |
| 339 | public $files_manager; |
| 340 | |
| 341 | /** |
| 342 | * Assets manager. |
| 343 | * |
| 344 | * Holds the plugin assets manager. |
| 345 | * |
| 346 | * @since 2.6.0 |
| 347 | * @access public |
| 348 | * |
| 349 | * @var Assets_Manager |
| 350 | */ |
| 351 | public $assets_manager; |
| 352 | |
| 353 | /** |
| 354 | * Icons Manager. |
| 355 | * |
| 356 | * Holds the plugin icons manager. |
| 357 | * |
| 358 | * @access public |
| 359 | * |
| 360 | * @var Icons_Manager |
| 361 | */ |
| 362 | public $icons_manager; |
| 363 | |
| 364 | /** |
| 365 | * WordPress widgets manager. |
| 366 | * |
| 367 | * Holds the WordPress widgets manager. |
| 368 | * |
| 369 | * @since 1.0.0 |
| 370 | * @access public |
| 371 | * |
| 372 | * @var WordPress_Widgets_Manager |
| 373 | */ |
| 374 | public $wordpress_widgets_manager; |
| 375 | |
| 376 | /** |
| 377 | * Modules manager. |
| 378 | * |
| 379 | * Holds the plugin modules manager. |
| 380 | * |
| 381 | * @since 1.0.0 |
| 382 | * @access public |
| 383 | * |
| 384 | * @var Modules_Manager |
| 385 | */ |
| 386 | public $modules_manager; |
| 387 | |
| 388 | /** |
| 389 | * Beta testers. |
| 390 | * |
| 391 | * Holds the plugin beta testers. |
| 392 | * |
| 393 | * @since 1.0.0 |
| 394 | * @access public |
| 395 | * |
| 396 | * @var Beta_Testers |
| 397 | */ |
| 398 | public $beta_testers; |
| 399 | |
| 400 | /** |
| 401 | * Inspector. |
| 402 | * |
| 403 | * Holds the plugin inspector data. |
| 404 | * |
| 405 | * @since 2.1.2 |
| 406 | * @access public |
| 407 | * |
| 408 | * @var Inspector |
| 409 | */ |
| 410 | public $inspector; |
| 411 | |
| 412 | /** |
| 413 | * Common functionality. |
| 414 | * |
| 415 | * Holds the plugin common functionality. |
| 416 | * |
| 417 | * @since 2.3.0 |
| 418 | * @access public |
| 419 | * |
| 420 | * @var CommonApp |
| 421 | */ |
| 422 | public $common; |
| 423 | |
| 424 | /** |
| 425 | * Log manager. |
| 426 | * |
| 427 | * Holds the plugin log manager. |
| 428 | * |
| 429 | * @access public |
| 430 | * |
| 431 | * @var Log_Manager |
| 432 | */ |
| 433 | public $logger; |
| 434 | |
| 435 | /** |
| 436 | * Dev tools. |
| 437 | * |
| 438 | * Holds the plugin dev tools. |
| 439 | * |
| 440 | * @access private |
| 441 | * |
| 442 | * @var Dev_Tools |
| 443 | */ |
| 444 | private $dev_tools; |
| 445 | |
| 446 | /** |
| 447 | * Upgrade manager. |
| 448 | * |
| 449 | * Holds the plugin upgrade manager. |
| 450 | * |
| 451 | * @access public |
| 452 | * |
| 453 | * @var Core\Upgrade\Manager |
| 454 | */ |
| 455 | public $upgrade; |
| 456 | |
| 457 | /** |
| 458 | * Tasks manager. |
| 459 | * |
| 460 | * Holds the plugin tasks manager. |
| 461 | * |
| 462 | * @var Core\Upgrade\Custom_Tasks_Manager |
| 463 | */ |
| 464 | public $custom_tasks; |
| 465 | |
| 466 | /** |
| 467 | * Kits manager. |
| 468 | * |
| 469 | * Holds the plugin kits manager. |
| 470 | * |
| 471 | * @access public |
| 472 | * |
| 473 | * @var Core\Kits\Manager |
| 474 | */ |
| 475 | public $kits_manager; |
| 476 | |
| 477 | /** |
| 478 | * @var \Elementor\Data\V2\Manager |
| 479 | */ |
| 480 | public $data_manager_v2; |
| 481 | |
| 482 | /** |
| 483 | * Legacy mode. |
| 484 | * |
| 485 | * Holds the plugin legacy mode data. |
| 486 | * |
| 487 | * @access public |
| 488 | * |
| 489 | * @var array |
| 490 | */ |
| 491 | public $legacy_mode; |
| 492 | |
| 493 | /** |
| 494 | * App. |
| 495 | * |
| 496 | * Holds the plugin app data. |
| 497 | * |
| 498 | * @since 3.0.0 |
| 499 | * @access public |
| 500 | * |
| 501 | * @var Core\App\App |
| 502 | */ |
| 503 | public $app; |
| 504 | |
| 505 | /** |
| 506 | * WordPress API. |
| 507 | * |
| 508 | * Holds the methods that interact with WordPress Core API. |
| 509 | * |
| 510 | * @since 3.0.0 |
| 511 | * @access public |
| 512 | * |
| 513 | * @var Wp_Api |
| 514 | */ |
| 515 | public $wp; |
| 516 | |
| 517 | /** |
| 518 | * Experiments manager. |
| 519 | * |
| 520 | * Holds the plugin experiments manager. |
| 521 | * |
| 522 | * @since 3.1.0 |
| 523 | * @access public |
| 524 | * |
| 525 | * @var Experiments_Manager |
| 526 | */ |
| 527 | public $experiments; |
| 528 | |
| 529 | /** |
| 530 | * Uploads manager. |
| 531 | * |
| 532 | * Holds the plugin uploads manager responsible for handling file uploads |
| 533 | * that are not done with WordPress Media. |
| 534 | * |
| 535 | * @since 3.3.0 |
| 536 | * @access public |
| 537 | * |
| 538 | * @var Uploads_Manager |
| 539 | */ |
| 540 | public $uploads_manager; |
| 541 | |
| 542 | /** |
| 543 | * Breakpoints manager. |
| 544 | * |
| 545 | * Holds the plugin breakpoints manager. |
| 546 | * |
| 547 | * @since 3.2.0 |
| 548 | * @access public |
| 549 | * |
| 550 | * @var Breakpoints_Manager |
| 551 | */ |
| 552 | public $breakpoints; |
| 553 | |
| 554 | /** |
| 555 | * Assets loader. |
| 556 | * |
| 557 | * Holds the plugin assets loader responsible for conditionally enqueuing |
| 558 | * styles and script assets that were pre-enabled. |
| 559 | * |
| 560 | * @since 3.3.0 |
| 561 | * @access public |
| 562 | * |
| 563 | * @var Assets_Loader |
| 564 | */ |
| 565 | public $assets_loader; |
| 566 | |
| 567 | /** |
| 568 | * Clone. |
| 569 | * |
| 570 | * Disable class cloning and throw an error on object clone. |
| 571 | * |
| 572 | * The whole idea of the singleton design pattern is that there is a single |
| 573 | * object. Therefore, we don't want the object to be cloned. |
| 574 | * |
| 575 | * @access public |
| 576 | * @since 1.0.0 |
| 577 | */ |
| 578 | public function __clone() { |
| 579 | // Cloning instances of the class is forbidden. |
| 580 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Wakeup. |
| 585 | * |
| 586 | * Disable unserializing of the class. |
| 587 | * |
| 588 | * @access public |
| 589 | * @since 1.0.0 |
| 590 | */ |
| 591 | public function __wakeup() { |
| 592 | // Unserializing instances of the class is forbidden. |
| 593 | _doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'elementor' ), '1.0.0' ); |
| 594 | } |
| 595 | |
| 596 | /** |
| 597 | * Instance. |
| 598 | * |
| 599 | * Ensures only one instance of the plugin class is loaded or can be loaded. |
| 600 | * |
| 601 | * @since 1.0.0 |
| 602 | * @access public |
| 603 | * @static |
| 604 | * |
| 605 | * @return Plugin An instance of the class. |
| 606 | */ |
| 607 | public static function instance() { |
| 608 | if ( is_null( self::$instance ) ) { |
| 609 | self::$instance = new self(); |
| 610 | |
| 611 | /** |
| 612 | * Elementor loaded. |
| 613 | * |
| 614 | * Fires when Elementor was fully loaded and instantiated. |
| 615 | * |
| 616 | * @since 1.0.0 |
| 617 | */ |
| 618 | do_action( 'elementor/loaded' ); |
| 619 | } |
| 620 | |
| 621 | return self::$instance; |
| 622 | } |
| 623 | |
| 624 | /** |
| 625 | * Init. |
| 626 | * |
| 627 | * Initialize Elementor Plugin. Register Elementor support for all the |
| 628 | * supported post types and initialize Elementor components. |
| 629 | * |
| 630 | * @since 1.0.0 |
| 631 | * @access public |
| 632 | */ |
| 633 | public function init() { |
| 634 | $this->add_cpt_support(); |
| 635 | |
| 636 | $this->init_components(); |
| 637 | |
| 638 | /** |
| 639 | * Elementor init. |
| 640 | * |
| 641 | * Fires when Elementor components are initialized. |
| 642 | * |
| 643 | * After Elementor finished loading but before any headers are sent. |
| 644 | * |
| 645 | * @since 1.0.0 |
| 646 | */ |
| 647 | do_action( 'elementor/init' ); |
| 648 | } |
| 649 | |
| 650 | /** |
| 651 | * Get install time. |
| 652 | * |
| 653 | * Retrieve the time when Elementor was installed. |
| 654 | * |
| 655 | * @since 2.6.0 |
| 656 | * @access public |
| 657 | * @static |
| 658 | * |
| 659 | * @return int Unix timestamp when Elementor was installed. |
| 660 | */ |
| 661 | public function get_install_time() { |
| 662 | $installed_time = get_option( '_elementor_installed_time' ); |
| 663 | |
| 664 | if ( ! $installed_time ) { |
| 665 | $installed_time = time(); |
| 666 | |
| 667 | update_option( '_elementor_installed_time', $installed_time ); |
| 668 | } |
| 669 | |
| 670 | return $installed_time; |
| 671 | } |
| 672 | |
| 673 | /** |
| 674 | * @since 2.3.0 |
| 675 | * @access public |
| 676 | */ |
| 677 | public function on_rest_api_init() { |
| 678 | // On admin/frontend sometimes the rest API is initialized after the common is initialized. |
| 679 | if ( ! $this->common ) { |
| 680 | $this->init_common(); |
| 681 | } |
| 682 | } |
| 683 | |
| 684 | /** |
| 685 | * Init components. |
| 686 | * |
| 687 | * Initialize Elementor components. Register actions, run setting manager, |
| 688 | * initialize all the components that run elementor, and if in admin page |
| 689 | * initialize admin components. |
| 690 | * |
| 691 | * @since 1.0.0 |
| 692 | * @access private |
| 693 | */ |
| 694 | private function init_components() { |
| 695 | $this->experiments = new Experiments_Manager(); |
| 696 | $this->breakpoints = new Breakpoints_Manager(); |
| 697 | $this->inspector = new Inspector(); |
| 698 | |
| 699 | Settings_Manager::run(); |
| 700 | |
| 701 | $this->db = new DB(); |
| 702 | $this->controls_manager = new Controls_Manager(); |
| 703 | $this->documents = new Documents_Manager(); |
| 704 | $this->kits_manager = new Kits_Manager(); |
| 705 | $this->schemes_manager = new Schemes_Manager(); |
| 706 | $this->elements_manager = new Elements_Manager(); |
| 707 | $this->widgets_manager = new Widgets_Manager(); |
| 708 | $this->skins_manager = new Skins_Manager(); |
| 709 | $this->files_manager = new Files_Manager(); |
| 710 | $this->assets_manager = new Assets_Manager(); |
| 711 | $this->icons_manager = new Icons_Manager(); |
| 712 | $this->settings = new Settings(); |
| 713 | $this->tools = new Tools(); |
| 714 | $this->editor = new Editor(); |
| 715 | $this->preview = new Preview(); |
| 716 | $this->frontend = new Frontend(); |
| 717 | $this->maintenance_mode = new Maintenance_Mode(); |
| 718 | $this->dynamic_tags = new Dynamic_Tags_Manager(); |
| 719 | $this->modules_manager = new Modules_Manager(); |
| 720 | $this->templates_manager = new TemplateLibrary\Manager(); |
| 721 | $this->role_manager = new Core\RoleManager\Role_Manager(); |
| 722 | $this->system_info = new System_Info_Module(); |
| 723 | $this->revisions_manager = new Revisions_Manager(); |
| 724 | $this->images_manager = new Images_Manager(); |
| 725 | $this->wp = new Wp_Api(); |
| 726 | $this->assets_loader = new Assets_Loader(); |
| 727 | $this->uploads_manager = new Uploads_Manager(); |
| 728 | |
| 729 | User::init(); |
| 730 | Api::init(); |
| 731 | Tracker::init(); |
| 732 | |
| 733 | $this->upgrade = new Core\Upgrade\Manager(); |
| 734 | $this->custom_tasks = new Core\Upgrade\Custom_Tasks_Manager(); |
| 735 | |
| 736 | $this->app = new Core\App\App(); |
| 737 | |
| 738 | if ( is_admin() ) { |
| 739 | $this->heartbeat = new Heartbeat(); |
| 740 | $this->wordpress_widgets_manager = new WordPress_Widgets_Manager(); |
| 741 | $this->admin = new Admin(); |
| 742 | $this->beta_testers = new Beta_Testers(); |
| 743 | new Elementor_3_Re_Migrate_Globals(); |
| 744 | } |
| 745 | } |
| 746 | |
| 747 | /** |
| 748 | * @since 2.3.0 |
| 749 | * @access public |
| 750 | */ |
| 751 | public function init_common() { |
| 752 | $this->common = new CommonApp(); |
| 753 | |
| 754 | $this->common->init_components(); |
| 755 | } |
| 756 | |
| 757 | /** |
| 758 | * Get Legacy Mode |
| 759 | * |
| 760 | * @since 3.0.0 |
| 761 | * @deprecated 3.1.0 Use `Plugin::$instance->experiments->is_feature_active()` instead |
| 762 | * |
| 763 | * @param string $mode_name Optional. Default is null |
| 764 | * |
| 765 | * @return bool|bool[] |
| 766 | */ |
| 767 | public function get_legacy_mode( $mode_name = null ) { |
| 768 | self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation |
| 769 | ->deprecated_function( __METHOD__, '3.1.0', 'Plugin::$instance->experiments->is_feature_active()' ); |
| 770 | |
| 771 | $legacy_mode = [ |
| 772 | 'elementWrappers' => ! self::$instance->experiments->is_feature_active( 'e_dom_optimization' ), |
| 773 | ]; |
| 774 | |
| 775 | if ( ! $mode_name ) { |
| 776 | return $legacy_mode; |
| 777 | } |
| 778 | |
| 779 | if ( isset( $legacy_mode[ $mode_name ] ) ) { |
| 780 | return $legacy_mode[ $mode_name ]; |
| 781 | } |
| 782 | |
| 783 | // If there is no legacy mode with the given mode name; |
| 784 | return false; |
| 785 | } |
| 786 | |
| 787 | /** |
| 788 | * Add custom post type support. |
| 789 | * |
| 790 | * Register Elementor support for all the supported post types defined by |
| 791 | * the user in the admin screen and saved as `elementor_cpt_support` option |
| 792 | * in WordPress `$wpdb->options` table. |
| 793 | * |
| 794 | * If no custom post type selected, usually in new installs, this method |
| 795 | * will return the two default post types: `page` and `post`. |
| 796 | * |
| 797 | * @since 1.0.0 |
| 798 | * @access private |
| 799 | */ |
| 800 | private function add_cpt_support() { |
| 801 | $cpt_support = get_option( 'elementor_cpt_support', self::ELEMENTOR_DEFAULT_POST_TYPES ); |
| 802 | |
| 803 | foreach ( $cpt_support as $cpt_slug ) { |
| 804 | add_post_type_support( $cpt_slug, 'elementor' ); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | /** |
| 809 | * Register autoloader. |
| 810 | * |
| 811 | * Elementor autoloader loads all the classes needed to run the plugin. |
| 812 | * |
| 813 | * @since 1.6.0 |
| 814 | * @access private |
| 815 | */ |
| 816 | private function register_autoloader() { |
| 817 | require_once ELEMENTOR_PATH . '/includes/autoloader.php'; |
| 818 | |
| 819 | Autoloader::run(); |
| 820 | } |
| 821 | |
| 822 | /** |
| 823 | * Plugin Magic Getter |
| 824 | * |
| 825 | * @since 3.1.0 |
| 826 | * @access public |
| 827 | * |
| 828 | * @param $property |
| 829 | * @return mixed |
| 830 | * @throws \Exception |
| 831 | */ |
| 832 | public function __get( $property ) { |
| 833 | if ( 'posts_css_manager' === $property ) { |
| 834 | self::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_argument( 'Plugin::$instance->posts_css_manager', '2.7.0', 'Plugin::$instance->files_manager' ); |
| 835 | |
| 836 | return $this->files_manager; |
| 837 | } |
| 838 | |
| 839 | if ( 'data_manager' === $property ) { |
| 840 | return Data_Manager::instance(); |
| 841 | } |
| 842 | |
| 843 | if ( property_exists( $this, $property ) ) { |
| 844 | throw new \Exception( 'Cannot access private property' ); |
| 845 | } |
| 846 | |
| 847 | return null; |
| 848 | } |
| 849 | |
| 850 | /** |
| 851 | * Plugin constructor. |
| 852 | * |
| 853 | * Initializing Elementor plugin. |
| 854 | * |
| 855 | * @since 1.0.0 |
| 856 | * @access private |
| 857 | */ |
| 858 | private function __construct() { |
| 859 | $this->register_autoloader(); |
| 860 | |
| 861 | $this->logger = Log_Manager::instance(); |
| 862 | $this->data_manager_v2 = Data_Manager_V2::instance(); |
| 863 | |
| 864 | Maintenance::init(); |
| 865 | Compatibility::register_actions(); |
| 866 | |
| 867 | add_action( 'init', [ $this, 'init' ], 0 ); |
| 868 | add_action( 'rest_api_init', [ $this, 'on_rest_api_init' ] ); |
| 869 | } |
| 870 | |
| 871 | final public static function get_title() { |
| 872 | return esc_html__( 'Elementor', 'elementor' ); |
| 873 | } |
| 874 | } |
| 875 | |
| 876 | if ( ! defined( 'ELEMENTOR_TESTS' ) ) { |
| 877 | // In tests we run the instance manually. |
| 878 | Plugin::instance(); |
| 879 | } |
| 880 |