Make WordPress Core


Ignore:
Timestamp:
12/14/2021 01:55:28 AM (3 years ago)
Author:
noisysocks
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json.php

    r52329 r52364  
    108108        array(
    109109            'path'       => array( 'color', 'palette' ),
    110             'override'   => false,
     110            'override'   => array( 'color', 'defaultPalette' ),
    111111            'value_key'  => 'color',
    112112            'css_vars'   => '--wp--preset--color--$slug',
     
    120120        array(
    121121            'path'       => array( 'color', 'gradients' ),
    122             'override'   => false,
     122            'override'   => array( 'color', 'defaultGradients' ),
    123123            'value_key'  => 'gradient',
    124124            'css_vars'   => '--wp--preset--gradient--$slug',
     
    398398        $new_theme_json = $theme_json;
    399399
    400         if ( isset( $new_theme_json['settings']['appearanceTools'] ) ) {
     400        if (
     401            isset( $new_theme_json['settings']['appearanceTools'] ) &&
     402            true === $new_theme_json['settings']['appearanceTools']
     403        ) {
    401404            self::do_opt_in_into_settings( $new_theme_json['settings'] );
    402405        }
     
    404407        if ( isset( $new_theme_json['settings']['blocks'] ) && is_array( $new_theme_json['settings']['blocks'] ) ) {
    405408            foreach ( $new_theme_json['settings']['blocks'] as &$block ) {
    406                 if ( isset( $block['appearanceTools'] ) ) {
     409                if ( isset( $block['appearanceTools'] ) && ( true === $block['appearanceTools'] ) ) {
    407410                    self::do_opt_in_into_settings( $block );
    408411                }
     
    434437
    435438        foreach ( $to_opt_in as $path ) {
    436             if ( null === _wp_array_get( $context, $path, null ) ) {
     439            // Use "unset prop" as a marker instead of "null" because
     440            // "null" can be a valid value for some props (e.g. blockGap).
     441            if ( 'unset prop' === _wp_array_get( $context, $path, 'unset prop' ) ) {
    437442                _wp_array_set( $context, $path, true );
    438443            }
     
    15031508         */
    15041509        $nodes        = self::get_setting_nodes( $incoming_data );
    1505         $slugs_global = self::get_slugs_not_to_override( $this->theme_json );
     1510        $slugs_global = self::get_default_slugs( $this->theme_json, array( 'settings' ) );
    15061511        foreach ( $nodes as $node ) {
    1507             $slugs_node = self::get_slugs_not_to_override( $this->theme_json, $node['path'] );
     1512            $slugs_node = self::get_default_slugs( $this->theme_json, $node['path'] );
    15081513            $slugs      = array_merge_recursive( $slugs_global, $slugs_node );
    15091514
     
    15171522            // Replace the presets.
    15181523            foreach ( self::PRESETS_METADATA as $preset ) {
     1524                $override_preset = self::should_override_preset( $this->theme_json, $node['path'], $preset['override'] );
     1525
    15191526                foreach ( self::VALID_ORIGINS as $origin ) {
    15201527                    $path    = array_merge( $node['path'], $preset['path'], array( $origin ) );
     
    15261533                    if (
    15271534                        ( 'theme' !== $origin ) ||
    1528                         ( 'theme' === $origin && $preset['override'] )
     1535                        ( 'theme' === $origin && $override_preset )
    15291536                    ) {
    15301537                        _wp_array_set( $this->theme_json, $path, $content );
    1531                     }
    1532 
    1533                     if ( 'theme' === $origin && ! $preset['override'] ) {
    1534                         $content = self::filter_slugs( $content, $preset['path'], $slugs );
     1538                    } else {
     1539                        $slugs_for_preset = _wp_array_get( $slugs, $preset['path'], array() );
     1540                        $content          = self::filter_slugs( $content, $slugs_for_preset );
    15351541                        _wp_array_set( $this->theme_json, $path, $content );
    15361542                    }
     
    15411547
    15421548    /**
    1543      * Returns the slugs for all the presets that cannot be overriden
    1544      * in the given path. It returns an associative array
     1549     * Returns whether a presets should be overriden or not.
     1550     *
     1551     * @since 5.9.0
     1552     *
     1553     * @param array      $theme_json The theme.json like structure to inspect.
     1554     * @param array      $path Path to inspect.
     1555     * @param bool|array $override Data to compute whether to override the preset.
     1556     * @return boolean
     1557     */
     1558    private static function should_override_preset( $theme_json, $path, $override ) {
     1559        if ( is_bool( $override ) ) {
     1560            return $override;
     1561        }
     1562
     1563        /*
     1564         * The relationship between whether to override the defaults
     1565         * and whether the defaults are enabled is inverse:
     1566         *
     1567         * - If defaults are enabled  => theme presets should not be overriden
     1568         * - If defaults are disabled => theme presets should be overriden
     1569         *
     1570         * For example, a theme sets defaultPalette to false,
     1571         * making the default palette hidden from the user.
     1572         * In that case, we want all the theme presets to be present,
     1573         * so they should override the defaults.
     1574         */
     1575        if ( is_array( $override ) ) {
     1576            $value = _wp_array_get( $theme_json, array_merge( $path, $override ) );
     1577            if ( isset( $value ) ) {
     1578                return ! $value;
     1579            }
     1580
     1581            // Search the top-level key if none was found for this node.
     1582            $value = _wp_array_get( $theme_json, array_merge( array( 'settings' ), $override ) );
     1583            if ( isset( $value ) ) {
     1584                return ! $value;
     1585            }
     1586
     1587            return true;
     1588        }
     1589    }
     1590
     1591    /**
     1592     * Returns the default slugs for all the presets in an associative array
    15451593     * whose keys are the preset paths and the leafs is the list of slugs.
    15461594     *
    15471595     * For example:
    15481596     *
    1549      * array(
     1597     *  array(
    15501598     *   'color' => array(
    15511599     *     'palette'   => array( 'slug-1', 'slug-2' ),
     
    15561604     * @since 5.9.0
    15571605     *
    1558      * @param array $data      A theme.json like structure to inspect.
    1559      * @param array $node_path The path to inspect. Default `array( 'settings' )`.
    1560      * @return array An associative array containing the slugs for the given path.
    1561      */
    1562     private static function get_slugs_not_to_override( $data, $node_path = array( 'settings' ) ) {
     1606     * @param array $data      A theme.json like structure.
     1607     * @param array $node_path The path to inspect. It's 'settings' by default.
     1608     * @return array
     1609     */
     1610    private static function get_default_slugs( $data, $node_path ) {
    15631611        $slugs = array();
     1612
    15641613        foreach ( self::PRESETS_METADATA as $metadata ) {
    1565             if ( $metadata['override'] ) {
    1566                 continue;
    1567             }
    1568 
    1569             $slugs_for_preset = array();
    1570             $path             = array_merge( $node_path, $metadata['path'], array( 'default' ) );
    1571             $preset           = _wp_array_get( $data, $path, null );
     1614            $path   = array_merge( $node_path, $metadata['path'], array( 'default' ) );
     1615            $preset = _wp_array_get( $data, $path, null );
    15721616            if ( ! isset( $preset ) ) {
    15731617                continue;
    15741618            }
    15751619
     1620            $slugs_for_preset = array();
    15761621            $slugs_for_preset = array_map(
    1577                 function( $value ) {
     1622                static function( $value ) {
    15781623                    return isset( $value['slug'] ) ? $value['slug'] : null;
    15791624                },
     
    15921637     *
    15931638     * @param array $node  The node with the presets to validate.
    1594      * @param array $path  The path to the preset type to inspect.
    15951639     * @param array $slugs The slugs that should not be overriden.
    15961640     * @return array The new node.
    15971641     */
    1598     private static function filter_slugs( $node, $path, $slugs ) {
    1599         $slugs_for_preset = _wp_array_get( $slugs, $path, array() );
    1600         if ( empty( $slugs_for_preset ) ) {
     1642    private static function filter_slugs( $node, $slugs ) {
     1643        if ( empty( $slugs ) ) {
    16011644            return $node;
    16021645        }
     
    16041647        $new_node = array();
    16051648        foreach ( $node as $value ) {
    1606             if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs_for_preset, true ) ) {
     1649            if ( isset( $value['slug'] ) && ! in_array( $value['slug'], $slugs, true ) ) {
    16071650                $new_node[] = $value;
    16081651            }
Note: See TracChangeset for help on using the changeset viewer.