user892134
user892134

Reputation: 3214

WordPress, if function exists and plugin name?

I'm working on a WordPress theme and have installed some plugins and after reading about including if(function_exists()) to prevent the site from breaking, how do i determine the name of the functions?

For example i have the plugins; Contact Form 7, Menu Image, Gallery . How do i find out the function name?;

if ( function_exists('$functionname')) {


}

Upvotes: 0

Views: 887

Answers (2)

Obmerk Kronen
Obmerk Kronen

Reputation: 15979

you can either look at the specific plugin code, choose a prominent function and use in a code like in your example :

if ( function_exists('functionname')) {


}

or alternatively, using the is_plugin_active() function like demonstrated in the codex :

<?php
   If (is_plugin_active('plugin-directory/plugin-file.php')) {
      //plugin is activated
   }
?>

Note that the use differs a bit when using in front end , because you need to include a specific file from the backend:

<?php include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); ?>
<?php is_plugin_active('plugin-directory/plugin-file.php' ?>

Please read more in the above codex link.

Upvotes: 1

fisicx
fisicx

Reputation: 69

You really don't need to do this. The plugins all have their own means of error checking so it's not something to worry about.

If you really want to mess with the plugin code then be aware that it will be overwritten then next time the plugin updates.

Upvotes: 0

Related Questions