Wordpress Series: Coding Your Way Via Plugins
Today's article is another part of the wordpress tutorial series I've recently started, and which targets handling the concept of how to create your own Wordpress Plugin via coding.
Still not sure what wordpress is? In a nutshell, it is basically a Content Management System (CMS) for building websites. Still not there? Simply check out my the definition in my prior article here Retrieving Wordpress Custom Posts Via Ajax

Oh and if you've missed prior entries in the tutorial, you can check out the first two parts:
- How To Properly Customize Your Wordpress Installation .. Via Coding
- Securing Your Wordpress Installation
What is a Wordpress Plugin?
Generally speaking, a plugin is an additional tool on top of an existing solution. It allows you to perform a task that is not by default supported as part of the platform at hand.
A wordpress plugin is basically just that. It is an additional functionality that is not normally available as part of your standard wordpress functionality, and is normally aimed at upgrading your site/solution to accommodate for your needs.
There are literally thousands of plugins already available for wordpress. As of now, there are over 53,000 plugins hosted on the official wordpress plugins directory
While there might be many others hosted elsewhere, yet the former is the easiest and most accessible platform for hosting wordpress plugins.
Why create your own plugin?
So while there are that many wordpress plugins, which could basically expand the functionality in tons of ways possible, yet there are at times, many reasons why you would want to create your own plugin, including but not limited to:
- Existing wordpress plugin is too bulky: many plugins cover a wide range of functionality, and hence can bulk up your site's site and slow its performance. And we don't want that.
- Existing wordpress plugin potentially badly implemented: While many plugins are of high quality, and you can normally assess the quality via reviews and ratings, yet some plugins can cause harmful or unneeded outcome to your site, not to mention potential conflicts with other plugins.
- Your functionality is not covered already: which makes it a necessity to build a new plugin (for really minor changes, you can also use different ways for customizing your wordpress install, as mentioned in our prior article How To Properly Customize Your Wordpress Installation .. Via Coding)
How complex is building a plugin?
It might be a daunting task in other platforms and/or frameworks, yet with wordpress, the process is essentially quite easy that almost anyone can do it, even with minor knowledge of programming.
Preferably that knowledge would be in PHP (the server side language used by wordpress), MySQL database NOT being a necessity (as wordpress can handle that layer for you via its interfacing functionalities), and some Front end scripting is useful (a combination of HTML+CSS+JS/JQuery) for building the interface and interacting with it.
Steps in building the plugin
Create the plugin's file structure
The plugin's file structure can be as minor as a single folder with a single PHP file. Chose the name of your plugin to conform to what the plugin is aimed at, especially if you plan on sharing this plugin with others, for example My plugin for saving data and then name your folder and single file (at least one PHP file is required) according to that standard (my-plugin-for-saving-data and my-plugin-for-saving-data.php).
Check the below structure of a plugin that I created called Woo Product Remover

A readme.txt file is not required yet is helpful, especially to highlight what the plugin provides in terms of functionality, but also as the official documentation for anyone using the plugin.
Code structure
As mentioned above, creating the plugin requires a single php file. While for larger plugins, you can have thousands of files and folders, but for the wordpress install to identify this to be a proper plugin, there are minor structural requirements needed at the level of that one php file.
This includes having a proper header in the my-plugin-for-saving-data.php example file, which would go as follows, all inclusive including the opening and closing /* */ which identify a comment section in PHP:
/*
Plugin Name: My plugin for saving data
Plugin URI: http://www.mypluginforsavingdata.com/
Description: My plugin for saving data allows my wordpress site to cook, bake, and do my laundry :d
Version: 1.0.1
Author: Mystery user
Author URI: http://www.mysteryuser.com
License: GPLv2
*/
A sample screenshot from that woo product remover plugin's core PHP file:

Script your plugin
From now on, it's up to your coding skills. In fact, you can either opt for scripting your plugin via functional programming (just plain standard code), or via object oriented coding (which involves creating classes, and initiating them).
The easier approach would definitely be the former approach, especially for newbies. Using this option, you can basically start typing whatever you would like your plugin to accomplish, and then once the plugin is activated, the code will run.
It is very common though to rely on wordpress hooks and filters, to properly time the moment at which the plugin's code will run and where its affects will happen.
Looking at the code sample shared above, you can notice the use of one sample hook
add_action( 'admin_menu', 'gk_wpr_prod_admin_menu' );
which basically handles making the plugin accessible via adding a relevant tab to wordpress' left menu, for the plugin to be available via the backend for logged in users.
Location of your plugin
Once ready, the plugin is required to be placed within your wordpress installation's plugins folder, otherwise wordpress will not be able to recognize it as an available plugin. If you look into the prior screenshot for with file structure of the plugin, you will notice the plugin is place within the
wp-content\plugins\ folder
Activating your plugin
Activating your plugin is just a piece of cake. You would just need to:
- login to your wordpress installation (http://wordpresslocalurl/wp-admin/)
- chose from the left tab your plugins --> installed plugins.
- scroll to your relevant plugin
- click on the Activate button
- If all your code works well, your plugin would become properly activated, as shown below

That's it! no further steps needed to create a plugin.
Hope you found this as useful and helpful as intended.
Photo Credits: All images used in this article are either created by me, or available under CC license (labeled as reusable under google image search)
Founder of Arab Steem
Arab Steem is a community project to expand Steemit to the Arab world, by supporting the existing Arab steemians and promoting others to join.
You can connect with us on @arabsteem or via discord channel https://discord.gg/g98z2Ya
Your support is well appreciated!
Proud Member Of
- steemSTEM: SteemSTEM is a project that aims to increase both the quality as well as visibility of Science, Technology, Engineering and Mathematics (and Health). You can check out some great scientific articles via visiting the project tag #steemSTEM , project page @steemstem, or connecting with us on chat https://steemit.chat/channel/steemSTEM
- MAP(Minnows Accelerator Project): MAP is a growing community helping talented minnows accelerate their growth on Steemit.
To join, check out the link at the home page of @accelerator account - Steemitbloggers: #Steemitbloggers is a community supporting bloggers with authentic and awesome content!
To join check out the discord channel https://discordapp.com/invite/gRypnga
Thanks again!
Posted on Utopian.io - Rewarding Open Source Contributors
موضوع ممتازشكرا صديقي
Excellent topic thanks bro
شكرا صديقي ! :)
Ahah, j'ai un wordpress sur lequel je n'avais aucune audience. Steemit donne largement plus de visibilité pour mes "talents".
haha oui je te comprends. Steemit et utopian ont fait une grande difference au monde de blogging maintenant. Mais quand meme wordpress c'est super pour d'autres sites/business ! :)
Welldone @mcfarhat. Even though I'm not getting involved with any other websites apart from my Steemit blog, I still found your article rich in content and beneficial. I hope utopian give you a major upv. Cheers!
#SteemitBloggers
#Hug-Challenge!
Thank you buddy ! :)
great post brotha :) going to resteem so I can come back to this when I need to .
Thank you !
Slightly beyond me at this time. I have just started to get to grips with Wordpress at the moment. Revolution Slider is my current focus area for my own personal development. Being visual is a struggle at times for me, but it is coming slowly!
Glad to hear you're working on wordpress. You will get there ! :)
Thank you for posting. Helpful
Thank you
hopefully accepted by uptopian
thank you Imran
أحسنت النشر
شكرا صديقي
Wordpress is always great
indeed it is!
Good information I want to participate in the competitions held in Steam and not how I wish to meet me @mcfarhat
Thank you, you could chat to me on discord or on arabsteem discord channel
ok @mcfarhat