1

Hi iam developing a plugin to activated a couple of plugins. i.e: the plugin jetpack has six plugins and all gets activated on a single install,like wise i need to activate a group of plugins from acivating this plugin.

for example consider a plugin called 'site plugin' which has sub folders of other plugins. when i activate 'site plugin' it should show options to activate other plugins in it.

I hope some one could help me.

migrated from stackoverflow.com Jun 30 '11 at 14:26

This question came from our site for professional and enthusiast programmers.

  • Are these child plugins developed by third parties or are they all your own code? – scribu Jun 30 '11 at 15:23
2

You're main pluggin can use register_activation_hook and use the function you register thru the hook to activate you're necesary pluggins.

Smth along these lines :

    // get already activated plugins
    $plugins = get_option('active_plugins');
    $puginsToActiv = array('Plugin1', 'Plugin2', 'Plugin3');
    if($plugins)
    {
        $changed = false;
        foreach ($puginsTostActiv as $plugin)
        {
            if (!in_array($plugin, $plugins))
            {
                $changed = true;
                array_push($plugins,$plugin);
            }
        }

        if ( $changed )
            update_option('active_plugins',$plugins);
    }
// code not tested
  • Or you could use activate_plugin() found in wp-admin/includes/plugin.php – scribu Jun 30 '11 at 15:24
  • @scribu : yes you could use that too – poelinca Jul 1 '11 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.