onetone_theme_register_required_plugins

Register the required plugins for this theme.

Description

onetone_theme_register_required_plugins(); 

In this example, we register two plugins - one included with the TGMPA library and one from the .org repo.

The variable passed to tgmpa_register_plugins() should be an array of plugin arrays.

This function is hooked into tgmpa_init, which is fired within the TGM_Plugin_Activation class constructor.


Usage

  1. if ( !function_exists( 'onetone_theme_register_required_plugins' ) ) { 
  2. require_once '/functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = onetone_theme_register_required_plugins(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions.php  
  1. function onetone_theme_register_required_plugins() { 
  2.  
  3. /** 
  4. * Array of plugin arrays. Required keys are name and slug. 
  5. * If the source is NOT from the .org repo, then source is also required. 
  6. */ 
  7. $plugins = array( 
  8. // This is an example of how to include a plugin pre-packaged with a theme 
  9. array( 
  10. 'name' => __('Magee Shortcodes', 'onetone'), // The plugin name 
  11. 'slug' => 'magee-shortcodes', // The plugin slug (typically the folder name) 
  12. 'source' => esc_url('https://downloads.wordpress.org/plugin/magee-shortcodes.zip'), // The plugin source 
  13. 'required' => true, // If false, the plugin is only 'recommended' instead of required 
  14. 'version' => '1.2.4', // E.g. 1.0.0. If set, the active plugin must be this version or higher, otherwise a notice is presented 
  15. 'force_activation' => false, // If true, plugin is activated upon theme activation and cannot be deactivated until theme switch 
  16. 'force_deactivation' => false, // If true, plugin is deactivated upon theme switch, useful for theme-specific plugins 
  17. 'external_url' => '', // If set, overrides default API URL and points to an external URL 
  18. 'id' => 'magee-shortcodes',  
  19.  
  20.  
  21. ),  
  22.  
  23. ); 
  24.  
  25. /** 
  26. * Array of configuration settings. Amend each line as needed. 
  27. * If you want the default strings to be available under your own theme domain,  
  28. * leave the strings uncommented. 
  29. * Some of the strings are added into a sprintf, so see the comments at the 
  30. * end of each line for what each argument will be. 
  31. */ 
  32. $config = array( 
  33. 'id' => 'onetone', // Unique ID for hashing notices for multiple instances of TGMPA. 
  34. 'default_path' => '', // Default absolute path to pre-packaged plugins. 
  35. 'menu' => 'onetone-install-plugins', // Menu slug. 
  36. 'has_notices' => true, // Show admin notices or not. 
  37. 'dismissable' => false, // If false, a user cannot dismiss the nag message. 
  38. 'dismiss_msg' => '', // If 'dismissable' is false, this message will be output at top of nag. 
  39. 'is_automatic' => false, // Automatically activate plugins after installation or not. 
  40. 'message' => '', // Message to output right before the plugins table. 
  41. 'strings' => array( 
  42. 'page_title' => __( 'Install Required Plugins', 'onetone' ),  
  43. 'menu_title' => __( 'Install Plugins', 'onetone' ),  
  44. 'installing' => __( 'Installing Plugin: %s', 'onetone' ), // %s = plugin name. 
  45. 'oops' => __( 'Something went wrong with the plugin API.', 'onetone' ),  
  46. 'notice_can_install_required' => _n_noop( 'This theme requires the following plugin: %1$s.<br/><span style="color:red;">NOTICE:</span> Onetone includes all shortcodes inside the Magee Shortcodes plugin. As to best user experience, please activate it now.', 'This theme requires the following plugins: %1$s.<br/><span style="color:red;">NOTICE:</span> Onetone includes all shortcodes inside the Magee Shortcodes plugin. As to best user experience, please activate it now.', 'onetone' ), // %1$s = plugin name(s). 
  47. 'notice_can_install_recommended' => _n_noop( 'This theme recommends the following plugin: %1$s.', 'This theme recommends the following plugins: %1$s.', 'onetone' ), // %1$s = plugin name(s). 
  48. 'notice_cannot_install' => _n_noop( 'Sorry, but you do not have the correct permissions to install the %s plugin. Contact the administrator of this site for help on getting the plugin installed.', 'Sorry, but you do not have the correct permissions to install the %s plugins. Contact the administrator of this site for help on getting the plugins installed.', 'onetone' ), // %1$s = plugin name(s). 
  49. 'notice_can_activate_required' => _n_noop( 'The following required plugin is currently inactive: %1$s.<br/><span style="color:red;">NOTICE:</span> Onetone includes all shortcodes inside the Magee Shortcodes plugin. As to best user experience, please activate it now.', 'The following required plugins are currently inactive: %1$s.<br/><span style="color:red;">NOTICE:</span> Onetone includes all shortcodes inside the Magee Shortcodes plugin. As to best user experience, please activate it now.', 'onetone' ), // %1$s = plugin name(s). 
  50. 'notice_can_activate_recommended' => _n_noop( 'The following recommended plugin is currently inactive: %1$s.', 'The following recommended plugins are currently inactive: %1$s.', 'onetone' ), // %1$s = plugin name(s). 
  51. 'notice_cannot_activate' => _n_noop( 'Sorry, but you do not have the correct permissions to activate the %s plugin. Contact the administrator of this site for help on getting the plugin activated.', 'Sorry, but you do not have the correct permissions to activate the %s plugins. Contact the administrator of this site for help on getting the plugins activated.', 'onetone' ), // %1$s = plugin name(s). 
  52. 'notice_ask_to_update' => _n_noop( 'The following plugin needs to be updated to its latest version to ensure maximum compatibility with this theme: %1$s.', 'The following plugins need to be updated to their latest version to ensure maximum compatibility with this theme: %1$s.', 'onetone' ), // %1$s = plugin name(s). 
  53. 'notice_cannot_update' => _n_noop( 'Sorry, but you do not have the correct permissions to update the %s plugin. Contact the administrator of this site for help on getting the plugin updated.', 'Sorry, but you do not have the correct permissions to update the %s plugins. Contact the administrator of this site for help on getting the plugins updated.', 'onetone' ), // %1$s = plugin name(s). 
  54. 'install_link' => _n_noop( 'Begin installing plugin', 'Begin installing plugins', 'onetone' ),  
  55. 'activate_link' => _n_noop( 'Begin activating plugin', 'Begin activating plugins', 'onetone' ),  
  56. 'return' => __( 'Return to Required Plugins Installer', 'onetone' ),  
  57. 'plugin_activated' => __( 'Plugin activated successfully.', 'onetone' ),  
  58. 'complete' => __( 'All plugins installed and activated successfully. %s', 'onetone' ), // %s = dashboard link. 
  59. 'nag_type' => 'updated' // Determines admin notice type - can only be 'updated', 'update-nag' or error. 
  60. ); 
  61.  
  62. tgmpa( $plugins, $config ); 
  63.