wp_filter_out_block_nodes

函式
wp_filter_out_block_nodes ( $nodes )
引數
  • (array) $nodes The nodes to filter.
    Required:
返回值
  • (array) A filtered array of style nodes.
定義位置
相關方法
wp_filter_post_ksesfilter_block_kseswp_filter_ksesfilter_block_contentwp_filter_object_list
引入
6.1.0
棄用
-

wp_filter_out_block_nodes:這個過濾器用於從文章的內容中刪除特定的塊。它將文章內容作為引數,並返回已刪除指定塊的修改後的內容。

對來自WP_Theme_JSON::get_style_nodes()的風格節點列表應用一個過濾器。

這個特殊的過濾器會刪除陣列中的所有塊。

我們希望WP_Theme_JSON對如何使用CSS的實施細節一無所知。這個過濾器允許我們根據我們是否正在載入獨立的資產來修改WP_Theme_JSON的輸出,而不需要讓類知道這個細節。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_filter_out_block_nodes( $nodes ) {
return array_filter(
$nodes,
function( $node ) {
return ! in_array( 'blocks', $node['path'], true );
},
ARRAY_FILTER_USE_BOTH
);
}
function wp_filter_out_block_nodes( $nodes ) { return array_filter( $nodes, function( $node ) { return ! in_array( 'blocks', $node['path'], true ); }, ARRAY_FILTER_USE_BOTH ); }
function wp_filter_out_block_nodes( $nodes ) {
	return array_filter(
		$nodes,
		function( $node ) {
			return ! in_array( 'blocks', $node['path'], true );
		},
		ARRAY_FILTER_USE_BOTH
	);
}

常見問題

FAQs
檢視更多 >