PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.0
Elementor Website Builder – more than just a page builder v3.3.0
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 +433 -130 4.1.33.3.0 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\Assets\Files_Upload_Handler;
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' ) ) {
@@ -26,8 +34,14 @@
26 34 */
27 35 class Editor {
28 36
29 37 /**
38 + * The nonce key for Elementor editor.
39 + * @deprecated 2.3.0
40 + */
41 + const EDITING_NONCE_KEY = 'elementor-editing';
42 +
43 + /**
30 44 * User capability required to access Elementor editor.
31 45 */
32 46 const EDITING_CAPABILITY = 'edit_posts';
33 47
@@ -60,18 +74,8 @@
60 74 */
61 75 public $notice_bar;
62 76
63 77 /**
64 - * @var Promotion
65 - */
66 - public $promotion;
67 -
68 - /**
69 - * @var Editor_Loader_Interface
70 - */
71 - private $loader;
72 -
73 - /**
74 78 * Init.
75 79 *
76 80 * Initialize Elementor editor. Registers all needed actions to run Elementor,
77 81 * removes conflicting actions etc.
@@ -80,11 +84,11 @@
80 84 *
81 85 * @since 1.0.0
82 86 * @access public
83 87 *
84 - * @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`.
85 89 */
86 - public function init( $to_die = true ) {
90 + public function init( $die = true ) {
87 91 if ( empty( $_REQUEST['post'] ) ) {
88 92 return;
89 93 }
90 94
@@ -156,12 +160,12 @@
156 160 Utils::do_not_cache();
157 161
158 162 do_action( 'elementor/editor/init' );
159 163
160 - $this->get_loader()->print_root_template();
164 + $this->print_editor_template();
161 165
162 166 // From the action it's an empty string, from tests its `false`
163 - if ( false !== $to_die ) {
167 + if ( false !== $die ) {
164 168 die;
165 169 }
166 170 }
167 171
@@ -197,9 +201,9 @@
197 201
198 202 $document = Plugin::$instance->documents->get( get_the_ID() );
199 203
200 204 if ( ! $document ) {
201 - wp_die( esc_html__( 'Document not found.', 'elementor' ) );
205 + wp_die( __( 'Document not found.', 'elementor' ) );
202 206 }
203 207
204 208 if ( ! $document->is_editable_by_current_user() || ! $document->is_built_with_elementor() ) {
205 209 return;
@@ -307,10 +311,8 @@
307 311 return get_user_by( 'id', $locked_user );
308 312 }
309 313
310 314 /**
311 - * NOTICE: This method not in use, it's here for backward compatibility.
312 - *
313 315 * Print Editor Template.
314 316 *
315 317 * Include the wrapper template of the editor.
316 318 *
@@ -333,14 +335,173 @@
333 335 remove_action( 'wp_enqueue_scripts', [ $this, __FUNCTION__ ], 999999 );
334 336
335 337 global $wp_styles, $wp_scripts;
336 338
339 + $plugin = Plugin::$instance;
340 +
337 341 // Reset global variable
338 342 $wp_styles = new \WP_Styles(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
339 343 $wp_scripts = new \WP_Scripts(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
340 344
341 - $this->get_loader()->register_scripts();
345 + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS ) ? '' : '.min';
342 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 +
343 504 /**
344 505 * Before editor enqueue scripts.
345 506 *
346 507 * Fires before Elementor editor scripts are enqueued.
@@ -351,13 +512,112 @@
351 512
352 513 // Tweak for WP Admin menu icons
353 514 wp_print_styles( 'editor-buttons' );
354 515
355 - $this->get_loader()->enqueue_scripts();
516 + $settings = SettingsManager::get_settings_managers_config();
517 + // Moved to document since 2.9.0.
518 + unset( $settings['page'] );
356 519
357 - 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;
358 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 + ];
592 +
593 + if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) {
594 + $config['promotionWidgets'] = Api::get_promotion_widgets();
595 + }
596 +
597 + $this->bc_move_document_filters();
598 +
359 599 /**
600 + * Localize editor settings.
601 + *
602 + * Filters the editor localized settings.
603 + *
604 + * @since 1.0.0
605 + *
606 + * @param array $config Editor configuration.
607 + * @param int $post_id The ID of the current post being edited.
608 + */
609 + $config = apply_filters( 'elementor/editor/localize_settings', $config );
610 +
611 + Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config );
612 +
613 + wp_enqueue_script( 'elementor-editor' );
614 +
615 + wp_set_script_translations( 'elementor-editor', 'elementor' );
616 +
617 + $plugin->controls_manager->enqueue_control_scripts();
618 +
619 + /**
360 620 * After editor enqueue scripts.
361 621 *
362 622 * Fires after Elementor editor scripts are enqueued.
363 623 *
@@ -383,13 +643,84 @@
383 643 * @since 1.0.0
384 644 */
385 645 do_action( 'elementor/editor/before_enqueue_styles' );
386 646
387 - $this->get_loader()->register_styles();
388 - $this->get_loader()->enqueue_styles();
647 + $suffix = Utils::is_script_debug() ? '' : '.min';
389 648
390 - $this->enqueue_theme_ui_styles();
649 + $direction_suffix = is_rtl() ? '-rtl' : '';
391 650
651 + wp_register_style(
652 + 'font-awesome',
653 + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css',
654 + [],
655 + '4.7.0'
656 + );
657 +
658 + wp_register_style(
659 + 'elementor-select2',
660 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css',
661 + [],
662 + '4.0.6-rc.1'
663 + );
664 +
665 + wp_register_style(
666 + 'google-font-roboto',
667 + 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
668 + [],
669 + ELEMENTOR_VERSION
670 + );
671 +
672 + wp_register_style(
673 + 'flatpickr',
674 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css',
675 + [],
676 + '1.12.0'
677 + );
678 +
679 + wp_register_style(
680 + 'pickr',
681 + ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css',
682 + [],
683 + '1.5.0'
684 + );
685 +
686 + wp_register_style(
687 + 'elementor-editor',
688 + ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css',
689 + [
690 + 'elementor-common',
691 + 'elementor-select2',
692 + 'elementor-icons',
693 + 'wp-auth-check',
694 + 'google-font-roboto',
695 + 'flatpickr',
696 + 'pickr',
697 + ],
698 + ELEMENTOR_VERSION
699 + );
700 +
701 + wp_enqueue_style( 'elementor-editor' );
702 +
703 + $ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
704 +
705 + if ( 'light' !== $ui_theme ) {
706 + $ui_theme_media_queries = 'all';
707 +
708 + if ( 'auto' === $ui_theme ) {
709 + $ui_theme_media_queries = '(prefers-color-scheme: dark)';
710 + }
711 +
712 + wp_enqueue_style(
713 + 'elementor-editor-dark-mode',
714 + ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
715 + [
716 + 'elementor-editor',
717 + ],
718 + ELEMENTOR_VERSION,
719 + $ui_theme_media_queries
720 + );
721 + }
722 +
392 723 $breakpoints = Plugin::$instance->breakpoints->get_breakpoints();
393 724
394 725 // The two breakpoints under 'tablet' need to be checked for values.
395 726 if ( $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ]->is_custom() || $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA ]->is_enabled() ) {
@@ -408,44 +739,51 @@
408 739 */
409 740 do_action( 'elementor/editor/after_enqueue_styles' );
410 741 }
411 742
412 - private function enqueue_theme_ui_styles() {
413 - $ui_theme_selected = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
743 + /**
744 + * Get WordPress editor config.
745 + *
746 + * Config the default WordPress editor with custom settings for Elementor use.
747 + *
748 + * @since 1.9.0
749 + * @access private
750 + */
751 + private function get_wp_editor_config() {
752 + // Remove all TinyMCE plugins.
753 + remove_all_filters( 'mce_buttons', 10 );
754 + remove_all_filters( 'mce_external_plugins', 10 );
414 755
415 - $ui_themes = [
416 - 'light',
417 - 'dark',
418 - ];
756 + if ( ! class_exists( '\_WP_Editors', false ) ) {
757 + require ABSPATH . WPINC . '/class-wp-editor.php';
758 + }
419 759
420 - if ( 'auto' === $ui_theme_selected || ! in_array( $ui_theme_selected, $ui_themes, true ) ) {
421 - $ui_light_theme_media_queries = '(prefers-color-scheme: light)';
422 - $ui_dark_theme_media_queries = '(prefers-color-scheme: dark)';
423 - } else {
424 - $ui_light_theme_media_queries = 'none';
425 - $ui_dark_theme_media_queries = 'none';
760 + // WordPress 4.8 and higher
761 + if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) {
762 + \_WP_Editors::print_default_editor_scripts();
763 + \_WP_Editors::print_tinymce_scripts();
764 + }
765 + ob_start();
426 766
427 - if ( 'light' === $ui_theme_selected ) {
428 - $ui_light_theme_media_queries = 'all';
429 - } elseif ( 'dark' === $ui_theme_selected ) {
430 - $ui_dark_theme_media_queries = 'all';
431 - }
432 - }
767 + wp_editor(
768 + '%%EDITORCONTENT%%',
769 + 'elementorwpeditor',
770 + [
771 + 'editor_class' => 'elementor-wp-editor',
772 + 'editor_height' => 250,
773 + 'drag_drop_upload' => true,
774 + ]
775 + );
433 776
434 - $this->enqueue_theme_ui( 'light', $ui_light_theme_media_queries );
435 - $this->enqueue_theme_ui( 'dark', $ui_dark_theme_media_queries );
436 - }
777 + $config = ob_get_clean();
437 778
438 - private function enqueue_theme_ui( $ui_theme, $ui_theme_media_queries = 'all' ) {
439 - $suffix = Utils::is_script_debug() ? '' : '.min';
779 + // Don't call \_WP_Editors methods again
780 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 );
781 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 );
440 782
441 - wp_enqueue_style(
442 - 'e-theme-ui-' . $ui_theme,
443 - ELEMENTOR_ASSETS_URL . 'css/theme-' . $ui_theme . $suffix . '.css',
444 - [],
445 - ELEMENTOR_VERSION,
446 - $ui_theme_media_queries
447 - );
783 + \_WP_Editors::editor_js();
784 +
785 + return $config;
448 786 }
449 787
450 788 /**
451 789 * Editor head trigger.
@@ -486,11 +824,13 @@
486 824 $plugin->controls_manager->render_controls();
487 825 $plugin->widgets_manager->render_widgets_content();
488 826 $plugin->elements_manager->render_elements_content();
489 827
828 + $plugin->schemes_manager->print_schemes_templates();
829 +
490 830 $plugin->dynamic_tags->print_templates();
491 831
492 - $this->get_loader()->register_additional_templates();
832 + $this->init_editor_templates();
493 833
494 834 /**
495 835 * Elementor editor footer.
496 836 *
@@ -526,12 +866,11 @@
526 866 * @since 1.0.0
527 867 * @access public
528 868 */
529 869 public function __construct() {
530 - Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() );
870 + Plugin::$instance->data_manager->register_controller( Data\Globals\Controller::class );
531 871
532 872 $this->notice_bar = new Notice_Bar();
533 - $this->promotion = new Promotion();
534 873
535 874 add_action( 'admin_action_elementor', [ $this, 'init' ] );
536 875 add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] );
537 876
@@ -537,31 +876,11 @@
537 876
538 877 // Handle autocomplete feature for URL control.
539 878 add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
540 879 add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
541 -
542 - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
543 880 }
544 881
545 882 /**
546 - * Signals to WordPress that Elementor is replacing the block editor on its own editor page,
547 - * so that block-editor-specific behaviour (e.g. WP 7.0 COOP/COEP isolation headers) is not
548 - * applied when the Elementor editor is active.
549 - *
550 - * @param bool $replace Whether the editor is being replaced.
551 - * @param \WP_Post $post The post being edited.
552 - *
553 - * @return bool
554 - */
555 - public function filter_replace_editor( $replace, $post ) {
556 - if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
557 - return true;
558 - }
559 -
560 - return $replace;
561 - }
562 -
563 - /**
564 883 * @since 2.2.0
565 884 * @access public
566 885 */
567 886 public function filter_wp_link_query_args( $query ) {
@@ -577,11 +896,9 @@
577 896 * @since 2.2.0
578 897 * @access public
579 898 */
580 899 public function filter_wp_link_query( $results ) {
581 -
582 - // PHPCS - The user data is not used.
583 - if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
900 + if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) {
584 901 $post_type_object = get_post_type_object( 'post' );
585 902 $post_label = $post_type_object->labels->singular_name;
586 903
587 904 foreach ( $results as & $result ) {
@@ -593,71 +910,57 @@
593 910
594 911 return $results;
595 912 }
596 913
597 - public function set_post_id( $post_id ) {
598 - $this->post_id = $post_id;
599 - }
600 -
601 914 /**
602 - * Get loader.
915 + * Init editor templates.
603 916 *
604 - * @return Editor_Loader_Interface
917 + * Initialize default elementor templates used in the editor panel.
918 + *
919 + * @since 1.7.0
920 + * @access private
605 921 */
606 - private function get_loader() {
607 - if ( ! $this->loader ) {
608 - $this->loader = Editor_Loader_Factory::create();
922 + private function init_editor_templates() {
923 + $template_names = [
924 + 'global',
925 + 'panel',
926 + 'panel-elements',
927 + 'repeater',
928 + 'templates',
929 + 'navigator',
930 + 'hotkeys',
931 + 'responsive-bar',
932 + ];
609 933
610 - $this->loader->init();
934 + foreach ( $template_names as $template_name ) {
935 + Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" );
611 936 }
612 -
613 - return $this->loader;
614 937 }
615 938
616 - /**
617 - * Get elements presets.
618 - *
619 - * @return array
620 - */
621 - public function get_elements_presets() {
622 - $element_types = Plugin::$instance->elements_manager->get_element_types();
623 - $presets = [];
939 + private function bc_move_document_filters() {
940 + global $wp_filter;
624 941
625 - foreach ( $element_types as $el_type => $element ) {
626 - $this->check_element_for_presets( $element, $el_type, $presets );
627 - }
942 + $old_tag = 'elementor/editor/localize_settings';
943 + $new_tag = 'elementor/document/config';
628 944
629 - return $presets;
630 - }
631 -
632 - /**
633 - * @return void
634 - */
635 - private function check_element_for_presets( $element, $el_type, &$presets ) {
636 - $element_presets = $element->get_panel_presets();
637 -
638 - if ( empty( $element_presets ) ) {
945 + if ( ! has_filter( $old_tag ) ) {
639 946 return;
640 947 }
641 948
642 - foreach ( $element_presets as $key => $preset ) {
643 - $this->maybe_add_preset( $el_type, $preset, $key, $presets );
644 - }
645 - }
949 + foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) {
950 + foreach ( $filters as $filter_id => $filter_args ) {
951 + if ( 2 === $filter_args['accepted_args'] ) {
952 + remove_filter( $old_tag, $filter_id, $priority );
646 953
647 - /**
648 - * @return void
649 - */
650 - private function maybe_add_preset( $el_type, $preset, $key, &$presets ) {
651 - if ( $this->is_valid_preset( $el_type, $preset ) ) {
652 - $presets[ $key ] = $preset;
954 + add_filter( $new_tag, $filter_args['function'], $priority, 2 );
955 +
956 + // TODO: Hard deprecation
957 + // _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' );
958 + }
959 + }
653 960 }
654 961 }
655 962
656 - /**
657 - * @return boolean
658 - */
659 - private function is_valid_preset( $el_type, $preset ) {
660 - return isset( $preset['replacements']['custom']['originalWidget'] )
661 - && $el_type === $preset['replacements']['custom']['originalWidget'];
963 + public function set_post_id( $post_id ) {
964 + $this->post_id = $post_id;
662 965 }
663 966 }