WordPress.org

Ready to get started?Download WordPress

Forums

Consolidate <head /> links in wp_head action (2 posts)

  1. buttlessone
    Member
    Posted 6 years ago #

    Considering different themes tend to use different feed links in their header.php files, with many of them not including Atom links and possibly using the older RSS versions, would it be possible to include almost all of a theme's typical header.php links as actions being called from the 'wp_head' do_action in the next point release of WordPress? The only header link(s) that are theme specific and hence belong in a theme's header.php file are the <link rel="stylesheet" ones.

    I realize this would cause duplicate links with older themes, but it would be trivially easy to update a theme's header.php file to satisfy this change by just deleting the affected <link rel="... lines from a header.php file with the exception of the stylesheet link.

    The benefits to doing this are many, with the ones I can immediately think of being:
    1. Gives blog owners instead of theme designers control over which links/feeds are advertised as being available in the returned <head /> section.
    2. Allows for newer versions of existing feeds to be specified by the core WordPress files including the included RSS widget or even allow for newer feed technologies to be incorporated into WordPress without having to re-alter themes that have been updated.
    3. Would allow a plugin to control which feeds were advertised as available and/or to who. A plugin can already supply a custom RSS widget specifying which feeds are available and can already control a feed with the do_feed_* actions, but it seems to me the last pieces of feed control a plugin can't control are the non-uniform <head /> section links in a theme's header.php file.

    Something along the lines of adding to the /wp-includes/default-filters.php file:
    add_action('wp_head','rss_link');
    add_action('wp_head','atom_link');
    add_action('wp_head','pingback_link');

    And adding the following to /wp-includes/general-template.php:

    function rss_link() {
    echo ' <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="' . bloginfo('rss2_url') . "\" />\n";
    }
    function rss_link() {
    echo ' <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="' . bloginfo('atom_url') . "\" />\n";
    }
    function rss_link() {
    echo ' <link rel="pingback" href="' . bloginfo('pingback_url') . "\" />\n";
    }

    Once these very simple core changes are made, just inform theme designers that for their themes to be WordPress 2.4 (or whatever) compliant the only <head /> links that are to be included are for style sheets.

  2. Adam Brown
    Member
    Posted 6 years ago #

    This is more of a topic for the trac, methinks. The developers don't come by here often.

Topic Closed

This topic has been closed to new replies.

About this Topic