diff --git a/lib/compat/wordpress-5.9/class-wp-theme-json-5-9.php b/lib/compat/wordpress-5.9/class-wp-theme-json-5-9.php new file mode 100644 index 00000000000000..e69de29bb2d1d6 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 189e3694dd87f6..4040ecb9c32c15 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 @@ -162,17 +162,12 @@ protected static function sanitize( $input, $valid_block_names, $valid_element_n * @return array Sanitized structure. */ public static function remove_insecure_properties( $theme_json ) { - $sanitized = array(); - - $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); - + $sanitized = array(); + $theme_json = WP_Theme_JSON_Schema::migrate( $theme_json ); $valid_block_names = array_keys( static::get_blocks_metadata() ); $valid_element_names = array_keys( static::ELEMENTS ); - - $theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names ); - - $blocks_metadata = static::get_blocks_metadata(); - $style_nodes = static::get_style_nodes( $theme_json, $blocks_metadata ); + $theme_json = static::sanitize( $theme_json, $valid_block_names, $valid_element_names ); + $style_nodes = static::get_style_nodes( $theme_json ); foreach ( $style_nodes as $metadata ) { $input = _wp_array_get( $theme_json, $metadata['path'], array() ); @@ -327,10 +322,9 @@ 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, $selectors = array() ) { + protected static function get_style_nodes( $theme_json ) { $nodes = array(); if ( ! isset( $theme_json['styles'] ) ) { return $nodes; @@ -374,7 +368,7 @@ protected static function get_style_nodes( $theme_json, $selectors = array() ) { return $nodes; } - $nodes = array_merge( $nodes, static::get_block_nodes( $theme_json, $selectors ) ); + $nodes = array_merge( $nodes, static::get_block_nodes( $theme_json ) ); // 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 ); @@ -393,13 +387,13 @@ 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 = array() ) { - $selectors = empty( $selectors ) ? static::get_blocks_metadata() : $selectors; + private static function get_block_nodes( $theme_json ) { + $selectors = static::get_blocks_metadata(); $nodes = array(); + if ( ! isset( $theme_json['styles'] ) ) { return $nodes; }