From 5c0ab159e4973ac409d27014c4143df899110750 Mon Sep 17 00:00:00 2001 From: Mirco Babini Date: Fri, 24 Sep 2021 14:46:09 +0200 Subject: [PATCH] 1.3.5 add reinstall-themes and skip plugins/themes when running --- command.php | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/command.php b/command.php index 6e4a452..c22d8e5 100644 --- a/command.php +++ b/command.php @@ -4,7 +4,7 @@ class Swim_WP_CLI extends WP_CLI_Command { // todo move the version to the "package meta" docblock - const VERSION = '1.3.4'; + const VERSION = '1.3.5'; /** * A test which always gives success and the current version. @@ -53,6 +53,32 @@ public function reinstall_core( array $args = [], array $assoc_args = [] ) { WP_CLI::runcommand( "wp core verify-checksums", $options ); } + /** + * Reinstall themes + * - known limits: can't delete infected files... maybe? + * + * ## EXAMPLES + * + * wp swim reinstall-themes + * + * @subcommand reinstall-themes + */ + public function reinstall_themes( array $args = [], array $assoc_args = [] ) { + // subcommand options + $options = array( + 'return' => true, // Return 'STDOUT'; use 'all' for full object. + 'parse' => 'json', // Parse captured STDOUT to JSON array. + 'launch' => false, // Reuse the current process. + 'exit_error' => true, // Halt script execution on error. + ); + + $skip_themes_and_plugins = ' --skip-themes --skip-plugins'; + + // reinstall + WP_CLI::debug( "wp theme install $(wp theme list --field=name $skip_themes_and_plugins) --force $skip_themes_and_plugins" ); + WP_CLI::runcommand( "wp theme install $(wp theme list --field=name $skip_themes_and_plugins) --force $skip_themes_and_plugins", $options ); + } + /** * Reinstall plugins * - known limits: can't delete infected files... maybe? @@ -72,9 +98,11 @@ public function reinstall_plugins( array $args = [], array $assoc_args = [] ) { 'exit_error' => true, // Halt script execution on error. ); - // db dump - WP_CLI::debug( "wp plugin install $(wp plugin list --field=name) --force" ); - WP_CLI::runcommand( "wp plugin install $(wp plugin list --field=name) --force", $options ); + $skip_themes_and_plugins = ' --skip-themes --skip-plugins'; + + // reinstall + WP_CLI::debug( "wp plugin install $(wp plugin list --field=name $skip_themes_and_plugins) --force $skip_themes_and_plugins" ); + WP_CLI::runcommand( "wp plugin install $(wp plugin list --field=name $skip_themes_and_plugins) --force $skip_themes_and_plugins", $options ); } /**