Make WordPress Core


Ignore:
Timestamp:
03/17/2025 01:01:24 PM (9 months ago)
Author:
joemcgill
Message:

Editor: Support site preview mode for the Site Editor.

This allows the Site Editor to load a preview of the site as an IFRAME_REQUEST by checking for a wp_site_preview query param. By setting the IFRAME_REQUEST constant when loading the preview, the site's admin bar and some third party plugin overlays will not be shown in the preview.

Props wildworks, joemcgill, peterwilsoncc, presstoke, mamaduka, johnbillion, faisal03.
Fixes #63076.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/block-editor.php

    r59775 r60003  
    857857    return $theme_settings;
    858858}
     859
     860/**
     861 * Initialize site preview.
     862 *
     863 * This function sets IFRAME_REQUEST to true if the site preview parameter is set.
     864 *
     865 * @since 6.8.0
     866 */
     867function wp_initialize_site_preview_hooks() {
     868    if (
     869        ! defined( 'IFRAME_REQUEST' ) &&
     870        isset( $_GET['wp_site_preview'] ) &&
     871        1 === (int) $_GET['wp_site_preview'] &&
     872        current_user_can( 'edit_theme_options' )
     873    ) {
     874        define( 'IFRAME_REQUEST', true );
     875    }
     876}
Note: See TracChangeset for help on using the changeset viewer.