Posts, Post Types: Introduce the wp_list_table_show_post_checkbox filter which allows the visibility of the bulk edit checkbox on the post list table to be controlled separately from the edit_post capability of the current user.

Props coreyw, alexstine

Fixes #51291

Built from https://develop.svn.wordpress.org/trunk@49950


git-svn-id: http://core.svn.wordpress.org/trunk@49649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
John Blackbourn 2021-01-08 17:18:07 +00:00
parent 47c146ac27
commit b364ff86e5
2 changed files with 14 additions and 2 deletions

View File

@ -925,7 +925,19 @@ class WP_Posts_List_Table extends WP_List_Table {
* @param WP_Post $post The current WP_Post object.
*/
public function column_cb( $post ) {
if ( current_user_can( 'edit_post', $post->ID ) ) :
$show = current_user_can( 'edit_post', $post->ID );
/**
* Filters whether to show the bulk edit checkbox for a post in its list table.
*
* By default the checkbox is only shown if the current user can edit the post.
*
* @since 5.7.0
*
* @param bool $show Whether to show the checkbox.
* @param WP_Post $post The current WP_Post object.
*/
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
?>
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
<?php

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49949';
$wp_version = '5.7-alpha-49950';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.