Tribe__Events__Community__Main::findTodaysPage()
Searches current user’s events for the event closest to today but not in the past, and returns the ‘page’ that event is on.
Return
(object) The page object.
Source
File: src/Tribe/Main.php
public function findTodaysPage() {
if ( WP_DEBUG ) delete_transient( 'tribe_community_events_today_page' );
$todaysPage = get_transient( 'tribe_community_events_today_page' );
$todaysPage = null;
if ( ! $todaysPage ) {
$current_user = wp_get_current_user();
if ( is_object( $current_user ) && ! empty( $current_user->ID ) ) {
$args = array(
'posts_per_page' => -1,
'paged' => 0,
'nopaging' => true,
'author' => $current_user->ID,
'post_type' => Tribe__Events__Main::POSTTYPE,
'post_status' => 'any',
'order' => 'ASC',
'orderby' => 'meta_value',
'meta_key' => '_EventStartDate',
'meta_query' => array(
'key' => '_EventStartDate',
'value' => date( 'Y-m-d 00:00:00' ),
'compare' => '<=',
),
);
$tp = new WP_Query( $args );
$pc = $tp->post_count;
unset( $tp );
$todaysPage = floor( $pc / $this->eventsPerPage );
//handle bounds
if ( $todaysPage <= 0 )
$todaysPage = 1;
set_transient( 'tribe-community-events_today_page', $todaysPage, 60 * 60 * 1 ); //cache for an hour
}
}
return $todaysPage;
}
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |