WP_Block_Metadata_Registry::get_default_collection_roots
Gets the default collection root directory paths.
Method of the class: WP_Block_Metadata_Registry{}
No Hooks.
Returns
String[]
. List of directory paths within which metadata collections are allowed.
Usage
$result = WP_Block_Metadata_Registry::get_default_collection_roots();
Changelog
Since 6.7.2 | Introduced. |
WP_Block_Metadata_Registry::get_default_collection_roots() WP Block Metadata Registry::get default collection roots code WP 6.8.1
private static function get_default_collection_roots() { if ( isset( self::$default_collection_roots ) ) { return self::$default_collection_roots; } $collection_roots = array( wp_normalize_path( ABSPATH . WPINC ), wp_normalize_path( WP_CONTENT_DIR ), wp_normalize_path( WPMU_PLUGIN_DIR ), wp_normalize_path( WP_PLUGIN_DIR ), ); $theme_roots = get_theme_roots(); if ( ! is_array( $theme_roots ) ) { $theme_roots = array( $theme_roots ); } foreach ( $theme_roots as $theme_root ) { $collection_roots[] = trailingslashit( wp_normalize_path( WP_CONTENT_DIR ) ) . ltrim( wp_normalize_path( $theme_root ), '/' ); } self::$default_collection_roots = array_unique( $collection_roots ); return self::$default_collection_roots; }