_get_block_templates_paths

The timeline below displays how wordpress function _get_block_templates_paths has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.2

/**
 * Finds all nested template part file paths in a theme's directory.
 *
 * @since 5.9.0
 * @access private
 *
 * @param string $base_directory The theme's file path.
 * @return string[] A list of paths to all template part files.
 */
function _get_block_templates_paths($base_directory)
{
    static $template_path_list = array();
    if (isset($template_path_list[$base_directory])) {
        return $template_path_list[$base_directory];
    }
    $path_list = array();
    if (is_dir($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;
        }
    }
    $template_path_list[$base_directory] = $path_list;
    return $path_list;
}

WordPress Version: 6.5

/**
 * Finds all nested template part file paths in a theme's directory.
 *
 * @since 5.9.0
 * @access private
 *
 * @param string $base_directory The theme's file path.
 * @return string[] A list of paths to all template part files.
 */
function _get_block_templates_paths($base_directory)
{
    static $template_path_list = array();
    if (isset($template_path_list[$base_directory])) {
        return $template_path_list[$base_directory];
    }
    $path_list = array();
    try {
        $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;
        }
    } catch (Exception $e) {
        // Do nothing.
    }
    $template_path_list[$base_directory] = $path_list;
    return $path_list;
}

WordPress Version: 6.3

/**
 * Finds all nested template part file paths in a theme's directory.
 *
 * @since 5.9.0
 * @access private
 *
 * @param string $base_directory The theme's file path.
 * @return string[] A list of paths to all template part files.
 */
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;
}

WordPress Version: 5.9

/**
 * Finds all nested template part file paths in a theme's directory.
 *
 * @since 5.9.0
 * @access private
 *
 * @param string $base_directory The theme's file path.
 * @return array A list of paths to all template part files.
 */
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;
}