@@ -289,6 +289,9 @@ protected function get_all_items() {
289289 * [--all]
290290 * : If set, all plugins will be activated.
291291 *
292+ * [--exclude=<name>]
293+ * : Comma separated list of plugin slugs to be excluded from activation.
294+ *
292295 * [--network]
293296 * : If set, the plugin will be activated for the entire multisite network.
294297 *
@@ -307,8 +310,9 @@ protected function get_all_items() {
307310 public function activate ( $ args , $ assoc_args = array () ) {
308311 $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
309312 $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
313+ $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' );
310314
311- $ args = $ this ->check_optional_args_and_all ( $ args , $ all );
315+ $ args = $ this ->check_optional_args_and_all ( $ args , $ all, ' activate ' , $ all_exclude );
312316 if ( ! $ args ) {
313317 return ;
314318 }
@@ -375,6 +379,9 @@ public function activate( $args, $assoc_args = array() ) {
375379 * [--all]
376380 * : If set, all plugins will be deactivated.
377381 *
382+ * [--exclude=<name>]
383+ * : Comma separated list of plugin slugs that should be excluded from deactivation.
384+ *
378385 * [--network]
379386 * : If set, the plugin will be deactivated for the entire multisite network.
380387 *
@@ -384,12 +391,19 @@ public function activate( $args, $assoc_args = array() ) {
384391 * $ wp plugin deactivate hello
385392 * Plugin 'hello' deactivated.
386393 * Success: Deactivated 1 of 1 plugins.
394+ *
395+ * # Deactivate all plugins with exclusion
396+ * $ wp plugin deactivate --all --exclude=hello,wordpress-seo
397+ * Plugin 'contact-form-7' deactivated.
398+ * Plugin 'ninja-forms' deactivated.
399+ * Success: Deactivated 2 of 2 plugins.
387400 */
388401 public function deactivate ( $ args , $ assoc_args = array () ) {
389- $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
390- $ disable_all = Utils \get_flag_value ( $ assoc_args , 'all ' );
402+ $ network_wide = Utils \get_flag_value ( $ assoc_args , 'network ' );
403+ $ disable_all = Utils \get_flag_value ( $ assoc_args , 'all ' );
404+ $ disable_all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' );
391405
392- $ args = $ this ->check_optional_args_and_all ( $ args , $ disable_all );
406+ $ args = $ this ->check_optional_args_and_all ( $ args , $ disable_all, ' deactivate ' , $ disable_all_exclude );
393407 if ( ! $ args ) {
394408 return ;
395409 }
@@ -891,18 +905,28 @@ public function get( $args, $assoc_args ) {
891905 * [--all]
892906 * : If set, all plugins will be uninstalled.
893907 *
908+ * [--exclude=<name>]
909+ * : Comma separated list of plugin slugs to be excluded from uninstall.
910+ *
894911 * ## EXAMPLES
895912 *
896913 * $ wp plugin uninstall hello
897914 * Uninstalled and deleted 'hello' plugin.
898915 * Success: Uninstalled 1 of 1 plugins.
916+ *
917+ * # Uninstall all plugins excluding specified ones
918+ * $ wp plugin uninstall --all --exclude=hello-dolly,jetpack
919+ * Uninstalled and deleted 'akismet' plugin.
920+ * Uninstalled and deleted 'tinymce-templates' plugin.
921+ * Success: Uninstalled 2 of 2 plugins.
899922 */
900923 public function uninstall ( $ args , $ assoc_args = array () ) {
901924
902- $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
925+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
926+ $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , false );
903927
904928 // Check if plugin names or --all is passed.
905- $ args = $ this ->check_optional_args_and_all ( $ args , $ all , 'uninstall ' );
929+ $ args = $ this ->check_optional_args_and_all ( $ args , $ all , 'uninstall ' , $ all_exclude );
906930 if ( ! $ args ) {
907931 return ;
908932 }
@@ -1014,6 +1038,9 @@ public function is_active( $args, $assoc_args = array() ) {
10141038 * [--all]
10151039 * : If set, all plugins will be deleted.
10161040 *
1041+ * [--exclude=<name>]
1042+ * : Comma separated list of plugin slugs to be excluded from deletion.
1043+ *
10171044 * ## EXAMPLES
10181045 *
10191046 * # Delete plugin
@@ -1025,12 +1052,19 @@ public function is_active( $args, $assoc_args = array() ) {
10251052 * $ wp plugin delete $(wp plugin list --status=inactive --field=name)
10261053 * Deleted 'tinymce-templates' plugin.
10271054 * Success: Deleted 1 of 1 plugins.
1055+ *
1056+ * # Delete all plugins excluding specified ones
1057+ * $ wp plugin delete --all --exclude=hello-dolly,jetpack
1058+ * Deleted 'akismet' plugin.
1059+ * Deleted 'tinymce-templates' plugin.
1060+ * Success: Deleted 2 of 2 plugins.
10281061 */
10291062 public function delete ( $ args , $ assoc_args = array () ) {
1030- $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
1063+ $ all = Utils \get_flag_value ( $ assoc_args , 'all ' , false );
1064+ $ all_exclude = Utils \get_flag_value ( $ assoc_args , 'exclude ' , false );
10311065
10321066 // Check if plugin names or --all is passed.
1033- $ args = $ this ->check_optional_args_and_all ( $ args , $ all , 'delete ' );
1067+ $ args = $ this ->check_optional_args_and_all ( $ args , $ all , 'delete ' , $ all_exclude );
10341068 if ( ! $ args ) {
10351069 return ;
10361070 }
0 commit comments