
面向WordPress用户的MAMP Pro终极指南
_filter_block_template_part_area ( $type )
filter_block_template_part_area: 这个钩子用于过滤块模板部分的区域。这允许开发者修改块模板部分的区域并添加自定义逻辑。
检查输入的’area’是否是一个支持的值。
如果支持则返回输入值,否则返回’uncategorized’值。
function _filter_block_template_part_area( $type ) { $allowed_areas = array_map( static function ( $item ) { return $item['area']; }, get_allowed_block_template_part_areas() ); if ( in_array( $type, $allowed_areas, true ) ) { return $type; } $warning_message = sprintf( /* translators: %1$s: Template area type, %2$s: the uncategorized template area value. */ __( '"%1$s" is not a supported wp_template_part area value and has been added as "%2$s".' ), $type, WP_TEMPLATE_PART_AREA_UNCATEGORIZED ); trigger_error( $warning_message, E_USER_NOTICE ); return WP_TEMPLATE_PART_AREA_UNCATEGORIZED; }