6 * @subpackage Multisite |
6 * @subpackage Multisite |
7 * @since 3.0.0 |
7 * @since 3.0.0 |
8 */ |
8 */ |
9 |
9 |
10 /** Load WordPress Administration Bootstrap */ |
10 /** Load WordPress Administration Bootstrap */ |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 require_once __DIR__ . '/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 |
40 ) |
40 ) |
41 ); |
41 ); |
42 |
42 |
43 get_current_screen()->set_help_sidebar( |
43 get_current_screen()->set_help_sidebar( |
44 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
44 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . |
45 '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>' ) . '</p>' . |
45 '<p>' . __( '<a href="https://wordpress.org/support/article/network-admin-sites-screen/">Documentation on Site Management</a>' ) . '</p>' . |
46 '<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>' |
47 ); |
47 ); |
48 |
48 |
49 get_current_screen()->set_screen_reader_content( |
49 get_current_screen()->set_screen_reader_content( |
50 array( |
50 array( |
59 /** This action is documented in wp-admin/network/edit.php */ |
59 /** This action is documented in wp-admin/network/edit.php */ |
60 do_action( 'wpmuadminedit' ); |
60 do_action( 'wpmuadminedit' ); |
61 |
61 |
62 // A list of valid actions and their associated messaging for confirmation output. |
62 // A list of valid actions and their associated messaging for confirmation output. |
63 $manage_actions = array( |
63 $manage_actions = array( |
|
64 /* translators: %s: Site URL. */ |
64 'activateblog' => __( 'You are about to activate the site %s.' ), |
65 'activateblog' => __( 'You are about to activate the site %s.' ), |
|
66 /* translators: %s: Site URL. */ |
65 'deactivateblog' => __( 'You are about to deactivate the site %s.' ), |
67 'deactivateblog' => __( 'You are about to deactivate the site %s.' ), |
|
68 /* translators: %s: Site URL. */ |
66 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ), |
69 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ), |
|
70 /* translators: %s: Site URL. */ |
67 'archiveblog' => __( 'You are about to archive the site %s.' ), |
71 'archiveblog' => __( 'You are about to archive the site %s.' ), |
|
72 /* translators: %s: Site URL. */ |
68 'unspamblog' => __( 'You are about to unspam the site %s.' ), |
73 'unspamblog' => __( 'You are about to unspam the site %s.' ), |
|
74 /* translators: %s: Site URL. */ |
69 'spamblog' => __( 'You are about to mark the site %s as spam.' ), |
75 'spamblog' => __( 'You are about to mark the site %s as spam.' ), |
|
76 /* translators: %s: Site URL. */ |
70 'deleteblog' => __( 'You are about to delete the site %s.' ), |
77 'deleteblog' => __( 'You are about to delete the site %s.' ), |
|
78 /* translators: %s: Site URL. */ |
71 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ), |
79 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ), |
|
80 /* translators: %s: Site URL. */ |
72 'matureblog' => __( 'You are about to mark the site %s as not mature.' ), |
81 'matureblog' => __( 'You are about to mark the site %s as not mature.' ), |
73 ); |
82 ); |
74 |
83 |
75 if ( 'confirm' === $_GET['action'] ) { |
84 if ( 'confirm' === $_GET['action'] ) { |
76 // The action2 parameter contains the action being taken on the site. |
85 // The action2 parameter contains the action being taken on the site. |
97 } |
106 } |
98 |
107 |
99 $site_details = get_site( $id ); |
108 $site_details = get_site( $id ); |
100 $site_address = untrailingslashit( $site_details->domain . $site_details->path ); |
109 $site_address = untrailingslashit( $site_details->domain . $site_details->path ); |
101 |
110 |
102 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
111 require_once ABSPATH . 'wp-admin/admin-header.php'; |
103 ?> |
112 ?> |
104 <div class="wrap"> |
113 <div class="wrap"> |
105 <h1><?php _e( 'Confirm your action' ); ?></h1> |
114 <h1><?php _e( 'Confirm your action' ); ?></h1> |
106 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post"> |
115 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post"> |
107 <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" /> |
116 <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" /> |
108 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
117 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
109 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
118 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
110 <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?> |
119 <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?> |
111 <p><?php echo sprintf( $manage_actions[ $site_action ], $site_address ); ?></p> |
120 <p><?php printf( $manage_actions[ $site_action ], $site_address ); ?></p> |
112 <?php submit_button( __( 'Confirm' ), 'primary' ); ?> |
121 <?php submit_button( __( 'Confirm' ), 'primary' ); ?> |
113 </form> |
122 </form> |
114 </div> |
123 </div> |
115 <?php |
124 <?php |
116 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
125 require_once ABSPATH . 'wp-admin/admin-footer.php'; |
117 exit(); |
126 exit; |
118 } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) { |
127 } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) { |
119 $action = $_GET['action']; |
128 $action = $_GET['action']; |
120 check_admin_referer( $action . '_' . $id ); |
129 check_admin_referer( $action . '_' . $id ); |
121 } elseif ( 'allblogs' === $_GET['action'] ) { |
130 } elseif ( 'allblogs' === $_GET['action'] ) { |
122 check_admin_referer( 'bulk-sites' ); |
131 check_admin_referer( 'bulk-sites' ); |
130 if ( ! current_user_can( 'delete_sites' ) ) { |
139 if ( ! current_user_can( 'delete_sites' ) ) { |
131 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); |
140 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); |
132 } |
141 } |
133 |
142 |
134 $updated_action = 'not_deleted'; |
143 $updated_action = 'not_deleted'; |
135 if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) { |
144 if ( '0' != $id && get_network()->site_id != $id && current_user_can( 'delete_site', $id ) ) { |
136 wpmu_delete_blog( $id, true ); |
145 wpmu_delete_blog( $id, true ); |
137 $updated_action = 'delete'; |
146 $updated_action = 'delete'; |
138 } |
147 } |
139 break; |
148 break; |
140 |
149 |
142 check_admin_referer( 'ms-delete-sites' ); |
151 check_admin_referer( 'ms-delete-sites' ); |
143 |
152 |
144 foreach ( (array) $_POST['site_ids'] as $site_id ) { |
153 foreach ( (array) $_POST['site_ids'] as $site_id ) { |
145 $site_id = (int) $site_id; |
154 $site_id = (int) $site_id; |
146 |
155 |
147 if ( $site_id == get_network()->site_id ) { |
156 if ( get_network()->site_id == $site_id ) { |
148 continue; |
157 continue; |
149 } |
158 } |
150 |
159 |
151 if ( ! current_user_can( 'delete_site', $site_id ) ) { |
160 if ( ! current_user_can( 'delete_site', $site_id ) ) { |
152 $site = get_site( $site_id ); |
161 $site = get_site( $site_id ); |
153 $site_address = untrailingslashit( $site->domain . $site->path ); |
162 $site_address = untrailingslashit( $site->domain . $site->path ); |
154 |
163 |
155 wp_die( sprintf( __( 'Sorry, you are not allowed to delete the site %s.' ), $site_address ), 403 ); |
164 wp_die( |
|
165 sprintf( |
|
166 /* translators: %s: Site URL. */ |
|
167 __( 'Sorry, you are not allowed to delete the site %s.' ), |
|
168 $site_address |
|
169 ), |
|
170 403 |
|
171 ); |
156 } |
172 } |
157 |
173 |
158 $updated_action = 'all_delete'; |
174 $updated_action = 'all_delete'; |
159 wpmu_delete_blog( $site_id, true ); |
175 wpmu_delete_blog( $site_id, true ); |
160 } |
176 } |
161 break; |
177 break; |
162 |
178 |
163 case 'allblogs': |
179 case 'allblogs': |
164 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { |
180 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { |
165 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
181 $doaction = -1 != $_POST['action'] ? $_POST['action'] : $_POST['action2']; |
166 |
182 |
167 foreach ( (array) $_POST['allblogs'] as $key => $val ) { |
183 foreach ( (array) $_POST['allblogs'] as $key => $val ) { |
168 if ( $val != '0' && $val != get_network()->site_id ) { |
184 if ( '0' != $val && get_network()->site_id != $val ) { |
169 switch ( $doaction ) { |
185 switch ( $doaction ) { |
170 case 'delete': |
186 case 'delete': |
171 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
187 require_once ABSPATH . 'wp-admin/admin-header.php'; |
172 ?> |
188 ?> |
173 <div class="wrap"> |
189 <div class="wrap"> |
174 <h1><?php _e( 'Confirm your action' ); ?></h1> |
190 <h1><?php _e( 'Confirm your action' ); ?></h1> |
175 <form action="sites.php?action=delete_sites" method="post"> |
191 <form action="sites.php?action=delete_sites" method="post"> |
176 <input type="hidden" name="action" value="delete_sites" /> |
192 <input type="hidden" name="action" value="delete_sites" /> |
205 } |
221 } |
206 } else { |
222 } else { |
207 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
223 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
208 } |
224 } |
209 } |
225 } |
|
226 |
210 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { |
227 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { |
211 $redirect_to = wp_get_referer(); |
228 $redirect_to = wp_get_referer(); |
212 $blogs = (array) $_POST['allblogs']; |
229 $blogs = (array) $_POST['allblogs']; |
|
230 |
213 /** This action is documented in wp-admin/network/site-themes.php */ |
231 /** This action is documented in wp-admin/network/site-themes.php */ |
214 $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); |
232 $redirect_to = apply_filters( 'handle_network_bulk_actions-' . get_current_screen()->id, $redirect_to, $doaction, $blogs, $id ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores |
|
233 |
215 wp_safe_redirect( $redirect_to ); |
234 wp_safe_redirect( $redirect_to ); |
216 exit(); |
235 exit; |
217 } |
236 } |
218 } else { |
237 } else { |
219 $location = network_admin_url( 'sites.php' ); |
238 // Process query defined by WP_MS_Site_List_Table::extra_table_nav(). |
220 if ( ! empty( $_REQUEST['paged'] ) ) { |
239 $location = remove_query_arg( |
221 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); |
240 array( '_wp_http_referer', '_wpnonce' ), |
222 } |
241 add_query_arg( $_POST, network_admin_url( 'sites.php' ) ) |
|
242 ); |
|
243 |
223 wp_redirect( $location ); |
244 wp_redirect( $location ); |
224 exit(); |
245 exit; |
225 } |
246 } |
|
247 |
226 break; |
248 break; |
227 |
249 |
228 case 'archiveblog': |
250 case 'archiveblog': |
229 case 'unarchiveblog': |
251 case 'unarchiveblog': |
230 update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' ); |
252 update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' ); |
346 <a href="<?php echo network_admin_url( 'site-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
369 <a href="<?php echo network_admin_url( 'site-new.php' ); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> |
347 <?php endif; ?> |
370 <?php endif; ?> |
348 |
371 |
349 <?php |
372 <?php |
350 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
373 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { |
351 /* translators: %s: search keywords */ |
374 /* translators: %s: Search query. */ |
352 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
375 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); |
353 } |
376 } |
354 ?> |
377 ?> |
355 |
378 |
356 <hr class="wp-header-end"> |
379 <hr class="wp-header-end"> |
|
380 |
|
381 <?php $wp_list_table->views(); ?> |
357 |
382 |
358 <?php echo $msg; ?> |
383 <?php echo $msg; ?> |
359 |
384 |
360 <form method="get" id="ms-search" class="wp-clearfix"> |
385 <form method="get" id="ms-search" class="wp-clearfix"> |
361 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?> |
386 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?> |