8 */ |
8 */ |
9 |
9 |
10 /** Load WordPress Administration Bootstrap */ |
10 /** Load WordPress Administration Bootstrap */ |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
12 |
12 |
13 if ( ! current_user_can( 'manage_sites' ) ) |
13 if ( ! current_user_can( 'manage_sites' ) ) { |
14 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
14 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
|
15 } |
15 |
16 |
16 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' ); |
17 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' ); |
17 $pagenum = $wp_list_table->get_pagenum(); |
18 $pagenum = $wp_list_table->get_pagenum(); |
18 |
19 |
19 $title = __( 'Sites' ); |
20 $title = __( 'Sites' ); |
20 $parent_file = 'sites.php'; |
21 $parent_file = 'sites.php'; |
21 |
22 |
22 add_screen_option( 'per_page' ); |
23 add_screen_option( 'per_page' ); |
23 |
24 |
24 get_current_screen()->add_help_tab( array( |
25 get_current_screen()->add_help_tab( |
25 'id' => 'overview', |
26 array( |
26 'title' => __('Overview'), |
27 'id' => 'overview', |
27 'content' => |
28 'title' => __( 'Overview' ), |
28 '<p>' . __('Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.') . '</p>' . |
29 'content' => |
29 '<p>' . __('This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.') . '</p>' . |
30 '<p>' . __( 'Add New takes you to the Add New Site screen. You can search for a site by Name, ID number, or IP address. Screen Options allows you to choose how many sites to display on one page.' ) . '</p>' . |
30 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . |
31 '<p>' . __( 'This is the main table of all sites on this network. Switch between list and excerpt views by using the icons above the right side of the table.' ) . '</p>' . |
31 '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' . |
32 '<p>' . __( 'Hovering over each site reveals seven options (three for the primary site):' ) . '</p>' . |
32 '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' . |
33 '<ul><li>' . __( 'An Edit link to a separate Edit Site screen.' ) . '</li>' . |
33 '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' . |
34 '<li>' . __( 'Dashboard leads to the Dashboard for that site.' ) . '</li>' . |
34 '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' . |
35 '<li>' . __( 'Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.' ) . '</li>' . |
35 '<li>' . __('Visit to go to the front-end site live.') . '</li></ul>' . |
36 '<li>' . __( 'Delete which is a permanent action after the confirmation screens.' ) . '</li>' . |
36 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' . |
37 '<li>' . __( 'Visit to go to the front-end site live.' ) . '</li></ul>' . |
37 '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>' |
38 '<p>' . __( 'The site ID is used internally, and is not shown on the front end of the site or to users/viewers.' ) . '</p>' . |
38 ) ); |
39 '<p>' . __( 'Clicking on bold headings can re-sort this table.' ) . '</p>', |
|
40 ) |
|
41 ); |
39 |
42 |
40 get_current_screen()->set_help_sidebar( |
43 get_current_screen()->set_help_sidebar( |
41 '<p><strong>' . __('For more information:') . '</strong></p>' . |
44 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
42 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' . |
45 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>' ) . '</p>' . |
43 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>' |
46 '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>' ) . '</p>' |
44 ); |
47 ); |
45 |
48 |
46 get_current_screen()->set_screen_reader_content( array( |
49 get_current_screen()->set_screen_reader_content( |
47 'heading_pagination' => __( 'Sites list navigation' ), |
50 array( |
48 'heading_list' => __( 'Sites list' ), |
51 'heading_pagination' => __( 'Sites list navigation' ), |
49 ) ); |
52 'heading_list' => __( 'Sites list' ), |
|
53 ) |
|
54 ); |
50 |
55 |
51 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
56 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
52 |
57 |
53 if ( isset( $_GET['action'] ) ) { |
58 if ( isset( $_GET['action'] ) ) { |
54 /** This action is documented in wp-admin/network/edit.php */ |
59 /** This action is documented in wp-admin/network/edit.php */ |
120 $updated_action = ''; |
125 $updated_action = ''; |
121 |
126 |
122 switch ( $_GET['action'] ) { |
127 switch ( $_GET['action'] ) { |
123 |
128 |
124 case 'deleteblog': |
129 case 'deleteblog': |
125 if ( ! current_user_can( 'delete_sites' ) ) |
130 if ( ! current_user_can( 'delete_sites' ) ) { |
126 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); |
131 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); |
|
132 } |
127 |
133 |
128 $updated_action = 'not_deleted'; |
134 $updated_action = 'not_deleted'; |
129 if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) { |
135 if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) { |
130 wpmu_delete_blog( $id, true ); |
136 wpmu_delete_blog( $id, true ); |
131 $updated_action = 'delete'; |
137 $updated_action = 'delete'; |
132 } |
138 } |
133 break; |
139 break; |
134 |
140 |
135 case 'delete_sites': |
141 case 'delete_sites': |
136 check_admin_referer( 'ms-delete-sites' ); |
142 check_admin_referer( 'ms-delete-sites' ); |
137 |
143 |
138 foreach ( (array) $_POST['site_ids'] as $site_id ) { |
144 foreach ( (array) $_POST['site_ids'] as $site_id ) { |
170 <input type="hidden" name="action" value="delete_sites" /> |
176 <input type="hidden" name="action" value="delete_sites" /> |
171 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
177 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
172 <?php wp_nonce_field( 'ms-delete-sites', '_wpnonce', false ); ?> |
178 <?php wp_nonce_field( 'ms-delete-sites', '_wpnonce', false ); ?> |
173 <p><?php _e( 'You are about to delete the following sites:' ); ?></p> |
179 <p><?php _e( 'You are about to delete the following sites:' ); ?></p> |
174 <ul class="ul-disc"> |
180 <ul class="ul-disc"> |
175 <?php foreach ( $_POST['allblogs'] as $site_id ) : |
181 <?php |
176 $site = get_site( $site_id ); |
182 foreach ( $_POST['allblogs'] as $site_id ) : |
|
183 $site = get_site( $site_id ); |
177 $site_address = untrailingslashit( $site->domain . $site->path ); |
184 $site_address = untrailingslashit( $site->domain . $site->path ); |
178 ?> |
185 ?> |
179 <li> |
186 <li> |
180 <?php echo $site_address; ?> |
187 <?php echo $site_address; ?> |
181 <input type="hidden" name="site_ids[]" value="<?php echo (int) $site_id; ?>" /> |
188 <input type="hidden" name="site_ids[]" value="<?php echo (int) $site_id; ?>" /> |
192 |
199 |
193 case 'spam': |
200 case 'spam': |
194 case 'notspam': |
201 case 'notspam': |
195 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; |
202 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; |
196 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); |
203 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); |
197 break; |
204 break; |
198 } |
205 } |
199 } else { |
206 } else { |
200 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
207 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
201 } |
208 } |
202 } |
209 } |
203 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { |
210 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { |
204 $redirect_to = wp_get_referer(); |
211 $redirect_to = wp_get_referer(); |
205 $blogs = (array) $_POST['allblogs']; |
212 $blogs = (array) $_POST['allblogs']; |
206 /** This action is documented in wp-admin/network/site-themes.php */ |
213 /** This action is documented in wp-admin/network/site-themes.php */ |
207 $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); |
214 $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); |
208 wp_safe_redirect( $redirect_to ); |
215 wp_safe_redirect( $redirect_to ); |
209 exit(); |
216 exit(); |
210 } |
217 } |
244 * |
251 * |
245 * @param string $id The ID of the site being deactivated. |
252 * @param string $id The ID of the site being deactivated. |
246 */ |
253 */ |
247 do_action( 'deactivate_blog', $id ); |
254 do_action( 'deactivate_blog', $id ); |
248 update_blog_status( $id, 'deleted', '1' ); |
255 update_blog_status( $id, 'deleted', '1' ); |
249 break; |
256 break; |
250 |
257 |
251 case 'unspamblog': |
258 case 'unspamblog': |
252 case 'spamblog': |
259 case 'spamblog': |
253 update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' ); |
260 update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' ); |
254 break; |
261 break; |
255 |
262 |
256 case 'unmatureblog': |
263 case 'unmatureblog': |
257 case 'matureblog': |
264 case 'matureblog': |
258 update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' ); |
265 update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' ); |
259 break; |
266 break; |
260 } |
267 } |
261 |
268 |
262 if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) { |
269 if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) { |
263 $updated_action = $_GET['action']; |
270 $updated_action = $_GET['action']; |
264 } |
271 } |
269 } |
276 } |
270 } |
277 } |
271 |
278 |
272 $msg = ''; |
279 $msg = ''; |
273 if ( isset( $_GET['updated'] ) ) { |
280 if ( isset( $_GET['updated'] ) ) { |
274 switch ( $_GET['updated'] ) { |
281 $action = $_GET['updated']; |
|
282 |
|
283 switch ( $action ) { |
275 case 'all_notspam': |
284 case 'all_notspam': |
276 $msg = __( 'Sites removed from spam.' ); |
285 $msg = __( 'Sites removed from spam.' ); |
277 break; |
286 break; |
278 case 'all_spam': |
287 case 'all_spam': |
279 $msg = __( 'Sites marked as spam.' ); |
288 $msg = __( 'Sites marked as spam.' ); |
280 break; |
289 break; |
281 case 'all_delete': |
290 case 'all_delete': |
282 $msg = __( 'Sites deleted.' ); |
291 $msg = __( 'Sites deleted.' ); |
283 break; |
292 break; |
284 case 'delete': |
293 case 'delete': |
285 $msg = __( 'Site deleted.' ); |
294 $msg = __( 'Site deleted.' ); |
286 break; |
295 break; |
287 case 'not_deleted': |
296 case 'not_deleted': |
288 $msg = __( 'Sorry, you are not allowed to delete that site.' ); |
297 $msg = __( 'Sorry, you are not allowed to delete that site.' ); |
289 break; |
298 break; |
290 case 'archiveblog': |
299 case 'archiveblog': |
291 $msg = __( 'Site archived.' ); |
300 $msg = __( 'Site archived.' ); |
292 break; |
301 break; |
293 case 'unarchiveblog': |
302 case 'unarchiveblog': |
294 $msg = __( 'Site unarchived.' ); |
303 $msg = __( 'Site unarchived.' ); |
295 break; |
304 break; |
296 case 'activateblog': |
305 case 'activateblog': |
297 $msg = __( 'Site activated.' ); |
306 $msg = __( 'Site activated.' ); |
298 break; |
307 break; |
299 case 'deactivateblog': |
308 case 'deactivateblog': |
300 $msg = __( 'Site deactivated.' ); |
309 $msg = __( 'Site deactivated.' ); |
301 break; |
310 break; |
302 case 'unspamblog': |
311 case 'unspamblog': |
303 $msg = __( 'Site removed from spam.' ); |
312 $msg = __( 'Site removed from spam.' ); |
304 break; |
313 break; |
305 case 'spamblog': |
314 case 'spamblog': |
306 $msg = __( 'Site marked as spam.' ); |
315 $msg = __( 'Site marked as spam.' ); |
307 break; |
316 break; |
308 default: |
317 default: |
309 /** |
318 /** |
310 * Filters a specific, non-default site-updated message in the Network admin. |
319 * Filters a specific, non-default, site-updated message in the Network admin. |
311 * |
320 * |
312 * The dynamic portion of the hook name, `$_GET['updated']`, refers to the |
321 * The dynamic portion of the hook name, `$action`, refers to the non-default |
313 * non-default site update action. |
322 * site update action. |
314 * |
323 * |
315 * @since 3.1.0 |
324 * @since 3.1.0 |
316 * |
325 * |
317 * @param string $msg The update message. Default 'Settings saved'. |
326 * @param string $msg The update message. Default 'Settings saved'. |
318 */ |
327 */ |
319 $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) ); |
328 $msg = apply_filters( "network_sites_updated_message_{$action}", __( 'Settings saved.' ) ); |
320 break; |
329 break; |
321 } |
330 } |
322 |
331 |
323 if ( ! empty( $msg ) ) |
332 if ( ! empty( $msg ) ) { |
324 $msg = '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
333 $msg = '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
|
334 } |
325 } |
335 } |
326 |
336 |
327 $wp_list_table->prepare_items(); |
337 $wp_list_table->prepare_items(); |
328 |
338 |
329 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
339 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
330 ?> |
340 ?> |
331 |
341 |
332 <div class="wrap"> |
342 <div class="wrap"> |
333 <h1 class="wp-heading-inline"><?php _e( 'Sites' ); ?></h1> |
343 <h1 class="wp-heading-inline"><?php _e( 'Sites' ); ?></h1> |
334 |
344 |
335 <?php if ( current_user_can( 'create_sites') ) : ?> |
345 <?php if ( current_user_can( 'create_sites' ) ) : ?> |
336 <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
346 <a href="<?php echo network_admin_url( 'site-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
337 <?php endif; ?> |
347 <?php endif; ?> |
338 |
348 |
339 <?php |
349 <?php |
340 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
350 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
341 /* translators: %s: search keywords */ |
351 /* translators: %s: search keywords */ |