Editor: add iframe around post editor.
Adds an iframe around the post editor only if all registered blocks are v3 or higher. Props ellatrix, mukesh27, costdev, oandregal, ramonopoly. Fixes #58626. Built from https://develop.svn.wordpress.org/trunk@56047 git-svn-id: http://core.svn.wordpress.org/trunk@55559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4e0fbeb04c
commit
7696e271f8
|
@ -287,7 +287,9 @@ function get_legacy_widget_block_editor_settings() {
|
||||||
* @since 6.0.0
|
* @since 6.0.0
|
||||||
* @access private
|
* @access private
|
||||||
*
|
*
|
||||||
* @global string $pagenow The filename of the current screen.
|
* @global string $pagenow The filename of the current screen.
|
||||||
|
* @global WP_Styles $wp_styles The WP_Styles current instance.
|
||||||
|
* @global WP_Scripts $wp_scripts The WP_Scripts current instance.
|
||||||
*
|
*
|
||||||
* @return array {
|
* @return array {
|
||||||
* The block editor assets.
|
* The block editor assets.
|
||||||
|
@ -297,65 +299,79 @@ function get_legacy_widget_block_editor_settings() {
|
||||||
* }
|
* }
|
||||||
*/
|
*/
|
||||||
function _wp_get_iframed_editor_assets() {
|
function _wp_get_iframed_editor_assets() {
|
||||||
global $pagenow, $editor_styles;
|
global $wp_styles, $wp_scripts, $pagenow;
|
||||||
|
|
||||||
$script_handles = array(
|
// Keep track of the styles and scripts instance to restore later.
|
||||||
'wp-polyfill',
|
$current_wp_styles = $wp_styles;
|
||||||
);
|
$current_wp_scripts = $wp_scripts;
|
||||||
$style_handles = array(
|
|
||||||
'wp-edit-blocks',
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
// Create new instances to collect the assets.
|
||||||
current_theme_supports( 'wp-block-styles' ) &&
|
$wp_styles = new WP_Styles();
|
||||||
( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 )
|
$wp_scripts = new WP_Scripts();
|
||||||
) {
|
|
||||||
$style_handles[] = 'wp-block-library-theme';
|
/*
|
||||||
|
* Register all currently registered styles and scripts. The actions that
|
||||||
|
* follow enqueue assets, but don't necessarily register them.
|
||||||
|
*/
|
||||||
|
$wp_styles->registered = $current_wp_styles->registered;
|
||||||
|
$wp_scripts->registered = $current_wp_scripts->registered;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We generally do not need reset styles for the iframed editor.
|
||||||
|
* However, if it's a classic theme, margins will be added to every block,
|
||||||
|
* which is reset specifically for list items, so classic themes rely on
|
||||||
|
* these reset styles.
|
||||||
|
*/
|
||||||
|
$wp_styles->done =
|
||||||
|
wp_theme_has_theme_json() ? array( 'wp-reset-editor-styles' ) : array();
|
||||||
|
|
||||||
|
wp_enqueue_script( 'wp-polyfill' );
|
||||||
|
// Enqueue the `editorStyle` handles for all core block, and dependencies.
|
||||||
|
wp_enqueue_style( 'wp-edit-blocks' );
|
||||||
|
|
||||||
|
if ( 'site-editor.php' === $pagenow ) {
|
||||||
|
wp_enqueue_style( 'wp-edit-site' );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( 'widgets.php' === $pagenow || 'customize.php' === $pagenow ) {
|
if ( current_theme_supports( 'wp-block-styles' ) ) {
|
||||||
$style_handles[] = 'wp-widgets';
|
wp_enqueue_style( 'wp-block-library-theme' );
|
||||||
$style_handles[] = 'wp-edit-widgets';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We don't want to load EDITOR scripts in the iframe, only enqueue
|
||||||
|
* front-end assets for the content.
|
||||||
|
*/
|
||||||
|
add_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' );
|
||||||
|
do_action( 'enqueue_block_assets' );
|
||||||
|
remove_filter( 'should_load_block_editor_scripts_and_styles', '__return_false' );
|
||||||
|
|
||||||
$block_registry = WP_Block_Type_Registry::get_instance();
|
$block_registry = WP_Block_Type_Registry::get_instance();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Additionally, do enqueue `editorStyle` assets for all blocks, which
|
||||||
|
* contains editor-only styling for blocks (editor content).
|
||||||
|
*/
|
||||||
foreach ( $block_registry->get_all_registered() as $block_type ) {
|
foreach ( $block_registry->get_all_registered() as $block_type ) {
|
||||||
$style_handles = array_merge(
|
if ( isset( $block_type->editor_style_handles ) && is_array( $block_type->editor_style_handles ) ) {
|
||||||
$style_handles,
|
foreach ( $block_type->editor_style_handles as $style_handle ) {
|
||||||
$block_type->style_handles,
|
wp_enqueue_style( $style_handle );
|
||||||
$block_type->editor_style_handles
|
}
|
||||||
);
|
}
|
||||||
|
|
||||||
$script_handles = array_merge(
|
|
||||||
$script_handles,
|
|
||||||
$block_type->script_handles
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$style_handles = array_unique( $style_handles );
|
|
||||||
$done = wp_styles()->done;
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
wp_print_styles();
|
||||||
// We do not need reset styles for the iframed editor.
|
|
||||||
wp_styles()->done = array( 'wp-reset-editor-styles' );
|
|
||||||
wp_styles()->do_items( $style_handles );
|
|
||||||
wp_styles()->done = $done;
|
|
||||||
|
|
||||||
$styles = ob_get_clean();
|
$styles = ob_get_clean();
|
||||||
|
|
||||||
$script_handles = array_unique( $script_handles );
|
|
||||||
$done = wp_scripts()->done;
|
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
wp_print_head_scripts();
|
||||||
wp_scripts()->done = array();
|
wp_print_footer_scripts();
|
||||||
wp_scripts()->do_items( $script_handles );
|
|
||||||
wp_scripts()->done = $done;
|
|
||||||
|
|
||||||
$scripts = ob_get_clean();
|
$scripts = ob_get_clean();
|
||||||
|
|
||||||
|
// Restore the original instances.
|
||||||
|
$wp_styles = $current_wp_styles;
|
||||||
|
$wp_scripts = $current_wp_scripts;
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'styles' => $styles,
|
'styles' => $styles,
|
||||||
'scripts' => $scripts,
|
'scripts' => $scripts,
|
||||||
|
|
|
@ -1629,7 +1629,7 @@ function wp_default_styles( $styles ) {
|
||||||
$styles->add(
|
$styles->add(
|
||||||
'wp-block-editor-content',
|
'wp-block-editor-content',
|
||||||
"/wp-includes/css/dist/block-editor/content$suffix.css",
|
"/wp-includes/css/dist/block-editor/content$suffix.css",
|
||||||
array()
|
array( 'wp-components' )
|
||||||
);
|
);
|
||||||
|
|
||||||
$wp_edit_blocks_dependencies = array(
|
$wp_edit_blocks_dependencies = array(
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.3-alpha-56046';
|
$wp_version = '6.3-alpha-56047';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue