[wp-hackers] Plugin deactivation

Andy Skelton skeltoac at hotmail.com
Mon Jul 4 18:03:10 GMT 2005


>From: Robert Deaton <false.hopes at gmail.com>
>While on the topic of plugins and dependancy plugins, is there any chance
>that we can add a priority hook for plugins, so that plugins that may or
>will have plugins that depend upon it can ensure that they are loaded 
>first,
>or at the very least that the dependancies can specify to be loaded later
>on, this way no fancy hooking around init or the like is required like I've
>been hacking to do in 1.5.

Robert,
I ran into this with Count My Clicks and I solved it by using custom hooks. 
There's no need to alter the way the core handles plugins. Is this what you 
meant by "fancy hooking around init":

count-my-clicks.php:
// Do all my plugin init stuff first, then:
global $cmc_loaded;
$cmc_loaded=true; // Leave a note for dependent plugins not yet loaded.
do_action('cmc_loaded'); // Signal dependent plugins already loaded to sart.

cmc-dependent-plugin.php:
function init_cmc_dependent_plugin() { // Wrap the guts in a function.
// Put all the cmc-dependent stuff here
}
if ( isset($cmc_loaded) ) init_cmc_dependent_plugin(); // Call the function; 
or
else add_action('cmc_loaded','init_cmc_dependent_plugin'); // let it be 
called later.

But what if your plugin depends on a plugin that wasn't written this way? We 
could have an official Plugin Template with these init lines added, or you 
could distribute your plugin with the needed plugin included and modified 
for your needs.

Cheers,
Andy

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today - it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/



More information about the wp-hackers mailing list