WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 3 months ago

#9134 closed defect (bug) (fixed)

cannot remove the link to comments in feeds

Reported by: jidanni Owned by: swissspidy
Milestone: 4.4 Priority: normal
Severity: normal Version: 2.7
Component: Feeds Keywords: good-first-bug has-patch has-unit-tests
Focuses: Cc:

Description

In feed-rss2.php, etc. there is no easy to turn off the comments link, for blogs that
have no, and don't allow, comments. So the link

<comments><?php comments_link(); ?></comments>

is just a waste. Same with

<wfw:commentRss><?php echo get_post_comments_feed_link(); ?></wfw:commentRss>

Yes. I can turn off comments, and remove all comments, but I cannot
remove the link to comments (without hacking the core.)

Attachments (6)

9134.diff (975 bytes) - added by sivel 7 years ago.
9134-v2.patch (2.1 KB) - added by peaceablewhale 7 years ago.
9134.patch (1.5 KB) - added by hakre 5 years ago.
Make Comments in RSS2 and ATOM feed filterable.
9134-v3.diff (4.3 KB) - added by realloc 5 months ago.
The comments node seems to be optional.
9134-v4.diff (3.9 KB) - added by realloc 5 months ago.
WordPress Coding Standards (& Spaces -> Tabs)
9134.2.diff (3.5 KB) - added by swissspidy 4 months ago.

Download all attachments as: .zip

Change History (30)

#1 @jidanni
7 years ago

  • Cc jidanni@… added

@sivel
7 years ago

#2 @sivel
7 years ago

  • Cc matt@… added
  • Keywords has-patch needs-testing added

First shot. Haven't looked at other feeds yet.

#3 @Denis-de-Bernardy
7 years ago

  • Keywords needs-patch added; has-patch needs-testing removed
  • Milestone set to 2.8

test should be: if exists comments or comments are open. and this also needs to be in other feed templates.

#4 @peaceablewhale
7 years ago

  • Keywords has-patch added; needs-patch removed

Changed keyword to has-patch

#5 @Denis-de-Bernardy
7 years ago

  • Keywords 2nd-opinion added

probably still not there.

link to comments should probably show if: comments or pings are present (get_comments_number()), or if comments or pings are opened (comments_open()
pings_open())

link to the comments feed should show if comments or pings are opened, regardless if whether any comments are present.

also, it may be worth checking that the fields can be omitted per specs.

#6 follow-up: @peaceablewhale
7 years ago

The comment element is optional: http://www.rssboard.org/rss-specification#ltcommentsgtSubelementOfLtitemgt. wfw:commentRss is a RSS extension and therefore it is optional. All Atom Thread links are not required.

Why should the comment link be included when ping is enabled? I think that the comment link is for replying to the post or referencing the current comments of the post only.

#7 in reply to: ↑ 6 @Denis-de-Bernardy
7 years ago

Replying to peaceablewhale:

Why should the comment link be included when ping is enabled? I think that the comment link is for replying to the post or referencing the current comments of the post only.

Hence the 2nd-opinion. WP treats comments and pings as the same animal. Unless I'm mistaking both will show in the comments feed.

#8 follow-up: @peaceablewhale
7 years ago

I am afraid that putting the ping link in atom:link[@rel="replies"] is a violation to RFC 4685:

An Atom link element with a rel attribute value of "replies" may be
used to reference a resource where responses to an entry may be
found. If the type attribute of the atom:link is omitted, its value
is assumed to be "application/atom+xml".

If there is no comment and comment is disabled, the link does not seem to conform to "reference a resource where responses to an entry".

#9 in reply to: ↑ 8 ; follow-up: @Denis-de-Bernardy
7 years ago

Replying to peaceablewhale:

If there is no comment and comment is disabled, the link does not seem to conform to "reference a resource where responses to an entry".

I think one could also argue that pingbacks and trackbacks also qualify as such if listed in the comments list... Let's get a third opinion.

#10 @Denis-de-Bernardy
7 years ago

  • Milestone changed from 2.8 to 2.9

Moving to 2.9, from lack of traction.

#11 @Denis-de-Bernardy
7 years ago

  • Keywords 2nd-opinion removed

#12 @Denis-de-Bernardy
7 years ago

  • Keywords needs-patch added; has-patch removed

broken patch

#13 @peaceablewhale
7 years ago

  • Keywords has-patch added; needs-patch removed

#14 @ryan
6 years ago

  • Milestone changed from 2.9 to Future Release

#15 @chrishajer
6 years ago

I was just looking for a way to do this and was disappointed to learn it can't be done without hacking the core. Is there a way to do it with a plugin?

#16 in reply to: ↑ 9 @hakre
5 years ago

Replying to Denis-de-Bernardy:

Replying to peaceablewhale:

If there is no comment and comment is disabled, the link does not seem to conform to "reference a resource where responses to an entry".

I think one could also argue that pingbacks and trackbacks also qualify as such if listed in the comments list... Let's get a third opinion.

Absolutely, the above quoted RFC:

An Atom link element with a rel attribute value of "replies" may be used to reference a resource where responses to an entry may be found.

Can point to a resource (web-page) where ping and trackbacks only are listed - as those qualify as replies.

The decision what counts could be put in one function which then get's filtered (or even just the filter and foks can add this feature by plugin).

@hakre
5 years ago

Make Comments in RSS2 and ATOM feed filterable.

#17 @hakre
5 years ago

Processing can be controlled by returning a value that evaluates to true or false, filter are named rss2_process_comments and atom_process_comments.

If you take a look into the atom code, it makes use of href="<?php the_permalink_rss() ?>#comments" wich is hardencoded as well with the theme that might differ to that so probably should be filterable as well.

#18 @mbijon
3 years ago

  • Cc mike@… added

#19 @chriscct7
5 months ago

  • Keywords needs-refresh added
  • Milestone changed from Future Release to 4.4
  • Owner set to chriscct7
  • Priority changed from lowest to normal
  • Severity changed from trivial to normal
  • Status changed from new to assigned

#20 @wonderboymusic
5 months ago

  • Keywords needs-docs needs-patch good-first-bug added; has-patch needs-refresh removed
  • Milestone changed from 4.4 to Future Release
  • Owner chriscct7 deleted

which is better: no <comments> node or <comments> node with empty contents?

Instead of filters, this should use post template logic for checking whether the value should be output - post_type_supports(), comments_open(), $post->comment_count, etc

I don't know what the proper patch looks like. Moving out of release until a patch materializes.

@realloc
5 months ago

The comments node seems to be optional.

#21 @realloc
5 months ago

  • Keywords has-patch added; needs-patch removed

The <comments> node seems to be optional. Source: https://validator.w3.org/feed/docs/rss2.html

@realloc
5 months ago

WordPress Coding Standards (& Spaces -> Tabs)

@swissspidy
4 months ago

#22 @swissspidy
4 months ago

  • Keywords has-unit-tests added; needs-docs removed
  • Milestone changed from Future Release to 4.4

IMHO adding a new has_comments_link function that is only used for feeds isn't really needed. All default themes and the new embed template in 4.4 use an if ( get_comments_number() || comments_open() ) {} check to show comment links.

comments_open() is already filterable, so it's easy to hide comment info from feeds when comments_open() returns false and there are no comments on a post.

9134.2.diff does exactly that.

#23 @swissspidy
4 months ago

  • Owner set to swissspidy

Marking the "good first bug" as claimed.

#24 @wonderboymusic
3 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 35506:

Feeds: <comments> is optional in RSS2, so don't include it when comments aren't present or open. Same for <wfw:commentRss> and <slash:comments>

Adds unit test.

Props swissspidy, realloc, hakre, sivel.
Fixes #9134.

Note: See TracTickets for help on using tickets.