[wp-trac] [WordPress Trac] #55648: Correct serialize_block @param documentation according to what the function does
WordPress Trac
noreply at wordpress.org
Mon May 2 11:01:02 UTC 2022
#55648: Correct serialize_block @param documentation according to what the function
does
-------------------------+-----------------------------
Reporter: manooweb | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Editor | Version:
Severity: normal | Keywords: has-patch
Focuses: docs |
-------------------------+-----------------------------
It looks like the documentation of serialize_block() function doesn't
corresponding on what the function really expects.
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/blocks.php#L598
Indeed, documentation says we must provide a WP_Block_Parser_Block object
while serialize_block() function tries to access to an array.
See for example
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/blocks.php#L605
or
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/blocks.php#L606
As serialize_blocks() function uses serialize_block() function the
proposed patched also fixed serialize_blocks() function documentation.
In addition, we often need to parse blocks before serialize them like in
_inject_theme_attribute_in_block_template_content() function
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/block-
template-utils.php#L435
It also seems parse_blocks() using the default WP_Block_Parser returns
representative array of WP_Block_Parser_Block object by casting object to
array.
https://core.trac.wordpress.org/browser/trunk/src/wp-
includes/blocks.php#L912
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
block-parser.php#L312
https://core.trac.wordpress.org/browser/trunk/src/wp-includes/class-wp-
block-parser.php#L495
--
Ticket URL: <https://core.trac.wordpress.org/ticket/55648>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list