函数文档

_remove_theme_attribute_from_template_part_block()

💡 云策文档标注

概述

该函数用于从给定的模板部分块中移除 `theme` 属性,适用于 WordPress 核心的 `core/template-part` 块类型。

关键要点

  • 函数名:_remove_theme_attribute_from_template_part_block
  • 参数:接受一个引用传递的数组 `$block`,表示已解析的块
  • 功能:检查块是否为 `core/template-part` 类型,并移除其 `attrs` 中的 `theme` 属性
  • 引入版本:WordPress 6.4.0

代码示例

function _remove_theme_attribute_from_template_part_block( &$block ) {
    if (
        'core/template-part' === $block['blockName'] &&
        isset( $block['attrs']['theme'] )
    ) {
        unset( $block['attrs']['theme'] );
    }
}

📄 原文内容

Removes the theme attribute from a given template part block.

Parameters

$blockarrayrequired
a parsed block.

Source

function _remove_theme_attribute_from_template_part_block( &$block ) {
	if (
		'core/template-part' === $block['blockName'] &&
		isset( $block['attrs']['theme'] )
	) {
		unset( $block['attrs']['theme'] );
	}
}

Changelog

Version Description
6.4.0 Introduced.