Users: Prevent author changes in bulk editor on large sites.

On large sites (with over 1000 users), include a hidden `post_author` field in the bulk editing interface to preven unexpected authorship changes.

Follow up to [53011], [53049].

Props georgestephanis, tobifjellner, peterwilsoncc, spacedmonkey, jb510.
Fixes #38741.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Peter Wilson 2022-04-08 06:26:02 +00:00
parent 5e885b798f
commit 8c29f283d7
2 changed files with 38 additions and 32 deletions

View File

@ -1653,15 +1653,20 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php endif; // $bulk ?>
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && ! wp_is_large_user_count() ) {
if ( post_type_supports( $screen->post_type, 'author' ) ) {
$authors_dropdown = '';
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$dropdown_name = 'post_author';
$dropdown_class = 'authors';
if ( wp_is_large_user_count() ) {
$authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) );
} else {
$users_opt = array(
'hide_if_only_one_author' => false,
'capability' => array( $post_type_object->cap->edit_posts ),
'name' => 'post_author',
'class' => 'authors',
'name' => $dropdown_name,
'class' => $dropdown_class,
'multi' => 1,
'echo' => 0,
'show' => 'display_name_with_login',
@ -1691,6 +1696,7 @@ class WP_Posts_List_Table extends WP_List_Table {
$authors_dropdown .= $authors;
$authors_dropdown .= '</label>';
}
}
} // current_user_can( 'edit_others_posts' )
if ( ! $bulk ) {
@ -1748,7 +1754,7 @@ class WP_Posts_List_Table extends WP_List_Table {
<div class="inline-edit-col">
<?php
if ( post_type_supports( $screen->post_type, 'author' ) && ! wp_is_large_user_count() && $bulk ) {
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) {
echo $authors_dropdown;
}
?>

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.0-alpha-53104';
$wp_version = '6.0-alpha-53105';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.