From dfcc2f6b18840761d2699213abfe702190362222 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 13 Aug 2022 22:36:27 +0000 Subject: [PATCH] Editor: Document the arguments for registering a block style. See #55646 git-svn-id: https://develop.svn.wordpress.org/trunk@53892 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/blocks.php | 2 ++ .../class-wp-block-styles-registry.php | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/blocks.php b/src/wp-includes/blocks.php index 952f7b085f..e731f5bd5b 100644 --- a/src/wp-includes/blocks.php +++ b/src/wp-includes/blocks.php @@ -991,6 +991,8 @@ function block_version( $content ) { * * @since 5.3.0 * + * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/ + * * @param string $block_name Block type name including namespace. * @param array $style_properties Array containing the properties of the style name, * label, style (name of the stylesheet to be enqueued), diff --git a/src/wp-includes/class-wp-block-styles-registry.php b/src/wp-includes/class-wp-block-styles-registry.php index 272e400f8c..b9a59f6d6e 100644 --- a/src/wp-includes/class-wp-block-styles-registry.php +++ b/src/wp-includes/class-wp-block-styles-registry.php @@ -34,12 +34,28 @@ final class WP_Block_Styles_Registry { /** * Registers a block style for the given block type. * + * If the block styles are present in a standalone stylesheet, register it and pass + * its handle as the `style_handle` argument. If the block styles should be inline, + * use the `inline_style` argument. Usually, one of them would be used to pass CSS + * styles. However, you could also skip them and provide CSS styles in any stylesheet + * or with an inline tag. + * * @since 5.3.0 * + * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/ + * * @param string $block_name Block type name including namespace. - * @param array $style_properties 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). + * @param array $style_properties { + * Array containing the properties of the style. + * + * @type string $name The identifier of the style used to compute a CSS class. + * @type string $label A human-readable label for the style. + * @type string $inline_style Inline CSS code that registers the CSS class required + * for the style. + * @type string $style_handle The handle to an already registered style that should be + * enqueued in places where block styles are needed. + * @type bool $is_default Whether this is the default style for the block type. + * } * @return bool True if the block style was registered with success and false otherwise. */ public function register( $block_name, $style_properties ) {