On this page
_get_block_templates_paths( string $base_directory ): array
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.
Finds all nested template part file paths in a theme’s directory.
Parameters
$base_directorystring Required-
The theme's file path.
Return
array A list of paths to all template part files.
Source
File: wp-includes/block-template-utils.php. View all references
function _get_block_templates_paths( $base_directory ) {
$path_list = array();
if ( file_exists( $base_directory ) ) {
$nested_files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator( $base_directory ) );
$nested_html_files = new RegexIterator( $nested_files, '/^.+\.html$/i', RecursiveRegexIterator::GET_MATCH );
foreach ( $nested_html_files as $path => $file ) {
$path_list[] = $path;
}
}
return $path_list;
}
Related
Used By
| Used By | Description |
|---|---|
| _get_block_templates_files() wp-includes/block-template-utils.php | Retrieves the template files from the theme. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/_get_block_templates_paths