SlideShare a Scribd company logo
Step by Step Guide for creating Wordpress plugin
http://idiotechie.com/?p=824                                                                  August 31, 2012



What is WordPress? WordPress is Open Source Blog
publishing software which uses PHP as front end and
MySQL as back end in the application. It is highly
extensible through pluggable framework and use of
‘Plugin’.

What is a WordPress Plugin? A plugin is a pluggable
feature to the WordPress application which allow an
enhancement , allows customization or modification to
the installed wordpress application easily. It consists of
one or more functions which integrates with the
wordpress application without actually modifying the existing application code.

In this article we will show a step by step guide on how to create a wordpress plugin and make it ready
to useHere are little key points on the background of WP Plugin.
WordPress Directory : All the WordPress plugins are kept under wp-contentplugins directory. So
any new plugins created needs to be used inside this folder.
File Header: File header in WordPress plays a vital role as it is this file which is read by the
wordpress application for getting the meta information e.g. plugin name, version, author etc.
WP Plugin Hooks: These are the components which hooks into the wordpress application without
modifying the original files. Hooks are of two types -
a) Action Hooks: This is all about inserting additional custom code into the wordpress application.
Actions are triggered by specific events in the WordPress application such as publishing a post,
changing themes, or displaying a page of the admin panel. Action hook code (function) can execute a
specific code in response to the event. e.g. wp_head, wp_footer, comment_post.

add_action( 'hook_name', 'your_function_name',[priority],
[accepted_args] );

b) Filter Hooks: Filters can be imagined as a piece of code which can change the text just before
writing the content into the database or displaying on the screen.e.g. the_content, the_title,
comment_text etc.

add_filter('hook_name', 'your_filter_function', [priority],
[accepted_args]);

Now we are going to create a simple WordPress plugin called ‘Simple Stylish Table’. This plugin
makes use of css file to create a stylish looking HTML table plugin. So let’s follow a step by step
guide.

Step 1: Give a plugin name and create directory
The plugin name must be unique and should relate to the functionality of the plugin.Let’s give the plugin
name as ‘Simple Stylish Tables’.Now create a folder under the wp-contentplugins path with simple-
stylish-tables.

Step 2: Create a css file.
Create a css file ‘ssstyle.css’ which actually overrides the standard wordpress application css file by
providing customized style for HTML tables.
.ss-table
{
padding: 0;
margin: 0;
border-collapse: collapse;
border: 1px dashed #333;
color: #000;
background: #bcd0e4;
}

In the above code snippet a new class .ss-table is being created to customize the look and feel of the
HTML table.

Step 3: Now create the main plugin file
Create a PHP file – ‘sstables.php’ which contains the main plugin code.

Step 4: Create the Header content

//Plugin Name: Simple Stylish Tables
Plugin URI: http://www.idiotechie.com/download/
Description: Simple plugin for creating styish tables in the WP
Author: Mainak Goswami
Version: 1.0
Author URI: http://www.idiotechie.com
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;
*/

The header information which holds the meta data of the plugin are actually featured in the plugin
dashboard when the plugin in installed.




Step 5: Create a function stylish_table()
The stylish_table() function will first register the new custom stylesheet :”ssstyle.css” for further use and
then add/enqueue a CSS style file to the wordpress generated page.

wp_register_style('stylish_table_style', plugins_url('ssstyle.css',
__FILE__),false,"1.0");

The above contents of the function wp_register_style can be explained as below:
wp_register_style(“Name of the Stylesheet”, “Path of the stylesheet”,”boolean value to determine that
there is no dependencies on any other stylesheet”,”version number”);

wp_enqueue_style('stylish_table_style');

This loads the “stylish_table_style” in the wordpress application.

Well…is that all? Wait…there is one last step…We will need to use one of the action hooks to hook our
plugin to the wordpress application.
add_action('wp_enqueue_scripts', 'stylish_table');

The add_action adds the function stylish_table() to the wp_enqueue_scripts hook.

That’s all about creating a plugin. Now how do I use it in my posts in blog?

Step 6: Submit your newly created plugin to the wordpress site as per the instructions provided in the
below link: http://codex.wordpress.org/Plugin_Submission_and_Promotion

Step 7: Install the plugin. The plugin can be added through “Add New” option in the Plugin Dashboard
page. Or it can be manually installed as well by placing/ FTP the code under the /wp-content/plugins
folder and then activate it from the plugin dashboard.

Step 8: Use the plugin inside the posts: Once the plugin has been activated it can be used to
customize to style up the existing or new HTML tables inside the posts and use the style class as -”ss-
table” which has been referred in the stylesheet or in the plugin description.

Sample Test table example is shown below.

<table class="ss-table" border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td valign="top" width="284">Java</td>
<td valign="top" width="284">C++</td>
</tr>
<tr>
<td valign="top" width="284">Write once, run anywhere /
everywhere.</td>
<td valign="top" width="284">Write once, compile anywhere.</td>
</tr>
<tr>
<td style="text-align: left;" valign="top" width="284"> Runs in a
virtual machine.</td>
<td style="text-align: left;" valign="top" width="284">Exposes low-
level details.</td>
</tr>
</tbody>
</table>

Output :
Note: The hover effect cannot be displayed here but as an example it can be found in the following post:
SAX vs DOM Parser.




<<Download Code>>

Filed in: PHP, Random, Social Media, Trends Tags: action hook, css, filter hook, guide, hooks, html,
php, plugin, step by step, stylish, table, Wordpress

More Related Content

What's hot (20)

PPTX
Wordpress
Arjun Srivastava
 
PDF
Agile Wordpress
Filippo Dino
 
ODP
The Future Of WordPress Presentation
Dougal Campbell
 
PDF
Plugin development demystified 2017
ylefebvre
 
PPTX
How to create your own WordPress plugin
John Tighe
 
PDF
Wordpress as a framework
Aggelos Synadakis
 
PPT
Getting Started With Wordpress
Digital Strategy Works LLC
 
PPT
Word press Plugins by WordPress Experts
Yameen Khan
 
PPT
WordPress Plugins
OpenSource Technologies Pvt. Ltd.
 
PPTX
Wordcamp2012 build your plugin
Alexandre Marreiros
 
PPT
Secure All The Things!
Dougal Campbell
 
ODP
Don't sh** in the Pool
Chris Jean
 
PDF
WordCamp SF 2011: Debugging in WordPress
andrewnacin
 
PPT
Developing Plugins For WordPress
Lester Chan
 
PPT
Top 20 word press plugins you've never heard of
Toan Nguyen
 
PPT
Top 20 WordPress Plugins You've Never Heard Of
Brad Williams
 
PPTX
Introduction to word press
Lucky Ali
 
PPTX
Jomc463 beginner wordpress(zeoli)
Digital Strategy Works LLC
 
KEY
WordPress for Content Editors
Milan van Bruggen
 
PDF
Plugins at WordCamp Phoenix
Andrew Ryno
 
Wordpress
Arjun Srivastava
 
Agile Wordpress
Filippo Dino
 
The Future Of WordPress Presentation
Dougal Campbell
 
Plugin development demystified 2017
ylefebvre
 
How to create your own WordPress plugin
John Tighe
 
Wordpress as a framework
Aggelos Synadakis
 
Getting Started With Wordpress
Digital Strategy Works LLC
 
Word press Plugins by WordPress Experts
Yameen Khan
 
Wordcamp2012 build your plugin
Alexandre Marreiros
 
Secure All The Things!
Dougal Campbell
 
Don't sh** in the Pool
Chris Jean
 
WordCamp SF 2011: Debugging in WordPress
andrewnacin
 
Developing Plugins For WordPress
Lester Chan
 
Top 20 word press plugins you've never heard of
Toan Nguyen
 
Top 20 WordPress Plugins You've Never Heard Of
Brad Williams
 
Introduction to word press
Lucky Ali
 
Jomc463 beginner wordpress(zeoli)
Digital Strategy Works LLC
 
WordPress for Content Editors
Milan van Bruggen
 
Plugins at WordCamp Phoenix
Andrew Ryno
 

Viewers also liked (15)

ODP
Beginning WordPress Plugin Development
Aizat Faiz
 
PPTX
Wp woo sms plugin
RankSol
 
PPTX
Custom Post Types and Taxonomies
Tammy Hart
 
KEY
WordPress 3 Custom Post Types
Dave Zille
 
PPSX
Workshop 4: IJssel-Vechtdelta lessons learned
Bas van Dishoeck
 
KEY
Custom Post Types in Depth at WordCamp Montreal
Joey Kudish
 
PPTX
Anatomy and Architecture of a WordPress Theme
Julie Kuehl
 
PDF
Slideshare photographer final
NishitMultidots
 
PDF
Slideshare videogames components
NishitMultidots
 
PDF
Slideshare psychologyofcolor final
NishitMultidots
 
PPTX
Architecture for WordPress on AWS
Saravana Kumar Periyasamy
 
PDF
WordPress Code Architecture
Mario Peshev
 
PDF
WordCamp Ireland - 40 tips for WordPress Optimization
Joost de Valk
 
PDF
Fiverr Seller Best Practices
Fiverr
 
PPTX
Basic Wordpress PPT
mayur akabari
 
Beginning WordPress Plugin Development
Aizat Faiz
 
Wp woo sms plugin
RankSol
 
Custom Post Types and Taxonomies
Tammy Hart
 
WordPress 3 Custom Post Types
Dave Zille
 
Workshop 4: IJssel-Vechtdelta lessons learned
Bas van Dishoeck
 
Custom Post Types in Depth at WordCamp Montreal
Joey Kudish
 
Anatomy and Architecture of a WordPress Theme
Julie Kuehl
 
Slideshare photographer final
NishitMultidots
 
Slideshare videogames components
NishitMultidots
 
Slideshare psychologyofcolor final
NishitMultidots
 
Architecture for WordPress on AWS
Saravana Kumar Periyasamy
 
WordPress Code Architecture
Mario Peshev
 
WordCamp Ireland - 40 tips for WordPress Optimization
Joost de Valk
 
Fiverr Seller Best Practices
Fiverr
 
Basic Wordpress PPT
mayur akabari
 
Ad

Similar to Step by step guide for creating wordpress plugin (20)

PDF
Creating Your First WordPress Plugin
Brad Williams
 
PDF
How to Create a Custom WordPress Plugin
Andolasoft Inc
 
PDF
Website development PDF which helps others make it easy
sanjanasanju23456789
 
PDF
Best Wordprees development company in bangalore
sanjanasanju23456789
 
PPSX
Extending WordPress
Jonathan Bossenger
 
PPTX
Faster WordPress Workflows
Eladio Jose Abquina
 
PPT
WordPress 2.5 Overview - Rich Media Institute
Brendan Sera-Shriar
 
PPTX
Getting started with WordPress development
Steve Mortiboy
 
PPTX
Writing your own WordPress themes and plugins
Stephanie Wells
 
PDF
Write your first WordPress plugin
Anthony Montalbano
 
PPTX
Plug in development
Lucky Ali
 
PPTX
Introduction To Simple WordPress Plugin Development
Bruce L Chamoff
 
PDF
WordPress Theming 101
Zero Point Development
 
PDF
5 Steps to Develop a WordPress Plugin From Scratch.pdf
BeePlugin
 
PPTX
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
PPTX
Wordpress For Begineer
Binita Neupane
 
PPTX
Wordpress multisite
Plasterdog Web Design
 
PPTX
Ch1,2 install
pyouells
 
PPTX
Ch1,2 install
pyouells
 
PDF
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Evan Mullins
 
Creating Your First WordPress Plugin
Brad Williams
 
How to Create a Custom WordPress Plugin
Andolasoft Inc
 
Website development PDF which helps others make it easy
sanjanasanju23456789
 
Best Wordprees development company in bangalore
sanjanasanju23456789
 
Extending WordPress
Jonathan Bossenger
 
Faster WordPress Workflows
Eladio Jose Abquina
 
WordPress 2.5 Overview - Rich Media Institute
Brendan Sera-Shriar
 
Getting started with WordPress development
Steve Mortiboy
 
Writing your own WordPress themes and plugins
Stephanie Wells
 
Write your first WordPress plugin
Anthony Montalbano
 
Plug in development
Lucky Ali
 
Introduction To Simple WordPress Plugin Development
Bruce L Chamoff
 
WordPress Theming 101
Zero Point Development
 
5 Steps to Develop a WordPress Plugin From Scratch.pdf
BeePlugin
 
Intro to Plugin Development, Miami WordCamp, 2015
topher1kenobe
 
Wordpress For Begineer
Binita Neupane
 
Wordpress multisite
Plasterdog Web Design
 
Ch1,2 install
pyouells
 
Ch1,2 install
pyouells
 
WordCamp Greenville 2018 - Beware the Dark Side, or an Intro to Development
Evan Mullins
 
Ad

Recently uploaded (20)

PDF
Staying Human in a Machine- Accelerated World
Catalin Jora
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
DOCX
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
PDF
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
PPTX
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
PPTX
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
PDF
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
PDF
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
PPTX
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 
Staying Human in a Machine- Accelerated World
Catalin Jora
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
NASA A Researcher’s Guide to International Space Station : Physical Sciences ...
Dr. PANKAJ DHUSSA
 
Cryptography Quiz: test your knowledge of this important security concept.
Rajni Bhardwaj Grover
 
The 2025 InfraRed Report - Redpoint Ventures
Razin Mustafiz
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
LOOPS in C Programming Language - Technology
RishabhDwivedi43
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
Book industry state of the nation 2025 - Tech Forum 2025
BookNet Canada
 
Mastering ODC + Okta Configuration - Chennai OSUG
HathiMaryA
 
Agentforce World Tour Toronto '25 - MCP with MuleSoft
Alexandra N. Martinez
 
“Voice Interfaces on a Budget: Building Real-time Speech Recognition on Low-c...
Edge AI and Vision Alliance
 
“Squinting Vision Pipelines: Detecting and Correcting Errors in Vision Models...
Edge AI and Vision Alliance
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
UPDF - AI PDF Editor & Converter Key Features
DealFuel
 
Seamless Tech Experiences Showcasing Cross-Platform App Design.pptx
presentifyai
 

Step by step guide for creating wordpress plugin

  • 1. Step by Step Guide for creating Wordpress plugin http://idiotechie.com/?p=824 August 31, 2012 What is WordPress? WordPress is Open Source Blog publishing software which uses PHP as front end and MySQL as back end in the application. It is highly extensible through pluggable framework and use of ‘Plugin’. What is a WordPress Plugin? A plugin is a pluggable feature to the WordPress application which allow an enhancement , allows customization or modification to the installed wordpress application easily. It consists of one or more functions which integrates with the wordpress application without actually modifying the existing application code. In this article we will show a step by step guide on how to create a wordpress plugin and make it ready to useHere are little key points on the background of WP Plugin. WordPress Directory : All the WordPress plugins are kept under wp-contentplugins directory. So any new plugins created needs to be used inside this folder. File Header: File header in WordPress plays a vital role as it is this file which is read by the wordpress application for getting the meta information e.g. plugin name, version, author etc. WP Plugin Hooks: These are the components which hooks into the wordpress application without modifying the original files. Hooks are of two types - a) Action Hooks: This is all about inserting additional custom code into the wordpress application. Actions are triggered by specific events in the WordPress application such as publishing a post, changing themes, or displaying a page of the admin panel. Action hook code (function) can execute a specific code in response to the event. e.g. wp_head, wp_footer, comment_post. add_action( 'hook_name', 'your_function_name',[priority], [accepted_args] ); b) Filter Hooks: Filters can be imagined as a piece of code which can change the text just before writing the content into the database or displaying on the screen.e.g. the_content, the_title, comment_text etc. add_filter('hook_name', 'your_filter_function', [priority], [accepted_args]); Now we are going to create a simple WordPress plugin called ‘Simple Stylish Table’. This plugin makes use of css file to create a stylish looking HTML table plugin. So let’s follow a step by step guide. Step 1: Give a plugin name and create directory The plugin name must be unique and should relate to the functionality of the plugin.Let’s give the plugin name as ‘Simple Stylish Tables’.Now create a folder under the wp-contentplugins path with simple- stylish-tables. Step 2: Create a css file. Create a css file ‘ssstyle.css’ which actually overrides the standard wordpress application css file by providing customized style for HTML tables.
  • 2. .ss-table { padding: 0; margin: 0; border-collapse: collapse; border: 1px dashed #333; color: #000; background: #bcd0e4; } In the above code snippet a new class .ss-table is being created to customize the look and feel of the HTML table. Step 3: Now create the main plugin file Create a PHP file – ‘sstables.php’ which contains the main plugin code. Step 4: Create the Header content //Plugin Name: Simple Stylish Tables Plugin URI: http://www.idiotechie.com/download/ Description: Simple plugin for creating styish tables in the WP Author: Mainak Goswami Version: 1.0 Author URI: http://www.idiotechie.com 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; */ The header information which holds the meta data of the plugin are actually featured in the plugin dashboard when the plugin in installed. Step 5: Create a function stylish_table() The stylish_table() function will first register the new custom stylesheet :”ssstyle.css” for further use and then add/enqueue a CSS style file to the wordpress generated page. wp_register_style('stylish_table_style', plugins_url('ssstyle.css', __FILE__),false,"1.0"); The above contents of the function wp_register_style can be explained as below: wp_register_style(“Name of the Stylesheet”, “Path of the stylesheet”,”boolean value to determine that there is no dependencies on any other stylesheet”,”version number”); wp_enqueue_style('stylish_table_style'); This loads the “stylish_table_style” in the wordpress application. Well…is that all? Wait…there is one last step…We will need to use one of the action hooks to hook our plugin to the wordpress application.
  • 3. add_action('wp_enqueue_scripts', 'stylish_table'); The add_action adds the function stylish_table() to the wp_enqueue_scripts hook. That’s all about creating a plugin. Now how do I use it in my posts in blog? Step 6: Submit your newly created plugin to the wordpress site as per the instructions provided in the below link: http://codex.wordpress.org/Plugin_Submission_and_Promotion Step 7: Install the plugin. The plugin can be added through “Add New” option in the Plugin Dashboard page. Or it can be manually installed as well by placing/ FTP the code under the /wp-content/plugins folder and then activate it from the plugin dashboard. Step 8: Use the plugin inside the posts: Once the plugin has been activated it can be used to customize to style up the existing or new HTML tables inside the posts and use the style class as -”ss- table” which has been referred in the stylesheet or in the plugin description. Sample Test table example is shown below. <table class="ss-table" border="1" cellspacing="0" cellpadding="0"> <tbody> <tr> <td valign="top" width="284">Java</td> <td valign="top" width="284">C++</td> </tr> <tr> <td valign="top" width="284">Write once, run anywhere / everywhere.</td> <td valign="top" width="284">Write once, compile anywhere.</td> </tr> <tr> <td style="text-align: left;" valign="top" width="284"> Runs in a virtual machine.</td> <td style="text-align: left;" valign="top" width="284">Exposes low- level details.</td> </tr> </tbody> </table> Output : Note: The hover effect cannot be displayed here but as an example it can be found in the following post: SAX vs DOM Parser. <<Download Code>> Filed in: PHP, Random, Social Media, Trends Tags: action hook, css, filter hook, guide, hooks, html, php, plugin, step by step, stylish, table, Wordpress