do_feed()
do_feed() 使用动作挂钩加载提要模板。Load the feed template from the …
do_feed()
使用动作挂钩加载提要模板。
Load the feed template from the use of an action hook.
目录锚点:#说明#返回#源码
说明(Description)
如果feed操作没有钩子,那么函数将死掉,并显示一条消息,告诉访问者feed无效。
最好每个饲料只有一个钩子。
返回(Return)
无返回值
源码(Source)
/**
* 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.
*
* @since 2.1.0
*
* @global WP_Query $wp_query Used to tell if the use a comment feed.
*/
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();
$hook = 'do_feed_' . $feed;
if ( ! has_action( $hook ) )
wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) );
/**
* Fires once the given feed is loaded.
*
* The dynamic hook name, $hook, refers to the feed name.
*
* @since 2.1.0
*
* @param bool $is_comment_feed Whether the feed is a comment feed.
*/
do_action( $hook, $wp_query->is_comment_feed );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 2.1.0 | wp-includes/functions.php:1534 | 0 | 7 |
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。

还没有任何评论,赶紧来占个楼吧!