{$field_no_prefix}_edit_pre
云策文档标注
概述
此文档介绍 WordPress 中的 {$field_no_prefix}_edit_pre 过滤器,用于在编辑特定文章字段时过滤其值。该过滤器仅适用于以 post_ 为前缀的字段,动态部分 $field_no_prefix 表示字段名去除前缀后的部分。
关键要点
- 过滤器名称基于字段名,例如 author_edit_pre、title_edit_pre 等。
- 参数包括 $value(字段值)和 $post_id(文章 ID)。
- 在 sanitize_post_field() 函数中使用,用于根据上下文清理文章字段。
代码示例
$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );注意事项
- 仅适用于以 post_ 为前缀的字段,如 post_author、post_title 等。
- 自 WordPress 2.3.0 版本引入。
原文内容
Filters the value of a specific post field to edit.
Description
Only applied to post fields with a name which is prefixed with post_.
The dynamic portion of the hook name, $field_no_prefix, refers to the post field name minus the post_ prefix. Possible filter names include:
author_edit_predate_edit_predate_gmt_edit_precontent_edit_pretitle_edit_preexcerpt_edit_prestatus_edit_prepassword_edit_prename_edit_premodified_edit_premodified_gmt_edit_precontent_filtered_edit_preparent_edit_pretype_edit_premime_type_edit_pre
Parameters
$valuemixed-
Value of the post field.
$post_idint-
Post ID.
Source
$value = apply_filters( "{$field_no_prefix}_edit_pre", $value, $post_id );
Changelog
| Version | Description |
|---|---|
| 2.3.0 | Introduced. |