register-plugins.php 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 child theme captivating
  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. require_once get_stylesheet_directory() . '/lib/plugins/tgm-plugin-activation/class-tgm-plugin-activation.php';
  20. add_action( 'tgmpa_register', 'captivating_register_required_plugins' );
  21. /**
  22. * Register the required plugins for this theme.
  23. *
  24. * In this example, we register five plugins:
  25. * - one included with the TGMPA library
  26. * - two from an external source, one from an arbitrary source, one from a GitHub repository
  27. * - two from the .org repo, where one demonstrates the use of the `is_callable` argument
  28. *
  29. * The variables passed to the `tgmpa()` function should be:
  30. * - an array of plugin arrays;
  31. * - optionally a configuration array.
  32. * If you are not changing anything in the configuration array, you can remove the array and remove the
  33. * variable from the function call: `tgmpa( $plugins );`.
  34. * In that case, the TGMPA default settings will be used.
  35. *
  36. * This function is hooked into `tgmpa_register`, which is fired on the WP `init` action on priority 10.
  37. */
  38. function captivating_register_required_plugins() {
  39. /*
  40. * Array of plugin arrays. Required keys are name and slug.
  41. * If the source is NOT from the .org repo, then source is also required.
  42. */
  43. $plugins = array(
  44. // This is an example of how to include a plugin from the WordPress Plugin Repository.
  45. array(
  46. 'name' => 'Genesis eNews Extended',
  47. 'slug' => 'genesis-enews-extended',
  48. 'required' => false,
  49. ),
  50. array(
  51. 'name' => 'Flexible Posts Widget',
  52. 'slug' => 'flexible-posts-widget',
  53. 'required' => false,
  54. ),
  55. array(
  56. 'name' => 'Simple Social Icons',
  57. 'slug' => 'simple-social-icons',
  58. 'required' => false,
  59. ),
  60. // array(
  61. // 'name' => 'Instagram Feed',
  62. // 'slug' => 'instagram-feed',
  63. // 'required' => false,
  64. // ),
  65. // array(
  66. // 'name' => 'Ninja Forms',
  67. // 'slug' => 'ninja-forms',
  68. // 'required' => false,
  69. // ),
  70. array(
  71. 'name' => 'Social Warfare',
  72. 'slug' => 'social-warfare',
  73. 'required' => false,
  74. ),
  75. array(
  76. 'name' => 'Regenerate Thumbnails',
  77. 'slug' => 'regenerate-thumbnails',
  78. 'required' => false,
  79. ),
  80. array(
  81. 'name' => 'Widget Importer & Exporter',
  82. 'slug' => 'widget-importer-exporter',
  83. 'required' => false,
  84. ),
  85. // array(
  86. // 'name' => 'Soliloquy Lite',
  87. // 'slug' => 'soliloquy-lite',
  88. // 'required' => false,
  89. // ),
  90. // array(
  91. // 'name' => 'Genesis Responsive Slider',
  92. // 'slug' => 'genesis-responsive-slider',
  93. // 'required' => false,
  94. // ),
  95. array(
  96. 'name' => 'WP Recipe Maker',
  97. 'slug' => 'wp-recipe-maker',
  98. 'required' => false,
  99. ),
  100. );
  101. /*
  102. * Array of configuration settings. Amend each line as needed.
  103. *
  104. * TGMPA will start providing localized text strings soon. If you already have translations of our standard
  105. * strings available, please help us make TGMPA even better by giving us access to these translations or by
  106. * sending in a pull-request with .po file(s) with the translations.
  107. *
  108. * Only uncomment the strings in the config array if you want to customize the strings.
  109. */
  110. $config = array(
  111. 'id' => 'captivating', // Unique ID for hashing notices for multiple instances of TGMPA.
  112. 'default_path' => '', // Default absolute path to bundled plugins.
  113. 'menu' => 'tgmpa-install-plugins', // Menu slug.
  114. 'parent_slug' => 'themes.php', // Parent menu slug.
  115. 'capability' => 'edit_theme_options', // Capability needed to view plugin install page, should be a capability associated with the parent menu used.
  116. 'has_notices' => true, // Show admin notices or not.
  117. 'dismissable' => true, // If false, a user cannot dismiss the nag message.
  118. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag.
  119. 'is_automatic' => false, // Automatically activate plugins after installation or not.
  120. 'message' => '', // Message to output right before the plugins table.
  121. /*
  122. 'strings' => array(
  123. 'page_title' => __( 'Install Required Plugins', 'captivating' ),
  124. 'menu_title' => __( 'Install Plugins', 'captivating' ),
  125. /* translators: %s: plugin name. * /
  126. 'installing' => __( 'Installing Plugin: %s', 'captivating' ),
  127. /* translators: %s: plugin name. * /
  128. 'updating' => __( 'Updating Plugin: %s', 'captivating' ),
  129. 'oops' => __( 'Something went wrong with the plugin API.', 'captivating' ),
  130. 'notice_can_install_required' => _n_noop(
  131. /* translators: 1: plugin name(s). * /
  132. 'This theme requires the following plugin: %1$s.',
  133. 'This theme requires the following plugins: %1$s.',
  134. 'captivating'
  135. ),
  136. 'notice_can_install_recommended' => _n_noop(
  137. /* translators: 1: plugin name(s). * /
  138. 'This theme recommends the following plugin: %1$s.',
  139. 'This theme recommends the following plugins: %1$s.',
  140. 'captivating'
  141. ),
  142. 'notice_ask_to_update' => _n_noop(
  143. /* translators: 1: plugin name(s). * /
  144. 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.',
  145. 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.',
  146. 'captivating'
  147. ),
  148. 'notice_ask_to_update_maybe' => _n_noop(
  149. /* translators: 1: plugin name(s). * /
  150. 'There is an update available for: %1$s.',
  151. 'There are updates available for the following plugins: %1$s.',
  152. 'captivating'
  153. ),
  154. 'notice_can_activate_required' => _n_noop(
  155. /* translators: 1: plugin name(s). * /
  156. 'The following required plugin is currently inactive: %1$s.',
  157. 'The following required plugins are currently inactive: %1$s.',
  158. 'captivating'
  159. ),
  160. 'notice_can_activate_recommended' => _n_noop(
  161. /* translators: 1: plugin name(s). * /
  162. 'The following recommended plugin is currently inactive: %1$s.',
  163. 'The following recommended plugins are currently inactive: %1$s.',
  164. 'captivating'
  165. ),
  166. 'install_link' => _n_noop(
  167. 'Begin installing plugin',
  168. 'Begin installing plugins',
  169. 'captivating'
  170. ),
  171. 'update_link' => _n_noop(
  172. 'Begin updating plugin',
  173. 'Begin updating plugins',
  174. 'captivating'
  175. ),
  176. 'activate_link' => _n_noop(
  177. 'Begin activating plugin',
  178. 'Begin activating plugins',
  179. 'captivating'
  180. ),
  181. 'return' => __( 'Return to Required Plugins Installer', 'captivating' ),
  182. 'plugin_activated' => __( 'Plugin activated successfully.', 'captivating' ),
  183. 'activated_successfully' => __( 'The following plugin was activated successfully:', 'captivating' ),
  184. /* translators: 1: plugin name. * /
  185. 'plugin_already_active' => __( 'No action taken. Plugin %1$s was already active.', 'captivating' ),
  186. /* translators: 1: plugin name. * /
  187. 'plugin_needs_higher_version' => __( 'Plugin not activated. A higher version of %s is needed for this theme. Please update the plugin.', 'captivating' ),
  188. /* translators: 1: dashboard link. * /
  189. 'complete' => __( 'All plugins installed and activated successfully. %1$s', 'captivating' ),
  190. 'dismiss' => __( 'Dismiss this notice', 'captivating' ),
  191. 'notice_cannot_install_activate' => __( 'There are one or more required or recommended plugins to install, update or activate.', 'captivating' ),
  192. 'contact_admin' => __( 'Please contact the administrator of this site for help.', 'captivating' ),
  193. '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.
  194. ),
  195. */
  196. );
  197. tgmpa( $plugins, $config );
  198. }