Instantiating a SimplePie object in WordPress
/* Create the SimplePie object */ | |
$this->feed = new SimplePie(); | |
/* Set the URL of the feed you're retrieving */ | |
$this->feed->set_feed_url( $this->source ); | |
/* Tell SimplePie to cache the feed using WordPress' cache class */ | |
$this->feed->set_cache_class( 'WP_Feed_Cache' ); | |
/* Tell SimplePie to use the WordPress class for retrieving feed files */ | |
$this->feed->set_file_class( 'WP_SimplePie_File' ); | |
/* Tell SimplePie how long to cache the feed data in the WordPress database */ | |
$this->feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 43200, $this->source ) ); | |
/* Run any other functions or filters that WordPress normally runs on feeds */ | |
do_action_ref_array( 'wp_feed_options', array( &$this->feed, $this->source ) ); | |
/* Initiate the SimplePie instance */ | |
$this->feed->init(); | |
/* Tell SimplePie to send the feed MIME headers */ | |
$this->feed->handle_content_type(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment