33 '<p>' . __('Hovering over each site reveals seven options (three for the primary site):') . '</p>' . |
30 '<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>' . |
31 '<ul><li>' . __('An Edit link to a separate Edit Site screen.') . '</li>' . |
35 '<li>' . __('Dashboard leads to the Dashboard for that site.') . '</li>' . |
32 '<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>' . |
33 '<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>' . |
34 '<li>' . __('Delete which is a permanent action after the confirmation screens.') . '</li>' . |
38 '<li>' . __('Visit to go to the frontend site live.') . '</li></ul>' . |
35 '<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>' . |
36 '<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>' |
37 '<p>' . __('Clicking on bold headings can re-sort this table.') . '</p>' |
41 ) ); |
38 ) ); |
42 |
39 |
43 get_current_screen()->set_help_sidebar( |
40 get_current_screen()->set_help_sidebar( |
44 '<p><strong>' . __('For more information:') . '</strong></p>' . |
41 '<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>' . |
42 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen">Documentation on Site Management</a>') . '</p>' . |
46 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
43 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/">Support Forums</a>') . '</p>' |
47 ); |
44 ); |
|
45 |
|
46 get_current_screen()->set_screen_reader_content( array( |
|
47 'heading_pagination' => __( 'Sites list navigation' ), |
|
48 'heading_list' => __( 'Sites list' ), |
|
49 ) ); |
48 |
50 |
49 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
51 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
50 |
52 |
51 if ( isset( $_GET['action'] ) ) { |
53 if ( isset( $_GET['action'] ) ) { |
52 /** This action is documented in wp-admin/network/edit.php */ |
54 /** This action is documented in wp-admin/network/edit.php */ |
53 do_action( 'wpmuadminedit' ); |
55 do_action( 'wpmuadminedit' ); |
54 |
56 |
|
57 // A list of valid actions and their associated messaging for confirmation output. |
|
58 $manage_actions = array( |
|
59 'activateblog' => __( 'You are about to activate the site %s.' ), |
|
60 'deactivateblog' => __( 'You are about to deactivate the site %s.' ), |
|
61 'unarchiveblog' => __( 'You are about to unarchive the site %s.' ), |
|
62 'archiveblog' => __( 'You are about to archive the site %s.' ), |
|
63 'unspamblog' => __( 'You are about to unspam the site %s.' ), |
|
64 'spamblog' => __( 'You are about to mark the site %s as spam.' ), |
|
65 'deleteblog' => __( 'You are about to delete the site %s.' ), |
|
66 'unmatureblog' => __( 'You are about to mark the site %s as mature.' ), |
|
67 'matureblog' => __( 'You are about to mark the site %s as not mature.' ), |
|
68 ); |
|
69 |
55 if ( 'confirm' === $_GET['action'] ) { |
70 if ( 'confirm' === $_GET['action'] ) { |
56 check_admin_referer( 'confirm' ); |
71 // The action2 parameter contains the action being taken on the site. |
|
72 $site_action = $_GET['action2']; |
|
73 |
|
74 if ( ! array_key_exists( $site_action, $manage_actions ) ) { |
|
75 wp_die( __( 'The requested action is not valid.' ) ); |
|
76 } |
|
77 |
|
78 // The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility. |
|
79 if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) { |
|
80 check_admin_referer( 'confirm' ); |
|
81 } else { |
|
82 check_admin_referer( $site_action . '_' . $id ); |
|
83 } |
57 |
84 |
58 if ( ! headers_sent() ) { |
85 if ( ! headers_sent() ) { |
59 nocache_headers(); |
86 nocache_headers(); |
60 header( 'Content-Type: text/html; charset=utf-8' ); |
87 header( 'Content-Type: text/html; charset=utf-8' ); |
61 } |
88 } |
62 |
89 |
63 if ( $current_site->blog_id == $id ) { |
90 if ( get_network()->site_id == $id ) { |
64 wp_die( __( 'You are not allowed to change the current site.' ) ); |
91 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
65 } |
92 } |
|
93 |
|
94 $site_details = get_site( $id ); |
|
95 $site_address = untrailingslashit( $site_details->domain . $site_details->path ); |
66 |
96 |
67 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
97 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
68 ?> |
98 ?> |
69 <div class="wrap"> |
99 <div class="wrap"> |
70 <h2><?php _e( 'Confirm your action' ); ?></h2> |
100 <h1><?php _e( 'Confirm your action' ); ?></h1> |
71 <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post"> |
101 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post"> |
72 <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" /> |
102 <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" /> |
73 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
103 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
74 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
104 <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" /> |
75 <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?> |
105 <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?> |
76 <p><?php echo esc_html( wp_unslash( $_GET['msg'] ) ); ?></p> |
106 <p><?php echo sprintf( $manage_actions[ $site_action ], $site_address ); ?></p> |
77 <?php submit_button( __( 'Confirm' ), 'button' ); ?> |
107 <?php submit_button( __( 'Confirm' ), 'primary' ); ?> |
78 </form> |
108 </form> |
79 </div> |
109 </div> |
80 <?php |
110 <?php |
81 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
111 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
82 exit(); |
112 exit(); |
|
113 } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) { |
|
114 $action = $_GET['action']; |
|
115 check_admin_referer( $action . '_' . $id ); |
|
116 } elseif ( 'allblogs' === $_GET['action'] ) { |
|
117 check_admin_referer( 'bulk-sites' ); |
83 } |
118 } |
84 |
119 |
85 $updated_action = ''; |
120 $updated_action = ''; |
86 |
|
87 $manage_actions = array( 'deleteblog', 'allblogs', 'archiveblog', 'unarchiveblog', 'activateblog', 'deactivateblog', 'unspamblog', 'spamblog', 'unmatureblog', 'matureblog' ); |
|
88 if ( in_array( $_GET['action'], $manage_actions ) ) { |
|
89 $action = $_GET['action']; |
|
90 if ( 'allblogs' === $action ) |
|
91 $action = 'bulk-sites'; |
|
92 |
|
93 check_admin_referer( $action ); |
|
94 } |
|
95 |
121 |
96 switch ( $_GET['action'] ) { |
122 switch ( $_GET['action'] ) { |
97 |
123 |
98 case 'deleteblog': |
124 case 'deleteblog': |
99 if ( ! current_user_can( 'delete_sites' ) ) |
125 if ( ! current_user_can( 'delete_sites' ) ) |
100 wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) ); |
126 wp_die( __( 'Sorry, you are not allowed to access this page.' ), '', array( 'response' => 403 ) ); |
101 |
127 |
102 $updated_action = 'not_deleted'; |
128 $updated_action = 'not_deleted'; |
103 if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) { |
129 if ( $id != '0' && $id != get_network()->site_id && current_user_can( 'delete_site', $id ) ) { |
104 wpmu_delete_blog( $id, true ); |
130 wpmu_delete_blog( $id, true ); |
105 $updated_action = 'delete'; |
131 $updated_action = 'delete'; |
106 } |
132 } |
107 break; |
133 break; |
108 |
134 |
|
135 case 'delete_sites': |
|
136 check_admin_referer( 'ms-delete-sites' ); |
|
137 |
|
138 foreach ( (array) $_POST['site_ids'] as $site_id ) { |
|
139 $site_id = (int) $site_id; |
|
140 |
|
141 if ( $site_id == get_network()->site_id ) { |
|
142 continue; |
|
143 } |
|
144 |
|
145 if ( ! current_user_can( 'delete_site', $site_id ) ) { |
|
146 $site = get_site( $site_id ); |
|
147 $site_address = untrailingslashit( $site->domain . $site->path ); |
|
148 |
|
149 wp_die( sprintf( __( 'Sorry, you are not allowed to delete the site %s.' ), $site_address ), 403 ); |
|
150 } |
|
151 |
|
152 $updated_action = 'all_delete'; |
|
153 wpmu_delete_blog( $site_id, true ); |
|
154 } |
|
155 break; |
|
156 |
109 case 'allblogs': |
157 case 'allblogs': |
110 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { |
158 if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) { |
111 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
159 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2']; |
112 |
160 |
113 foreach ( (array) $_POST['allblogs'] as $key => $val ) { |
161 foreach ( (array) $_POST['allblogs'] as $key => $val ) { |
114 if ( $val != '0' && $val != $current_site->blog_id ) { |
162 if ( $val != '0' && $val != get_network()->site_id ) { |
115 switch ( $doaction ) { |
163 switch ( $doaction ) { |
116 case 'delete': |
164 case 'delete': |
117 if ( ! current_user_can( 'delete_site', $val ) ) |
165 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
118 wp_die( __( 'You are not allowed to delete the site.' ) ); |
166 ?> |
119 |
167 <div class="wrap"> |
120 $updated_action = 'all_delete'; |
168 <h1><?php _e( 'Confirm your action' ); ?></h1> |
121 wpmu_delete_blog( $val, true ); |
169 <form action="sites.php?action=delete_sites" method="post"> |
|
170 <input type="hidden" name="action" value="delete_sites" /> |
|
171 <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 ); ?> |
|
173 <p><?php _e( 'You are about to delete the following sites:' ); ?></p> |
|
174 <ul class="ul-disc"> |
|
175 <?php foreach ( $_POST['allblogs'] as $site_id ) : |
|
176 $site = get_site( $site_id ); |
|
177 $site_address = untrailingslashit( $site->domain . $site->path ); |
|
178 ?> |
|
179 <li> |
|
180 <?php echo $site_address; ?> |
|
181 <input type="hidden" name="site_ids[]" value="<?php echo (int) $site_id; ?>" /> |
|
182 </li> |
|
183 <?php endforeach; ?> |
|
184 </ul> |
|
185 <?php submit_button( __( 'Confirm' ), 'primary' ); ?> |
|
186 </form> |
|
187 </div> |
|
188 <?php |
|
189 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); |
|
190 exit(); |
122 break; |
191 break; |
123 |
192 |
124 case 'spam': |
193 case 'spam': |
125 case 'notspam': |
194 case 'notspam': |
126 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; |
195 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam'; |
127 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); |
196 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' ); |
128 break; |
197 break; |
129 } |
198 } |
130 } else { |
199 } else { |
131 wp_die( __( 'You are not allowed to change the current site.' ) ); |
200 wp_die( __( 'Sorry, you are not allowed to change the current site.' ) ); |
132 } |
201 } |
133 } |
202 } |
|
203 if ( ! in_array( $doaction, array( 'delete', 'spam', 'notspam' ), true ) ) { |
|
204 $redirect_to = wp_get_referer(); |
|
205 $blogs = (array) $_POST['allblogs']; |
|
206 /** 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 ); |
|
208 wp_safe_redirect( $redirect_to ); |
|
209 exit(); |
|
210 } |
134 } else { |
211 } else { |
135 wp_redirect( network_admin_url( 'sites.php' ) ); |
212 $location = network_admin_url( 'sites.php' ); |
|
213 if ( ! empty( $_REQUEST['paged'] ) ) { |
|
214 $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location ); |
|
215 } |
|
216 wp_redirect( $location ); |
136 exit(); |
217 exit(); |
137 } |
218 } |
138 break; |
219 break; |
139 |
220 |
140 case 'archiveblog': |
221 case 'archiveblog': |