Generally bloggers tend to write custom php functions in theme function.php file. I was also used to practicing it until I lost my custom functions (saved in theme function file) when I forgot copy all functions before updating my blog theme. However, I recovered overwritten function.php file from the most recent backup copy of my blog. (I always take daily automatic backup of my blog files and database – read more). But that incident took my time that I could have spent on other things. If I didn’t have backup, I would have done lot of work to recover several custom functions in theme function.php file. I realized the need to save all my custom functions in a separate plugin.
After that I decided to keep my custom WordPress PHP Code in any other place that was safe and updating WordPress core, themes or plugins couldn’t affect them. I had two choices;
Either keep all functions in database via a plugin
or Save theme in a plain plugin file that can be created easily
My Custom Functions by Arthur Gareginyan
It is an amazing simple plugin that lets you add all your custom functions in database. This plugin have its own interface to add custom functions. You can add unlimited custom functions with the help of this plugin. You might have been thinking that what will happen if you add wrong php array that may return a syntax error? We all know that we can’t access WordPress admin panel in most of php parse syntax error. If a plugin saves php code in database, it is pretty annoying to figure out that code in database using phpmyadmin. But it is not the case with this plugin. This plugin can’t submit a php code until it is valid. If you add a code piece that may trigger a syntax error, it will gently deny to submit the code and tells you the reason of denying.
Apart from that you can enable or disable custom functions any time with the help of an ON/OFF switch. This plugin uses php editor powered by CodeMirror that highlights syntax and also give number to lines.
Features of My Custom Functions plugin at a glance
- Syntax error protection
- saves PHP functions in database
- uses PHP editor and syntax highlighter by CodeMirror
Download link is locked
Create a plugin
You can create a simple plugin to save all your custom php code. It is very easy to this. Simple open your pc notepad and put the following code in it;
Plugin code /Download link is locked
Save this file with the name and extension like this;
Upload this file to your plugin directory
You can add your custom php functions between comment lines. You will have full control on this php file. All you need to do is activating this plugin. You can add custom code to this plugin using WordPress plugin editor, via FTP or hosting file manager.
You are free to change plugin name, URL, Description, Author, Author URL and version.