register_block_style() WordPress Function
The register_block_style() function is used to register a new block style for the block editor. This function takes two arguments: the name of the block style, and an optional array of style properties. Block styles are registered using the block_styles filter. This filter is passed an array of block styles, which can be modified by adding or removing styles. Once a block style is registered, it can be applied to any block in the editor. To do this, select the block you want to style, and then click the "Styles" dropdown in the block toolbar. Your custom block style will be listed under the "Custom" heading.
register_block_style( string $block_name, array $style_properties ) #
Registers a new block style.
Parameters
- $block_name
(string)(Required)Block type name including namespace.
- $style_properties
(array)(Required)Array containing the properties of the style name, label, style (name of the stylesheet to be enqueued), inline_style (string containing the CSS to be added).
Return
(bool) True if the block style was registered with success and false otherwise.
Source
File: wp-includes/blocks.php
function register_block_style( $block_name, $style_properties ) {
return WP_Block_Styles_Registry::get_instance()->register( $block_name, $style_properties );
}
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |