One of the greatest strengths of WordPress is the amazing user community, which has created tons of plugins to extend the functionality of an already great blogging tool.
Plugins that change the appearance of your blog need to be activated in two ways:
1. By clicking “activate” in the admin panel
2. By adding the necessary code to your template
Unfortunately, if you deactivate a plugin without removing its code from your template, you’ll get a PHP error, which can break the page’s layout or worse.
To prevent a deactivated plugin from crashing your site, or even creating a visual blight, simply wrap all the plugin-related code in the if(function_exists()) function, like this:
<?php if(function_exists(get_recent_posts)) { _e('<h2>Recent Posts</h2>');} ?>
<?php if(function_exists(get_recent_posts)) { get_recent_posts(10); } ?>
The first line creates a sidebar heading for “Recent Posts,” which you obviously wouldn’t want to display if you weren’t going to list the recent posts. The second line calls the get_recent_posts plugin, and saves your site from deadly page errors should you happen to deactivate the plugin.
If you wrap all of your plugin calls in this manner, you won’t have to edit your template when you activate or deactivate a plugin.
