@@ -199,15 +199,15 @@ |
||
199 | 199 | $cur->response = ''; |
200 | 200 | |
201 | 201 | switch ( $cur->response ) { |
202 | - case 'development' : |
|
203 | - return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
202 | + case 'development' : |
|
203 | + return sprintf( __( 'You are using a development version (%1$s). Cool! Please <a href="%2$s">stay updated</a>.' ), get_bloginfo( 'version', 'display' ), network_admin_url( 'update-core.php' ) ); |
|
204 | 204 | |
205 | - case 'upgrade' : |
|
206 | - return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
205 | + case 'upgrade' : |
|
206 | + return '<strong><a href="' . network_admin_url( 'update-core.php' ) . '">' . sprintf( __( 'Get Version %s' ), $cur->current ) . '</a></strong>'; |
|
207 | 207 | |
208 | - case 'latest' : |
|
209 | - default : |
|
210 | - return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
208 | + case 'latest' : |
|
209 | + default : |
|
210 | + return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) ); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 |
@@ -90,101 +90,101 @@ discard block |
||
90 | 90 | switch ( $wp_list_table->current_action() ) { |
91 | 91 | |
92 | 92 | /* Bulk Dropdown menu Role changes */ |
93 | -case 'promote': |
|
94 | - check_admin_referer('bulk-users'); |
|
93 | + case 'promote': |
|
94 | + check_admin_referer('bulk-users'); |
|
95 | 95 | |
96 | - if ( ! current_user_can( 'promote_users' ) ) |
|
97 | - wp_die( __( 'You can’t edit that user.' ) ); |
|
96 | + if ( ! current_user_can( 'promote_users' ) ) |
|
97 | + wp_die( __( 'You can’t edit that user.' ) ); |
|
98 | 98 | |
99 | - if ( empty($_REQUEST['users']) ) { |
|
100 | - wp_redirect($redirect); |
|
101 | - exit(); |
|
102 | - } |
|
103 | - |
|
104 | - $editable_roles = get_editable_roles(); |
|
105 | - $role = false; |
|
106 | - if ( ! empty( $_REQUEST['new_role2'] ) ) { |
|
107 | - $role = $_REQUEST['new_role2']; |
|
108 | - } elseif ( ! empty( $_REQUEST['new_role'] ) ) { |
|
109 | - $role = $_REQUEST['new_role']; |
|
110 | - } |
|
111 | - |
|
112 | - if ( ! $role || empty( $editable_roles[ $role ] ) ) { |
|
113 | - wp_die( __( 'You can’t give users that role.' ) ); |
|
114 | - } |
|
115 | - |
|
116 | - $userids = $_REQUEST['users']; |
|
117 | - $update = 'promote'; |
|
118 | - foreach ( $userids as $id ) { |
|
119 | - $id = (int) $id; |
|
120 | - |
|
121 | - if ( ! current_user_can('promote_user', $id) ) |
|
122 | - wp_die(__('You can’t edit that user.')); |
|
123 | - // The new role of the current user must also have the promote_users cap or be a multisite super admin |
|
124 | - if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users') |
|
125 | - && ! ( is_multisite() && is_super_admin() ) ) { |
|
126 | - $update = 'err_admin_role'; |
|
127 | - continue; |
|
99 | + if ( empty($_REQUEST['users']) ) { |
|
100 | + wp_redirect($redirect); |
|
101 | + exit(); |
|
128 | 102 | } |
129 | 103 | |
130 | - // If the user doesn't already belong to the blog, bail. |
|
131 | - if ( is_multisite() && !is_user_member_of_blog( $id ) ) { |
|
132 | - wp_die( |
|
133 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
134 | - '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', |
|
135 | - 403 |
|
136 | - ); |
|
104 | + $editable_roles = get_editable_roles(); |
|
105 | + $role = false; |
|
106 | + if ( ! empty( $_REQUEST['new_role2'] ) ) { |
|
107 | + $role = $_REQUEST['new_role2']; |
|
108 | + } elseif ( ! empty( $_REQUEST['new_role'] ) ) { |
|
109 | + $role = $_REQUEST['new_role']; |
|
137 | 110 | } |
138 | 111 | |
139 | - $user = get_userdata( $id ); |
|
140 | - $user->set_role( $role ); |
|
141 | - } |
|
112 | + if ( ! $role || empty( $editable_roles[ $role ] ) ) { |
|
113 | + wp_die( __( 'You can’t give users that role.' ) ); |
|
114 | + } |
|
142 | 115 | |
143 | - wp_redirect(add_query_arg('update', $update, $redirect)); |
|
144 | - exit(); |
|
116 | + $userids = $_REQUEST['users']; |
|
117 | + $update = 'promote'; |
|
118 | + foreach ( $userids as $id ) { |
|
119 | + $id = (int) $id; |
|
120 | + |
|
121 | + if ( ! current_user_can('promote_user', $id) ) |
|
122 | + wp_die(__('You can’t edit that user.')); |
|
123 | + // The new role of the current user must also have the promote_users cap or be a multisite super admin |
|
124 | + if ( $id == $current_user->ID && ! $wp_roles->role_objects[ $role ]->has_cap('promote_users') |
|
125 | + && ! ( is_multisite() && is_super_admin() ) ) { |
|
126 | + $update = 'err_admin_role'; |
|
127 | + continue; |
|
128 | + } |
|
145 | 129 | |
146 | -case 'dodelete': |
|
147 | - if ( is_multisite() ) |
|
148 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
130 | + // If the user doesn't already belong to the blog, bail. |
|
131 | + if ( is_multisite() && !is_user_member_of_blog( $id ) ) { |
|
132 | + wp_die( |
|
133 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
134 | + '<p>' . __( 'One of the selected users is not a member of this site.' ) . '</p>', |
|
135 | + 403 |
|
136 | + ); |
|
137 | + } |
|
149 | 138 | |
150 | - check_admin_referer('delete-users'); |
|
139 | + $user = get_userdata( $id ); |
|
140 | + $user->set_role( $role ); |
|
141 | + } |
|
151 | 142 | |
152 | - if ( empty($_REQUEST['users']) ) { |
|
153 | - wp_redirect($redirect); |
|
143 | + wp_redirect(add_query_arg('update', $update, $redirect)); |
|
154 | 144 | exit(); |
155 | - } |
|
156 | 145 | |
157 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
146 | + case 'dodelete': |
|
147 | + if ( is_multisite() ) |
|
148 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
158 | 149 | |
159 | - if ( empty( $_REQUEST['delete_option'] ) ) { |
|
160 | - $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
161 | - $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
162 | - wp_redirect( $url ); |
|
163 | - exit; |
|
164 | - } |
|
165 | - |
|
166 | - if ( ! current_user_can( 'delete_users' ) ) |
|
167 | - wp_die(__('You can’t delete users.')); |
|
150 | + check_admin_referer('delete-users'); |
|
168 | 151 | |
169 | - $update = 'del'; |
|
170 | - $delete_count = 0; |
|
152 | + if ( empty($_REQUEST['users']) ) { |
|
153 | + wp_redirect($redirect); |
|
154 | + exit(); |
|
155 | + } |
|
171 | 156 | |
172 | - foreach ( $userids as $id ) { |
|
173 | - if ( ! current_user_can( 'delete_user', $id ) ) |
|
174 | - wp_die(__( 'You can’t delete that user.' ) ); |
|
157 | + $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
175 | 158 | |
176 | - if ( $id == $current_user->ID ) { |
|
177 | - $update = 'err_admin_del'; |
|
178 | - continue; |
|
179 | - } |
|
180 | - switch ( $_REQUEST['delete_option'] ) { |
|
181 | - case 'delete': |
|
182 | - wp_delete_user( $id ); |
|
183 | - break; |
|
184 | - case 'reassign': |
|
185 | - wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
186 | - break; |
|
159 | + if ( empty( $_REQUEST['delete_option'] ) ) { |
|
160 | + $url = self_admin_url( 'users.php?action=delete&users[]=' . implode( '&users[]=', $userids ) . '&error=true' ); |
|
161 | + $url = str_replace( '&', '&', wp_nonce_url( $url, 'bulk-users' ) ); |
|
162 | + wp_redirect( $url ); |
|
163 | + exit; |
|
187 | 164 | } |
165 | + |
|
166 | + if ( ! current_user_can( 'delete_users' ) ) |
|
167 | + wp_die(__('You can’t delete users.')); |
|
168 | + |
|
169 | + $update = 'del'; |
|
170 | + $delete_count = 0; |
|
171 | + |
|
172 | + foreach ( $userids as $id ) { |
|
173 | + if ( ! current_user_can( 'delete_user', $id ) ) |
|
174 | + wp_die(__( 'You can’t delete that user.' ) ); |
|
175 | + |
|
176 | + if ( $id == $current_user->ID ) { |
|
177 | + $update = 'err_admin_del'; |
|
178 | + continue; |
|
179 | + } |
|
180 | + switch ( $_REQUEST['delete_option'] ) { |
|
181 | + case 'delete': |
|
182 | + wp_delete_user( $id ); |
|
183 | + break; |
|
184 | + case 'reassign': |
|
185 | + wp_delete_user( $id, $_REQUEST['reassign_user'] ); |
|
186 | + break; |
|
187 | + } |
|
188 | 188 | ++$delete_count; |
189 | 189 | } |
190 | 190 | |
@@ -192,95 +192,95 @@ discard block |
||
192 | 192 | wp_redirect($redirect); |
193 | 193 | exit(); |
194 | 194 | |
195 | -case 'delete': |
|
196 | - if ( is_multisite() ) |
|
197 | - wp_die( __('User deletion is not allowed from this screen.') ); |
|
195 | + case 'delete': |
|
196 | + if ( is_multisite() ) |
|
197 | + wp_die( __('User deletion is not allowed from this screen.') ); |
|
198 | 198 | |
199 | - check_admin_referer('bulk-users'); |
|
199 | + check_admin_referer('bulk-users'); |
|
200 | 200 | |
201 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
202 | - wp_redirect($redirect); |
|
203 | - exit(); |
|
204 | - } |
|
201 | + if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
202 | + wp_redirect($redirect); |
|
203 | + exit(); |
|
204 | + } |
|
205 | 205 | |
206 | - if ( ! current_user_can( 'delete_users' ) ) |
|
207 | - $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
206 | + if ( ! current_user_can( 'delete_users' ) ) |
|
207 | + $errors = new WP_Error( 'edit_users', __( 'You can’t delete users.' ) ); |
|
208 | 208 | |
209 | - if ( empty($_REQUEST['users']) ) |
|
210 | - $userids = array( intval( $_REQUEST['user'] ) ); |
|
211 | - else |
|
212 | - $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
209 | + if ( empty($_REQUEST['users']) ) |
|
210 | + $userids = array( intval( $_REQUEST['user'] ) ); |
|
211 | + else |
|
212 | + $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
|
213 | 213 | |
214 | - $users_have_content = false; |
|
215 | - if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { |
|
216 | - $users_have_content = true; |
|
217 | - } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { |
|
218 | - $users_have_content = true; |
|
219 | - } |
|
214 | + $users_have_content = false; |
|
215 | + if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { |
|
216 | + $users_have_content = true; |
|
217 | + } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . " ) LIMIT 1" ) ) { |
|
218 | + $users_have_content = true; |
|
219 | + } |
|
220 | 220 | |
221 | - if ( $users_have_content ) { |
|
222 | - add_action( 'admin_head', 'delete_users_add_js' ); |
|
223 | - } |
|
221 | + if ( $users_have_content ) { |
|
222 | + add_action( 'admin_head', 'delete_users_add_js' ); |
|
223 | + } |
|
224 | 224 | |
225 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
226 | -?> |
|
227 | -<form method="post" name="updateusers" id="updateusers"> |
|
228 | -<?php wp_nonce_field('delete-users') ?> |
|
229 | -<?php echo $referer; ?> |
|
225 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
226 | + ?> |
|
227 | + <form method="post" name="updateusers" id="updateusers"> |
|
228 | + <?php wp_nonce_field('delete-users') ?> |
|
229 | + <?php echo $referer; ?> |
|
230 | 230 | |
231 | 231 | <div class="wrap"> |
232 | 232 | <h1><?php _e( 'Delete Users' ); ?></h1> |
233 | -<?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
233 | + <?php if ( isset( $_REQUEST['error'] ) ) : ?> |
|
234 | 234 | <div class="error"> |
235 | 235 | <p><strong><?php _e( 'ERROR:' ); ?></strong> <?php _e( 'Please select an option.' ); ?></p> |
236 | 236 | </div> |
237 | 237 | <?php endif; ?> |
238 | - |
|
239 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
240 | - <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
241 | -<?php else : ?> |
|
242 | - <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
243 | -<?php endif; ?> |
|
238 | + |
|
239 | + <?php if ( 1 == count( $userids ) ) : ?> |
|
240 | + <p><?php _e( 'You have specified this user for deletion:' ); ?></p> |
|
241 | + <?php else : ?> |
|
242 | + <p><?php _e( 'You have specified these users for deletion:' ); ?></p> |
|
243 | + <?php endif; ?> |
|
244 | 244 | |
245 | 245 | <ul> |
246 | 246 | <?php |
247 | - $go_delete = 0; |
|
248 | - foreach ( $userids as $id ) { |
|
249 | - $user = get_userdata( $id ); |
|
250 | - if ( $id == $current_user->ID ) { |
|
251 | - /* translators: 1: user id, 2: user login */ |
|
252 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
253 | - } else { |
|
254 | - /* translators: 1: user id, 2: user login */ |
|
255 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
256 | - $go_delete++; |
|
247 | + $go_delete = 0; |
|
248 | + foreach ( $userids as $id ) { |
|
249 | + $user = get_userdata( $id ); |
|
250 | + if ( $id == $current_user->ID ) { |
|
251 | + /* translators: 1: user id, 2: user login */ |
|
252 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
253 | + } else { |
|
254 | + /* translators: 1: user id, 2: user login */ |
|
255 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"" . esc_attr($id) . "\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
256 | + $go_delete++; |
|
257 | + } |
|
257 | 258 | } |
258 | - } |
|
259 | - ?> |
|
260 | - </ul> |
|
261 | -<?php if ( $go_delete ) : |
|
259 | + ?> |
|
260 | + </ul> |
|
261 | + <?php if ( $go_delete ) : |
|
262 | 262 | |
263 | - if ( ! $users_have_content ) : ?> |
|
264 | - <input type="hidden" name="delete_option" value="delete" /> |
|
263 | + if ( ! $users_have_content ) : ?> |
|
264 | + <input type="hidden" name="delete_option" value="delete" /> |
|
265 | 265 | <?php else: ?> |
266 | - <?php if ( 1 == $go_delete ) : ?> |
|
267 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
266 | + <?php if ( 1 == $go_delete ) : ?> |
|
267 | + <fieldset><p><legend><?php _e( 'What should be done with content owned by this user?' ); ?></legend></p> |
|
268 | 268 | <?php else : ?> |
269 | - <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
269 | + <fieldset><p><legend><?php _e( 'What should be done with content owned by these users?' ); ?></legend></p> |
|
270 | 270 | <?php endif; ?> |
271 | 271 | <ul style="list-style:none;"> |
272 | 272 | <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" /> |
273 | 273 | <?php _e('Delete all content.'); ?></label></li> |
274 | 274 | <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" /> |
275 | 275 | <?php echo '<label for="delete_option1">' . __( 'Attribute all content to:' ) . '</label> '; |
276 | - wp_dropdown_users( array( |
|
277 | - 'name' => 'reassign_user', |
|
278 | - 'exclude' => array_diff( $userids, array( $current_user->ID ) ), |
|
279 | - 'show' => 'display_name_with_login', |
|
280 | - ) ); ?></li> |
|
276 | + wp_dropdown_users( array( |
|
277 | + 'name' => 'reassign_user', |
|
278 | + 'exclude' => array_diff( $userids, array( $current_user->ID ) ), |
|
279 | + 'show' => 'display_name_with_login', |
|
280 | + ) ); ?></li> |
|
281 | 281 | </ul></fieldset> |
282 | 282 | <?php endif; |
283 | - /** |
|
283 | + /** |
|
284 | 284 | * Fires at the end of the delete users form prior to the confirm button. |
285 | 285 | * |
286 | 286 | * @since 4.0.0 |
@@ -289,178 +289,178 @@ discard block |
||
289 | 289 | * @param WP_User $current_user WP_User object for the current user. |
290 | 290 | * @param array $userids Array of IDs for users being deleted. |
291 | 291 | */ |
292 | - do_action( 'delete_user_form', $current_user, $userids ); |
|
293 | - ?> |
|
294 | - <input type="hidden" name="action" value="dodelete" /> |
|
292 | + do_action( 'delete_user_form', $current_user, $userids ); |
|
293 | + ?> |
|
294 | + <input type="hidden" name="action" value="dodelete" /> |
|
295 | 295 | <?php submit_button( __('Confirm Deletion'), 'primary' ); ?> |
296 | -<?php else : ?> |
|
297 | - <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
298 | -<?php endif; ?> |
|
296 | + <?php else : ?> |
|
297 | + <p><?php _e('There are no valid users selected for deletion.'); ?></p> |
|
298 | + <?php endif; ?> |
|
299 | 299 | </div> |
300 | 300 | </form> |
301 | 301 | <?php |
302 | 302 | |
303 | -break; |
|
303 | + break; |
|
304 | 304 | |
305 | -case 'doremove': |
|
306 | - check_admin_referer('remove-users'); |
|
305 | + case 'doremove': |
|
306 | + check_admin_referer('remove-users'); |
|
307 | 307 | |
308 | - if ( ! is_multisite() ) |
|
309 | - wp_die( __( 'You can’t remove users.' ) ); |
|
308 | + if ( ! is_multisite() ) |
|
309 | + wp_die( __( 'You can’t remove users.' ) ); |
|
310 | 310 | |
311 | - if ( empty($_REQUEST['users']) ) { |
|
312 | - wp_redirect($redirect); |
|
313 | - exit; |
|
314 | - } |
|
311 | + if ( empty($_REQUEST['users']) ) { |
|
312 | + wp_redirect($redirect); |
|
313 | + exit; |
|
314 | + } |
|
315 | 315 | |
316 | - if ( ! current_user_can( 'remove_users' ) ) |
|
317 | - wp_die( __( 'You can’t remove users.' ) ); |
|
316 | + if ( ! current_user_can( 'remove_users' ) ) |
|
317 | + wp_die( __( 'You can’t remove users.' ) ); |
|
318 | 318 | |
319 | - $userids = $_REQUEST['users']; |
|
319 | + $userids = $_REQUEST['users']; |
|
320 | 320 | |
321 | - $update = 'remove'; |
|
322 | - foreach ( $userids as $id ) { |
|
323 | - $id = (int) $id; |
|
324 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
325 | - $update = 'err_admin_remove'; |
|
326 | - continue; |
|
327 | - } |
|
328 | - if ( !current_user_can('remove_user', $id) ) { |
|
329 | - $update = 'err_admin_remove'; |
|
330 | - continue; |
|
321 | + $update = 'remove'; |
|
322 | + foreach ( $userids as $id ) { |
|
323 | + $id = (int) $id; |
|
324 | + if ( $id == $current_user->ID && !is_super_admin() ) { |
|
325 | + $update = 'err_admin_remove'; |
|
326 | + continue; |
|
327 | + } |
|
328 | + if ( !current_user_can('remove_user', $id) ) { |
|
329 | + $update = 'err_admin_remove'; |
|
330 | + continue; |
|
331 | + } |
|
332 | + remove_user_from_blog($id, $blog_id); |
|
331 | 333 | } |
332 | - remove_user_from_blog($id, $blog_id); |
|
333 | - } |
|
334 | 334 | |
335 | - $redirect = add_query_arg( array('update' => $update), $redirect); |
|
336 | - wp_redirect($redirect); |
|
337 | - exit; |
|
335 | + $redirect = add_query_arg( array('update' => $update), $redirect); |
|
336 | + wp_redirect($redirect); |
|
337 | + exit; |
|
338 | 338 | |
339 | -case 'remove': |
|
339 | + case 'remove': |
|
340 | 340 | |
341 | - check_admin_referer('bulk-users'); |
|
341 | + check_admin_referer('bulk-users'); |
|
342 | 342 | |
343 | - if ( ! is_multisite() ) |
|
344 | - wp_die( __( 'You can’t remove users.' ) ); |
|
343 | + if ( ! is_multisite() ) |
|
344 | + wp_die( __( 'You can’t remove users.' ) ); |
|
345 | 345 | |
346 | - if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
347 | - wp_redirect($redirect); |
|
348 | - exit(); |
|
349 | - } |
|
346 | + if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) { |
|
347 | + wp_redirect($redirect); |
|
348 | + exit(); |
|
349 | + } |
|
350 | 350 | |
351 | - if ( !current_user_can('remove_users') ) |
|
352 | - $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
351 | + if ( !current_user_can('remove_users') ) |
|
352 | + $error = new WP_Error('edit_users', __('You can’t remove users.')); |
|
353 | 353 | |
354 | - if ( empty($_REQUEST['users']) ) |
|
355 | - $userids = array(intval($_REQUEST['user'])); |
|
356 | - else |
|
357 | - $userids = $_REQUEST['users']; |
|
354 | + if ( empty($_REQUEST['users']) ) |
|
355 | + $userids = array(intval($_REQUEST['user'])); |
|
356 | + else |
|
357 | + $userids = $_REQUEST['users']; |
|
358 | 358 | |
359 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
360 | -?> |
|
361 | -<form method="post" name="updateusers" id="updateusers"> |
|
362 | -<?php wp_nonce_field('remove-users') ?> |
|
363 | -<?php echo $referer; ?> |
|
359 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
360 | + ?> |
|
361 | + <form method="post" name="updateusers" id="updateusers"> |
|
362 | + <?php wp_nonce_field('remove-users') ?> |
|
363 | + <?php echo $referer; ?> |
|
364 | 364 | |
365 | 365 | <div class="wrap"> |
366 | 366 | <h1><?php _e( 'Remove Users from Site' ); ?></h1> |
367 | 367 | |
368 | -<?php if ( 1 == count( $userids ) ) : ?> |
|
369 | - <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
370 | -<?php else : ?> |
|
371 | - <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
372 | -<?php endif; ?> |
|
368 | + <?php if ( 1 == count( $userids ) ) : ?> |
|
369 | + <p><?php _e( 'You have specified this user for removal:' ); ?></p> |
|
370 | + <?php else : ?> |
|
371 | + <p><?php _e( 'You have specified these users for removal:' ); ?></p> |
|
372 | + <?php endif; ?> |
|
373 | 373 | |
374 | 374 | <ul> |
375 | 375 | <?php |
376 | - $go_remove = false; |
|
377 | - foreach ( $userids as $id ) { |
|
378 | - $id = (int) $id; |
|
379 | - $user = get_userdata( $id ); |
|
380 | - if ( $id == $current_user->ID && !is_super_admin() ) { |
|
381 | - /* translators: 1: user id, 2: user login */ |
|
382 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
383 | - } elseif ( !current_user_can('remove_user', $id) ) { |
|
384 | - /* translators: 1: user id, 2: user login */ |
|
385 | - echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don’t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
386 | - } else { |
|
387 | - /* translators: 1: user id, 2: user login */ |
|
388 | - echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
389 | - $go_remove = true; |
|
390 | - } |
|
391 | - } |
|
392 | - ?> |
|
393 | -</ul> |
|
394 | -<?php if ( $go_remove ) : ?> |
|
395 | - <input type="hidden" name="action" value="doremove" /> |
|
376 | + $go_remove = false; |
|
377 | + foreach ( $userids as $id ) { |
|
378 | + $id = (int) $id; |
|
379 | + $user = get_userdata( $id ); |
|
380 | + if ( $id == $current_user->ID && !is_super_admin() ) { |
|
381 | + /* translators: 1: user id, 2: user login */ |
|
382 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>The current user will not be removed.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
383 | + } elseif ( !current_user_can('remove_user', $id) ) { |
|
384 | + /* translators: 1: user id, 2: user login */ |
|
385 | + echo "<li>" . sprintf(__('ID #%1$s: %2$s <strong>You don’t have permission to remove this user.</strong>'), $id, $user->user_login) . "</li>\n"; |
|
386 | + } else { |
|
387 | + /* translators: 1: user id, 2: user login */ |
|
388 | + echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1$s: %2$s'), $id, $user->user_login) . "</li>\n"; |
|
389 | + $go_remove = true; |
|
390 | + } |
|
391 | + } |
|
392 | + ?> |
|
393 | + </ul> |
|
394 | + <?php if ( $go_remove ) : ?> |
|
395 | + <input type="hidden" name="action" value="doremove" /> |
|
396 | 396 | <?php submit_button( __('Confirm Removal'), 'primary' ); ?> |
397 | -<?php else : ?> |
|
398 | - <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
399 | -<?php endif; ?> |
|
397 | + <?php else : ?> |
|
398 | + <p><?php _e('There are no valid users selected for removal.'); ?></p> |
|
399 | + <?php endif; ?> |
|
400 | 400 | </div> |
401 | 401 | </form> |
402 | 402 | <?php |
403 | 403 | |
404 | -break; |
|
404 | + break; |
|
405 | 405 | |
406 | -default: |
|
406 | + default: |
|
407 | 407 | |
408 | - if ( !empty($_GET['_wp_http_referer']) ) { |
|
409 | - wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
410 | - exit; |
|
411 | - } |
|
412 | - |
|
413 | - $wp_list_table->prepare_items(); |
|
414 | - $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
415 | - if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
416 | - wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
417 | - exit; |
|
418 | - } |
|
408 | + if ( !empty($_GET['_wp_http_referer']) ) { |
|
409 | + wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce'), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ); |
|
410 | + exit; |
|
411 | + } |
|
419 | 412 | |
420 | - include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
413 | + $wp_list_table->prepare_items(); |
|
414 | + $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' ); |
|
415 | + if ( $pagenum > $total_pages && $total_pages > 0 ) { |
|
416 | + wp_redirect( add_query_arg( 'paged', $total_pages ) ); |
|
417 | + exit; |
|
418 | + } |
|
421 | 419 | |
422 | - $messages = array(); |
|
423 | - if ( isset($_GET['update']) ) : |
|
424 | - switch($_GET['update']) { |
|
425 | - case 'del': |
|
426 | - case 'del_many': |
|
427 | - $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
|
428 | - if ( 1 == $delete_count ) { |
|
429 | - $message = __( 'User deleted.' ); |
|
430 | - } else { |
|
431 | - $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
420 | + include( ABSPATH . 'wp-admin/admin-header.php' ); |
|
421 | + |
|
422 | + $messages = array(); |
|
423 | + if ( isset($_GET['update']) ) : |
|
424 | + switch($_GET['update']) { |
|
425 | + case 'del': |
|
426 | + case 'del_many': |
|
427 | + $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0; |
|
428 | + if ( 1 == $delete_count ) { |
|
429 | + $message = __( 'User deleted.' ); |
|
430 | + } else { |
|
431 | + $message = _n( '%s user deleted.', '%s users deleted.', $delete_count ); |
|
432 | + } |
|
433 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
434 | + break; |
|
435 | + case 'add': |
|
436 | + if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) { |
|
437 | + /* translators: %s: edit page url */ |
|
438 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ), |
|
439 | + esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
440 | + self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>'; |
|
441 | + } else { |
|
442 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>'; |
|
443 | + } |
|
444 | + break; |
|
445 | + case 'promote': |
|
446 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
447 | + break; |
|
448 | + case 'err_admin_role': |
|
449 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
450 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
451 | + break; |
|
452 | + case 'err_admin_del': |
|
453 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can’t delete the current user.') . '</p></div>'; |
|
454 | + $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
455 | + break; |
|
456 | + case 'remove': |
|
457 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
458 | + break; |
|
459 | + case 'err_admin_remove': |
|
460 | + $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>'; |
|
461 | + $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
462 | + break; |
|
432 | 463 | } |
433 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( $message, number_format_i18n( $delete_count ) ) . '</p></div>'; |
|
434 | - break; |
|
435 | - case 'add': |
|
436 | - if ( isset( $_GET['id'] ) && ( $user_id = $_GET['id'] ) && current_user_can( 'edit_user', $user_id ) ) { |
|
437 | - /* translators: %s: edit page url */ |
|
438 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . sprintf( __( 'New user created. <a href="%s">Edit user</a>' ), |
|
439 | - esc_url( add_query_arg( 'wp_http_referer', urlencode( wp_unslash( $_SERVER['REQUEST_URI'] ) ), |
|
440 | - self_admin_url( 'user-edit.php?user_id=' . $user_id ) ) ) ) . '</p></div>'; |
|
441 | - } else { |
|
442 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __( 'New user created.' ) . '</p></div>'; |
|
443 | - } |
|
444 | - break; |
|
445 | - case 'promote': |
|
446 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Changed roles.') . '</p></div>'; |
|
447 | - break; |
|
448 | - case 'err_admin_role': |
|
449 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('The current user’s role must have user editing capabilities.') . '</p></div>'; |
|
450 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other user roles have been changed.') . '</p></div>'; |
|
451 | - break; |
|
452 | - case 'err_admin_del': |
|
453 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __('You can’t delete the current user.') . '</p></div>'; |
|
454 | - $messages[] = '<div id="message" class="updated notice is-dismissible"><p>' . __('Other users have been deleted.') . '</p></div>'; |
|
455 | - break; |
|
456 | - case 'remove': |
|
457 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('User removed from this site.') . '</p></div>'; |
|
458 | - break; |
|
459 | - case 'err_admin_remove': |
|
460 | - $messages[] = '<div id="message" class="error notice is-dismissible"><p>' . __("You can't remove the current user.") . '</p></div>'; |
|
461 | - $messages[] = '<div id="message" class="updated notice is-dismissible fade"><p>' . __('Other users have been removed.') . '</p></div>'; |
|
462 | - break; |
|
463 | - } |
|
464 | 464 | endif; ?> |
465 | 465 | |
466 | 466 | <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?> |