I’m looking into using http://tgmpluginactivation.com/ to activate required plugins for my custom theme during the theme activation step.
From what I can tell, this class only Activates plugins automatically, but it doesn’t automatically Install plugins I have bundled with my theme.
Does anyone know if it’s possible to automatically Install plugins upon theme activation? Preferably, in a way that can still make use of TGM?
Edited Answer:
TMG is a very popular auto plugin installer for WordPress and a lot of Premium theme author use it. You can get the php class here https://github.com/thomasgriffin/TGM-Plugin-Activation. Also when you will download it you will get a php file named example.php. You just have to include that example.php file in your function.php file and you just can edit that file to have auto installation for the required plugins for your theme.
You have to do something like this in the example.php file
Thanks
Sabbir
The
activate_plugin
function should be what you’re looking for. Place it in aafter_setup_theme
action.Usage
The doc. page for the
activate_plugin
function doesn’t look too promising, and I have no idea if it will actually work, since I’ve never used it. I guess it’s worth a shot?I imagine activating plugins when a theme is activated could be potentially wreak havoc and break websites.
References