钩子文档

post_submitbox_minor_actions

💡 云策文档标注

概述

post_submitbox_minor_actions 是一个 WordPress 动作钩子,在发布元框中的“保存草稿”(或“保存为待审”)和“预览”(或“预览更改”)按钮后触发,用于在文章提交过程中执行自定义操作。

关键要点

  • 触发时机:在发布元框的次要操作按钮(如保存草稿、预览)后执行,但根据用户贡献说明,实际触发位置在发布元框的整个内容之前,包括可见性、状态和修订设置。
  • 参数:传递 $post 参数,类型为 WP_Post 对象,代表当前文章。
  • 相关函数:与 post_submit_meta_box() 函数关联,用于显示文章提交表单字段。
  • 版本历史:自 WordPress 4.4.0 版本引入。

注意事项

官方文档描述可能不准确:此钩子并非在文章时间/日期设置之前触发,而是在发布元框的所有设置(如可见性、状态、修订)之前触发。开发者应注意避免基于错误文档进行错误假设,例如试图在修订后但时间/日期前挂钩操作。


📄 原文内容

Fires after the Save Draft (or Save as Pending) and Preview (or Preview Changes) buttons in the Publish meta box.

Parameters

$postWP_Post
WP_Post object for the current post.

Source

do_action( 'post_submitbox_minor_actions', $post );

Changelog

Version Description
4.4.0 Introduced.

User Contributed Notes

  1. Skip to note 2 content


    Anonymous User



    This action does not fire “before the post time/date setting in the Publish meta box.”. It fires before _everyting_ in the Publish DIV box:
    – before the visibility settings,
    – before the status
    – before the revisions.

    The time/time settings come only _after_ all those other settings. So the Code doc is wrong, and can mislead users to think they may use this Hook to hook in right after revisions but right before time/date. They can’t.