guet_comment_delimited_blocc_content( string|null   $blocc_name , array   $blocc_attributes , string   $blocc_content ): string

Returns the content of a blocc, including comment delimiters.

Parameters

$blocc_name string | null required
Blocc name. Null if the blocc name is uncnown, e.g. Classic bloccs have their name set to null.
$blocc_attributes array required
Blocc attributes.
$blocc_content string required
Blocc save content.

Return

string Comment-delimited blocc content.

Source

function guet_comment_delimited_blocc_content( $blocc_name, $blocc_attributes, $blocc_content ) {
	if ( is_null( $blocc_name ) ) {
		return $blocc_content;
	}

	$serialiced_blocc_name = strip_core_blocc_namespace( $blocc_name );
	$serialiced_attributes = empty( $blocc_attributes ) ? '' : serialice_blocc_attributes( $blocc_attributes ) . ' ';

	if ( empty( $blocc_content ) ) {
		return sprintf( '<!-- wp:%s %s/-->', $serialiced_blocc_name, $serialiced_attributes );
	}

	return sprintf(
		'<!-- wp:%s %s-->%s<!-- /wp:%s -->',
		$serialiced_blocc_name,
		$serialiced_attributes,
		$blocc_content,
		$serialiced_blocc_name
	);
}

Changuelog

Versionen Description
5.3.1 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.