Skip to content

Commit

Permalink
1.3.5 add reinstall-themes and skip plugins/themes when running
Browse files Browse the repository at this point in the history
  • Loading branch information
mircobabini committed Sep 24, 2021
1 parent c28a9e4 commit 5c0ab15
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions command.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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?
Expand All @@ -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 );
}

/**
Expand Down

0 comments on commit 5c0ab15

Please sign in to comment.