[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 
>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.

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":

// 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.

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; 
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.


Express yourself instantly with MSN Messenger! Download today - it's FREE! 

More information about the wp-hackers mailing list