Do not use deprecated Etc timezones. Props miqrogroove. fixes #11558 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@12507 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
10a5ba6622
commit
95835a693a
|
@ -139,11 +139,23 @@ foreach ( $offset_range as $offset ) {
|
||||||
else: // looks like we can do nice timezone selection!
|
else: // looks like we can do nice timezone selection!
|
||||||
$current_offset = get_option('gmt_offset');
|
$current_offset = get_option('gmt_offset');
|
||||||
$tzstring = get_option('timezone_string');
|
$tzstring = get_option('timezone_string');
|
||||||
if (empty($tzstring)) { // set the Etc zone if no timezone string exists
|
|
||||||
if ($current_offset < 0) $offnum = - ceil($current_offset);
|
$check_zone_info = true;
|
||||||
else $offnum = - floor($current_offset);
|
|
||||||
$tzstring = 'Etc/GMT' . (($offnum >= 0) ? '+' : '') . $offnum;
|
// Remove old Etc mappings. Fallback to gmt_offset.
|
||||||
|
if ( false !== strpos($tzstring,'Etc/GMT') )
|
||||||
|
$tzstring = '';
|
||||||
|
|
||||||
|
if (empty($tzstring)) { // Create a UTC+- zone if no timezone string exists
|
||||||
|
$check_zone_info = false;
|
||||||
|
if ( 0 == $current_offset )
|
||||||
|
$tzstring = 'UTC+0';
|
||||||
|
elseif ($current_offset < 0)
|
||||||
|
$tzstring = 'UTC' . $current_offset;
|
||||||
|
else
|
||||||
|
$tzstring = 'UTC+' . $current_offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
|
<th scope="row"><label for="timezone_string"><?php _e('Timezone') ?></label></th>
|
||||||
<td>
|
<td>
|
||||||
|
@ -160,7 +172,7 @@ if (empty($tzstring)) { // set the Etc zone if no timezone string exists
|
||||||
<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
|
<span class="description"><?php _e('Choose a city in the same timezone as you.'); ?></span>
|
||||||
<br />
|
<br />
|
||||||
<span>
|
<span>
|
||||||
<?php if ($tzstring) : ?>
|
<?php if ($check_zone_info && $tzstring) : ?>
|
||||||
<?php
|
<?php
|
||||||
$now = localtime(time(),true);
|
$now = localtime(time(),true);
|
||||||
if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
|
if ($now['tm_isdst']) _e('This timezone is currently in daylight savings time.');
|
||||||
|
|
|
@ -65,6 +65,12 @@ case 'update':
|
||||||
$_POST['date_format'] = $_POST['date_format_custom'];
|
$_POST['date_format'] = $_POST['date_format_custom'];
|
||||||
if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
|
if ( !empty($_POST['time_format']) && isset($_POST['time_format_custom']) && '\c\u\s\t\o\m' == stripslashes( $_POST['time_format'] ) )
|
||||||
$_POST['time_format'] = $_POST['time_format_custom'];
|
$_POST['time_format'] = $_POST['time_format_custom'];
|
||||||
|
// Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
|
||||||
|
if ( !empty($_POST['timezone_string']) && preg_match('/^UTC[+-]/', $_POST['timezone_string']) ) {
|
||||||
|
$_POST['gmt_offset'] = $_POST['timezone_string'];
|
||||||
|
$_POST['gmt_offset'] = preg_replace('/UTC\+?/', '', $_POST['gmt_offset']);
|
||||||
|
$_POST['timezone_string'] = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $options ) {
|
if ( $options ) {
|
||||||
|
|
|
@ -3393,7 +3393,7 @@ function _wp_timezone_choice_usort_callback( $a, $b ) {
|
||||||
function wp_timezone_choice( $selected_zone ) {
|
function wp_timezone_choice( $selected_zone ) {
|
||||||
static $mo_loaded = false;
|
static $mo_loaded = false;
|
||||||
|
|
||||||
$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific', 'Etc' );
|
$continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific');
|
||||||
|
|
||||||
// Load translations for continents and cities
|
// Load translations for continents and cities
|
||||||
if ( !$mo_loaded ) {
|
if ( !$mo_loaded ) {
|
||||||
|
@ -3409,9 +3409,6 @@ function wp_timezone_choice( $selected_zone ) {
|
||||||
if ( !in_array( $zone[0], $continents ) ) {
|
if ( !in_array( $zone[0], $continents ) ) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ( 'Etc' === $zone[0] && in_array( $zone[1], array( 'UCT', 'GMT', 'GMT0', 'GMT+0', 'GMT-0', 'Greenwich', 'Universal', 'Zulu' ) ) ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
|
// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
|
||||||
$exists = array(
|
$exists = array(
|
||||||
|
@ -3452,21 +3449,13 @@ function wp_timezone_choice( $selected_zone ) {
|
||||||
|
|
||||||
// Continent optgroup
|
// Continent optgroup
|
||||||
if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
|
if ( !isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {
|
||||||
$label = ( 'Etc' === $zone['continent'] ) ? __( 'Manual offsets' ) : $zone['t_continent'];
|
$label = $zone['t_continent'];
|
||||||
$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
|
$structure[] = '<optgroup label="'. esc_attr( $label ) .'">';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the city to the value
|
// Add the city to the value
|
||||||
$value[] = $zone['city'];
|
$value[] = $zone['city'];
|
||||||
if ( 'Etc' === $zone['continent'] ) {
|
|
||||||
if ( 'UTC' === $zone['city'] ) {
|
|
||||||
$display = '';
|
|
||||||
} else {
|
|
||||||
$display = str_replace( 'GMT', '', $zone['city'] );
|
|
||||||
$display = strtr( $display, '+-', '-+' ) . ':00';
|
|
||||||
}
|
|
||||||
$display = sprintf( __( 'UTC %s' ), $display );
|
|
||||||
} else {
|
|
||||||
$display = $zone['t_city'];
|
$display = $zone['t_city'];
|
||||||
if ( !empty( $zone['subcity'] ) ) {
|
if ( !empty( $zone['subcity'] ) ) {
|
||||||
// Add the subcity to the value
|
// Add the subcity to the value
|
||||||
|
@ -3474,7 +3463,6 @@ function wp_timezone_choice( $selected_zone ) {
|
||||||
$display .= ' - ' . $zone['t_subcity'];
|
$display .= ' - ' . $zone['t_subcity'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Build the value
|
// Build the value
|
||||||
$value = join( '/', $value );
|
$value = join( '/', $value );
|
||||||
|
@ -3490,6 +3478,36 @@ function wp_timezone_choice( $selected_zone ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Do UTC
|
||||||
|
$structure[] = '<optgroup label="'. esc_attr__( 'UTC' ) .'">';
|
||||||
|
$selected = '';
|
||||||
|
if ( 'UTC' === $selected_zone )
|
||||||
|
$selected = 'selected="selected" ';
|
||||||
|
$structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>';
|
||||||
|
$structure[] = '</optgroup>';
|
||||||
|
|
||||||
|
// Do manual UTC offsets
|
||||||
|
$structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">';
|
||||||
|
$offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5,
|
||||||
|
0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14);
|
||||||
|
foreach ( $offset_range as $offset ) {
|
||||||
|
if ( 0 <= $offset )
|
||||||
|
$offset_name = '+' . $offset;
|
||||||
|
else
|
||||||
|
$offset_name = (string) $offset;
|
||||||
|
|
||||||
|
$offset_value = $offset_name;
|
||||||
|
$offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);
|
||||||
|
$offset_name = 'UTC' . $offset_name;
|
||||||
|
$offset_value = 'UTC' . $offset_value;
|
||||||
|
$selected = '';
|
||||||
|
if ( $offset_value === $selected_zone )
|
||||||
|
$selected = 'selected="selected" ';
|
||||||
|
$structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>";
|
||||||
|
|
||||||
|
}
|
||||||
|
$structure[] = '</optgroup>';
|
||||||
|
|
||||||
return join( "\n", $structure );
|
return join( "\n", $structure );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue