/wp-admin/includes/options.php

https://bitbucket.org/devbctph/futura_wp · PHP · 124 lines · 82 code · 12 blank · 30 comment · 9 complexity · 4b4ab0d3e06315e8a9a2e863465462c5 MD5 · raw file

  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() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  49. });
  50. $( 'input[name="date_format_custom"]' ).on( 'click input', 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() ).closest( 'fieldset' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
  56. });
  57. $( 'input[name="time_format_custom"]' ).on( 'click input', 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. fieldset = format.closest( 'fieldset' ),
  63. example = fieldset.find( '.example' ),
  64. spinner = fieldset.find( '.spinner' );
  65. spinner.addClass( 'is-active' );
  66. $.post( ajaxurl, {
  67. action: 'date_format_custom' == format.attr( 'name' ) ? 'date_format' : 'time_format',
  68. date : format.val()
  69. }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
  70. });
  71. var languageSelect = $( '#WPLANG' );
  72. $( 'form' ).submit( function() {
  73. // Don't show a spinner for English and installed languages,
  74. // as there is nothing to download.
  75. if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
  76. $( '#submit', this ).after( '<span class="spinner language-install-spinner is-active" />' );
  77. }
  78. });
  79. });
  80. </script>
  81. <?php
  82. }
  83. /**
  84. * Display JavaScript on the page.
  85. *
  86. * @since 3.5.0
  87. */
  88. function options_reading_add_js() {
  89. ?>
  90. <script type="text/javascript">
  91. jQuery(document).ready(function($){
  92. var section = $('#front-static-pages'),
  93. staticPage = section.find('input:radio[value="page"]'),
  94. selects = section.find('select'),
  95. check_disabled = function(){
  96. selects.prop( 'disabled', ! staticPage.prop('checked') );
  97. };
  98. check_disabled();
  99. section.find('input:radio').change(check_disabled);
  100. });
  101. </script>
  102. <?php
  103. }
  104. /**
  105. * Render the site charset setting.
  106. *
  107. * @since 3.5.0
  108. */
  109. function options_reading_blog_charset() {
  110. echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
  111. 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>';
  112. }