How to include or prompt users to automatically download, install or activate required plugins upon theme activation? Well, now that is completely possible with TGM Plugin. TGM Plugin Activation is the best way to require plugins for WordPress themes.
Whether you are building a theme for a customer, industrial or open source job you might face a scenario where your style’s functionality depends on a plugin. A good example would be Advanced Personalized Area. This plugin pack a full array of personalization options for WordPress that many your theme do not have. Why not develop a theme and also require it activated to utilize?
TGM Plugin do these eaisly:
- Instantly set up a plugin that comes pre-packaged with the theme.
- Automatically download zip file from the WordPress Plugin Database and install it.
In either situation, this new course can manage numerous instances of both, which means that you could include/prompt to download as many plugins as needed! On activation, individuals are motivated with admin notifications that specific plugins are required.
The UI is really acquainted and user-friendly considering that it does the same with the rest of the WordPress admin UI. Users could then hit the send switch that sets up the plugin. You could even have plugins be downloaded and install as well as mounted from the WordPress Plugin Repository!
The TGM_Plugin_Activation lesson uses the exact same methods as WordPress itself makes use of to download and install, upgrade as well as switch on plugins.
Ways to Include TGM Plugin with your theme
After download the pack you need to include the class for use within your functions.php file. This is done by the require_once line.
pre-packed zip file have these two php file you can see above code. just put these file in your theme folder. Above code show these two files, include in functions file after you can change folder path according to you.
You get two files in pack, no need to changes in ‘class-tgm-plugin-activation.php’ named file. we will do change in ‘plugins_load.php’ file because this file tell theme to install required plugin in theme. in plugin_load file i added ‘Revolution Slider’ in required plugin list which i already include in my theme folder you can see easily.
The second one is ‘TGM New Media Plugin’ which will download from different url, and the finally ‘Contact Form 7’ which directly download and activate from WordPress site. i added all three method which can install required plugin in your theme. you can change according to your requirements. All codes well commented.
After successful integrate the TGM you will see above message in your theme.The TGM Plugin Activation library was created and is maintained by Thomas Griffin.
Hope you will like my this post thanks for developers to make such a great way to Auto Install Require Plugins for Your WordPress Themes