
什么是及如何使用WordPress CLI
get_theme_file_uri ( $file = '' )
get_theme_file_uri: 这个函数返回当前主题目录中一个给定文件的URI。该URI是相对于主题目录的。
检索主题中一个文件的URL。
在模板目录之前搜索样式表目录,因此从父主题继承的主题可以只覆盖一个文件。
function get_theme_file_uri( $file = '' ) { $file = ltrim( $file, '/' ); if ( empty( $file ) ) { $url = get_stylesheet_directory_uri(); } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) { $url = get_stylesheet_directory_uri() . '/' . $file; } else { $url = get_template_directory_uri() . '/' . $file; } /** * Filters the URL to a file in the theme. * * @since 4.7.0 * * @param string $url The file URL. * @param string $file The requested file to search for. */ return apply_filters( 'theme_file_uri', $url, $file ); }