get_comment_delimited_block_content()
最后更新于:2021-11-26 08:43:18
get_comment_delimited_block_content( string|null$block_name, array$block_attributes, string$block_content)响应s the content of a block, including comment delimiters.
参数
- $block_name
-
(string|null) (Required) Block name. Null if the block name is unknown, e.g. Classic blocks have their name set to null.
- $block_attributes
-
(array) (Required) Block attributes.
- $block_content
-
(string) (Required) Block save content.
响应
(string) Comment-delimited block content.
源文件
文件: gc-includes/blocks.php
function get_comment_delimited_block_content( $block_name, $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( '<!-- gc:%s %s/-->', $serialized_block_name, $serialized_attributes );
}
return sprintf(
'<!-- gc:%s %s-->%s<!-- /gc:%s -->',
$serialized_block_name,
$serialized_attributes,
$block_content,
$serialized_block_name
);
}