Oct 10 2007
Installing a WordPress plugin can be somewhat stressful for those who are unfamiliar with web design or programming. There are many plugins which require you to go into the PHP source code of a WordPress module and then add the function to call the plugin. Normally, the instructions just tell you to enter the function name. This works well until you deactivate or uninstall the plugin. You need to remove the PHP code you added to your blog or you’ll get an error message, or worse, the page may fail to render!
One way to get around this is to use function_exists () with the plugin. This is a PHP function which will return a true value if the function that its trying to run exists. This may seem confusing, but the following code will make it easier to understand.
if (function_exists ('wp_plugin'))
This checks if the function to call the plugin (which is named wp_plugin) is active (or installed). If it is, then it will run the function wp_plugin (). If the function could not be found, then no command will be run and the next statement after wp_plugin () will be executed.
You need to ensure that you enter ‘wp_plugin’ and not ‘wp_plugin ()’ in function_exists for it to work properly.
If you wrap the plugins that you install this way, you can easily turn on and off the plugin and still have a fully functional blog.