Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to call plugins on a theme page. Specifically I am after the 'User Avatar' theme but their will be other later.

How do I call a plugin on a theme?

Presumable something linke <?php ...plugin name... ;?> but that isn't it. Any ideas.

Marvellous

share|improve this question
    
What do you mean by "call plugins on a theme page?" That could mean several things. Can you be more explicit in what you want to happen? –  MikeSchinkel Feb 16 '11 at 15:28
add comment

3 Answers

up vote 2 down vote accepted

You must check the documentation of the plugin.

  1. Is it supporting shortcodes? Do sometingh like <? do_shortcode('[plugin_shortcode]'); ?>
  2. Has function to call in the theme? Do something like <? my_plugin_function(); ?>
share|improve this answer
add comment

you could do it through shortcode like keatch said or you could create a function in your plugin that would be called from within your theme.

look here, section 7. Creating the user function

you are supposed to put the output of your plugin into that function (keep in mind that you should use return to print out the output, and not echo, since with echo you don't have enough control over where your output will end up).

share|improve this answer
    
also make sure to use if cases as shown in kaisers answer, it's allways good to have this checks.. –  pootzko Feb 16 '11 at 15:09
add comment

Other options would be

function_exists( 'first_loaded_plugin_fn' ) AND do_something();
class_exists( 'initial_plugin_class' ) AND do_something();

The best chance is the callback function from register_activation_hook( $file, $function ); if the plugin does not only offer a template tag or similar basic functionality.

or:

Some option from the plugin that get's added on init/activation:

echo  ! empty( get_option( 'plugin_option_name' ) ) ? 'activated' : 'not active';

or:

Check if the plugins_loaded hook has some action (<-- link)

echo has_action( 'plugins_loaded', 'fn_to_check') !== false ? 'activated' : 'not active';

You'll hacve to take a closer look at the returned result. The result may contain the priority too.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.