Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
00bfe03
Allow the style property of block.json to be an array
adamziel Jun 22, 2022
92f6635
Refactor the other use of _register_single_block_style_handle
adamziel Jun 22, 2022
277603c
Filter out arrays of styles before enqueuing them in class-wp-block.php
adamziel Jun 22, 2022
6eb4626
Do not flatten the styles array in block_type_metadata filter
adamziel Jun 23, 2022
2acd65b
Clarify the docstring
adamziel Jun 23, 2022
127aac5
Clarify the intention of not processing arrays
adamziel Jun 23, 2022
b58f2e7
Clarify the intention
adamziel Jun 23, 2022
14116bb
Further clarify the intention
adamziel Jun 23, 2022
61e2828
Handle style arrays in block-editor.php
adamziel Jun 23, 2022
4b668b0
Handle style arrays in script-loader.php
adamziel Jun 23, 2022
eeb8ede
Adjust code style to avoid requesting block name in the test_handle_p…
adamziel Jun 23, 2022
37113d9
Do not assume 'file' is an exisitng key
adamziel Jun 23, 2022
d70e683
Add comments, rename _register_single_block_style_handle to register_…
adamziel Jun 24, 2022
e034805
Register all string style handles, not just the first one
adamziel Jun 27, 2022
7e086ef
Add array sypport to WP_Block_Type and WP_Rest_Block_Types_Controller
adamziel Jun 29, 2022
438a35b
Add support for editor_styles
adamziel Jun 29, 2022
e4fc856
Delete _wp_multiple_block_styles now that multiple styles are handled
adamziel Jun 29, 2022
3bdb544
Normalize styles format to a list
adamziel Jun 29, 2022
da476d2
Add docstring to _wp_normalize_block_styles_from_mixed_format_to_array
adamziel Jun 29, 2022
ce39fb7
Move the argument normalization inside of WP_Block_Type class
adamziel Jun 29, 2022
c9f0d13
Support array-based styles in register_block_style_handle and add uni…
adamziel Jun 29, 2022
81f13cb
Add an empty _wp_multiple_block_styles function
adamziel Jun 29, 2022
994938f
Add debug statement to see the provlem in the CI
adamziel Jun 29, 2022
c44ba77
Update docs
adamziel Jun 29, 2022
b8ab9d0
Fix last test failures
adamziel Jun 29, 2022
124b4ad
Add @since to normalize_block_styles_from_mixed_format_to_array
adamziel Jun 29, 2022
2c396ae
Merge branch 'trunk' into allow-style-arrays-in-block-json
adamziel Jul 8, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add docstring to _wp_normalize_block_styles_from_mixed_format_to_array
  • Loading branch information
adamziel committed Jun 29, 2022
commit da476d2f6bbc7b65d6f3b51d887c1cbe553dfc40
39 changes: 21 additions & 18 deletions src/wp-includes/class-wp-block-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,26 +406,29 @@ public function get_attributes() {
}
}

/**
* The style and editor_style properties may be defined in any of the following ways:
*
* String handle:
* { "style": "my-block" }
*
* Style definition:
* { "style": { "color": { "text": "#fff" } } }
*
* An array with a string handle:
* { "style": [ "my-block" ] }
*
* A mixed array of string handle and style definitions:
* { "style": [ "my-block", { "color": { "text": "#fff" } } ] }
*
* That's a lot of work for the developer to handle, so we'll handle it for them.
* This filter always stores the styles in the mixed array format.
*
* @param array $args Array or string of arguments for registering a block type.
* @return array Modified array with styles in a consistent format.
*/
function _wp_normalize_block_styles_from_mixed_format_to_array( $args ) {
foreach ( $args as $property_name => $property_value ) {
/*
* The style and editor_style properties may be defined in any of the following ways:
*
* String handle:
* { "style": "my-block" }
*
* Style definition:
* { "style": { "color": { "text": "#fff" } } }
*
* An array with a string handle:
* { "style": [ "my-block" ] }
*
* A mixed array of string handle and style definitions:
* { "style": [ "my-block", { "color": { "text": "#fff" } } ] }
*
* That's a lot of work for the developer to handle, so we'll handle it for them.
* The code below always stores the styles in the mixed array format.
*/
if (
! is_null( $property_value ) &&
in_array( $property_name, array( 'style', 'editor_style' ), true )
Expand Down