3 * Multisite sites administration panel.
6 * @subpackage Multisite
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
13 if ( ! is_multisite() )
14 wp_die( __( 'Multisite support is not enabled.' ) );
16 if ( ! current_user_can( 'manage_sites' ) )
17 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 );
19 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
20 $pagenum = $wp_list_table->get_pagenum();
22 $title = __( 'Sites' );
23 $parent_file = 'sites.php';
25 add_screen_option( 'per_page' );
27 get_current_screen()->add_help_tab( array(
29 'title' => __('Overview'),
31 '<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>' .
32 '<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>' .
33 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' .
34 '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' .
35 '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' .
36 '<li>' . __('Deactivate, Archive, and Spam which lead to confirmation screens. These actions can be reversed later.') . '</li>' .
37 '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' .
38 '<li>' . __('Visit to go to the front-end site live.') . '</li></ul>' .
39 '<p>' . __('The site ID is used internally, and is not shown on the front end of the site or to users/viewers.') . '</p>' .
40 '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>'
43 get_current_screen()->set_help_sidebar(
44 '<p><strong>' . __('For more information:') . '</strong></p>' .
45 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' .
46 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
49 get_current_screen()->set_screen_reader_content( array(
50 'heading_pagination' => __( 'Sites list navigation' ),
51 'heading_list' => __( 'Sites list' ),
54 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
56 if ( isset( $_GET['action'] ) ) {
57 /** This action is documented in wp-admin/network/edit.php */
58 do_action( 'wpmuadminedit' );
60 // A list of valid actions and their associated messaging for confirmation output.
61 $manage_actions = array(
62 'activateblog' => __( 'You are about to activate the site %s.' ),
63 'deactivateblog' => __( 'You are about to deactivate the site %s.' ),
64 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ),
65 'archiveblog' => __( 'You are about to archive the site %s.' ),
66 'unspamblog' => __( 'You are about to unspam the site %s.' ),
67 'spamblog' => __( 'You are about to mark the site %s as spam.' ),
68 'deleteblog' => __( 'You are about to delete the site %s.' ),
69 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ),
70 'matureblog' => __( 'You are about to mark the site %s as not mature.' ),
73 if ( 'confirm' === $_GET['action'] ) {
74 // The action2 parameter contains the action being taken on the site.
75 $site_action = $_GET['action2'];
77 if ( ! array_key_exists( $site_action, $manage_actions ) ) {
78 wp_die( __( 'The requested action is not valid.' ) );
81 // The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility.
82 if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) {
83 check_admin_referer( 'confirm' );
85 check_admin_referer( $site_action . '_' . $id );
88 if ( ! headers_sent() ) {
90 header( 'Content-Type: text/html; charset=utf-8' );
93 if ( $current_site->blog_id == $id ) {
94 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) );
97 $site_details = get_blog_details( $id );
98 $site_address = untrailingslashit( $site_details->domain . $site_details->path );
100 require_once( ABSPATH . 'wp-admin/admin-header.php' );
103 <h1><?php _e( 'Confirm your action' ); ?></h1>
104 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post">
105 <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" />
106 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
107 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
108 <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?>
109 <p><?php echo sprintf( $manage_actions[ $site_action ], $site_address ); ?></p>
110 <?php submit_button( __( 'Confirm' ), 'primary' ); ?>
114 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
116 } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) {
117 $action = $_GET['action'];
118 check_admin_referer( $action . '_' . $id );
119 } elseif ( 'allblogs' === $_GET['action'] ) {
120 check_admin_referer( 'bulk-sites' );
123 $updated_action = '';
125 switch ( $_GET['action'] ) {
128 if ( ! current_user_can( 'delete_sites' ) )
129 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) );
131 $updated_action = 'not_deleted';
132 if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
133 wpmu_delete_blog( $id, true );
134 $updated_action = 'delete';
139 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
140 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
142 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
143 if ( $val != '0' && $val != $current_site->blog_id ) {
144 switch ( $doaction ) {
146 if ( ! current_user_can( 'delete_site', $val ) )
147 wp_die( __( 'Sorry, you are not allowed to delete the site.' ) );
149 $updated_action = 'all_delete';
150 wpmu_delete_blog( $val, true );
155 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
156 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
160 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) );
164 $location = network_admin_url( 'sites.php' );
165 if ( ! empty( $_REQUEST['paged'] ) ) {
166 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
168 wp_redirect( $location );
174 case 'unarchiveblog':
175 update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
179 update_blog_status( $id, 'deleted', '0' );
182 * Fires after a network site is activated.
186 * @param string $id The ID of the activated site.
188 do_action( 'activate_blog', $id );
191 case 'deactivateblog':
193 * Fires before a network site is deactivated.
197 * @param string $id The ID of the site being deactivated.
199 do_action( 'deactivate_blog', $id );
200 update_blog_status( $id, 'deleted', '1' );
205 update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
210 update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
214 if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) {
215 $updated_action = $_GET['action'];
218 if ( ! empty( $updated_action ) ) {
219 wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
225 if ( isset( $_GET['updated'] ) ) {
226 switch ( $_GET['updated'] ) {
228 $msg = __( 'Sites removed from spam.' );
231 $msg = __( 'Sites marked as spam.' );
234 $msg = __( 'Sites deleted.' );
237 $msg = __( 'Site deleted.' );
240 $msg = __( 'Sorry, you are not allowed to delete that site.' );
243 $msg = __( 'Site archived.' );
245 case 'unarchiveblog':
246 $msg = __( 'Site unarchived.' );
249 $msg = __( 'Site activated.' );
251 case 'deactivateblog':
252 $msg = __( 'Site deactivated.' );
255 $msg = __( 'Site removed from spam.' );
258 $msg = __( 'Site marked as spam.' );
262 * Filters a specific, non-default site-updated message in the Network admin.
264 * The dynamic portion of the hook name, `$_GET['updated']`, refers to the
265 * non-default site update action.
269 * @param string $msg The update message. Default 'Settings saved'.
271 $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
275 if ( ! empty( $msg ) )
276 $msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>';
279 $wp_list_table->prepare_items();
281 require_once( ABSPATH . 'wp-admin/admin-header.php' );
285 <h1><?php _e( 'Sites' ); ?>
287 <?php if ( current_user_can( 'create_sites') ) : ?>
288 <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
292 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) {
293 /* translators: %s: search keywords */
294 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) );
300 <form method="get" id="ms-search">
301 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
302 <input type="hidden" name="action" value="blogs" />
305 <form id="form-site-list" action="sites.php?action=allblogs" method="post">
306 <?php $wp_list_table->display(); ?>
311 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>