Skip to content

Commit a331593

Browse files
Refactor custom CSS support validation logic
Add check for empty custom CSS before block support validation.
1 parent 7e5a7d0 commit a331593

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/wp-includes/block-supports/custom-css.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
* @return array The same parsed block with custom CSS class name added if appropriate.
1515
*/
1616
function wp_render_custom_css_support_styles( $parsed_block ) {
17-
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $parsed_block['blockName'] );
17+
// Check if the custom CSS attribute even exists.
18+
$custom_css = $parsed_block['attrs']['style']['css'] ?? '';
1819

19-
if ( ! block_has_support( $block_type, 'customCSS', true ) ) {
20+
if ( empty( trim( $custom_css ) ) ) {
2021
return $parsed_block;
2122
}
2223

23-
$custom_css = trim( $parsed_block['attrs']['style']['css'] ?? '' );
24+
$block_type = WP_Block_Type_Registry::get_instance()->get_registered( $parsed_block['blockName'] );
2425

25-
if ( empty( $custom_css ) ) {
26+
if ( ! block_has_support( $block_type, 'customCSS', true ) ) {
2627
return $parsed_block;
2728
}
2829

0 commit comments

Comments
 (0)