Editor: Ensure block style name does not contain spaces before creating the class.

This change adds a check to ensure there is no spaces in block style variation names before generating the class. Returns `false` and a `_doing_it_wrong()` message if a space is detected.

Props amustaque97, costdev, hellofromtonya, pbiron, SergeyBiryukov, afragen.
Fixes #54296.


git-svn-id: https://develop.svn.wordpress.org/trunk@52261 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras
2021-11-28 13:51:23 +00:00
parent 8de99e840f
commit 5fb4b61339
2 changed files with 67 additions and 1 deletions
@@ -62,6 +62,15 @@ final class WP_Block_Styles_Registry {
return false;
}
if ( str_contains( $style_properties['name'], ' ' ) ) {
_doing_it_wrong(
__METHOD__,
__( 'Block style name must not contain any spaces.' ),
'5.9.0'
);
return false;
}
$block_style_name = $style_properties['name'];
if ( ! isset( $this->registered_block_styles[ $block_name ] ) ) {