WordPress at Your Fingertips
function is not described

WP_Block_Styles_Registry::register() public WP 5.3.0

Registers a block style.

{} It's a method of the class: WP_Block_Styles_Registry{}

No Hooks.

Return

true|false. True if the block style was registered with success and false otherwise.

Usage

$WP_Block_Styles_Registry = new WP_Block_Styles_Registry();
$WP_Block_Styles_Registry->register( $block_name, $style_properties );
$block_name(string) (required)
Block type name including namespace.
$style_properties(array) (required)
Array containing the properties of the style name, label, is_default, style_handle (name of the stylesheet to be enqueued), inline_style (string containing the CSS to be added).

Changelog

Since 5.3.0 Introduced.

Code of WP_Block_Styles_Registry::register() WP 5.8.2

public function register( $block_name, $style_properties ) {

	if ( ! isset( $block_name ) || ! is_string( $block_name ) ) {
		_doing_it_wrong(
			__METHOD__,
			__( 'Block name must be a string.' ),
			'5.3.0'
		);
		return false;
	}

	if ( ! isset( $style_properties['name'] ) || ! is_string( $style_properties['name'] ) ) {
		_doing_it_wrong(
			__METHOD__,
			__( 'Block style name must be a string.' ),
			'5.3.0'
		);
		return false;
	}

	$block_style_name = $style_properties['name'];

	if ( ! isset( $this->registered_block_styles[ $block_name ] ) ) {
		$this->registered_block_styles[ $block_name ] = array();
	}
	$this->registered_block_styles[ $block_name ][ $block_style_name ] = $style_properties;

	return true;
}