Quote:
Originally Posted by Supz
fris, is there a way to have plugins activate on theme activations in multisite. If you pick a certain theme, it auto activates certain plugins that the theme needs?
|
hopefully this will help you.
two ways, install automatically if it inst installed, or show a notice in the admin with an option to install the plugin.
Code:
<?php
// add to your theme functions.php
// two ways to do this, automatically, or give the user an option to install the required plugin
// 1. install plugin automatically
function run_activate_plugin( $plugin ) {
$current = get_option( 'active_plugins' );
$plugin = plugin_basename( trim( $plugin ) );
if ( !in_array( $plugin, $current ) ) {
$current[] = $plugin;
sort( $current );
do_action( 'activate_plugin', trim( $plugin ) );
update_option( 'active_plugins', $current );
do_action( 'activate_' . trim( $plugin ) );
do_action( 'activated_plugin', trim( $plugin) );
}
return null;
}
run_activate_plugin( 'wp-postratings/wp-postratings.php' );
// 2. give user option to install
ratings_check();
function ratings_check()
{
if ( !function_exists('the_ratings') )
{
add_thickbox();
add_action('admin_notices', 'ratings_check_notice');
}
}
function ratings_check_notice()
{
?>
<div class='updated fade'>
<p>The Post Ratings plugin is required for this theme to function properly. <a href="<?php echo admin_url('plugin-install.php?tab=plugin-information&plugin=wp-postratings&TB_iframe=true&width=640&height=517'); ?>" class="thickbox onclick">Install now</a>.</p>
</div>
<?php
}
?>