Is there a way to check and see if a particular plugin has been activated for a blog? Specifically I need to check if the gallery2 plugin is enabled and if so add a line to the header of every theme we support. maybe something like this sudo code would work:
if has_plugin(plugin_name) {
<?php g2_imageframes(); ?>
}
Without this if I enable the css for image frames in the themes users without gallery2 enabled have strange results while those with it enabled are fine.
If this is not an option is there a way to force all new blugs to have the plugin enabled and preconfigured? This is probably going to be necessary for other plugins as well.
Can't the plugin use the wp_head hook to add it in when needed?
You got me on that one Jaseone. I'm not familiar with the wp_head hook. I guess I need to do some research. How are you suggesting implementing it?
http://wordpress.org/support/topic/13068
Basically every theme should have a call to wp_head() in it's HTML header so you can hook into it with a plugin.
I'm looking at this but I don't think it will do what I need. Specifically I only want to include the g2 frame headers IF the blog-admin has activated the wpg2 plugin. What I *really* want to do is have the plugin activated and configured when the blog is initially created. This seems like the easiest way to acomplish it although I was still have to add the <?php g2_imageframes(); ?>
line to every theme before </head>
Foud it. This is what I was looking for. Now let's see if I get it to do what I want :-)
//Test if Plugin is active.
$current_plugins = get_option('active_plugins');
if (!in_array('wp-gallery2/g2embed.php', $current_plugins)) {
echo "<h2>Fatal Gallery Plug-in error</h2> Here's the error from Gallery2 Plug-in: Plug-in has not been Activated";
exit;
}
That seems illogical to me, wouldn't it make more sense somewhere within the WPG2 plugin to do:
add_action('wp_head', 'g2_imageframes');
Then if the plugin is activated then the header will get added or am I missing something?
I'm sure its me thats missing something but I do have it working for now. This is what I'm using in the header.php
file of every theme. I'm placing it immediately before the </head>
tag.
<?php
//Test if G2 Plugin is active.
$current_plugins = get_option('active_plugins');
if (in_array('wp-gallery2/g2embed.php', $current_plugins)) {
g2_imageframes();
}
?>
No doubt it would make more sense to find a way to do it in wp_head
or some other single place but until I learn this code a lot better I just have to hack away.
Thanks for the advice, I'm still looking into to it and trying to get the flow of the code.