Make WordPress Core

Changeset 60003


Ignore:
Timestamp:
03/17/2025 01:01:24 PM (2 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.

Location:
trunk/src/wp-includes
Files:
2 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}
  • trunk/src/wp-includes/default-filters.php

    r59980 r60003  
    552552add_action( 'plugins_loaded', 'wp_initialize_theme_preview_hooks', 1 );
    553553
     554// Site preview for Classic Theme.
     555add_action( 'init', 'wp_initialize_site_preview_hooks', 1 );
     556
    554557// Calendar widget cache.
    555558add_action( 'save_post', 'delete_get_calendar_cache' );
Note: See TracChangeset for help on using the changeset viewer.