函数文档

wp_skip_border_serialization()

💡 云策文档标注

概述

wp_skip_border_serialization() 是一个已弃用的 WordPress 函数,用于检查当前区块的边框属性序列化是否应跳过。自 WordPress 6.0.0 起,建议使用 wp_should_skip_block_supports_serialization() 替代。

关键要点

  • 函数 wp_skip_border_serialization() 已弃用,自 6.0.0 版本起应改用 wp_should_skip_block_supports_serialization()。
  • 该函数检查区块类型是否设置了 __experimentalBorder 支持,并验证 __experimentalSkipSerialization 属性以决定是否跳过边框序列化。
  • 参数 $block_type 为 WP_Block_Type 对象,返回布尔值表示是否应跳过序列化。

注意事项

使用此函数会触发弃用警告,建议更新代码以避免兼容性问题。


📄 原文内容

Checks whether serialization of the current block’s border properties should occur.

Description

See also

Parameters

$block_typeWP_Block_Typerequired
Block type.

Return

bool Whether serialization of the current block’s border properties should occur.

Source

function wp_skip_border_serialization( $block_type ) {
	_deprecated_function( __FUNCTION__, '6.0.0', 'wp_should_skip_block_supports_serialization()' );

	$border_support = isset( $block_type->supports['__experimentalBorder'] )
		? $block_type->supports['__experimentalBorder']
		: false;

	return is_array( $border_support ) &&
		array_key_exists( '__experimentalSkipSerialization', $border_support ) &&
		$border_support['__experimentalSkipSerialization'];
}

Changelog

Version Description
6.0.0 Deprecated. Use wp_should_skip_block_supports_serialization() introduced in 6.0.0.
5.8.0 Introduced.