Creating a WordPress Plugin is a little bit easier. Here is the simple tutorial for wordpress plugin development. Plugin development involves following important aspects
This plugin will display today’s date
- Download this plugin and install in your server/localhost
- Posts -> Add New
- type in your post
You will see today’s date with style
[code type=php]
<?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
* License: A “Slug” license name e.g. GPL2
*/
?>
[/code]
This header values will be replicated in plugin page
- freeze_plugin() – this php function will return today date with CSS style given below.
- add_shortcode(‘freeze’, ‘freeze_plugin’) – creates shortcode “freeze”
[code type=php]
<?php
/*
Plugin Name: Freeze Plugin
Plugin URI: http://freezecoders.com/
Description: Freeze coders is a simple plugin with short code to display current date.
Author: prasad
Author URI: http://freezecoders.com/
Version: 1.0
*/
function freeze_plugin()
{
echo “<div class=’freeze-date’>”.date(‘M d, Y’).”</div>”;
}
add_shortcode(‘freeze’, ‘freeze_plugin’);
?>
<style type=”text/css”>
.freeze-date
{
background: #ccc;
padding: 5px 15px;
font-size: 24px;
}
</style>
[/code]
How to Create ShortCode
Shortcode in wordpress is like a abbreviation, which is used to call a function. Main use of shortcode is, inside post we can’t call php function and shortcode will do intermediate.
add_shortcode(‘freeze’, ‘freeze_plugin’);
freeze – shortcode name, it will be used as freeze
freeze_plugin – freeze shortcode’s equivalent php function
Folder name: Freeze-Plugin
File name: freeze-plugin.php
freeze-plugin.php file should be inside the folder Freeze-Plugin
Make the folder as .ZIP format
Then you can use this plugin in wordpress by installing and activate.