[wp-hackers] Plugin Management issue...
Owen Winkler
ringmaster at midnightcircus.com
Tue Jun 29 16:27:36 UTC 2004
You should really do this with filter priorities. But here goes:
function sort_plugin_string($current)
{
global $dependson;
$ary_current = explode("\n", trim($current));
foreach($ary_current as $plugin_file)
{
if(trim($plugin_file) != '')
{
$plugin_data = implode('', file(ABSPATH .
'/wp-content/plugins/' . $plugin_file));
preg_match("|Dependencies:(.*)|i", $plugin_data,
$dependstr);
$dependson[$plugin_file] = explode(';',
trim($dependstr[1]));
}
}
usort($ary_current, 'sort_plugins');
return trim(implode("\n", $ary_current));
}
function sort_plugins($a, $b)
{
global $dependson;
switch(true)
{
case in_array($b, $dependson[$a]): return 1;
case in_array($a, $dependson[$b]): return -1;
default: return 0;
}
}
...
$current = sort_plugin_string($current); // Added this line
update_option('active_plugins', $current);
...
More information about the hackers
mailing list