Make WordPress Core

Opened 16 years ago

Closed 15 years ago

Last modified 15 years ago

#8878 closed enhancement (fixed)

Allow theme developers to have feed links automatically outputted

Reported by: viper007bond's profile Viper007Bond Owned by: viper007bond's profile Viper007Bond
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: has-patch dev-feedback 2nd-opinion
Focuses: Cc:

Description

Oddly enough this idea occurred to both Matt and I today without talking to each other before hand. Crazy.

Anyway, theme developers shouldn't have to hard code in the <link>s or code up the logic to display the URL to a category, etc. feed in their theme's head. On the other hand, we can't just go and do it ourselves as browsers aren't smart enough to ignore duplicate feed links.

So I have a patch in the works where a theme developer can just call a function in their theme's functions.php file and that will queue up automatically adding <link> tags to the <head> depending on current location (home, single, category, etc.).

Attachments (6)

8878.patch (10.9 KB) - added by Viper007Bond 16 years ago.
First pass
8878.2.patch (11.6 KB) - added by Viper007Bond 16 years ago.
Output the extra feeds without theme author intervention, make general feeds optional, minor improvements
8878.3.patch (11.6 KB) - added by Viper007Bond 16 years ago.
Keep two new functions in the same order, but move them to much earlier in the wp_head hook
8878.4.patch (910 bytes) - added by Viper007Bond 16 years ago.
Ensure get_the_title() is escaped
8878.5.patch (1.1 KB) - added by Viper007Bond 16 years ago.
Better name an option, grammar fix for translation comment
feed-link-title-typo.diff (893 bytes) - added by nbachiyski 16 years ago.

Download all attachments as: .zip

Change History (32)

#1 @Viper007Bond
16 years ago

  • Component changed from Template to Feeds

#2 @Viper007Bond
16 years ago

  • Component changed from Feeds to Template

Nevermind, it's a templates thing.

@Viper007Bond
16 years ago

First pass

#3 @Viper007Bond
16 years ago

  • Keywords has-patch needs-testing added

#4 @Viper007Bond
16 years ago

Usage:

Remove all <link>'s from your theme that point at any of the feeds. Add automatic_feed_links(); to your theme's functions.php file. Done.

@Viper007Bond
16 years ago

Output the extra feeds without theme author intervention, make general feeds optional, minor improvements

#5 @Viper007Bond
16 years ago

Per Matt's good suggestion:

99% (if not more) of themes don't output the <link> to the feed when you're viewing a category, author, tag, etc. archive listing. Therefore we can safely automatically output those without requiring theme updates.

Only the default general feeds will need to be manually enabled to avoid duplicating what is hardcoded into most themes. This new patch also makes just one general feed rather than both RSS2 and Atom. However the pre-existing default_feed filter can switch WordPress to using Atom by default rather than RSS.

This patch also makes feed_content_type() output application/octet-stream rather than a blank if it doesn't know about a feed type. Thanks to rmccue on that one.

#6 follow-up: @ionfish
16 years ago

This is a nice idea. By way of reference, here's the code I use to do this in Tarski:

http://github.com/ionfish/tarski/blob/9fceb56c66bf44f624a859fece33fb37dc02888d/library/classes/asset.php#L122-185

Would be great to be able to remove all that logic and leave it to core to sort out.

#7 in reply to: ↑ 6 @Viper007Bond
16 years ago

Would be great to be able to remove all that logic and leave it to core to sort out.

Yep, you'd now just add automatic_feed_links(); to your theme's functions.php and be done. :)

@Viper007Bond
16 years ago

Keep two new functions in the same order, but move them to much earlier in the wp_head hook

#8 @azaozz
16 years ago

(In [10377]) Add support for automatic feed links in themes, props Viper007Bond, see #8878

#9 @Viper007Bond
16 years ago

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

Seems to be working okay. Please reopen if anyone runs into any trouble.

#10 @Viper007Bond
16 years ago

  • Keywords needs-testing removed
  • Resolution fixed deleted
  • Status changed from closed to reopened

DD32 caught a bug with the single post's comments feed:

if the_title contains HTML (ie. added by a filter), Then its not being properly escaped

Incoming patch.

@Viper007Bond
16 years ago

Ensure get_the_title() is escaped

#11 @azaozz
16 years ago

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

(In [10467]) Ensure get_the_title() is escaped in feed links, props Viper007Bond, fixes #8878

#12 @ryan
16 years ago

(In [10532]) Add some attribute_escape()s for good measure. see #8878

#13 @Viper007Bond
16 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

More code nitpicking. Might as well do it now rather than after 2.8 final or even never.

@Viper007Bond
16 years ago

Better name an option, grammar fix for translation comment

#14 @azaozz
16 years ago

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

(In [10534]) Automatic fees links: better option name and grammar fix for translation comment, props Viper007Bond, fixes #8878

#15 @nbachiyski
16 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

The default value key in feed_links() was changed to feedtitle, but in the body it is still referenced as rsstitle.

#16 @azaozz
16 years ago

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

(In [10558]) Feed links: fix arg name, props nbachiyski, fixes #8878

#17 @Viper007Bond
16 years ago

Whoops. That was silly of me.

#18 @peaceablewhale
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Should the new feed links be located above the usual blog feed and blog comments feed links? I think the new links should be preferred--For example, when an user is searching something and he clicks on the browser's feed button, he should expect to get a search results feed instead of the blog feed.

#19 @peaceablewhale
15 years ago

  • Keywords dev-feedback 2nd-opinion added

#20 @Denis-de-Bernardy
15 years ago

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

I doubt it. On my own browser (Camino), clicking the rss icon in the address bar will list all of the available feeds when several are present.

#21 follow-up: @peaceablewhale
15 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

However, it is not the case in Internet Explorer 7 and 8. In addition, shouldn't the more preferred feed be put at a higher position?

#22 @Denis-de-Bernardy
15 years ago

I'd rather have the blog's feed, myself. but I suppose it's a personal preference. :-)

#23 @peaceablewhale
15 years ago

Ic :)

Should an option be added to the Admin Panel to customize that?

#24 @Denis-de-Bernardy
15 years ago

oh dear no, please. no more options. there are too many. :D

the most natural option (for readers who aren't aware that a site may have multiple RSS feeds) should be enforced imo. best I know, that would mean the site's feed.

#25 in reply to: ↑ 21 @Viper007Bond
15 years ago

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

Let's leave this closed please. The most important and used feed, i.e. the main blog feed, belongs on top.

Replying to peaceablewhale:

However, it is not the case in Internet Explorer 7 and 8.

Click the down arrow to the right of the RSS icon. You can pick from the list of feeds.

#26 @Viper007Bond
15 years ago

Oh, and no more options. This is a fringe request which can easily be handled by a plugin.

Not core material.

Note: See TracTickets for help on using tickets.