WordPress Plugins have become a game changer, they allow you to do thing which previously you may have thought impossible. A key part of the success of WordPress is precisely its ability to accept plugins and widgets, and, of course, the thousands of programmers who develop the most diverse plugins that do everything a little.
Anyone who works with WordPress sometimes needs to create certain specific features for just one website. From just changing the order of the administration menu to more specific functionality in the front end, such as disabling the administration bar for certain types of users.
Creating a WordPress plugins
Creating a plugin is not difficult, but requires some knowledge of PHP and WordPress. If you have already edited some functions.php of a theme by putting code in it, then you will certainly be able to create a specific plugin as well. You can look at this type of plugin as a portable and specific functions.php. It’s sure to take longer to create plugins for each feature, however, you’ll be sure to:
- If your theme refreshes or you change your theme, the features will not break.
- If you want to disable a specific feature, you can just disable the plugin in the admin panel, instead of logging in to your FTP, navigating to your theme, and commenting on all the code regarding the feature that you plan to disable.
- If you want to update the code to a new version, you will not have to walk any further looking.
As you can see, using specific plugins turns out to be quite advantageous. Almost all functionality additions should go for a specific plugin. However, if you need to decide whether or not to create a plugin for a particular feature instead of putting it in functions.php, think about this functionality in the long run: decide whether it will be constant on your site, whether it will be extended if you change the theme, for example, if in 5 years this functionality will continue to be useful for your site or blog, even if your layout changes completely. The key to the solution here is to realize whether the functionality is site specific or layout specific, and therefore the theme.
Creating a plugin is not a difficult task, it’s quite simple. Let’s see a very simple example, creating a plugin that will only change the logo of the WordPress login form.
Create the plugin file
All plugins are in the wp-content / plugins / directory of WordPress and this is where we will create a new subdirectory called custom-branding. This subdirectory will house all files from our plugin that will customize the WordPress login form.
Now let’s create a file called custom-branding.php in this subdirectory and we’ll edit it in order to insert the following content:
Plugin Name: Custom Branding
Author: Mauricio Silva
/ Code snippets will come here
This will be the initial content of your plugin so that WordPress can recognize it as a plugin. At this point, if you go to the admin panel, in the Plugins menu, you will find this plugin listed. If you enable it, obviously it will not do anything, as it does not have any associated PHP code at the moment, however you can edit it later, whenever you want, without having to disable it.
See how easy it is to create a plugin? Now all the rest is just a matter of putting the snippets of code inside this file.