Skip to content

Instantly share code, notes, and snippets.

@svenl77
Last active December 3, 2016 11:20
Show Gist options
  • Save svenl77/c5c580d38e48a64c78b220f2a59244e0 to your computer and use it in GitHub Desktop.
Save svenl77/c5c580d38e48a64c78b220f2a59244e0 to your computer and use it in GitHub Desktop.
No function names needed to add TGM
<?php
//
// Check the plugin dependencies
//
add_action('init', function(){
// Only Check for requirements in the admin
if(!is_admin()){
return;
}
// Require TGM
require ( dirname(__FILE__) . '/includes/resources/tgm/class-tgm-plugin-activation.php' );
// Hook required plugins function to the tgmpa_register action
add_action( 'tgmpa_register', function() {
// Create the required plugins array
$plugins['advanced-custom-fields'] = array(
'name' => 'Advanced Custom Fields',
'slug' => 'advanced-custom-fields',
'required' => true,
);
// todo: Check if pro is instaled and if true add the pro version as attribute so that TGM will activate the pro Version
if ( ! defined( 'BUDDYFORMS_PRO_VERSION' ) ) {
$plugins['buddyforms'] = array(
'name' => 'BuddyForms',
'slug' => 'buddyforms',
'required' => true,
);
}
$config = array(
'id' => 'buddyforms-tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'parent_slug' => 'plugins.php', // Parent menu slug.
'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
'has_notices' => true, // Show admin notices or not.
'dismissable' => false, // If false, a user cannot dismiss the nag message.
'is_automatic' => true, // Automatically activate plugins after installation or not.
);
// Call the tgmpa function to register the required plugins
tgmpa( $plugins, $config );
} );
}, 1, 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment