Make WordPress Core

Ticket #38734: 38734.diff

File 38734.diff, 33.0 KB (added by johnbillion, 8 years ago)
  • src/wp-admin/options-general.php

    diff --git src/wp-admin/options-general.php src/wp-admin/options-general.php
    index 22d475c..872c572 100644
     
    99/** WordPress Administration Bootstrap */
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    1111
    12 /** WordPress Translation Install API */
    13 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    14 
    1512if ( ! current_user_can( 'manage_options' ) )
    1613        wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    1714
    1815$title = __('General Settings');
    1916$parent_file = 'options-general.php';
    20 /* translators: date and time format for exact current time, mainly about timezones, see https://secure.php.net/date */
    21 $timezone_format = _x('Y-m-d H:i:s', 'timezone date format');
    2217
    2318add_action('admin_head', 'options_general_add_js');
    2419
    include( ABSPATH . 'wp-admin/admin-header.php' ); 
    5449
    5550<form method="post" action="options.php" novalidate="novalidate">
    5651<?php settings_fields('general'); ?>
    57 
    58 <table class="form-table">
    59 <tr>
    60 <th scope="row"><label for="blogname"><?php _e('Site Title') ?></label></th>
    61 <td><input name="blogname" type="text" id="blogname" value="<?php form_option('blogname'); ?>" class="regular-text" /></td>
    62 </tr>
    63 <tr>
    64 <th scope="row"><label for="blogdescription"><?php _e('Tagline') ?></label></th>
    65 <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option('blogdescription'); ?>" class="regular-text" />
    66 <p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ) ?></p></td>
    67 </tr>
    68 <?php if ( !is_multisite() ) { ?>
    69 <tr>
    70 <th scope="row"><label for="siteurl"><?php _e('WordPress Address (URL)') ?></label></th>
    71 <td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" /></td>
    72 </tr>
    73 <tr>
    74 <th scope="row"><label for="home"><?php _e('Site Address (URL)') ?></label></th>
    75 <td><input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" />
    76 <?php if ( ! defined( 'WP_HOME' ) ) : ?>
    77 <p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); ?></p></td>
    78 <?php endif; ?>
    79 </tr>
    80 <tr>
    81 <th scope="row"><label for="admin_email"><?php _e('Email Address') ?> </label></th>
    82 <td><input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
    83 <p class="description" id="admin-email-description"><?php _e( 'This address is used for admin purposes, like new user notification.' ) ?></p></td>
    84 </tr>
    85 <tr>
    86 <th scope="row"><?php _e('Membership') ?></th>
    87 <td> <fieldset><legend class="screen-reader-text"><span><?php _e('Membership') ?></span></legend><label for="users_can_register">
    88 <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked('1', get_option('users_can_register')); ?> />
    89 <?php _e('Anyone can register') ?></label>
    90 </fieldset></td>
    91 </tr>
    92 <tr>
    93 <th scope="row"><label for="default_role"><?php _e('New User Default Role') ?></label></th>
    94 <td>
    95 <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select>
    96 </td>
    97 </tr>
    98 <?php } else { ?>
    99 <tr>
    100 <th scope="row"><label for="new_admin_email"><?php _e('Email Address') ?> </label></th>
    101 <td><input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
    102 <p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ) ?></p>
    103 <?php
    104 $new_admin_email = get_option( 'new_admin_email' );
    105 if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?>
    106 <div class="updated inline">
    107 <p><?php
    108         printf(
    109                 /* translators: %s: new admin email */
    110                 __( 'There is a pending change of the admin email to %s.' ),
    111                 '<code>' . esc_html( $new_admin_email ) . '</code>'
    112         );
    113         printf(
    114                 ' <a href="%1$s">%2$s</a>',
    115                 esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
    116                 __( 'Cancel' )
    117         );
    118 ?></p>
    119 </div>
    120 <?php endif; ?>
    121 </td>
    122 </tr>
    123 <?php } ?>
    124 <tr>
    125 <?php
    126 $current_offset = get_option('gmt_offset');
    127 $tzstring = get_option('timezone_string');
    128 
    129 $check_zone_info = true;
    130 
    131 // Remove old Etc mappings. Fallback to gmt_offset.
    132 if ( false !== strpos($tzstring,'Etc/GMT') )
    133         $tzstring = '';
    134 
    135 if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists
    136         $check_zone_info = false;
    137         if ( 0 == $current_offset )
    138                 $tzstring = 'UTC+0';
    139         elseif ($current_offset < 0)
    140                 $tzstring = 'UTC' . $current_offset;
    141         else
    142                 $tzstring = 'UTC+' . $current_offset;
    143 }
    144 
    145 ?>
    146 <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
    147 <td>
    148 
    149 <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
    150         <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?>
    151 </select>
    152 
    153 <p class="description" id="timezone-description"><?php _e( 'Choose either a city in the same timezone as you or a UTC timezone offset.' ); ?></p>
    154 
    155 <p class="timezone-info">
    156         <span id="utc-time"><?php
    157                 /* translators: 1: UTC abbreviation, 2: UTC time */
    158                 printf( __( 'Universal time (%1$s) is %2$s.' ),
    159                         '<abbr>' . __( 'UTC' ) . '</abbr>',
    160                         '<code>' . date_i18n( $timezone_format, false, true ) . '</code>'
    161                 );
    162         ?></span>
    163 <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
    164         <span id="local-time"><?php
    165                 /* translators: %s: local time */
    166                 printf( __( 'Local time is %s.' ),
    167                         '<code>' . date_i18n( $timezone_format ) . '</code>'
    168                 );
    169         ?></span>
    170 <?php endif; ?>
    171 </p>
    172 
    173 <?php if ( $check_zone_info && $tzstring ) : ?>
    174 <p class="timezone-info">
    175 <span>
    176         <?php
    177         // Set TZ so localtime works.
    178         date_default_timezone_set($tzstring);
    179         $now = localtime(time(), true);
    180         if ( $now['tm_isdst'] )
    181                 _e('This timezone is currently in daylight saving time.');
    182         else
    183                 _e('This timezone is currently in standard time.');
    184         ?>
    185         <br />
    186         <?php
    187         $allowed_zones = timezone_identifiers_list();
    188 
    189         if ( in_array( $tzstring, $allowed_zones) ) {
    190                 $found = false;
    191                 $date_time_zone_selected = new DateTimeZone($tzstring);
    192                 $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());
    193                 $right_now = time();
    194                 foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) {
    195                         if ( $tr['ts'] > $right_now ) {
    196                             $found = true;
    197                                 break;
    198                         }
    199                 }
    200 
    201                 if ( $found ) {
    202                         echo ' ';
    203                         $message = $tr['isdst'] ?
    204                                 /* translators: %s: date and time  */
    205                                 __( 'Daylight saving time begins on: %s.')  :
    206                                 /* translators: %s: date and time  */
    207                                 __( 'Standard time begins on: %s.' );
    208                         // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
    209                         printf( $message,
    210                                 '<code>' . date_i18n(
    211                                         __( 'F j, Y' ) . ' ' . __( 'g:i a' ),
    212                                         $tr['ts'] + ( $tz_offset - $tr['offset'] )
    213                                 ) . '</code>'
    214                         );
    215                 } else {
    216                         _e( 'This timezone does not observe daylight saving time.' );
    217                 }
    218         }
    219         // Set back to UTC.
    220         date_default_timezone_set('UTC');
    221         ?>
    222         </span>
    223 </p>
    224 <?php endif; ?>
    225 </td>
    226 
    227 </tr>
    228 <tr>
    229 <th scope="row"><?php _e('Date Format') ?></th>
    230 <td>
    231         <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend>
    232 <?php
    233         /**
    234         * Filters the default date formats.
    235         *
    236         * @since 2.7.0
    237         * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
    238         *
    239         * @param array $default_date_formats Array of default date formats.
    240         */
    241         $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
    242 
    243         $custom = true;
    244 
    245         foreach ( $date_formats as $format ) {
    246                 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
    247                 if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="
    248                         echo " checked='checked'";
    249                         $custom = false;
    250                 }
    251                 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
    252         }
    253 
    254         echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
    255         checked( $custom );
    256         echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom date format in the following field' ) . '</span></label>' .
    257                 '<label for="date_format_custom" class="screen-reader-text">' . __( 'Custom date format:' ) . '</label>' .
    258                 '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" /></span>' .
    259                 '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' .
    260                 "<span class='spinner'></span>\n";
    261 ?>
    262         </fieldset>
    263 </td>
    264 </tr>
    265 <tr>
    266 <th scope="row"><?php _e('Time Format') ?></th>
    267 <td>
    268         <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend>
    269 <?php
    270         /**
    271         * Filters the default time formats.
    272         *
    273         * @since 2.7.0
    274         *
    275         * @param array $default_time_formats Array of default time formats.
    276         */
    277         $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) );
    278 
    279         $custom = true;
    280 
    281         foreach ( $time_formats as $format ) {
    282                 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
    283                 if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="
    284                         echo " checked='checked'";
    285                         $custom = false;
    286                 }
    287                 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
    288         }
    289 
    290         echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
    291         checked( $custom );
    292         echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom time format in the following field' ) . '</span></label>' .
    293                 '<label for="time_format_custom" class="screen-reader-text">' . __( 'Custom time format:' ) . '</label>' .
    294                 '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" /></span>' .
    295                 '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' .
    296                 "<span class='spinner'></span>\n";
    297 
    298         echo "\t<p class='date-time-doc'>" . __('<a href="https://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.') . "</p>\n";
    299 ?>
    300         </fieldset>
    301 </td>
    302 </tr>
    303 <tr>
    304 <th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th>
    305 <td><select name="start_of_week" id="start_of_week">
    306 <?php
    307 /**
    308  * @global WP_Locale $wp_locale
    309  */
    310 global $wp_locale;
    311 
    312 for ($day_index = 0; $day_index <= 6; $day_index++) :
    313         $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';
    314         echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';
    315 endfor;
    316 ?>
    317 </select></td>
    318 </tr>
    319 <?php do_settings_fields('general', 'default'); ?>
    320 
    321 <?php
    322 $languages = get_available_languages();
    323 $translations = wp_get_available_translations();
    324 if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
    325         $languages[] = WPLANG;
    326 }
    327 if ( ! empty( $languages ) || ! empty( $translations ) ) {
    328         ?>
    329         <tr>
    330                 <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th>
    331                 <td>
    332                         <?php
    333                         $locale = get_locale();
    334                         if ( ! in_array( $locale, $languages ) ) {
    335                                 $locale = '';
    336                         }
    337 
    338                         wp_dropdown_languages( array(
    339                                 'name'         => 'WPLANG',
    340                                 'id'           => 'WPLANG',
    341                                 'selected'     => $locale,
    342                                 'languages'    => $languages,
    343                                 'translations' => $translations,
    344                                 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
    345                         ) );
    346 
    347                         // Add note about deprecated WPLANG constant.
    348                         if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) {
    349                                 if ( is_super_admin() ) {
    350                                         ?>
    351                                         <p class="description">
    352                                                 <strong><?php _e( 'Note:' ); ?></strong> <?php printf( __( 'The %s constant in your %s file is no longer needed.' ), '<code>WPLANG</code>', '<code>wp-config.php</code>' ); ?>
    353                                         </p>
    354                                         <?php
    355                                 }
    356                                 _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) );
    357                         }
    358                         ?>
    359                 </td>
    360         </tr>
    361         <?php
    362 }
    363 ?>
    364 </table>
    365 
    36652<?php do_settings_sections('general'); ?>
    367 
    36853<?php submit_button(); ?>
    36954</form>
    37055
  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index 5a73975..bf8e4ec 100644
    add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 ); 
    382382// REST API actions.
    383383add_action( 'init',          'rest_api_init' );
    384384add_action( 'rest_api_init', 'rest_api_default_filters',   10, 1 );
    385 add_action( 'rest_api_init', 'register_initial_settings',  10 );
    386385add_action( 'rest_api_init', 'create_initial_rest_routes', 99 );
    387386add_action( 'parse_request', 'rest_api_loaded' );
    388387
     388// Settings Fields
     389add_action( 'init',       'register_initial_settings',          10 );
     390add_action( 'admin_init', 'register_initial_settings_sections', 10 );
     391
    389392/**
    390393 * Filters formerly mixed into wp-includes
    391394 */
  • src/wp-includes/option.php

    diff --git src/wp-includes/option.php src/wp-includes/option.php
    index ac17c2f..1c3a8bd 100644
    function set_site_transient( $transient, $value, $expiration = 0 ) { 
    17151715/**
    17161716 * Register default settings available in WordPress.
    17171717 *
    1718  * The settings registered here are primarily useful for the REST API, so this
    1719  * does not encompass all settings available in WordPress.
    1720  *
    17211718 * @since 4.7.0
    17221719 */
    17231720function register_initial_settings() {
     1721        // General Settings
    17241722        register_setting( 'general', 'blogname', array(
    17251723                'show_in_rest' => array(
    17261724                        'name' => 'title',
    function register_initial_settings() { 
    17461744                                ),
    17471745                        ),
    17481746                        'type'         => 'string',
     1747                        'description'  => __( 'WordPress URL.' ),
     1748                ) );
     1749
     1750                register_setting( 'general', 'home', array(
     1751                        'show_in_rest' => array(
     1752                                'name'    => 'home',
     1753                                'schema'  => array(
     1754                                        'format' => 'uri',
     1755                                ),
     1756                        ),
     1757                        'type'         => 'string',
    17491758                        'description'  => __( 'Site URL.' ),
    17501759                ) );
    1751         }
    17521760
    1753         if ( ! is_multisite() ) {
    17541761                register_setting( 'general', 'admin_email', array(
    17551762                        'show_in_rest' => array(
    17561763                                'name'    => 'email',
    function register_initial_settings() { 
    17611768                        'type'         => 'string',
    17621769                        'description'  => __( 'This address is used for admin purposes, like new user notification.' ),
    17631770                ) );
     1771
     1772                register_setting( 'general', 'users_can_register', array(
     1773                        'show_in_rest' => true,
     1774                        'type'         => 'boolean',
     1775                        'description'  => __( 'Anyone can register.' ),
     1776                ) );
     1777
     1778                register_setting( 'general', 'default_role', array(
     1779                        'show_in_rest' => true,
     1780                        'type'         => 'string',
     1781                        'description'  => __( 'New User Default Role.' ),
     1782                ) );
     1783
    17641784        }
    17651785
    17661786        register_setting( 'general', 'timezone_string', array(
    function register_initial_settings() { 
    17981818                'default'      => 'en_US',
    17991819        ) );
    18001820
     1821        // Writing Settings
    18011822        register_setting( 'writing', 'use_smilies', array(
    18021823                'show_in_rest' => true,
    18031824                'type'         => 'boolean',
    function register_initial_settings() { 
    18171838                'description'  => __( 'Default post format.' ),
    18181839        ) );
    18191840
     1841        // Reading Settings
    18201842        register_setting( 'reading', 'posts_per_page', array(
    18211843                'show_in_rest' => true,
    18221844                'type'         => 'integer',
    function register_initial_settings() { 
    18241846                'default'      => 10,
    18251847        ) );
    18261848
     1849        // Discussion Settings
    18271850        register_setting( 'discussion', 'default_ping_status', array(
    18281851                'show_in_rest' => array(
    18291852                        'schema'   => array(
    function register_initial_settings() { 
    18461869
    18471870}
    18481871
     1872function register_initial_settings_sections() {
     1873        /** WordPress Translation Install API */
     1874        require_once ABSPATH . 'wp-admin/includes/translation-install.php';
     1875
     1876        $settings = get_registered_settings();
     1877
     1878        add_settings_section(
     1879                'default',
     1880                '',
     1881                '__return_false',
     1882                'general'
     1883        );
     1884
     1885        add_settings_field(
     1886                'blogname',
     1887                __( 'Site Title' ),
     1888                'wp_settings_field_blogname',
     1889                $settings['blogname']['group'],
     1890                'default',
     1891                array(
     1892                        'setting'   => $settings['blogname'],
     1893                        'label_for' => 'blogname',
     1894                )
     1895        );
     1896
     1897        add_settings_field(
     1898                'blogdescription',
     1899                __( 'Tagline' ),
     1900                'wp_settings_field_blogdescription',
     1901                $settings['blogdescription']['group'],
     1902                'default',
     1903                array(
     1904                        'setting'   => $settings['blogdescription'],
     1905                        'label_for' => 'blogdescription',
     1906                )
     1907        );
     1908
     1909        if ( ! is_multisite() ) {
     1910                add_settings_field(
     1911                        'siteurl',
     1912                        __( 'WordPress Address (URL)' ),
     1913                        'wp_settings_field_siteurl',
     1914                        $settings['siteurl']['group'],
     1915                        'default',
     1916                        array(
     1917                                'setting'   => $settings['siteurl'],
     1918                                'label_for' => 'siteurl',
     1919                        )
     1920                );
     1921
     1922                add_settings_field(
     1923                        'home',
     1924                        __( 'Site Address (URL)' ),
     1925                        'wp_settings_field_home',
     1926                        $settings['home']['group'],
     1927                        'default',
     1928                        array(
     1929                                'setting'   => $settings['home'],
     1930                                'label_for' => 'home',
     1931                        )
     1932                );
     1933
     1934                add_settings_field(
     1935                        'admin_email',
     1936                        __( 'Email Address' ),
     1937                        'wp_settings_field_admin_email',
     1938                        $settings['admin_email']['group'],
     1939                        'default',
     1940                        array(
     1941                                'setting'   => $settings['admin_email'],
     1942                                'label_for' => 'admin_email',
     1943                        )
     1944                );
     1945
     1946                add_settings_field(
     1947                        'users_can_register',
     1948                        __( 'Membership' ),
     1949                        'wp_settings_field_users_can_register',
     1950                        $settings['users_can_register']['group'],
     1951                        'default',
     1952                        array(
     1953                                'setting' => $settings['users_can_register'],
     1954                        )
     1955                );
     1956
     1957                add_settings_field(
     1958                        'default_role',
     1959                        __( 'New User Default Role' ),
     1960                        'wp_settings_field_default_role',
     1961                        $settings['default_role']['group'],
     1962                        'default',
     1963                        array(
     1964                                'setting'   => $settings['default_role'],
     1965                                'label_for' => 'default_role',
     1966                        )
     1967                );
     1968
     1969        } else {
     1970
     1971                // add_settings_field(
     1972                //      'admin_email',
     1973                //      __( 'Email Address' ),
     1974                //      'wp_settings_field_admin_email',
     1975                //      $settings['admin_email']['group'],
     1976                //      'default',
     1977                //      array(
     1978                //              'setting'   => $settings['admin_email'],
     1979                //              'label_for' => 'admin_email',
     1980                //      )
     1981                // );
     1982
     1983        }
     1984
     1985        add_settings_field(
     1986                'timezone_string',
     1987                __( 'Timezone' ),
     1988                'wp_settings_field_timezone_string',
     1989                $settings['timezone_string']['group'],
     1990                'default',
     1991                array(
     1992                        'setting'   => $settings['timezone_string'],
     1993                        'label_for' => 'timezone_string',
     1994                )
     1995        );
     1996
     1997        add_settings_field(
     1998                'date_format',
     1999                __( 'Date Format' ),
     2000                'wp_settings_field_date_format',
     2001                $settings['date_format']['group'],
     2002                'default',
     2003                array(
     2004                        'setting' => $settings['date_format'],
     2005                )
     2006        );
     2007
     2008        add_settings_field(
     2009                'time_format',
     2010                __( 'Time Format' ),
     2011                'wp_settings_field_time_format',
     2012                $settings['time_format']['group'],
     2013                'default',
     2014                array(
     2015                        'setting' => $settings['time_format'],
     2016                )
     2017        );
     2018
     2019        add_settings_field(
     2020                'start_of_week',
     2021                __( 'Week Starts On' ),
     2022                'wp_settings_field_start_of_week',
     2023                $settings['start_of_week']['group'],
     2024                'default',
     2025                array(
     2026                        'setting'   => $settings['start_of_week'],
     2027                        'label_for' => 'start_of_week',
     2028                )
     2029        );
     2030
     2031        $languages    = get_available_languages();
     2032        $translations = wp_get_available_translations();
     2033
     2034        if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) {
     2035                $languages[] = WPLANG;
     2036        }
     2037
     2038        if ( ! empty( $languages ) || ! empty( $translations ) ) {
     2039
     2040                $locale = get_locale();
     2041                if ( ! in_array( $locale, $languages ) ) {
     2042                        $locale = '';
     2043                }
     2044
     2045                add_settings_field(
     2046                        'WPLANG',
     2047                        __( 'Site Language' ),
     2048                        'wp_settings_field_wplang',
     2049                        $settings['WPLANG']['group'],
     2050                        'default',
     2051                        array(
     2052                                'setting'      => $settings['WPLANG'],
     2053                                'label_for'    => 'WPLANG',
     2054                                'languages'    => $languages,
     2055                                'translations' => $translations,
     2056                                'locale'       => $locale,
     2057                        )
     2058                );
     2059
     2060        }
     2061
     2062}
     2063
     2064function wp_settings_field_blogname( array $args ) {
     2065        ?>
     2066        <input name="blogname" type="text" id="blogname" value="<?php form_option( 'blogname' ); ?>" class="regular-text" />
     2067        <?php
     2068}
     2069
     2070function wp_settings_field_blogdescription( array $args ) {
     2071        ?>
     2072        <input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option( 'blogdescription' ); ?>" class="regular-text" />
     2073        <p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ) ?></p>
     2074        <?php
     2075}
     2076
     2077function wp_settings_field_siteurl( array $args ) {
     2078        ?>
     2079        <input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php if ( defined( 'WP_SITEURL' ) ) echo ' disabled' ?>" />
     2080        <?php
     2081}
     2082
     2083function wp_settings_field_home( array $args ) {
     2084        ?>
     2085        <input name="home" type="url" id="home" aria-describedby="home-description" value="<?php form_option( 'home' ); ?>"<?php disabled( defined( 'WP_HOME' ) ); ?> class="regular-text code<?php if ( defined( 'WP_HOME' ) ) echo ' disabled' ?>" />
     2086        <?php if ( ! defined( 'WP_HOME' ) ) : ?>
     2087        <p class="description" id="home-description"><?php _e( 'Enter the address here if you <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory">want your site home page to be different from your WordPress installation directory.</a>' ); ?></p>
     2088        <?php endif; ?>
     2089        <?php
     2090}
     2091
     2092function wp_settings_field_admin_email( array $args ) {
     2093
     2094        if ( ! is_multisite() ) {
     2095
     2096                ?>
     2097                <input name="admin_email" type="email" id="admin_email" aria-describedby="admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
     2098                <p class="description" id="admin-email-description"><?php echo esc_html( $args['setting']['description'] ); ?></p>
     2099                <?php
     2100
     2101        } else {
     2102
     2103                ?>
     2104                <input name="new_admin_email" type="email" id="new_admin_email" aria-describedby="new-admin-email-description" value="<?php form_option( 'admin_email' ); ?>" class="regular-text ltr" />
     2105                <p class="description" id="new-admin-email-description"><?php _e( 'This address is used for admin purposes. If you change this we will send you an email at your new address to confirm it. <strong>The new address will not become active until confirmed.</strong>' ); ?></p>
     2106                <?php
     2107                $new_admin_email = get_option( 'new_admin_email' );
     2108                if ( $new_admin_email && $new_admin_email != get_option( 'admin_email' ) ) { ?>
     2109                        <div class="updated inline">
     2110                                <p><?php
     2111                                        printf(
     2112                                                /* translators: %s: new admin email */
     2113                                                __( 'There is a pending change of the admin email to %s.' ),
     2114                                                '<code>' . esc_html( $new_admin_email ) . '</code>'
     2115                                        );
     2116                                        printf(
     2117                                                ' <a href="%1$s">%2$s</a>',
     2118                                                esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ),
     2119                                                __( 'Cancel' )
     2120                                        );
     2121                                ?></p>
     2122                        </div>
     2123                <?php }
     2124        }
     2125
     2126}
     2127
     2128function wp_settings_field_users_can_register( array $args ) {
     2129        ?>
     2130        <fieldset>
     2131                <legend class="screen-reader-text"><span><?php _e('Membership') ?></span></legend>
     2132                <label for="users_can_register">
     2133                        <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> />
     2134                        <?php _e( 'Anyone can register' ); ?>
     2135                </label>
     2136        </fieldset>
     2137        <?php
     2138}
     2139
     2140function wp_settings_field_default_role( array $args ) {
     2141        ?>
     2142        <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select>
     2143        <?php
     2144}
     2145
     2146function wp_settings_field_timezone_string( array $args ) {
     2147        $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
     2148        $current_offset  = get_option( 'gmt_offset' );
     2149        $tzstring        = get_option( 'timezone_string' );
     2150        $check_zone_info = true;
     2151
     2152        // Remove old Etc mappings. Fallback to gmt_offset.
     2153        if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
     2154                $tzstring = '';
     2155        }
     2156
     2157        if ( empty( $tzstring ) ) {
     2158                // Create a UTC+- zone if no timezone string exists
     2159                $check_zone_info = false;
     2160                if ( 0 == $current_offset ) {
     2161                        $tzstring = 'UTC+0';
     2162                } elseif ( $current_offset < 0 ) {
     2163                        $tzstring = 'UTC' . $current_offset;
     2164                } else {
     2165                        $tzstring = 'UTC+' . $current_offset;
     2166                }
     2167        }
     2168
     2169        ?>
     2170        <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description">
     2171                <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?>
     2172        </select>
     2173
     2174        <p class="description" id="timezone-description"><?php _e( 'Choose either a city in the same timezone as you or a UTC timezone offset.' ); ?></p>
     2175
     2176        <p class="timezone-info">
     2177                <span id="utc-time"><?php
     2178                        /* translators: 1: UTC abbreviation, 2: UTC time */
     2179                        printf( __( 'Universal time (%1$s) is %2$s.' ),
     2180                                '<abbr>' . __( 'UTC' ) . '</abbr>',
     2181                                '<code>' . date_i18n( $timezone_format, false, true ) . '</code>'
     2182                        );
     2183                ?></span>
     2184                <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
     2185                        <span id="local-time"><?php
     2186                                /* translators: %s: local time */
     2187                                printf( __( 'Local time is %s.' ),
     2188                                        '<code>' . date_i18n( $timezone_format ) . '</code>'
     2189                                );
     2190                        ?></span>
     2191                <?php endif; ?>
     2192        </p>
     2193
     2194        <?php if ( $check_zone_info && $tzstring ) : ?>
     2195                <p class="timezone-info">
     2196                <span>
     2197                        <?php
     2198                        // Set TZ so localtime works.
     2199                        date_default_timezone_set( $tzstring );
     2200                        $now = localtime( time(), true );
     2201                        if ( $now['tm_isdst'] ) {
     2202                                _e('This timezone is currently in daylight saving time.');
     2203                        } else {
     2204                                _e('This timezone is currently in standard time.');
     2205                        }
     2206                        ?>
     2207                        <br />
     2208                        <?php
     2209                        $allowed_zones = timezone_identifiers_list();
     2210
     2211                        if ( in_array( $tzstring, $allowed_zones) ) {
     2212                                $found = false;
     2213                                $date_time_zone_selected = new DateTimeZone($tzstring);
     2214                                $tz_offset = timezone_offset_get( $date_time_zone_selected, date_create() );
     2215                                $right_now = time();
     2216                                foreach ( timezone_transitions_get( $date_time_zone_selected ) as $tr ) {
     2217                                        if ( $tr['ts'] > $right_now ) {
     2218                                            $found = true;
     2219                                                break;
     2220                                        }
     2221                                }
     2222
     2223                                if ( $found ) {
     2224                                        echo ' ';
     2225                                        $message = $tr['isdst'] ?
     2226                                                /* translators: %s: date and time  */
     2227                                                __( 'Daylight saving time begins on: %s.')  :
     2228                                                /* translators: %s: date and time  */
     2229                                                __( 'Standard time begins on: %s.' );
     2230                                        // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
     2231                                        printf( $message,
     2232                                                '<code>' . date_i18n(
     2233                                                        __( 'F j, Y' ) . ' ' . __( 'g:i a' ),
     2234                                                        $tr['ts'] + ( $tz_offset - $tr['offset'] )
     2235                                                ) . '</code>'
     2236                                        );
     2237                                } else {
     2238                                        _e( 'This timezone does not observe daylight saving time.' );
     2239                                }
     2240                        }
     2241                        // Set back to UTC.
     2242                        date_default_timezone_set( 'UTC' );
     2243                        ?>
     2244                        </span>
     2245                </p>
     2246        <?php endif;
     2247}
     2248
     2249function wp_settings_field_date_format( array $args ) {
     2250        ?>
     2251        <fieldset>
     2252                <legend class="screen-reader-text"><span><?php _e( 'Date Format' ); ?></span></legend>
     2253                <?php
     2254                        /**
     2255                        * Filters the default date formats.
     2256                        *
     2257                        * @since 2.7.0
     2258                        * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
     2259                        *
     2260                        * @param array $default_date_formats Array of default date formats.
     2261                        */
     2262                        $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
     2263
     2264                        $custom = true;
     2265
     2266                        foreach ( $date_formats as $format ) {
     2267                                echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
     2268                                if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "==="
     2269                                        echo " checked='checked'";
     2270                                        $custom = false;
     2271                                }
     2272                                echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
     2273                        }
     2274
     2275                        echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
     2276                        checked( $custom );
     2277                        echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom date format in the following field' ) . '</span></label>' .
     2278                                '<label for="date_format_custom" class="screen-reader-text">' . __( 'Custom date format:' ) . '</label>' .
     2279                                '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" /></span>' .
     2280                                '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' .
     2281                                "<span class='spinner'></span>\n";
     2282                ?>
     2283        </fieldset>
     2284        <?php
     2285}
     2286
     2287function wp_settings_field_time_format( array $args ) {
     2288        ?>
     2289        <fieldset>
     2290                <legend class="screen-reader-text"><span><?php _e( 'Time Format' ); ?></span></legend>
     2291                <?php
     2292                        /**
     2293                        * Filters the default time formats.
     2294                        *
     2295                        * @since 2.7.0
     2296                        *
     2297                        * @param array $default_time_formats Array of default time formats.
     2298                        */
     2299                        $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) );
     2300
     2301                        $custom = true;
     2302
     2303                        foreach ( $time_formats as $format ) {
     2304                                echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
     2305                                if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "==="
     2306                                        echo " checked='checked'";
     2307                                        $custom = false;
     2308                                }
     2309                                echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
     2310                        }
     2311
     2312                        echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
     2313                        checked( $custom );
     2314                        echo '/> <span class="date-time-text date-time-custom-text">' . __( 'Custom:' ) . '<span class="screen-reader-text"> ' . __( 'enter a custom time format in the following field' ) . '</span></label>' .
     2315                                '<label for="time_format_custom" class="screen-reader-text">' . __( 'Custom time format:' ) . '</label>' .
     2316                                '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" /></span>' .
     2317                                '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' .
     2318                                "<span class='spinner'></span>\n";
     2319
     2320                        echo "\t<p class='date-time-doc'>" . __( '<a href="https://codex.wordpress.org/Formatting_Date_and_Time">Documentation on date and time formatting</a>.' ) . "</p>\n";
     2321                ?>
     2322        </fieldset>
     2323        <?php
     2324}
     2325
     2326function wp_settings_field_start_of_week( array $args ) {
     2327        /**
     2328         * @global WP_Locale $wp_locale
     2329         */
     2330        global $wp_locale;
     2331
     2332        ?>
     2333        <select name="start_of_week" id="start_of_week">
     2334                <?php
     2335                for ( $day_index = 0; $day_index <= 6; $day_index++ ) {
     2336                        $selected = ( get_option( 'start_of_week' ) == $day_index ) ? 'selected="selected"' : '';
     2337                        echo "\n\t<option value='" . esc_attr( $day_index ) . "' {$selected}>" . $wp_locale->get_weekday( $day_index ) . '</option>';
     2338                }
     2339                ?>
     2340        </select>
     2341<?php
     2342}
     2343
     2344function wp_settings_field_wplang( array $args ) {
     2345        wp_dropdown_languages( array(
     2346                'name'                        => 'WPLANG',
     2347                'id'                          => 'WPLANG',
     2348                'selected'                    => $args['locale'],
     2349                'languages'                   => $args['languages'],
     2350                'translations'                => $args['translations'],
     2351                'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
     2352        ) );
     2353
     2354        // Add note about deprecated WPLANG constant.
     2355        if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $args['locale'] !== WPLANG ) {
     2356                if ( is_super_admin() ) {
     2357                        ?>
     2358                        <p class="description">
     2359                                <strong><?php _e( 'Note:' ); ?></strong>
     2360                                <?php
     2361                                printf(
     2362                                        __( 'The %s constant in your %s file is no longer needed.' ),
     2363                                        '<code>WPLANG</code>',
     2364                                        '<code>wp-config.php</code>'
     2365                                ); ?>
     2366                        </p>
     2367                        <?php
     2368                }
     2369                _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) );
     2370        }
     2371        ?>
     2372        <?php
     2373}
     2374
    18492375/**
    18502376 * Register a setting and its data.
    18512377 *