A WordPress-centric search engine for devs and theme authors



get_comment_delimited_block_content ›

Since5.3.1
Deprecatedn/a
get_comment_delimited_block_content ( $block_name = null, $block_attributes, $block_content )
Parameters: (3)
  • (string) block_name Block name.
    Required: No
    Default: null
  • (array) attributes Block attributes.
    Required: Yes
  • (string) content Block save content.
    Required: Yes
Returns:
  • (string) Comment-delimited block content.
Defined at:
Codex:

Returns the content of a block, including comment delimiters.



Source

function get_comment_delimited_block_content( $block_name = null, $block_attributes, $block_content ) {
	if ( is_null( $block_name ) ) {
		return $block_content;
	}

	$serialized_block_name = strip_core_block_namespace( $block_name );
	$serialized_attributes = empty( $block_attributes ) ? '' : serialize_block_attributes( $block_attributes ) . ' ';

	if ( empty( $block_content ) ) {
		return sprintf( '<!-- wp:%s %s/-->', $serialized_block_name, $serialized_attributes );
	}

	return sprintf(
		'<!-- wp:%s %s-->%s<!-- /wp:%s -->',
		$serialized_block_name,
		$serialized_attributes,
		$block_content,
		$serialized_block_name
	);
}