View Single Post
Old 12-18-2010, 09:41 AM  
Supz
Arthur Flegenheimer
 
Supz's Avatar
 
Industry Role:
Join Date: Jul 2006
Location: New York City
Posts: 11,057
Quote:
Originally Posted by fris View Post
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
}
?>
Will give it a shot.

Thank you very much!
Supz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote