
适合初学者和专业人士CSS备忘单
_get_block_templates_paths ( $base_directory )
_get_block_templates_paths: 这是一个用来获取特定主题的所有块模板路径的数组的函数。它接收一个主题目录路径作为参数,并返回一个块模板路径的数组。
找到一个主题目录中所有嵌套的模板部分文件路径。
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; }