| | 45 | function confirm_remove_users( $users, $action = 'remove' ) { |
| | 46 | global $referer; |
| | 47 | |
| | 48 | $current_user = wp_get_current_user(); |
| | 49 | if ( !is_array( $users ) ) |
| | 50 | return false; |
| | 51 | ?> |
| | 52 | <div class="wrap"> |
| | 53 | <form action="" method="post" name="updateusers" id="updateusers"> |
| | 54 | <?php |
| | 55 | wp_nonce_field("$action-users"); |
| | 56 | echo $referer; |
| | 57 | screen_icon(); |
| | 58 | |
| | 59 | switch ( $action ) { |
| | 60 | case 'delete': |
| | 61 | echo '<h2>' . __( 'Delete Users' ) . '</h2>'; |
| | 62 | echo '<p>' . __( 'Transfer or delete posts and links before deleting users.' ) . '</p>'; |
| | 63 | break; |
| | 64 | case 'remove': |
| | 65 | echo '<h2>' . __( 'Remove Users from Site' ) . '</h2>'; |
| | 66 | echo '<p>' . __( 'Transfer or delete posts and links before removing users.' ) . '</p>'; |
| | 67 | break; |
| | 68 | } |
| | 69 | |
| | 70 | echo '<ul>'; |
| | 71 | foreach ( (array) $users as $user_id ) { |
| | 72 | $user = new WP_User($user_id); |
| | 73 | $proceed = false; |
| | 74 | |
| | 75 | switch ( $action ) { |
| | 76 | case 'delete': |
| | 77 | if ( $user_id == $current_user->ID ) |
| | 78 | echo '<li>' . sprintf( __('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $user_id, $user->user_login ) . '</li>'; |
| | 79 | elseif ( !current_user_can('delete_user', $user_id) ) |
| | 80 | echo '<li>' . sprintf( __('ID #%1s: %2s <strong>You don\'t have permission to delete this user.</strong>'), $user_id, $user->user_login ) . '</li>'; |
| | 81 | else |
| | 82 | $proceed = true; |
| | 83 | break; |
| | 84 | case 'remove': |
| | 85 | if ( $user_id == $current_user->id && ! is_super_admin() ) |
| | 86 | echo '<li>' . sprintf( __('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $user_id, $user->user_login ) . '</li>'; |
| | 87 | elseif ( !current_user_can('remove_user', $user_id) ) |
| | 88 | echo '<li>' . sprintf( __('ID #%1s: %2s <strong>You don\'t have permission to remove this user.</strong>'), $user_id, $user->user_login ) . '</li>'; |
| | 89 | else |
| | 90 | $proceed = true; |
| | 91 | break; |
| | 92 | } |
| | 93 | |
| | 94 | if ( $proceed ) { |
| | 95 | echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr( $user_id ) . "\" />" . sprintf( __('ID #%1s: %2s'), $user_id, $user->user_login ) . "</li>\n"; |
| | 96 | ?> |
| | 97 | <fieldset><p><legend><?php printf( __( "What should be done with posts and links owned by <em>%s</em>?" ), $user->user_login ); ?></legend></p> |
| | 98 | <ul style="list-style:none;"> |
| | 99 | <li><label><input type="radio" id="delete_option0" name="delete_option[<?php echo $user->ID; ?>]" value="delete" checked="checked" /> |
| | 100 | <?php _e( 'Delete all posts and links.' ); ?></label></li> |
| | 101 | <li><label><input type="radio" id="delete_option1" name="delete_option[<?php echo $user->ID; ?>]" value="reassign" /> |
| | 102 | <?php echo __( 'Attribute all posts and links to:' ) . '</label>'; ?> |
| | 103 | <?php wp_dropdown_users( array( 'exclude' => array_diff( $users, array( $user->ID ) ) ) ); ?></li> |
| | 104 | </ul></fieldset> |
| | 105 | <?php |
| | 106 | } |
| | 107 | } |
| | 108 | echo '</ul>'; |
| | 109 | |
| | 110 | switch ( $action ) { |
| | 111 | case 'delete': |
| | 112 | echo '<input type="hidden" name="action" value="dodelete" />'; |
| | 113 | submit_button( __('Confirm Deletion'), 'secondary' ); |
| | 114 | break; |
| | 115 | case 'remove': |
| | 116 | echo '<input type="hidden" name="action" value="doremove" />'; |
| | 117 | submit_button( __('Confirm Removal'), 'secondary' ); |
| | 118 | break; |
| | 119 | } |
| | 120 | ?> |
| | 121 | </form> |
| | 122 | </div> |
| | 123 | <?php |
| | 124 | } |
| | 125 | |
| 158 | | <div class="wrap"> |
| 159 | | <?php screen_icon(); ?> |
| 160 | | <h2><?php _e('Delete Users'); ?></h2> |
| 161 | | <p><?php _e('You have specified these users for deletion:'); ?></p> |
| 162 | | <ul> |
| 163 | | <?php |
| 164 | | $go_delete = false; |
| 165 | | foreach ( (array) $userids as $id ) { |
| 166 | | $id = (int) $id; |
| 167 | | $user = new WP_User($id); |
| 168 | | if ( $id == $current_user->ID ) { |
| 169 | | echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
| 170 | | } else { |
| 171 | | echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n"; |
| 172 | | $go_delete = true; |
| 173 | | } |
| 174 | | } |
| 175 | | ?> |
| 176 | | </ul> |
| 177 | | <?php if ( $go_delete ) : ?> |
| 178 | | <fieldset><p><legend><?php _e('What should be done with posts and links owned by this user?'); ?></legend></p> |
| 179 | | <ul style="list-style:none;"> |
| 180 | | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" /> |
| 181 | | <?php _e('Delete all posts and links.'); ?></label></li> |
| 182 | | <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
| 183 | | <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:').'</label>'; |
| 184 | | wp_dropdown_users( array( 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li> |
| 185 | | </ul></fieldset> |
| 186 | | <input type="hidden" name="action" value="dodelete" /> |
| 187 | | <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?> |
| 188 | | <?php else : ?> |
| 189 | | <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
| 190 | | <?php endif; ?> |
| 191 | | </div> |
| 192 | | </form> |
| 193 | | <?php |
| 194 | | |
| 253 | | <div class="wrap"> |
| 254 | | <?php screen_icon(); ?> |
| 255 | | <h2><?php _e('Remove Users from Site'); ?></h2> |
| 256 | | <p><?php _e('You have specified these users for removal:'); ?></p> |
| 257 | | <ul> |
| 258 | | <?php |
| 259 | | $go_remove = false; |
| 260 | | foreach ( $userids as $id ) { |
| 261 | | $id = (int) $id; |
| 262 | | $user = new WP_User($id); |
| 263 | | if ( $id == $current_user->id && !is_super_admin() ) { |
| 264 | | echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
| 265 | | } elseif ( !current_user_can('remove_user', $id) ) { |
| 266 | | echo "<li>" . sprintf(__('ID #%1s: %2s <strong>You don\'t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
| 267 | | } else { |
| 268 | | echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n"; |
| 269 | | $go_remove = true; |
| 270 | | } |
| 271 | | } |
| 272 | | ?> |
| 273 | | <?php if ( $go_remove ) : ?> |
| 274 | | <input type="hidden" name="action" value="doremove" /> |
| 275 | | <?php submit_button( __('Confirm Removal'), 'secondary' ); ?> |
| 276 | | <?php else : ?> |
| 277 | | <p><?php _e('There are no valid users selected for removal.'); ?></p> |
| 278 | | <?php endif; ?> |
| 279 | | </div> |
| 280 | | </form> |
| 281 | | <?php |
| 282 | | |