mirror of
git://develop.git.wordpress.org/
synced 2025-03-24 05:49:49 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@60003 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
b98b347504
commit
eaeda35de1
@ -856,3 +856,21 @@ function get_classic_theme_supports_block_editor_settings() {
|
||||
|
||||
return $theme_settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize site preview.
|
||||
*
|
||||
* This function sets IFRAME_REQUEST to true if the site preview parameter is set.
|
||||
*
|
||||
* @since 6.8.0
|
||||
*/
|
||||
function wp_initialize_site_preview_hooks() {
|
||||
if (
|
||||
! defined( 'IFRAME_REQUEST' ) &&
|
||||
isset( $_GET['wp_site_preview'] ) &&
|
||||
1 === (int) $_GET['wp_site_preview'] &&
|
||||
current_user_can( 'edit_theme_options' )
|
||||
) {
|
||||
define( 'IFRAME_REQUEST', true );
|
||||
}
|
||||
}
|
||||
|
@ -551,6 +551,9 @@ add_action( 'transition_post_status', '_wp_keep_alive_customize_changeset_depend
|
||||
// Block Theme Previews.
|
||||
add_action( 'plugins_loaded', 'wp_initialize_theme_preview_hooks', 1 );
|
||||
|
||||
// Site preview for Classic Theme.
|
||||
add_action( 'init', 'wp_initialize_site_preview_hooks', 1 );
|
||||
|
||||
// Calendar widget cache.
|
||||
add_action( 'save_post', 'delete_get_calendar_cache' );
|
||||
add_action( 'delete_post', 'delete_get_calendar_cache' );
|
||||
|
Loading…
x
Reference in New Issue
Block a user