File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,7 @@ public static function get_post_type_registration_args(): array {
176
176
public static function get_post_meta_registration_args (): array {
177
177
return array (
178
178
'_online_event_link ' => array (
179
- 'auth_callback ' => function () {
179
+ 'auth_callback ' => function () {
180
180
return current_user_can ( 'edit_posts ' );
181
181
},
182
182
'sanitize_callback ' => 'sanitize_url ' ,
@@ -399,6 +399,13 @@ protected function get_formatted_datetime(
399
399
string $ which = 'start ' ,
400
400
bool $ local = true
401
401
): string {
402
+ $ cache_key = 'formatted_datetime_ ' . md5 ( $ format . $ which . ( $ local ? 'local ' : 'gmt ' ) );
403
+
404
+ $ cached_date = get_transient ( $ cache_key );
405
+ if ( false !== $ cached_date ) {
406
+ return $ cached_date ;
407
+ }
408
+
402
409
$ dt = $ this ->get_datetime ();
403
410
$ date = $ dt [ sprintf ( 'datetime_%s_gmt ' , $ which ) ];
404
411
$ dt ['timezone ' ] = static ::maybe_convert_offset ( $ dt ['timezone ' ] );
@@ -419,6 +426,8 @@ protected function get_formatted_datetime(
419
426
$ date = wp_date ( $ format , $ ts , $ tz );
420
427
}
421
428
429
+ set_transient ( $ cache_key , $ date , HOUR_IN_SECONDS * 12 );
430
+
422
431
return (string ) $ date ;
423
432
}
424
433
@@ -868,7 +877,7 @@ public function save_datetimes( array $params ): bool {
868
877
$ retval = false ;
869
878
$ fields = array_filter (
870
879
$ params ,
871
- function ( $ key ) {
880
+ function ( $ key ) {
872
881
return in_array (
873
882
$ key ,
874
883
array (
You can’t perform that action at this time.
0 commit comments