wp-cli / ideas

💡 Ideas and feature requests are collected here
40 stars 1 forks source link

Add command to detect presence of multisite installation #170

Closed baizmandesign closed 1 year ago

baizmandesign commented 1 year ago

I'd like to propose adding a new command that tests whether a WP instance is a multisite installation:

$ wp core is-multisite

It would work similarly to wp core is-installed and return 0 if the instance is a network and 1 if it isn't a network. (I don't think we need to create an inverse command to test whether a site is a non-networked singleton... that's the more common occurrence.)

Why is this command useful? When activating and deactivating plugins, an additional --network parameter can be passed to them. I have scripts that automatically activate and deactivate plugins across several installations, and of those installations some are singletons and some are networks. This would be useful to determine whether I needed to add the --network flag. (There must be other use cases where it's beneficial for scripts and humans to quickly test whether a site is a network.)

One reason not to consider this command is because, thanks to WP CLI, it's already trivial to determine whether a site is part of a network by obtaining the return value of the command below:

$ wp config get MULTISITE

But part of me feels as if a command like this should be native to WP CLI and would be of a piece with commands like wp core is-installed, wp plugin is-installed, wp theme is-active, etc.

danielbachhuber commented 1 year ago

Thanks for the suggestion, @baizmandesign !

How would you see wp core is-multisite as different from wp core is-installed --network ?

baizmandesign commented 1 year ago

@danielbachhuber Oh my, it's not different! I'm embarrassed to say I didn't see that flag in the commands documentation (and I consult the docs almost daily, both on the web and via wp help). Feel free to reject this proposal and close this issue. Sorry to have wasted your time!

danielbachhuber commented 1 year ago

@baizmandesign No worries! Appreciate you stopping by, and glad we already had a solution for you 😊