| @@ -1,10 +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 | -use Elementor\Core\Settings\Manager as SettingsManager; | |
| 7 | 5 | |
| 8 | 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | 7 | exit; // Exit if accessed directly. |
| 10 | 8 | } |
| @@ -19,13 +17,8 @@ | ||
| 19 | 17 | */ |
| 20 | 18 | class Preview extends App { |
| 21 | 19 | |
| 22 | 20 | /** |
| 23 | - * The priority of the preview enqueued styles. | |
| 24 | - */ | |
| 25 | - const ENQUEUED_STYLES_PRIORITY = 20; | |
| 26 | - | |
| 27 | - /** | |
| 28 | 21 | * Is Preview. |
| 29 | 22 | * |
| 30 | 23 | * Holds a flag if current request is a preview. |
| 31 | 24 | * The flag is not related to a specific post or edit permissions. |
| @@ -84,9 +77,9 @@ | ||
| 84 | 77 | register_shutdown_function( function () { |
| 85 | 78 | $e = error_get_last(); |
| 86 | 79 | if ( $e ) { |
| 87 | 80 | echo '<div id="elementor-preview-debug-error"><pre>'; |
| 88 | - Utils::print_unescaped_internal_string( $e['message'] ); | |
| 81 | + echo $e['message']; | |
| 89 | 82 | echo '</pre></div>'; |
| 90 | 83 | } |
| 91 | 84 | } ); |
| 92 | 85 | } |
| @@ -93,13 +86,8 @@ | ||
| 93 | 86 | |
| 94 | 87 | $this->post_id = get_the_ID(); |
| 95 | 88 | $this->is_preview = true; |
| 96 | 89 | |
| 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 | 90 | // Don't redirect to permalink. |
| 103 | 91 | remove_action( 'template_redirect', 'redirect_canonical' ); |
| 104 | 92 | |
| 105 | 93 | // Compatibility with Yoast SEO plugin when 'Removes unneeded query variables from the URL' enabled. |
| @@ -113,9 +101,9 @@ | ||
| 113 | 101 | |
| 114 | 102 | add_action( 'wp_enqueue_scripts', function() { |
| 115 | 103 | $this->enqueue_styles(); |
| 116 | 104 | $this->enqueue_scripts(); |
| 117 | - }, self::ENQUEUED_STYLES_PRIORITY ); | |
| 105 | + } ); | |
| 118 | 106 | |
| 119 | 107 | add_filter( 'the_content', [ $this, 'builder_wrapper' ], 999999 ); |
| 120 | 108 | |
| 121 | 109 | add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| @@ -200,20 +188,8 @@ | ||
| 200 | 188 | return true; |
| 201 | 189 | } |
| 202 | 190 | |
| 203 | 191 | /** |
| 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 | 192 | * Builder wrapper. |
| 217 | 193 | * |
| 218 | 194 | * Used to add an empty HTML wrapper for the builder, the javascript will add |
| 219 | 195 | * the content later. |
| @@ -252,13 +228,11 @@ | ||
| 252 | 228 | wp_add_inline_script( 'jquery-migrate', 'jQuery.holdReady( true );' ); |
| 253 | 229 | |
| 254 | 230 | Plugin::$instance->frontend->enqueue_styles(); |
| 255 | 231 | |
| 256 | - Plugin::$instance->elements_manager->enqueue_elements_styles(); | |
| 257 | - | |
| 258 | 232 | Plugin::$instance->widgets_manager->enqueue_widgets_styles(); |
| 259 | 233 | |
| 260 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 234 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 261 | 235 | |
| 262 | 236 | $direction_suffix = is_rtl() ? '-rtl' : ''; |
| 263 | 237 | |
| 264 | 238 | wp_register_style( |
| @@ -276,19 +250,20 @@ | ||
| 276 | 250 | ], |
| 277 | 251 | ELEMENTOR_VERSION |
| 278 | 252 | ); |
| 279 | 253 | |
| 280 | - wp_enqueue_style( | |
| 281 | - 'e-theme-ui-light', | |
| 282 | - $this->get_css_assets_url( 'theme-light' ), | |
| 283 | - [], | |
| 284 | - ELEMENTOR_VERSION | |
| 285 | - ); | |
| 254 | + wp_enqueue_style( 'editor-preview' ); | |
| 286 | 255 | |
| 287 | - wp_enqueue_style( 'editor-preview' ); | |
| 256 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { | |
| 257 | + wp_register_style( | |
| 258 | + 'editor-preview-legacy', | |
| 259 | + ELEMENTOR_ASSETS_URL . 'css/editor-preview-legacy' . $direction_suffix . $suffix . '.css', | |
| 260 | + [], | |
| 261 | + ELEMENTOR_VERSION | |
| 262 | + ); | |
| 288 | 263 | |
| 289 | - // Handle the 'wp audio' in editor preview. | |
| 290 | - wp_enqueue_style( 'wp-mediaelement' ); | |
| 264 | + wp_enqueue_style( 'editor-preview-legacy' ); | |
| 265 | + } | |
| 291 | 266 | |
| 292 | 267 | /** |
| 293 | 268 | * Preview enqueue styles. |
| 294 | 269 | * |
| @@ -312,11 +287,10 @@ | ||
| 312 | 287 | private function enqueue_scripts() { |
| 313 | 288 | Plugin::$instance->frontend->register_scripts(); |
| 314 | 289 | |
| 315 | 290 | Plugin::$instance->widgets_manager->enqueue_widgets_scripts(); |
| 316 | - Plugin::$instance->elements_manager->enqueue_elements_scripts(); | |
| 317 | 291 | |
| 318 | - $suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 292 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; | |
| 319 | 293 | |
| 320 | 294 | wp_enqueue_script( |
| 321 | 295 | 'elementor-inline-editor', |
| 322 | 296 | ELEMENTOR_ASSETS_URL . 'lib/inline-editor/js/inline-editor' . $suffix . '.js', |
| @@ -323,11 +297,8 @@ | ||
| 323 | 297 | [], |
| 324 | 298 | ELEMENTOR_VERSION, |
| 325 | 299 | true |
| 326 | 300 | ); |
| 327 | - | |
| 328 | - // Handle the 'wp audio' in editor preview. | |
| 329 | - wp_enqueue_script( 'wp-mediaelement' ); | |
| 330 | 301 | |
| 331 | 302 | /** |
| 332 | 303 | * Preview enqueue scripts. |
| 333 | 304 | * |