Wordpress basic functionality is provide a blogging platform. But now a days it is not a just blogging platform but it use into many other scripts such as web forums, classic web page, CMS (Content Management System) etc.
We can extend wordpress capabilities by theme, plugin or page template.In this tutorial we learn the basic information about the wordpress plugin development.
Naming Conventions
When write your plugin code, it is best practice to follow regulations set up by wordpress.
Always choose function name unique and related to plugin name. so it doesn’t create ambiguity with other plugin.
Put comment wherever and whenever needed in code.
Plugin folder
Plugins directory you will find inside wp-content directory. Wordpress allow you to place the plug-in sigle php file directly into the wp-content/plugins directory. But it’s good practice to create a sub directory name with plugin name inside the wp-content directory. Inside you can put JS, CSS, PHP, HTML & readme.txt etc.
Understanding Actions and Filters
add_action() and add_filter() are heart of a wordpress plugins. Both functions also called as a wordpress hooks. It is very important to know the difference between both function before start wordpress plugins development.
add_action($tag,$fun) :
used to call functions in your plugin at specific time. Wordpress offers various action list.
add_filter($tag,$fun) :
used to modify different types data before any action like adding it to the database or sending it to the browser screen.More about the wordpress hooks.
Standard Plugin information
The first line of every plugin must be comment information for parsing wordpress engine. This comment line known as standard Plugin information header. Below is an example of header format.
1: <?php
2: /*3: Plugin Name: Name Of The Plugin
4: Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
5: Description: A brief description of the Plugin.
6: Version: The Plugin's Version Number, e.g.: 1.0
7: Author: Name Of The Plugin Author
8: Author URI: http://URI_Of_The_Plugin_Author
9: License: A "Slug" license name e.g. GPL2
10: */11: ?>
This header part parse by the wordpress engine and add it to the plugins screen so it can be activated, load it, and run it’s function. Without header information plugin never run.
Plugin Name line must be present in header part, without it can not work. Order of the lines is not important.
No comments:
Post a Comment