描述
通过函数传递一个分类项字段的值,应该被假定为已经为分类项字段将要使用的上下文清理了该值。
如果没有给定上下文或不支持的上下文,则将应用默认过滤器。
每个上下文都有足够的过滤器来支持自定义筛选,而无需创建自己的过滤函数。只需创建一个与所需过滤器挂钩的函数。
参数
$field
string必填-
要清理的分类项(term)字段。
$value
string必填-
搜索此分类项值。
$term_id
int必填-
分类项 ID。
$taxonomy
string必填-
分类法(taxonomy)名称。
$context
string必填-
清理分类项字段的上下文。
接受'raw'
、'edit'
、'db'
、'display'
、'rss'
、'attribute'
或'js'
。默认'display'
。
返回
mixed 清理后的字段。
钩子
- apply_filters( "edit_term_{$field}",
mixed $value ,int $term_id ,string $taxonomy ) -
过滤要编辑的分类项(term)字段,然后再对其进行清理。
- apply_filters( "edit_{$taxonomy}_{$field}",
mixed $value ,int $term_id ) -
在清理分类法字段之前,过滤要编辑的分类字段。
- apply_filters( 'pre_category_nicename',
string $value ) -
在清理类别nicename之前对其进行过滤。
- apply_filters( "pre_term_{$field}",
mixed $value ,string $taxonomy ) -
在清除分类项(term)字段值之前过滤该值。
- apply_filters( "pre_{$taxonomy}_{$field}",
mixed $value ) -
在清理分类法字段之前过滤该字段。
- apply_filters( "term_{$field}",
mixed $value ,int $term_id ,string $taxonomy ,string $context ) -
过滤清理以供显示的分类项(term)字段。
- apply_filters( "term_{$field}_rss",
mixed $value ,string $taxonomy ) -
过滤在RSS中使用的分类项(term)字段。
- apply_filters( "{$taxonomy}_{$field}",
mixed $value ,int $term_id ,string $context ) -
过滤清理以供显示的分类法字段。
- apply_filters( "{$taxonomy}_{$field}_rss",
mixed $value ) -
过滤在RSS中使用的分类法字段。
源码
更新日志
版本 | 描述 |
---|---|
2.3.0 | 开始引入 |