You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

142 lines
4.1 KiB

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