- Timestamp:
- 02/21/2018 11:00:50 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-community-events.php
r42343 r42726 417 417 418 418 /** 419 * Discards expired events, and reduces the remaining list. 420 * 421 * @since 4.8.0 419 * Prepares the event list for presentation. 420 * 421 * Discards expired events, and makes WordCamps "sticky." Attendees need more 422 * advanced notice about WordCamps than they do for meetups, so camps should 423 * appear in the list sooner. If a WordCamp is coming up, the API will "stick" 424 * it in the response, even if it wouldn't otherwise appear. When that happens, 425 * the event will be at the end of the list, and will need to be moved into a 426 * higher position, so that it doesn't get trimmed off. 427 * 428 * @since 4.8.0 429 * @since 5.0.0 Stick a WordCamp to the final list. 422 430 * 423 431 * @param array $response_body The response body which contains the events. … … 426 434 protected function trim_events( $response_body ) { 427 435 if ( isset( $response_body['events'] ) ) { 436 $wordcamps = array(); 428 437 $current_timestamp = current_time( 'timestamp' ); 429 438 430 439 foreach ( $response_body['events'] as $key => $event ) { 431 // Skip WordCamps, because they might be multi-day events. 432 if ( 'meetup' !== $event['type'] ) { 440 /* 441 * Skip WordCamps, because they might be multi-day events. 442 * Save a copy so they can be pinned later. 443 */ 444 if ( 'wordcamp' === $event['type'] ) { 445 $wordcamps[] = $event; 433 446 continue; 434 447 } … … 442 455 443 456 $response_body['events'] = array_slice( $response_body['events'], 0, 3 ); 457 $trimmed_event_types = array_column( $response_body['events'], 'type' ); 458 459 // Make sure the soonest upcoming WordCamps is pinned in the list. 460 if ( ! in_array( 'wordcamp', $trimmed_event_types ) && $wordcamps ) { 461 array_pop( $response_body['events'] ); 462 array_push( $response_body['events'], $wordcamps[0] ); 463 } 444 464 } 445 465
Note: See TracChangeset
for help on using the changeset viewer.