Block Editor: Backport inclusion of new editor settings to the core.

This commit includes in the core settings for the gradients theme API stabilized in https://github.com/WordPress/gutenberg/pull/20107, and for the image sizes required for the latest posts feature image https://github.com/WordPress/gutenberg/pull/17151/.

Props: youknowriad, ryelle.
Fixes #49389.
Built from https://develop.svn.wordpress.org/trunk@47240


git-svn-id: http://core.svn.wordpress.org/trunk@47040 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
jorgefilipecosta 2020-02-10 17:52:15 +00:00
parent 7019add74e
commit 76e375434b
2 changed files with 20 additions and 4 deletions

View File

@ -135,6 +135,7 @@ wp_localize_script( 'wp-editor', '_wpMetaBoxUrl', $meta_box_url );
$align_wide = get_theme_support( 'align-wide' ); $align_wide = get_theme_support( 'align-wide' );
$color_palette = current( (array) get_theme_support( 'editor-color-palette' ) ); $color_palette = current( (array) get_theme_support( 'editor-color-palette' ) );
$font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) ); $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) );
$gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) );
/** /**
* Filters the allowed block types for the editor, defaulting to true (all * Filters the allowed block types for the editor, defaulting to true (all
@ -226,6 +227,15 @@ foreach ( $image_size_names as $image_size_slug => $image_size_name ) {
); );
} }
$image_dimensions = array();
$all_sizes = wp_get_registered_image_subsizes();
foreach ( $available_image_sizes as $size ) {
$key = $size['slug'];
if ( isset( $all_sizes[ $key ] ) ) {
$image_dimensions[ $key ] = $all_sizes[ $key ];
}
}
// Lock settings. // Lock settings.
$user_id = wp_check_post_lock( $post->ID ); $user_id = wp_check_post_lock( $post->ID );
if ( $user_id ) { if ( $user_id ) {
@ -278,6 +288,7 @@ $editor_settings = array(
'allowedBlockTypes' => $allowed_block_types, 'allowedBlockTypes' => $allowed_block_types,
'disableCustomColors' => get_theme_support( 'disable-custom-colors' ), 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),
'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ), 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),
'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),
'disablePostFormats' => ! current_theme_supports( 'post-formats' ), 'disablePostFormats' => ! current_theme_supports( 'post-formats' ),
/** This filter is documented in wp-admin/edit-form-advanced.php */ /** This filter is documented in wp-admin/edit-form-advanced.php */
'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ), 'titlePlaceholder' => apply_filters( 'enter_title_here', __( 'Add title' ), $post ),
@ -288,6 +299,7 @@ $editor_settings = array(
'allowedMimeTypes' => get_allowed_mime_types(), 'allowedMimeTypes' => get_allowed_mime_types(),
'styles' => $styles, 'styles' => $styles,
'imageSizes' => $available_image_sizes, 'imageSizes' => $available_image_sizes,
'imageDimensions' => $image_dimensions,
'richEditingEnabled' => user_can_richedit(), 'richEditingEnabled' => user_can_richedit(),
'postLock' => $lock_details, 'postLock' => $lock_details,
'postLockUtils' => array( 'postLockUtils' => array(
@ -320,6 +332,10 @@ if ( false !== $font_sizes ) {
$editor_settings['fontSizes'] = $font_sizes; $editor_settings['fontSizes'] = $font_sizes;
} }
if ( false !== $gradient_presets ) {
$editor_settings['gradients'] = $gradient_presets;
}
if ( ! empty( $post_type_object->template ) ) { if ( ! empty( $post_type_object->template ) ) {
$editor_settings['template'] = $post_type_object->template; $editor_settings['template'] = $post_type_object->template;
$editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false; $editor_settings['templateLock'] = ! empty( $post_type_object->template_lock ) ? $post_type_object->template_lock : false;

View File

@ -13,7 +13,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.4-alpha-47239'; $wp_version = '5.4-alpha-47240';
/** /**
* 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.