- if ($options) {
- foreach ($options as $option) {
- $option = trim($option);
- $value = $_POST[$option];
- if(!is_array($value)) $value = trim($value);
- $value = stripslashes_deep($value);
- update_option($option, $value);
+ if ( !isset( $whitelist_options[ $option_page ] ) )
+ wp_die( __( '<strong>ERROR</strong>: options page not found.' ) );
+
+ if ( 'options' == $option_page ) {
+ if ( is_multisite() && ! is_super_admin() )
+ wp_die( __( 'You do not have sufficient permissions to modify unregistered settings for this site.' ) );
+ $options = explode( ',', stripslashes( $_POST[ 'page_options' ] ) );
+ } else {
+ $options = $whitelist_options[ $option_page ];
+ }
+
+ // Handle custom date/time formats
+ if ( 'general' == $option_page ) {
+ if ( !empty($_POST['date_format']) && isset($_POST['date_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['date_format'] ) )
+ $_POST['date_format'] = $_POST['date_format_custom'];
+ if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
+ $_POST['time_format'] = $_POST['time_format_custom'];
+ // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
+ if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
+ $_POST['gmt_offset'] = $_POST['timezone_string'];
+ $_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
+ $_POST['timezone_string'] = '';
+ }
+ }
+
+ if ( $options ) {
+ foreach ( $options as $option ) {
+ if ( $unregistered )
+ _deprecated_argument( 'options.php', '2.7', sprintf( __( 'The <code>%1$s</code> setting is unregistered. Unregistered settings are deprecated. See http://codex.wordpress.org/Settings_API' ), $option, $option_page ) );
+
+ $option = trim( $option );
+ $value = null;
+ if ( isset( $_POST[ $option ] ) ) {
+ $value = $_POST[ $option ];
+ if ( ! is_array( $value ) )
+ $value = trim( $value );
+ $value = stripslashes_deep( $value );
+ }
+ update_option( $option, $value );