Best Practice: Check if Function Exists When Adding in WordPress Theme


Best Practice: Check if Function Exists When Adding in WordPress Theme
Luna Weems

The best part about WordPress is plugins. Theme designers also have a tendency of using WordPress plugins for adding cool features. When working on a custom WordPress theme project for a client, one thing you want to make sure is follow the best practice. Yesterday, we got an inquiry from one of our users whose site was broken. He had a custom design done by someone. The theme worked great until he changed hosts. His single posts would not load after post content. The comments area, sidebar, footer, nothing will load. It will simply output the error. We went in and fixed the issue for them. The issue was that his theme designer did not follow the best practice. He had a very popular plugin “User Photo” which allows you to add user’s photo at the bottom of the post, except he was just adding the function directly. Now this would work unless ofcourse the plugin gets disabled for some reason. When this client switched hosts, apparently the GD Library was not installed in the new server. This caused the plugin to deactivate. You also could not re-activate the plugin because it relies on the GD Library. This caused the site to be broken for all users. This obviously gets that theme designer a bad reputation because when the client asked what was the issue, we explained to them. If you are a theme designer adding plugin outputs, you should always follow the best practice. Here are some examples of how we do things with our clients:

Ahmed Mohsin
Sophie Doyle

The best part about WordPress is plugins. Theme designers also have a tendency of using WordPress plugins for adding cool features. When working on a custom WordPress theme project for a client, one thing you want to make sure is follow the best practice. Yesterday, we got an inquiry from one of our users whose site was broken. He had a custom design done by someone. The theme worked great until he changed hosts. His single posts would not load after post content. The comments area, sidebar, footer, nothing will load. It will simply output the error. We went in and fixed the issue for them. The issue was that his theme designer did not follow the best practice. He had a very popular plugin “User Photo” which allows you to add user’s photo at the bottom of the post, except he was just adding the function directly. Now this would work unless ofcourse the plugin gets disabled for some reason. When this client switched hosts, apparently the GD Library was not installed in the new server. This caused the plugin to deactivate. You also could not re-activate the plugin because it relies on the GD Library. This caused the site to be broken for all users. This obviously gets that theme designer a bad reputation because when the client asked what was the issue, we explained to them. If you are a theme designer adding plugin outputs, you should always follow the best practice. Here are some examples of how we do things with our clients:

Be the first to comment

Leave a Reply

Your email address will not be published.


*