Here is a small guide to create WordPress Plugin to avoid adding snippets on theme’s or child theme’s functions.php. There are technical differences that can create – non functioning or malfunctioning of the snippet which can be made working with a bit more work but basically,
functions.php is frankly better to keep it as clean as possible. Why? It is better way to debug. It is a better way to separate non-theme framework specific and theme specific snippets. Basically as we almost always use Cache, adding something suddenly on theme’s or child theme’s
functions.php file, can make the complex caching system a bit confused. Otherwise, frankly we can move all the plugin functions to be called from theme’s or child theme’s
functions.php file. Plugins can make WordPress slow for bad coding or database related issues. This kind of small
Hello Dolly like plugin will not do any harm. WordPress load stuffs in this way : plugin files > child theme™s
functions.php > theme framework™s
functions.php . On nginx + PHP5-FPM + XCache, this sequence can impact the page loading speed. Actually it is better to fork the theme framework and use it as theme. As that is difficult work in many situation to many of the users, you can create WordPress Plugin to avoid these snippets on theme’s functions.php file.
How To Create WordPress Plugin As Theme’s functions.php Replacement
It is very easy to create a WordPress Plugin, just if you write your own lines in this way, it becomes a plugin :
* Plugin Name: Custom Function Plugin
* Plugin URI: https://thecustomizewindows.com
* Description: Custom plugin to add snippets.
* Author: Abhishek_Ghosh
* Author URI: https://dr.abhishekghosh.net
* Version: 1.0
// replace this line with snippet
if you write these on a plain text editor like Emacs or vi or nano or TextWrangler or gdeit for Windows if you use Microsoft Windows, save it as
custom_function_plugin.php, zip it and upload via WordPress Plugin installer, it will work fine. We have our Plugin as Gist on Github, you can test it.
MU-Plugins Directory on Single WordPress Site
It is funny that, if you create a directory under
wp-content directory with the name
mu-plugins and place plugin inside it, a new string will show beside
Must Use. Plugins placed on this directory will not need activation. WordPress loads them like theme’s or child theme’s
functions.php file. This is great if you are editing from SSH or FTP. If everything break down, simply you can rename
This article is basically for our readers who run their own IaaS instances. It will take huge time, but if you separate them, it will work better.
Follow the Author of this article :