Wordpress plugin is an addon for Wordpress blogs to add new features to the blog. There are tons of Wordpress extensions available at the Wordpress extension directory. I recently wrote a twitter extension for Wordpress which is available for public download here.
If you are planing to write your own Wordpress extension, you can do it if you have knowledge of PHP and if you are aware of the Wordpress functionality.
For writing a Wordpress plugin you need to first create a file with the following code on top part of the file. You need to maintain the coding style of the Wordpress plugin as per the Wordpress Documentation
<?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the plugin.
Version: The plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
*/
?>
The licence part of a Wordpress plugin
<?php
/* Copyright YEAR PLUGIN_AUTHOR_NAME (email : PLUGIN AUTHOR EMAIL)
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 GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
?>
The above two codes are the standard for Wordpress plugins and you need to follow that
Then comes the programing part of the wordpress. I show a simple function which prints some text
<?php
function myFirstPlugin($mycontent) {
return str_replace("kishore", "<a href = \"http://kish.in\">Kishore</a>");
}
?>
<?php add_filter('the_content','myFirstPlugin'); ?>
Your first plugin is ready for testing.
What does this plugin do?
I have created a function which replaces the text, “Kishore” with a link to my blog. I have used the filter “the_content” which replaces the text of the content of post.


{ 1 trackback }
{ 0 comments… add one now }