get_parent_theme_file_uri

函式
get_parent_theme_file_uri ( $file = '' )
引數
  • (string) $file Optional. File to return the URL for in the template directory.
    Required:
    Default: (empty)
返回值
  • (string) The URL of the file.
定義位置
相關方法
get_parent_theme_file_pathget_theme_file_uriwp_print_theme_file_treeget_registered_theme_featureget_theme_file_path
引入
4.7.0
棄用
-

get_parent_theme_file_uri函式是一個WordPress的函式,用於檢索父主題目錄中的檔案的URL: 這個函式接受一個引數,即你要檢索的檔案的URL的檔名: 該函式返回指定檔案的URL。

檢索父主題中一個檔案的URL。

function get_parent_theme_file_uri( $file = '' ) {
	$file = ltrim( $file, '/' );

	if ( empty( $file ) ) {
		$url = get_template_directory_uri();
	} else {
		$url = get_template_directory_uri() . '/' . $file;
	}

	/**
	 * Filters the URL to a file in the parent theme.
	 *
	 * @since 4.7.0
	 *
	 * @param string $url  The file URL.
	 * @param string $file The requested file to search for.
	 */
	return apply_filters( 'parent_theme_file_uri', $url, $file );
}

常見問題

FAQs
檢視更多 >