diff --git a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php index 6d5030c9544a6b..6ce14dd5ba2efe 100644 --- a/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php +++ b/lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php @@ -118,10 +118,11 @@ protected static function get_blocks_metadata() { * * @since 5.8.0 * - * @param array $theme_json The tree to extract style nodes from. + * @param array $theme_json The tree to extract style nodes from. + * @param array $selectors List of selectors per block. * @return array */ - protected static function get_style_nodes( $theme_json ) { + protected static function get_style_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; @@ -147,7 +148,7 @@ protected static function get_style_nodes( $theme_json ) { return $nodes; } - $nodes = array_merge( $nodes, static::get_block_nodes( $theme_json ) ); + $nodes = array_merge( $nodes, static::get_block_nodes( $theme_json, $selectors ) ); // This filter allows us to modify the output of WP_Theme_JSON so that we can do things like loading block CSS independently. return apply_filters( 'gutenberg_get_style_nodes', $nodes ); @@ -166,11 +167,12 @@ public function get_styles_block_nodes() { * An internal method to get the block nodes from a theme.json file. * * @param array $theme_json The theme.json converted to an array. + * @param array $selectors Optional list of selectors per block. * * @return array The block nodes in theme.json. */ - private static function get_block_nodes( $theme_json ) { - $selectors = static::get_blocks_metadata(); + private static function get_block_nodes( $theme_json, $selectors = array() ) { + $selectors = empty( $selectors ) ? static::get_blocks_metadata() : $selectors; $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; @@ -215,9 +217,9 @@ private static function get_block_nodes( $theme_json ) { /** * Gets the CSS rules for a particular block from theme.json. * - * @param array $block_metadata Meta data about the block to get styles for. + * @param array $block_metadata Metadata about the block to get styles for. * - * @return array Styles for the block. + * @return string Styles for the block. */ public function get_styles_for_block( $block_metadata ) { $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() );