Make WordPress Core


Ignore:
Timestamp:
04/11/2022 05:01:04 AM (4 years ago)
Author:
peterwilsoncc
Message:

Feeds: Remove comment feed HTML headers when empty.

Remove the link[rel=alternate] element from the HTML header when the comment feeds are disabled. Previously the HTML element was output with an empty href attribute.

The element is removed if get_post_comments_feed_link() returns an empty string or the feed is disabled via the feed_links_show_comments_feed filter.

Props barryceelen, audrasjb, costdev, rachelbaker, Boniu91.
Fixes #54703.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r53087 r53125  
    31543154        $post = get_post( $id );
    31553155
    3156         if ( comments_open() || pings_open() || $post->comment_count > 0 ) {
    3157             $title = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
    3158             $href  = get_post_comments_feed_link( $post->ID );
     3156        /** This filter is documented in wp-includes/general-template.php */
     3157        $show_comments_feed = apply_filters( 'feed_links_show_comments_feed', true );
     3158
     3159        if ( $show_comments_feed && ( comments_open() || pings_open() || $post->comment_count > 0 ) ) {
     3160            $title     = sprintf( $args['singletitle'], get_bloginfo( 'name' ), $args['separator'], the_title_attribute( array( 'echo' => false ) ) );
     3161            $feed_link = get_post_comments_feed_link( $post->ID );
     3162
     3163            if ( $feed_link ) {
     3164                $href = $feed_link;
     3165            }
    31593166        }
    31603167    } elseif ( is_post_type_archive() ) {
Note: See TracChangeset for help on using the changeset viewer.