21 // Used in the HTML title tag. |
21 // Used in the HTML title tag. |
22 $title = __( 'Settings' ); |
22 $title = __( 'Settings' ); |
23 $this_file = 'options.php'; |
23 $this_file = 'options.php'; |
24 $parent_file = 'options-general.php'; |
24 $parent_file = 'options-general.php'; |
25 |
25 |
26 wp_reset_vars( array( 'action', 'option_page' ) ); |
26 $action = ! empty( $_REQUEST['action'] ) ? sanitize_text_field( $_REQUEST['action'] ) : ''; |
|
27 $option_page = ! empty( $_REQUEST['option_page'] ) ? sanitize_text_field( $_REQUEST['option_page'] ) : ''; |
27 |
28 |
28 $capability = 'manage_options'; |
29 $capability = 'manage_options'; |
29 |
30 |
30 // This is for back compat and will eventually be removed. |
31 // This is for back compat and will eventually be removed. |
31 if ( empty( $option_page ) ) { |
32 if ( empty( $option_page ) ) { |
156 $allowed_options['options'] = array(); |
158 $allowed_options['options'] = array(); |
157 $allowed_options['privacy'] = array(); |
159 $allowed_options['privacy'] = array(); |
158 |
160 |
159 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); |
161 $mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' ); |
160 |
162 |
161 if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) { |
163 if ( ! is_utf8_charset() ) { |
162 $allowed_options['reading'][] = 'blog_charset'; |
164 $allowed_options['reading'][] = 'blog_charset'; |
163 } |
165 } |
164 |
166 |
165 if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
167 if ( get_site_option( 'initial_db_version' ) < 32453 ) { |
166 $allowed_options['writing'][] = 'use_smilies'; |
168 $allowed_options['writing'][] = 'use_smilies'; |
177 |
179 |
178 $allowed_options['general'][] = 'users_can_register'; |
180 $allowed_options['general'][] = 'users_can_register'; |
179 $allowed_options['general'][] = 'default_role'; |
181 $allowed_options['general'][] = 'default_role'; |
180 |
182 |
181 $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); |
183 $allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options ); |
182 $allowed_options['writing'][] = 'ping_sites'; |
184 if ( '1' === get_option( 'blog_public' ) ) { |
|
185 $allowed_options['writing'][] = 'ping_sites'; |
|
186 } |
183 |
187 |
184 $allowed_options['media'][] = 'uploads_use_yearmonth_folders'; |
188 $allowed_options['media'][] = 'uploads_use_yearmonth_folders'; |
185 |
189 |
186 /* |
190 /* |
187 * If upload_url_path is not the default (empty), |
191 * If upload_url_path is not the default (empty), |
243 |
247 |
244 if ( ! isset( $allowed_options[ $option_page ] ) ) { |
248 if ( ! isset( $allowed_options[ $option_page ] ) ) { |
245 wp_die( |
249 wp_die( |
246 sprintf( |
250 sprintf( |
247 /* translators: %s: The options page name. */ |
251 /* translators: %s: The options page name. */ |
248 __( '<strong>Error</strong>: Options page %s not found in the allowed options list.' ), |
252 __( '<strong>Error:</strong> The %s options page is not in the allowed options list.' ), |
249 '<code>' . esc_html( $option_page ) . '</code>' |
253 '<code>' . esc_html( $option_page ) . '</code>' |
250 ) |
254 ) |
251 ); |
255 ); |
252 } |
256 } |
253 |
257 |
277 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
281 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty. |
278 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { |
282 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', $_POST['timezone_string'] ) ) { |
279 $_POST['gmt_offset'] = $_POST['timezone_string']; |
283 $_POST['gmt_offset'] = $_POST['timezone_string']; |
280 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); |
284 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', $_POST['gmt_offset'] ); |
281 $_POST['timezone_string'] = ''; |
285 $_POST['timezone_string'] = ''; |
|
286 } elseif ( isset( $_POST['timezone_string'] ) && ! in_array( $_POST['timezone_string'], timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) { |
|
287 // Reset to the current value. |
|
288 $current_timezone_string = get_option( 'timezone_string' ); |
|
289 |
|
290 if ( ! empty( $current_timezone_string ) ) { |
|
291 $_POST['timezone_string'] = $current_timezone_string; |
|
292 } else { |
|
293 $_POST['gmt_offset'] = get_option( 'gmt_offset' ); |
|
294 $_POST['timezone_string'] = ''; |
|
295 } |
|
296 |
|
297 add_settings_error( |
|
298 'general', |
|
299 'settings_updated', |
|
300 __( 'The timezone you have entered is not valid. Please select a valid timezone.' ), |
|
301 'error' |
|
302 ); |
282 } |
303 } |
283 |
304 |
284 // Handle translation installation. |
305 // Handle translation installation. |
285 if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) { |
306 if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) { |
286 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; |
307 require_once ABSPATH . 'wp-admin/includes/translation-install.php'; |
301 if ( $unregistered ) { |
322 if ( $unregistered ) { |
302 _deprecated_argument( |
323 _deprecated_argument( |
303 'options.php', |
324 'options.php', |
304 '2.7.0', |
325 '2.7.0', |
305 sprintf( |
326 sprintf( |
306 /* translators: %s: The option/setting. */ |
327 /* translators: 1: The option/setting, 2: Documentation URL. */ |
307 __( 'The %s setting is unregistered. Unregistered settings are deprecated. See https://developer.wordpress.org/plugins/settings/settings-api/' ), |
328 __( 'The %1$s setting is unregistered. Unregistered settings are deprecated. See <a href="%2$s">documentation on the Settings API</a>.' ), |
308 '<code>' . esc_html( $option ) . '</code>' |
329 '<code>' . esc_html( $option ) . '</code>', |
|
330 __( 'https://developer.wordpress.org/plugins/settings/settings-api/' ) |
309 ) |
331 ) |
310 ); |
332 ); |
311 } |
333 } |
312 |
334 |
313 $option = trim( $option ); |
335 $option = trim( $option ); |
342 |
364 |
343 // If no settings errors were registered add a general 'updated' message. |
365 // If no settings errors were registered add a general 'updated' message. |
344 if ( ! count( get_settings_errors() ) ) { |
366 if ( ! count( get_settings_errors() ) ) { |
345 add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' ); |
367 add_settings_error( 'general', 'settings_updated', __( 'Settings saved.' ), 'success' ); |
346 } |
368 } |
347 set_transient( 'settings_errors', get_settings_errors(), 30 ); |
369 |
|
370 set_transient( 'settings_errors', get_settings_errors(), 30 ); // 30 seconds. |
348 |
371 |
349 // Redirect back to the settings page that was submitted. |
372 // Redirect back to the settings page that was submitted. |
350 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
373 $goback = add_query_arg( 'settings-updated', 'true', wp_get_referer() ); |
351 wp_redirect( $goback ); |
374 wp_redirect( $goback ); |
352 exit; |
375 exit; |
353 } |
376 } |
354 |
377 |
355 require_once ABSPATH . 'wp-admin/admin-header.php'; ?> |
378 require_once ABSPATH . 'wp-admin/admin-header.php'; |
|
379 ?> |
356 |
380 |
357 <div class="wrap"> |
381 <div class="wrap"> |
358 <h1><?php esc_html_e( 'All Settings' ); ?></h1> |
382 <h1><?php esc_html_e( 'All Settings' ); ?></h1> |
359 |
383 |
360 <div class="notice notice-warning"> |
384 <?php |
361 <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> |
385 wp_admin_notice( |
362 </div> |
386 '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This page allows direct access to your site settings. You can break things here. Please be cautious!' ), |
363 |
387 array( |
|
388 'type' => 'warning', |
|
389 ) |
|
390 ); |
|
391 ?> |
364 <form name="form" action="options.php" method="post" id="all-options"> |
392 <form name="form" action="options.php" method="post" id="all-options"> |
365 <?php wp_nonce_field( 'options-options' ); ?> |
393 <?php wp_nonce_field( 'options-options' ); ?> |
366 <input type="hidden" name="action" value="update" /> |
394 <input type="hidden" name="action" value="update" /> |
367 <input type="hidden" name="option_page" value="options" /> |
395 <input type="hidden" name="option_page" value="options" /> |
368 <table class="form-table" role="presentation"> |
396 <table class="form-table" role="presentation"> |
396 $name = esc_attr( $option->option_name ); |
424 $name = esc_attr( $option->option_name ); |
397 ?> |
425 ?> |
398 <tr> |
426 <tr> |
399 <th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th> |
427 <th scope="row"><label for="<?php echo $name; ?>"><?php echo esc_html( $option->option_name ); ?></label></th> |
400 <td> |
428 <td> |
401 <?php if ( strpos( $value, "\n" ) !== false ) : ?> |
429 <?php if ( str_contains( $value, "\n" ) ) : ?> |
402 <textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"><?php echo esc_textarea( $value ); ?></textarea> |
430 <textarea class="<?php echo $class; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" cols="30" rows="5"><?php echo esc_textarea( $value ); ?></textarea> |
403 <?php else : ?> |
431 <?php else : ?> |
404 <input class="regular-text <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>"<?php disabled( $disabled, true ); ?> /> |
432 <input class="regular-text <?php echo $class; ?>" type="text" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr( $value ); ?>"<?php disabled( $disabled, true ); ?> /> |
405 <?php endif; ?></td> |
433 <?php endif; ?></td> |
406 </tr> |
434 </tr> |