@@ -21,6 +21,8 @@ public function __construct() {
2121 add_action ( 'upgrader_process_complete ' , function () {
2222 remove_action ( 'upgrader_process_complete ' , array ( 'Language_Pack_Upgrader ' , 'async_upgrade ' ), 20 );
2323 }, 1 );
24+
25+ $ this ->fetcher = new \WP_CLI \Fetchers \Plugin ;
2426 }
2527
2628 abstract protected function get_upgrader_class ( $ force );
@@ -301,9 +303,29 @@ protected function update_many( $args, $assoc_args ) {
301303 $ items_to_update = self ::get_minor_or_patch_updates ( $ items_to_update , $ type );
302304 }
303305
306+ $ exclude = WP_CLI \Utils \get_flag_value ( $ assoc_args , 'exclude ' );
307+ if ( isset ( $ exclude ) ) {
308+ $ exclude_items = explode ( ', ' , trim ( $ assoc_args ['exclude ' ], ', ' ) );
309+ unset( $ assoc_args ['exclude ' ] );
310+ foreach ( $ exclude_items as $ item ) {
311+ if ( 'plugin ' === $ this ->item_type ) {
312+ $ plugin = $ this ->fetcher ->get ( $ item );
313+ unset( $ items_to_update [ $ plugin ->file ] );
314+ } elseif ( 'theme ' === $ this ->item_type ) {
315+ $ theme_root = get_theme_root () . '/ ' . $ item ;
316+ unset( $ items_to_update [ $ theme_root ] );
317+ }
318+ }
319+ }
320+
304321 if ( \WP_CLI \Utils \get_flag_value ( $ assoc_args , 'dry-run ' ) ) {
305322 if ( empty ( $ items_to_update ) ) {
306323 \WP_CLI ::log ( "No {$ this ->item_type } updates available. " );
324+
325+ if ( NULL !== $ exclude ) {
326+ \WP_CLI ::log ( "Skipped updates for: $ exclude " );
327+ }
328+
307329 return ;
308330 }
309331
@@ -319,6 +341,10 @@ protected function update_many( $args, $assoc_args ) {
319341 \WP_CLI \Utils \format_items ( 'table ' , $ items_to_update , array ( 'name ' , 'status ' , 'version ' , 'update_version ' ) );
320342 }
321343
344+ if ( NULL !== $ exclude ) {
345+ \WP_CLI ::log ( "Skipped updates for: $ exclude " );
346+ }
347+
322348 return ;
323349 }
324350
@@ -378,6 +404,9 @@ protected function update_many( $args, $assoc_args ) {
378404
379405 $ total_updated = Utils \get_flag_value ( $ assoc_args , 'all ' ) ? $ num_to_update : count ( $ args );
380406 Utils \report_batch_operation_results ( $ this ->item_type , 'update ' , $ total_updated , $ num_updated , $ errors );
407+ if ( NULL !== $ exclude ) {
408+ \WP_CLI ::log ( "Skipped updates for: $ exclude " );
409+ }
381410 }
382411
383412 protected function _list ( $ _ , $ assoc_args ) {
0 commit comments