I have WP-CLI working fine using WP Multisite (or network). I can create blogs, add users, set permissions etc. But am not certain how to enable plugins for individual blogs via WP CLI.
For example, I can see for a specific blog that I have the following plugins enabled:
$ wp option get active_plugins --url=blogs.my.domain/test1
array (
0 => 'active-directory-integration/ad-integration.php',
1 => 'disable-comments/disable-comments.php',
2 => 'http-authentication/http-authentication.php',
)
Which have been done by using the normal GUI and all is well.
However what I would like to do is set the options for each plugin - which I have done via WP CLI. What I am not certain how to do is manipulate the associative array via WP_CLI
in order to activate the plugins for each new site, at the moment understandably the active_plugins
appear as follows even though the plugin's settings are in place:
$ wp option get active_plugins --url=blogs.my.domain/test2 array ()
So I would like to have the array set as the first example of a site where the plugins are enabled.
If someone can give me some clues as to how to manipulate and control associative arrays via WP CLI I would appreciate your help.
I have WP-CLI working fine using WP Multisite (or network). I can create blogs, add users, set permissions etc. But am not certain how to enable plugins for individual blogs via WP CLI.
For example, I can see for a specific blog that I have the following plugins enabled:
$ wp option get active_plugins --url=blogs.my.domain/test1
array (
0 => 'active-directory-integration/ad-integration.php',
1 => 'disable-comments/disable-comments.php',
2 => 'http-authentication/http-authentication.php',
)
Which have been done by using the normal GUI and all is well.
However what I would like to do is set the options for each plugin - which I have done via WP CLI. What I am not certain how to do is manipulate the associative array via WP_CLI
in order to activate the plugins for each new site, at the moment understandably the active_plugins
appear as follows even though the plugin's settings are in place:
$ wp option get active_plugins --url=blogs.my.domain/test2 array ()
So I would like to have the array set as the first example of a site where the plugins are enabled.
If someone can give me some clues as to how to manipulate and control associative arrays via WP CLI I would appreciate your help.
Share Improve this question edited May 7, 2019 at 13:52 butlerblog 5,1313 gold badges28 silver badges44 bronze badges asked Nov 25, 2014 at 11:56 Paul OsbornePaul Osborne 411 silver badge3 bronze badges2 Answers
Reset to default 1You could probably manipulate the option with wp option update
but you shouldn't.
It has plenty of dedicated commands for plugins, in your case it would probably be something like wp plugin activate active-directory-integration,disable-comments,http-authentication --url=blogs.my.domain/test1
.
Sorry need a long comment, so having to use an answer:
What you suggest works, but I have found an issue(bug?):
$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray (
)
Which is what I would expect, then activate the plugin:
$ wp plugin activate active-directory-integration --url=blogs.my.domain/undersea/submarine
Warning: Could not activate the 'active-directory-integration' plugin.
Which suggests that the plugin has not activated, but:
$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray (
0 => 'active-directory-integration/ad-integration.php',
)
Tells me that it is active, which is not what I expected.
So deactivating the plugin:
$ wp plugin deactivate active-directory-integration --url=blogs.canterbury.ac.uk/undersea/submarine
Success: Plugin 'active-directory-integration' deactivated.
and to confirm:
$ wp option get active_plugins --url=blogs.my.domain/undersea/submarinearray (
)
Which is what I would expect.
So I get a correct message when a plugin is deactivated but not when one is, this is just a bit misleading.
I appreciate being able to do what I need to do, however the misleading message is not as helpful as I would like.
Many thanks
P.