_register_block_bindings_post_data_source()
云策文档标注
概述
此函数用于在块绑定注册表中注册 Post Data 数据源,为 WordPress 开发者提供一种标准化的方式来关联块与文章数据。
关键要点
- 函数 _register_block_bindings_post_data_source() 调用 register_block_bindings_source() 来注册一个名为 'core/post-data' 的块绑定源。
- 注册时指定了标签、获取值的回调函数 _block_bindings_post_data_get_value,以及所需的上下文数组(包括 postId 和 postType)。
- 此功能从 WordPress 6.9.0 版本开始引入。
原文内容
Registers Post Data source in the block bindings registry.
Source
function _register_block_bindings_post_data_source() {
register_block_bindings_source(
'core/post-data',
array(
'label' => _x( 'Post Data', 'block bindings source' ),
'get_value_callback' => '_block_bindings_post_data_get_value',
'uses_context' => array( 'postId', 'postType' ), // Both are needed on the client side.
)
);
}
Changelog
| Version | Description |
|---|---|
| 6.9.0 | Introduced. |