[wp-trac] [WordPress Trac] #22316: Plugin Dependencies (Yet Another Plugin Dependencies Ticket)
WordPress Trac
noreply at wordpress.org
Mon May 13 11:17:53 UTC 2013
#22316: Plugin Dependencies (Yet Another Plugin Dependencies Ticket)
--------------------------+------------------------------
Reporter: Viper007Bond | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version: 3.4.2
Severity: normal | Resolution:
Keywords: dev-feedback |
--------------------------+------------------------------
Changes (by bobbingwide):
* cc: herb@… (added)
Comment:
I've been delivering plugins with plugin dependency logic since April
2012. I developed the "full" solution in the oik base plugin and provided
lazy code in the dependent plugins.
Since there's no core API, each plugin that has a dependency needs to
deliver the same basic code. I tried to develop a solution that worked
during activation; but that was a nightmare. I plumped for responding to
"admin_notices".
{{{
add_action( "admin_notices", "oiku_activation" );
/**
* Implement the "admin_notices" action for oik-user
*/
function oiku_activation() {
static $plugin_basename = null;
if ( !$plugin_basename ) {
$plugin_basename = plugin_basename(__FILE__);
add_action( "after_plugin_row_" . $plugin_basename, __FUNCTION__ );
require_once( "admin/oik-activation.php" );
}
$depends = "oik:2.0-alpha.0329,oik-fields:1.18.0325";
oik_plugin_lazy_activation( __FILE__, $depends,
"oik_plugin_plugin_inactive" );
}
}}}
See http://plugins.svn.wordpress.org/oik-nivo-slider/trunk/admin/oik-
activation.php
This solution works for dependent plugins which are: missing, inactive,
not at the required minimum version. With the right API built into core
the above code could reduce to a one line filter.
Note: plugins which are dependent on others wait for the appropriate
"plugin loaded" signal before attempting to use those plugins APIs.
The challenge I now face is where the missing or out-of-date dependent
plugin's repository isn't wordpress.org. e.g. oik-fields. I have a
similar challenge when it comes to determining which jQuery libraries are
available!
--
Ticket URL: <http://core.trac.wordpress.org/ticket/22316#comment:65>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list