钩子文档

nav_menu_meta_box_object

💡 云策文档标注

概述

nav_menu_meta_box_object 是一个 WordPress 过滤器,用于控制是否为当前对象类型添加菜单项元框。如果过滤器返回假值,则不会添加对应的菜单项元框。

关键要点

  • 过滤器名称:nav_menu_meta_box_object
  • 参数:$post_type,类型为 WP_Post_Type 或 false,表示当前要添加菜单项元框的对象
  • 返回值:如果返回 false 或其他假值,则阻止添加菜单项元框;否则,正常添加
  • 用途:常用于 AJAX 处理或自定义菜单元框逻辑中

代码示例

$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );

注意事项

  • 此过滤器在 WordPress 3.0.0 版本中引入
  • 相关函数包括 wp_ajax_menu_get_metabox()、wp_nav_menu_post_type_meta_boxes() 和 wp_nav_menu_taxonomy_meta_boxes()

📄 原文内容

Filters whether a menu items meta box will be added for the current object type.

Description

If a falsey value is returned instead of an object, the menu items meta box for the current meta box object will not be added.

Parameters

$post_typeWP_Post_Type|false
The current object to add a menu items meta box for.

Source

$post_type = apply_filters( 'nav_menu_meta_box_object', $post_type );

Changelog

Version Description
3.0.0 Introduced.