钩子文档

wp_list_table_show_post_checkbox

💡 云策文档标注

概述

wp_list_table_show_post_checkbox 是一个 WordPress 过滤器,用于控制文章列表表格中是否显示批量编辑复选框。默认情况下,复选框仅对当前用户有编辑权限的文章显示。

关键要点

  • 这是一个过滤器,允许开发者自定义文章列表表格中复选框的显示逻辑。
  • 默认行为基于当前用户对文章的编辑权限来决定是否显示复选框。
  • 过滤器接受两个参数:$show(布尔值,表示是否显示复选框)和 $post(WP_Post 对象,表示当前文章)。
  • 在 WP_Posts_List_Table::column_cb() 方法中使用,处理复选框列的输出。
  • 该过滤器从 WordPress 5.7.0 版本开始引入。

代码示例

if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :

📄 原文内容

Filters whether to show the bulk edit checkbox for a post in its list table.

Description

By default the checkbox is only shown if the current user can edit the post.

Parameters

$showbool
Whether to show the checkbox.
$postWP_Post
The current WP_Post object.

Source

if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :

Changelog

Version Description
5.7.0 Introduced.