[ Index ]

PHP Cross Reference of WordPress

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              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"]' ).on( '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  
  57          $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
  58              $( '#date_format_custom_radio' ).prop( 'checked', true );
  59          });
  60  
  61          $( 'input[name="time_format"]' ).on( 'click', function() {
  62              if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) )
  63                  $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  64          });
  65  
  66          $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
  67              $( '#time_format_custom_radio' ).prop( 'checked', true );
  68          });
  69  
  70          $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
  71              var format = $( this ),
  72                  fieldset = format.closest( 'fieldset' ),
  73                  example = fieldset.find( '.example' ),
  74                  spinner = fieldset.find( '.spinner' );
  75  
  76              // Debounce the event callback while users are typing.
  77              clearTimeout( $.data( this, 'timer' ) );
  78              $( this ).data( 'timer', setTimeout( function() {
  79                  // If custom date is not empty.
  80                  if ( format.val() ) {
  81                      spinner.addClass( 'is-active' );
  82  
  83                      $.post( ajaxurl, {
  84                          action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',
  85                          date     : format.val()
  86                      }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
  87                  }
  88              }, 500 ) );
  89          } );
  90  
  91          var languageSelect = $( '#WPLANG' );
  92          $( 'form' ).on( 'submit', function() {
  93              // Don't show a spinner for English and installed languages,
  94              // as there is nothing to download.
  95              if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
  96                  $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
  97              }
  98          });
  99      } );
 100  </script>
 101      <?php
 102  }
 103  
 104  /**
 105   * Display JavaScript on the page.
 106   *
 107   * @since 3.5.0
 108   */
 109  function options_reading_add_js() {
 110      ?>
 111  <script type="text/javascript">
 112      jQuery( function($) {
 113          var section = $('#front-static-pages'),
 114              staticPage = section.find('input:radio[value="page"]'),
 115              selects = section.find('select'),
 116              check_disabled = function(){
 117                  selects.prop( 'disabled', ! staticPage.prop('checked') );
 118              };
 119          check_disabled();
 120          section.find( 'input:radio' ).on( 'change', check_disabled );
 121      } );
 122  </script>
 123      <?php
 124  }
 125  
 126  /**
 127   * Render the site charset setting.
 128   *
 129   * @since 3.5.0
 130   */
 131  function options_reading_blog_charset() {
 132      echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
 133      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>';
 134  }


Generated: Wed Oct 16 01:00:02 2024 Cross-referenced by PHPXref 0.7.1