extract_serialized_parent_block()WP 6.7.0

Accepts the serialized markup of a block and its inner blocks, and returns serialized markup of the wrapper block.

Internal function — this function is designed to be used by the kernel itself. It is not recommended to use this function in your code.

No Hooks.

Return

String. The serialized markup of the wrapper block.

Usage

extract_serialized_parent_block( $serialized_block );
$serialized_block(string) (required)
The serialized markup of a block and its inner blocks.

Notes

Changelog

Since 6.7.0 Introduced.

extract_serialized_parent_block() code WP 6.7.1

function extract_serialized_parent_block( $serialized_block ) {
	$start = strpos( $serialized_block, '-->' ) + strlen( '-->' );
	$end   = strrpos( $serialized_block, '<!--' );
	return substr( $serialized_block, 0, $start ) . substr( $serialized_block, $end );
}