WP Latest Post Blogroll is a WordPress Plugin that augments the traditional blogroll with the latest post topics found at the specified blog addresses listed in the blogroll. A link to the latest post at each of the blogs appears in the blogroll instead of the name of the blog.
Download the WP Latest Post Blogroll plugin at the WP Plugins Directory.
The source of WP Latest Post Blogroll plugin is a simplified adaptation of Vladimir Prelovac’s Live Blogroll plugin. He uses JavaScript and AJAX to call up the RSS feed of each site on the blogroll and capture the last few posts, their titles, posted dates and a fragment of the post content. This information is supposed to be presented in a pop up window when the user hovers their mouse pointer over a blog title in the blogroll. Unfortunately, some parameter of the Live Blogroll plugin keeps it from working properly with WordPress version 3.0 or greater, at least at the time of this writing.
By taking out the JavaScript and AJAX calls the plugin can be reduced to a single PHP file that shows the title of the last post for each site listed in the blogroll. If a site’s RSS feed cannot be found, then the title of the blog is listed instead. Taking away the interactivity of the blogroll leaves a simple, yet embellished, view of our favorite sites as listed in the blogroll.
The code was further updated to use the object-friendly fetch_feed function in order to replace the deprecated fetch_rss function.
Here’s the basic code for the WP Latest Post Blogroll:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
<?php
/*
Plugin Name: WP Latest Post Blogroll
Version: 1.0
Description: WP Latest Post Blogroll shows the most recent post title for each blog listed in the blogroll.
Author: LizzyFin
Author URI: http://computeraxe.com/
Plugin URI: http://computeraxe.com/wordpress-plugins/wp-latest-post-blogroll/
*/
/*
Copyright (c) 2011 LizzyFin
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the <a href="http://wordpress.org/about/gpl/">GNU General Public License</a>
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Contact the author via http://computeraxe.com/about-axe/
*/
/* Version check */
global $wp_version;
$exit_msg = __('WP Latest Post Blogroll requires WordPress 3.0 or newer. This plugin has been deactivated. <a href="http://codex.wordpress.org/Upgrading_WordPress">Please update!</a>');
if (version_compare($wp_version,"3.0","<"))
{
exit ($exit_msg);
}
//define plugin path
$wp_latest_blogroll_plugin_url = trailingslashit(WP_PLUGIN_DIR.'/'.dirname(plugin_basename(__FILE__)));
//include file that contains functions for parsing RSS feeds
require_once(ABSPATH . WPINC . '/feed.php');
//filter hook for changing display of bookmarks or blogroll
add_filter('get_bookmarks', 'WPLatestRoll_GetBookmarksFilter');
//filter function to get bookmarks
function WPLatestRoll_GetBookmarksFilter($items)
{
//do nothing if in the admin menu
if (is_admin())
{
return $items;
}
//parse all blogroll items
foreach($items as $item)
{
//check if the link is public
if ($item->link_visible=='Y')
{
$link_url=trailingslashit($item->link_url);
//simple feed guessing
if (strstr($link_url,"blogspot"))
{
//blogspot blog
$feed_url=$link_url."feeds/posts/default/";
}
elseif (strstr($link_url,"typepad"))
{
//typepad blog
$feed_url=$link_url."atom.xml";
}
else
{
//own domain or wordpress blog
$feed_url=$link_url."feed/";
}
// use WordPress to fetch the RSS feed, $feedfile is SimplePie object
$feedfile = fetch_feed($feed_url);
if (!is_wp_error($feedfile)) { // Checks that the object is created ok
// Figure out how many total items there are, but limit it to 5
$maxitems = $feedfile->get_item_quantity(5);
// Build an array of all the items
$feed_items = $feedfile->get_items(0, $maxitems);
$last_item = $feedfile->get_item(0);
$link_link = $last_item->get_permalink();
$link_name = $last_item->get_title();
$item->link_url=$link_link;
$item->link_name=$link_name;
}
if (!isset($feedfile)) {
$item->link_url=$item->link_url;
$item->link_name=$item->link_name;
}
}
}
//return the items
return $items;
}
?> |
Credit and thanks go out to Vladimir for showing us how to breathe life into our blogrolls.
WP Latest Post Blogroll can be used where ever you have your blogroll.
