do_meta_boxes
云策文档标注
概述
do_meta_boxes 是一个 WordPress 动作钩子,在元框(meta boxes)被添加后触发。它用于在编辑文章、链接或仪表板等屏幕中执行自定义操作。
关键要点
- 触发时机:在默认元框上下文(normal、advanced、side)的元框添加后触发。
- 参数:包括 $post_type(文章类型或屏幕标识)、$context(元框上下文)和 $post(文章对象、链接对象或空字符串)。
- 用途:常用于注册或自定义元框,例如在 register_and_do_post_meta_boxes() 和 wp_dashboard_setup() 函数中调用。
代码示例
do_action( 'do_meta_boxes', $post_type, 'normal', $post );注意事项
- 此钩子自 WordPress 3.0.0 版本引入。
- 在不同屏幕(如编辑文章、编辑链接、仪表板)中,$post 参数可能为文章对象、链接对象或空字符串,需根据上下文处理。
原文内容
Fires after meta boxes have been added.
Description
Fires once for each of the default meta box contexts: normal, advanced, and side.
Parameters
$post_typestring-
Post type of the post on Edit Post screen,
'link'on Edit Link screen,'dashboard'on Dashboard screen. $contextstring-
Meta box context. Possible values include
'normal','advanced','side'. $postWP_Post|object|string-
Post object on Edit Post screen, link object on Edit Link screen, an empty string on Dashboard screen.
Source
do_action( 'do_meta_boxes', $post_type, 'normal', $post );
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |