| @@ -166,8 +166,13 @@ | ||
| 166 | 166 | 'blocks' => $blocks_data, |
| 167 | 167 | ), |
| 168 | 168 | ); |
| 169 | 169 | |
| 170 | + // Ensure variation state styles know about any custom viewport breakpoints. | |
| 171 | + if ( isset( $theme_json['settings']['viewport'] ) ) { | |
| 172 | + $config['settings']['viewport'] = $theme_json['settings']['viewport']; | |
| 173 | + } | |
| 174 | + | |
| 170 | 175 | // Turn off filter that excludes block nodes. They are needed here for the variation's inner block types. |
| 171 | 176 | if ( ! is_admin() ) { |
| 172 | 177 | remove_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' ); |
| 173 | 178 | } |
| @@ -219,12 +224,12 @@ | ||
| 219 | 224 | * @since 6.6.0 |
| 220 | 225 | * |
| 221 | 226 | * @see gutenberg_render_block_style_variation_support_styles |
| 222 | 227 | * |
| 223 | - * @param string $block_content Rendered block content. | |
| 224 | - * @param array $block Block object. | |
| 228 | + * @param string $block_content Rendered block content. | |
| 229 | + * @param array $block Block object. | |
| 225 | 230 | * |
| 226 | - * @return string Filtered block content. | |
| 231 | + * @return string Filtered block content. | |
| 227 | 232 | */ |
| 228 | 233 | function gutenberg_render_block_style_variation_class_name( $block_content, $block ) { |
| 229 | 234 | if ( ! $block_content || empty( $block['attrs']['className'] ) ) { |
| 230 | 235 | return $block_content; |
| @@ -229,13 +234,18 @@ | ||
| 229 | 234 | if ( ! $block_content || empty( $block['attrs']['className'] ) ) { |
| 230 | 235 | return $block_content; |
| 231 | 236 | } |
| 232 | 237 | |
| 238 | + $block_class_name = $block['attrs']['className']; | |
| 239 | + if ( ! is_string( $block_class_name ) ) { | |
| 240 | + return $block_content; | |
| 241 | + } | |
| 242 | + | |
| 233 | 243 | /* |
| 234 | 244 | * Matches a class prefixed by `is-style`, followed by the |
| 235 | 245 | * variation slug, then `--`, and finally an instance number. |
| 236 | 246 | */ |
| 237 | - preg_match( '/\bis-style-(\S+?--\d+)\b/', $block['attrs']['className'], $matches ); | |
| 247 | + preg_match( '/\bis-style-(\S+?--\d+)\b/', $block_class_name, $matches ); | |
| 238 | 248 | |
| 239 | 249 | if ( empty( $matches ) ) { |
| 240 | 250 | return $block_content; |
| 241 | 251 | } |