Make WordPress Core

Ticket #12636: 12636.diff

File 12636.diff, 4.1 KB (added by nacin, 13 years ago)

Proof of concept.

  • wp-admin/admin-ajax.php

     
    14221422        update_post_meta( $link_id, '_menu_item_url', $link_url );
    14231423
    14241424        die( json_encode($link_id) );
     1425case 'date_i18n' :
     1426        $return = date_i18n( $_POST['date'] );
     1427        die( $return );
     1428        break;
    14251429default :
    14261430        do_action( 'wp_ajax_' . $_POST['action'] );
    14271431        die('0');
  • wp-admin/options-general.php

     
    3030        jQuery(document).ready(function($){
    3131                $("input[name='date_format']").click(function(){
    3232                        if ( "date_format_custom_radio" != $(this).attr("id") )
    33                                 $("input[name='date_format_custom']").val( $(this).val() );
     33                                $("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
    3434                });
    3535                $("input[name='date_format_custom']").focus(function(){
    3636                        $("#date_format_custom_radio").attr("checked", "checked");
     
    3838
    3939                $("input[name='time_format']").click(function(){
    4040                        if ( "time_format_custom_radio" != $(this).attr("id") )
    41                                 $("input[name='time_format_custom']").val( $(this).val() );
     41                                $("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
    4242                });
    4343                $("input[name='time_format_custom']").focus(function(){
    4444                        $("#time_format_custom_radio").attr("checked", "checked");
    4545                });
     46                $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
     47                        var format = $(this);
     48                        format.siblings('img').css('visibility','visible');
     49                        $.post(ajaxurl, {
     50                                        action: 'date_i18n',
     51                                        date : format.val(),
     52                                }, function(d) { format.siblings('.example').text(d); format.siblings('img').css('visibility','hidden'); } );   
     53                });
    4654        });
    4755//]]>
    4856</script>
     
    255263                        echo " checked='checked'";
    256264                        $custom = false;
    257265                }
    258                 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
     266                echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
    259267        }
    260268
    261269        echo '  <label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
    262270        checked( $custom );
    263         echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( get_option('date_format') ) . '" class="small-text" /> ' . date_i18n( get_option('date_format') ) . "\n";
     271        echo '/> ' . __('Custom:') . ' </label><input type="text" name="date_format_custom" value="' . esc_attr( get_option('date_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('date_format') ) . "</span> <img style='visibility:hidden' src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' />\n";
    264272
    265         echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date formatting</a>. Click &#8220;Save Changes&#8221; to update sample output.') . "</p>\n";
     273        echo "\t<p>" . __('<a href="http://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.') . "</p>\n";
    266274?>
    267275        </fieldset>
    268276</td>
     
    287295                        echo " checked='checked'";
    288296                        $custom = false;
    289297                }
    290                 echo ' /> ' . date_i18n( $format ) . "</label><br />\n";
     298                echo ' /> <span>' . date_i18n( $format ) . "</span></label><br />\n";
    291299        }
    292300
    293301        echo '  <label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
    294302        checked( $custom );
    295         echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( get_option('time_format') ) . '" class="small-text" /> ' . date_i18n( get_option('time_format') ) . "\n";
     303        echo '/> ' . __('Custom:') . ' </label><input type="text" name="time_format_custom" value="' . esc_attr( get_option('time_format') ) . '" class="small-text" /> <span class="example"> ' . date_i18n( get_option('time_format') ) . "</span> <img style='visibility:hidden' src='" . esc_url( admin_url( 'images/wpspin_light.gif' ) ) . "' />\n";
     304        ;
    296305?>
    297306        </fieldset>
    298307</td>