From b16a2c07c6e3f09e0e43cb76970ee7ec5097ef92 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 13 Oct 2008 18:32:16 +0000 Subject: [PATCH] Date and time presets from Viper007Bond. see #7552 git-svn-id: https://develop.svn.wordpress.org/trunk@9131 602fd350-edb4-49c9-b593-d223f7449a82 --- 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 3f1eef5e2a..5d3d9c8880 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 6ecc496bcb..8c9cbe2dd1 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'); ?>