| 1 |
<?php |
| 2 |
/** |
| 3 |
* This file represents an example of the code that themes would use to register |
| 4 |
* the required plugins. |
| 5 |
* |
| 6 |
* It is expected that theme authors would copy and paste this code into their |
| 7 |
* functions.php file, and amend to suit. |
| 8 |
* |
| 9 |
* @see http://tgmpluginactivation.com/configuration/ for detailed documentation. |
| 10 |
* |
| 11 |
* @package TGM-Plugin-Activation |
| 12 |
* @subpackage Example |
| 13 |
* @version 2.6.1 for plugin Wpdirectorykit |
| 14 |
* @author Thomas Griffin, Gary Jones, Juliette Reinders Folmer |
| 15 |
* @copyright Copyright (c) 2011, Thomas Griffin |
| 16 |
* @license http://opensource.org/licenses/gpl-2.0.php GPL v2 or later |
| 17 |
* @link https://github.com/TGMPA/TGM-Plugin-Activation |
| 18 |
*/ |
| 19 |
|
| 20 |
/** |
| 21 |
* Include the TGM_Plugin_Activation class. |
| 22 |
* |
| 23 |
* Depending on your implementation, you may want to change the include call: |
| 24 |
* |
| 25 |
* Parent Theme: |
| 26 |
* require_once get_template_directory() . '/path/to/class-tgm-plugin-activation.php'; |
| 27 |
* |
| 28 |
* Child Theme: |
| 29 |
* require_once get_stylesheet_directory() . '/path/to/class-tgm-plugin-activation.php'; |
| 30 |
* |
| 31 |
* Plugin: |
| 32 |
* require_once dirname( __FILE__ ) . '/path/to/class-tgm-plugin-activation.php'; |
| 33 |
*/ |
| 34 |
require_once dirname( __FILE__ ) . '/class-tgm-plugin-activation.php'; |
| 35 |
|
| 36 |
add_action( 'tgmpa_register', 'wpdirectorykit_register_required_plugins' ); |
| 37 |
|
| 38 |
/** |
| 39 |
* Register the required plugins for this plugin. |
| 40 |
* |
| 41 |
* In this example, we register five plugins: |
| 42 |
* - one included with the TGMPA library |
| 43 |
* - two from an external source, one from an arbitrary source, one from a GitHub repository |
| 44 |
* - two from the .org repo, where one demonstrates the use of the `is_callable` argument |
| 45 |
* |
| 46 |
* The variables passed to the `tgmpa()` function should be: |
| 47 |
* - an array of plugin arrays; |
| 48 |
* - optionally a configuration array. |
| 49 |
* If you are not changing anything in the configuration array, you can remove the array and remove the |
| 50 |
* variable from the function call: `tgmpa( $plugins );`. |
| 51 |
* In that case, the TGMPA default settings will be used. |
| 52 |
* |
| 53 |
* This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10. |
| 54 |
*/ |
| 55 |
function wpdirectorykit_register_required_plugins() { |
| 56 |
/* |
| 57 |
* Array of plugin arrays. Required keys are name and slug. |
| 58 |
* If the source is NOT from the .org repo, then source is also required. |
| 59 |
*/ |
| 60 |
$plugins = array( |
| 61 |
|
| 62 |
|
| 63 |
array( |
| 64 |
'name' => 'Element Invader', |
| 65 |
'slug' => 'elementinvader', |
| 66 |
'required' => false, |
| 67 |
), |
| 68 |
array( |
| 69 |
'name' => 'ElementInvader Addons for Elementor', |
| 70 |
'slug' => 'elementinvader-addons-for-elementor', |
| 71 |
'required' => false, |
| 72 |
), |
| 73 |
array( |
| 74 |
'name' => 'Elementor', |
| 75 |
'slug' => 'elementor', |
| 76 |
'required' => false, |
| 77 |
), |
| 78 |
|
| 79 |
|
| 80 |
// This is an example of the use of 'is_callable' functionality. A user could - for instance - |
| 81 |
// have WPSEO installed *or* WPSEO Premium. The slug would in that last case be different, i.e. |
| 82 |
// 'wordpress-seo-premium'. |
| 83 |
// By setting 'is_callable' to either a function from that plugin or a class method |
| 84 |
// `array( 'class', 'method' )` similar to how you hook in to actions and filters, TGMPA can still |
| 85 |
// recognize the plugin as being installed. |
| 86 |
|
| 87 |
/* |
| 88 |
array( |
| 89 |
'name' => 'Meta Box', |
| 90 |
'slug' => 'meta-box', |
| 91 |
'required' => false, |
| 92 |
'is_callable' => 'rwmb_meta', |
| 93 |
),*/ |
| 94 |
|
| 95 |
); |
| 96 |
|
| 97 |
/* |
| 98 |
* Array of configuration settings. Amend each line as needed. |
| 99 |
* |
| 100 |
* TGMPA will start providing localized text strings soon. If you already have translations of our standard |
| 101 |
* strings available, please help us make TGMPA even better by giving us access to these translations or by |
| 102 |
* sending in a pull-request with .po file(s) with the translations. |
| 103 |
* |
| 104 |
* Only uncomment the strings in the config array if you want to customize the strings. |
| 105 |
*/ |
| 106 |
$config = array( |
| 107 |
'id' => 'wpdirectorykit', // Unique ID for hashing notices for multiple instances of TGMPA. |
| 108 |
'default_path' => '', // Default absolute path to bundled plugins. |
| 109 |
'menu' => 'tgmpa-install-plugins', // Menu slug. |
| 110 |
'parent_slug' => 'plugins.php', // Parent menu slug. |
| 111 |
'capability' => 'manage_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used. |
| 112 |
'has_notices' => true, // Show admin notices or not. |
| 113 |
'dismissable' => true, // If false, a user cannot dismiss the nag message. |
| 114 |
'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. |
| 115 |
'is_automatic' => false, // Automatically activate plugins after installation or not. |
| 116 |
'message' => '', // Message to output right before the plugins table. |
| 117 |
|
| 118 |
/* |
| 119 |
'strings' => array( |
| 120 |
'page_title' => __( 'Install Required Plugins', 'wpdirectorykit' ), |
| 121 |
'menu_title' => __( 'Install Plugins', 'wpdirectorykit' ), |
| 122 |
/* translators: %s: plugin name. * / |
| 123 |
'installing' => __( 'Installing Plugin: %s', 'wpdirectorykit' ), |
| 124 |
/* translators: %s: plugin name. * / |
| 125 |
'updating' => __( 'Updating Plugin: %s', 'wpdirectorykit' ), |
| 126 |
'oops' => __( 'Something went wrong with the plugin API.', 'wpdirectorykit' ), |
| 127 |
'notice_can_install_required' => _n_noop( |
| 128 |
/* translators: 1: plugin name(s). * / |
| 129 |
'Plugin WP Directory Kit requires the following plugin: %1$s.', |
| 130 |
'Plugin WP Directory Kit requires the following plugins: %1$s.', |
| 131 |
'wpdirectorykit' |
| 132 |
), |
| 133 |
'notice_can_install_recommended' => _n_noop( |
| 134 |
/* translators: 1: plugin name(s). * / |
| 135 |
'Plugin WP Directory Kit recommends the following plugin: %1$s.', |
| 136 |
'Plugin WP Directory Kit recommends the following plugins: %1$s.', |
| 137 |
'wpdirectorykit' |
| 138 |
), |
| 139 |
'notice_ask_to_update' => _n_noop( |
| 140 |
/* translators: 1: plugin name(s). * / |
| 141 |
'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this plugin: %1$s.', |
| 142 |
'The following plugins need to be updated to their latest version to ensure maximum compatibility with this plugin: %1$s.', |
| 143 |
'wpdirectorykit' |
| 144 |
), |
| 145 |
'notice_ask_to_update_maybe' => _n_noop( |
| 146 |
/* translators: 1: plugin name(s). * / |
| 147 |
'There is an update available for: %1$s.', |
| 148 |
'There are updates available for the following plugins: %1$s.', |
| 149 |
'wpdirectorykit' |
| 150 |
), |
| 151 |
'notice_can_activate_required' => _n_noop( |
| 152 |
/* translators: 1: plugin name(s). * / |
| 153 |
'The following required plugin is currently inactive: %1$s.', |
| 154 |
'The following required plugins are currently inactive: %1$s.', |
| 155 |
'wpdirectorykit' |
| 156 |
), |
| 157 |
'notice_can_activate_recommended' => _n_noop( |
| 158 |
/* translators: 1: plugin name(s). * / |
| 159 |
'The following recommended plugin is currently inactive: %1$s.', |
| 160 |
'The following recommended plugins are currently inactive: %1$s.', |
| 161 |
'wpdirectorykit' |
| 162 |
), |
| 163 |
'install_link' => _n_noop( |
| 164 |
'Begin installing plugin', |
| 165 |
'Begin installing plugins', |
| 166 |
'wpdirectorykit' |
| 167 |
), |
| 168 |
'update_link' => _n_noop( |
| 169 |
'Begin updating plugin', |
| 170 |
'Begin updating plugins', |
| 171 |
'wpdirectorykit' |
| 172 |
), |
| 173 |
'activate_link' => _n_noop( |
| 174 |
'Begin activating plugin', |
| 175 |
'Begin activating plugins', |
| 176 |
'wpdirectorykit' |
| 177 |
), |
| 178 |
'return' => __( 'Return to Required Plugins Installer', 'wpdirectorykit' ), |
| 179 |
'plugin_activated' => __( 'Plugin activated successfully.', 'wpdirectorykit' ), |
| 180 |
'activated_successfully' => __( 'The following plugin was activated successfully:', 'wpdirectorykit' ), |
| 181 |
/* translators: 1: plugin name. * / |
| 182 |
'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'wpdirectorykit' ), |
| 183 |
/* translators: 1: plugin name. * / |
| 184 |
'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this plugin. Please update the plugin.', 'wpdirectorykit' ), |
| 185 |
/* translators: 1: dashboard link. * / |
| 186 |
'complete' => __( 'All plugins installed and activated successfully. %1$s', 'wpdirectorykit' ), |
| 187 |
'dismiss' => __( 'Dismiss this notice', 'wpdirectorykit' ), |
| 188 |
'notice_cannot_install_activate' => __( 'There are one or more required or recommended plugins to install, update or activate.', 'wpdirectorykit' ), |
| 189 |
'contact_admin' => __( 'Please contact the administrator of this site for help.', 'wpdirectorykit' ), |
| 190 |
|
| 191 |
'nag_type' => '', // Determines admin notice type - can only be one of the typical WP notice classes, such as 'updated', 'update-nag', 'notice-warning', 'notice-info' or 'error'. Some of which may not work as expected in older WP versions. |
| 192 |
), |
| 193 |
*/ |
| 194 |
); |
| 195 |
|
| 196 |
tgmpa( $plugins, $config ); |
| 197 |
} |
| 198 |
|