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