As a follow-on to my previous post about disabling plugins, this script will enable plugins from the shell.
I should’ve had the foresight to make the first script do both tasks but my immediate need was only to disable plugins so that’s as far as I went. A reader of the previous post, Mark Kreyman, asked if I was able to create a companion script which would allow him to enable plugins. I wrote this script at his request.
% php wp_enable_plugins.php
Inactive plugins:
- akismet/akismet.php
- google-analyticator/google-analyticator.php
- google-sitemap-generator/sitemap.php
Specify plugin name(s) from above on the command line to enable them.
% php wp_enable_plugins.php akismet/akismet.php
Enabled 1/1 plugins.
This script (and the disable script) aren’t meant to turn all plugins on/off in one shot. There’s loads of resources on the web showing how to do that. These scripts are meant to enable/disable selective plugins.
Download plugin enable script: wp_enable_plugins.php
Download plugin disable script: wp_disable_plugins.php
Hi, I downloaded the script but in wordpress 3.3.1 it seems doesn’t work… it says the plugin is disabled but in fact is still enabled
Hi giuseppe,
I just double checked on a 3.3.1 installation and it works a-ok for me.
Hi Joel and thx for your quick reply… you’re right, it works, it was a browser cache problem, the scripts are very useful, thanks!
You’re welcome!
Works like a charm. On cPanel servers:
/home//public_html
wget http://www.packetmischief.ca/files/wp/wp_enable_plugins.php
Good for command line troubleshooting of plugins which may be using too much CPU or memory. Disabling them one by one and checking server load should help you determine if a particular plugin is causing server issues.
Thanks Joel.
above should read /home/cpanelusername/public_html
Thanks from russian php coders! :)
If I enable the plugin wp-super-cache through php, the plugin automatically perform the required settings? Copy the folder,files, for example? Or I need to enable through web interface?
Hi,
It probably will, yes. The script calls the proper WP hook to activate plugins. Quickest way to know though is just try it for yourself.
Hello,
wp_disable_plugin.php works fine for me but wp_enable_plugins.php don’t works…
I don’t understand enable script because there is no select on database…
Can you help me ?
Thanks,
Julien
Hi. Please provide the exact command you’re using and the resulting script output.
root@mypc:/var/www/buddypress # php wp_enable_plugins.php
root@mypc:/var/www/buddypress #
Nothing output. I use root user to execute php script.
Hi Julien,
You didn’t tell the script what plugin to enable. Follow my example from above:
% php wp_enable_plugins.php akismet/akismet.php
This is what I’ve try with two different plugin which is disable.
Example:
php wp_enable_plugins.php quick-chat/quick-chat.php
And then, when I go to the list of plugin in administration area, quick chat is still disable.
I though that wp_enable_plugin.php without agument coul’d dsplay the list of unactive plugin (like wp_disable_plugin)
You’re right, without arguments it will show the list of disabled plugins.
% php wp_enable_plugins.php
Inactive plugins:
– akismet/akismet.php
Specify plugin name(s) from above on the command line to enable them.
What version of WordPress as you trying this against? Please make sure your working directory is your wordpress directory under your web docs root.
I use the latest version of wordpress (3.4.2) and I always run the script from the web docs root. I have 32 installed plugins.
Thanks
Try this. Edit the script and remove the “@” character from the beginning of the “include” and “include_once” lines near the top of the script. Run the script and paste the output here.
Hi Joel can we create similar script to manage users on word press site
Hi Avinash,
I imagine you can. It’s not something I’ve ever done but this is where you’d find the right information about how to do it: http://codex.wordpress.org/Main_Page
Hi Joel,
I wanted to say awesome and thank you for your script. I am curious how to get it to work if I move wp-config.php up one directory (out of public_html)? When I try to change the include line to:
@include “../wp-config.php”;
the script stop working and doesn’t output anything. Can you advise how to make it work with wp-config.php moved up a directory?
Hey Don,
Thanks for the feedback :)
Can you remove the “@” in front of the include statement and try again. Do you get an error that says something like “wp-settings.php): failed to open stream: No such file or directory”? That’s what happens when you move wp-config.php out of the wordpress directory. You need to modify wp-config.php so that the ABSPATH constant includes the name of the wordpress subdirectory. For example:
define(‘ABSPATH’, dirname(__FILE__) . ‘/wordpress/’);
I don’t believe this has any negative affect on WordPress itself but you should test it carefully.