mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-29 04:28:07 +01:00
Community Events Dashboard: Always show a WordCamp if one is coming up.
WordCamps are celebrations of the local WordPress Community and once a local one is scheduled, people in that community should know it is coming. This adjusts the WordPress Events in the dashboard widgets to always display a WordCamp, even if there are multiple Meetups happening first. Props iandunn, metalandcoffee, warmlaundry, alejandroxlopez, jorbin. Merges [42726], [42728], and [43356] to the 4.9 branch. Fixes #41112. Built from https://develop.svn.wordpress.org/branches/4.9@43357 git-svn-id: http://core.svn.wordpress.org/branches/4.9@43185 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e2bf0ae498
commit
567d4b0961
@ -385,20 +385,33 @@ class WP_Community_Events {
|
||||
}
|
||||
|
||||
/**
|
||||
* Discards expired events, and reduces the remaining list.
|
||||
* Prepares the event list for presentation.
|
||||
*
|
||||
* Discards expired events, and makes WordCamps "sticky." Attendees need more
|
||||
* advanced notice about WordCamps than they do for meetups, so camps should
|
||||
* appear in the list sooner. If a WordCamp is coming up, the API will "stick"
|
||||
* it in the response, even if it wouldn't otherwise appear. When that happens,
|
||||
* the event will be at the end of the list, and will need to be moved into a
|
||||
* higher position, so that it doesn't get trimmed off.
|
||||
*
|
||||
* @since 4.8.0
|
||||
* @since 4.9.7 Stick a WordCamp to the final list.
|
||||
*
|
||||
* @param array $response_body The response body which contains the events.
|
||||
* @return array The response body with events trimmed.
|
||||
*/
|
||||
protected function trim_events( $response_body ) {
|
||||
if ( isset( $response_body['events'] ) ) {
|
||||
$wordcamps = array();
|
||||
$current_timestamp = current_time( 'timestamp' );
|
||||
|
||||
foreach ( $response_body['events'] as $key => $event ) {
|
||||
// Skip WordCamps, because they might be multi-day events.
|
||||
if ( 'meetup' !== $event['type'] ) {
|
||||
/*
|
||||
* Skip WordCamps, because they might be multi-day events.
|
||||
* Save a copy so they can be pinned later.
|
||||
*/
|
||||
if ( 'wordcamp' === $event['type'] ) {
|
||||
$wordcamps[] = $event;
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -410,6 +423,13 @@ class WP_Community_Events {
|
||||
}
|
||||
|
||||
$response_body['events'] = array_slice( $response_body['events'], 0, 3 );
|
||||
$trimmed_event_types = wp_list_pluck( $response_body['events'], 'type' );
|
||||
|
||||
// Make sure the soonest upcoming WordCamps is pinned in the list.
|
||||
if ( ! in_array( 'wordcamp', $trimmed_event_types ) && $wordcamps ) {
|
||||
array_pop( $response_body['events'] );
|
||||
array_push( $response_body['events'], $wordcamps[0] );
|
||||
}
|
||||
}
|
||||
|
||||
return $response_body;
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9.7-alpha-43354';
|
||||
$wp_version = '4.9.7-alpha-43357';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user