_strip_template_file_suffix()
云策文档标注
概述
_strip_template_file_suffix() 是一个 WordPress 函数,用于从模板文件名中移除 .php 或 .html 后缀。它接受一个字符串参数并返回去除后缀后的文件名。
关键要点
- 函数功能:移除模板文件名中的 .php 或 .html 后缀
- 参数:$template_file(字符串,必需),表示模板文件名
- 返回值:字符串,表示去除后缀后的模板文件名
- 实现方式:使用正则表达式 preg_replace 匹配并移除后缀
- 引入版本:WordPress 5.8.0
代码示例
function _strip_template_file_suffix( $template_file ) {
return preg_replace( '/.(php|html)$/', '', $template_file );
}
原文内容
Strips .php or .html suffix from template file names.
Parameters
$template_filestringrequired-
Template file name.
Source
function _strip_template_file_suffix( $template_file ) {
return preg_replace( '/.(php|html)$/', '', $template_file );
}
Changelog
| Version | Description |
|---|---|
| 5.8.0 | Introduced. |