The best way to add custom functions to WordPress without braking it
Adding custom functions to your WordPress can be time consuming and sometimes unsafe. As a freelancer, I deal with all kinds of WordPress tweaks and tasks, and my priority is to get them done as fast as I can without breaking anything.
Using custom functions to solve various client requests speeds up my work enormously, but can at times be unsafe in the terms of braking the clients website completely. When talking about speed that simply means that i have developed a system of doing everything through the WordPress admin panel.
White screen and broken website after editing functions.php
This happens for various reasons, but the most common one occurs if the existing website plugin interferes with one of the functions or if I make a typo in the code or leave an unwanted white space somewhere.
The standard practice is to write your custom function, then usually insert it into theme functions file – functions.php. This works perfectly if you don’t make any of the mistakes mentioned above. But what if you do? Then the whole website goes blank white page and we really don’t want that to happen… Like.. EVER!
To be honest, for us developers is not a big thing really as the solution to it is simply logging into FTP or Cpanel and erasing the last made changes to the functions.php file. But if you have your client online and browsing his website then it can cause some panic 🙂
Adding custom functions the easy way – My Custom Functions WordPress plugin
Russian guy called Arthur Gareginyan has come up with a great plugin that I use as a standard plugin on all of my websites.
It simply does the following..
1. It lets you insert your custom functions using the admin panel without ever touching your functions.php file.
2. It pre- runs the code and informs you if there is an error in it… “FATAL ERROR” as one of my clients once corrected me 🙂
As a result your website will NEVER GO BLANK again due to your typo or a bad code.
It’s completely free and awesome. So go ahead install it, check it out and make sure to rate it 5 stars on The WordPress Plugin Repository
My Custom Functions WordPress plugin by Arthur Gareginyan
- Responsive & Mobile optimized settings page
- Checks the entered code for fatal errors (simple checks)
- Trigger for temporary disable the custom functions
- Easy disable option for WSOD
- Syntax highlighting (by CodeMirror)
- Line numbering
- Active line highlighting
- Editor allow for tab indentation
- Ready for translation (POT file included)
It’s really useful in case of any theme update, because your custom function wordpress PHP code would never be overwritten. Your custom function PHP code will keep on working, no matter how many times you upgrade or switch your theme.
Using my Custom Functions WordPress plugin
Here is how to add your custom functions without braking anything.
- Install the plugin from WordPress repository or through your admin panel by searching for ” my custom functions”
2. Go to > appearance > my custom functions
3. Enter your custom functions and hit “save changes” voila- there it is 🙂
4. What happens if i enter a wrong code?
Now this is what the plugin is all about, it wont be applied and you will get a warning about it without getting the white screen of death or having to access the functions.php to revert it.
The best way to add custom functions to WordPress without braking it – solved!
If you like this post share it around, thanks 😉