27 '<p>' . __('<strong>Settings</strong> - 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>' |
27 '<p>' . __('<strong>Settings</strong> - 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>' |
28 ) ); |
28 ) ); |
29 |
29 |
30 get_current_screen()->set_help_sidebar( |
30 get_current_screen()->set_help_sidebar( |
31 '<p><strong>' . __('For more information:') . '</strong></p>' . |
31 '<p><strong>' . __('For more information:') . '</strong></p>' . |
32 '<p>' . __('<a href="http://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' . |
32 '<p>' . __('<a href="https://codex.wordpress.org/Network_Admin_Sites_Screen" target="_blank">Documentation on Site Management</a>') . '</p>' . |
33 '<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
33 '<p>' . __('<a href="https://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>' |
34 ); |
34 ); |
35 |
35 |
36 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
36 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
37 |
37 |
38 if ( ! $id ) |
38 if ( ! $id ) |
39 wp_die( __('Invalid site ID.') ); |
39 wp_die( __('Invalid site ID.') ); |
40 |
40 |
41 $details = get_blog_details( $id ); |
41 $details = get_blog_details( $id ); |
42 if ( !can_edit_network( $details->site_id ) ) |
42 if ( !can_edit_network( $details->site_id ) ) |
43 wp_die( __( 'You do not have permission to access this page.' ) ); |
43 wp_die( __( 'You do not have permission to access this page.' ), 403 ); |
44 |
44 |
|
45 $parsed = parse_url( $details->siteurl ); |
45 $is_main_site = is_main_site( $id ); |
46 $is_main_site = is_main_site( $id ); |
46 |
47 |
47 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { |
48 if ( isset($_REQUEST['action']) && 'update-site' == $_REQUEST['action'] ) { |
48 check_admin_referer( 'edit-site' ); |
49 check_admin_referer( 'edit-site' ); |
49 |
50 |
50 switch_to_blog( $id ); |
51 switch_to_blog( $id ); |
51 |
52 |
52 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { |
53 // Rewrite rules can't be flushed during switch to blog. |
53 $blog_address = esc_url_raw( $_POST['blog']['domain'] . $_POST['blog']['path'] ); |
|
54 if ( get_option( 'siteurl' ) != $blog_address ) |
|
55 update_option( 'siteurl', $blog_address ); |
|
56 |
|
57 if ( get_option( 'home' ) != $blog_address ) |
|
58 update_option( 'home', $blog_address ); |
|
59 } |
|
60 |
|
61 // rewrite rules can't be flushed during switch to blog |
|
62 delete_option( 'rewrite_rules' ); |
54 delete_option( 'rewrite_rules' ); |
63 |
55 |
64 // update blogs table |
56 // Update blogs table. |
65 $blog_data = wp_unslash( $_POST['blog'] ); |
57 $blog_data = wp_unslash( $_POST['blog'] ); |
66 $existing_details = get_blog_details( $id, false ); |
58 $existing_details = get_blog_details( $id, false ); |
67 $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' ); |
59 $blog_data_checkboxes = array( 'public', 'archived', 'spam', 'mature', 'deleted' ); |
68 foreach ( $blog_data_checkboxes as $c ) { |
60 foreach ( $blog_data_checkboxes as $c ) { |
69 if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) ) |
61 if ( ! in_array( $existing_details->$c, array( 0, 1 ) ) ) |
70 $blog_data[ $c ] = $existing_details->$c; |
62 $blog_data[ $c ] = $existing_details->$c; |
71 else |
63 else |
72 $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0; |
64 $blog_data[ $c ] = isset( $_POST['blog'][ $c ] ) ? 1 : 0; |
73 } |
65 } |
74 update_blog_details( $id, $blog_data ); |
66 update_blog_details( $id, $blog_data ); |
|
67 |
|
68 if ( isset( $_POST['update_home_url'] ) && $_POST['update_home_url'] == 'update' ) { |
|
69 $new_details = get_blog_details( $id, false ); |
|
70 $blog_address = esc_url_raw( $new_details->domain . $new_details->path ); |
|
71 if ( get_option( 'siteurl' ) != $blog_address ) { |
|
72 update_option( 'siteurl', $blog_address ); |
|
73 } |
|
74 if ( get_option( 'home' ) != $blog_address ) { |
|
75 update_option( 'home', $blog_address ); |
|
76 } |
|
77 } |
75 |
78 |
76 restore_current_blog(); |
79 restore_current_blog(); |
77 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') ); |
80 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-info.php') ); |
78 exit; |
81 exit; |
79 } |
82 } |
83 if ( 'updated' == $_GET['update'] ) |
86 if ( 'updated' == $_GET['update'] ) |
84 $messages[] = __('Site info updated.'); |
87 $messages[] = __('Site info updated.'); |
85 } |
88 } |
86 |
89 |
87 $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) ); |
90 $site_url_no_http = preg_replace( '#^http(s)?://#', '', get_blogaddress_by_id( $id ) ); |
88 $title_site_url_linked = sprintf( __('Edit Site: <a href="%1$s">%2$s</a>'), get_blogaddress_by_id( $id ), $site_url_no_http ); |
91 $title_site_url_linked = sprintf( __( 'Edit Site: %s' ), '<a href="' . get_blogaddress_by_id( $id ) . '">' . $site_url_no_http . '</a>' ); |
89 $title = sprintf( __('Edit Site: %s'), $site_url_no_http ); |
92 $title = sprintf( __( 'Edit Site: %s' ), $site_url_no_http ); |
90 |
93 |
91 $parent_file = 'sites.php'; |
94 $parent_file = 'sites.php'; |
92 $submenu_file = 'sites.php'; |
95 $submenu_file = 'sites.php'; |
93 |
96 |
94 require( ABSPATH . 'wp-admin/admin-header.php' ); |
97 require( ABSPATH . 'wp-admin/admin-header.php' ); |
95 |
98 |
96 ?> |
99 ?> |
97 |
100 |
98 <div class="wrap"> |
101 <div class="wrap"> |
99 <?php screen_icon('ms-admin'); ?> |
|
100 <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2> |
102 <h2 id="edit-site"><?php echo $title_site_url_linked ?></h2> |
101 <h3 class="nav-tab-wrapper"> |
103 <h3 class="nav-tab-wrapper"> |
102 <?php |
104 <?php |
103 $tabs = array( |
105 $tabs = array( |
104 'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php' ), |
106 'site-info' => array( 'label' => __( 'Info' ), 'url' => 'site-info.php' ), |
113 ?> |
115 ?> |
114 </h3> |
116 </h3> |
115 <?php |
117 <?php |
116 if ( ! empty( $messages ) ) { |
118 if ( ! empty( $messages ) ) { |
117 foreach ( $messages as $msg ) |
119 foreach ( $messages as $msg ) |
118 echo '<div id="message" class="updated"><p>' . $msg . '</p></div>'; |
120 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
119 } ?> |
121 } ?> |
120 <form method="post" action="site-info.php?action=update-site"> |
122 <form method="post" action="site-info.php?action=update-site"> |
121 <?php wp_nonce_field( 'edit-site' ); ?> |
123 <?php wp_nonce_field( 'edit-site' ); ?> |
122 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
124 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
123 <table class="form-table"> |
125 <table class="form-table"> |
124 <tr class="form-field form-required"> |
126 <tr class="form-field form-required"> |
125 <th scope="row"><?php _e( 'Domain' ) ?></th> |
127 <?php if ( $is_main_site ) { ?> |
126 <?php |
128 <th scope="row"><?php _e( 'Domain' ) ?></th> |
127 $protocol = is_ssl() ? 'https://' : 'http://'; |
129 <td><code><?php echo $parsed['scheme'] . '://' . esc_attr( $details->domain ) ?></code></td> |
128 if ( $is_main_site ) { ?> |
|
129 <td><code><?php echo $protocol; echo esc_attr( $details->domain ) ?></code></td> |
|
130 <?php } else { ?> |
130 <?php } else { ?> |
131 <td><?php echo $protocol; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" size="33" /></td> |
131 <th scope="row"><label for="domain"><?php _e( 'Domain' ) ?></label></th> |
|
132 <td><?php echo $parsed['scheme'] . '://'; ?><input name="blog[domain]" type="text" id="domain" value="<?php echo esc_attr( $details->domain ) ?>" /></td> |
132 <?php } ?> |
133 <?php } ?> |
133 </tr> |
134 </tr> |
134 <tr class="form-field form-required"> |
135 <tr class="form-field form-required"> |
|
136 <?php if ( $is_main_site ) { ?> |
135 <th scope="row"><?php _e( 'Path' ) ?></th> |
137 <th scope="row"><?php _e( 'Path' ) ?></th> |
136 <?php if ( $is_main_site ) { ?> |
|
137 <td><code><?php echo esc_attr( $details->path ) ?></code></td> |
138 <td><code><?php echo esc_attr( $details->path ) ?></code></td> |
138 <?php |
139 <?php |
139 } else { |
140 } else { |
140 switch_to_blog( $id ); |
141 switch_to_blog( $id ); |
141 ?> |
142 ?> |
142 <td><input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" size="40" style='margin-bottom:5px;' /> |
143 <th scope="row"><label for="path"><?php _e( 'Path' ) ?></label></th> |
143 <br /><input type="checkbox" style="width:20px;" name="update_home_url" value="update" <?php if ( get_option( 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_option( 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></td> |
144 <td> |
|
145 <input name="blog[path]" type="text" id="path" value="<?php echo esc_attr( $details->path ) ?>" /><br /> |
|
146 <input type="checkbox" name="update_home_url" id="update_home_url" value="update" <?php if ( get_option( 'siteurl' ) == untrailingslashit( get_blogaddress_by_id ($id ) ) || get_option( 'home' ) == untrailingslashit( get_blogaddress_by_id( $id ) ) ) echo 'checked="checked"'; ?> /> <label for="update_home_url"><?php _e( 'Update <code>siteurl</code> and <code>home</code> as well.' ); ?></label> |
|
147 </td> |
144 <?php |
148 <?php |
145 restore_current_blog(); |
149 restore_current_blog(); |
146 } ?> |
150 } ?> |
147 </tr> |
151 </tr> |
148 <tr class="form-field"> |
152 <tr class="form-field"> |
149 <th scope="row"><?php _ex( 'Registered', 'site' ) ?></th> |
153 <th scope="row"><label for="blog_registered"><?php _ex( 'Registered', 'site' ) ?></label></th> |
150 <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" size="40" /></td> |
154 <td><input name="blog[registered]" type="text" id="blog_registered" value="<?php echo esc_attr( $details->registered ) ?>" /></td> |
151 </tr> |
155 </tr> |
152 <tr class="form-field"> |
156 <tr class="form-field"> |
153 <th scope="row"><?php _e( 'Last Updated' ); ?></th> |
157 <th scope="row"><label for="blog_last_updated"><?php _e( 'Last Updated' ); ?></label></th> |
154 <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" size="40" /></td> |
158 <td><input name="blog[last_updated]" type="text" id="blog_last_updated" value="<?php echo esc_attr( $details->last_updated ) ?>" /></td> |
155 </tr> |
159 </tr> |
156 <?php |
160 <?php |
157 $attribute_fields = array( 'public' => __( 'Public' ) ); |
161 $attribute_fields = array( 'public' => __( 'Public' ) ); |
158 if ( ! $is_main_site ) { |
162 if ( ! $is_main_site ) { |
159 $attribute_fields['archived'] = __( 'Archived' ); |
163 $attribute_fields['archived'] = __( 'Archived' ); |