WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WP_Community_Events::trim_events() protected WP 4.8.0

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.

Это метод класса: WP_Community_Events{}

Хуков нет.

Возвращает

Массив. The response body with events trimmed.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->trim_events( $response_body );
$response_body(массив) (обязательный)
The response body which contains the events.

Список изменений

С версии 4.8.0 Введена.
С версии 4.9.7 Stick a WordCamp to the final list.

Код WP_Community_Events::trim_events() WP 5.5.1

wp-admin/includes/class-wp-community-events.php
<?php
protected function trim_events( $response_body ) {
	if ( isset( $response_body['events'] ) ) {
		$wordcamps = array();
		$today     = current_time( 'Y-m-d' );

		foreach ( $response_body['events'] as $key => $event ) {
			/*
			 * 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;
			}

			// We don't get accurate time with timezone from API, so we only take the date part (Y-m-d).
			$event_date = substr( $event['date'], 0, 10 );

			if ( $today > $event_date ) {
				unset( $response_body['events'][ $key ] );
			}
		}

		$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 WordCamp is pinned in the list.
		if ( ! in_array( 'wordcamp', $trimmed_event_types, true ) && $wordcamps ) {
			array_pop( $response_body['events'] );
			array_push( $response_body['events'], $wordcamps[0] );
		}
	}

	return $response_body;
}