New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force reinstall all plugins or themes #3293

Closed
jb510 opened this Issue Aug 16, 2016 · 7 comments

Comments

3 participants
@jb510

jb510 commented Aug 16, 2016

I feel like this has been suggested before, but the past issues I found were actually different (either about core, or about an individual plugin/theme)

I would really like it if there were a way to:
wp plugin update --all --force
and
wp theme update --all --force

Which would reinstall all plugins/themes with the latest version from the repo.

There is a regular plugin I've used for this in the past: https://wordpress.org/plugins/baw-force-plugin-updates/ but it seems a natural fit to wp cli.

This is common step when dealing with a hacked site and frankly I'd like to run it periodically on non-hacked sites just in case anything got out of sync between repos and servers.

@danielbachhuber

This comment has been minimized.

Member

danielbachhuber commented Aug 16, 2016

You can achieve the same by composing two commands:

$ wp plugin install $(wp plugin list --field=name) --force
Warning: Couldn't find 'airplane-mode' in the WordPress.org plugin directory.
Installing Akismet (3.1.11)
Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
Unpacking the package...
Installing the plugin...
Removing the old version of the plugin...
Plugin updated successfully.

I'll include this as an example in the docs

@jb510

This comment has been minimized.

jb510 commented Aug 16, 2016

Oh fancy! Thanks!

Question (obviously I'm not that versed in bash scripting): Is the first $ your bash prompt? I use zsh and have a custom prompt, but I it didn't work when I included the first $.

wp plugin install $(wp plugin list --field=name) --force

Obviously I'm not that versed in bash syntax.... I found this https://www.gnu.org/software/bash/manual/bash.html#Command-Substitution which I assume is that function, just want to make sure I'm not missing something.

@danielbachhuber

This comment has been minimized.

Member

danielbachhuber commented Aug 16, 2016

Is the first $ your bash prompt? I use zsh and have a custom prompt, but I it didn't work when I included the first $.

No, $ is just an indicator for a command being entered into the bash prompt (compared to output from the command).

@danielbachhuber danielbachhuber added this to the 0.25.0 milestone Aug 16, 2016

@khromov

This comment has been minimized.

khromov commented Mar 11, 2017

Great snippet @danielbachhuber

If anyone is looking to reinstall themes in the same manner, the command is:

wp theme install $(wp theme list --field=name) --force
@jb510

This comment has been minimized.

jb510 commented Nov 7, 2017

So this normally works, but I'm getting fatals from plugins and the theme calling a member function on null (old code using globals). Normally --skip-plugins and --skip-themes would bypass that, but here I get

% wp plugin install $(wp plugin list --field=name) --force --skip-plugins --skip-themes

usage: wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--activate] [--activate-network]

I guess you can't skip when installing? Seems odd though as I thought those were global params https://developer.wordpress.org/cli/commands/plugin/install/

@danielbachhuber

This comment has been minimized.

Member

danielbachhuber commented Nov 7, 2017

@jb510 You're using bash substitution, which means you're running two separate commands. You'll need to also run wp plugin list --skip-plugins --skip-themes

@jb510

This comment has been minimized.

jb510 commented Nov 7, 2017

damn it... that thought occurred to me briefly and then I forgot to try it. You bash skilled are legendary...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment