Make WordPress Core


Ignore:
Timestamp:
09/10/2015 09:44:29 PM (10 years ago)
Author:
wonderboymusic
Message:

Move ad hoc Options functions to wp-admin/includes/options.php:

  • Move options_discussion_add_js() from wp-admin/options-discussion.php
  • Move options_general_add_js() from wp-admin/options-general.php
  • Move options_permalink_add_js() from wp-admin/options-permalink.php
  • Move options_reading_add_js() from wp-admin/options-reading.php
  • Move options_reading_blog_charset() from wp-admin/options-reading.php

See #33813.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-general.php

    r33774 r34022  
    2121$timezone_format = _x('Y-m-d H:i:s', 'timezone date format');
    2222
    23 /**
    24  * Display JavaScript on the page.
    25  *
    26  * @since 3.5.0
    27  */
    28 function options_general_add_js() {
    29 ?>
    30 <script type="text/javascript">
    31     jQuery(document).ready(function($){
    32         var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
    33             homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
    34 
    35         $( '#blogname' ).on( 'input', function() {
    36             var title = $.trim( $( this ).val() ) || homeURL;
    37 
    38             // Truncate to 40 characters.
    39             if ( 40 < title.length ) {
    40                 title = title.substring( 0, 40 ) + '\u2026';
    41             }
    42 
    43             $siteName.text( title );
    44         });
    45 
    46         $("input[name='date_format']").click(function(){
    47             if ( "date_format_custom_radio" != $(this).attr("id") )
    48                 $( "input[name='date_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).text() );
    49         });
    50         $("input[name='date_format_custom']").focus(function(){
    51             $( '#date_format_custom_radio' ).prop( 'checked', true );
    52         });
    53 
    54         $("input[name='time_format']").click(function(){
    55             if ( "time_format_custom_radio" != $(this).attr("id") )
    56                 $( "input[name='time_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).text() );
    57         });
    58         $("input[name='time_format_custom']").focus(function(){
    59             $( '#time_format_custom_radio' ).prop( 'checked', true );
    60         });
    61         $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
    62             var format = $(this);
    63             format.siblings( '.spinner' ).addClass( 'is-active' );
    64             $.post(ajaxurl, {
    65                     action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
    66                     date : format.val()
    67                 }, function(d) { format.siblings( '.spinner' ).removeClass( 'is-active' ); format.siblings('.example').text(d); } );
    68         });
    69 
    70         var languageSelect = $( '#WPLANG' );
    71         $( 'form' ).submit( function() {
    72             // Don't show a spinner for English and installed languages,
    73             // as there is nothing to download.
    74             if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
    75                 $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
    76             }
    77         });
    78     });
    79 </script>
    80 <?php
    81 }
    8223add_action('admin_head', 'options_general_add_js');
    8324
Note: See TracChangeset for help on using the changeset viewer.