8 */ |
8 */ |
9 |
9 |
10 /** Load WordPress Administration Bootstrap */ |
10 /** Load WordPress Administration Bootstrap */ |
11 require_once( dirname( __FILE__ ) . '/admin.php' ); |
11 require_once( dirname( __FILE__ ) . '/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 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); |
17 get_current_screen()->add_help_tab( get_site_screen_help_tab_args() ); |
17 get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); |
18 get_current_screen()->set_help_sidebar( get_site_screen_help_sidebar_content() ); |
18 |
19 |
19 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
20 $id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
20 |
21 |
21 if ( ! $id ) |
22 if ( ! $id ) { |
22 wp_die( __('Invalid site ID.') ); |
23 wp_die( __( 'Invalid site ID.' ) ); |
|
24 } |
23 |
25 |
24 $details = get_site( $id ); |
26 $details = get_site( $id ); |
25 if ( ! $details ) { |
27 if ( ! $details ) { |
26 wp_die( __( 'The requested site does not exist.' ) ); |
28 wp_die( __( 'The requested site does not exist.' ) ); |
27 } |
29 } |
28 |
30 |
29 if ( !can_edit_network( $details->site_id ) ) |
31 if ( ! can_edit_network( $details->site_id ) ) { |
30 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 } |
31 |
34 |
32 $is_main_site = is_main_site( $id ); |
35 $is_main_site = is_main_site( $id ); |
33 |
36 |
34 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'] ) ) { |
35 check_admin_referer( 'edit-site' ); |
38 check_admin_referer( 'edit-site' ); |
36 |
39 |
37 switch_to_blog( $id ); |
40 switch_to_blog( $id ); |
38 |
41 |
39 $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. |
40 foreach ( (array) $_POST['option'] as $key => $val ) { |
43 foreach ( (array) $_POST['option'] as $key => $val ) { |
41 $key = wp_unslash( $key ); |
44 $key = wp_unslash( $key ); |
42 $val = wp_unslash( $val ); |
45 $val = wp_unslash( $val ); |
43 if ( $key === 0 || is_array( $val ) || in_array($key, $skip_options) ) |
46 if ( $key === 0 || is_array( $val ) || in_array( $key, $skip_options ) ) { |
44 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 edit blog options |
|
48 } |
45 update_option( $key, $val ); |
49 update_option( $key, $val ); |
46 } |
50 } |
47 |
51 |
48 /** |
52 /** |
49 * Fires after the site options are updated. |
53 * Fires after the site options are updated. |
54 * @param int $id The ID of the site being updated. |
58 * @param int $id The ID of the site being updated. |
55 */ |
59 */ |
56 do_action( 'wpmu_update_blog_options', $id ); |
60 do_action( 'wpmu_update_blog_options', $id ); |
57 |
61 |
58 restore_current_blog(); |
62 restore_current_blog(); |
59 wp_redirect( add_query_arg( array( 'update' => 'updated', 'id' => $id ), 'site-settings.php') ); |
63 wp_redirect( |
|
64 add_query_arg( |
|
65 array( |
|
66 'update' => 'updated', |
|
67 'id' => $id, |
|
68 ), |
|
69 'site-settings.php' |
|
70 ) |
|
71 ); |
60 exit; |
72 exit; |
61 } |
73 } |
62 |
74 |
63 if ( isset($_GET['update']) ) { |
75 if ( isset( $_GET['update'] ) ) { |
64 $messages = array(); |
76 $messages = array(); |
65 if ( 'updated' == $_GET['update'] ) |
77 if ( 'updated' == $_GET['update'] ) { |
66 $messages[] = __('Site options updated.'); |
78 $messages[] = __( 'Site options updated.' ); |
|
79 } |
67 } |
80 } |
68 |
81 |
69 /* translators: %s: site name */ |
82 /* translators: %s: site name */ |
70 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); |
83 $title = sprintf( __( 'Edit Site: %s' ), esc_html( $details->blogname ) ); |
71 |
84 |
72 $parent_file = 'sites.php'; |
85 $parent_file = 'sites.php'; |
73 $submenu_file = 'sites.php'; |
86 $submenu_file = 'sites.php'; |
74 |
87 |
75 require( ABSPATH . 'wp-admin/admin-header.php' ); |
88 require( ABSPATH . 'wp-admin/admin-header.php' ); |
76 |
89 |
77 ?> |
90 ?> |
80 <h1 id="edit-site"><?php echo $title; ?></h1> |
93 <h1 id="edit-site"><?php echo $title; ?></h1> |
81 <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> |
94 <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> |
82 |
95 |
83 <?php |
96 <?php |
84 |
97 |
85 network_edit_site_nav( array( |
98 network_edit_site_nav( |
86 'blog_id' => $id, |
99 array( |
87 'selected' => 'site-settings' |
100 'blog_id' => $id, |
88 ) ); |
101 'selected' => 'site-settings', |
|
102 ) |
|
103 ); |
89 |
104 |
90 if ( ! empty( $messages ) ) { |
105 if ( ! empty( $messages ) ) { |
91 foreach ( $messages as $msg ) |
106 foreach ( $messages as $msg ) { |
92 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
107 echo '<div id="message" class="updated notice is-dismissible"><p>' . $msg . '</p></div>'; |
93 } ?> |
108 } |
|
109 } |
|
110 ?> |
94 <form method="post" action="site-settings.php?action=update-site"> |
111 <form method="post" action="site-settings.php?action=update-site"> |
95 <?php wp_nonce_field( 'edit-site' ); ?> |
112 <?php wp_nonce_field( 'edit-site' ); ?> |
96 <input type="hidden" name="id" value="<?php echo esc_attr( $id ) ?>" /> |
113 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" /> |
97 <table class="form-table"> |
114 <table class="form-table" role="presentation"> |
98 <?php |
115 <?php |
99 $blog_prefix = $wpdb->get_blog_prefix( $id ); |
116 $blog_prefix = $wpdb->get_blog_prefix( $id ); |
100 $sql = "SELECT * FROM {$blog_prefix}options |
117 $sql = "SELECT * FROM {$blog_prefix}options |
101 WHERE option_name NOT LIKE %s |
118 WHERE option_name NOT LIKE %s |
102 AND option_name NOT LIKE %s"; |
119 AND option_name NOT LIKE %s"; |
103 $query = $wpdb->prepare( $sql, |
120 $query = $wpdb->prepare( |
|
121 $sql, |
104 $wpdb->esc_like( '_' ) . '%', |
122 $wpdb->esc_like( '_' ) . '%', |
105 '%' . $wpdb->esc_like( 'user_roles' ) |
123 '%' . $wpdb->esc_like( 'user_roles' ) |
106 ); |
124 ); |
107 $options = $wpdb->get_results( $query ); |
125 $options = $wpdb->get_results( $query ); |
108 foreach ( $options as $option ) { |
126 foreach ( $options as $option ) { |
109 if ( $option->option_name == 'default_role' ) |
127 if ( $option->option_name == 'default_role' ) { |
110 $editblog_default_role = $option->option_value; |
128 $editblog_default_role = $option->option_value; |
|
129 } |
111 $disabled = false; |
130 $disabled = false; |
112 $class = 'all-options'; |
131 $class = 'all-options'; |
113 if ( is_serialized( $option->option_value ) ) { |
132 if ( is_serialized( $option->option_value ) ) { |
114 if ( is_serialized_string( $option->option_value ) ) { |
133 if ( is_serialized_string( $option->option_value ) ) { |
115 $option->option_value = esc_html( maybe_unserialize( $option->option_value ) ); |
134 $option->option_value = esc_html( maybe_unserialize( $option->option_value ) ); |
116 } else { |
135 } else { |
117 $option->option_value = 'SERIALIZED DATA'; |
136 $option->option_value = 'SERIALIZED DATA'; |
118 $disabled = true; |
137 $disabled = true; |
119 $class = 'all-options disabled'; |
138 $class = 'all-options disabled'; |
120 } |
139 } |
121 } |
140 } |
122 if ( strpos( $option->option_value, "\n" ) !== false ) { |
141 if ( strpos( $option->option_value, "\n" ) !== false ) { |
123 ?> |
142 ?> |
124 <tr class="form-field"> |
143 <tr class="form-field"> |
125 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></label></th> |
144 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ); ?>"><?php echo ucwords( str_replace( '_', ' ', $option->option_name ) ); ?></label></th> |
126 <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> |
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> |
127 </tr> |
146 </tr> |
128 <?php |
147 <?php |
129 } else { |
148 } else { |
130 ?> |
149 ?> |
131 <tr class="form-field"> |
150 <tr class="form-field"> |
132 <th scope="row"><label for="<?php echo esc_attr( $option->option_name ) ?>"><?php echo esc_html( ucwords( str_replace( "_", " ", $option->option_name ) ) ); ?></label></th> |
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> |
133 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> |
152 <?php if ( $is_main_site && in_array( $option->option_name, array( 'siteurl', 'home' ) ) ) { ?> |
134 <td><code><?php echo esc_html( $option->option_value ) ?></code></td> |
153 <td><code><?php echo esc_html( $option->option_value ); ?></code></td> |
135 <?php } else { ?> |
154 <?php } else { ?> |
136 <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> |
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> |
137 <?php } ?> |
156 <?php } ?> |
138 </tr> |
157 </tr> |
139 <?php |
158 <?php |
140 } |
159 } |
141 } // End foreach |
160 } // End foreach |
142 /** |
161 /** |
143 * Fires at the end of the Edit Site form, before the submit button. |
162 * Fires at the end of the Edit Site form, before the submit button. |
144 * |
163 * |