Wordpress Plugin Development for beginners

Hi this is Aman. I am PHP developer. I have worked in many technologies. I have worked on many Wordpress websites and created some custom Wordpress plugins as well.
As a beginner, the very first thing comes in mind that “What is the meaning of Wordpress plugin?” So, In very simple words.
A WordPress Plugin is a program or a set of one or more functions written in the PHP scripting language, that adds a specific set of features or services to the WordPress site.
Hmmm.. I thing its a good definition for Wordpress plugin. Isn’t it?
So, let’s move further there are many plugins available in Wordpress some are freely available and some needs to purchase( Hmmm…heavy for the pocket). But sometimes there are some requirements for that we need a custom Wordpress plugins.
Now, Whenever the term custom plugin development come, many of us things it would be very difficult. Is it?

No.. Not that much difficult. I will share the basic steps for plugin development. Hope that will help you. So, Let’s start.
Step1: The very first step is create a folder in plugins folder. Obesely! it is “wp-content/plugins” yar. Try to give a name similar to your requirements. Like if I have to create a plugin for gallery then I will give folder a name may be “gallery” or “my_gallery” anything you like all depends upon you.
Step2: Create a file with .php . You can name it “index.php” or “gallery.php”. Now, lets; move to the 3rd step.
Step3: Now, in the file after <?php tag define the Plugin name, plugin URI (if any), Description(For what the plugin is for), Author, version. Something like
/*
Plugin Name: Gallery
Plugin URI:
Description: Plugin to add, edit, view the gallery items from admin.
Author: Admin
Version: 1.0.1
Author URI:
*/
Isn’t it Cool…?
Step4: Now, next is define the admin url, folder, plugin url, file path, directory name. If you wanna include any script or style then you can also include that. Lets have an example:
/* Define */
define(‘ADMIN_URL’, admin_url());
define(‘GALLERY_FOLDER’, dirname(plugin_basename(__FILE__)));
define(‘GALLERY_URL’, plugins_url(‘/’) . GALLERY_FOLDER);
define(‘GALLERY_FILE_PATH’, dirname(__FILE__));
define(‘GALLERY_DIR_NAME’, basename(GALLERY_FILE_PATH));
/* Include script/style*/if(file_exists( GALLERY_FILE_PATH . ‘/inc/scripts.php’))
{
require_once(GALLERY_FILE_PATH . “/inc/scripts.php”);
}
Step5: Next step is to add activation and deactivation hooks.
function wp_gallery_install()
{
/* Here you can add script to create tables as per your requirements. */
}
function wp_gallery_uninstall()
{
/* Here you can add script to delete tables. */
}register_activation_hook(__FILE__,’wp_gallery_install’);
register_deactivation_hook(__FILE__ , ‘wp_gallery_uninstall’ );
Step6: After that create admin menus for plugin using Wordpress hooks. Something like
add_action(‘admin_menu’,’gallery_admin_menu’);
function gallery_admin_menu() {
add_menu_page(
MENU1,
MENU1,
8,
__FILE__,
“galley_list”,
GALLERY_URL.”/images/gallery.png”
);
add_submenu_page(__FILE__,MENU2 ,MENU2 ,’8',’add_gallery’,’add_gallery’);
}
and include the pages for functionality. Have a look here
function galley_list()
{
// include page to show gallery list.
}function add_gallery()
{
// include page for add items to gallery functionality.
}
Now, go to the plugins in admin pannel and install the plugin then activate it. With all these 6 steps you are good to go.. Now play with the plugin and do whatever you want to do.
Ohh! How can I forgot this… Please note try to give unique names for folder, in definition section and for hooks so that it will not conflict with any other plugin.
Conclusion
Wordpress plugin development is not that much difficult. Only we need is little efforts and knowledge how and what we have to do.
I hope the above steps will helpful for you.
This is all about custom plugin development. This was my first try. If you found it useful please clap 👏 for this article.

