Creating a Safety Net for WordPress Plugin Integrations

Posted by Johan Cyprich on 10 Oct 2007 | Tagged as: Programming

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'))
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.



Tweet This Tweet This Post!

Related posts:
    WordPress 2.3.3
    Testing WordPress with WP Security Scan
    WordPress 3.0.2 Security Update
    Important WordPress Security Update

Share this post:

del.icio.us:Creating a Safety Net for WordPress Plugin Integrations digg:Creating a Safety Net for WordPress Plugin Integrations spurl:Creating a Safety Net for WordPress Plugin Integrations wists:Creating a Safety Net for WordPress Plugin Integrations simpy:Creating a Safety Net for WordPress Plugin Integrations newsvine:Creating a Safety Net for WordPress Plugin Integrations blinklist:Creating a Safety Net for WordPress Plugin Integrations furl:Creating a Safety Net for WordPress Plugin Integrations reddit:Creating a Safety Net for WordPress Plugin Integrations fark:Creating a Safety Net for WordPress Plugin Integrations blogmarks:Creating a Safety Net for WordPress Plugin Integrations Y!:Creating a Safety Net for WordPress Plugin Integrations smarking:Creating a Safety Net for WordPress Plugin Integrations magnolia:Creating a Safety Net for WordPress Plugin Integrations segnalo:Creating a Safety Net for WordPress Plugin Integrations gifttagging:Creating a Safety Net for WordPress Plugin Integrations

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv badge