Calling a plugin in theme development

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?

Read More

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

Marvellous

Related posts

Leave a Reply

3 comments

  1. 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(); ?>
  2. 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.

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