Make WordPress Core


Ignore:
Timestamp:
09/14/2022 03:50:01 PM (3 years ago)
Author:
hellofromTonya
Message:

Editor: Revert [54159].

Reverting changeset due to failing PHPUnit tests. Tests pass without changeset [54156], but fail with it. Reverting to explore why in the original PR after rebasing.

See #56467.

File:
1 edited

Legend:

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

    r54159 r54160  
    231231
    232232        return $with_theme_supports;
    233     }
    234 
    235     /**
    236      * Gets the styles for blocks from the block.json file.
    237      *
    238      * @since 6.1.0
    239      *
    240      * @return WP_Theme_JSON
    241      */
    242     public static function get_block_data() {
    243         $registry = WP_Block_Type_Registry::get_instance();
    244         $blocks   = $registry->get_all_registered();
    245         $config   = array( 'version' => 1 );
    246         foreach ( $blocks as $block_name => $block_type ) {
    247             if ( isset( $block_type->supports['__experimentalStyle'] ) ) {
    248                 $config['styles']['blocks'][ $block_name ] = static::remove_json_comments( $block_type->supports['__experimentalStyle'] );
    249             }
    250 
    251             if (
    252                 isset( $block_type->supports['spacing']['blockGap']['__experimentalDefault'] ) &&
    253                 null === _wp_array_get( $config, array( 'styles', 'blocks', $block_name, 'spacing', 'blockGap' ), null )
    254             ) {
    255                 // Ensure an empty placeholder value exists for the block, if it provides a default blockGap value.
    256                 // The real blockGap value to be used will be determined when the styles are rendered for output.
    257                 $config['styles']['blocks'][ $block_name ]['spacing']['blockGap'] = null;
    258             }
    259         }
    260 
    261         // Core here means it's the lower level part of the styles chain.
    262         // It can be a core or a third-party block.
    263         return new WP_Theme_JSON( $config, 'core' );
    264     }
    265 
    266     /**
    267      * When given an array, this will remove any keys with the name `//`.
    268      *
    269      * @param array $array The array to filter.
    270      * @return array The filtered array.
    271      */
    272     private static function remove_json_comments( $array ) {
    273         unset( $array['//'] );
    274         foreach ( $array as $k => $v ) {
    275             if ( is_array( $v ) ) {
    276                 $array[ $k ] = static::remove_json_comments( $v );
    277             }
    278         }
    279 
    280         return $array;
    281233    }
    282234
     
    419371     * @since 5.9.0 Added user data, removed the `$settings` parameter,
    420372     *              added the `$origin` parameter.
    421      * @since 6.1.0 Added block data.
    422373     *
    423374     * @param string $origin Optional. To what level should we merge data.
     
    432383        $result = new WP_Theme_JSON();
    433384        $result->merge( static::get_core_data() );
    434         $result->merge( static::get_block_data() );
    435385        $result->merge( static::get_theme_data() );
    436386
Note: See TracChangeset for help on using the changeset viewer.