render_block_core_pattern

函式
render_block_core_pattern ( $attributes )
引數
  • (array) $attributes Block attributes.
    Required:
返回值
  • (string) Returns the output of the pattern.
定義位置
相關方法
register_block_core_patternrender_block_core_post_termsrender_block_core_avatarrender_block_core_post_daterender_block_core_post_content
引入
-
棄用
-

render_block_core_pattern: 這個函式用來在WordPress中渲染一個塊模式。區塊模式允許使用者在他們的網站上快速新增預先設計好的佈局,這可以在建立頁面時節省時間和精力: 這個函式負責生成區塊模式的HTML標記。

在伺服器上渲染`core/pattern`區塊。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function render_block_core_pattern( $attributes ) {
if ( empty( $attributes['slug'] ) ) {
return '';
}
$slug = $attributes['slug'];
$registry = WP_Block_Patterns_Registry::get_instance();
if ( ! $registry->is_registered( $slug ) ) {
return '';
}
$pattern = $registry->get_registered( $slug );
return do_blocks( $pattern['content'] );
}
function render_block_core_pattern( $attributes ) { if ( empty( $attributes['slug'] ) ) { return ''; } $slug = $attributes['slug']; $registry = WP_Block_Patterns_Registry::get_instance(); if ( ! $registry->is_registered( $slug ) ) { return ''; } $pattern = $registry->get_registered( $slug ); return do_blocks( $pattern['content'] ); }
function render_block_core_pattern( $attributes ) {
	if ( empty( $attributes['slug'] ) ) {
		return '';
	}

	$slug     = $attributes['slug'];
	$registry = WP_Block_Patterns_Registry::get_instance();
	if ( ! $registry->is_registered( $slug ) ) {
		return '';
	}

	$pattern = $registry->get_registered( $slug );
	return do_blocks( $pattern['content'] );
}

常見問題

FAQs
檢視更多 >