_register_block_bindings_post_meta_source()
云策文档标注
概述
此函数用于在块绑定注册表中注册 Post Meta 源,允许开发者将块属性绑定到文章元数据。
关键要点
- 函数名:_register_block_bindings_post_meta_source()
- 调用 register_block_bindings_source() 注册源,标识符为 'core/post-meta'
- 配置包括标签、获取值回调函数和使用的上下文(postId 和 postType)
- 引入于 WordPress 6.5.0 版本
代码示例
_register_block_bindings_post_meta_source() {
register_block_bindings_source(
'core/post-meta',
array(
'label' => _x( 'Post Meta', 'block bindings source' ),
'get_value_callback' => '_block_bindings_post_meta_get_value',
'uses_context' => array( 'postId', 'postType' ),
)
);
}
原文内容
Registers Post Meta source in the block bindings registry.
Source
function _register_block_bindings_post_meta_source() {
register_block_bindings_source(
'core/post-meta',
array(
'label' => _x( 'Post Meta', 'block bindings source' ),
'get_value_callback' => '_block_bindings_post_meta_get_value',
'uses_context' => array( 'postId', 'postType' ),
)
);
}
Changelog
| Version | Description |
|---|---|
| 6.5.0 | Introduced. |