Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/wp-includes/block-supports/states.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,14 +542,23 @@ function wp_render_block_states_support( $block_content, $block ) {
return $block_content;
}

/*
* Every CSS rule this function can produce is keyed off the block's `style`
* attribute. Without it there is nothing to generate, so bail before doing
* any of the lookups below — this runs for every block on every request.
*/
$style = $block['attrs']['style'] ?? array();
if ( empty( $style ) || ! is_array( $style ) ) {
return $block_content;
}

$block_name = $block['blockName'];
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );
if ( ! $block_type ) {
return $block_content;
}

$supported_pseudo_states = WP_Theme_JSON::VALID_BLOCK_PSEUDO_SELECTORS[ $block_name ] ?? array();
$style = $block['attrs']['style'] ?? array();
$css_rules = array();
$viewport_settings = wp_get_global_settings( array( 'viewport' ) );
$responsive_media_queries = WP_Theme_JSON::get_viewport_media_queries( $viewport_settings );
Expand Down
Loading