WP_Block_Metadata_Registry::get_metadata()
Retrieves block metadata for a given block within a specific collection.
This method uses the registered collections to efficiently lookup block metadata without reading individual block.json files.
Метод класса: WP_Block_Metadata_Registry{}
Хуков нет.
Возвращает
Массив|null
. The block metadata for the block, or null if not found.
Использование
$result = WP_Block_Metadata_Registry::get_metadata( $file_or_folder );
- $file_or_folder(строка) (обязательный)
- The path to the file or folder containing the block.
Список изменений
С версии 6.7.0 | Введена. |
Код WP_Block_Metadata_Registry::get_metadata() WP Block Metadata Registry::get metadata WP 6.7.1
public static function get_metadata( $file_or_folder ) { $path = self::find_collection_path( $file_or_folder ); if ( ! $path ) { return null; } $collection = &self::$collections[ $path ]; if ( null === $collection['metadata'] ) { // Load the manifest file if not already loaded $collection['metadata'] = require $collection['manifest']; } // Get the block name from the path. $block_name = self::default_identifier_callback( $file_or_folder ); return isset( $collection['metadata'][ $block_name ] ) ? $collection['metadata'][ $block_name ] : null; }