Friends, in this article, we will learn how to create custom plugin using PHP for WordPress websites and how we will activate and deactivate plugin. So let’s know how to make custom plugin.
Table of Contents
File Manager or Local Host HTDOCS
First of all you have to go to your WordPress folder. And then you have to open the wp content folder, then you will find the folder of the plugin in it, it also has to open it. Then inside it you have to take a new folder. And his name is to keep the swing that meets the plugging. Like in our case there is a data show folder. After that, you have to open a code editor. Then you have to select the new file. And you have to keep the name of that file the same. Which is the name of your folder. You’ll save after you keep the name.
PHP Code
Now we will first write the syntax of php, then after that we will take a comment, we will give the details of the plugin inside it so that these details will be shown in WordPress after being installed. First we will take the name Plugin then we will take the description then we will take the author name then we will take the plugin URI link so that it appears as a link in WordPress. After that we will take the author URI and give a link in it as well. Then we will name the version so that as soon as our plugin is installed, we will see its version.
Plugin activates or deactivates
Now we will learn how to activate or deactivate the plugin. First of all, you have to take the function for activation and in it you have to give two parameters, the first file and the second one will create a function so that we can make a call while activating. After that we will not create a function for deactivate and will give two parameters in that function also, first file and second function will be created. Then we’ll also call the deactivated function.
Add plugins to Menu
Now you have to take the function of an add menu and it will take two parameters, the first admin menu secondly you have to create a function, then you have to create a function in it, then you have to give five parameters in it. First you will get the name of the plugin and the name of the plugin in the second parameter and the third will come to position 8, after which you have to take the file. Then you have to create a function. Now we will call this function and in this we will echo welcome to plugin message.
I hope you liked this article of ours, if you have any problem in making plugins, then watch the video below because in the video we have explained step by step.