Several plugins provide users with template tags like functions to include plugin output into themes, the most common way of including plugin code into themes looks like this:
<h2>Section Header</h2>
<?php plugin_template_tag_function(); ?>
Though the above code is absolutely right, PHP errors will occur if you disable the plugin and do not remove the template tag from the theme. There is a much better way of including template tags in your themes, which ensures that PHP errors do not occur when you disable plugins and do not remove them from your themes:
<?php if ( function_exists(’plugin_template_tag_function’) ) : ?>
<h2>Section Header</h2>
<?php plugin_template_tag_function(); ?>
<?php endif; ?>
The if condition in the above code ensures that the function you want to use is registered, before the code is executed. This extra check will ensure that your theme will load without PHP errors, even if the plugin has been disabled.
If you are new to conditional statements, you can read one of our earlier post about if, then and else conditions.