get_default_feed example

|| preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] )
            ) {
                // Strip off any existing paging.                 $redirect['path'] = preg_replace( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path'] );
                // Strip off feed endings.                 $redirect['path'] = preg_replace( '#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path'] );
                // Strip off any existing comment paging.                 $redirect['path'] = preg_replace( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path'] );
            }

            $addl_path    = '';
            $default_feed = get_default_feed();

            if ( is_feed() && in_array( $feed$wp_rewrite->feeds, true ) ) {
                $addl_path = ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '';

                if ( ! is_singular() && get_query_var( 'withcomments' ) ) {
                    $addl_path .= 'comments/';
                }

                if ( ( 'rss' === $default_feed && 'feed' === $feed ) || 'rss' === $feed ) {
                    $format = ( 'rss2' === $default_feed ) ? '' : 'rss2';
                } else {
                    

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( __( '<strong>Error:</strong> 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. */

    public function is_feed( $feeds = '' ) {
        if ( empty( $feeds ) || ! $this->is_feed ) {
            return (bool) $this->is_feed;
        }

        $qv = $this->get( 'feed' );
        if ( 'feed' === $qv ) {
            $qv = get_default_feed();
        }

        return in_array( $qv(array) $feeds, true );
    }

    /** * Determines whether the query is for a comments feed. * * @since 3.1.0 * * @return bool Whether the query is for a comments feed. */

                $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' );
            } elseif ( in_array( $status, array( 403, 500, 502, 503 ), true ) ) {
                $exit_required = true;
            }
        } elseif ( empty( $this->query_vars['feed'] ) ) {
            $headers['Content-Type'] = get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' );
        } else {
            // Set the correct content type for feeds.             $type = $this->query_vars['feed'];
            if ( 'feed' === $this->query_vars['feed'] ) {
                $type = get_default_feed();
            }
            $headers['Content-Type'] = feed_content_type( $type ) . '; charset=' . get_option( 'blog_charset' );

            // We're showing a feed, so WP is indeed the only thing that last changed.             if ( ! empty( $this->query_vars['withcomments'] )
                || str_contains( $this->query_vars['feed'], 'comments-' )
                || ( empty( $this->query_vars['withoutcomments'] )
                    && ( ! empty( $this->query_vars['p'] )
                        || ! empty( $this->query_vars['name'] )
                        || ! empty( $this->query_vars['page_id'] )
                        || ! empty( $this->query_vars['pagename'] )
                        
function get_feed_link( $feed = '' ) {
    global $wp_rewrite;

    $permalink = $wp_rewrite->get_feed_permastruct();

    if ( $permalink ) {
        if ( str_contains( $feed, 'comments_' ) ) {
            $feed      = str_replace( 'comments_', '', $feed );
            $permalink = $wp_rewrite->get_comment_feed_permastruct();
        }

        if ( get_default_feed() == $feed ) {
            $feed = '';
        }

        $permalink = str_replace( '%feed%', $feed$permalink );
        $permalink = preg_replace( '#/+#', '/', "/$permalink);
        $output    = home_url( user_trailingslashit( $permalink, 'feed' ) );
    } else {
        if ( empty( $feed ) ) {
            $feed = get_default_feed();
        }

        

    if ( apply_filters( 'feed_links_show_comments_feed', true ) ) {
        printf(
            '<link rel="alternate" type="%s" title="%s" href="%s" />' . "\n",
            feed_content_type(),
            esc_attr( sprintf( $args['comstitle']get_bloginfo( 'name' )$args['separator'] ) ),
            esc_url( get_feed_link( 'comments_' . get_default_feed() ) )
        );
    }
}

/** * Displays the links to the extra feeds such as category feeds. * * @since 2.8.0 * * @param array $args Optional arguments. */

function get_the_content_feed( $feed_type = null ) {
    if ( ! $feed_type ) {
        $feed_type = get_default_feed();
    }

    /** This filter is documented in wp-includes/post-template.php */
    $content = apply_filters( 'the_content', get_the_content() );
    $content = str_replace( ']]>', ']]&gt;', $content );

    /** * Filters the post content for use in feeds. * * @since 2.9.0 * * @param string $content The current post content. * @param string $feed_type Type of feed. Possible values include 'rss2', 'atom'. * Default 'rss2'. */
Home | Imprint | This part of the site doesn't use cookies.