]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/sites.php
WordPress 4.3-scripts
[autoinstalls/wordpress.git] / wp-admin / network / sites.php
1 <?php
2 /**
3  * Multisite sites administration panel.
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.0.0
8  */
9
10 /** Load WordPress Administration Bootstrap */
11 require_once( dirname( __FILE__ ) . '/admin.php' );
12
13 if ( ! is_multisite() )
14         wp_die( __( 'Multisite support is not enabled.' ) );
15
16 if ( ! current_user_can( 'manage_sites' ) )
17         wp_die( __( 'You do not have permission to access this page.' ), 403 );
18
19 $wp_list_table = _get_list_table( 'WP_MS_Sites_List_Table' );
20 $pagenum = $wp_list_table->get_pagenum();
21
22 $title = __( 'Sites' );
23 $parent_file = 'sites.php';
24
25 add_screen_option( 'per_page' );
26
27 get_current_screen()->add_help_tab( array(
28         'id'      => 'overview',
29         'title'   => __('Overview'),
30         'content' =>
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 frontend 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>'
41 ) );
42
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>'
47 );
48
49 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
50
51 if ( isset( $_GET['action'] ) ) {
52         /** This action is documented in wp-admin/network/edit.php */
53         do_action( 'wpmuadminedit' );
54
55         // A list of valid actions and their associated messaging for confirmation output.
56         $manage_actions = array(
57                 'activateblog'   => __( 'You are about to activate the site %s' ),
58                 'deactivateblog' => __( 'You are about to deactivate the site %s' ),
59                 'unarchiveblog'  => __( 'You are about to unarchive the site %s.' ),
60                 'archiveblog'    => __( 'You are about to archive the site %s.' ),
61                 'unspamblog'     => __( 'You are about to unspam the site %s.' ),
62                 'spamblog'       => __( 'You are about to mark the site %s as spam.' ),
63                 'deleteblog'     => __( 'You are about to delete the site %s.' ),
64                 'unmatureblog'   => __( 'You are about to mark the site %s as mature.' ),
65                 'matureblog'     => __( 'You are about to mark the site %s as not mature.' ),
66         );
67
68         if ( 'confirm' === $_GET['action'] ) {
69                 // The action2 parameter contains the action being taken on the site.
70                 $site_action = $_GET['action2'];
71
72                 if ( ! array_key_exists( $site_action, $manage_actions ) ) {
73                         wp_die( __( 'The requested action is not valid.' ) );
74                 }
75
76                 // The mature/unmature UI exists only as external code. Check the "confirm" nonce for backward compatibility.
77                 if ( 'matureblog' === $site_action || 'unmatureblog' === $site_action ) {
78                         check_admin_referer( 'confirm' );
79                 } else {
80                         check_admin_referer( $site_action . '_' . $id );
81                 }
82
83                 if ( ! headers_sent() ) {
84                         nocache_headers();
85                         header( 'Content-Type: text/html; charset=utf-8' );
86                 }
87
88                 if ( $current_site->blog_id == $id ) {
89                         wp_die( __( 'You are not allowed to change the current site.' ) );
90                 }
91
92                 $site_details = get_blog_details( $id );
93                 $site_address = untrailingslashit( $site_details->domain . $site_details->path );
94
95                 require_once( ABSPATH . 'wp-admin/admin-header.php' );
96                 ?>
97                         <div class="wrap">
98                                 <h1><?php _e( 'Confirm your action' ); ?></h1>
99                                 <form action="sites.php?action=<?php echo esc_attr( $site_action ); ?>" method="post">
100                                         <input type="hidden" name="action" value="<?php echo esc_attr( $site_action ); ?>" />
101                                         <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
102                                         <input type="hidden" name="_wp_http_referer" value="<?php echo esc_attr( wp_get_referer() ); ?>" />
103                                         <?php wp_nonce_field( $site_action . '_' . $id, '_wpnonce', false ); ?>
104                                         <p><?php echo sprintf( $manage_actions[ $site_action ], $site_address ); ?></p>
105                                         <?php submit_button( __( 'Confirm' ), 'button' ); ?>
106                                 </form>
107                         </div>
108                 <?php
109                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
110                 exit();
111         } elseif ( array_key_exists( $_GET['action'], $manage_actions ) ) {
112                 $action = $_GET['action'];
113                 check_admin_referer( $action . '_' . $id );
114         } elseif ( 'allblogs' === $_GET['action'] ) {
115                 check_admin_referer( 'bulk-sites' );
116         }
117
118         $updated_action = '';
119
120         switch ( $_GET['action'] ) {
121
122                 case 'deleteblog':
123                         if ( ! current_user_can( 'delete_sites' ) )
124                                 wp_die( __( 'You do not have permission to access this page.' ), '', array( 'response' => 403 ) );
125
126                         $updated_action = 'not_deleted';
127                         if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
128                                 wpmu_delete_blog( $id, true );
129                                 $updated_action = 'delete';
130                         }
131                 break;
132
133                 case 'allblogs':
134                         if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
135                                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
136
137                                 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
138                                         if ( $val != '0' && $val != $current_site->blog_id ) {
139                                                 switch ( $doaction ) {
140                                                         case 'delete':
141                                                                 if ( ! current_user_can( 'delete_site', $val ) )
142                                                                         wp_die( __( 'You are not allowed to delete the site.' ) );
143
144                                                                 $updated_action = 'all_delete';
145                                                                 wpmu_delete_blog( $val, true );
146                                                         break;
147
148                                                         case 'spam':
149                                                         case 'notspam':
150                                                                 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
151                                                                 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
152                                                         break;
153                                                 }
154                                         } else {
155                                                 wp_die( __( 'You are not allowed to change the current site.' ) );
156                                         }
157                                 }
158                         } else {
159                                 wp_redirect( network_admin_url( 'sites.php' ) );
160                                 exit();
161                         }
162                 break;
163
164                 case 'archiveblog':
165                 case 'unarchiveblog':
166                         update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
167                 break;
168
169                 case 'activateblog':
170                         update_blog_status( $id, 'deleted', '0' );
171
172                         /**
173                          * Fires after a network site is activated.
174                          *
175                          * @since MU
176                          *
177                          * @param string $id The ID of the activated site.
178                          */
179                         do_action( 'activate_blog', $id );
180                 break;
181
182                 case 'deactivateblog':
183                         /**
184                          * Fires before a network site is deactivated.
185                          *
186                          * @since MU
187                          *
188                          * @param string $id The ID of the site being deactivated.
189                          */
190                         do_action( 'deactivate_blog', $id );
191                         update_blog_status( $id, 'deleted', '1' );
192                 break;
193
194                 case 'unspamblog':
195                 case 'spamblog':
196                         update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
197                 break;
198
199                 case 'unmatureblog':
200                 case 'matureblog':
201                         update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
202                 break;
203         }
204
205         if ( empty( $updated_action ) && array_key_exists( $_GET['action'], $manage_actions ) ) {
206                 $updated_action = $_GET['action'];
207         }
208
209         if ( ! empty( $updated_action ) ) {
210                 wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
211                 exit();
212         }
213 }
214
215 $msg = '';
216 if ( isset( $_GET['updated'] ) ) {
217         switch ( $_GET['updated'] ) {
218                 case 'all_notspam':
219                         $msg = __( 'Sites removed from spam.' );
220                 break;
221                 case 'all_spam':
222                         $msg = __( 'Sites marked as spam.' );
223                 break;
224                 case 'all_delete':
225                         $msg = __( 'Sites deleted.' );
226                 break;
227                 case 'delete':
228                         $msg = __( 'Site deleted.' );
229                 break;
230                 case 'not_deleted':
231                         $msg = __( 'You do not have permission to delete that site.' );
232                 break;
233                 case 'archiveblog':
234                         $msg = __( 'Site archived.' );
235                 break;
236                 case 'unarchiveblog':
237                         $msg = __( 'Site unarchived.' );
238                 break;
239                 case 'activateblog':
240                         $msg = __( 'Site activated.' );
241                 break;
242                 case 'deactivateblog':
243                         $msg = __( 'Site deactivated.' );
244                 break;
245                 case 'unspamblog':
246                         $msg = __( 'Site removed from spam.' );
247                 break;
248                 case 'spamblog':
249                         $msg = __( 'Site marked as spam.' );
250                 break;
251                 default:
252                         /**
253                          * Filter a specific, non-default site-updated message in the Network admin.
254                          *
255                          * The dynamic portion of the hook name, `$_GET['updated']`, refers to the
256                          * non-default site update action.
257                          *
258                          * @since 3.1.0
259                          *
260                          * @param string $msg The update message. Default 'Settings saved'.
261                          */
262                         $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
263                 break;
264         }
265
266         if ( ! empty( $msg ) )
267                 $msg = '<div class="updated" id="message notice is-dismissible"><p>' . $msg . '</p></div>';
268 }
269
270 $wp_list_table->prepare_items();
271
272 require_once( ABSPATH . 'wp-admin/admin-header.php' );
273 ?>
274
275 <div class="wrap">
276 <h1><?php _e( 'Sites' ); ?>
277
278 <?php if ( current_user_can( 'create_sites') ) : ?>
279         <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
280 <?php endif; ?>
281
282 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
283         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
284 } ?>
285 </h1>
286
287 <?php echo $msg; ?>
288
289 <form method="get" id="ms-search">
290 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
291 <input type="hidden" name="action" value="blogs" />
292 </form>
293
294 <form id="form-site-list" action="sites.php?action=allblogs" method="post">
295         <?php $wp_list_table->display(); ?>
296 </form>
297 </div>
298 <?php
299
300 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>