wpseek.com
WordPress开发者和主题制作者的搜索引擎



wp_apply_anchor_support › WordPress Function

Since7.0.0
已弃用n/a
› wp_apply_anchor_support ( $block_type, $block_attributes )
访问:
  • private
参数: (2)
  • (WP_Block_Type) $block_type Block Type.
    Required: Yes
  • (array<string,mixed>) $block_attributes Block attributes.
    Required: Yes
返回:
  • (array<string,string>) Attributes with block anchor id.
定义在:
文档:

Add the anchor id to the output.



源码

function wp_apply_anchor_support( WP_Block_Type $block_type, array $block_attributes ): array {
	if ( empty( $block_attributes ) ) {
		return array();
	}

	if ( ! block_has_support( $block_type, array( 'anchor' ) ) ) {
		return array();
	}

	if ( ! isset( $block_attributes['anchor'] ) || ! is_string( $block_attributes['anchor'] ) || '' === $block_attributes['anchor'] ) {
		return array();
	}

	return array( 'id' => $block_attributes['anchor'] );
}