W3cubDocs

/WordPress

get_comment_delimited_block_content( string $block_name = null, array $block_attributes, string $block_content )

Returns the content of a block, including comment delimiters.

Parameters

$block_name

(string) (Optional) Block name.

Default value: null

$block_attributes

(array) (Required) Block attributes.

$block_content

(string) (Required) Block save content.

Return

(string) Comment-delimited block content.

Source

File: wp-includes/blocks.php

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
	);
}

Changelog

Version Description
5.3.1 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/get_comment_delimited_block_content