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,43 +1653,49 @@ class WP_Posts_List_Table extends WP_List_Table {
<?php endif; // $bulk ?> <?php endif; // $bulk ?>
<?php <?php
if ( post_type_supports( $screen->post_type, 'author' ) && ! wp_is_large_user_count() ) { if ( post_type_supports( $screen->post_type, 'author' ) ) {
$authors_dropdown = ''; $authors_dropdown = '';
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) {
$users_opt = array( $dropdown_name = 'post_author';
'hide_if_only_one_author' => false, $dropdown_class = 'authors';
'capability' => array( $post_type_object->cap->edit_posts ), if ( wp_is_large_user_count() ) {
'name' => 'post_author', $authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) );
'class' => 'authors', } else {
'multi' => 1, $users_opt = array(
'echo' => 0, 'hide_if_only_one_author' => false,
'show' => 'display_name_with_login', 'capability' => array( $post_type_object->cap->edit_posts ),
); 'name' => $dropdown_name,
'class' => $dropdown_class,
'multi' => 1,
'echo' => 0,
'show' => 'display_name_with_login',
);
if ( $bulk ) { if ( $bulk ) {
$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' ); $users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
} }
/** /**
* Filters the arguments used to generate the Quick Edit authors drop-down. * Filters the arguments used to generate the Quick Edit authors drop-down.
* *
* @since 5.6.0 * @since 5.6.0
* *
* @see wp_dropdown_users() * @see wp_dropdown_users()
* *
* @param array $users_opt An array of arguments passed to wp_dropdown_users(). * @param array $users_opt An array of arguments passed to wp_dropdown_users().
* @param bool $bulk A flag to denote if it's a bulk action. * @param bool $bulk A flag to denote if it's a bulk action.
*/ */
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); $users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk );
$authors = wp_dropdown_users( $users_opt ); $authors = wp_dropdown_users( $users_opt );
if ( $authors ) { if ( $authors ) {
$authors_dropdown = '<label class="inline-edit-author">'; $authors_dropdown = '<label class="inline-edit-author">';
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; $authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
$authors_dropdown .= $authors; $authors_dropdown .= $authors;
$authors_dropdown .= '</label>'; $authors_dropdown .= '</label>';
}
} }
} // current_user_can( 'edit_others_posts' ) } // current_user_can( 'edit_others_posts' )
@ -1748,7 +1754,7 @@ class WP_Posts_List_Table extends WP_List_Table {
<div class="inline-edit-col"> <div class="inline-edit-col">
<?php <?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; echo $authors_dropdown;
} }
?> ?>

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @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. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.