| 9 | function roles_dropdown( $field_args ) { |
| 10 | $input_attrs = array( |
| 11 | 'id' => ! empty( $field_args['input_id'] ) ? $field_args['input_id'] : '', |
| 12 | 'name' => ! empty( $field_args['input_name'] ) ? $field_args['input_name'] : '', |
| 13 | 'class' => ! empty( $field_args['input_class'] ) ? $field_args['input_class'] : '', |
| 14 | ); |
| 15 | |
| 16 | $description_attrs = array(); |
| 17 | |
| 18 | if ( ! empty( $field_args['description'] ) ) { |
| 19 | if ( ! empty( $field_args['description_id'] ) ) { |
| 20 | $description_attrs['id'] = $field_args['description_id']; |
| 21 | $input_attrs['aria-describedby'] = $field_args['description_id']; |
| 22 | } |
| 23 | $description_attrs['class'] = 'description'; |
| 24 | } |
| 25 | |
| 26 | $current = ! empty( $field_args['value'] ) ? $field_args['value'] : ''; |
| 27 | ?> |
| 28 | <select<?php attrs( $input_attrs ); ?>><?php wp_dropdown_roles( $current ); ?></select> |
| 29 | <?php |
| 30 | |
| 31 | if ( ! empty( $field_args['description'] ) ) { |
| 32 | echo '<p' . attrs( $description_attrs, false ) . '>' . $field_args['description'] . '</p>'; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | function languages_dropdown( $field_args ) { |
| 37 | $languages = isset( $field_args['languages'] ) ? $field_args['languages'] : get_available_languages(); |
| 38 | $translations = isset( $field_args['translations'] ) ? $field_args['translations'] : wp_get_available_translations(); |
| 39 | |
| 40 | $locale = get_locale(); |
| 41 | if ( ! in_array( $locale, $languages ) ) { |
| 42 | $locale = ''; |
| 43 | } |
| 44 | |
| 45 | wp_dropdown_languages( array( |
| 46 | 'name' => ! empty( $field_args['input_name'] ) ? $field_args['input_name'] : '', |
| 47 | 'id' => ! empty( $field_args['input_id'] ) ? $field_args['input_id'] : '', |
| 48 | 'selected' => $locale, |
| 49 | 'languages' => $languages, |
| 50 | 'translations' => $translations, |
| 51 | 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(), |
| 52 | ) ); |
| 53 | } |
| 54 | |
| 55 | function timezones_dropdown( $field_args ) { |
| 56 | $current_offset = get_option('gmt_offset'); |
| 57 | $tzstring = ! empty( $field_args['value'] ) ? $field_args['value'] : ''; |
| 58 | |
| 59 | $check_zone_info = true; |
| 60 | |
| 61 | // Remove old Etc mappings. Fallback to gmt_offset. |
| 62 | if ( false !== strpos($tzstring,'Etc/GMT') ) |
| 63 | $tzstring = ''; |
| 64 | |
| 65 | if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists |
| 66 | $check_zone_info = false; |
| 67 | if ( 0 == $current_offset ) |
| 68 | $tzstring = 'UTC+0'; |
| 69 | elseif ($current_offset < 0) |
| 70 | $tzstring = 'UTC' . $current_offset; |
| 71 | else |
| 72 | $tzstring = 'UTC+' . $current_offset; |
| 73 | } |
| 74 | |
| 75 | $input_attrs = array( |
| 76 | 'id' => ! empty( $field_args['input_id'] ) ? $field_args['input_id'] : '', |
| 77 | 'name' => ! empty( $field_args['input_name'] ) ? $field_args['input_name'] : '', |
| 78 | 'class' => ! empty( $field_args['input_class'] ) ? $field_args['input_class'] : '', |
| 79 | ); |
| 80 | |
| 81 | $description_attrs = array(); |
| 82 | |
| 83 | if ( ! empty( $field_args['description'] ) ) { |
| 84 | if ( ! empty( $field_args['description_id'] ) ) { |
| 85 | $description_attrs['id'] = $field_args['description_id']; |
| 86 | $input_attrs['aria-describedby'] = $field_args['description_id']; |
| 87 | } |
| 88 | $description_attrs['class'] = 'description'; |
| 89 | } |
| 90 | |
| 91 | ?> |
| 92 | <select<?php attrs( $input_attrs ); ?>><?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?></select> |
| 93 | <?php |
| 94 | |
| 95 | if ( ! empty( $field_args['description'] ) ) { |
| 96 | echo '<p' . attrs( $description_attrs, false ) . '>' . $field_args['description'] . '</p>'; |
| 97 | } |
| 98 | |
| 99 | $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' ); |
| 100 | |
| 101 | ?> |
| 102 | <p class="timezone-info"> |
| 103 | <span id="utc-time"><?php |
| 104 | /* translators: 1: UTC abbreviation, 2: UTC time */ |
| 105 | printf( __( 'Universal time (%1$s) is %2$s.' ), |
| 106 | '<abbr>' . __( 'UTC' ) . '</abbr>', |
| 107 | '<code>' . date_i18n( $timezone_format, false, true ) . '</code>' |
| 108 | ); |
| 109 | ?></span> |
| 110 | <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?> |
| 111 | <span id="local-time"><?php |
| 112 | /* translators: %s: local time */ |
| 113 | printf( __( 'Local time is %s.' ), |
| 114 | '<code>' . date_i18n( $timezone_format ) . '</code>' |
| 115 | ); |
| 116 | ?></span> |
| 117 | <?php endif; ?> |
| 118 | </p> |
| 119 | |
| 120 | <?php if ( $check_zone_info && $tzstring ) : ?> |
| 121 | <p class="timezone-info"> |
| 122 | <span> |
| 123 | <?php |
| 124 | // Set TZ so localtime works. |
| 125 | date_default_timezone_set($tzstring); |
| 126 | $now = localtime(time(), true); |
| 127 | if ( $now['tm_isdst'] ) |
| 128 | _e('This timezone is currently in daylight saving time.'); |
| 129 | else |
| 130 | _e('This timezone is currently in standard time.'); |
| 131 | ?> |
| 132 | <br /> |
| 133 | <?php |
| 134 | $allowed_zones = timezone_identifiers_list(); |
| 135 | |
| 136 | if ( in_array( $tzstring, $allowed_zones) ) { |
| 137 | $found = false; |
| 138 | $date_time_zone_selected = new DateTimeZone($tzstring); |
| 139 | $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
| 140 | $right_now = time(); |
| 141 | foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) { |
| 142 | if ( $tr['ts'] > $right_now ) { |
| 143 | $found = true; |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if ( $found ) { |
| 149 | echo ' '; |
| 150 | $message = $tr['isdst'] ? |
| 151 | /* translators: %s: date and time */ |
| 152 | __( 'Daylight saving time begins on: %s.') : |
| 153 | /* translators: %s: date and time */ |
| 154 | __( 'Standard time begins on: %s.' ); |
| 155 | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
| 156 | printf( $message, |
| 157 | '<code>' . date_i18n( |
| 158 | __( 'F j, Y' ) . ' ' . __( 'g:i a' ), |
| 159 | $tr['ts'] + ( $tz_offset - $tr['offset'] ) |
| 160 | ) . '</code>' |
| 161 | ); |
| 162 | } else { |
| 163 | _e( 'This timezone does not observe daylight saving time.' ); |
| 164 | } |
| 165 | } |
| 166 | // Set back to UTC. |
| 167 | date_default_timezone_set('UTC'); |
| 168 | ?> |
| 169 | </span> |
| 170 | </p> |
| 171 | <?php endif; |
| 172 | } |
| 173 | |
| 174 | function datetime_format_radio( $field_args ) { |
| 175 | $input_attrs = array( |
| 176 | 'type' => 'radio', |
| 177 | 'id' => ! empty( $field_args['input_id'] ) ? $field_args['input_id'] : '', |
| 178 | 'name' => ! empty( $field_args['input_name'] ) ? $field_args['input_name'] : '', |
| 179 | 'class' => ! empty( $field_args['input_class'] ) ? $field_args['input_class'] : '', |
| 180 | ); |
| 181 | |
| 182 | $choices = array(); |
| 183 | $custom_radio_label = ''; |
| 184 | $custom_label = ''; |
| 185 | |
| 186 | if ( ! empty( $field_args['mode'] ) && 'time_format' === $field_args['mode'] ) { |
| 187 | /** |
| 188 | * Filters the default time formats. |
| 189 | * |
| 190 | * @since 2.7.0 |
| 191 | * |
| 192 | * @param array $default_time_formats Array of default time formats. |
| 193 | */ |
| 194 | $choices = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) ); |
| 195 | |
| 196 | $custom_radio_label = __( 'Custom: enter a custom time format in the field below' ); |
| 197 | $custom_label = __( 'Custom time format:' ); |
| 198 | } else { |
| 199 | /** |
| 200 | * Filters the default date formats. |
| 201 | * |
| 202 | * @since 2.7.0 |
| 203 | * @since 4.0.0 Added ISO date standard YYYY-MM-DD format. |
| 204 | * |
| 205 | * @param array $default_date_formats Array of default date formats. |
| 206 | */ |
| 207 | $choices = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) ); |
| 208 | |
| 209 | $custom_radio_label = __( 'Custom: enter a custom date format in the field below' ); |
| 210 | $custom_label = __( 'Custom date format:' ); |
| 211 | } |
| 212 | |
| 213 | $current = ! empty( $field_args['value'] ) ? $field_args['value'] : $choices[0]; |
| 214 | |
| 215 | $custom = false; |
| 216 | if ( ! in_array( $current, $choices ) ) { |
| 217 | $custom = true; |
| 218 | } |
| 219 | |
| 220 | $id_suffix = 0; |
| 221 | foreach ( $choices as $value ) { |
| 222 | $id_suffix++; |
| 223 | |
| 224 | $radio_attrs = $input_attrs; |
| 225 | $radio_attrs['id'] .= '-' . zeroise( $id_suffix, 2 ); |
| 226 | $radio_attrs['value'] = $value; |
| 227 | |
| 228 | echo '<span class="radio-item">'; |
| 229 | echo '<input' . attrs( $radio_attrs, false ) . checked( $current, $value, false ) . ' />'; |
| 230 | echo ' <label for="' . $radio_attrs['id'] . '"><span class="date-time-text format-i18n">' . date_i18n( $value ) . '</span><code>' . esc_html( $value ) . '</code></label>'; |
| 231 | echo '</span><br />'; |
| 232 | } |
| 233 | |
| 234 | $radio_attrs = $input_attrs; |
| 235 | $radio_attrs['id'] = $radio_attrs['name'] . '_custom_radio'; |
| 236 | $radio_attrs['value'] = '\c\u\s\t\o\m'; |
| 237 | |
| 238 | echo '<span class="radio-item">'; |
| 239 | echo '<input' . attrs( $radio_attrs, false ) . checked( $custom, true, false ) . ' />'; |
| 240 | echo ' <label for="' . $radio_attrs['id'] . '">' . $custom_radio_label . '</label>'; |
| 241 | echo '</span><br />'; |
| 242 | |
| 243 | $description_id = $radio_attrs['id'] . '-custom-description'; |
| 244 | $text_attrs = array( |
| 245 | 'type' => 'text', |
| 246 | 'id' => $radio_attrs['name'] . '_custom', |
| 247 | 'name' => $radio_attrs['name'] . '_custom', |
| 248 | 'class' => 'small-text', |
| 249 | 'value' => $current, |
| 250 | 'aria-describedby' => $description_id, |
| 251 | ); |
| 252 | |
| 253 | echo '<span class="radio-item">'; |
| 254 | echo '<label for="' . esc_attr( $text_attrs['id'] ) . '">' . $custom_label . '</label>'; |
| 255 | echo ' <input' . attrs( $text_attrs, false ) . ' />'; |
| 256 | echo ' <span class="description" id="' . $description_id . '">' . __( 'Example:' ) . ' <span class="example">' . date_i18n( $current ) . '</span><span class="spinner"></span></span>'; |
| 257 | echo '</span>'; |
| 258 | } |
| 259 | |
| 260 | function add_settings_fields_options_general() { |
| 261 | add_settings_field( 'blogname', __( 'Site Title' ), 'text', 'general', 'default', array( |
| 262 | 'input_class' => 'regular-text', |
| 263 | ) ); |
| 264 | |
| 265 | add_settings_field( 'blogdescription', __( 'Tagline' ), 'text', 'general', 'default', array( |
| 266 | 'input_class' => 'regular-text', |
| 267 | 'description_id' => 'tagline-description', |
| 268 | 'description' => __( 'In a few words, explain what this site is about.' ), |
| 269 | ) ); |
| 270 | |
| 271 | if ( ! is_multisite() ) { |
| 272 | add_settings_field( 'siteurl', __( 'WordPress Address (URL)' ), 'url', 'general', 'default', array( |
| 273 | 'input_class' => 'regular-text code' . ( defined( 'WP_SITEURL' ) ? ' disabled' : '' ), |
| 274 | 'disabled' => defined( 'WP_SITEURL' ) ? true : false, |
| 275 | ) ); |
| 276 | |
| 277 | add_settings_field( 'home', __( 'Site Address (URL)' ), 'url', 'general', 'default', array( |
| 278 | 'input_class' => 'regular-text code' . ( defined( 'WP_HOME' ) ? ' disabled' : '' ), |
| 279 | 'disabled' => defined( 'WP_HOME' ) ? true : false, |
| 280 | 'description' => __( '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>' ), |
| 281 | ) ); |
| 282 | |
| 283 | add_settings_field( 'admin_email', __( 'Email Address' ), 'email', 'general', 'default', array( |
| 284 | 'input_id' => 'admin-email', |
| 285 | 'input_class' => 'regular-text ltr', |
| 286 | 'description' => __( 'This address is used for admin purposes, like new user notification.' ), |
| 287 | ) ); |
| 288 | |
| 289 | add_settings_field( 'users_can_register', __( 'Membership' ), 'checkbox', 'general', 'default', array( |
| 290 | 'label' => __( 'Anyone can register' ), |
| 291 | ) ); |
| 292 | |
| 293 | add_settings_field( 'default_role', __( 'New User Default Role' ), 'roles_dropdown', 'general', 'default' ); |
| 294 | } else { |
| 295 | add_settings_field( 'admin_email', __( 'Email Address' ), 'email', 'general', 'default', array( |
| 296 | 'input_id' => 'new_admin_email', |
| 297 | 'input_name' => 'new_admin_email', |
| 298 | 'input_class' => 'regular-text ltr', |
| 299 | 'description_id' => 'new-admin-email-description', |
| 300 | 'description' => __( '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>' ), |
| 301 | 'value_callback' => function() { |
| 302 | return get_option( 'admin_email' ); |
| 303 | }, |
| 304 | 'after' => function() { |
| 305 | $new_admin_email = get_option( 'new_admin_email' ); |
| 306 | if ( $new_admin_email && $new_admin_email != get_option('admin_email') ) : ?> |
| 307 | <div class="updated inline"> |
| 308 | <p><?php |
| 309 | printf( |
| 310 | /* translators: %s: new admin email */ |
| 311 | __( 'There is a pending change of the admin email to %s.' ), |
| 312 | '<code>' . esc_html( $new_admin_email ) . '</code>' |
| 313 | ); |
| 314 | printf( |
| 315 | ' <a href="%1$s">%2$s</a>', |
| 316 | esc_url( wp_nonce_url( admin_url( 'options.php?dismiss=new_admin_email' ), 'dismiss-' . get_current_blog_id() . '-new_admin_email' ) ), |
| 317 | __( 'Cancel' ) |
| 318 | ); |
| 319 | ?></p> |
| 320 | </div> |
| 321 | <?php endif; |
| 322 | }, |
| 323 | ) ); |
| 324 | } |
| 325 | |
| 326 | $languages = get_available_languages(); |
| 327 | $translations = wp_get_available_translations(); |
| 328 | if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { |
| 329 | $languages[] = WPLANG; |
| 330 | } |
| 331 | if ( ! empty( $languages ) || ! empty( $translations ) ) { |
| 332 | add_settings_field( 'WPLANG', __( 'Site Language' ), 'languages_dropdown', 'general', 'default', array( |
| 333 | 'languages' => $languages, |
| 334 | 'translations' => $translations, |
| 335 | 'after' => function() { |
| 336 | // Add note about deprecated WPLANG constant. |
| 337 | if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) { |
| 338 | if ( is_multisite() && current_user_can( 'manage_network_options' ) |
| 339 | || ! is_multisite() && current_user_can( 'manage_options' ) ) { |
| 340 | ?> |
| 341 | <p class="description"> |
| 342 | <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>' ); ?> |
| 343 | </p> |
| 344 | <?php |
| 345 | } |
| 346 | _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) ); |
| 347 | } |
| 348 | }, |
| 349 | ) ); |
| 350 | } |
| 351 | |
| 352 | add_settings_field( 'timezone_string', __( 'Timezone' ), 'timezones_dropdown', 'general', 'default', array( |
| 353 | 'description_id' => 'timezone-description', |
| 354 | 'description' => __( 'Choose either a city in the same timezone as you or a UTC timezone offset.' ), |
| 355 | ) ); |
| 356 | |
| 357 | add_settings_field( 'date_format', __( 'Date Format' ), 'datetime_format_radio', 'general', 'default', array( |
| 358 | 'mode' => 'date_format', |
| 359 | ) ); |
| 360 | |
| 361 | add_settings_field( 'time_format', __( 'Time Format' ), 'datetime_format_radio', 'general', 'default', array( |
| 362 | 'mode' => 'time_format', |
| 363 | 'after' => function() { |
| 364 | ?> |
| 365 | <p class="date-time-doc"><a href="https://codex.wordpress.org/Formatting_Date_and_Time"><?php _e( 'Documentation on date and time formatting' ); ?></a>.</p> |
| 366 | <?php |
| 367 | }, |
| 368 | ) ); |
| 369 | |
| 370 | /** |
| 371 | * @global WP_Locale $wp_locale |
| 372 | */ |
| 373 | global $wp_locale; |
| 374 | |
| 375 | $start_of_week_choices = array(); |
| 376 | for ( $day_index = 0; $day_index <= 6; $day_index++ ) { |
| 377 | $start_of_week_choices[ $day_index ] = $wp_locale->get_weekday( $day_index ); |
| 378 | } |
| 379 | |
| 380 | add_settings_field( 'start_of_week', __( 'Week Starts On' ), 'select', 'general', 'default', array( |
| 381 | 'choices' => $start_of_week_choices, |
| 382 | ) ); |
| 383 | } |
| 384 | |
125 | | $languages = get_available_languages(); |
126 | | $translations = wp_get_available_translations(); |
127 | | if ( ! is_multisite() && defined( 'WPLANG' ) && '' !== WPLANG && 'en_US' !== WPLANG && ! in_array( WPLANG, $languages ) ) { |
128 | | $languages[] = WPLANG; |
129 | | } |
130 | | if ( ! empty( $languages ) || ! empty( $translations ) ) { |
131 | | ?> |
132 | | <tr> |
133 | | <th width="33%" scope="row"><label for="WPLANG"><?php _e( 'Site Language' ); ?></label></th> |
134 | | <td> |
135 | | <?php |
136 | | $locale = get_locale(); |
137 | | if ( ! in_array( $locale, $languages ) ) { |
138 | | $locale = ''; |
139 | | } |
140 | | |
141 | | wp_dropdown_languages( array( |
142 | | 'name' => 'WPLANG', |
143 | | 'id' => 'WPLANG', |
144 | | 'selected' => $locale, |
145 | | 'languages' => $languages, |
146 | | 'translations' => $translations, |
147 | | 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(), |
148 | | ) ); |
149 | | |
150 | | // Add note about deprecated WPLANG constant. |
151 | | if ( defined( 'WPLANG' ) && ( '' !== WPLANG ) && $locale !== WPLANG ) { |
152 | | if ( is_multisite() && current_user_can( 'manage_network_options' ) |
153 | | || ! is_multisite() && current_user_can( 'manage_options' ) ) { |
154 | | ?> |
155 | | <p class="description"> |
156 | | <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>' ); ?> |
157 | | </p> |
158 | | <?php |
159 | | } |
160 | | _deprecated_argument( 'define()', '4.0.0', sprintf( __( 'The %s constant in your %s file is no longer needed.' ), 'WPLANG', 'wp-config.php' ) ); |
161 | | } |
162 | | ?> |
163 | | </td> |
164 | | </tr> |
165 | | <?php |
166 | | } |
167 | | ?> |
168 | | <tr> |
169 | | <?php |
170 | | $current_offset = get_option('gmt_offset'); |
171 | | $tzstring = get_option('timezone_string'); |
172 | | |
173 | | $check_zone_info = true; |
174 | | |
175 | | // Remove old Etc mappings. Fallback to gmt_offset. |
176 | | if ( false !== strpos($tzstring,'Etc/GMT') ) |
177 | | $tzstring = ''; |
178 | | |
179 | | if ( empty($tzstring) ) { // Create a UTC+- zone if no timezone string exists |
180 | | $check_zone_info = false; |
181 | | if ( 0 == $current_offset ) |
182 | | $tzstring = 'UTC+0'; |
183 | | elseif ($current_offset < 0) |
184 | | $tzstring = 'UTC' . $current_offset; |
185 | | else |
186 | | $tzstring = 'UTC+' . $current_offset; |
187 | | } |
188 | | |
189 | | ?> |
190 | | <th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th> |
191 | | <td> |
192 | | |
193 | | <select id="timezone_string" name="timezone_string" aria-describedby="timezone-description"> |
194 | | <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); ?> |
195 | | </select> |
196 | | |
197 | | <p class="description" id="timezone-description"><?php _e( 'Choose either a city in the same timezone as you or a UTC timezone offset.' ); ?></p> |
198 | | |
199 | | <p class="timezone-info"> |
200 | | <span id="utc-time"><?php |
201 | | /* translators: 1: UTC abbreviation, 2: UTC time */ |
202 | | printf( __( 'Universal time (%1$s) is %2$s.' ), |
203 | | '<abbr>' . __( 'UTC' ) . '</abbr>', |
204 | | '<code>' . date_i18n( $timezone_format, false, true ) . '</code>' |
205 | | ); |
206 | | ?></span> |
207 | | <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?> |
208 | | <span id="local-time"><?php |
209 | | /* translators: %s: local time */ |
210 | | printf( __( 'Local time is %s.' ), |
211 | | '<code>' . date_i18n( $timezone_format ) . '</code>' |
212 | | ); |
213 | | ?></span> |
214 | | <?php endif; ?> |
215 | | </p> |
216 | | |
217 | | <?php if ( $check_zone_info && $tzstring ) : ?> |
218 | | <p class="timezone-info"> |
219 | | <span> |
220 | | <?php |
221 | | // Set TZ so localtime works. |
222 | | date_default_timezone_set($tzstring); |
223 | | $now = localtime(time(), true); |
224 | | if ( $now['tm_isdst'] ) |
225 | | _e('This timezone is currently in daylight saving time.'); |
226 | | else |
227 | | _e('This timezone is currently in standard time.'); |
228 | | ?> |
229 | | <br /> |
230 | | <?php |
231 | | $allowed_zones = timezone_identifiers_list(); |
232 | | |
233 | | if ( in_array( $tzstring, $allowed_zones) ) { |
234 | | $found = false; |
235 | | $date_time_zone_selected = new DateTimeZone($tzstring); |
236 | | $tz_offset = timezone_offset_get($date_time_zone_selected, date_create()); |
237 | | $right_now = time(); |
238 | | foreach ( timezone_transitions_get($date_time_zone_selected) as $tr) { |
239 | | if ( $tr['ts'] > $right_now ) { |
240 | | $found = true; |
241 | | break; |
242 | | } |
243 | | } |
244 | | |
245 | | if ( $found ) { |
246 | | echo ' '; |
247 | | $message = $tr['isdst'] ? |
248 | | /* translators: %s: date and time */ |
249 | | __( 'Daylight saving time begins on: %s.') : |
250 | | /* translators: %s: date and time */ |
251 | | __( 'Standard time begins on: %s.' ); |
252 | | // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n(). |
253 | | printf( $message, |
254 | | '<code>' . date_i18n( |
255 | | __( 'F j, Y' ) . ' ' . __( 'g:i a' ), |
256 | | $tr['ts'] + ( $tz_offset - $tr['offset'] ) |
257 | | ) . '</code>' |
258 | | ); |
259 | | } else { |
260 | | _e( 'This timezone does not observe daylight saving time.' ); |
261 | | } |
262 | | } |
263 | | // Set back to UTC. |
264 | | date_default_timezone_set('UTC'); |
265 | | ?> |
266 | | </span> |
267 | | </p> |
268 | | <?php endif; ?> |
269 | | </td> |
270 | | |
271 | | </tr> |
272 | | <tr> |
273 | | <th scope="row"><?php _e('Date Format') ?></th> |
274 | | <td> |
275 | | <fieldset><legend class="screen-reader-text"><span><?php _e('Date Format') ?></span></legend> |
276 | | <?php |
277 | | /** |
278 | | * Filters the default date formats. |
279 | | * |
280 | | * @since 2.7.0 |
281 | | * @since 4.0.0 Added ISO date standard YYYY-MM-DD format. |
282 | | * |
283 | | * @param array $default_date_formats Array of default date formats. |
284 | | */ |
285 | | $date_formats = array_unique( apply_filters( 'date_formats', array( __( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) ); |
286 | | |
287 | | $custom = true; |
288 | | |
289 | | foreach ( $date_formats as $format ) { |
290 | | echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'"; |
291 | | if ( get_option('date_format') === $format ) { // checked() uses "==" rather than "===" |
292 | | echo " checked='checked'"; |
293 | | $custom = false; |
294 | | } |
295 | | echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; |
296 | | } |
297 | | |
298 | | echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"'; |
299 | | checked( $custom ); |
300 | | 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>' . |
301 | | '<label for="date_format_custom" class="screen-reader-text">' . __( 'Custom date format:' ) . '</label>' . |
302 | | '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" /></span>' . |
303 | | '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'date_format' ) ) . '</span>' . |
304 | | "<span class='spinner'></span>\n"; |
305 | | ?> |
306 | | </fieldset> |
307 | | </td> |
308 | | </tr> |
309 | | <tr> |
310 | | <th scope="row"><?php _e('Time Format') ?></th> |
311 | | <td> |
312 | | <fieldset><legend class="screen-reader-text"><span><?php _e('Time Format') ?></span></legend> |
313 | | <?php |
314 | | /** |
315 | | * Filters the default time formats. |
316 | | * |
317 | | * @since 2.7.0 |
318 | | * |
319 | | * @param array $default_time_formats Array of default time formats. |
320 | | */ |
321 | | $time_formats = array_unique( apply_filters( 'time_formats', array( __( 'g:i a' ), 'g:i A', 'H:i' ) ) ); |
322 | | |
323 | | $custom = true; |
324 | | |
325 | | foreach ( $time_formats as $format ) { |
326 | | echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'"; |
327 | | if ( get_option('time_format') === $format ) { // checked() uses "==" rather than "===" |
328 | | echo " checked='checked'"; |
329 | | $custom = false; |
330 | | } |
331 | | echo ' /> <span class="date-time-text format-i18n">' . date_i18n( $format ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n"; |
332 | | } |
333 | | |
334 | | echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"'; |
335 | | checked( $custom ); |
336 | | 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>' . |
337 | | '<label for="time_format_custom" class="screen-reader-text">' . __( 'Custom time format:' ) . '</label>' . |
338 | | '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" /></span>' . |
339 | | '<span class="screen-reader-text">' . __( 'example:' ) . ' </span> <span class="example">' . date_i18n( get_option( 'time_format' ) ) . '</span>' . |
340 | | "<span class='spinner'></span>\n"; |
341 | | |
342 | | 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"; |
343 | | ?> |
344 | | </fieldset> |
345 | | </td> |
346 | | </tr> |
347 | | <tr> |
348 | | <th scope="row"><label for="start_of_week"><?php _e('Week Starts On') ?></label></th> |
349 | | <td><select name="start_of_week" id="start_of_week"> |
350 | | <?php |
351 | | /** |
352 | | * @global WP_Locale $wp_locale |
353 | | */ |
354 | | global $wp_locale; |
355 | | |
356 | | for ($day_index = 0; $day_index <= 6; $day_index++) : |
357 | | $selected = (get_option('start_of_week') == $day_index) ? 'selected="selected"' : ''; |
358 | | echo "\n\t<option value='" . esc_attr($day_index) . "' $selected>" . $wp_locale->get_weekday($day_index) . '</option>'; |
359 | | endfor; |
360 | | ?> |
361 | | </select></td> |
362 | | </tr> |
363 | | <?php do_settings_fields('general', 'default'); ?> |
364 | | </table> |
365 | | |