144 'default_email_category', |
144 'default_email_category', |
145 'default_link_category', |
145 'default_link_category', |
146 'default_post_format', |
146 'default_post_format', |
147 ), |
147 ), |
148 ); |
148 ); |
149 $whitelist_options['misc'] = $whitelist_options['options'] = $whitelist_options['privacy'] = array(); |
149 $allowed_options['misc'] = array(); |
|
150 $allowed_options['options'] = array(); |
|
151 $allowed_options['privacy'] = array(); |
150 |
152 |
151 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); |
153 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); |
152 |
154 |
153 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ) ) ) { |
155 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) { |
154 $whitelist_options['reading'][] = 'blog_charset'; |
156 $allowed_options['reading'][] = 'blog_charset'; |
155 } |
157 } |
156 |
158 |
157 if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
159 if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
158 $whitelist_options['writing'][] = 'use_smilies'; |
160 $allowed_options['writing'][] = 'use_smilies'; |
159 $whitelist_options['writing'][] = 'use_balanceTags'; |
161 $allowed_options['writing'][] = 'use_balanceTags'; |
160 } |
162 } |
161 |
163 |
162 if ( ! is_multisite() ) { |
164 if ( ! is_multisite() ) { |
163 if ( ! defined( 'WP_SITEURL' ) ) { |
165 if ( ! defined( 'WP_SITEURL' ) ) { |
164 $whitelist_options['general'][] = 'siteurl'; |
166 $allowed_options['general'][] = 'siteurl'; |
165 } |
167 } |
166 if ( ! defined( 'WP_HOME' ) ) { |
168 if ( ! defined( 'WP_HOME' ) ) { |
167 $whitelist_options['general'][] = 'home'; |
169 $allowed_options['general'][] = 'home'; |
168 } |
170 } |
169 |
171 |
170 $whitelist_options['general'][] = 'users_can_register'; |
172 $allowed_options['general'][] = 'users_can_register'; |
171 $whitelist_options['general'][] = 'default_role'; |
173 $allowed_options['general'][] = 'default_role'; |
172 |
174 |
173 $whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options ); |
175 $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); |
174 $whitelist_options['writing'][] = 'ping_sites'; |
176 $allowed_options['writing'][] = 'ping_sites'; |
175 |
177 |
176 $whitelist_options['media'][] = 'uploads_use_yearmonth_folders'; |
178 $allowed_options['media'][] = 'uploads_use_yearmonth_folders'; |
177 |
179 |
178 // If upload_url_path and upload_path are both default values, they're locked. |
180 /* |
|
181 * If upload_url_path is not the default (empty), |
|
182 * or upload_path is not the default ('wp-content/uploads' or empty), |
|
183 * they can be edited, otherwise they're locked. |
|
184 */ |
179 if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) { |
185 if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) { |
180 $whitelist_options['media'][] = 'upload_path'; |
186 $allowed_options['media'][] = 'upload_path'; |
181 $whitelist_options['media'][] = 'upload_url_path'; |
187 $allowed_options['media'][] = 'upload_url_path'; |
182 } |
188 } |
183 } else { |
189 } else { |
184 /** |
190 /** |
185 * Filters whether the post-by-email functionality is enabled. |
191 * Filters whether the post-by-email functionality is enabled. |
186 * |
192 * |
187 * @since 3.0.0 |
193 * @since 3.0.0 |
188 * |
194 * |
189 * @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
195 * @param bool $enabled Whether post-by-email configuration is enabled. Default true. |
190 */ |
196 */ |
191 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { |
197 if ( apply_filters( 'enable_post_by_email_configuration', true ) ) { |
192 $whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options ); |
198 $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); |
193 } |
199 } |
194 } |
200 } |
195 |
201 |
196 /** |
202 /** |
197 * Filters the options white list. |
203 * Filters the allowed options list. |
198 * |
204 * |
199 * @since 2.7.0 |
205 * @since 2.7.0 |
200 * |
206 * @deprecated 5.5.0 Use {@see 'allowed_options'} instead. |
201 * @param array $whitelist_options White list options. |
207 * |
|
208 * @param array $allowed_options The allowed options list. |
202 */ |
209 */ |
203 $whitelist_options = apply_filters( 'whitelist_options', $whitelist_options ); |
210 $allowed_options = apply_filters_deprecated( |
204 |
211 'whitelist_options', |
205 /* |
212 array( $allowed_options ), |
206 * If $_GET['action'] == 'update' we are saving settings sent from a settings page |
213 '5.5.0', |
|
214 'apply_filters_deprecated', |
|
215 __( 'Please consider writing more inclusive code.' ) |
|
216 ); |
|
217 |
|
218 /** |
|
219 * Filters the allowed options list. |
|
220 * |
|
221 * @since 5.5.0 |
|
222 * |
|
223 * @param array $allowed_options The allowed options list. |
207 */ |
224 */ |
208 if ( 'update' == $action ) { |
225 $allowed_options = apply_filters( 'allowed_options', $allowed_options ); |
209 if ( 'options' == $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. |
226 |
|
227 if ( 'update' === $action ) { // We are saving settings sent from a settings page. |
|
228 if ( 'options' === $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed. |
210 $unregistered = true; |
229 $unregistered = true; |
211 check_admin_referer( 'update-options' ); |
230 check_admin_referer( 'update-options' ); |
212 } else { |
231 } else { |
213 $unregistered = false; |
232 $unregistered = false; |
214 check_admin_referer( $option_page . '-options' ); |
233 check_admin_referer( $option_page . '-options' ); |
215 } |
234 } |
216 |
235 |
217 if ( ! isset( $whitelist_options[ $option_page ] ) ) { |
236 if ( ! isset( $allowed_options[ $option_page ] ) ) { |
218 wp_die( __( '<strong>ERROR</strong>: options page not found.' ) ); |
237 wp_die( |
219 } |
238 sprintf( |
220 |
239 /* translators: %s: The options page name. */ |
221 if ( 'options' == $option_page ) { |
240 __( '<strong>Error</strong>: Options page %s not found in the allowed options list.' ), |
|
241 '<code>' . esc_html( $option_page ) . '</code>' |
|
242 ) |
|
243 ); |
|
244 } |
|
245 |
|
246 if ( 'options' === $option_page ) { |
222 if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) { |
247 if ( is_multisite() && ! current_user_can( 'manage_network_options' ) ) { |
223 wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); |
248 wp_die( __( 'Sorry, you are not allowed to modify unregistered settings for this site.' ) ); |
224 } |
249 } |
225 $options = explode( ',', wp_unslash( $_POST['page_options'] ) ); |
250 $options = explode( ',', wp_unslash( $_POST['page_options'] ) ); |
226 } else { |
251 } else { |
227 $options = $whitelist_options[ $option_page ]; |
252 $options = $allowed_options[ $option_page ]; |
228 } |
253 } |
229 |
254 |
230 if ( 'general' == $option_page ) { |
255 if ( 'general' === $option_page ) { |
231 // Handle custom date/time formats. |
256 // Handle custom date/time formats. |
232 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['date_format'] ) ) { |
257 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] ) |
|
258 && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] ) |
|
259 ) { |
233 $_POST['date_format'] = $_POST['date_format_custom']; |
260 $_POST['date_format'] = $_POST['date_format_custom']; |
234 } |
261 } |
235 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) && '\c\u\s\t\o\m' == wp_unslash( $_POST['time_format'] ) ) { |
262 |
|
263 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] ) |
|
264 && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] ) |
|
265 ) { |
236 $_POST['time_format'] = $_POST['time_format_custom']; |
266 $_POST['time_format'] = $_POST['time_format_custom']; |
237 } |
267 } |
|
268 |
238 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
269 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
239 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { |
270 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { |
240 $_POST['gmt_offset'] = $_POST['timezone_string']; |
271 $_POST['gmt_offset'] = $_POST['timezone_string']; |
241 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); |
272 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); |
242 $_POST['timezone_string'] = ''; |
273 $_POST['timezone_string'] = ''; |
243 } |
274 } |
244 |
275 |
245 // Handle translation installation. |
276 // Handle translation installation. |
246 if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) { |
277 if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) { |
247 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
278 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; |
248 |
279 |
249 if ( wp_can_install_language_pack() ) { |
280 if ( wp_can_install_language_pack() ) { |
250 $language = wp_download_language_pack( $_POST['WPLANG'] ); |
281 $language = wp_download_language_pack( $_POST['WPLANG'] ); |
251 if ( $language ) { |
282 if ( $language ) { |
252 $_POST['WPLANG'] = $language; |
283 $_POST['WPLANG'] = $language; |
293 if ( $user_language_old !== $user_language_new ) { |
324 if ( $user_language_old !== $user_language_new ) { |
294 load_default_textdomain( $user_language_new ); |
325 load_default_textdomain( $user_language_new ); |
295 } |
326 } |
296 } |
327 } |
297 |
328 |
298 /** |
329 /* |
299 * Handle settings errors and return to options page |
330 * Handle settings errors and return to options page. |
300 */ |
331 */ |
|
332 |
301 // If no settings errors were registered add a general 'updated' message. |
333 // If no settings errors were registered add a general 'updated' message. |
302 if ( ! count( get_settings_errors() ) ) { |
334 if ( ! count( get_settings_errors() ) ) { |
303 add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'updated' ); |
335 add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' ); |
304 } |
336 } |
305 set_transient( 'settings_errors', get_settings_errors(), 30 ); |
337 set_transient( 'settings_errors', get_settings_errors(), 30 ); |
306 |
338 |
307 /** |
339 // Redirect back to the settings page that was submitted. |
308 * Redirect back to the settings page that was submitted |
|
309 */ |
|
310 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
340 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
311 wp_redirect( $goback ); |
341 wp_redirect( $goback ); |
312 exit; |
342 exit; |
313 } |
343 } |
314 |
344 |
315 include( ABSPATH . 'wp-admin/admin-header.php' ); ?> |
345 require_once ABSPATH . 'wp-admin/admin-header.php'; ?> |
316 |
346 |
317 <div class="wrap"> |
347 <div class="wrap"> |
318 <h1><?php esc_html_e( 'All Settings' ); ?></h1> |
348 <h1><?php esc_html_e( 'All Settings' ); ?></h1> |
|
349 |
|
350 <div class="notice notice-warning"> |
|
351 <p><strong><?php _e( 'Warning:' ); ?></strong> <?php _e( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ); ?></p> |
|
352 </div> |
|
353 |
319 <form name="form" action="options.php" method="post" id="all-options"> |
354 <form name="form" action="options.php" method="post" id="all-options"> |
320 <?php wp_nonce_field( 'options-options' ); ?> |
355 <?php wp_nonce_field( 'options-options' ); ?> |
321 <input type="hidden" name="action" value="update" /> |
356 <input type="hidden" name="action" value="update" /> |
322 <input type="hidden" name="option_page" value="options" /> |
357 <input type="hidden" name="option_page" value="options" /> |
323 <table class="form-table" role="presentation"> |
358 <table class="form-table" role="presentation"> |
324 <?php |
359 <?php |
325 $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
360 $options = $wpdb->get_results( "SELECT * FROM $wpdb->options ORDER BY option_name" ); |
326 |
361 |
327 foreach ( (array) $options as $option ) : |
362 foreach ( (array) $options as $option ) : |
328 $disabled = false; |
363 $disabled = false; |
329 if ( $option->option_name == '' ) { |
364 |
|
365 if ( '' === $option->option_name ) { |
330 continue; |
366 continue; |
331 } |
367 } |
|
368 |
332 if ( is_serialized( $option->option_value ) ) { |
369 if ( is_serialized( $option->option_value ) ) { |
333 if ( is_serialized_string( $option->option_value ) ) { |
370 if ( is_serialized_string( $option->option_value ) ) { |
334 // This is a serialized string, so we should display it. |
371 // This is a serialized string, so we should display it. |
335 $value = maybe_unserialize( $option->option_value ); |
372 $value = maybe_unserialize( $option->option_value ); |
336 $options_to_update[] = $option->option_name; |
373 $options_to_update[] = $option->option_name; |