Created
June 27, 2014 17:54
-
-
Save caseydriscoll/20e7f714b90cd8c56d56 to your computer and use it in GitHub Desktop.
Tribe Unlimited iCal Feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UnlimitedICalFeed { | |
public static function setup() { | |
add_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 75 ); | |
} | |
public static function pre_get_posts( WP_Query $query ) { | |
if ( ! $query->tribe_is_event_query ) return self::shutdown(); | |
if ( ! isset($_GET['ical'] ) || 'all' !== $_GET['ical'] ) return self::shutdown(); | |
$query->set( 'posts_per_page', -1 ); | |
} | |
protected static function shutdown() { | |
remove_action( 'pre_get_posts', array( __CLASS__, 'pre_get_posts' ), 75 ); | |
return null; | |
} | |
} | |
UnlimitedICalFeed::setup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment