Changeset 58246
- Timestamp:
- 05/30/2024 07:33:23 AM (14 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks.php
r58186 r58246 1903 1903 * 1904 1904 * @since 5.3.0 1905 * @since 6.6.0 Updated types as registry now allows registering styles for multiple block types at once. 1905 1906 * 1906 1907 * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/ 1907 1908 * 1908 * @param string $block_name Block type name including namespace. 1909 * @param array $style_properties Array containing the properties of the style name, label, 1910 * style_handle (name of the stylesheet to be enqueued), 1911 * inline_style (string containing the CSS to be added). 1912 * See WP_Block_Styles_Registry::register(). 1909 * @param string|array $block_name Block type name including namespace or array of namespaced block type names. 1910 * @param array $style_properties Array containing the properties of the style name, label, 1911 * style_handle (name of the stylesheet to be enqueued), 1912 * inline_style (string containing the CSS to be added), 1913 * style_data (theme.json-like array to generate CSS from). 1914 * See WP_Block_Styles_Registry::register(). 1913 1915 * @return bool True if the block style was registered with success and false otherwise. 1914 1916 */ -
trunk/src/wp-includes/class-wp-block-styles-registry.php
r54133 r58246 43 43 * 44 44 * @since 5.3.0 45 * @since 6.6.0 Added ability to register style across multiple block types along with theme.json-like style data. 45 46 * 46 47 * @link https://developer.wordpress.org/block-editor/reference-guides/block-api/block-styles/ 47 48 * 48 * @param string $block_name Block type name including namespace.49 * @param array $style_properties {49 * @param string|array $block_name Block type name including namespace or array of namespaced block type names. 50 * @param array $style_properties { 50 51 * Array containing the properties of the style. 51 52 * … … 57 58 * enqueued in places where block styles are needed. 58 59 * @type bool $is_default Whether this is the default style for the block type. 60 * @type array $style_data Theme.json-like object to generate CSS from. 59 61 * } 60 62 * @return bool True if the block style was registered with success and false otherwise. … … 62 64 public function register( $block_name, $style_properties ) { 63 65 64 if ( ! is set( $block_name ) || ! is_string( $block_name ) ) {65 _doing_it_wrong( 66 __METHOD__, 67 __( 'Block name must be a string .' ),68 ' 5.3.0'66 if ( ! is_string( $block_name ) && ! is_array( $block_name ) ) { 67 _doing_it_wrong( 68 __METHOD__, 69 __( 'Block name must be a string or array.' ), 70 '6.6.0' 69 71 ); 70 72 return false; … … 90 92 91 93 $block_style_name = $style_properties['name']; 92 93 if ( ! isset( $this->registered_block_styles[ $block_name ] ) ) { 94 $this->registered_block_styles[ $block_name ] = array(); 95 } 96 $this->registered_block_styles[ $block_name ][ $block_style_name ] = $style_properties; 94 $block_names = is_string( $block_name ) ? array( $block_name ) : $block_name; 95 96 foreach ( $block_names as $name ) { 97 if ( ! isset( $this->registered_block_styles[ $name ] ) ) { 98 $this->registered_block_styles[ $name ] = array(); 99 } 100 $this->registered_block_styles[ $name ][ $block_style_name ] = $style_properties; 101 } 97 102 98 103 return true;
Note: See TracChangeset
for help on using the changeset viewer.