Advertisements

fetch_feed

Definition:
function fetch_feed($url) {}

Build SimplePie object based on RSS or Atom feed from URL.

Parameters

  • string $url: URL to retrieve feed

Return values

returns:WP_Error object on failure or SimplePie object on success

Defined filters

  • wp_feed_cache_transient_lifetime
    apply_filters('wp_feed_cache_transient_lifetime', 43200, $url)

Defined actions

  • wp_feed_options
    do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );

Source code

function fetch_feed($url) {

	require_once (ABSPATH . WPINC . '/class-feed.php');



	$feed = new SimplePie();

	$feed->set_feed_url($url);

	$feed->set_cache_class('WP_Feed_Cache');

	$feed->set_file_class('WP_SimplePie_File');

	$feed->set_cache_duration(apply_filters('wp_feed_cache_transient_lifetime', 43200, $url));

	do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );

	$feed->init();

	$feed->handle_content_type();



	if ( $feed->error() )

		return new WP_Error('simplepie-error', $feed->error());



	return $feed;

}

1058

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: