Skip to content

Instantly share code, notes, and snippets.

@Niq1982
Last active September 16, 2021 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Niq1982/83a81d2f6aa3792cb9026b4224f55984 to your computer and use it in GitHub Desktop.
Save Niq1982/83a81d2f6aa3792cb9026b4224f55984 to your computer and use it in GitHub Desktop.
Force reinstall everything with WP CLI

Use WP CLI to reinstall everything when there's a possibility that the site is hacked and could include some malicious code. Also be sure that you download/deploy fresh copies of plugins and themes that aren't hosted in the WordPress repositories

Download and install WP fresh core

Use --skip-content to not download default themes/plugins.

Dont do this if wp installation is any way customised, bedrock etc
wp core download --force --skip-content

Reinstall every plugin that's installed

Use --skip-plugins --skip-themes to skip plugins and themes to minimize errors and prevent running the possible malicious code

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

Reinstall every theme that's installed

Use --skip-plugins --skip-themes to skip plugins and themes to minimize errors and prevent running the possible malicious code

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

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