[wp-hackers] Selected Improvements to the Core

DD32 wordpress at dd32.id.au
Sun Jan 13 01:38:32 GMT 2008


On Sun, 13 Jan 2008 12:16:43 +1100, Jacob Santos <wordpress at santosj.name> wrote:
> *Pre-Activation Hook*
>
> There is no dependency API in WordPress, so there has been times when I
> didn't want my plugin to be enabled until another plugin was enabled. It
> allows me to distribute one plugin with most of the functionality that
> is needed, much like the WordPress Plugin Framework and plugins that
> require that plugin to be enabled first.
>
> There needs to be a way to say to the user, "Oops, sorry, I'm dependent
> on several factors and you don't met those." Which is currently lacking
> in the patch. It might be confusing for users to click activate and have
> WordPress say the plugin was activated, but not have the plugin be
> activated. However, I'm unsure how to do this at this point.
>
> I still would rather have something that allows me prevent my plugin's
> activation until my plugin's requirements are met.
>
> [1] http://trac.wordpress.org/ticket/3141
> [2] http://trac.wordpress.org/ticket/4048
>
> Any feedback is appreciated.
>


As of 2.4 with the deactivate_plugins() function, Its possible, Allthough not as pretty: (Possible with previous versions if you update the active plugins array yourself)

/*
Plugin Name: I need more recent PHP!
Plugin URI: http://dd32.id.au/
Description: Tests non-activation.
Author: Dion Hulse
Version: 1.0

Requires WordPress 2.4 or later.

*/

register_activation_hook(__FILE__, 'nwp_act');

function nwp_act(){
	global $wp_version;
	if( version_compare( $wp_version, '2.5', '>=') )
		return; //Its WP 2.5 or later
	deactivate_plugins(__FILE__);
	wp_die('<h1>NewerWordPress Plugin</h1>
			<p>This plugin requires WordPress 2.5, which you do not have.</p>
			<p>Click  <a href="plugins.php">here</a> Back to plugins list</p>');
}


More information about the wp-hackers mailing list