How-To: Write a WordPress Plugin
WordPress Plugins help us to easily modify , customize and enhance the WordPress Blog. We can use the WordPress Plugins to add functionality to WordPress instead of the modifying the core programming of the WordPress.
If you need a specific functionality for your blog you must first search WordPress Repository for existing plugins to see if someone has already developed a plugin that suits your requirements. If not then you should proceed developing your own plugin which is explained below:
I assume that you are already familiar with the basic functionality of WordPress, and PHP programming.
Creating a Plugin
This section will take you through the steps of creating a well-structured WordPress Plugin.
Names, Files, and Locations
You should choose a name for your plugin which describes what the plugin is going to do. For example a Stock Exchange related plugin should use wordpress Stocks in its name. You should also check the WordPress repository to check if the proposed name is available or already taken .
Create a plugin file with the name based on the name of the plugin. It is not cumplosary but you should follow the rules. You can place this file directly under the /wp-content/plugins/ directory or in the directory of you plugin (e.g: /wp-content/plugins/your-plugin/)
If you want to host your Plugin on http://wordpress.org/extend/plugins/, you also need to create a readme.txt file in a standard format, and include it with your Plugin. See http://wordpress.org/extend/plugins/about/readme.txt for a description of the format.
Note that the WordPress plugin repository takes the “Requires” and “Tested up to” versions from the readme.txt in the stable tag.
Creating Plugin Files
Now it’s time to put some information into your main Plugin PHP file.
Standard Plugin Information
Your Plugin’s main PHP must start with the following code.
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
License: A "Slug" license name e.g. GPL2
These lines will serve as the definition of your plugin. You can write your plugin code after these lines. The whole plugin logic will follow these lines .