WP_Block_Metadata_Registry::get_default_collection_roots(): string[]

In this article

This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

Gets the default collection root directory paths.

Return

string[] List of directory paths within which metadata collections are allowed.

Source

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;
}

Changelog

VersionDescription
6.7.2Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.