From 91950354e902ab61c00314af98171df9c697918f Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 13 Oct 2008 18:32:16 +0000 Subject: [PATCH] Date and time presets from Viper007Bond. see #7552 git-svn-id: http://svn.automattic.com/wordpress/trunk@9131 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/options-general.php | 95 ++++++++++++++++++++++++++++++++++-- wp-admin/options.php | 24 +++++---- 2 files changed, 105 insertions(+), 14 deletions(-) diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php index 3f1eef5e2..5d3d9c888 100644 --- a/wp-admin/options-general.php +++ b/wp-admin/options-general.php @@ -12,6 +12,39 @@ require_once('./admin.php'); $title = __('General Settings'); $parent_file = 'options-general.php'; +/** + * Display JavaScript on the page. + * + * @package WordPress + * @subpackage General_Settings_Panel + */ +function add_js() { +?> + + @@ -96,14 +129,66 @@ foreach ( $offset_range as $offset ) { -
- + +
+ ' . gmdate( $format, current_time('timestamp') ) . "
\n"; + } + + echo ' ' . gmdate( get_option('date_format'), current_time('timestamp') ) . "\n"; + + echo "\t

" . __('Documentation on date formatting. Click "Save Changes" to update sample output.') . "

\n"; +?> +
+ -
-
-Documentation on date formatting. Click "Save Changes" to update sample output.') ?> + +
+ ' . gmdate( $format, current_time('timestamp') ) . "
\n"; + } + + echo ' ' . gmdate( get_option('time_format'), current_time('timestamp') ) . "\n"; +?> +
+ diff --git a/wp-admin/options.php b/wp-admin/options.php index 6ecc496bc..8c9cbe2dd 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -41,33 +41,39 @@ if ( !current_user_can('manage_options') ) switch($action) { case 'update': - $any_changed = 0; - $option_page = $_POST[ 'option_page' ]; check_admin_referer( $option_page . '-options' ); if ( !isset( $whitelist_options[ $option_page ] ) ) wp_die( __( 'Error! Options page not found.' ) ); - if ( $option_page == 'options' ) { + if ( 'options' == $option_page ) { $options = explode(',', stripslashes( $_POST[ 'page_options' ] )); } else { $options = $whitelist_options[ $option_page ]; } - if ($options) { - foreach ($options as $option) { + // Handle custom date/time formats + if ( 'general' == $option_page ) { + if ( !empty($_POST['date_format']) && !empty($_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']) && !empty($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) ) + $_POST['time_format'] = $_POST['time_format_custom']; + } + + if ( $options ) { + foreach ( $options as $option ) { $option = trim($option); $value = $_POST[$option]; - if(!is_array($value)) $value = trim($value); + if ( !is_array($value) ) $value = trim($value); $value = stripslashes_deep($value); update_option($option, $value); } } - $goback = add_query_arg('updated', 'true', wp_get_referer()); - wp_redirect($goback); - break; + $goback = add_query_arg( 'updated', 'true', wp_get_referer() ); + wp_redirect( $goback ); + break; default: include('admin-header.php'); ?>