- Timestamp:
- 02/26/2025 07:38:08 PM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-block-metadata-registry.php
r59730 r59874 181 181 182 182 /** 183 * Gets the list of absolute paths to all block metadata files that are part of the given collection. 184 * 185 * For instance, if a block metadata collection is registered with path `WP_PLUGIN_DIR . '/my-plugin/blocks/'`, 186 * and the manifest file includes metadata for two blocks `'block-a'` and `'block-b'`, the result of this method 187 * will be an array containing: 188 * * `WP_PLUGIN_DIR . '/my-plugin/blocks/block-a/block.json'` 189 * * `WP_PLUGIN_DIR . '/my-plugin/blocks/block-b/block.json'` 190 * 191 * @since 6.8.0 192 * 193 * @param string $path The absolute base path for a previously registered collection. 194 * @return string[] List of block metadata file paths, or an empty array if the given `$path` is invalid. 195 */ 196 public static function get_collection_block_metadata_files( $path ) { 197 $path = wp_normalize_path( rtrim( $path, '/' ) ); 198 199 if ( ! isset( self::$collections[ $path ] ) ) { 200 _doing_it_wrong( 201 __METHOD__, 202 __( 'No registered block metadata collection was found for the provided path.' ), 203 '6.8.0' 204 ); 205 return array(); 206 } 207 208 $collection = &self::$collections[ $path ]; 209 210 if ( null === $collection['metadata'] ) { 211 // Load the manifest file if not already loaded. 212 $collection['metadata'] = require $collection['manifest']; 213 } 214 215 return array_map( 216 static function ( $block_name ) use ( $path ) { 217 return "{$path}/{$block_name}/block.json"; 218 }, 219 array_keys( $collection['metadata'] ) 220 ); 221 } 222 223 /** 183 224 * Finds the collection path for a given file or folder. 184 225 *
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)