185 * Generate options for the month Select. |
185 * Generate options for the month Select. |
186 * |
186 * |
187 * Based on touch_time(). |
187 * Based on touch_time(). |
188 * |
188 * |
189 * @since 4.9.0 |
189 * @since 4.9.0 |
|
190 * |
190 * @see touch_time() |
191 * @see touch_time() |
191 * |
192 * |
192 * @global WP_Locale $wp_locale |
193 * @global WP_Locale $wp_locale WordPress date and time locale object. |
193 * |
194 * |
194 * @return array |
195 * @return array |
195 */ |
196 */ |
196 public function get_month_choices() { |
197 public function get_month_choices() { |
197 global $wp_locale; |
198 global $wp_locale; |
198 $months = array(); |
199 $months = array(); |
199 for ( $i = 1; $i < 13; $i++ ) { |
200 for ( $i = 1; $i < 13; $i++ ) { |
200 $month_text = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); |
201 $month_text = $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ); |
201 |
202 |
202 /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */ |
203 /* translators: 1: Month number (01, 02, etc.), 2: Month abbreviation. */ |
203 $months[ $i ]['text'] = sprintf( __( '%1$s-%2$s' ), $i, $month_text ); |
204 $months[ $i ]['text'] = sprintf( __( '%1$s-%2$s' ), $i, $month_text ); |
204 $months[ $i ]['value'] = $i; |
205 $months[ $i ]['value'] = $i; |
205 } |
206 } |
206 return array( |
207 return array( |
207 'month_choices' => $months, |
208 'month_choices' => $months, |
226 $tz = ''; |
227 $tz = ''; |
227 } |
228 } |
228 |
229 |
229 if ( $tz ) { |
230 if ( $tz ) { |
230 $now = new DateTime( 'now', $tz ); |
231 $now = new DateTime( 'now', $tz ); |
231 $formatted_gmt_offset = sprintf( 'UTC%s', $this->format_gmt_offset( $tz->getOffset( $now ) / 3600 ) ); |
232 $formatted_gmt_offset = $this->format_gmt_offset( $tz->getOffset( $now ) / 3600 ); |
232 $tz_name = str_replace( '_', ' ', $tz->getName() ); |
233 $tz_name = str_replace( '_', ' ', $tz->getName() ); |
233 $timezone_info['abbr'] = $now->format( 'T' ); |
234 $timezone_info['abbr'] = $now->format( 'T' ); |
234 |
235 |
235 /* translators: 1: timezone name, 2: timezone abbreviation, 3: gmt offset */ |
236 $timezone_info['description'] = sprintf( |
236 $timezone_info['description'] = sprintf( __( 'Timezone is %1$s (%2$s), currently %3$s.' ), $tz_name, $timezone_info['abbr'], $formatted_gmt_offset ); |
237 /* translators: 1: Timezone name, 2: Timezone abbreviation, 3: UTC abbreviation and offset, 4: UTC offset. */ |
|
238 __( 'Your timezone is set to %1$s (%2$s), currently %3$s (Coordinated Universal Time %4$s).' ), |
|
239 $tz_name, |
|
240 '<abbr>' . $timezone_info['abbr'] . '</abbr>', |
|
241 '<abbr>UTC</abbr>' . $formatted_gmt_offset, |
|
242 $formatted_gmt_offset |
|
243 ); |
237 } else { |
244 } else { |
238 $timezone_info['description'] = ''; |
245 $timezone_info['description'] = ''; |
239 } |
246 } |
240 } else { |
247 } else { |
241 $formatted_gmt_offset = $this->format_gmt_offset( intval( get_option( 'gmt_offset', 0 ) ) ); |
248 $formatted_gmt_offset = $this->format_gmt_offset( intval( get_option( 'gmt_offset', 0 ) ) ); |
242 $timezone_info['abbr'] = sprintf( 'UTC%s', $formatted_gmt_offset ); |
249 |
243 |
250 $timezone_info['description'] = sprintf( |
244 /* translators: %s: UTC offset */ |
251 /* translators: 1: UTC abbreviation and offset, 2: UTC offset. */ |
245 $timezone_info['description'] = sprintf( __( 'Timezone is %s.' ), $timezone_info['abbr'] ); |
252 __( 'Your timezone is set to %1$s (Coordinated Universal Time %2$s).' ), |
|
253 '<abbr>UTC</abbr>' . $formatted_gmt_offset, |
|
254 $formatted_gmt_offset |
|
255 ); |
246 } |
256 } |
247 |
257 |
248 return $timezone_info; |
258 return $timezone_info; |
249 } |
259 } |
250 |
260 |
251 /** |
261 /** |
252 * Format GMT Offset. |
262 * Format GMT Offset. |
253 * |
263 * |
254 * @since 4.9.0 |
264 * @since 4.9.0 |
|
265 * |
255 * @see wp_timezone_choice() |
266 * @see wp_timezone_choice() |
256 * |
267 * |
257 * @param float $offset Offset in hours. |
268 * @param float $offset Offset in hours. |
258 * @return string Formatted offset. |
269 * @return string Formatted offset. |
259 */ |
270 */ |