Charl van Niekerk » Blog

Main

Latest

Archives

Powered by Blogger

Muti Wordpress 2.5 Plugin

After some discussion via mail I created my first Wordpress plugin this afternoon. It's very simple and will add a little "Muti This" button to the bottom of your posts.

<?php
/*
Plugin Name: Muti
Plugin URI: http://muti.co.za
Description: Adds a muti button at the bottom of each post.
Author: Charl van Niekerk
Version: 1.0
Author URI: http://charlvn.za.net
*/
function muti($c) {
  return $c . '<p><a href="http://muti.co.za/submit?url=' . urlencode(get_permalink()) . '&amp;title=' . urlencode(the_title('', '', false)) . '"><img src="' . get_option('siteurl') . '/wp-content/plugins/muti/muti.gif" alt="Muti This" title="Muti This" /></a></p>';
}
add_action('the_content', 'muti');

To install it get muti.zip and put the muti directory inside of your wp-content/plugins directory. Then just open your Wordpress admin back-end and enable the plugin as usual.

This has been created for and tested on Wordpress 2.5; it may or may not work on older versions.

Please let me know what you think and if you have any suggestions for improvements!

1 Comments

Comment by Blogger Alastair on Wednesday, April 16, 2008 6:43:00 AM

Nice Charl,

One thing worth considering is whether you want the muti link on all pages or just single (ie view) pages. You could just add a condition something like:

if(Is_Single()) {
show content and muti button }
else {
just show content }

Then the muti link will only appear on single pages and not the front page.

Cheers

Post a Comment

Copyright © 2004-2009 Charl van Niekerk. All articles are released under the Creative Commons Attribution 2.5 South Africa licence, unless where otherwise stated.