Activating and de-activating plugins

Basic usage

To activate a plugin, use –activate:

wordshell mysite akismet --activate

Output upon success:

mysite: akismet/akismet.php: Plugin successfully activated

To de-activate, use –deactivate:

wordshell mysite akismet --deactivate

Output upon success:

mysite: akismet/akismet.php: Plugin successfully deactivated

Note that these operations will go ahead and show the same output, regardless of whether the plugin is presently active or not. i.e. They do not first test for the plugin’s activation status. To test whether a plugin is active or not, see the manual page for listing plugins.

Plugins and WordPress Multisite

This feature first appeared in WordShell 1.3.73.

You may want to familiarise yourself with some of the concepts involved with working with plugins in WordPress Multisite (a.k.a. WordPress networks): http://codex.wordpress.org/Multisite_Network_Administration#Plugins. From that page you will learn that installing, updating and deleting plugins on a multisite WordPress install is no different to doing so on an ordinary WordPress install. There is nothing new you need to learn to do that – it is only activating and de-activating plugins that has some differences. Plugins can be activated for every blog, without the blog owner being able to over-ride (a “network activation”); or they can be made available per-blog for the blog owner to choose.

If working with a multisite install, then by default –activate, deactivate and –list work upon plugins for your site’s main (primary) blog. If instead you wish to use a different blog, then use the –blog parameter. Specify either the blog ID, or the sub-directory/sub-domain for the blog, e.g.:

wordshell mysite akismet --activate --blog=2

wordshell mysite akismet --activate --blog=mysecondblog

If you wish to activate the plugin for the whole network (“network activation” – see http://codex.wordpress.org/Multisite_Network_Administration#Plugins) then add –network:

wordshell mysite akismet --activate --network

The same switches can be provided with –deactivate and –list. With –list, “–network” tells you whether the plugin is network activated. When listing for a particular blog, however, –list will tell you whether the plugin is active for that blog, and if it is active that might be because the plugin has been network activated, or might be because it is enabled on that particular blog. To work out which is the case, you may need to run both with and without –network, like so:

wordshell mysite akismet --list --blog=mysecondblog

Result:

mysite akismet 2.5.6 Akismet

The plugin is active (there is no (i) after the plugin name). But is it active because of being network activated?

wordshell mysite akismet --activate --blog=mysecondblog

Result:

mysite (i) akismet 2.5.6 Akismet

The plugin is not network activated. Therefore it must be active because it was individually activated on that particular blog.

Hints and tips

Do not confuse the switch –activate with –active. The former is the switch to activate a plugin. The second switch is for specifying that the operation given (e.g. –list, –update) should only be carried out on active plugins and not on inactive ones. Similarly for –deactivate and –inactive.

Not always needed

When you delete a plugin (using –delete), then the plugin is automatically de-activated; you do not need to specify –deactivate. You can over-ride that behaviour with –skipdeactivate if you need to (e.g. if the de-activate is causing an error).

Next read:

Leave a Reply

Site Map