/wp-admin/includes/options.php

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