How to Create a PluginWordPress?

Amrita Bhattarai
Dear WordPress
Published in
5 min readJan 31, 2020

Plugin…?

Plugin….? How to add? How does it work? …and main point if you don’t know about the Plugin then you must read my tutorial. Don’t worried about it. In my tutorial, there is an easy and simple way to know about the Plugin which I have been done. It is necessary to know about WordPress, I think you already know about it, if not then you should know about WordPress then start to add a plugin.

So, let’s start to make a plugin….

At first, you should clear about the Plugin so I give a simple definition that you read very carefully and try to understand.

A Plugin is a piece of software containing a group of functions that can be added to a WordPress website according to our needs. They can extend functionality or add new features to your WordPress websites which make your WordPress sites more attractive. If your search then you find any plugin in Wordpress.

Wordpress is the simplest, most popular platform where you can create your own website or blog. WordPress is basically a tool that makes attractive and manage important aspects of your website — like content — without any programming code.

If you don’t know any code or no interest in coding but you want to make a website in a short time with an easy and effective way then you can choose the best Platform i.e WordPress.

So let’s start...

* Simple way install Plugin in WordPress?

However, if you want to install the plugin is a simple and understanding way, you should follow the instruction as written:

  1. At, First thing you need to do is go to your WordPress admin area and click on plugins>Add New

2. Find the plugin or search the plugin in keyword by typing the plugin name or the functionality you are looking for like we did, For example, Twenty-twenty. Type the Twenty-twenty in the search block. After that, you will see a bunch of listings like the example below:

search the plugin right side or choose the plugin as you want.

3. After that you will get the bunch of plugin listing as like the example below:

some of the plugin as seen in the figure.

4. You can pick the plugin which is best for you. Since in our search, we were looking for Twenty-twenty plugin and then we will click the ‘Install Now’ button.

5. WordPress will now download and install the plugin for you. After this, you will see that to activate the plugin.

Activate the plugin

6. A WordPress plugin can be installed on your site, but it will not work unless you activate it. So go ahead and click on the activate plugin link to activate the plugin on your WordPress site.

And you will see the plugin as shown in figure

7. Click on activate and then you will see that that plugin is activated on your Dashboard side.

8. If you will not like the twenty-twenty plugin then click on deactivate, then the plugin will be automatically deactivated. There is a simple way to activate the plugin in WordPress.However, if you are interested to work in the plugin then there are many plugins you can or search as you need.

*Another way to create a plugin in WordPress with Simple and understanding way..?

In the above text where you can directly activate your Plugin in Wordpress but If you are interested in coding then you can create a WordPress plugin in some simple steps. To understand how WordPress Plugins work and how to activate them on your WordPress.

Let me show you how…

  • Create the main PHP file for your plugin.
  • Now, you’ll need to create the main file for your plugin. To do so, create a PHP file within your new plugin folder and give it the same name such as gharbazar.php. After you’ve done that, open your plugin’s main file and get ready to do some editing.
<?php
/**
* Plugin Name: gharbazar
* Plugin URI: http://www.mywebsite.com/my-first-plugin
* Description: The very first plugin that I have ever created.
* Version: 1.0
* Author: Your Name
* Author URI: http://www.mywebsite.com
*/
/// create a plugin in php file
  • You can now activate it within the WordPress admin in plugins as shown in figure
Activate the plugin
  • After this, the plugin is to activate and open your plugin’s main file and get ready to do some editing inside the gharbazar plugin by creating the function. The create function activates the plugin in Dashboard and you can do whatever you want inside the as shown in the below figure.
class gharbazar
{
private $gharbazar_screen_name;
private static $instance;
/*......*/
static function GetInstance()
{
if (!isset(self::$instance)) {
self::$instance = new self();
}
return self::$instance;
}
public function PluginMenu()
{
$this->my_plugin_screen_name = add_menu_page(
'Gharbazar',
'Gharbazar',
'manage_options',
__FILE__,
array($this, 'RenderPage'),
plugins_url('/img/icon.png', __DIR__)
);
}
//create a form
public
function
InitPlugin()
{
add_action('admin_menu', array($this, 'PluginMenu'));
add_shortcode('data_entry',array($this,'RenderPage'));
}
}
$gharbazar = gharbazar::GetInstance();
$gharbazar->InitPlugin();
  • That’s it! You’ve just completed the minimum number of steps that are required to create a WordPress plugin. After this, the plugin is activated on your dashboard. It is simple and easy to understand to create a plugin in WordPress.Well done!

--

--