I just installed the Snap my Roll plugin at www.patriciaritsemavaneck.name - this plugin randomly displays a snapshot of a site from your blogroll.
Sounds pretty cool but getting this feature up and running proved to be a little less cool…
First of all the instructions on how to activate and use the plugin at the WordPress Plugins pages are extremely minimal and also contain some typos:
<?php if (functionexists('snapmyroll')){snapmy_roll();} ?>
should be…
<?php if (function_exists('snap_my_roll')){snap_my_roll();} ?>
I got the almost correct line of php script from the developer’s blog, but if you copied from here, you need to remove the blank space before the first ? - question mark:
< ?php if (function_exists('snap_my_roll')){snap_my_roll();} ?>
Otherwise all instructions at this blog are in French and mine had become too rusty to make much sense of what was being asked in comments etc. And unfortunately, getting the php line correct didn’t make the plugin work…
I hate to give up quickly, so I decided to look at the plugin files to see if I could get this fixed myself. The original code is this:
function snap_my_roll(){
global $wpdb;
$js_url = get_settings('siteurl') . '/wp-content/plugins/SnapMyRoll/' . 'js/';
wp_enqueue_script('jquery');
//store links in an array
$my_query = "SELECT link_name, link_url FROM wp_links WHERE link_visible = 'Y'";
$links = $wpdb->get_results($my_query, OBJECT);
//rand the the array and build the javascript
shuffle($links);
echo "<li>\n\t<h2>Snap my 'Roll</h2>\n";
echo '<script type="text/javascript" src="'.$js_url.'jquery.js"></script>'."\n";
echo '<script type="text/javascript" src="'.$js_url.'jquery.innerfade.js"></script>'."\n";
echo '<script type="text/javascript">'."\n";
echo "\$j=jQuery.noConflict();\n";
echo "\$j(document).ready( function(){\n";
echo "\$j('#blogroll').innerfade(\n";
echo "{ timeout: 4000 ,type: 'sequence', containerheight: '180px', runningclass: 'snap_li'});\n";
echo "});\n";
echo "</script>\n";
//lets print the list of images
echo '<ul id="blogroll">'."\n";
foreach($links as $link){
echo '<li style="width:252px;">'."\n\t".'<a href="' .$link->link_url.'" title="'.$link->link_name.'">'."\n\t".'<img src="http://images.websnapr.com/?url='.$link->link_url.'&size=s" alt="'.$link->link_name.'" /><br />»'.$link->link_name."\n\t".'</a></li>';
echo "\n";
}
echo "</ul>\n</li>";
}
?>
And the problem is with the path to the .js files this plugin uses. It calls 2 files:
- jquery.js
- jquery.innerfade.js
But in the download you only get jquery.innerfade.js - which isn’t a problem because WordPress comes with jquery.js. The only problem is that WP’s jquery.js file is located somewhere else…
So I relocated the jquery.innerfade.js file to sit next to jquery.js and changed the code to this:
function snap_my_roll(){
global $wpdb;
$js_url = get_settings('siteurl') . '/wp-includes/js/jquery/';
wp_enqueue_script('jquery');
//store links in an array
$my_query = "SELECT link_name, link_url FROM wp_links WHERE link_visible = 'Y'";
$links = $wpdb->get_results($my_query, OBJECT);
//rand the the array and build the javascript
shuffle($links);
echo '<script type="text/javascript" src="'.$js_url.'jquery.js"></script>'."\n";
echo '<script type="text/javascript" src="'.$js_url.'jquery.innerfade.js"></script>'."\n";
echo '<script type="text/javascript">'."\n";
echo "\$j=jQuery.noConflict();\n";
echo "\$j(document).ready( function(){\n";
echo "\$j('#blogroll').innerfade(\n";
echo "{ timeout: 7000 ,type: 'sequence', containerheight: '133px', runningclass: 'snap_li'});\n";
echo "});\n";
echo "</script>\n";
//lets print the list of images
echo '<ul id="blogroll">'."\n";
foreach($links as $link){
echo '<li>'."\n\t".'<a href="' .$link->link_url.'" title="'.$link->link_name.'">'."\n\t".'<img class="websnapr" src="http://images.websnapr.com/?url='.$link->link_url.'&size=s" alt="'.$link->link_name.'" /></a></li>';
echo "\n";
}
echo "</ul>\n";
}
?>
I also made some changes to the generated html, but that is only to fit my template and not always a necessity.
Do I like this plugin?
At current I’m having mixed feelings about it.
- This plugin uses a screen snap shot service from www.websnapr.com - it’s a free service with the usual limitations when you don’t upgrade to their pro account. They add a watermark text to the snap shots. It’s not very intrusive, but it wouldn’t look good on any professional sites (by which I mean sites used for commercial purposes as opposed to personal blogs and such).
- In addition there seems to be a limit to the number of snap shots they will generate for you per day. I still have 3 snap shots in queue and they have been in this status for well over 12 hours by now…
- As for the plugin itself, I don’t like the fact it cannot be used as a widget. If you add the php snippet to a text widget, it just displays the php code in your sidebar. (You can actually get another plugin to fix this problem, but that’s another story…)
- The plugin prints a default title ‘Snap my Roll’ which can only be changed from within the php file.
- What I also don’t like is that the plugin generates html that isn’t compliant with WordPress standards. It’s minor - just h2 tags instead of h3 tags for the plugin title, but still…
I think this plugin has potential. With some small adjustments it would be better suitable for general use. I will still look for an alternative at this point that suits my own needs better…
UPDATE - 20 March 2008 at 17:21
After only a couple of hours, I decided to let this plugin go. It wants to be the top layer of the site no matter what and that seriously disturbs my lightbox feature for photographs�
One Trackback
[…] améliorations tiennent compte du feedback collecté sur certains blogs et en commentaire de la page du […]