From 3bea36d03a35fcc8b92091caa970663cb768aa78 Mon Sep 17 00:00:00 2001 From: Hiroshi Urabe Date: Sun, 22 May 2022 21:49:14 +0900 Subject: [PATCH 1/4] get_style_nodes should be compatible with parent method. fix phpdoc. --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 6d5030c9544a6..dc1e710897723 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 @@ -119,9 +119,10 @@ protected static function get_blocks_metadata() { * @since 5.8.0 * * @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; @@ -217,7 +218,7 @@ private static function get_block_nodes( $theme_json ) { * * @param array $block_metadata Meta data 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() ); From e66df700639532ae8aa541aa6a7d6bc41ea16011 Mon Sep 17 00:00:00 2001 From: Ramon Date: Mon, 23 May 2022 10:41:34 +1000 Subject: [PATCH 2/4] Formatting. --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 dc1e710897723..25c863a7aee9f 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,7 +118,7 @@ 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 */ @@ -216,7 +216,7 @@ 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 string Styles for the block. */ From 7384f7691bd7c6efb922a0a6e03ec0b7bcc43994 Mon Sep 17 00:00:00 2001 From: Ramon Date: Mon, 23 May 2022 11:23:51 +1000 Subject: [PATCH 3/4] Pass optional $selectors arg to get_block_nodes --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 25c863a7aee9f..1253bac1606d0 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 @@ -148,7 +148,7 @@ protected static function get_style_nodes( $theme_json, $selectors = array() ) 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 ); @@ -167,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; From bebac4c9e494656cb99c03770f3387c86fe34530 Mon Sep 17 00:00:00 2001 From: Ramon Date: Mon, 23 May 2022 12:08:13 +1000 Subject: [PATCH 4/4] Update lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> --- lib/compat/wordpress-6.1/class-wp-theme-json-6-1.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 1253bac1606d0..6ce14dd5ba2ef 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 @@ -122,7 +122,7 @@ protected static function get_blocks_metadata() { * @param array $selectors List of selectors per block. * @return array */ - protected static function get_style_nodes( $theme_json, $selectors = array() ) { + protected static function get_style_nodes( $theme_json, $selectors = array() ) { $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes;