[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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.on( '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( function($) {
  38          var $siteName = $( '#wp-admin-bar-site-name' ).children( 'a' ).first(),
  39              $siteIconPreview = $('#site-icon-preview-site-title'),
  40              homeURL = ( <?php echo wp_json_encode( get_home_url() ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
  41  
  42          $( '#blogname' ).on( 'input', function() {
  43              var title = $.trim( $( this ).val() ) || homeURL;
  44  
  45              // Truncate to 40 characters.
  46              if ( 40 < title.length ) {
  47                  title = title.substring( 0, 40 ) + '\u2026';
  48              }
  49  
  50              $siteName.text( title );
  51              $siteIconPreview.text( title );
  52          });
  53  
  54          $( 'input[name="date_format"]' ).on( 'click', function() {
  55              if ( 'date_format_custom_radio' !== $(this).attr( 'id' ) )
  56                  $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  57          });
  58  
  59          $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
  60              $( '#date_format_custom_radio' ).prop( 'checked', true );
  61          });
  62  
  63          $( 'input[name="time_format"]' ).on( 'click', function() {
  64              if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) )
  65                  $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  66          });
  67  
  68          $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
  69              $( '#time_format_custom_radio' ).prop( 'checked', true );
  70          });
  71  
  72          $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
  73              var format = $( this ),
  74                  fieldset = format.closest( 'fieldset' ),
  75                  example = fieldset.find( '.example' ),
  76                  spinner = fieldset.find( '.spinner' );
  77  
  78              // Debounce the event callback while users are typing.
  79              clearTimeout( $.data( this, 'timer' ) );
  80              $( this ).data( 'timer', setTimeout( function() {
  81                  // If custom date is not empty.
  82                  if ( format.val() ) {
  83                      spinner.addClass( 'is-active' );
  84  
  85                      $.post( ajaxurl, {
  86                          action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',
  87                          date     : format.val()
  88                      }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
  89                  }
  90              }, 500 ) );
  91          } );
  92  
  93          var languageSelect = $( '#WPLANG' );
  94          $( 'form' ).on( 'submit', function() {
  95              /*
  96               * Don't show a spinner for English and installed languages,
  97               * as there is nothing to download.
  98               */
  99              if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
 100                  $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
 101              }
 102          });
 103      } );
 104  </script>
 105      <?php
 106  }
 107  
 108  /**
 109   * Display JavaScript on the page.
 110   *
 111   * @since 3.5.0
 112   */
 113  function options_reading_add_js() {
 114      ?>
 115  <script type="text/javascript">
 116      jQuery( function($) {
 117          var section = $('#front-static-pages'),
 118              staticPage = section.find('input:radio[value="page"]'),
 119              selects = section.find('select'),
 120              check_disabled = function(){
 121                  selects.prop( 'disabled', ! staticPage.prop('checked') );
 122              };
 123          check_disabled();
 124          section.find( 'input:radio' ).on( 'change', check_disabled );
 125      } );
 126  </script>
 127      <?php
 128  }
 129  
 130  /**
 131   * Render the site charset setting.
 132   *
 133   * @since 3.5.0
 134   */
 135  function options_reading_blog_charset() {
 136      echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
 137      echo '<p class="description">' . __( 'The <a href="https://wordpress.org/documentation/article/wordpress-glossary/#character-set">character encoding</a> of your site (UTF-8 is recommended)' ) . '</p>';
 138  }


Generated : Thu Nov 21 08:20:01 2024 Cross-referenced by PHPXref