Recently I have written few articles/tips for wordpress. So here is one more article on this series. In this tutorial we will see how we can activate wordpress plugins programatically.
This would be useful when you don’t want some of your plugin to be disabled. Using below code your those plugins will always remain activated even if some one has deactivated form the admin panel. :)
How let’s have a look at below code block for the same. You just need to place below code in functions.php file of your active theme.
$current_plugin = get_option("active_plugins");
//Array of plugin which you want to remain active
$always_active_plugin = array("plugin_x", "plugin_y", "plugin_z");
// Looping through active plugins
foreach ($always_active_plugin as $plugin_name)
// If plugin is not active then add to list
// Finally update plugins.
Hope this will be useful when you need this. Subscribe to our RSS Feed to get updates via email.