Make WordPress Core

Opened 16 years ago

Closed 15 years ago

#5328 closed enhancement (fixed)

Make default feed format pluggable

Reported by: rubys's profile rubys Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version:
Component: Feeds Keywords: has-patch
Focuses: Cc:

Description

Provide a filter hook that a plugin could replace that would allow the plugin to control the default feed format. Additionally, the filter could provide the mime_type, display_name, short_name, and long_name to themes so that they could adjust, if they so desire.

The provided patch adjusts the default theme to make use of this new filter. Simply drop in this plugin and activate it, and the pages automatically adapt. Deactivate the plugin, and the pages revert back to RSS 2.0.

Additional plugins could be defined for RSS 0.92 or RSS 1.0.

This patch does *not* change the default feed format from RSS 2.0.

Attachments (3)

feed-filter.patch (17.9 KB) - added by rubys 16 years ago.
add get_default_feed() and get_feed_info($feed) based on suggestion by ryan
feed-filter.diff (17.9 KB) - added by rubys 16 years ago.
second attempt to upload this patch
default_feed.diff (11.7 KB) - added by ryan 16 years ago.

Download all attachments as: .zip

Change History (16)

#1 @rubys
16 years ago

  • Type changed from defect to enhancement

#2 @ryan
16 years ago

How about a get_default_feed() function that applies a default_feed filter and a get_feed_info($feed) for getting details for that feed?

@rubys
16 years ago

add get_default_feed() and get_feed_info($feed) based on suggestion by ryan

#3 @ryan
16 years ago

I'm still seeing the old patch, I think. Attached is what I had in mind. It's not complete.

#4 @ryan
16 years ago

Notes about the patch. We could go ahead and add info for all the feeds we ship with to get_feed_inf(). I added some checks need to make sure we correctly create links when permalinks are not enabled. Category feed links generated by wp_list_categories() follow the default. The same can be done for authors.

@rubys
16 years ago

second attempt to upload this patch

#5 @rubys
16 years ago

The way I figure it, going from hardcoding the default feed format to hardcoding the info for all of the feed formats is but a half step. A plugin is still required, and allowing people to control the full info means they can add I♥RSS icons, or links to the feed validator, or translate the long name into Russian or whatever. Furthermore, specific themes could even check for additional information that is not provided by the default.

If you look at the actual sample plugin for Atom, it really isn't all that much burden to the plugin authors, and reduces bloat from the WP Core.

*shrug*

I suggest you try the patch. Create a clean wordpress install with the default theme, install the patch and active the Atom plugin and see what you think. If you still prefer hardcoding the info for the feed formats in the core, I'm entirely OK with that.

Unrelated: any idea why Trac won't show an HTML preview for my patches, but will show yours?

#6 follow-up: @ryan
16 years ago

My patch marks the long name for translation. Realistically, for translation to be useful, feed info for all feeds need to be in core so that the strings will be in the default message catalog. Otherwise, the plugin will need to ship with its own translations. i18n theme authors probably won't bother changing their themes to use feed info if it means relying on an outside catalog. The fact that this requires theme changes and has i18n impact makes this more involved than if we were just changing the default feed links to do atom instead of rss2. comments_feed_link(), for example, is useless for an i18n-ready theme. Such themes would have to do something like:

<p><a href="<?php echo get_post_comments_feed_link($post->ID); ?>"><?php printf(__("%s feed for comments on this post."), get_bloginfo('feed_format_long_name'); ?></a></p>

Let's split this into two parts. The first part would make it possible to change the default feed in the guts of WP. The second would allow themes to be feed type neutral, which is the bigger change.

#7 @jasonadamyoung
16 years ago

If this is going to be part of core - is there any reason why this shouldn't be part of the wp_options? I admittedly haven't traced the execution of this everywhere, but it seems like get_option('default_feed_format') would be preferred over get_default_feed and still hardcoding 'rss2' in that (or even hardcoding it in a sense in a wp_feed_selector).

I might be missing something in the overhead of the options use, but it looks like the options already have filter hooks - and sticking this in wp_options leaves open the door for a interface plugin to set the default feed format from within the admin interface.

#8 in reply to: ↑ 6 @rubys
16 years ago

Replying to ryan:

Let's split this into two parts.The first part would make it possible to change the default feed in the guts of WP.

That would be Ticket 4595.

The second would allow themes to be feed type neutral, which is the bigger change.

Once of the various patches to ticket 4595 is committed, I'll gladly generate a new patch for 5328 which builds upon this. Making a subset of the various names translatable and/or actually translating them could be a third ticket.

@ryan
16 years ago

#9 @ryan
16 years ago

FWIW, here's the patch I've been playing with. It adds a feed_type arg to wp_list_authors() and wp_list_categories(). It deprecates old _rss_link() functions and moves all feed_link functions to link-template.php so that they are not so scattered. No template changes are made. That's for later.

This patch still uses get_default_feed() rather than an option. I'll bring up adding an option for this in the next dev meeting.

#10 @ryan
16 years ago

(In [6365]) New feed_link functions. Deprecate rss_link functions. Make default feed pluggable. Props rubys. see #5328

#11 @rubys
16 years ago

I created a filter which simply returns 'atom', and registered it as the 'default_feed' filter, on a blog which uses the default theme. The net visible effect is that

<link rel="alternate" type="application/rss+xml" title="App Test RSS Feed" href="http://rubix.home/wordpress/feed/" />

Changed to

<link rel="alternate" type="application/rss+xml" title="App Test RSS Feed" href="http://rubix.home/wordpress/feed/rss2/" />

While this puts in place an important piece of enabling infrastructure, I don't believe that it is sufficient to warrant closing this ticket.

#12 @ffemtcj
16 years ago

  • Milestone changed from 2.5 to 2.6

#13 @Denis-de-Bernardy
15 years ago

  • Component changed from General to Feeds
  • Milestone changed from 2.9 to 2.8
  • Resolution set to fixed
  • Status changed from new to closed

fixed a while ago

Note: See TracTickets for help on using tickets.