diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php
index 11c11cedf1..27ca2a1246 100644
--- a/wp-admin/admin-ajax.php
+++ b/wp-admin/admin-ajax.php
@@ -1463,6 +1463,12 @@ case 'set-post-thumbnail':
}
die( '0' );
break;
+case 'date_format' :
+ die( date_i18n( sanitize_option( 'date_format', $_POST['date'] ) ) );
+ break;
+case 'time_format' :
+ die( date_i18n( sanitize_option( 'time_format', $_POST['date'] ) ) );
+ break;
default :
do_action( 'wp_ajax_' . $_POST['action'] );
die('0');
diff --git a/wp-admin/options-general.php b/wp-admin/options-general.php
index 1aaee47230..ca4c70af38 100644
--- a/wp-admin/options-general.php
+++ b/wp-admin/options-general.php
@@ -30,7 +30,7 @@ function add_js() {
jQuery(document).ready(function($){
$("input[name='date_format']").click(function(){
if ( "date_format_custom_radio" != $(this).attr("id") )
- $("input[name='date_format_custom']").val( $(this).val() );
+ $("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='date_format_custom']").focus(function(){
$("#date_format_custom_radio").attr("checked", "checked");
@@ -38,11 +38,19 @@ function add_js() {
$("input[name='time_format']").click(function(){
if ( "time_format_custom_radio" != $(this).attr("id") )
- $("input[name='time_format_custom']").val( $(this).val() );
+ $("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='time_format_custom']").focus(function(){
$("#time_format_custom_radio").attr("checked", "checked");
});
+ $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
+ var format = $(this);
+ format.siblings('img').css('visibility','visible');
+ $.post(ajaxurl, {
+ action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
+ date : format.val(),
+ }, function(d) { format.siblings('img').css('visibility','hidden'); format.siblings('.example').text(d); } );
+ });
});
//]]>
@@ -265,14 +273,14 @@ if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
echo " checked='checked'";
$custom = false;
}
- echo ' /> ' . date_i18n( $format ) . "
\n";
+ echo ' /> ' . date_i18n( $format ) . "
\n";
}
echo ' ' . date_i18n( get_option('date_format') ) . "\n";
+ echo '/> ' . __('Custom:') . ' ' . date_i18n( get_option('date_format') ) . " \n";
- echo "\t
" . __('Documentation on date formatting. Click “Save Changes” to update sample output.') . "
\n"; + echo "\t" . __('Documentation on date and time formatting.') . "
\n"; ?> @@ -297,12 +305,13 @@ if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists echo " checked='checked'"; $custom = false; } - echo ' /> ' . date_i18n( $format ) . "