Month_View::prev_url( $canonical = false, $passthru_vars = array() )
{@inheritDoc}
Source
File: src/Tribe/Views/V2/Views/Month_View.php
public function prev_url( $canonical = false, array $passthru_vars = [] ) { if ( isset( $this->prev_url ) ) { return $this->prev_url; } // Setup the Default date for the month view here. $default_date = 'today'; $date = $this->context->get( 'event_date', $default_date ); $current_date = Dates::build_date_object( $date ); if ( $this->skip_empty() ) { // Find the first event that starts before the start of this month. $prev_event = tribe_events() ->by_args( $this->filter_repository_args( $this->setup_repository_args() ) ) ->where( 'starts_before', tribe_beginning_of_day( $current_date->format( 'Y-m-01' ) ) ) ->order( 'DESC' ) ->first(); if ( ! $prev_event instanceof \WP_Post ) { return $this->filter_prev_url( $canonical, '' ); } // Show the closest date on which that event appears (but not the current date). $prev_date = min( $prev_event->dates->start, $current_date->sub( new \DateInterval( 'P1M' ) ) ); } else { $prev_date = Dates::build_date_object( $current_date->format( 'Y-m-01' ) ); $prev_date->sub( new \DateInterval( 'P1M' ) ); // Let's make sure to prevent users from paginating endlessly back when we know there are no more events. $earliest = tribe_get_option( 'earliest_date', $prev_date ); if ( $current_date->format( 'Y-m' ) === Dates::build_date_object( $earliest )->format( 'Y-m' ) ) { return $this->filter_prev_url( $canonical, '' ); } } $url = $this->build_url_for_date( $prev_date, $canonical, $passthru_vars ); $this->prev_url = $url; return $this->filter_prev_url( $canonical, $url ); }