_wp_filter_taxonomy_base()
云策文档标注
概述
_wp_filter_taxonomy_base() 是一个 WordPress 内部函数,用于过滤分类法的 URL 基础路径,主要移除手动添加的 /index.php/ 前缀。
关键要点
- 函数作用:过滤分类法的 URL 基础路径,移除 /index.php/ 前缀并修剪斜杠。
- 参数:$base(必需),表示要过滤的分类法基础路径字符串。
- 返回值:返回处理后的字符串。
- 引入版本:WordPress 2.6.0。
代码示例
function _wp_filter_taxonomy_base( $base ) {
if ( ! empty( $base ) ) {
$base = preg_replace( '|^/index.php/|', '', $base );
$base = trim( $base, '/' );
}
return $base;
}
原文内容
Filters the URL base for taxonomies.
Description
To remove any manually prepended /index.php/.
Parameters
$basestringrequired-
The taxonomy base that we’re going to filter
Source
function _wp_filter_taxonomy_base( $base ) {
if ( ! empty( $base ) ) {
$base = preg_replace( '|^/index.php/|', '', $base );
$base = trim( $base, '/' );
}
return $base;
}
Changelog
| Version | Description |
|---|---|
| 2.6.0 | Introduced. |