Skip to content

Instantly share code, notes, and snippets.

@elimn
Last active March 16, 2017 17:26
Show Gist options
  • Save elimn/67679b0b9b74793a53f0 to your computer and use it in GitHub Desktop.
Save elimn/67679b0b9b74793a53f0 to your computer and use it in GitHub Desktop.
MT | TEC | Always show Next/Prev links in Month View
<?php
/**
* Allows visitors to page forward/backwards in any direction within month view
* an "infinite" number of times (ie, outwith the populated range of months).
*/
class ContinualMonthViewPagination {
public function __construct() {
add_filter( 'tribe_events_the_next_month_link', array( $this, 'next_month' ) );
add_filter( 'tribe_events_the_previous_month_link', array( $this, 'previous_month' ) );
}
public function next_month() {
$url = tribe_get_next_month_link();
$text = tribe_get_next_month_text();
$date = TribeEvents::instance()->nextMonth( tribe_get_month_view_date() );
return '<a data-month="' . $date . '" href="' . $url . '" rel="next">' . $text . ' <span>&raquo;</span></a>';
}
public function previous_month() {
$url = tribe_get_previous_month_link();
$text = tribe_get_previous_month_text();
$date = TribeEvents::instance()->previousMonth( tribe_get_month_view_date() );
return '<a data-month="' . $date . '" href="' . $url . '" rel="prev"><span>&laquo;</span> ' . $text . ' </a>';
}
}
new ContinualMonthViewPagination;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment