Recent Links RSS and 304 Responce

by @jehiah on 2004-10-14 16:45UTC
Filed under: All

There is a small problem in the 1.31 version of the Recent Links plugin by Markku Seguerra where your recent links feed will get marked with a http responce code of 304 indicating that it has not been modified since the last request based upon the modify dates of your blog entries not your recent links. The following changes will resolve this. Note: these changes involve modifying code that is outside of the recent links plugin.

First we need to set a flag in the rss processing page so that wordpress will know where to go for the date modified. In wp-recent-links-rss2.php at line 2 add

$doing_recent_links = 1;

Next we need to change wordpress default functionality and add code to get a different date modified based on the flag above. At Line 86 in wp-blog-header.php change line 87 from

$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';


if (!isset($doing_recent_links) || !$doing_recent_links)
    $wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0).' GMT';
    $wp_last_modified = mysql2date('D, d M Y H:i:s', get_last_recentlink_postmodified(), 0).' GMT';

Finally add a function to the recent links plugin which will get the date from the most recent link. Add the get_last_recentlink_postmodified() function to the end of wp-content/plugins/rp-plugin-recent-links.php

function get_last_recentlink_postmodified() {
    global $pagenow,$table_prefix, $wpdb,$tablerecentlinks = $table_prefix.'recentlinks';
    $add_seconds_blog = get_settings('gmt_offset') * 3600;
    $add_seconds_server = date('Z');
    $now = current_time('mysql', 1);
    return $wpdb->get_var("SELECT date_added FROM $tablerecentlinks WHERE date_added <= '$now' AND link_visible = 'Y' ORDER BY post_modified_gmt DESC LIMIT 1");
Subscribe via RSS ı Email
© 2022 - Jehiah Czebotar