do_feed()
最后更新于:2021-11-26 03:46:19
do_feed()Load the feed template from the use of an action hook.
源文件
文件: gc-includes/functions.php
function do_feed() {
global $gc_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}" ) ) {
gc_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 hook names include:
*
* - `do_feed_atom`
* - `do_feed_rdf`
* - `do_feed_rss`
* - `do_feed_rss2`
*
* @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}", $gc_query->is_comment_feed, $feed );
}