Let's talk Contact us. No cost. No obligation.

Fill out this form and we will contact you with in 24 hrs.




Knowledge Base

Create a WordPress Plugin

April 20, 2017

Now developers need to create files and folder structure under wp-content/plugins/ folder. Let’s start creating a specific folder with name my_plugin.

Next, we must create our main plugin file under my_plugin. We’ll name it my_plugin.php. We can name it whatever we want, it does not make any difference.

Now it is the time to tell WordPress that our file is going to implement a plugin. The process to do so is very simple. All we need to do is add a plugin specific information header to our newly created file.
This standard header will look like this:
Plugin Name: My Plugin
Plugin URI: http://www.onsinteractive.com
Description: Plugin for tutorial
Author: Sanjay
Version: 1.0
Author URI: http://www.onsinteractive.com

Now we will register plugin activation and deactivation hooks in my_plugin.php file. we can do this by following funtions:

register_activation_hook(__FILE__, ‘my_plugin_install’);
register_deactivation_hook(__FILE__, ‘my_plugin_deactivation’);
Now we need to define the funtions to activate and deactivate the plugin in my_plugin.php file
function my_plugin_install()
// write your code here

function my_plugin_deactivation()
// write your code here

Now you are done with the plugin.

About Sanjay Kumar

Software Professional with around six years of experience in software industry. My area of expertise includes:- PHP, MySQL, OOPs, MVC, WordPress, Magento, Web Services, SOAP, AJAX, JQuery, JavaScript, JSON.