Skip to content

Instantly share code, notes, and snippets.

@rilwis
Created June 6, 2016 02:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rilwis/467db4538525749567cd8b390d34deaa to your computer and use it in GitHub Desktop.
Save rilwis/467db4538525749567cd8b390d34deaa to your computer and use it in GitHub Desktop.
Include Meta Box extension in themes/plugins
<?php
require_once get_template_directory() . '/class-tgm-plugin-activation.php'; // Path to TGM Plugin Activation class.
add_action( 'tgmpa_register', 'your_prefix_register_required_plugins' );
function your_prefix_register_required_plugins() {
/*
* 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(
// This is an example of how to include a plugin bundled with a theme.
array(
'name' => 'Extension Name', // The plugin name.
'slug' => 'extension-slug', // The plugin slug (typically the folder name).
'source' => get_stylesheet_directory() . '/lib/plugins/extension.zip', // The plugin source.
'required' => true, // If false, the plugin is only 'recommended' instead of required.
),
);
$config = array(
'id' => 'tgmpa', // Unique ID for hashing notices for multiple instances of TGMPA.
'default_path' => '', // Default absolute path to bundled plugins.
'menu' => 'tgmpa-install-plugins', // Menu slug.
'parent_slug' => 'themes.php', // Parent menu slug.
'capability' => 'edit_theme_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.
'is_automatic' => false, // Automatically activate plugins after installation or not.
'message' => '', // Message to output right before the plugins table.
'strings' => array(
'page_title' => __( 'Install Required Plugins', 'theme-slug' ),
'menu_title' => __( 'Install Plugins', 'theme-slug' ),
)
);
tgmpa( $plugins, $config );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment