do_feed() - WordPress 函数参考中文文档

返回介绍

do_feed()

发布于 2017-09-10 字数2046 浏览 923 评论 0

do_feed()

Load the feed template from the use of an action hook.


描述

If the feed action does not have a hook, then the function will die with a message telling the visitor that the feed is not valid.

It is better to only have one hook for each feed.


源代码

File: wp-includes/functions.php

function do_feed() {
	global $wp_query;

	$feed = get_query_var( 'feed' );

	// Remove the pad, if present.
	$feed = preg_replace( '/^_+/', '', $feed );

	if ( $feed == '' || $feed == 'feed' )
		$feed = get_default_feed();

	if ( ! has_action( "do_feed_{$feed}" ) ) {
		wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
	}

	/**
	 * Fires once the given feed is loaded.
	 *
	 * The dynamic portion of the hook name, `$feed`, refers to the feed template name.
	 * Possible values include: 'rdf', 'rss', 'rss2', and 'atom'.
	 *
	 * @since 2.1.0
	 * @since 4.4.0 The `$feed` parameter was added.
	 *
	 * @param bool   $is_comment_feed Whether the feed is a comment feed.
	 * @param string $feed            The feed name.
	 */
	do_action( "do_feed_{$feed}", $wp_query->is_comment_feed, $feed );
}

更新日志

Version 描述
2.1.0 Introduced.

相关函数

Uses

  • wp-includes/functions.php:
    do_feed_{$feed}
  • wp-includes/l10n.php:
    __()
  • wp-includes/query.php:
    get_query_var()
  • wp-includes/functions.php:
    wp_die()
  • wp-includes/plugin.php:
    has_action()
  • wp-includes/plugin.php:
    do_action()
  • wp-includes/feed.php:
    get_default_feed()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

上一篇:do_enclose()

下一篇:do_feed_atom()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!