| @@ -1,9 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\App; |
| 5 | -use Elementor\Core\Editor\Editor; | |
| 6 | 5 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 7 | 6 | |
| 8 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 8 | exit; // Exit if accessed directly. |
| @@ -19,13 +18,8 @@ | ||
| 19 | 18 | */ |
| 20 | 19 | class Preview extends App { |
| 21 | 20 | |
| 22 | 21 | /** |
| 23 | - * The priority of the preview enqueued styles. | |
| 24 | - */ | |
| 25 | - const ENQUEUED_STYLES_PRIORITY = 20; | |
| 26 | - | |
| 27 | - /** | |
| 28 | 22 | * Is Preview. |
| 29 | 23 | * |
| 30 | 24 | * Holds a flag if current request is a preview. |
| 31 | 25 | * The flag is not related to a specific post or edit permissions. |
| @@ -93,13 +87,8 @@ | ||
| 93 | 87 | |
| 94 | 88 | $this->post_id = get_the_ID(); |
| 95 | 89 | $this->is_preview = true; |
| 96 | 90 | |
| 97 | - // Send Document-Isolation-Policy on the preview iframe so it shares | |
| 98 | - // an agent cluster with the editor parent and synchronous DOM access | |
| 99 | - // (e.g. iframe.contentWindow.elementorFrontend) keeps working. | |
| 100 | - Editor::send_document_isolation_policy_header(); | |
| 101 | - | |
| 102 | 91 | // Don't redirect to permalink. |
| 103 | 92 | remove_action( 'template_redirect', 'redirect_canonical' ); |
| 104 | 93 | |
| 105 | 94 | // Compatibility with Yoast SEO plugin when 'Removes unneeded query variables from the URL' enabled. |
| @@ -113,9 +102,9 @@ | ||
| 113 | 102 | |
| 114 | 103 | add_action( 'wp_enqueue_scripts', function() { |
| 115 | 104 | $this->enqueue_styles(); |
| 116 | 105 | $this->enqueue_scripts(); |
| 117 | - }, self::ENQUEUED_STYLES_PRIORITY ); | |
| 106 | + } ); | |
| 118 | 107 | |
| 119 | 108 | add_filter( 'the_content', [ $this, 'builder_wrapper' ], 999999 ); |
| 120 | 109 | |
| 121 | 110 | add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| @@ -200,20 +189,8 @@ | ||
| 200 | 189 | return true; |
| 201 | 190 | } |
| 202 | 191 | |
| 203 | 192 | /** |
| 204 | - * Whether WordPress post preview or Elementor preview iframe is active. | |
| 205 | - * | |
| 206 | - * @since 4.1.0 | |
| 207 | - * @access public | |
| 208 | - * | |
| 209 | - * @return bool | |
| 210 | - */ | |
| 211 | - public function is_editor_or_preview() { | |
| 212 | - return is_preview() || $this->is_preview_mode(); | |
| 213 | - } | |
| 214 | - | |
| 215 | - /** | |
| 216 | 193 | * Builder wrapper. |
| 217 | 194 | * |
| 218 | 195 | * Used to add an empty HTML wrapper for the builder, the javascript will add |
| 219 | 196 | * the content later. |
| @@ -252,13 +229,11 @@ | ||
| 252 | 229 | wp_add_inline_script( 'jquery-migrate', 'jQuery.holdReady( true );' ); |
| 253 | 230 | |
| 254 | 231 | Plugin::$instance->frontend->enqueue_styles(); |
| 255 | 232 | |
| 256 | - Plugin::$instance->elements_manager->enqueue_elements_styles(); | |
| 257 | - | |
| 258 | 233 | Plugin::$instance->widgets_manager->enqueue_widgets_styles(); |
| 259 | 234 | |
| 260 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 235 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 261 | 236 | |
| 262 | 237 | $direction_suffix = is_rtl() ? '-rtl' : ''; |
| 263 | 238 | |
| 264 | 239 | wp_register_style( |
| @@ -285,8 +260,19 @@ | ||
| 285 | 260 | ); |
| 286 | 261 | |
| 287 | 262 | wp_enqueue_style( 'editor-preview' ); |
| 288 | 263 | |
| 264 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { | |
| 265 | + wp_register_style( | |
| 266 | + 'editor-preview-legacy', | |
| 267 | + ELEMENTOR_ASSETS_URL . 'css/editor-preview-legacy' . $direction_suffix . $suffix . '.css', | |
| 268 | + [], | |
| 269 | + ELEMENTOR_VERSION | |
| 270 | + ); | |
| 271 | + | |
| 272 | + wp_enqueue_style( 'editor-preview-legacy' ); | |
| 273 | + } | |
| 274 | + | |
| 289 | 275 | // Handle the 'wp audio' in editor preview. |
| 290 | 276 | wp_enqueue_style( 'wp-mediaelement' ); |
| 291 | 277 | |
| 292 | 278 | /** |
| @@ -312,11 +298,10 @@ | ||
| 312 | 298 | private function enqueue_scripts() { |
| 313 | 299 | Plugin::$instance->frontend->register_scripts(); |
| 314 | 300 | |
| 315 | 301 | Plugin::$instance->widgets_manager->enqueue_widgets_scripts(); |
| 316 | - Plugin::$instance->elements_manager->enqueue_elements_scripts(); | |
| 317 | 302 | |
| 318 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 303 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 319 | 304 | |
| 320 | 305 | wp_enqueue_script( |
| 321 | 306 | 'elementor-inline-editor', |
| 322 | 307 | ELEMENTOR_ASSETS_URL . 'lib/inline-editor/js/inline-editor' . $suffix . '.js', |