钩子文档

disable_formats_dropdown

💡 云策文档标注

概述

本文档介绍 disable_formats_dropdown 过滤器,用于控制是否在文章列表表中移除“格式”下拉菜单。该过滤器接受布尔值和文章类型参数,影响 WP_Posts_List_Table::formats_dropdown() 方法的行为。

关键要点

  • 过滤器名称:disable_formats_dropdown
  • 参数:$disable(布尔值,默认 false)和 $post_type(字符串,文章类型 slug)
  • 用途:移除文章列表表中的“格式”下拉菜单,常用于自定义文章类型或特定界面优化
  • 相关函数:WP_Posts_List_Table::formats_dropdown(),位于 wp-admin/includes/class-wp-posts-list-table.php
  • 版本变更:5.2.0 引入,5.5.0 添加 $post_type 参数

代码示例

if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) {

📄 原文内容

Filters whether to remove the ‘Formats’ drop-down from the post list table.

Parameters

$disablebool
Whether to disable the drop-down. Default false.
$post_typestring
Post type slug.

Source

if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) {

Changelog

Version Description
5.5.0 The $post_type parameter was added.
5.2.0 Introduced.