]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/sites.php
WordPress 4.0
[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.' ) );
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', array( 'label' => _x( 'Sites', 'sites per page (screen options)' ) ) );
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="http://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         if ( 'confirm' === $_GET['action'] ) {
56                 check_admin_referer( 'confirm' );
57
58                 if ( ! headers_sent() ) {
59                         nocache_headers();
60                         header( 'Content-Type: text/html; charset=utf-8' );
61                 }
62
63                 if ( $current_site->blog_id == $id ) {
64                         wp_die( __( 'You are not allowed to change the current site.' ) );
65                 }
66
67                 require_once( ABSPATH . 'wp-admin/admin-header.php' );
68                 ?>
69                         <div class="wrap">
70                                 <h2><?php _e( 'Confirm your action' ); ?></h2>
71                                 <form action="sites.php?action=<?php echo esc_attr( $_GET['action2'] ) ?>" method="post">
72                                         <input type="hidden" name="action" value="<?php echo esc_attr( $_GET['action2'] ) ?>" />
73                                         <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() ); ?>" />
75                                         <?php wp_nonce_field( $_GET['action2'], '_wpnonce', false ); ?>
76                                         <p><?php echo esc_html( wp_unslash( $_GET['msg'] ) ); ?></p>
77                                         <?php submit_button( __( 'Confirm' ), 'button' ); ?>
78                                 </form>
79                         </div>
80                 <?php
81                 require_once( ABSPATH . 'wp-admin/admin-footer.php' );
82                 exit();
83         }
84
85         $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
96         switch ( $_GET['action'] ) {
97
98                 case 'deleteblog':
99                         if ( ! current_user_can( 'delete_sites' ) )
100                                 wp_die( __( 'You do not have permission to access this page.' ) );
101
102                         $updated_action = 'not_deleted';
103                         if ( $id != '0' && $id != $current_site->blog_id && current_user_can( 'delete_site', $id ) ) {
104                                 wpmu_delete_blog( $id, true );
105                                 $updated_action = 'delete';
106                         }
107                 break;
108
109                 case 'allblogs':
110                         if ( ( isset( $_POST['action'] ) || isset( $_POST['action2'] ) ) && isset( $_POST['allblogs'] ) ) {
111                                 $doaction = $_POST['action'] != -1 ? $_POST['action'] : $_POST['action2'];
112
113                                 foreach ( (array) $_POST['allblogs'] as $key => $val ) {
114                                         if ( $val != '0' && $val != $current_site->blog_id ) {
115                                                 switch ( $doaction ) {
116                                                         case 'delete':
117                                                                 if ( ! current_user_can( 'delete_site', $val ) )
118                                                                         wp_die( __( 'You are not allowed to delete the site.' ) );
119
120                                                                 $updated_action = 'all_delete';
121                                                                 wpmu_delete_blog( $val, true );
122                                                         break;
123
124                                                         case 'spam':
125                                                         case 'notspam':
126                                                                 $updated_action = ( 'spam' === $doaction ) ? 'all_spam' : 'all_notspam';
127                                                                 update_blog_status( $val, 'spam', ( 'spam' === $doaction ) ? '1' : '0' );
128                                                         break;
129                                                 }
130                                         } else {
131                                                 wp_die( __( 'You are not allowed to change the current site.' ) );
132                                         }
133                                 }
134                         } else {
135                                 wp_redirect( network_admin_url( 'sites.php' ) );
136                                 exit();
137                         }
138                 break;
139
140                 case 'archiveblog':
141                 case 'unarchiveblog':
142                         update_blog_status( $id, 'archived', ( 'archiveblog' === $_GET['action'] ) ? '1' : '0' );
143                 break;
144
145                 case 'activateblog':
146                         update_blog_status( $id, 'deleted', '0' );
147
148                         /**
149                          * Fires after a network site is activated.
150                          *
151                          * @since MU
152                          *
153                          * @param string $id The ID of the activated site.
154                          */
155                         do_action( 'activate_blog', $id );
156                 break;
157
158                 case 'deactivateblog':
159                         /**
160                          * Fires before a network site is deactivated.
161                          *
162                          * @since MU
163                          *
164                          * @param string $id The ID of the site being deactivated.
165                          */
166                         do_action( 'deactivate_blog', $id );
167                         update_blog_status( $id, 'deleted', '1' );
168                 break;
169
170                 case 'unspamblog':
171                 case 'spamblog':
172                         update_blog_status( $id, 'spam', ( 'spamblog' === $_GET['action'] ) ? '1' : '0' );
173                 break;
174
175                 case 'unmatureblog':
176                 case 'matureblog':
177                         update_blog_status( $id, 'mature', ( 'matureblog' === $_GET['action'] ) ? '1' : '0' );
178                 break;
179         }
180
181         if ( empty( $updated_action ) && in_array( $_GET['action'], $manage_actions ) )
182                 $updated_action = $_GET['action'];
183
184         if ( ! empty( $updated_action ) ) {
185                 wp_safe_redirect( add_query_arg( array( 'updated' => $updated_action ), wp_get_referer() ) );
186                 exit();
187         }
188 }
189
190 $msg = '';
191 if ( isset( $_GET['updated'] ) ) {
192         switch ( $_GET['updated'] ) {
193                 case 'all_notspam':
194                         $msg = __( 'Sites removed from spam.' );
195                 break;
196                 case 'all_spam':
197                         $msg = __( 'Sites marked as spam.' );
198                 break;
199                 case 'all_delete':
200                         $msg = __( 'Sites deleted.' );
201                 break;
202                 case 'delete':
203                         $msg = __( 'Site deleted.' );
204                 break;
205                 case 'not_deleted':
206                         $msg = __( 'You do not have permission to delete that site.' );
207                 break;
208                 case 'archiveblog':
209                         $msg = __( 'Site archived.' );
210                 break;
211                 case 'unarchiveblog':
212                         $msg = __( 'Site unarchived.' );
213                 break;
214                 case 'activateblog':
215                         $msg = __( 'Site activated.' );
216                 break;
217                 case 'deactivateblog':
218                         $msg = __( 'Site deactivated.' );
219                 break;
220                 case 'unspamblog':
221                         $msg = __( 'Site removed from spam.' );
222                 break;
223                 case 'spamblog':
224                         $msg = __( 'Site marked as spam.' );
225                 break;
226                 default:
227                         /**
228                          * Filter a specific, non-default site-updated message in the Network admin.
229                          *
230                          * The dynamic portion of the hook name, $_GET['updated'], refers to the non-default
231                          * site update action.
232                          *
233                          * @since 3.1.0
234                          *
235                          * @param string $msg The update message. Default 'Settings saved'.
236                          */
237                         $msg = apply_filters( 'network_sites_updated_message_' . $_GET['updated'], __( 'Settings saved.' ) );
238                 break;
239         }
240
241         if ( ! empty( $msg ) )
242                 $msg = '<div class="updated" id="message"><p>' . $msg . '</p></div>';
243 }
244
245 $wp_list_table->prepare_items();
246
247 require_once( ABSPATH . 'wp-admin/admin-header.php' );
248 ?>
249
250 <div class="wrap">
251 <h2><?php _e( 'Sites' ) ?>
252
253 <?php if ( current_user_can( 'create_sites') ) : ?>
254         <a href="<?php echo network_admin_url('site-new.php'); ?>" class="add-new-h2"><?php echo esc_html_x( 'Add New', 'site' ); ?></a>
255 <?php endif; ?>
256
257 <?php if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) {
258         printf( '<span class="subtitle">' . __( 'Search results for &#8220;%s&#8221;' ) . '</span>', esc_html( $s ) );
259 } ?>
260 </h2>
261
262 <?php echo $msg; ?>
263
264 <form action="" method="get" id="ms-search">
265 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>
266 <input type="hidden" name="action" value="blogs" />
267 </form>
268
269 <form id="form-site-list" action="sites.php?action=allblogs" method="post">
270         <?php $wp_list_table->display(); ?>
271 </form>
272 </div>
273 <?php
274
275 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>