Enable WordPress Plugins From the Shell

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

21 thoughts on “Enable WordPress Plugins From the Shell”

  1. 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

      1. 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!

  2. 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?

    1. 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.

  3. 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 ?



      1. 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.

        1. 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

          1. This is what I’ve try with two different plugin which is disable.

            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)

            1. 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.

  4. 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.


    1. 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.

  5. 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?

    1. 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.

Leave a Reply to Joel Knight Cancel reply

Your email address will not be published. Required fields are marked *

Would you like to subscribe to email notification of new comments? You can also subscribe without commenting.