函数文档

wp_register_block_metadata_collection()

💡 云策文档标注

概述

wp_register_block_metadata_collection() 函数用于注册块元数据集合,允许核心和第三方插件在集中位置注册其块元数据集合,以提高性能。

关键要点

  • 函数用途:注册块元数据集合,避免从文件系统多次读取和解析 JSON,从而提升性能。
  • 参数说明:$path(必需)为集合中块文件的基础路径,$manifest(必需)为集合清单文件的路径。
  • 内部实现:通过调用 WP_Block_Metadata_Registry::register_collection() 方法实现注册。
  • 相关函数:与 wp_register_block_types_from_metadata_collection() 关联,用于从集合注册所有块类型。
  • 版本信息:自 WordPress 6.7.0 版本引入。

📄 原文内容

Registers a block metadata collection.

Description

This function allows core and third-party plugins to register their block metadata collections in a centralized location. Registering collections can improve performance by avoiding multiple reads from the filesystem and parsing JSON.

Parameters

$pathstringrequired
The base path in which block files for the collection reside.
$manifeststringrequired
The path to the manifest file for the collection.

Source

function wp_register_block_metadata_collection( $path, $manifest ) {
	WP_Block_Metadata_Registry::register_collection( $path, $manifest );
}

Changelog

Version Description
6.7.0 Introduced.