_get_block_templates_paths

函式
_get_block_templates_paths ( $base_directory )
Access
Private
引數
  • (string) $base_directory The theme's file path.
    Required:
返回值
  • (array) A list of paths to all template part files.
定義位置
相關方法
_get_block_templates_filesget_block_templatesget_block_template_get_block_template_fileblock_template_part
引入
5.9.0
棄用
-

_get_block_templates_paths: 這是一個用來獲取特定主題的所有塊模板路徑的陣列的函式。它接收一個主題目錄路徑作為引數,並返回一個塊模板路徑的陣列。

找到一個主題目錄中所有巢狀的模板部分檔案路徑。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >