Archive for the ‘PHP’ Category

A Free plugin for you :)

Friday, December 3rd, 2010

I’ve setup a database at the old scripttricks.com-domain and wrote a small plugin that, when activated, grabs and displays a famous quote on all of your posts.

Demo: check the bottom of the posts on this blog :)

Here’s the code:

<?php
/*
Plugin Name: myQuotesWP
Version: 0.5
Plugin URI: http://www.scripttricks.com
Description: Adds a famous quote to the end of all blog posts
Author: Bjorn
Author URI:
*/
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function fetch_quote($content) {
if(! is_feed() && ! is_page()) { // dont want it showing on anything but posts
$content .= file_get_contents_curl(“http://www.scripttricks.com/qu1/getquote.php”);
}
return $content;
}
add_filter(‘the_content’, ‘fetch_quote’);
?>
Save the code as “myQuotesWP.php”, copy it into your plugins-folder, activate and you’re ready to go. If you make any improvements on it or tweak, don’t hesitate to let me know, I enjoy seeing what others do with my code :)
You can also download it right here:
http://bjornsays.com/wp-content/plugins/downloads-manager/img/icons/winzip.gif download: myQuotesWP (532B)
added: 03/12/2010

description: Grabs a famous quote from scripttricks.com and adds it to the end of your posts. Unzip into your wp-content/plugins-folder, activate and you're set.