plugin dependency #88

pdewouters opened this Issue Jan 21, 2012 · 7 comments


None yet

2 participants



thanks for the great class!
I want to recommend WP Rotator and Flexslider for WP Rotator. The problem is that it tries to activate the Flexslider plugin before WP Rotator but the former checks first if WP Rotator is installed, otherwise it doesn't activate. So the "please activate" message never goes away, unless you go to plugins and activate them in the correct order manually.


Thanks for pointing this out. This would be a good feature to add. Although this isn't perfect, for the time being you could do a conditional plugin addition, like so:

`add_action( 'tgmpa_register', 'my_theme_register_required_plugins' );

  • Register the required plugins for this theme. *
  • In this example, we register two plugins - one included with the TGMPA library
  • and one from the .org repo. *
  • The variable passed to tgmpa_register_plugins() should be an array of plugin
  • arrays. *
  • This function is hooked into tgmpa_init, which is fired within the
  • TGM_Plugin_Activation class constructor.
    function my_theme_register_required_plugins() {

    $plugin_active = is_plugin_active( 'tgm-example-plugin/tgm-example-plugin.php' ) ? array ( 'name' => 'Edit Howdy', 'slug' => 'edithowdy', 'required' => false ) : null;


    • Array of plugin arrays. Required keys are name and slug.
    • If the source is NOT from the .org repo, then source is also required. / $plugins = array( $plugin_active, /* This is an example of how to include a plugin pre-packaged with a theme */ array( 'name' => 'TGM Example Plugin', // The plugin name 'slug' => 'tgm-example-plugin', // The plugin slug (typically the folder name) 'source' => get_stylesheet_directory() . '/lib/tgm-plugin-activation/plugins/', // The plugin source 'required' => true // If false, the plugin is only 'recommended' instead of required ) );

    /** Change this to your theme text domain, used for internationalising strings */
    $theme_text_domain = 'inline';


    • Array of configuration settings. Uncomment and amend each line as needed.
    • If you want the default strings to be available under your own theme domain,
    • uncomment the strings and domain.
    • Some of the strings are added into a sprintf, so see the comments at the
    • end of each line for what each argument will be. / $config = array( /'domain' => $theme_text_domain, // Text domain - likely want to be the same as your theme. / /'default_path' => '', // Default absolute path to pre-packaged plugins / /'menu' => 'inline-required-plugins', // Menu slug / /'notices' => true, // Show admin notices or not / 'strings' => array( /'page_title' => __( 'inLine Required Plugins', $theme_text_domain ), // / /'menu_title' => __( 'Install Plugins', $theme_text_domain ), // / /'instructions_install' => __( 'The %1$s plugin is required for this theme. Click on the big blue button below to install and activate %1$s.', $theme_text_domain ), // %1$s = plugin name / /'instructions_activate' => __( 'The %1$s is installed but currently inactive. Please go to the plugin administration page page to activate it.', $theme_text_domain ), // %1$s = plugin name, %2$s = plugins page URL / /'button' => __( 'Install %s Now', $theme_text_domain ), // %1$s = plugin name / /'installing' => __( 'Installing Plugin: %s', $theme_text_domain ), // %1$s = plugin name / /'oops' => __( 'Something went wrong with the plugin API.', $theme_text_domain ), // / /'notice_can_install' => __( 'This theme requires the %1$s plugin. Click here to begin the installation process. You may be asked for FTP credentials based on your server setup.', $theme_text_domain ), // %1$s = plugin name, %2$s = TGMPA page URL / /'notice_cannot_install' => __( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', $theme_text_domain ), // %1$s = plugin name / /'notice_can_activate' => __( 'This theme requires the %1$s plugin. That plugin is currently inactive, so please go to the plugin administration page to activate it.', $theme_text_domain ), // %1$s = plugin name, %2$s = plugins page URL / /'notice_cannot_activate' => __( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', $theme_text_domain ), // %1$s = plugin name / /'return' => __( 'Return to Required Plugins Installer', $theme_text_domain ), // / /'plugin_activated' => __( 'Plugin activated successfully.', $theme_text_domain ) // */ ) );

    tgmpa( $plugins, $config );


Notice the $plugin_active variable. You could identify the plugin file path that way to check if it was active or not. If the plugin is active, then it adds the dependent plugin to this list (and thus users will receive a new notice once the parent plugin is installed). If that isn't the case, it does nothing.

Obviously this isn't perfect, but since you are already going to know the plugins and files, you could use this approach.

This is definitely something to work on for a future version, though! Thanks for pointing it out!


weird, I got an error "function is_active_plugin" does not exist. maybe it's not available in that scope?


It should be is_plugin_active instead of is_active_plugin :-)


sorry that was a typo in the comment. I pasted the code that you posted:
Fatal error: Call to undefined function is_plugin_active() in C:\xampp\htdocs\websavvy\wp-content\themes\wsm-carla-anna\functions.php on line 327


Hmm, that does happen whenever you deactivate the plugin needed for the dependency. Ok, scratch that (I didn't test it enough), I'll just have to put this on the docket for a future version. :-)


You may also want to look at this plugin by Scribu:

You could possibly use this in conjunction with the class to get rolling. :-)


thanks I'll take a look

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment