2015-09-10 17:45:24 -04:00
< ? php
/**
* WordPress Options Administration API .
*
* @ package WordPress
* @ subpackage Administration
* @ since 4.4 . 0
*/
/**
* Output JavaScript to toggle display of additional settings if avatars are disabled .
*
* @ since 4.2 . 0
*/
function options_discussion_add_js () {
?>
< script >
( function ( $ ){
var parent = $ ( '#show_avatars' ),
children = $ ( '.avatar-settings' );
parent . change ( function (){
children . toggleClass ( 'hide-if-js' , ! this . checked );
});
})( jQuery );
</ script >
< ? php
}
/**
* Display JavaScript on the page .
*
* @ since 3.5 . 0
*/
function options_general_add_js () {
?>
< script type = " text/javascript " >
jQuery ( document ) . ready ( function ( $ ){
var $siteName = $ ( '#wp-admin-bar-site-name' ) . children ( 'a' ) . first (),
homeURL = ( < ? php echo wp_json_encode ( get_home_url () ); ?> || '' ).replace( /^(https?:\/\/)?(www\.)?/, '' );
$ ( '#blogname' ) . on ( 'input' , function () {
var title = $ . trim ( $ ( this ) . val () ) || homeURL ;
// Truncate to 40 characters.
if ( 40 < title . length ) {
title = title . substring ( 0 , 40 ) + '\u2026' ;
}
$siteName . text ( title );
});
$ ( " input[name='date_format'] " ) . click ( function (){
if ( " date_format_custom_radio " != $ ( this ) . attr ( " id " ) )
2017-11-08 22:57:36 -05:00
$ ( 'input[name="date_format_custom"]' ) . val ( $ ( this ) . val () ) . closest ( 'fieldset' ) . find ( '.example' ) . text ( $ ( this ) . parent ( 'label' ) . children ( '.format-i18n' ) . text () );
2015-09-10 17:45:24 -04:00
});
2017-05-02 16:03:42 -04:00
$ ( 'input[name="date_format_custom"]' ) . on ( 'click input' , function () {
2015-09-10 17:45:24 -04:00
$ ( '#date_format_custom_radio' ) . prop ( 'checked' , true );
});
$ ( " input[name='time_format'] " ) . click ( function (){
if ( " time_format_custom_radio " != $ ( this ) . attr ( " id " ) )
2017-11-08 22:57:36 -05:00
$ ( 'input[name="time_format_custom"]' ) . val ( $ ( this ) . val () ) . closest ( 'fieldset' ) . find ( '.example' ) . text ( $ ( this ) . parent ( 'label' ) . children ( '.format-i18n' ) . text () );
2015-09-10 17:45:24 -04:00
});
2017-05-02 16:03:42 -04:00
$ ( 'input[name="time_format_custom"]' ) . on ( 'click input' , function () {
2015-09-10 17:45:24 -04:00
$ ( '#time_format_custom_radio' ) . prop ( 'checked' , true );
});
$ ( " input[name='date_format_custom'], input[name='time_format_custom'] " ) . change ( function () {
2017-11-08 22:57:36 -05:00
var format = $ ( this ),
fieldset = format . closest ( 'fieldset' ),
example = fieldset . find ( '.example' ),
spinner = fieldset . find ( '.spinner' );
spinner . addClass ( 'is-active' );
$ . post ( ajaxurl , {
action : 'date_format_custom' == format . attr ( 'name' ) ? 'date_format' : 'time_format' ,
2015-09-10 17:45:24 -04:00
date : format . val ()
2017-11-08 22:57:36 -05:00
}, function ( d ) { spinner . removeClass ( 'is-active' ); example . text ( d ); } );
2015-09-10 17:45:24 -04:00
});
var languageSelect = $ ( '#WPLANG' );
$ ( 'form' ) . submit ( function () {
// Don't show a spinner for English and installed languages,
// as there is nothing to download.
if ( ! languageSelect . find ( 'option:selected' ) . data ( 'installed' ) ) {
2017-05-07 08:01:42 -04:00
$ ( '#submit' , this ) . after ( '<span class="spinner language-install-spinner is-active" />' );
2015-09-10 17:45:24 -04:00
}
});
});
</ script >
< ? php
}
/**
* Display JavaScript on the page .
*
* @ since 3.5 . 0
*/
function options_reading_add_js () {
?>
< script type = " text/javascript " >
jQuery ( document ) . ready ( function ( $ ){
var section = $ ( '#front-static-pages' ),
staticPage = section . find ( 'input:radio[value="page"]' ),
selects = section . find ( 'select' ),
check_disabled = function (){
selects . prop ( 'disabled' , ! staticPage . prop ( 'checked' ) );
};
check_disabled ();
section . find ( 'input:radio' ) . change ( check_disabled );
});
</ script >
< ? php
}
/**
2016-01-27 22:35:27 -05:00
* Render the site charset setting .
2015-09-10 17:45:24 -04:00
*
* @ since 3.5 . 0
*/
function options_reading_blog_charset () {
echo '<input name="blog_charset" type="text" id="blog_charset" value="' . esc_attr ( get_option ( 'blog_charset' ) ) . '" class="regular-text" />' ;
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>' ;
2016-01-27 22:35:27 -05:00
}