PluginProbe
Elementor Website Builder – more than just a page builder / 3.32.2
Elementor Website Builder – more than just a page builder v3.32.2
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 +8 -159 4.3.0-beta23.32.2 View file →
@@ -3,11 +3,10 @@
3 3
4 4 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
5 5 use Elementor\Core\Common\Modules\Ajax\Module;
6 6 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;
7 +use Elementor\Core\Editor\Loader\Editor_Loader_Factory;
8 +use Elementor\Core\Editor\Loader\Editor_Loader_Interface;
10 9 use Elementor\Core\Settings\Manager as SettingsManager;
11 10 use Elementor\Plugin;
12 11 use Elementor\TemplateLibrary\Source_Local;
13 12 use Elementor\Utils;
@@ -66,9 +65,9 @@
66 65 */
67 66 public $promotion;
68 67
69 68 /**
70 - * @var Editor_Loader
69 + * @var Editor_Loader_Interface
71 70 */
72 71 private $loader;
73 72
74 73 /**
@@ -81,11 +80,11 @@
81 80 *
82 81 * @since 1.0.0
83 82 * @access public
84 83 *
85 - * @param bool $to_die Optional. Whether to die at the end. Default is `true`.
84 + * @param bool $die Optional. Whether to die at the end. Default is `true`.
86 85 */
87 - public function init( $to_die = true ) {
86 + public function init( $die = true ) {
88 87 if ( empty( $_REQUEST['post'] ) ) {
89 88 return;
90 89 }
91 90
@@ -117,10 +116,8 @@
117 116
118 117 // Send MIME Type header like WP admin-header.
119 118 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
120 119
121 - self::send_document_isolation_policy_header();
122 -
123 120 add_filter( 'show_admin_bar', '__return_false' );
124 121
125 122 // Remove all WordPress actions
126 123 remove_all_actions( 'wp_head' );
@@ -162,9 +159,9 @@
162 159
163 160 $this->get_loader()->print_root_template();
164 161
165 162 // From the action it's an empty string, from tests its `false`
166 - if ( false !== $to_die ) {
163 + if ( false !== $die ) {
167 164 die;
168 165 }
169 166 }
170 167
@@ -212,67 +209,8 @@
212 209 die;
213 210 }
214 211
215 212 /**
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 213 * Whether the edit mode is active.
276 214 *
277 215 * Used to determine whether we are in the edit mode.
278 216 *
@@ -599,89 +537,11 @@
599 537
600 538 // Handle autocomplete feature for URL control.
601 539 add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
602 540 add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
603 -
604 - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
605 541 }
606 542
607 543 /**
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 544 * @since 2.2.0
685 545 * @access public
686 546 */
687 547 public function filter_wp_link_query_args( $query ) {
@@ -720,24 +580,13 @@
720 580
721 581 /**
722 582 * Get loader.
723 583 *
724 - * @return Editor_Loader
584 + * @return Editor_Loader_Interface
725 585 */
726 586 private function get_loader() {
727 587 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 - );
588 + $this->loader = Editor_Loader_Factory::create();
740 589
741 590 $this->loader->init();
742 591 }
743 592