When deleting via User List Table, don't prompt for re-attribution if the user(s) do(es) not have any posts.

Props rajnikmit, wojtek.szkutnik, benjmay, wonderboymusic.
Fixes #6405. 


git-svn-id: https://develop.svn.wordpress.org/trunk@34000 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor 2015-09-10 16:46:38 +00:00
parent 9473a479d9
commit 2deb9565c0
2 changed files with 46 additions and 34 deletions

View File

@ -446,3 +446,22 @@ function default_password_nag() {
printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' ); printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
echo '</p></div>'; echo '</p></div>';
} }
/**
* @since 3.5.0
* @access private
*/
function delete_users_add_js() { ?>
<script>
jQuery(document).ready( function($) {
var submit = $('#submit').prop('disabled', true);
$('input[name="delete_option"]').one('change', function() {
submit.prop('disabled', false);
});
$('#reassign_user').focus( function() {
$('#delete_option1').prop('checked', true).trigger('change');
});
});
</script>
<?php
}

View File

@ -80,25 +80,6 @@ if ( empty($_REQUEST) ) {
$update = ''; $update = '';
/**
* @since 3.5.0
* @access private
*/
function delete_users_add_js() { ?>
<script>
jQuery(document).ready( function($) {
var submit = $('#submit').prop('disabled', true);
$('input[name=delete_option]').one('change', function() {
submit.prop('disabled', false);
});
$('#reassign_user').focus( function() {
$('#delete_option1').prop('checked', true).trigger('change');
});
});
</script>
<?php
}
switch ( $wp_list_table->current_action() ) { switch ( $wp_list_table->current_action() ) {
/* Bulk Dropdown menu Role changes */ /* Bulk Dropdown menu Role changes */
@ -215,7 +196,15 @@ case 'delete':
else else
$userids = array_map( 'intval', (array) $_REQUEST['users'] ); $userids = array_map( 'intval', (array) $_REQUEST['users'] );
$users_posts = new WP_Query( array(
'post_type' => 'any',
'author' => implode( ',', $userids ),
'posts_per_page' => 1
) );
if ( $users_posts->have_posts() ) {
add_action( 'admin_head', 'delete_users_add_js' ); add_action( 'admin_head', 'delete_users_add_js' );
}
include( ABSPATH . 'wp-admin/admin-header.php' ); include( ABSPATH . 'wp-admin/admin-header.php' );
?> ?>
@ -251,7 +240,11 @@ case 'delete':
} }
?> ?>
</ul> </ul>
<?php if ( $go_delete ) : ?> <?php if ( $go_delete ) :
if ( ! $users_posts->have_posts() ) : ?>
<input type="hidden" name="delete_option" value="delete" />
<?php else: ?>
<?php if ( 1 == $go_delete ) : ?> <?php if ( 1 == $go_delete ) : ?>
<fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
<?php else : ?> <?php else : ?>
@ -264,7 +257,7 @@ case 'delete':
<?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
</ul></fieldset> </ul></fieldset>
<?php <?php endif;
/** /**
* Fires at the end of the delete users form prior to the confirm button. * Fires at the end of the delete users form prior to the confirm button.
* *