Opened 2 years ago
Last modified 2 years ago
#56519 new defect (bug)
Inner blocks serialization bug in serialize_block function
Reported by: | saqibsarwar | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | 5.3.1 |
Component: | Editor | Keywords: | needs-patch |
Focuses: | Cc: |
Description
Hi,
The serialize_block function https://developer.wordpress.org/reference/functions/serialize_block/ fails when the number of inner blocks increases.
The following custom function solved it for me.
<?php function custom_serialize_block( $block ) { $block_content = ''; foreach ( $block['innerContent'] as $chunk ) { if ( is_string( $chunk ) ) { $block_content .= $chunk; } else { foreach ( $block['innerBlocks'] as $inner_block ) { $block_content .= custom_serialize_block( $inner_block ); } } } if ( ! is_array( $block['attrs'] ) ) { $block['attrs'] = []; } return get_comment_delimited_block_content( $block['blockName'], $block['attrs'], $block_content ); }
Change History (2)
Note: See
TracTickets for help on using
tickets.