mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-02 01:20:03 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@52364 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -107,7 +107,7 @@ class WP_Theme_JSON {
|
||||
const PRESETS_METADATA = array(
|
||||
array(
|
||||
'path' => array( 'color', 'palette' ),
|
||||
'override' => false,
|
||||
'override' => array( 'color', 'defaultPalette' ),
|
||||
'value_key' => 'color',
|
||||
'css_vars' => '--wp--preset--color--$slug',
|
||||
'classes' => array(
|
||||
@@ -119,7 +119,7 @@ class WP_Theme_JSON {
|
||||
),
|
||||
array(
|
||||
'path' => array( 'color', 'gradients' ),
|
||||
'override' => false,
|
||||
'override' => array( 'color', 'defaultGradients' ),
|
||||
'value_key' => 'gradient',
|
||||
'css_vars' => '--wp--preset--gradient--$slug',
|
||||
'classes' => array( '.has-$slug-gradient-background' => 'background' ),
|
||||
@@ -397,13 +397,16 @@ class WP_Theme_JSON {
|
||||
private static function maybe_opt_in_into_settings( $theme_json ) {
|
||||
$new_theme_json = $theme_json;
|
||||
|
||||
if ( isset( $new_theme_json['settings']['appearanceTools'] ) ) {
|
||||
if (
|
||||
isset( $new_theme_json['settings']['appearanceTools'] ) &&
|
||||
true === $new_theme_json['settings']['appearanceTools']
|
||||
) {
|
||||
self::do_opt_in_into_settings( $new_theme_json['settings'] );
|
||||
}
|
||||
|
||||
if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) {
|
||||
foreach ( $new_theme_json['settings']['blocks'] as &$block ) {
|
||||
if ( isset( $block['appearanceTools'] ) ) {
|
||||
if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) {
|
||||
self::do_opt_in_into_settings( $block );
|
||||
}
|
||||
}
|
||||
@@ -433,7 +436,9 @@ class WP_Theme_JSON {
|
||||
);
|
||||
|
||||
foreach ( $to_opt_in as $path ) {
|
||||
if ( null === _wp_array_get( $context, $path, null ) ) {
|
||||
// Use "unset prop" as a marker instead of "null" because
|
||||
// "null" can be a valid value for some props (e.g. blockGap).
|
||||
if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) {
|
||||
_wp_array_set( $context, $path, true );
|
||||
}
|
||||
}
|
||||
@@ -1502,9 +1507,9 @@ class WP_Theme_JSON {
|
||||
* we remove it from the theme presets.
|
||||
*/
|
||||
$nodes = self::get_setting_nodes( $incoming_data );
|
||||
$slugs_global = self::get_slugs_not_to_override( $this->theme_json );
|
||||
$slugs_global = self::get_default_slugs( $this->theme_json, array( 'settings' ) );
|
||||
foreach ( $nodes as $node ) {
|
||||
$slugs_node = self::get_slugs_not_to_override( $this->theme_json, $node['path'] );
|
||||
$slugs_node = self::get_default_slugs( $this->theme_json, $node['path'] );
|
||||
$slugs = array_merge_recursive( $slugs_global, $slugs_node );
|
||||
|
||||
// Replace the spacing.units.
|
||||
@@ -1516,6 +1521,8 @@ class WP_Theme_JSON {
|
||||
|
||||
// Replace the presets.
|
||||
foreach ( self::PRESETS_METADATA as $preset ) {
|
||||
$override_preset = self::should_override_preset( $this->theme_json, $node['path'], $preset['override'] );
|
||||
|
||||
foreach ( self::VALID_ORIGINS as $origin ) {
|
||||
$path = array_merge( $node['path'], $preset['path'], array( $origin ) );
|
||||
$content = _wp_array_get( $incoming_data, $path, null );
|
||||
@@ -1525,13 +1532,12 @@ class WP_Theme_JSON {
|
||||
|
||||
if (
|
||||
( 'theme' !== $origin ) ||
|
||||
( 'theme' === $origin && $preset['override'] )
|
||||
( 'theme' === $origin && $override_preset )
|
||||
) {
|
||||
_wp_array_set( $this->theme_json, $path, $content );
|
||||
}
|
||||
|
||||
if ( 'theme' === $origin && ! $preset['override'] ) {
|
||||
$content = self::filter_slugs( $content, $preset['path'], $slugs );
|
||||
} else {
|
||||
$slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() );
|
||||
$content = self::filter_slugs( $content, $slugs_for_preset );
|
||||
_wp_array_set( $this->theme_json, $path, $content );
|
||||
}
|
||||
}
|
||||
@@ -1540,13 +1546,55 @@ class WP_Theme_JSON {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the slugs for all the presets that cannot be overriden
|
||||
* in the given path. It returns an associative array
|
||||
* Returns whether a presets should be overriden or not.
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $theme_json The theme.json like structure to inspect.
|
||||
* @param array $path Path to inspect.
|
||||
* @param bool|array $override Data to compute whether to override the preset.
|
||||
* @return boolean
|
||||
*/
|
||||
private static function should_override_preset( $theme_json, $path, $override ) {
|
||||
if ( is_bool( $override ) ) {
|
||||
return $override;
|
||||
}
|
||||
|
||||
/*
|
||||
* The relationship between whether to override the defaults
|
||||
* and whether the defaults are enabled is inverse:
|
||||
*
|
||||
* - If defaults are enabled => theme presets should not be overriden
|
||||
* - If defaults are disabled => theme presets should be overriden
|
||||
*
|
||||
* For example, a theme sets defaultPalette to false,
|
||||
* making the default palette hidden from the user.
|
||||
* In that case, we want all the theme presets to be present,
|
||||
* so they should override the defaults.
|
||||
*/
|
||||
if ( is_array( $override ) ) {
|
||||
$value = _wp_array_get( $theme_json, array_merge( $path, $override ) );
|
||||
if ( isset( $value ) ) {
|
||||
return ! $value;
|
||||
}
|
||||
|
||||
// Search the top-level key if none was found for this node.
|
||||
$value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $override ) );
|
||||
if ( isset( $value ) ) {
|
||||
return ! $value;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default slugs for all the presets in an associative array
|
||||
* whose keys are the preset paths and the leafs is the list of slugs.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* array(
|
||||
* array(
|
||||
* 'color' => array(
|
||||
* 'palette' => array( 'slug-1', 'slug-2' ),
|
||||
* 'gradients' => array( 'slug-3', 'slug-4' ),
|
||||
@@ -1555,26 +1603,23 @@ class WP_Theme_JSON {
|
||||
*
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $data A theme.json like structure to inspect.
|
||||
* @param array $node_path The path to inspect. Default `array( 'settings' )`.
|
||||
* @return array An associative array containing the slugs for the given path.
|
||||
* @param array $data A theme.json like structure.
|
||||
* @param array $node_path The path to inspect. It's 'settings' by default.
|
||||
* @return array
|
||||
*/
|
||||
private static function get_slugs_not_to_override( $data, $node_path = array( 'settings' ) ) {
|
||||
private static function get_default_slugs( $data, $node_path ) {
|
||||
$slugs = array();
|
||||
foreach ( self::PRESETS_METADATA as $metadata ) {
|
||||
if ( $metadata['override'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slugs_for_preset = array();
|
||||
$path = array_merge( $node_path, $metadata['path'], array( 'default' ) );
|
||||
$preset = _wp_array_get( $data, $path, null );
|
||||
foreach ( self::PRESETS_METADATA as $metadata ) {
|
||||
$path = array_merge( $node_path, $metadata['path'], array( 'default' ) );
|
||||
$preset = _wp_array_get( $data, $path, null );
|
||||
if ( ! isset( $preset ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$slugs_for_preset = array();
|
||||
$slugs_for_preset = array_map(
|
||||
function( $value ) {
|
||||
static function( $value ) {
|
||||
return isset( $value['slug'] ) ? $value['slug'] : null;
|
||||
},
|
||||
$preset
|
||||
@@ -1591,19 +1636,17 @@ class WP_Theme_JSON {
|
||||
* @since 5.9.0
|
||||
*
|
||||
* @param array $node The node with the presets to validate.
|
||||
* @param array $path The path to the preset type to inspect.
|
||||
* @param array $slugs The slugs that should not be overriden.
|
||||
* @return array The new node.
|
||||
*/
|
||||
private static function filter_slugs( $node, $path, $slugs ) {
|
||||
$slugs_for_preset = _wp_array_get( $slugs, $path, array() );
|
||||
if ( empty( $slugs_for_preset ) ) {
|
||||
private static function filter_slugs( $node, $slugs ) {
|
||||
if ( empty( $slugs ) ) {
|
||||
return $node;
|
||||
}
|
||||
|
||||
$new_node = array();
|
||||
foreach ( $node as $value ) {
|
||||
if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs_for_preset, true ) ) {
|
||||
if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) {
|
||||
$new_node[] = $value;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user