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

feed_links_extra

Definition:
function feed_links_extra( $args = array() {}

Display the links to the extra feeds such as category feeds.

Parameters

  • array $args: Optional arguments.

Source code

function feed_links_extra( $args = array() ) {

	$defaults = array(

		/* translators: Separator between blog name and feed type in feed links */

		'separator'   => _x('»', 'feed link'),

		/* translators: 1: blog name, 2: separator(raquo), 3: post title */

		'singletitle' => __('%1$s %2$s %3$s Comments Feed'),

		/* translators: 1: blog name, 2: separator(raquo), 3: category name */

		'cattitle'    => __('%1$s %2$s %3$s Category Feed'),

		/* translators: 1: blog name, 2: separator(raquo), 3: tag name */

		'tagtitle'    => __('%1$s %2$s %3$s Tag Feed'),

		/* translators: 1: blog name, 2: separator(raquo), 3: author name  */

		'authortitle' => __('%1$s %2$s Posts by %3$s Feed'),

		/* translators: 1: blog name, 2: separator(raquo), 3: search phrase */

		'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'),

	);



	$args = wp_parse_args( $args, $defaults );



	if ( is_single() || is_page() ) {

		$id = 0;

		$post = &get_post( $id );



		if ( comments_open() || pings_open() || $post->comment_count > 0 ) {

			$title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) );

			$href = get_post_comments_feed_link( $post->ID );

		}

	} elseif ( is_category() ) {

		$term = get_queried_object();



		$title = sprintf( $args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name );

		$href = get_category_feed_link( $term->term_id );

	} elseif ( is_tag() ) {

		$term = get_queried_object();



		$title = sprintf( $args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name );

		$href = get_tag_feed_link( $term->term_id );

	} elseif ( is_author() ) {

		$author_id = intval( get_query_var('author') );



		$title = sprintf( $args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta( 'display_name', $author_id ) );

		$href = get_author_feed_link( $author_id );

	} elseif ( is_search() ) {

		$title = sprintf( $args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query( false ) );

		$href = get_search_feed_link();

	}



	if ( isset($title) && isset($href) )

		echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . '" />' . "\n";

}

1056

feed_links

Definition:
function feed_links( $args = array() {}

Display the links to the general feeds.

Parameters

  • array $args: Optional arguments.

Source code

function feed_links( $args = array() ) {

	if ( !current_theme_supports('automatic-feed-links') )

		return;



	$defaults = array(

		/* translators: Separator between blog name and feed type in feed links */

		'separator'	=> _x('&raquo;', 'feed link'),

		/* translators: 1: blog title, 2: separator (raquo) */

		'feedtitle'	=> __('%1$s %2$s Feed'),

		/* translators: %s: blog title, 2: separator (raquo) */

		'comstitle'	=> __('%1$s %2$s Comments Feed'),

	);



	$args = wp_parse_args( $args, $defaults );



	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['feedtitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link() . "\" />\n";

	echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr(sprintf( $args['comstitle'], get_bloginfo('name'), $args['separator'] )) . '" href="' . get_feed_link( 'comments_' . get_default_feed() ) . "\" />\n";

}

1054

feed_content_type

Definition:
function feed_content_type( $type = '' ) {}

Return the content type for specified feed type.

Parameters

  • $type

Defined filters

  • feed_content_type
    apply_filters( 'feed_content_type', $content_type, $type )

Source code

function feed_content_type( $type = '' ) {

	if ( empty($type) )

		$type = get_default_feed();



	$types = array(

		'rss'  => 'application/rss+xml',

		'rss2' => 'application/rss+xml',

		'rss-http'  => 'text/xml',

		'atom' => 'application/atom+xml',

		'rdf'  => 'application/rdf+xml'

	);



	$content_type = ( !empty($types[$type]) ) ? $types[$type] : 'application/octet-stream';



	return apply_filters( 'feed_content_type', $content_type, $type );

}

1052

favorite_actions

Definition:
function favorite_actions( $screen = null ) {}

Parameters

  • $screen

Defined filters

  • favorite_actions
    apply_filters( 'favorite_actions', $actions, $screen )

Source code

function favorite_actions( $screen = null ) {

	$default_action = false;



	if ( is_string($screen) )

		$screen = convert_to_screen($screen);



	if ( $screen->is_user )

		return;



	if ( isset($screen->post_type) ) {

		$post_type_object = get_post_type_object($screen->post_type);

		if ( 'add' != $screen->action )

			$default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));

		else

			$default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));

	}



	if ( !$default_action ) {

		if ( $screen->is_network ) {

			$default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));

		} else {

			switch ( $screen->id ) {

				case 'upload':

					$default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));

					break;

				case 'media':

					$default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));

					break;

				case 'link-manager':

				case 'link':

					if ( 'add' != $screen->action )

						$default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));

					else

						$default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));

					break;

				case 'users':

					$default_action = array('user-new.php' => array(__('New User'), 'create_users'));

					break;

				case 'user':

					$default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));

					break;

				case 'plugins':

					$default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));

					break;

				case 'plugin-install':

					$default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));

					break;

				case 'themes':

					$default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));

					break;

				case 'theme-install':

					$default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));

					break;

				default:

					$default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));

					break;

			}

		}

	}



	if ( !$screen->is_network ) {

		$actions = array(

			'post-new.php' => array(__('New Post'), 'edit_posts'),

			'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),

			'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),

			'media-new.php' => array(__('Upload'), 'upload_files'),

			'edit-comments.php' => array(__('Comments'), 'moderate_comments')

			);

	} else {

		$actions = array(

			'sites.php' => array( __('Sites'), 'manage_sites'),

			'users.php' => array( __('Users'), 'manage_network_users')

		);

	}



	$default_key = array_keys($default_action);

	$default_key = $default_key[0];

	if ( isset($actions[$default_key]) )

		unset($actions[$default_key]);

	$actions = array_merge($default_action, $actions);

	$actions = apply_filters( 'favorite_actions', $actions, $screen );



	$allowed_actions = array();

	foreach ( $actions as $action => $data ) {

		if ( current_user_can($data[1]) )

			$allowed_actions[$action] = $data[0];

	}



	if ( empty($allowed_actions) )

		return;



	$first = array_keys($allowed_actions);

	$first = $first[0];

	echo '<div id="favorite-actions">';

	echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';

	echo '<div id="favorite-inside">';



	array_shift($allowed_actions);



	foreach ( $allowed_actions as $action => $label) {

		echo "<div class='favorite-action'><a href='$action'>";

		echo $label;

		echo "</a></div>\n";

	}

	echo "</div></div>\n";

}

1050