]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/network/site-info.php
WordPress 4.4.1-scripts
[autoinstalls/wordpress.git] / wp-admin / network / site-info.php
1 <?php
2 /**
3  * Edit Site Info Administration Screen
4  *
5  * @package WordPress
6  * @subpackage Multisite
7  * @since 3.1.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
17 if ( ! current_user_can( 'manage_sites' ) ) {
18         wp_die( __( 'You do not have sufficient permissions to edit this site.' ) );
19 }
20
21 get_current_screen()->add_help_tab( array(
22         'id'      => 'overview',
23         'title'   => __( 'Overview' ),
24         'content' =>
25                 '<p>' . __( 'The menu is for editing information specific to individual sites, particularly if the admin area of a site is unavailable.' ) . '</p>' .
26                 '<p>' . __( '<strong>Info</strong> &mdash; The site URL is rarely edited as this can cause the site to not work properly. The Registered date and Last Updated date are displayed. Network admins can mark a site as archived, spam, deleted and mature, to remove from public listings or disable.' ) . '</p>' .
27                 '<p>' . __( '<strong>Users</strong> &mdash; This displays the users associated with this site. You can also change their role, reset their password, or remove them from the site. Removing the user from the site does not remove the user from the network.' ) . '</p>' .
28                 '<p>' . sprintf( __( '<strong>Themes</strong> &mdash; This area shows themes that are not already enabled across the network. Enabling a theme in this menu makes it accessible to this site. It does not activate the theme, but allows it to show in the site&#8217;s Appearance menu. To enable a theme for the entire network, see the <a href="%s">Network Themes</a> screen.' ), network_admin_url( 'themes.php' ) ) . '</p>' .
29                 '<p>' . __( '<strong>Settings</strong> &mdash; This page shows a list of all settings associated with this site. Some are created by WordPress and others are created by plugins you activate. Note that some fields are grayed out and say Serialized Data. You cannot modify these values due to the way the setting is stored in the database.' ) . '</p>'
30 ) );
31
32 get_current_screen()->set_help_sidebar(
33         '<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
34         '<p>' . __( '<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>' ) . '</p>' .
35         '<p>' . __( '<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>' ) . '</p>'
36 );
37
38 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0;
39
40 if ( ! $id ) {
41         wp_die( __('Invalid site ID.') );
42 }
43
44 $details = get_blog_details( $id );
45 if ( ! $details ) {
46         wp_die( __( 'The requested site does not exist.' ) );
47 }
48
49 if ( ! can_edit_network( $details->site_id ) ) {
50         wp_die( __( 'You do not have permission to access this page.' ), 403 );
51 }
52
53 $parsed_scheme = parse_url( $details->siteurl, PHP_URL_SCHEME );
54 $is_main_site = is_main_site( $id );
55
56 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] ) {
57         check_admin_referer( 'edit-site' );
58
59         switch_to_blog( $id );
60
61         // Rewrite rules can't be flushed during switch to blog.
62         delete_option( 'rewrite_rules' );
63
64         $blog_data = wp_unslash( $_POST['blog'] );
65         $blog_data['scheme'] = $parsed_scheme;
66
67         if ( $is_main_site ) {
68                 // On the network's main site, don't allow the domain or path to change.
69                 $blog_data['domain'] = $details->domain;
70                 $blog_data['path'] = $details->path;
71         } else {
72                 // For any other site, the scheme, domain, and path can all be changed. We first
73                 // need to ensure a scheme has been provided, otherwise fallback to the existing.
74                 $new_url_scheme = parse_url( $blog_data['url'], PHP_URL_SCHEME );
75
76                 if ( ! $new_url_scheme ) {
77                         $blog_data['url'] = esc_url( $parsed_scheme . '://' . $blog_data['url'] );
78                 }
79                 $update_parsed_url = parse_url( $blog_data['url'] );
80
81                 $blog_data['scheme'] = $update_parsed_url['scheme'];
82                 $blog_data['domain'] = $update_parsed_url['host'];
83                 $blog_data['path'] = $update_parsed_url['path'];
84         }
85
86         $existing_details = get_blog_details( $id, false );
87         $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' );
88         foreach ( $blog_data_checkboxes as $c ) {
89                 if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) ) {
90                         $blog_data[ $c ] = $existing_details->$c;
91                 } else {
92                         $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0;
93                 }
94         }
95
96         update_blog_details( $id, $blog_data );
97
98         // Maybe update home and siteurl options.
99         $new_details = get_blog_details( $id, false );
100
101         $old_home_url = trailingslashit( esc_url( get_option( 'home' ) ) );
102         $old_home_parsed = parse_url( $old_home_url );
103
104         if ( $old_home_parsed['host'] === $existing_details->domain && $old_home_parsed['path'] === $existing_details->path ) {
105                 $new_home_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
106                 update_option( 'home', $new_home_url );
107         }
108
109         $old_site_url = trailingslashit( esc_url( get_option( 'siteurl' ) ) );
110         $old_site_parsed = parse_url( $old_site_url );
111
112         if ( $old_site_parsed['host'] === $existing_details->domain && $old_site_parsed['path'] === $existing_details->path ) {
113                 $new_site_url = untrailingslashit( esc_url_raw( $blog_data['scheme'] . '://' . $new_details->domain . $new_details->path ) );
114                 update_option( 'siteurl', $new_site_url );
115         }
116
117         restore_current_blog();
118         wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php' ) );
119         exit;
120 }
121
122 if ( isset( $_GET['update'] ) ) {
123         $messages = array();
124         if ( 'updated' == $_GET['update'] ) {
125                 $messages[] = __( 'Site info updated.' );
126         }
127 }
128
129 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) );
130
131 $parent_file = 'sites.php';
132 $submenu_file = 'sites.php';
133
134 require( ABSPATH . 'wp-admin/admin-header.php' );
135
136 ?>
137
138 <div class="wrap">
139 <h1 id="edit-site"><?php echo $title; ?></h1>
140 <p class="edit-site-actions"><a href="<?php echo esc_url( get_home_url( $id, '/' ) ); ?>"><?php _e( 'Visit' ); ?></a> | <a href="<?php echo esc_url( get_admin_url( $id ) ); ?>"><?php _e( 'Dashboard' ); ?></a></p>
141 <h2 class="nav-tab-wrapper nav-tab-small">
142 <?php
143 $tabs = array(
144         'site-info'     => array( 'label' => __( 'Info' ),     'url' => 'site-info.php'     ),
145         'site-users'    => array( 'label' => __( 'Users' ),    'url' => 'site-users.php'    ),
146         'site-themes'   => array( 'label' => __( 'Themes' ),   'url' => 'site-themes.php'   ),
147         'site-settings' => array( 'label' => __( 'Settings' ), 'url' => 'site-settings.php' ),
148 );
149 foreach ( $tabs as $tab_id => $tab ) {
150         $class = ( $tab['url'] == $pagenow ) ? ' nav-tab-active' : '';
151         echo '<a href="' . $tab['url'] . '?id=' . $id .'" class="nav-tab' . $class . '">' . esc_html( $tab['label'] ) . '</a>';
152 }
153 ?>
154 </h2>
155 <?php
156 if ( ! empty( $messages ) ) {
157         foreach ( $messages as $msg ) {
158                 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>';
159         }
160 }
161 ?>
162 <form method="post" action="site-info.php?action=update-site">
163         <?php wp_nonce_field( 'edit-site' ); ?>
164         <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" />
165         <table class="form-table">
166                 <?php
167                 // The main site of the network should not be updated on this page.
168                 if ( $is_main_site ) : ?>
169                 <tr class="form-field">
170                         <th scope="row"><?php _e( 'Site URL' ); ?></th>
171                         <td><?php echo esc_url( $details->siteurl ); ?></td>
172                 </tr>
173                 <?php
174                 // For any other site, the scheme, domain, and path can all be changed.
175                 else : ?>
176                 <tr class="form-field form-required">
177                         <th scope="row"><?php _e( 'Site URL' ); ?></th>
178                         <td><input name="blog[url]" type="text" id="url" value="<?php echo $parsed_scheme . '://' . esc_attr( $details->domain ) . esc_attr( $details->path ); ?>" /></td>
179                 </tr>
180                 <?php endif; ?>
181
182                 <tr class="form-field">
183                         <th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ) ?></label></th>
184                         <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" /></td>
185                 </tr>
186                 <tr class="form-field">
187                         <th scope="row"><label for="blog_last_updated"><?php _e( 'Last Updated' ); ?></label></th>
188                         <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" /></td>
189                 </tr>
190                 <?php
191                 $attribute_fields = array( 'public' => __( 'Public' ) );
192                 if ( ! $is_main_site ) {
193                         $attribute_fields['archived'] = __( 'Archived' );
194                         $attribute_fields['spam']     = _x( 'Spam', 'site' );
195                         $attribute_fields['deleted']  = __( 'Deleted' );
196                 }
197                 $attribute_fields['mature'] = __( 'Mature' );
198                 ?>
199                 <tr>
200                         <th scope="row"><?php _e( 'Attributes' ); ?></th>
201                         <td>
202                         <fieldset>
203                         <legend class="screen-reader-text"><?php _e( 'Set site attributes' ) ?></legend>
204                         <?php foreach ( $attribute_fields as $field_key => $field_label ) : ?>
205                                 <label><input type="checkbox" name="blog[<?php echo $field_key; ?>]" value="1" <?php checked( (bool) $details->$field_key, true ); disabled( ! in_array( $details->$field_key, array( 0, 1 ) ) ); ?> />
206                                 <?php echo $field_label; ?></label><br/>
207                         <?php endforeach; ?>
208                         <fieldset>
209                         </td>
210                 </tr>
211         </table>
212         <?php submit_button(); ?>
213 </form>
214
215 </div>
216 <?php
217 require( ABSPATH . 'wp-admin/admin-footer.php' );