Changeset 42343 for trunk/src/wp-admin/options-general.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-admin/options-general.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/options-general.php
r42217 r42343 13 13 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); 14 14 15 if ( ! current_user_can( 'manage_options' ) ) 15 if ( ! current_user_can( 'manage_options' ) ) { 16 16 wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) ); 17 18 $title = __('General Settings'); 17 } 18 19 $title = __( 'General Settings' ); 19 20 $parent_file = 'options-general.php'; 20 21 /* 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');22 23 add_action( 'admin_head', 'options_general_add_js');24 25 $options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.') . '</p>' .26 '<p>' . __( 'Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.') . '</p>';22 $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' ); 23 24 add_action( 'admin_head', 'options_general_add_js' ); 25 26 $options_help = '<p>' . __( 'The fields on this screen determine some of the basics of your site setup.' ) . '</p>' . 27 '<p>' . __( 'Most themes display the site title at the top of every page, in the title bar of the browser, and as the identifying name for syndicated feeds. The tagline is also displayed by many themes.' ) . '</p>'; 27 28 28 29 if ( ! is_multisite() ) { 29 $options_help .= '<p>' . __( 'The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.') . '</p>' .30 '<p>' . __( 'If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.') . '</p>';30 $options_help .= '<p>' . __( 'The WordPress URL and the Site URL can be the same (example.com) or different; for example, having the WordPress core files (example.com/wordpress) in a subdirectory instead of the root directory.' ) . '</p>' . 31 '<p>' . __( 'If you want site visitors to be able to register themselves, as opposed to by the site administrator, check the membership box. A default user role can be set for all new users, whether self-registered or registered by the site admin.' ) . '</p>'; 31 32 } 32 33 … … 35 36 '<p>' . __( 'You must click the Save Changes button at the bottom of the screen for new settings to take effect.' ) . '</p>'; 36 37 37 get_current_screen()->add_help_tab( array( 38 'id' => 'overview', 39 'title' => __('Overview'), 40 'content' => $options_help, 41 ) ); 38 get_current_screen()->add_help_tab( 39 array( 40 'id' => 'overview', 41 'title' => __( 'Overview' ), 42 'content' => $options_help, 43 ) 44 ); 42 45 43 46 get_current_screen()->set_help_sidebar( 44 '<p><strong>' . __( 'For more information:') . '</strong></p>' .45 '<p>' . __( '<a href="https://codex.wordpress.org/Settings_General_Screen">Documentation on General Settings</a>') . '</p>' .46 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'47 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 48 '<p>' . __( '<a href="https://codex.wordpress.org/Settings_General_Screen">Documentation on General Settings</a>' ) . '</p>' . 49 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' 47 50 ); 48 51 … … 54 57 55 58 <form method="post" action="options.php" novalidate="novalidate"> 56 <?php settings_fields( 'general'); ?>59 <?php settings_fields( 'general' ); ?> 57 60 58 61 <table class="form-table"> 59 62 60 63 <tr> 61 <th scope="row"><label for="blogname"><?php _e( 'Site Title')?></label></th>62 <td><input name="blogname" type="text" id="blogname" value="<?php form_option( 'blogname'); ?>" class="regular-text" /></td>63 </tr> 64 65 <tr> 66 <th scope="row"><label for="blogdescription"><?php _e( 'Tagline')?></label></th>67 <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option( 'blogdescription'); ?>" class="regular-text" />68 <p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ) ?></p></td>69 </tr> 70 71 <?php 72 if ( !is_multisite() ) {73 $wp_site_url_class = $wp_home_class = '';74 if ( defined( 'WP_SITEURL' ) ) {75 $wp_site_url_class = ' disabled';76 }77 if ( defined( 'WP_HOME' ) ) {78 $wp_home_class = ' disabled';79 }80 ?> 81 82 <tr> 83 <th scope="row"><label for="siteurl"><?php _e( 'WordPress Address (URL)')?></label></th>64 <th scope="row"><label for="blogname"><?php _e( 'Site Title' ); ?></label></th> 65 <td><input name="blogname" type="text" id="blogname" value="<?php form_option( 'blogname' ); ?>" class="regular-text" /></td> 66 </tr> 67 68 <tr> 69 <th scope="row"><label for="blogdescription"><?php _e( 'Tagline' ); ?></label></th> 70 <td><input name="blogdescription" type="text" id="blogdescription" aria-describedby="tagline-description" value="<?php form_option( 'blogdescription' ); ?>" class="regular-text" /> 71 <p class="description" id="tagline-description"><?php _e( 'In a few words, explain what this site is about.' ); ?></p></td> 72 </tr> 73 74 <?php 75 if ( ! is_multisite() ) { 76 $wp_site_url_class = $wp_home_class = ''; 77 if ( defined( 'WP_SITEURL' ) ) { 78 $wp_site_url_class = ' disabled'; 79 } 80 if ( defined( 'WP_HOME' ) ) { 81 $wp_home_class = ' disabled'; 82 } 83 ?> 84 85 <tr> 86 <th scope="row"><label for="siteurl"><?php _e( 'WordPress Address (URL)' ); ?></label></th> 84 87 <td><input name="siteurl" type="url" id="siteurl" value="<?php form_option( 'siteurl' ); ?>"<?php disabled( defined( 'WP_SITEURL' ) ); ?> class="regular-text code<?php echo $wp_site_url_class; ?>" /></td> 85 88 </tr> 86 89 87 90 <tr> 88 <th scope="row"><label for="home"><?php _e( 'Site Address (URL)')?></label></th>91 <th scope="row"><label for="home"><?php _e( 'Site Address (URL)' ); ?></label></th> 89 92 <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 echo $wp_home_class; ?>" /> 90 93 <?php if ( ! defined( 'WP_HOME' ) ) : ?> 91 <p class="description" id="home-description"><?php 94 <p class="description" id="home-description"> 95 <?php 92 96 printf( 93 97 /* translators: %s: Codex URL */ … … 95 99 __( 'https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory' ) 96 100 ); 97 ?></p> 101 ?> 102 </p> 98 103 <?php endif; ?> 99 104 </td> … … 108 113 <?php 109 114 $new_admin_email = get_option( 'new_admin_email' ); 110 if ( $new_admin_email && $new_admin_email != get_option( 'admin_email' ) ) : ?> 115 if ( $new_admin_email && $new_admin_email != get_option( 'admin_email' ) ) : 116 ?> 111 117 <div class="updated inline"> 112 <p><?php 118 <p> 119 <?php 113 120 printf( 114 121 /* translators: %s: new admin email */ … … 121 128 __( 'Cancel' ) 122 129 ); 123 ?></p> 130 ?> 131 </p> 124 132 </div> 125 133 <?php endif; ?> … … 130 138 131 139 <tr> 132 <th scope="row"><?php _e( 'Membership')?></th>133 <td> <fieldset><legend class="screen-reader-text"><span><?php _e( 'Membership')?></span></legend><label for="users_can_register">134 <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option('users_can_register')); ?> />135 <?php _e( 'Anyone can register')?></label>140 <th scope="row"><?php _e( 'Membership' ); ?></th> 141 <td> <fieldset><legend class="screen-reader-text"><span><?php _e( 'Membership' ); ?></span></legend><label for="users_can_register"> 142 <input name="users_can_register" type="checkbox" id="users_can_register" value="1" <?php checked( '1', get_option( 'users_can_register' ) ); ?> /> 143 <?php _e( 'Anyone can register' ); ?></label> 136 144 </fieldset></td> 137 145 </tr> 138 146 139 147 <tr> 140 <th scope="row"><label for="default_role"><?php _e( 'New User Default Role')?></label></th>148 <th scope="row"><label for="default_role"><?php _e( 'New User Default Role' ); ?></label></th> 141 149 <td> 142 <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option('default_role') ); ?></select> 143 </td> 144 </tr> 145 146 <?php } 147 148 $languages = get_available_languages(); 150 <select name="default_role" id="default_role"><?php wp_dropdown_roles( get_option( 'default_role' ) ); ?></select> 151 </td> 152 </tr> 153 154 <?php 155 } 156 157 $languages = get_available_languages(); 149 158 $translations = wp_get_available_translations(); 150 159 if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { … … 162 171 } 163 172 164 wp_dropdown_languages( array( 165 'name' => 'WPLANG', 166 'id' => 'WPLANG', 167 'selected' => $locale, 168 'languages' => $languages, 169 'translations' => $translations, 170 'show_available_translations' => current_user_can( 'install_languages' ), 171 ) ); 173 wp_dropdown_languages( 174 array( 175 'name' => 'WPLANG', 176 'id' => 'WPLANG', 177 'selected' => $locale, 178 'languages' => $languages, 179 'translations' => $translations, 180 'show_available_translations' => current_user_can( 'install_languages' ), 181 ) 182 ); 172 183 173 184 // Add note about deprecated WPLANG constant. … … 177 188 ?> 178 189 <p class="description"> 179 <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>' ); ?>190 <strong><?php _e( 'Note:' ); ?></strong> <?php printf( __( 'The %1$s constant in your %2$s file is no longer needed.' ), '<code>WPLANG</code>', '<code>wp-config.php</code>' ); ?> 180 191 </p> 181 192 <?php 182 193 } 183 _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The % s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) );194 _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %1$s constant in your %2$s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) ); 184 195 } 185 196 ?> … … 191 202 <tr> 192 203 <?php 193 $current_offset = get_option( 'gmt_offset');194 $tzstring = get_option('timezone_string');204 $current_offset = get_option( 'gmt_offset' ); 205 $tzstring = get_option( 'timezone_string' ); 195 206 196 207 $check_zone_info = true; 197 208 198 209 // Remove old Etc mappings. Fallback to gmt_offset. 199 if ( false !== strpos( $tzstring,'Etc/GMT') )210 if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) { 200 211 $tzstring = ''; 201 202 if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists 212 } 213 214 if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists 203 215 $check_zone_info = false; 204 if ( 0 == $current_offset ) 216 if ( 0 == $current_offset ) { 205 217 $tzstring = 'UTC+0'; 206 elseif ($current_offset < 0)218 } elseif ( $current_offset < 0 ) { 207 219 $tzstring = 'UTC' . $current_offset; 208 else220 } else { 209 221 $tzstring = 'UTC+' . $current_offset; 210 } 211 212 ?> 213 <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th> 222 } 223 } 224 225 ?> 226 <th scope="row"><label for="timezone_string"><?php _e( 'Timezone' ); ?></label></th> 214 227 <td> 215 228 … … 221 234 222 235 <p class="timezone-info"> 223 <span id="utc-time"><?php 236 <span id="utc-time"> 237 <?php 224 238 /* translators: 1: UTC abbreviation, 2: UTC time */ 225 printf( __( 'Universal time (%1$s) is %2$s.' ), 239 printf( 240 __( 'Universal time (%1$s) is %2$s.' ), 226 241 '<abbr>' . __( 'UTC' ) . '</abbr>', 227 242 '<code>' . date_i18n( $timezone_format, false, true ) . '</code>' 228 243 ); 229 ?></span> 244 ?> 245 </span> 230 246 <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?> 231 <span id="local-time"><?php 247 <span id="local-time"> 248 <?php 232 249 /* translators: %s: local time */ 233 printf( __( 'Local time is %s.' ), 250 printf( 251 __( 'Local time is %s.' ), 234 252 '<code>' . date_i18n( $timezone_format ) . '</code>' 235 253 ); 236 ?></span> 254 ?> 255 </span> 237 256 <?php endif; ?> 238 257 </p> … … 243 262 <?php 244 263 // Set TZ so localtime works. 245 date_default_timezone_set($tzstring); 246 $now = localtime(time(), true); 247 if ( $now['tm_isdst'] ) 248 _e('This timezone is currently in daylight saving time.'); 249 else 250 _e('This timezone is currently in standard time.'); 264 date_default_timezone_set( $tzstring ); 265 $now = localtime( time(), true ); 266 if ( $now['tm_isdst'] ) { 267 _e( 'This timezone is currently in daylight saving time.' ); 268 } else { 269 _e( 'This timezone is currently in standard time.' ); 270 } 251 271 ?> 252 272 <br /> … … 254 274 $allowed_zones = timezone_identifiers_list(); 255 275 256 if ( in_array( $tzstring, $allowed_zones ) ) {257 $found = false;258 $date_time_zone_selected = new DateTimeZone( $tzstring);259 $tz_offset = timezone_offset_get($date_time_zone_selected, date_create());260 $right_now = time();261 foreach ( timezone_transitions_get( $date_time_zone_selected) as $tr) {276 if ( in_array( $tzstring, $allowed_zones ) ) { 277 $found = false; 278 $date_time_zone_selected = new DateTimeZone( $tzstring ); 279 $tz_offset = timezone_offset_get( $date_time_zone_selected, date_create() ); 280 $right_now = time(); 281 foreach ( timezone_transitions_get( $date_time_zone_selected ) as $tr ) { 262 282 if ( $tr['ts'] > $right_now ) { 263 $found = true;283 $found = true; 264 284 break; 265 285 } … … 270 290 $message = $tr['isdst'] ? 271 291 /* translators: %s: date and time */ 272 __( 'Daylight saving time begins on: %s.' ):292 __( 'Daylight saving time begins on: %s.' ) : 273 293 /* translators: %s: date and time */ 274 294 __( 'Standard time begins on: %s.' ); 275 295 // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). 276 printf( $message, 296 printf( 297 $message, 277 298 '<code>' . date_i18n( 278 299 __( 'F j, Y' ) . ' ' . __( 'g:i a' ), … … 285 306 } 286 307 // Set back to UTC. 287 date_default_timezone_set( 'UTC');308 date_default_timezone_set( 'UTC' ); 288 309 ?> 289 310 </span> … … 294 315 </tr> 295 316 <tr> 296 <th scope="row"><?php _e( 'Date Format')?></th>317 <th scope="row"><?php _e( 'Date Format' ); ?></th> 297 318 <td> 298 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Date Format')?></span></legend>319 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Date Format' ); ?></span></legend> 299 320 <?php 300 321 /** 301 * Filters the default date formats.302 *303 * @since 2.7.0304 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.305 *306 * @param array $default_date_formats Array of default date formats.307 */322 * Filters the default date formats. 323 * 324 * @since 2.7.0 325 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format. 326 * 327 * @param array $default_date_formats Array of default date formats. 328 */ 308 329 $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) ); 309 330 310 331 $custom = true; 311 332 312 foreach ( $date_formats as $format ) {313 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";314 if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "==="315 echo " checked='checked'";316 $custom = false;317 }318 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";319 }333 foreach ( $date_formats as $format ) { 334 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'"; 335 if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===" 336 echo " checked='checked'"; 337 $custom = false; 338 } 339 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; 340 } 320 341 321 342 echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; … … 332 353 </tr> 333 354 <tr> 334 <th scope="row"><?php _e( 'Time Format')?></th>355 <th scope="row"><?php _e( 'Time Format' ); ?></th> 335 356 <td> 336 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Time Format')?></span></legend>357 <fieldset><legend class="screen-reader-text"><span><?php _e( 'Time Format' ); ?></span></legend> 337 358 <?php 338 359 /** 339 * Filters the default time formats.340 *341 * @since 2.7.0342 *343 * @param array $default_time_formats Array of default time formats.344 */360 * Filters the default time formats. 361 * 362 * @since 2.7.0 363 * 364 * @param array $default_time_formats Array of default time formats. 365 */ 345 366 $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) ); 346 367 347 368 $custom = true; 348 369 349 foreach ( $time_formats as $format ) {350 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";351 if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "==="352 echo " checked='checked'";353 $custom = false;354 }355 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";356 }370 foreach ( $time_formats as $format ) { 371 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'"; 372 if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===" 373 echo " checked='checked'"; 374 $custom = false; 375 } 376 echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; 377 } 357 378 358 379 echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; … … 365 386 "<span class='spinner'></span>\n" . '</p>'; 366 387 367 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";388 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"; 368 389 ?> 369 390 </fieldset> … … 371 392 </tr> 372 393 <tr> 373 <th scope="row"><label for="start_of_week"><?php _e( 'Week Starts On')?></label></th>394 <th scope="row"><label for="start_of_week"><?php _e( 'Week Starts On' ); ?></label></th> 374 395 <td><select name="start_of_week" id="start_of_week"> 375 396 <?php … … 379 400 global $wp_locale; 380 401 381 for ( $day_index = 0; $day_index <= 6; $day_index++) :382 $selected = ( get_option('start_of_week') == $day_index) ? 'selected="selected"' : '';383 echo "\n\t<option value='" . esc_attr( $day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>';402 for ( $day_index = 0; $day_index <= 6; $day_index++ ) : 403 $selected = ( get_option( 'start_of_week' ) == $day_index ) ? 'selected="selected"' : ''; 404 echo "\n\t<option value='" . esc_attr( $day_index ) . "' $selected>" . $wp_locale->get_weekday( $day_index ) . '</option>'; 384 405 endfor; 385 406 ?> 386 407 </select></td> 387 408 </tr> 388 <?php do_settings_fields( 'general', 'default'); ?>409 <?php do_settings_fields( 'general', 'default' ); ?> 389 410 </table> 390 411 391 <?php do_settings_sections( 'general'); ?>412 <?php do_settings_sections( 'general' ); ?> 392 413 393 414 <?php submit_button(); ?>
Note: See TracChangeset
for help on using the changeset viewer.