6 * @subpackage Multisite |
6 * @subpackage Multisite |
7 * @since 3.1.0 |
7 * @since 3.1.0 |
8 */ |
8 */ |
9 |
9 |
10 /** Load WordPress Administration Bootstrap */ |
10 /** Load WordPress Administration Bootstrap */ |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 require_once __DIR__ . '/admin.php'; |
12 |
12 |
13 if ( ! current_user_can( 'manage_sites' ) ) { |
13 if ( ! current_user_can( 'manage_sites' ) ) { |
14 wp_die( __( 'Sorry, you are not allowed to edit this site.' ) ); |
14 wp_die( __( 'Sorry, you are not allowed to edit this site.' ) ); |
15 } |
15 } |
16 |
16 |
32 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
32 wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); |
33 } |
33 } |
34 |
34 |
35 $is_main_site = is_main_site( $id ); |
35 $is_main_site = is_main_site( $id ); |
36 |
36 |
37 if ( isset( $_REQUEST['action'] ) && 'update-site' == $_REQUEST['action'] && is_array( $_POST['option'] ) ) { |
37 if ( isset( $_REQUEST['action'] ) && 'update-site' === $_REQUEST['action'] && is_array( $_POST['option'] ) ) { |
38 check_admin_referer( 'edit-site' ); |
38 check_admin_referer( 'edit-site' ); |
39 |
39 |
40 switch_to_blog( $id ); |
40 switch_to_blog( $id ); |
41 |
41 |
42 $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form. |
42 $skip_options = array( 'allowedthemes' ); // Don't update these options since they are handled elsewhere in the form. |
43 foreach ( (array) $_POST['option'] as $key => $val ) { |
43 foreach ( (array) $_POST['option'] as $key => $val ) { |
44 $key = wp_unslash( $key ); |
44 $key = wp_unslash( $key ); |
45 $val = wp_unslash( $val ); |
45 $val = wp_unslash( $val ); |
46 if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options ) ) { |
46 if ( 0 === $key || is_array( $val ) || in_array( $key, $skip_options, true ) ) { |
47 continue; // Avoids "0 is a protected WP option and may not be modified" error when edit blog options |
47 continue; // Avoids "0 is a protected WP option and may not be modified" error when editing blog options. |
48 } |
48 } |
49 update_option( $key, $val ); |
49 update_option( $key, $val ); |
50 } |
50 } |
51 |
51 |
52 /** |
52 /** |
72 exit; |
72 exit; |
73 } |
73 } |
74 |
74 |
75 if ( isset( $_GET['update'] ) ) { |
75 if ( isset( $_GET['update'] ) ) { |
76 $messages = array(); |
76 $messages = array(); |
77 if ( 'updated' == $_GET['update'] ) { |
77 if ( 'updated' === $_GET['update'] ) { |
78 $messages[] = __( 'Site options updated.' ); |
78 $messages[] = __( 'Site options updated.' ); |
79 } |
79 } |
80 } |
80 } |
81 |
81 |
82 /* translators: %s: site name */ |
82 /* translators: %s: Site title. */ |
83 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); |
83 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); |
84 |
84 |
85 $parent_file = 'sites.php'; |
85 $parent_file = 'sites.php'; |
86 $submenu_file = 'sites.php'; |
86 $submenu_file = 'sites.php'; |
87 |
87 |
88 require( ABSPATH . 'wp-admin/admin-header.php' ); |
88 require_once ABSPATH . 'wp-admin/admin-header.php'; |
89 |
89 |
90 ?> |
90 ?> |
91 |
91 |
92 <div class="wrap"> |
92 <div class="wrap"> |
93 <h1 id="edit-site"><?php echo $title; ?></h1> |
93 <h1 id="edit-site"><?php echo $title; ?></h1> |
121 $sql, |
121 $sql, |
122 $wpdb->esc_like( '_' ) . '%', |
122 $wpdb->esc_like( '_' ) . '%', |
123 '%' . $wpdb->esc_like( 'user_roles' ) |
123 '%' . $wpdb->esc_like( 'user_roles' ) |
124 ); |
124 ); |
125 $options = $wpdb->get_results( $query ); |
125 $options = $wpdb->get_results( $query ); |
|
126 |
126 foreach ( $options as $option ) { |
127 foreach ( $options as $option ) { |
127 if ( $option->option_name == 'default_role' ) { |
128 if ( 'default_role' === $option->option_name ) { |
128 $editblog_default_role = $option->option_value; |
129 $editblog_default_role = $option->option_value; |
129 } |
130 } |
|
131 |
130 $disabled = false; |
132 $disabled = false; |
131 $class = 'all-options'; |
133 $class = 'all-options'; |
|
134 |
132 if ( is_serialized( $option->option_value ) ) { |
135 if ( is_serialized( $option->option_value ) ) { |
133 if ( is_serialized_string( $option->option_value ) ) { |
136 if ( is_serialized_string( $option->option_value ) ) { |
134 $option->option_value = esc_html( maybe_unserialize( $option->option_value ) ); |
137 $option->option_value = esc_html( maybe_unserialize( $option->option_value ) ); |
135 } else { |
138 } else { |
136 $option->option_value = 'SERIALIZED DATA'; |
139 $option->option_value = 'SERIALIZED DATA'; |
137 $disabled = true; |
140 $disabled = true; |
138 $class = 'all-options disabled'; |
141 $class = 'all-options disabled'; |
139 } |
142 } |
140 } |
143 } |
|
144 |
141 if ( strpos( $option->option_value, "\n" ) !== false ) { |
145 if ( strpos( $option->option_value, "\n" ) !== false ) { |
142 ?> |
146 ?> |
143 <tr class="form-field"> |
147 <tr class="form-field"> |
144 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th> |
148 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th> |
145 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td> |
149 <td><textarea class="<?php echo $class; ?>" rows="5" cols="40" name="option[<?php echo esc_attr( $option->option_name ); ?>]" id="<?php echo esc_attr( $option->option_name ); ?>"<?php disabled( $disabled ); ?>><?php echo esc_textarea( $option->option_value ); ?></textarea></td> |
147 <?php |
151 <?php |
148 } else { |
152 } else { |
149 ?> |
153 ?> |
150 <tr class="form-field"> |
154 <tr class="form-field"> |
151 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th> |
155 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo esc_html( ucwords( str_replace( '_', ' ', $option->option_name ) ) ); ?></label></th> |
152 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> |
156 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ), true ) ) { ?> |
153 <td><code><?php echo esc_html( $option->option_value ); ?></code></td> |
157 <td><code><?php echo esc_html( $option->option_value ); ?></code></td> |
154 <?php } else { ?> |
158 <?php } else { ?> |
155 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td> |
159 <td><input class="<?php echo $class; ?>" name="option[<?php echo esc_attr( $option->option_name ); ?>]" type="text" id="<?php echo esc_attr( $option->option_name ); ?>" value="<?php echo esc_attr( $option->option_value ); ?>" size="40" <?php disabled( $disabled ); ?> /></td> |
156 <?php } ?> |
160 <?php } ?> |
157 </tr> |
161 </tr> |
158 <?php |
162 <?php |
159 } |
163 } |
160 } // End foreach |
164 } // End foreach. |
|
165 |
161 /** |
166 /** |
162 * Fires at the end of the Edit Site form, before the submit button. |
167 * Fires at the end of the Edit Site form, before the submit button. |
163 * |
168 * |
164 * @since 3.0.0 |
169 * @since 3.0.0 |
165 * |
170 * |