[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> options.php (source)

   1  <?php
   2  /**
   3   * WordPress Options Administration API.
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 4.4.0
   8   */
   9  
  10  /**
  11   * Output JavaScript to toggle display of additional settings if avatars are disabled.
  12   *
  13   * @since 4.2.0
  14   */
  15  function options_discussion_add_js() {
  16      ?>
  17      <script>
  18      (function($){
  19          var parent = $( '#show_avatars' ),
  20              children = $( '.avatar-settings' );
  21          parent.change(function(){
  22              children.toggleClass( 'hide-if-js', ! this.checked );
  23          });
  24      })(jQuery);
  25      </script>
  26      <?php
  27  }
  28  
  29  /**
  30   * Display JavaScript on the page.
  31   *
  32   * @since 3.5.0
  33   */
  34  function options_general_add_js() {
  35      ?>
  36  <script type="text/javascript">
  37      jQuery(document).ready(function($){
  38          var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
  39              homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
  40  
  41          $( '#blogname' ).on( 'input', function() {
  42              var title = $.trim( $( this ).val() ) || homeURL;
  43  
  44              // Truncate to 40 characters.
  45              if ( 40 < title.length ) {
  46                  title = title.substring( 0, 40 ) + '\u2026';
  47              }
  48  
  49              $siteName.text( title );
  50          });
  51  
  52          $("input[name='date_format']").click(function(){
  53              if ( "date_format_custom_radio" != $(this).attr("id") )
  54                  $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  55          });
  56          $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
  57              $( '#date_format_custom_radio' ).prop( 'checked', true );
  58          });
  59  
  60          $("input[name='time_format']").click(function(){
  61              if ( "time_format_custom_radio" != $(this).attr("id") )
  62                  $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  63          });
  64  
  65          $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
  66              $( '#time_format_custom_radio' ).prop( 'checked', true );
  67          });
  68  
  69          $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
  70              var format = $( this ),
  71                  fieldset = format.closest( 'fieldset' ),
  72                  example = fieldset.find( '.example' ),
  73                  spinner = fieldset.find( '.spinner' );
  74  
  75              // Debounce the event callback while users are typing.
  76              clearTimeout( $.data( this, 'timer' ) );
  77              $( this ).data( 'timer', setTimeout( function() {
  78                  // If custom date is not empty.
  79                  if ( format.val() ) {
  80                      spinner.addClass( 'is-active' );
  81  
  82                      $.post( ajaxurl, {
  83                          action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format',
  84                          date     : format.val()
  85                      }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
  86                  }
  87              }, 500 ) );
  88          } );
  89  
  90          var languageSelect = $( '#WPLANG' );
  91          $( 'form' ).submit( function() {
  92              // Don't show a spinner for English and installed languages,
  93              // as there is nothing to download.
  94              if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
  95                  $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
  96              }
  97          });
  98      });
  99  </script>
 100      <?php
 101  }
 102  
 103  /**
 104   * Display JavaScript on the page.
 105   *
 106   * @since 3.5.0
 107   */
 108  function options_reading_add_js() {
 109      ?>
 110  <script type="text/javascript">
 111      jQuery(document).ready(function($){
 112          var section = $('#front-static-pages'),
 113              staticPage = section.find('input:radio[value="page"]'),
 114              selects = section.find('select'),
 115              check_disabled = function(){
 116                  selects.prop( 'disabled', ! staticPage.prop('checked') );
 117              };
 118          check_disabled();
 119          section.find( 'input:radio' ).change( check_disabled );
 120      });
 121  </script>
 122      <?php
 123  }
 124  
 125  /**
 126   * Render the site charset setting.
 127   *
 128   * @since 3.5.0
 129   */
 130  function options_reading_blog_charset() {
 131      echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
 132      echo '<p class="description">' . __( 'The <a href="https://wordpress.org/support/article/glossary/#character-set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
 133  }


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7