December 3, 2010 – 3:57 am
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:
[dm]2[/dm]
Posted in New Products, Personal, PHP, Programming, web | 2 Comments »