_get_template_edit_filename()
云策文档标注
概述
_get_template_edit_filename() 函数用于为主题文件编辑器整理文件名以进行 URL 显示。它通过移除父文件夹路径来生成相对路径。
关键要点
- 函数接受两个必需参数:$fullpath(主题文件的完整路径)和 $containingfolder(主题父文件夹的路径)。
- 返回一个字符串,表示从完整路径中移除父文件夹路径后的相对路径。
- 该函数自 WordPress 2.9.0 版本引入。
代码示例
function _get_template_edit_filename( $fullpath, $containingfolder ) {
return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
}
原文内容
Tidies a filename for url display by the theme file editor.
Parameters
$fullpathstringrequired-
Full path to the theme file
$containingfolderstringrequired-
Path of the theme parent folder
Source
function _get_template_edit_filename( $fullpath, $containingfolder ) {
return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
}
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |