pre_term_{$field}
云策文档标注
概述
pre_term_{$field} 是一个 WordPress 过滤器钩子,用于在术语字段值被清理之前进行过滤。动态部分 $field 指代术语字段名称。
关键要点
- 钩子名称包含动态部分 $field,对应术语字段(如 name、description)。
- 参数包括 $value(术语字段的原始值)和 $taxonomy(分类法 slug)。
- 主要用于在 sanitize_term_field() 函数中调用,允许开发者修改清理前的术语数据。
代码示例
$value = apply_filters( "pre_term_{$field}", $value, $taxonomy );注意事项
- 自 WordPress 2.3.0 版本引入,确保兼容性。
- 与 sanitize_term_field() 函数关联,用于术语字段的清理流程。
原文内容
Filters a term field value before it is sanitized.
Description
The dynamic portion of the hook name, $field, refers to the term field.
Parameters
$valuemixed-
Value of the term field.
$taxonomystring-
Taxonomy slug.
Source
$value = apply_filters( "pre_term_{$field}", $value, $taxonomy );
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |