wpseek.com
WordPress开发者和主题制作者的搜索引擎



_get_block_templates_paths › WordPress Function

Since5.9.0
已弃用n/a
_get_block_templates_paths ( $base_directory )
访问:
  • private
参数:
  • (string) $base_directory The theme's file path.
    Required: Yes
返回:
  • (string[]) A list of paths to all template part files.
定义在:
文档:

Finds all nested template part file paths in a theme's directory.



源码

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