PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
← All changes | vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler_TimezoneHelper.php +25 -15 1.5.2 → trunk View file →
@@ -3,22 +3,28 @@
3 3 /**
4 4 * Class ActionScheduler_TimezoneHelper
5 5 */
6 6 abstract class ActionScheduler_TimezoneHelper {
7 - private static $local_timezone = NULL;
8 7
9 8 /**
9 + * DateTimeZone object.
10 + *
11 + * @var null|DateTimeZone
12 + */
13 + private static $local_timezone = null;
14 +
15 + /**
10 16 * Set a DateTime's timezone to the WordPress site's timezone, or a UTC offset
11 17 * if no timezone string is available.
12 18 *
13 19 * @since 2.1.0
14 20 *
15 - * @param DateTime $date
21 + * @param DateTime $date Timestamp.
16 22 * @return ActionScheduler_DateTime
17 23 */
18 24 public static function set_local_timezone( DateTime $date ) {
19 25
20 - // Accept a DateTime for easier backward compatibility, even though we require methods on ActionScheduler_DateTime
26 + // Accept a DateTime for easier backward compatibility, even though we require methods on ActionScheduler_DateTime.
21 27 if ( ! is_a( $date, 'ActionScheduler_DateTime' ) ) {
22 28 $date = as_get_datetime_object( $date->format( 'U' ) );
23 29 }
24 30
@@ -41,8 +47,9 @@
41 47 * string, then an empty string will be returned, and the UTC offset should be used to set a DateTime's
42 48 * timezone.
43 49 *
44 50 * @since 2.1.0
51 + * @param bool $reset Unused.
45 52 * @return string PHP timezone string for the site or empty if no timezone string is available.
46 53 */
47 54 protected static function get_local_timezone_string( $reset = false ) {
48 55 // If site timezone string exists, return it.
@@ -74,9 +81,9 @@
74 81 }
75 82 }
76 83 }
77 84
78 - // No timezone string
85 + // No timezone string.
79 86 return '';
80 87 }
81 88
82 89 /**
@@ -96,25 +103,28 @@
96 103 }
97 104 }
98 105
99 106 /**
107 + * Get local timezone.
108 + *
109 + * @param bool $reset Toggle to discard stored value.
100 110 * @deprecated 2.1.0
101 111 */
102 - public static function get_local_timezone( $reset = FALSE ) {
112 + public static function get_local_timezone( $reset = false ) {
103 113 _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' );
104 114 if ( $reset ) {
105 - self::$local_timezone = NULL;
115 + self::$local_timezone = null;
106 116 }
107 - if ( !isset(self::$local_timezone) ) {
108 - $tzstring = get_option('timezone_string');
117 + if ( ! isset( self::$local_timezone ) ) {
118 + $tzstring = get_option( 'timezone_string' );
109 119
110 - if ( empty($tzstring) ) {
111 - $gmt_offset = get_option('gmt_offset');
112 - if ( $gmt_offset == 0 ) {
120 + if ( empty( $tzstring ) ) {
121 + $gmt_offset = absint( get_option( 'gmt_offset' ) );
122 + if ( 0 === $gmt_offset ) {
113 123 $tzstring = 'UTC';
114 124 } else {
115 125 $gmt_offset *= HOUR_IN_SECONDS;
116 - $tzstring = timezone_name_from_abbr( '', $gmt_offset, 1 );
126 + $tzstring = timezone_name_from_abbr( '', $gmt_offset, 1 );
117 127
118 128 // If there's no timezone string, try again with no DST.
119 129 if ( false === $tzstring ) {
120 130 $tzstring = timezone_name_from_abbr( '', $gmt_offset, 0 );
@@ -124,11 +134,11 @@
124 134 if ( false === $tzstring ) {
125 135 $is_dst = date( 'I' ); // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date -- we are actually interested in the runtime timezone.
126 136 foreach ( timezone_abbreviations_list() as $abbr ) {
127 137 foreach ( $abbr as $city ) {
128 - if ( $city['dst'] == $is_dst && $city['offset'] == $gmt_offset ) {
138 + if ( $city['dst'] === $is_dst && $city['offset'] === $gmt_offset ) {
129 139 // If there's no valid timezone ID, keep looking.
130 - if ( null === $city['timezone_id'] ) {
140 + if ( is_null( $city['timezone_id'] ) ) {
131 141 continue;
132 142 }
133 143
134 144 $tzstring = $city['timezone_id'];
@@ -144,9 +154,9 @@
144 154 }
145 155 }
146 156 }
147 157
148 - self::$local_timezone = new DateTimeZone($tzstring);
158 + self::$local_timezone = new DateTimeZone( $tzstring );
149 159 }
150 160 return self::$local_timezone;
151 161 }
152 162 }