钩子文档

edit_{$taxonomy}_{$field}

💡 云策文档标注

概述

edit_{$taxonomy}_{$field} 是一个 WordPress 过滤器,用于在分类法字段被清理之前修改其值。它允许开发者在处理分类法数据时进行自定义操作。

关键要点

  • 这是一个动态过滤器,名称中的 $taxonomy 和 $field 分别代表分类法 slug 和字段名。
  • 过滤器接收两个参数:$value(分类法字段的原始值)和 $term_id(术语 ID)。
  • 常用于 sanitize_term_field() 函数中,以在清理前调整字段值。

代码示例

$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );

注意事项

  • 此过滤器自 WordPress 2.3.0 版本引入,确保在兼容版本中使用。
  • 使用时应确保 $taxonomy 和 $field 变量正确设置,以避免过滤器名称错误。

📄 原文内容

Filters the taxonomy field to edit before it is sanitized.

Description

The dynamic portions of the filter name, $taxonomy and $field, refer to the taxonomy slug and taxonomy field, respectively.

Parameters

$valuemixed
Value of the taxonomy field to edit.
$term_idint
Term ID.

Source

$value = apply_filters( "edit_{$taxonomy}_{$field}", $value, $term_id );

Changelog

Version Description
2.3.0 Introduced.