equal
deleted
inserted
replaced
12 * |
12 * |
13 * A client for api.wordpress.org/events. |
13 * A client for api.wordpress.org/events. |
14 * |
14 * |
15 * @since 4.8.0 |
15 * @since 4.8.0 |
16 */ |
16 */ |
|
17 #[AllowDynamicProperties] |
17 class WP_Community_Events { |
18 class WP_Community_Events { |
18 /** |
19 /** |
19 * ID for a WordPress user account. |
20 * ID for a WordPress user account. |
20 * |
21 * |
21 * @since 4.8.0 |
22 * @since 4.8.0 |
350 * |
351 * |
351 * @return array|false An array containing `location` and `events` items |
352 * @return array|false An array containing `location` and `events` items |
352 * on success, false on failure. |
353 * on success, false on failure. |
353 */ |
354 */ |
354 public function get_cached_events() { |
355 public function get_cached_events() { |
355 $cached_response = get_site_transient( $this->get_events_transient_key( $this->user_location ) ); |
356 $transient_key = $this->get_events_transient_key( $this->user_location ); |
356 |
357 if ( ! $transient_key ) { |
|
358 return false; |
|
359 } |
|
360 |
|
361 $cached_response = get_site_transient( $transient_key ); |
357 if ( isset( $cached_response['events'] ) ) { |
362 if ( isset( $cached_response['events'] ) ) { |
358 $cached_response['events'] = $this->trim_events( $cached_response['events'] ); |
363 $cached_response['events'] = $this->trim_events( $cached_response['events'] ); |
359 } |
364 } |
360 |
365 |
361 return $cached_response; |
366 return $cached_response; |
476 } |
481 } |
477 } |
482 } |
478 |
483 |
479 $future_wordcamps = array_filter( |
484 $future_wordcamps = array_filter( |
480 $future_events, |
485 $future_events, |
481 static function( $wordcamp ) { |
486 static function ( $wordcamp ) { |
482 return 'wordcamp' === $wordcamp['type']; |
487 return 'wordcamp' === $wordcamp['type']; |
483 } |
488 } |
484 ); |
489 ); |
485 |
490 |
486 $future_wordcamps = array_values( $future_wordcamps ); // Remove gaps in indices. |
491 $future_wordcamps = array_values( $future_wordcamps ); // Remove gaps in indices. |