wp/wp-includes/customize/class-wp-customize-date-time-control.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
   171 							<select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian">
   171 							<select id="{{ idPrefix }}date-time-meridian" class="date-input meridian" data-component="meridian">
   172 								<option value="am"><?php esc_html_e( 'AM' ); ?></option>
   172 								<option value="am"><?php esc_html_e( 'AM' ); ?></option>
   173 								<option value="pm"><?php esc_html_e( 'PM' ); ?></option>
   173 								<option value="pm"><?php esc_html_e( 'PM' ); ?></option>
   174 							</select>
   174 							</select>
   175 						<# } #>
   175 						<# } #>
   176 						<abbr class="date-timezone" aria-label="<?php esc_attr_e( 'Timezone' ); ?>" title="<?php echo esc_attr( $timezone_info['description'] ); ?>"><?php echo esc_html( $timezone_info['abbr'] ); ?></abbr>
   176 						<p><?php echo $timezone_info['description']; ?></p>
   177 					</div>
   177 					</div>
   178 				</fieldset>
   178 				</fieldset>
   179 			<# } #>
   179 			<# } #>
   180 		</div>
   180 		</div>
   181 		<?php
   181 		<?php
   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 	 */