3 * WordPress Options Administration API.
6 * @subpackage Administration
11 * Output JavaScript to toggle display of additional settings if avatars are disabled.
15 function options_discussion_add_js() {
19 var parent = $( '#show_avatars' ),
20 children = $( '.avatar-settings' );
21 parent.change(function(){
22 children.toggleClass( 'hide-if-js', ! this.checked );
30 * Display JavaScript on the page.
34 function options_general_add_js() {
36 <script type="text/javascript">
37 jQuery(document).ready(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\.)?/, '' );
41 $( '#blogname' ).on( 'input', function() {
42 var title = $.trim( $( this ).val() ) || homeURL;
44 // Truncate to 40 characters.
45 if ( 40 < title.length ) {
46 title = title.substring( 0, 40 ) + '\u2026';
49 $siteName.text( title );
52 $("input[name='date_format']").click(function(){
53 if ( "date_format_custom_radio" != $(this).attr("id") )
54 $( "input[name='date_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
56 $("input[name='date_format_custom']").focus(function(){
57 $( '#date_format_custom_radio' ).prop( 'checked', true );
60 $("input[name='time_format']").click(function(){
61 if ( "time_format_custom_radio" != $(this).attr("id") )
62 $( "input[name='time_format_custom']" ).val( $( this ).val() ).siblings( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
64 $("input[name='time_format_custom']").focus(function(){
65 $( '#time_format_custom_radio' ).prop( 'checked', true );
67 $("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
69 format.siblings( '.spinner' ).addClass( 'is-active' );
71 action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
73 }, function(d) { format.siblings( '.spinner' ).removeClass( 'is-active' ); format.siblings('.example').text(d); } );
76 var languageSelect = $( '#WPLANG' );
77 $( 'form' ).submit( function() {
78 // Don't show a spinner for English and installed languages,
79 // as there is nothing to download.
80 if ( ! languageSelect.find( 'option:selected' ).data( 'installed' ) ) {
81 $( '#submit', this ).after( '<span class="spinner language-install-spinner" />' );
90 * Display JavaScript on the page.
94 function options_permalink_add_js() {
96 <script type="text/javascript">
97 jQuery(document).ready(function() {
98 jQuery('.permalink-structure input:radio').change(function() {
99 if ( 'custom' == this.value )
101 jQuery('#permalink_structure').val( this.value );
103 jQuery('#permalink_structure').focus(function() {
104 jQuery("#custom_selection").attr('checked', 'checked');
112 * Display JavaScript on the page.
116 function options_reading_add_js() {
118 <script type="text/javascript">
119 jQuery(document).ready(function($){
120 var section = $('#front-static-pages'),
121 staticPage = section.find('input:radio[value="page"]'),
122 selects = section.find('select'),
123 check_disabled = function(){
124 selects.prop( 'disabled', ! staticPage.prop('checked') );
127 section.find('input:radio').change(check_disabled);
134 * Render the site charset setting.
138 function options_reading_blog_charset() {
139 echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr( get_option( 'blog_charset' ) ) . '" class="regular-text" />';
140 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>';