|
| 1 | +<?php |
| 2 | +namespace VendorName\MyPlugin; |
| 3 | + |
| 4 | +class TGMPA extends Plugin { |
| 5 | + |
| 6 | + function __construct() { |
| 7 | + |
| 8 | + // Check for required/recommended plugins |
| 9 | + add_action( 'tgmpa_register', array( $this, 'register_required_plugins' ) ); |
| 10 | + |
| 11 | + } |
| 12 | + |
| 13 | + /** |
| 14 | + * Uses the TGMPA library to check for required/recommended plugins. |
| 15 | + * @since 0.3.0 |
| 16 | + * @link http://tgmpluginactivation.com/configuration/ Configuring TGMPA |
| 17 | + */ |
| 18 | + public function register_required_plugins() { |
| 19 | + |
| 20 | + /* |
| 21 | + * Array of plugin arrays. Required keys are name and slug. |
| 22 | + * If the source is NOT from the .org repo, then source is also required. |
| 23 | + */ |
| 24 | + $plugins = array( |
| 25 | + |
| 26 | + // This is an example of how to include a plugin bundled with a theme. |
| 27 | + array( |
| 28 | + 'name' => 'Carbon Fields Loader', // The plugin name. |
| 29 | + 'slug' => 'carbon-fields-loader', // The plugin slug (typically the folder name). |
| 30 | + 'source' => 'https://github.com/dmhendricks/carbon-fields-loader/archive/master.zip', // The plugin source. |
| 31 | + 'required' => true, // If false, the plugin is only 'recommended' instead of required. |
| 32 | + 'version' => '2.0.0', // E.g. 1.0.0. If set, the active plugin must be this version or higher. If the plugin version is higher than the plugin version installed, the user will be notified to update the plugin. |
| 33 | + 'force_activation' => true // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch. |
| 34 | + ) |
| 35 | + |
| 36 | + ); |
| 37 | + |
| 38 | + /* |
| 39 | + * Array of configuration settings. Amend each line as needed. |
| 40 | + * |
| 41 | + * TGMPA will start providing localized text strings soon. If you already have translations of our standard |
| 42 | + * strings available, please help us make TGMPA even better by giving us access to these translations or by |
| 43 | + * sending in a pull-request with .po file(s) with the translations. |
| 44 | + * |
| 45 | + * Only uncomment the strings in the config array if you want to customize the strings. |
| 46 | + */ |
| 47 | + $config = array( |
| 48 | + 'id' => $this->prefix( 'tgmpa' ), // Unique ID for hashing notices for multiple instances of TGMPA. |
| 49 | + 'menu' => 'tgmpa-install-plugins', // Menu slug. |
| 50 | + 'parent_slug' => 'themes.php', // Parent menu slug. |
| 51 | + 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
| 52 | + 'has_notices' => true, // Show admin notices or not. |
| 53 | + 'dismissable' => true, // If false, a user cannot dismiss the nag message. |
| 54 | + 'is_automatic' => true // Automatically activate plugins after installation or not. |
| 55 | + ); |
| 56 | + |
| 57 | + tgmpa( $plugins, $config ); |
| 58 | + |
| 59 | + } |
| 60 | + |
| 61 | +} |
0 commit comments