Skip to content
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 · 9 comments
Closed

Force reinstall all plugins or themes #3293

jb510 opened this issue Aug 16, 2016 · 9 comments

Comments

@jb510
Copy link

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
Copy link
Member

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
Copy link
Author

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
Copy link
Member

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
Copy link

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
Copy link
Author

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
Copy link
Member

@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
Copy link
Author

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...

@sharmashivanand
Copy link

Try this if you don't want to attempt drop-ins, mu-plugins, waste files left inside plugins folders etc.

This carefully looks for directories only inside wp-content/plugins and forces a reinstall.

wp plugin install $(ls -1p wp-content/plugins | grep '/$' | sed 's/\/$//') --force

@richard-muvirimi
Copy link

You can also use Force Reinstall to force plugin and theme reinstallation

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

No branches or pull requests

5 participants