Make WordPress Core

Ticket #6405: 6405.3.diff

File 6405.3.diff, 3.9 KB (added by wonderboymusic, 8 years ago)
  • src/wp-admin/includes/user.php

     
    446446        printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
    447447        echo '</p></div>';
    448448}
     449
     450/**
     451 * @since 3.5.0
     452 * @access private
     453 */
     454function delete_users_add_js() { ?>
     455<script>
     456jQuery(document).ready( function($) {
     457        var submit = $('#submit').prop('disabled', true);
     458        $('input[name="delete_option"]').one('change', function() {
     459                submit.prop('disabled', false);
     460        });
     461        $('#reassign_user').focus( function() {
     462                $('#delete_option1').prop('checked', true).trigger('change');
     463        });
     464});
     465</script>
     466<?php
     467}
     468 No newline at end of file
  • src/wp-admin/users.php

     
    8080
    8181$update = '';
    8282
    83 /**
    84  * @since 3.5.0
    85  * @access private
    86  */
    87 function delete_users_add_js() { ?>
    88 <script>
    89 jQuery(document).ready( function($) {
    90         var submit = $('#submit').prop('disabled', true);
    91         $('input[name=delete_option]').one('change', function() {
    92                 submit.prop('disabled', false);
    93         });
    94         $('#reassign_user').focus( function() {
    95                 $('#delete_option1').prop('checked', true).trigger('change');
    96         });
    97 });
    98 </script>
    99 <?php
    100 }
    101 
    10283switch ( $wp_list_table->current_action() ) {
    10384
    10485/* Bulk Dropdown menu Role changes */
     
    215196        else
    216197                $userids = array_map( 'intval', (array) $_REQUEST['users'] );
    217198
    218         add_action( 'admin_head', 'delete_users_add_js' );
     199        $users_posts = new WP_Query( array(
     200                'post_type' => 'any',
     201                'author' => implode( ',', $userids ),
     202                'posts_per_page' => 1
     203        ) );
    219204
     205        if ( $users_posts->have_posts() ) {
     206                add_action( 'admin_head', 'delete_users_add_js' );
     207        }
     208
    220209        include( ABSPATH . 'wp-admin/admin-header.php' );
    221210?>
    222211<form method="post" name="updateusers" id="updateusers">
     
    251240        }
    252241        ?>
    253242        </ul>
    254 <?php if ( $go_delete ) : ?>
    255         <?php if ( 1 == $go_delete ) : ?>
    256                 <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
    257         <?php else : ?>
    258                 <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
    259         <?php endif; ?>
    260         <ul style="list-style:none;">
    261                 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
    262                 <?php _e('Delete all content.'); ?></label></li>
    263                 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
    264                 <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
    265                 wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
    266         </ul></fieldset>
    267         <?php
     243<?php if ( $go_delete ) :
     244
     245        if ( ! $users_posts->have_posts() ) : ?>
     246                <input type="hidden" name="delete_option" value="delete" />
     247        <?php else: ?>
     248                <?php if ( 1 == $go_delete ) : ?>
     249                        <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p>
     250                <?php else : ?>
     251                        <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p>
     252                <?php endif; ?>
     253                <ul style="list-style:none;">
     254                        <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" />
     255                        <?php _e('Delete all content.'); ?></label></li>
     256                        <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
     257                        <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> ';
     258                        wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
     259                </ul></fieldset>
     260        <?php endif;
    268261        /**
    269262         * Fires at the end of the delete users form prior to the confirm button.
    270263         *