WordPress/wp-admin/site-editor.php
noisysocks 935058d178 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Image block: Set image display to grid when no alignment sent to properly align caption on resize
- Update and align template descriptions
- Site Editor - prevent loading state from showing the admin menu.
- Add client side routing for Site Editor
- Navigation: Add clearance for appender in submenus.
- Fix CSS Custom Properties for presets in the site editor
- Add/navigation blocks post processing after migration from menu items
- Allow selector ordering to ensure theme.json root selector margin takes precedence 
- Do not remove theme presets if defaults are hidden
- Format library: fix unsetting highlight color
- FSE: Fix template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity
- ColorPalette: Improving accessibility and visibility
- Update: Make the color popover on the gradient picker appear as expected
- Site Editor: Display a notice if export fails
- Fix docs and function naming for gallery block registration in PHP
- Switch to addEventListener for load event in the navigation block view script
- Fix mistake in _remove_theme_attribute_in_block_template_content
- Better synchronisation between Gutenberg and Core code
- Move the block page templates hook into compat/5.9 folder
- Moves to the template loader hooks and functions into lib/compat folder
- Refactor the gutenberg_is_fse_theme function to use wp_is_block_theme
- Site Editor: Update support doc URL in Welcome Guide
- Global Styles: Add Welcome Guide toggle
- Hide remove control point when removing would break gradient control
- Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin
- Image: Fix resizer controls being hidden in Safari when switching between alignments
- Remove Navigation Menus from WP Admin sidebar
- Site Editor: Hide the block appender in the Template Part editor
- Site Editor: Use server definition for the Template Areas
- Synchronize wp_is_block_theme and block-templates block support with Core
- E2E: Retry login again after a bad nonce request to prevent intermittent test failures 
- Fix theme requirement validation with WP 5.8
- Fix WP 5.9 check for conditionally running code
- Fix post comment form input width
- Border Style Control: Update styling for consistency with border width control
- Fix form-submit styles by adding button classes to the submit-button in post-comments block
- Site Editor: Fix edit template part link in header dropdown
- Move duotone palette to the bottom of global styles gradients
- Fix how appearanceTools works
- Move WP 5.9 wp-admin menus compatibility code to lib/compat folder
- Revert "Site Editor: Set the <title> on the list page to be same as the CPT name"
- Site Editor: Document Actions: add SR text to heading 1
- Do not register global styles CPT in WordPress 5.9
- Global Styles: Move the 'Edit colors' button to a standard menu item
- Fix styles for previews and patterns
- Site Editor: Fix failing E2E test
- Templates: Search for old template names in the parent theme too
- Remove 4 instances of 'gutenberg' text domain from WordPress core
- Fix content loss when ungrouping template parts or reusable blocks
- Simplify the RESET_BLOCK action to fix template part focus mode content loss
- [Global Styles]: Make Blocks section more distinguishable
- Only use block markup for comment form button when using a block theme
- Navigation: Fix vertical alignment of page list in modal.
- Fix: ToggleGroupControl active state
- Remove gutenberg_ prefix from @wordpress/block-library

Props ocean90, oandregal, hellofromtonya, youknowriad.
See #54487.

Built from https://develop.svn.wordpress.org/trunk@52364


git-svn-id: http://core.svn.wordpress.org/trunk@51956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-14 01:57:26 +00:00

137 lines
4.1 KiB
PHP

<?php
/**
* Site Editor administration screen.
*
* @package WordPress
* @subpackage Administration
*/
global $post, $editor_styles;
/** WordPress Administration Bootstrap */
require_once __DIR__ . '/admin.php';
if ( ! current_user_can( 'edit_theme_options' ) ) {
wp_die(
'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
403
);
}
if ( ! wp_is_block_theme() ) {
wp_die( __( 'The theme you are currently using is not compatible with Full Site Editing.' ) );
}
// Used in the HTML title tag.
$title = __( 'Editor (beta)' );
$parent_file = 'themes.php';
// Flag that we're loading the block editor.
$current_screen = get_current_screen();
$current_screen->is_block_editor( true );
// Default to is-fullscreen-mode to avoid jumps in the UI.
add_filter(
'admin_body_class',
static function( $classes ) {
return "$classes is-fullscreen-mode";
}
);
$indexed_template_types = array();
foreach ( get_default_block_template_types() as $slug => $template_type ) {
$template_type['slug'] = (string) $slug;
$indexed_template_types[] = $template_type;
}
$block_editor_context = new WP_Block_Editor_Context();
$custom_settings = array(
'siteUrl' => site_url(),
'postsPerPage' => get_option( 'posts_per_page' ),
'styles' => get_block_editor_theme_styles(),
'defaultTemplateTypes' => $indexed_template_types,
'defaultTemplatePartAreas' => get_allowed_block_template_part_areas(),
'__experimentalBlockPatterns' => WP_Block_Patterns_Registry::get_instance()->get_all_registered(),
'__experimentalBlockPatternCategories' => WP_Block_Pattern_Categories_Registry::get_instance()->get_all_registered(),
);
$editor_settings = get_block_editor_settings( $custom_settings, $block_editor_context );
if ( isset( $_GET['postType'] ) && ! isset( $_GET['postId'] ) ) {
$post_type = get_post_type_object( $_GET['postType'] );
if ( ! $post_type ) {
wp_die( __( 'Invalid post type.' ) );
}
}
$active_global_styles_id = WP_Theme_JSON_Resolver::get_user_custom_post_type_id();
$active_theme = wp_get_theme()->get_stylesheet();
$preload_paths = array(
array( '/wp/v2/media', 'OPTIONS' ),
'/',
'/wp/v2/types?context=edit',
'/wp/v2/types/wp_template?context=edit',
'/wp/v2/types/wp_template-part?context=edit',
'/wp/v2/taxonomies?context=edit',
'/wp/v2/pages?context=edit',
'/wp/v2/categories?context=edit',
'/wp/v2/posts?context=edit',
'/wp/v2/tags?context=edit',
'/wp/v2/templates?context=edit&per_page=-1',
'/wp/v2/template-parts?context=edit&per_page=-1',
'/wp/v2/settings',
'/wp/v2/themes?context=edit&status=active',
'/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit',
'/wp/v2/global-styles/' . $active_global_styles_id,
'/wp/v2/global-styles/themes/' . $active_theme,
);
block_editor_rest_api_preload( $preload_paths, $block_editor_context );
wp_add_inline_script(
'wp-edit-site',
sprintf(
'wp.domReady( function() {
wp.editSite.initializeEditor( "site-editor", %s );
} );',
wp_json_encode( $editor_settings )
)
);
// Preload server-registered block schemas.
wp_add_inline_script(
'wp-blocks',
'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');'
);
wp_add_inline_script(
'wp-blocks',
sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( get_block_categories( $post ) ) ),
'after'
);
wp_enqueue_script( 'wp-edit-site' );
wp_enqueue_script( 'wp-format-library' );
wp_enqueue_style( 'wp-edit-site' );
wp_enqueue_style( 'wp-format-library' );
wp_enqueue_media();
if (
current_theme_supports( 'wp-block-styles' ) ||
( ! is_array( $editor_styles ) || count( $editor_styles ) === 0 )
) {
wp_enqueue_style( 'wp-block-library-theme' );
}
/** This action is documented in wp-admin/edit-form-blocks.php */
do_action( 'enqueue_block_editor_assets' );
require_once ABSPATH . 'wp-admin/admin-header.php';
?>
<div id="site-editor" class="edit-site"></div>
<?php
require_once ABSPATH . 'wp-admin/admin-footer.php';