Title: WP_Theme_JSON::get_valid_block_style_variations
Published: February 24, 2026

---

# WP_Theme_JSON::get_valid_block_style_variations( array $blocks_metadata = array() ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#source)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#wp--skip-link--target)

Collects valid block style variations keyed by block type.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#parameters)󠁿

 `$blocks_metadata`arrayoptional

List of metadata per block. Default is the metadata for all blocks.

Default:`array()`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#return)󠁿

 array Valid block style variations by block type.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#source)󠁿

    ```php
    protected static function get_valid_block_style_variations( $blocks_metadata = array() ) {
    	$valid_variations = array();
    	$blocks_metadata  = empty( $blocks_metadata ) ? static::get_blocks_metadata() : $blocks_metadata;
    	foreach ( $blocks_metadata as $block_name => $block_meta ) {
    		if ( ! isset( $block_meta['styleVariations'] ) ) {
    			continue;
    		}
    		$valid_variations[ $block_name ] = array_keys( $block_meta['styleVariations'] );
    	}

    	return $valid_variations;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-theme-json.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-theme-json.php#L4619)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-theme-json.php#L4619-L4630)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_theme_json/get_valid_block_style_variations/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.8.0](https://developer.wordpress.org/reference/since/6.8.0/) | Added the `$blocks_metadata` parameter. | 
| [6.6.0](https://developer.wordpress.org/reference/since/6.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_theme_json%2Fget_valid_block_style_variations%2F)
before being able to contribute a note or feedback.