|
80 | 80 |
|
81 | 81 | $update = ''; |
82 | 82 |
|
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 | | - |
102 | 83 | switch ( $wp_list_table->current_action() ) { |
103 | 84 |
|
104 | 85 | /* Bulk Dropdown menu Role changes */ |
@@ -215,7 +196,15 @@ function delete_users_add_js() { ?> |
215 | 196 | else |
216 | 197 | $userids = array_map( 'intval', (array) $_REQUEST['users'] ); |
217 | 198 |
|
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 | + ) ); |
| 204 | + |
| 205 | + if ( $users_posts->have_posts() ) { |
| 206 | + add_action( 'admin_head', 'delete_users_add_js' ); |
| 207 | + } |
219 | 208 |
|
220 | 209 | include( ABSPATH . 'wp-admin/admin-header.php' ); |
221 | 210 | ?> |
@@ -251,20 +240,24 @@ function delete_users_add_js() { ?> |
251 | 240 | } |
252 | 241 | ?> |
253 | 242 | </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; |
268 | 261 | /** |
269 | 262 | * Fires at the end of the delete users form prior to the confirm button. |
270 | 263 | * |
|
0 commit comments