PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.3
Elementor Website Builder – more than just a page builder v3.4.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | core/editor/editor.php +436 -257 4.3.0-beta23.4.3 View file →
@@ -1,16 +1,23 @@
1 1 <?php
2 2 namespace Elementor\Core\Editor;
3 3
4 +use Elementor\Api;
5 +use Elementor\Core\Breakpoints\Breakpoint;
4 6 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 7 use Elementor\Core\Common\Modules\Ajax\Module;
8 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 9 use Elementor\Core\Debug\Loading_Inspection_Manager;
7 -use Elementor\Core\Editor\Loader\Editor_Loader;
8 -use Elementor\Core\Utils\Assets_Config_Provider;
9 -use Elementor\Core\Utils\Collection;
10 +use Elementor\Core\Files\Assets\Files_Upload_Handler;
11 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
10 12 use Elementor\Core\Settings\Manager as SettingsManager;
13 +use Elementor\Icons_Manager;
11 14 use Elementor\Plugin;
15 +use Elementor\Settings;
16 +use Elementor\Shapes;
12 17 use Elementor\TemplateLibrary\Source_Local;
18 +use Elementor\Tools;
19 +use Elementor\User;
13 20 use Elementor\Utils;
14 21 use Elementor\Core\Editor\Data;
15 22
16 23 if ( ! defined( 'ABSPATH' ) ) {
@@ -27,8 +34,14 @@
27 34 */
28 35 class Editor {
29 36
30 37 /**
38 + * The nonce key for Elementor editor.
39 + * @deprecated 2.3.0
40 + */
41 + const EDITING_NONCE_KEY = 'elementor-editing';
42 +
43 + /**
31 44 * User capability required to access Elementor editor.
32 45 */
33 46 const EDITING_CAPABILITY = 'edit_posts';
34 47
@@ -61,18 +74,8 @@
61 74 */
62 75 public $notice_bar;
63 76
64 77 /**
65 - * @var Promotion
66 - */
67 - public $promotion;
68 -
69 - /**
70 - * @var Editor_Loader
71 - */
72 - private $loader;
73 -
74 - /**
75 78 * Init.
76 79 *
77 80 * Initialize Elementor editor. Registers all needed actions to run Elementor,
78 81 * removes conflicting actions etc.
@@ -81,11 +84,11 @@
81 84 *
82 85 * @since 1.0.0
83 86 * @access public
84 87 *
85 - * @param bool $to_die Optional. Whether to die at the end. Default is `true`.
88 + * @param bool $die Optional. Whether to die at the end. Default is `true`.
86 89 */
87 - public function init( $to_die = true ) {
90 + public function init( $die = true ) {
88 91 if ( empty( $_REQUEST['post'] ) ) {
89 92 return;
90 93 }
91 94
@@ -117,10 +120,8 @@
117 120
118 121 // Send MIME Type header like WP admin-header.
119 122 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
120 123
121 - self::send_document_isolation_policy_header();
122 -
123 124 add_filter( 'show_admin_bar', '__return_false' );
124 125
125 126 // Remove all WordPress actions
126 127 remove_all_actions( 'wp_head' );
@@ -159,12 +160,12 @@
159 160 Utils::do_not_cache();
160 161
161 162 do_action( 'elementor/editor/init' );
162 163
163 - $this->get_loader()->print_root_template();
164 + $this->print_editor_template();
164 165
165 166 // From the action it's an empty string, from tests its `false`
166 - if ( false !== $to_die ) {
167 + if ( false !== $die ) {
167 168 die;
168 169 }
169 170 }
170 171
@@ -212,67 +213,8 @@
212 213 die;
213 214 }
214 215
215 216 /**
216 - * Whether the current request targets the Elementor editor.
217 - *
218 - * Unlike `is_edit_mode()`, this is not affected by temporary `set_edit_mode()` overrides.
219 - *
220 - * @since 4.1.0
221 - * @access public
222 - *
223 - * @return bool Whether the current request targets the Elementor editor.
224 - */
225 - public function is_editor_request() {
226 - $common = Plugin::$instance->common;
227 -
228 - if ( $common ) {
229 - /** @var Module ajax */
230 - $ajax_data = $common->get_component( 'ajax' )->get_current_action_data();
231 -
232 - if ( ! empty( $ajax_data ) && 'get_document_config' === $ajax_data['action'] ) {
233 - return true;
234 - }
235 - }
236 -
237 - if ( $this->is_editor_admin_screen() ) {
238 - return true;
239 - }
240 -
241 - return $this->is_editor_ajax_request();
242 - }
243 -
244 - private function is_editor_admin_screen(): bool {
245 - if ( ! function_exists( 'get_current_screen' ) ) {
246 - return false;
247 - }
248 -
249 - $screen = get_current_screen();
250 -
251 - if ( ! $screen ) {
252 - return false;
253 - }
254 -
255 - return isset( $_GET['action'] ) && 'elementor' === $_GET['action'] && in_array( $screen->base, [ 'post', 'toplevel_page_elementor' ], true );
256 - }
257 -
258 - private function is_editor_ajax_request(): bool {
259 - $actions = apply_filters( 'elementor/editor/ajax_actions', [
260 - 'elementor',
261 -
262 - // Templates
263 - 'elementor_get_templates',
264 - 'elementor_save_template',
265 - 'elementor_get_template',
266 - 'elementor_delete_template',
267 - 'elementor_import_template',
268 - 'elementor_library_direct_actions',
269 - ] );
270 -
271 - return isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], $actions, true );
272 - }
273 -
274 - /**
275 217 * Whether the edit mode is active.
276 218 *
277 219 * Used to determine whether we are in the edit mode.
278 220 *
@@ -369,10 +311,8 @@
369 311 return get_user_by( 'id', $locked_user );
370 312 }
371 313
372 314 /**
373 - * NOTICE: This method not in use, it's here for backward compatibility.
374 - *
375 315 * Print Editor Template.
376 316 *
377 317 * Include the wrapper template of the editor.
378 318 *
@@ -395,14 +335,173 @@
395 335 remove_action( 'wp_enqueue_scripts', [ $this, __FUNCTION__ ], 999999 );
396 336
397 337 global $wp_styles, $wp_scripts;
398 338
339 + $plugin = Plugin::$instance;
340 +
399 341 // Reset global variable
400 342 $wp_styles = new \WP_Styles(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
401 343 $wp_scripts = new \WP_Scripts(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
402 344
403 - $this->get_loader()->register_scripts();
345 + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS ) ? '' : '.min';
404 346
347 + wp_register_script(
348 + 'elementor-editor-modules',
349 + ELEMENTOR_ASSETS_URL . 'js/editor-modules' . $suffix . '.js',
350 + [
351 + 'elementor-common-modules',
352 + ],
353 + ELEMENTOR_VERSION,
354 + true
355 + );
356 +
357 + wp_register_script(
358 + 'elementor-editor-document',
359 + ELEMENTOR_ASSETS_URL . 'js/editor-document' . $suffix . '.js',
360 + [
361 + 'elementor-common-modules',
362 + ],
363 + ELEMENTOR_VERSION,
364 + true
365 + );
366 + // Hack for waypoint with editor mode.
367 + wp_register_script(
368 + 'elementor-waypoints',
369 + ELEMENTOR_ASSETS_URL . 'lib/waypoints/waypoints-for-editor.js',
370 + [
371 + 'jquery',
372 + ],
373 + '4.0.2',
374 + true
375 + );
376 +
377 + wp_register_script(
378 + 'perfect-scrollbar',
379 + ELEMENTOR_ASSETS_URL . 'lib/perfect-scrollbar/js/perfect-scrollbar' . $suffix . '.js',
380 + [],
381 + '1.4.0',
382 + true
383 + );
384 +
385 + wp_register_script(
386 + 'jquery-easing',
387 + ELEMENTOR_ASSETS_URL . 'lib/jquery-easing/jquery-easing' . $suffix . '.js',
388 + [
389 + 'jquery',
390 + ],
391 + '1.3.2',
392 + true
393 + );
394 +
395 + wp_register_script(
396 + 'nprogress',
397 + ELEMENTOR_ASSETS_URL . 'lib/nprogress/nprogress' . $suffix . '.js',
398 + [],
399 + '0.2.0',
400 + true
401 + );
402 +
403 + wp_register_script(
404 + 'tipsy',
405 + ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $suffix . '.js',
406 + [
407 + 'jquery',
408 + ],
409 + '1.0.0',
410 + true
411 + );
412 +
413 + wp_register_script(
414 + 'jquery-elementor-select2',
415 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/js/e-select2.full' . $suffix . '.js',
416 + [
417 + 'jquery',
418 + ],
419 + '4.0.6-rc.1',
420 + true
421 + );
422 +
423 + wp_register_script(
424 + 'flatpickr',
425 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.js',
426 + [
427 + 'jquery',
428 + ],
429 + '1.12.0',
430 + true
431 + );
432 +
433 + wp_register_script(
434 + 'ace',
435 + 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js',
436 + [],
437 + '1.2.5',
438 + true
439 + );
440 +
441 + wp_register_script(
442 + 'ace-language-tools',
443 + 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ext-language_tools.js',
444 + [
445 + 'ace',
446 + ],
447 + '1.2.5',
448 + true
449 + );
450 +
451 + wp_register_script(
452 + 'jquery-hover-intent',
453 + ELEMENTOR_ASSETS_URL . 'lib/jquery-hover-intent/jquery-hover-intent' . $suffix . '.js',
454 + [],
455 + '1.0.0',
456 + true
457 + );
458 +
459 + wp_register_script(
460 + 'nouislider',
461 + ELEMENTOR_ASSETS_URL . 'lib/nouislider/nouislider' . $suffix . '.js',
462 + [],
463 + '13.0.0',
464 + true
465 + );
466 +
467 + wp_register_script(
468 + 'pickr',
469 + ELEMENTOR_ASSETS_URL . 'lib/pickr/pickr.min.js',
470 + [],
471 + '1.5.0',
472 + true
473 + );
474 +
475 + wp_register_script(
476 + 'elementor-editor',
477 + ELEMENTOR_ASSETS_URL . 'js/editor' . $suffix . '.js',
478 + [
479 + 'elementor-common',
480 + 'elementor-editor-modules',
481 + 'elementor-editor-document',
482 + 'wp-auth-check',
483 + 'jquery-ui-sortable',
484 + 'jquery-ui-resizable',
485 + 'perfect-scrollbar',
486 + 'nprogress',
487 + 'tipsy',
488 + 'imagesloaded',
489 + 'heartbeat',
490 + 'jquery-elementor-select2',
491 + 'flatpickr',
492 + 'ace',
493 + 'ace-language-tools',
494 + 'jquery-hover-intent',
495 + 'nouislider',
496 + 'pickr',
497 + 'react',
498 + 'react-dom',
499 + ],
500 + ELEMENTOR_VERSION,
501 + true
502 + );
503 +
405 504 /**
406 505 * Before editor enqueue scripts.
407 506 *
408 507 * Fires before Elementor editor scripts are enqueued.
@@ -413,13 +512,117 @@
413 512
414 513 // Tweak for WP Admin menu icons
415 514 wp_print_styles( 'editor-buttons' );
416 515
417 - $this->get_loader()->enqueue_scripts();
516 + $settings = SettingsManager::get_settings_managers_config();
517 + // Moved to document since 2.9.0.
518 + unset( $settings['page'] );
418 519
419 - Plugin::$instance->controls_manager->enqueue_control_scripts();
520 + $document = Plugin::$instance->documents->get_doc_or_auto_save( $this->post_id );
521 + $kits_manager = Plugin::$instance->kits_manager;
420 522
523 + $page_title_selector = $kits_manager->get_current_settings( 'page_title_selector' );
524 +
525 + $page_title_selector .= ', .elementor-page-title .elementor-heading-title';
526 +
527 + $config = [
528 + 'initial_document' => $document->get_config(),
529 + 'version' => ELEMENTOR_VERSION,
530 + 'home_url' => home_url(),
531 + 'admin_settings_url' => admin_url( 'admin.php?page=' . Settings::PAGE_ID ),
532 + 'admin_tools_url' => admin_url( 'admin.php?page=' . Tools::PAGE_ID ),
533 + 'autosave_interval' => AUTOSAVE_INTERVAL,
534 + 'tabs' => $plugin->controls_manager->get_tabs(),
535 + 'controls' => $plugin->controls_manager->get_controls_data(),
536 + 'elements' => $plugin->elements_manager->get_element_types_config(),
537 + 'schemes' => [
538 + 'items' => $plugin->schemes_manager->get_registered_schemes_data(),
539 + 'enabled_schemes' => Schemes_Manager::get_enabled_schemes(),
540 + ],
541 + 'globals' => [
542 + 'defaults_enabled' => [
543 + 'colors' => $kits_manager->is_custom_colors_enabled(),
544 + 'typography' => $kits_manager->is_custom_typography_enabled(),
545 + ],
546 + ],
547 + 'icons' => [
548 + 'libraries' => Icons_Manager::get_icon_manager_tabs_config(),
549 + 'goProURL' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=icon-library&utm_campaign=gopro&utm_medium=wp-dash' ),
550 + ],
551 + 'filesUpload' => [
552 + 'unfilteredFiles' => Files_Upload_Handler::is_enabled(),
553 + ],
554 + 'fa4_to_fa5_mapping_url' => ELEMENTOR_ASSETS_URL . 'lib/font-awesome/migration/mapping.js',
555 + 'default_schemes' => $plugin->schemes_manager->get_schemes_defaults(),
556 + 'settings' => $settings,
557 + 'system_schemes' => $plugin->schemes_manager->get_system_schemes(),
558 + 'wp_editor' => $this->get_wp_editor_config(),
559 + 'settings_page_link' => Settings::get_url(),
560 + 'tools_page_link' => Tools::get_url(),
561 + 'elementor_site' => 'https://go.elementor.com/about-elementor/',
562 + 'docs_elementor_site' => 'https://go.elementor.com/docs/',
563 + 'help_the_content_url' => 'https://go.elementor.com/the-content-missing/',
564 + 'help_flexbox_bc_url' => 'https://go.elementor.com/flexbox-layout-bc/',
565 + 'elementPromotionURL' => 'https://go.elementor.com/go-pro-%s',
566 + 'dynamicPromotionURL' => 'https://go.elementor.com/go-pro-dynamic-tag',
567 + 'additional_shapes' => Shapes::get_additional_shapes_for_config(),
568 + 'user' => [
569 + 'restrictions' => $plugin->role_manager->get_user_restrictions_array(),
570 + 'is_administrator' => current_user_can( 'manage_options' ),
571 + 'introduction' => User::get_introduction_meta(),
572 + ],
573 + 'preview' => [
574 + 'help_preview_error_url' => 'https://go.elementor.com/preview-not-loaded/',
575 + 'help_preview_http_error_url' => 'https://go.elementor.com/preview-not-loaded/#permissions',
576 + 'help_preview_http_error_500_url' => 'https://go.elementor.com/500-error/',
577 + 'debug_data' => Loading_Inspection_Manager::instance()->run_inspections(),
578 + ],
579 + 'locale' => get_locale(),
580 + 'rich_editing_enabled' => filter_var( get_user_meta( get_current_user_id(), 'rich_editing', true ), FILTER_VALIDATE_BOOLEAN ),
581 + 'page_title_selector' => $page_title_selector,
582 + 'tinymceHasCustomConfig' => class_exists( 'Tinymce_Advanced' ) || class_exists( 'Advanced_Editor_Tools' ),
583 + 'inlineEditing' => Plugin::$instance->widgets_manager->get_inline_editing_config(),
584 + 'dynamicTags' => Plugin::$instance->dynamic_tags->get_config(),
585 + 'ui' => [
586 + 'darkModeStylesheetURL' => ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
587 + 'defaultGenericFonts' => $kits_manager->get_current_settings( 'default_generic_fonts' ),
588 + ],
589 + // Empty array for BC to avoid errors.
590 + 'i18n' => [],
591 + // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
592 + 'responsive' => [
593 + 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
594 + 'icons_map' => Plugin::$instance->breakpoints->get_responsive_icons_classes_map(),
595 + ],
596 + ];
597 +
598 + if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) {
599 + $config['promotionWidgets'] = Api::get_promotion_widgets();
600 + }
601 +
602 + $this->bc_move_document_filters();
603 +
421 604 /**
605 + * Localize editor settings.
606 + *
607 + * Filters the editor localized settings.
608 + *
609 + * @since 1.0.0
610 + *
611 + * @param array $config Editor configuration.
612 + * @param int $post_id The ID of the current post being edited.
613 + */
614 + $config = apply_filters( 'elementor/editor/localize_settings', $config );
615 +
616 + Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config );
617 +
618 + wp_enqueue_script( 'elementor-editor' );
619 +
620 + wp_set_script_translations( 'elementor-editor', 'elementor' );
621 +
622 + $plugin->controls_manager->enqueue_control_scripts();
623 +
624 + /**
422 625 * After editor enqueue scripts.
423 626 *
424 627 * Fires after Elementor editor scripts are enqueued.
425 628 *
@@ -445,13 +648,84 @@
445 648 * @since 1.0.0
446 649 */
447 650 do_action( 'elementor/editor/before_enqueue_styles' );
448 651
449 - $this->get_loader()->register_styles();
450 - $this->get_loader()->enqueue_styles();
652 + $suffix = Utils::is_script_debug() ? '' : '.min';
451 653
452 - $this->enqueue_theme_ui_styles();
654 + $direction_suffix = is_rtl() ? '-rtl' : '';
453 655
656 + wp_register_style(
657 + 'font-awesome',
658 + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css',
659 + [],
660 + '4.7.0'
661 + );
662 +
663 + wp_register_style(
664 + 'elementor-select2',
665 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css',
666 + [],
667 + '4.0.6-rc.1'
668 + );
669 +
670 + wp_register_style(
671 + 'google-font-roboto',
672 + 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
673 + [],
674 + ELEMENTOR_VERSION
675 + );
676 +
677 + wp_register_style(
678 + 'flatpickr',
679 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css',
680 + [],
681 + '1.12.0'
682 + );
683 +
684 + wp_register_style(
685 + 'pickr',
686 + ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css',
687 + [],
688 + '1.5.0'
689 + );
690 +
691 + wp_register_style(
692 + 'elementor-editor',
693 + ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css',
694 + [
695 + 'elementor-common',
696 + 'elementor-select2',
697 + 'elementor-icons',
698 + 'wp-auth-check',
699 + 'google-font-roboto',
700 + 'flatpickr',
701 + 'pickr',
702 + ],
703 + ELEMENTOR_VERSION
704 + );
705 +
706 + wp_enqueue_style( 'elementor-editor' );
707 +
708 + $ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
709 +
710 + if ( 'light' !== $ui_theme ) {
711 + $ui_theme_media_queries = 'all';
712 +
713 + if ( 'auto' === $ui_theme ) {
714 + $ui_theme_media_queries = '(prefers-color-scheme: dark)';
715 + }
716 +
717 + wp_enqueue_style(
718 + 'elementor-editor-dark-mode',
719 + ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
720 + [
721 + 'elementor-editor',
722 + ],
723 + ELEMENTOR_VERSION,
724 + $ui_theme_media_queries
725 + );
726 + }
727 +
454 728 $breakpoints = Plugin::$instance->breakpoints->get_breakpoints();
455 729
456 730 // The two breakpoints under 'tablet' need to be checked for values.
457 731 if ( $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ]->is_custom() || $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA ]->is_enabled() ) {
@@ -470,44 +744,51 @@
470 744 */
471 745 do_action( 'elementor/editor/after_enqueue_styles' );
472 746 }
473 747
474 - private function enqueue_theme_ui_styles() {
475 - $ui_theme_selected = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
748 + /**
749 + * Get WordPress editor config.
750 + *
751 + * Config the default WordPress editor with custom settings for Elementor use.
752 + *
753 + * @since 1.9.0
754 + * @access private
755 + */
756 + private function get_wp_editor_config() {
757 + // Remove all TinyMCE plugins.
758 + remove_all_filters( 'mce_buttons', 10 );
759 + remove_all_filters( 'mce_external_plugins', 10 );
476 760
477 - $ui_themes = [
478 - 'light',
479 - 'dark',
480 - ];
761 + if ( ! class_exists( '\_WP_Editors', false ) ) {
762 + require ABSPATH . WPINC . '/class-wp-editor.php';
763 + }
481 764
482 - if ( 'auto' === $ui_theme_selected || ! in_array( $ui_theme_selected, $ui_themes, true ) ) {
483 - $ui_light_theme_media_queries = '(prefers-color-scheme: light)';
484 - $ui_dark_theme_media_queries = '(prefers-color-scheme: dark)';
485 - } else {
486 - $ui_light_theme_media_queries = 'none';
487 - $ui_dark_theme_media_queries = 'none';
765 + // WordPress 4.8 and higher
766 + if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) {
767 + \_WP_Editors::print_default_editor_scripts();
768 + \_WP_Editors::print_tinymce_scripts();
769 + }
770 + ob_start();
488 771
489 - if ( 'light' === $ui_theme_selected ) {
490 - $ui_light_theme_media_queries = 'all';
491 - } elseif ( 'dark' === $ui_theme_selected ) {
492 - $ui_dark_theme_media_queries = 'all';
493 - }
494 - }
772 + wp_editor(
773 + '%%EDITORCONTENT%%',
774 + 'elementorwpeditor',
775 + [
776 + 'editor_class' => 'elementor-wp-editor',
777 + 'editor_height' => 250,
778 + 'drag_drop_upload' => true,
779 + ]
780 + );
495 781
496 - $this->enqueue_theme_ui( 'light', $ui_light_theme_media_queries );
497 - $this->enqueue_theme_ui( 'dark', $ui_dark_theme_media_queries );
498 - }
782 + $config = ob_get_clean();
499 783
500 - private function enqueue_theme_ui( $ui_theme, $ui_theme_media_queries = 'all' ) {
501 - $suffix = Utils::is_script_debug() ? '' : '.min';
784 + // Don't call \_WP_Editors methods again
785 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 );
786 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 );
502 787
503 - wp_enqueue_style(
504 - 'e-theme-ui-' . $ui_theme,
505 - ELEMENTOR_ASSETS_URL . 'css/theme-' . $ui_theme . $suffix . '.css',
506 - [],
507 - ELEMENTOR_VERSION,
508 - $ui_theme_media_queries
509 - );
788 + \_WP_Editors::editor_js();
789 +
790 + return $config;
510 791 }
511 792
512 793 /**
513 794 * Editor head trigger.
@@ -548,11 +829,13 @@
548 829 $plugin->controls_manager->render_controls();
549 830 $plugin->widgets_manager->render_widgets_content();
550 831 $plugin->elements_manager->render_elements_content();
551 832
833 + $plugin->schemes_manager->print_schemes_templates();
834 +
552 835 $plugin->dynamic_tags->print_templates();
553 836
554 - $this->get_loader()->register_additional_templates();
837 + $this->init_editor_templates();
555 838
556 839 /**
557 840 * Elementor editor footer.
558 841 *
@@ -588,12 +871,11 @@
588 871 * @since 1.0.0
589 872 * @access public
590 873 */
591 874 public function __construct() {
592 - Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() );
875 + Plugin::$instance->data_manager->register_controller( Data\Globals\Controller::class );
593 876
594 877 $this->notice_bar = new Notice_Bar();
595 - $this->promotion = new Promotion();
596 878
597 879 add_action( 'admin_action_elementor', [ $this, 'init' ] );
598 880 add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] );
599 881
@@ -599,89 +881,11 @@
599 881
600 882 // Handle autocomplete feature for URL control.
601 883 add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
602 884 add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
603 -
604 - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
605 885 }
606 886
607 887 /**
608 - * Whether the Document-Isolation-Policy header should be sent on the
609 - * Elementor editor screen and the editor preview iframe.
610 - *
611 - * DIP places the document in its own agent cluster, which is the prerequisite
612 - * for cross-origin isolation features such as SharedArrayBuffer (required by
613 - * WordPress core's client-side media processing introduced in WP 7.1).
614 - *
615 - * Both the editor parent document and the preview iframe must send the same
616 - * DIP header so they join the same agent cluster and synchronous DOM access
617 - * between them (e.g. `iframe.contentWindow.elementorFrontend`) keeps working.
618 - *
619 - * The header is only honored by browsers on a secure context (HTTPS or
620 - * localhost) so the helper short-circuits on insecure origins to avoid
621 - * sending a header that the browser will ignore.
622 - *
623 - * @since 4.1.0
624 - *
625 - * @return bool
626 - */
627 - public static function should_use_document_isolation_policy() {
628 - if ( ! is_ssl() ) {
629 - $raw_host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
630 - $host = strtolower( (string) strtok( $raw_host, ':' ) );
631 -
632 - if ( 'localhost' !== $host && ! str_ends_with( $host, '.localhost' ) ) {
633 - return false;
634 - }
635 - }
636 -
637 - /**
638 - * Filters whether Elementor sends the Document-Isolation-Policy header
639 - * on the editor screen and preview iframe.
640 - *
641 - * @since 4.1.0
642 - *
643 - * @param bool $enabled Whether DIP is enabled. Defaults to true on a secure context.
644 - */
645 - return (bool) apply_filters( 'elementor/editor/use_document_isolation_policy', true );
646 - }
647 -
648 - /**
649 - * Send the Document-Isolation-Policy header for the current response.
650 - *
651 - * Safe to call from both the Elementor editor screen handler and the
652 - * preview iframe handler. No-op when {@see self::should_use_document_isolation_policy()}
653 - * returns false.
654 - *
655 - * @since 4.1.0
656 - */
657 - public static function send_document_isolation_policy_header() {
658 - if ( ! self::should_use_document_isolation_policy() || headers_sent() ) {
659 - return;
660 - }
661 -
662 - header( 'Document-Isolation-Policy: isolate-and-credentialless' );
663 - }
664 -
665 - /**
666 - * Signals to WordPress that Elementor is replacing the block editor on its own editor page,
667 - * so that block-editor-specific behaviour (e.g. WP 7.0 COOP/COEP isolation headers) is not
668 - * applied when the Elementor editor is active.
669 - *
670 - * @param bool $replace Whether the editor is being replaced.
671 - * @param \WP_Post $post The post being edited.
672 - *
673 - * @return bool
674 - */
675 - public function filter_replace_editor( $replace, $post ) {
676 - if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
677 - return true;
678 - }
679 -
680 - return $replace;
681 - }
682 -
683 - /**
684 888 * @since 2.2.0
685 889 * @access public
686 890 */
687 891 public function filter_wp_link_query_args( $query ) {
@@ -713,82 +917,57 @@
713 917
714 918 return $results;
715 919 }
716 920
717 - public function set_post_id( $post_id ) {
718 - $this->post_id = $post_id;
719 - }
720 -
721 921 /**
722 - * Get loader.
922 + * Init editor templates.
723 923 *
724 - * @return Editor_Loader
924 + * Initialize default elementor templates used in the editor panel.
925 + *
926 + * @since 1.7.0
927 + * @access private
725 928 */
726 - private function get_loader() {
727 - if ( ! $this->loader ) {
728 - $this->loader = new Editor_Loader(
729 - new Collection( [
730 - 'assets_url' => ELEMENTOR_ASSETS_URL,
731 - 'min_suffix' => ( Utils::is_script_debug() || Utils::is_elementor_tests() ) ? '' : '.min',
732 - 'direction_suffix' => is_rtl() ? '-rtl' : '',
733 - ] ),
734 - ( new Assets_Config_Provider() )->set_path_resolver(
735 - function ( $name ) {
736 - return ELEMENTOR_ASSETS_PATH . "js/packages/{$name}/{$name}.asset.php";
737 - }
738 - )
739 - );
929 + private function init_editor_templates() {
930 + $template_names = [
931 + 'global',
932 + 'panel',
933 + 'panel-elements',
934 + 'repeater',
935 + 'templates',
936 + 'navigator',
937 + 'hotkeys',
938 + 'responsive-bar',
939 + ];
740 940
741 - $this->loader->init();
941 + foreach ( $template_names as $template_name ) {
942 + Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" );
742 943 }
743 -
744 - return $this->loader;
745 944 }
746 945
747 - /**
748 - * Get elements presets.
749 - *
750 - * @return array
751 - */
752 - public function get_elements_presets() {
753 - $element_types = Plugin::$instance->elements_manager->get_element_types();
754 - $presets = [];
946 + private function bc_move_document_filters() {
947 + global $wp_filter;
755 948
756 - foreach ( $element_types as $el_type => $element ) {
757 - $this->check_element_for_presets( $element, $el_type, $presets );
758 - }
949 + $old_tag = 'elementor/editor/localize_settings';
950 + $new_tag = 'elementor/document/config';
759 951
760 - return $presets;
761 - }
762 -
763 - /**
764 - * @return void
765 - */
766 - private function check_element_for_presets( $element, $el_type, &$presets ) {
767 - $element_presets = $element->get_panel_presets();
768 -
769 - if ( empty( $element_presets ) ) {
952 + if ( ! has_filter( $old_tag ) ) {
770 953 return;
771 954 }
772 955
773 - foreach ( $element_presets as $key => $preset ) {
774 - $this->maybe_add_preset( $el_type, $preset, $key, $presets );
775 - }
776 - }
956 + foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) {
957 + foreach ( $filters as $filter_id => $filter_args ) {
958 + if ( 2 === $filter_args['accepted_args'] ) {
959 + remove_filter( $old_tag, $filter_id, $priority );
777 960
778 - /**
779 - * @return void
780 - */
781 - private function maybe_add_preset( $el_type, $preset, $key, &$presets ) {
782 - if ( $this->is_valid_preset( $el_type, $preset ) ) {
783 - $presets[ $key ] = $preset;
961 + add_filter( $new_tag, $filter_args['function'], $priority, 2 );
962 +
963 + // TODO: Hard deprecation
964 + // _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' );
965 + }
966 + }
784 967 }
785 968 }
786 969
787 - /**
788 - * @return boolean
789 - */
790 - private function is_valid_preset( $el_type, $preset ) {
791 - return isset( $preset['replacements']['custom']['originalWidget'] )
792 - && $el_type === $preset['replacements']['custom']['originalWidget'];
970 + public function set_post_id( $post_id ) {
971 + $this->post_id = $post_id;
793 972 }
794 973 }