- Timestamp:
- 06/16/2018 10:42:16 AM (6 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
- Property svn:mergeinfo changed
/trunk merged: 42726,42728,43356
- Property svn:mergeinfo changed
-
branches/4.9/src/wp-admin/includes/class-wp-community-events.php
r43082 r43357 386 386 387 387 /** 388 * Discards expired events, and reduces the remaining list. 389 * 390 * @since 4.8.0 388 * Prepares the event list for presentation. 389 * 390 * Discards expired events, and makes WordCamps "sticky." Attendees need more 391 * advanced notice about WordCamps than they do for meetups, so camps should 392 * appear in the list sooner. If a WordCamp is coming up, the API will "stick" 393 * it in the response, even if it wouldn't otherwise appear. When that happens, 394 * the event will be at the end of the list, and will need to be moved into a 395 * higher position, so that it doesn't get trimmed off. 396 * 397 * @since 4.8.0 398 * @since 4.9.7 Stick a WordCamp to the final list. 391 399 * 392 400 * @param array $response_body The response body which contains the events. … … 395 403 protected function trim_events( $response_body ) { 396 404 if ( isset( $response_body['events'] ) ) { 405 $wordcamps = array(); 397 406 $current_timestamp = current_time( 'timestamp' ); 398 407 399 408 foreach ( $response_body['events'] as $key => $event ) { 400 // Skip WordCamps, because they might be multi-day events. 401 if ( 'meetup' !== $event['type'] ) { 409 /* 410 * Skip WordCamps, because they might be multi-day events. 411 * Save a copy so they can be pinned later. 412 */ 413 if ( 'wordcamp' === $event['type'] ) { 414 $wordcamps[] = $event; 402 415 continue; 403 416 } … … 411 424 412 425 $response_body['events'] = array_slice( $response_body['events'], 0, 3 ); 426 $trimmed_event_types = wp_list_pluck( $response_body['events'], 'type' ); 427 428 // Make sure the soonest upcoming WordCamps is pinned in the list. 429 if ( ! in_array( 'wordcamp', $trimmed_event_types ) && $wordcamps ) { 430 array_pop( $response_body['events'] ); 431 array_push( $response_body['events'], $wordcamps[0] ); 432 } 413 433 } 414 434
Note: See TracChangeset
for help on using the changeset viewer.