Skip to content

Commit 5dc82b1

Browse files
Update class-event.php
- applied WPCS updates - transient time in easy to read format shared by Mike
1 parent b633e5b commit 5dc82b1

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

includes/core/classes/class-event.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ public static function get_post_type_registration_args(): array {
176176
public static function get_post_meta_registration_args(): array {
177177
return array(
178178
'_online_event_link' => array(
179-
'auth_callback' => function() {
179+
'auth_callback' => function () {
180180
return current_user_can( 'edit_posts' );
181181
},
182182
'sanitize_callback' => 'sanitize_url',
@@ -399,11 +399,10 @@ protected function get_formatted_datetime(
399399
string $which = 'start',
400400
bool $local = true
401401
): string {
402+
$cache_key = 'formatted_datetime_' . md5( $format . $which . ( $local ? 'local' : 'gmt' ) );
402403

403-
$cache_key = 'formatted_datetime_' . md5($format . $which . ($local ? 'local' : 'gmt'));
404-
405-
$cached_date = get_transient($cache_key);
406-
if ($cached_date !== false) {
404+
$cached_date = get_transient( $cache_key );
405+
if ( false !== $cached_date ) {
407406
return $cached_date;
408407
}
409408

@@ -427,7 +426,8 @@ protected function get_formatted_datetime(
427426
$date = wp_date( $format, $ts, $tz );
428427
}
429428

430-
set_transient($cache_key, $date, 43200);
429+
set_transient( $cache_key, $date, HOUR_IN_SECONDS * 12 );
430+
431431
return (string) $date;
432432
}
433433

@@ -877,7 +877,7 @@ public function save_datetimes( array $params ): bool {
877877
$retval = false;
878878
$fields = array_filter(
879879
$params,
880-
function( $key ) {
880+
function ( $key ) {
881881
return in_array(
882882
$key,
883883
array(

0 commit comments

Comments
 (0)