+ Post New Thread
Results 1 to 2 of 2

Thread: How to enable one Wordpress plugin on multiple/many sites at once via Linux shell

  1. #1
    Fli is offline
    Administrator Fli's Avatar
    Join Date
    Mar 2013

    How to enable one Wordpress plugin on multiple/many sites at once via Linux shell

    make money with your web site

    What i want: add & activate one wordpress plugin to many wordpress sites of mine
    What i have: one hosting account/server on which all wordpress sites are hosted

    Assuming my domains have their website folders in /home/user/public_html

    ls /home/user/public_html

    So i add all folders with .info and .cz to the file "/tmp/domains":
    ls -A1 /home/user/public_html|egrep ".info|.cz" >> /tmp/domains

    I verify domain names are listed properly in "/tmp/domains":
    cat /tmp/domains

    (it does not matter how your domain folders are named, it just need to be "something/" and your domain folders should contain wordpress files & folders like wp-content,wp-includes etc.)

    I download script that will enable certain wordpress plugin for me from within command line/shell:
    script source:
    /*      $jwk: wp_enable_plugins.php,v 1.2 2011/04/29 14:50:58 jwk Exp $ */
     * wp_enable_plugins.php
     * CLI helper script for WordPress that enables plugins. Run without
     * any arguments to display list of plugins that exist in your
     * wp-content/plugins/ directory. Specify plugins to enable as
     * arguments to the script. Note by default it does not enable plugins
     * network-wide (if you're running multi-site). Run it from your WordPress
     * directory so it can pick up your wp-config.php file.
     * Joel Knight
     * 2011.04.29
    @include "wp-config.php";
    @include_once "wp-includes/functions.php";
    @include_once "wp-admin/includes/plugin.php";
    if (!defined('DB_NAME'))
            die("ERROR: DB_NAME not defined. Are you in the 'wordpress' directory?\n");
    $action_plugins = $argv;
    array_shift($action_plugins); /* pull the script filename off */
    if (sizeof($action_plugins) == 0) {
            $installed_plugins = get_plugins();
            printf("Inactive plugins:\n");
            foreach ($installed_plugins as $pkey => $pval) {
                    if (!is_plugin_active($pkey))
                            printf("- %s\n", $pkey);
            printf("\nSpecify plugin name(s) from above on the command line to enable them.\n");
    } else {
            $cnt = 0;
            foreach ($action_plugins as $akey => $aval) {
                    if (activate_plugin($aval, '', /* network wide? */ false, /* silent? */ false) == null)
            printf("Enabled %d/%d plugins.\n", $cnt, sizeof($action_plugins));

    I copy this script to all my domain's folders:
    for i in $(cat /tmp/domains);do cp -n -rp /home/user/public_html/wp_enable_plugins.php /home/user/public_html/$i;done

    Then i run wp_enable_plugins.php script to discover paths of my inactive plugins:
    php wp_enable_plugins.php
    Inactive plugins:
    - anti-spam/anti-spam.php
    - comment-notifier/plugin.php
    - hello-dolly/hello.php

    If your plugin is not found, make sure you install it and keep it inactive(not activated) in the wordpress site which path is indicated when you run command "cmd"

    Once done, i want in my case "anti-spam/anti-spam.php" plugin to be enabled on all my wordpres sites

    Example when i installed that plugin and keep it inactive in /home/user/public_html/wp-content/plugins/anti-spam/. I copy this plugin folder and contents to all my domains this way:
    for i in $(cat /tmp/domains);do cp -n -rp /home/user/public_html/wp-content/plugins/anti-spam /home/user/public_html/$i/wp-content/plugins/;done

    Then i should be able to run wp_enable_plugins.php script in all my domains folders and enable my selected plugin on all my domains:
    for i in $(cat /tmp/domains);do cd /home/user/public_html/$i;php wp_enable_plugins.php anti-spam/anti-spam.php;done
    After plugin enabled, and all complete, delete the plugin enabler script:
    find /home/user/public_html -name wp_enable_plugins.php -delete

    Alternatively do it manually via Wordpress.

  2. #2
    Junior Member Trupti42's Avatar
    Join Date
    May 2017

    Is this useful / helpfull? Yes | No
    First create a new text document on your desktop and name it something like "Morning Coffee Sites.txt".
    Double click on it so notepad will open it for editing.
    Copy paste the following into it and replace the site name/URL with the ones you want to load.

+ Post New Thread

Similar Threads

  1. How To Add Plugin In WordPress Site..?
    By swatijain2233 in forum SEO - Search Engine Optimisation
    Replies: 2
    Last Post: 12-27-2018, 08:15 AM
  2. Akismet alternative plugin for Wordpress?
    By Fli in forum Wordpress
    Replies: 0
    Last Post: 02-06-2015, 05:18 PM
  3. Download wpDiscuz WordPress Comments WordPress Plugin
    By Ross Crumpler in forum Wordpress
    Replies: 0
    Last Post: 12-18-2014, 06:18 AM
  4. Replies: 0
    Last Post: 06-12-2014, 07:25 AM
  5. Download While Loading WordPress Plugin
    By Ross Crumpler in forum Wordpress
    Replies: 0
    Last Post: 06-10-2014, 08:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
 Protected by : ZB BLOCK  &  StopForumSpam