From e6f305124732f5b4e26802309dc2732197d04c9b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 16:10:49 +0000 Subject: [PATCH 1/8] Initial plan From cd83498a90f7930a596335fe0366adbf1467b199 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 16:24:30 +0000 Subject: [PATCH 2/8] Add check-update commands for plugins and themes Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- composer.json | 2 + features/plugin-check-update.feature | 121 +++++++++++++++++++++++++++ features/theme-check-update.feature | 114 +++++++++++++++++++++++++ src/Plugin_Command.php | 93 ++++++++++++++++++++ src/Theme_Command.php | 93 ++++++++++++++++++++ 5 files changed, 423 insertions(+) create mode 100644 features/plugin-check-update.feature create mode 100644 features/theme-check-update.feature diff --git a/composer.json b/composer.json index 4827a65c..108e74c1 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,7 @@ "plugin path", "plugin search", "plugin status", + "plugin check-update", "plugin toggle", "plugin uninstall", "plugin update", @@ -73,6 +74,7 @@ "theme path", "theme search", "theme status", + "theme check-update", "theme update", "theme mod list" ] diff --git a/features/plugin-check-update.feature b/features/plugin-check-update.feature new file mode 100644 index 00000000..c4f9bb71 --- /dev/null +++ b/features/plugin-check-update.feature @@ -0,0 +1,121 @@ +Feature: Check for plugin updates + + @require-wp-5.2 + Scenario: Check for plugin updates with no updates available + Given a WP install + + When I run `wp plugin install wordpress-importer --activate` + Then STDOUT should not be empty + + When I run `wp plugin check-update` + Then STDOUT should contain: + """ + Success: All plugins are up to date. + """ + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for plugin updates with updates available + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5 --activate` + Then STDOUT should not be empty + + When I run `wp plugin check-update` + Then STDOUT should be a table containing rows: + | name | status | version | + | wordpress-importer | active | 0.5 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for specific plugin updates + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5` + Then STDOUT should not be empty + + When I run `wp plugin install akismet` + Then STDOUT should not be empty + + When I run `wp plugin check-update wordpress-importer` + Then STDOUT should be a table containing rows: + | name | status | version | + | wordpress-importer | inactive | 0.5 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for all plugin updates with --all flag + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5 --activate` + Then STDOUT should not be empty + + When I run `wp plugin check-update --all` + Then STDOUT should be a table containing rows: + | name | status | version | + | wordpress-importer | active | 0.5 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for plugin updates in different output formats + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5` + Then STDOUT should not be empty + + When I run `wp plugin check-update --format=json` + Then STDOUT should be JSON containing: + """ + [{"name":"wordpress-importer","status":"inactive","version":"0.5"}] + """ + And the return code should be 0 + + When I run `wp plugin check-update --format=csv` + Then STDOUT should contain: + """ + name,status,version,update_version + """ + And STDOUT should contain: + """ + wordpress-importer,inactive,0.5 + """ + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for plugin updates with custom fields + Given a WP install + + When I run `wp plugin install wordpress-importer --version=0.5` + Then STDOUT should not be empty + + When I run `wp plugin check-update --fields=name,version` + Then STDOUT should be a table containing rows: + | name | version | + | wordpress-importer | 0.5 | + And the return code should be 0 + + @require-wp-5.2 + Scenario: Check for plugin updates when no specific plugin has updates + Given a WP install + + When I run `wp plugin install wordpress-importer` + Then STDOUT should not be empty + + When I run `wp plugin check-update wordpress-importer` + Then STDOUT should contain: + """ + Success: All plugins are up to date. + """ + And the return code should be 0 diff --git a/features/theme-check-update.feature b/features/theme-check-update.feature new file mode 100644 index 00000000..77522553 --- /dev/null +++ b/features/theme-check-update.feature @@ -0,0 +1,114 @@ +Feature: Check for theme updates + + Scenario: Check for theme updates with no updates available + Given a WP install + + When I run `wp theme install twentytwelve` + Then STDOUT should not be empty + + When I run `wp theme check-update` + Then STDOUT should contain: + """ + Success: All themes are up to date. + """ + And the return code should be 0 + + Scenario: Check for theme updates with updates available + Given a WP install + + When I run `wp theme install twentyfourteen --version=1.0` + Then STDOUT should not be empty + + When I run `wp theme check-update` + Then STDOUT should be a table containing rows: + | name | status | version | + | twentyfourteen | inactive | 1.0 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + Scenario: Check for specific theme updates + Given a WP install + + When I run `wp theme install twentyfourteen --version=1.0` + Then STDOUT should not be empty + + When I run `wp theme install twentytwelve` + Then STDOUT should not be empty + + When I run `wp theme check-update twentyfourteen` + Then STDOUT should be a table containing rows: + | name | status | version | + | twentyfourteen | inactive | 1.0 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + Scenario: Check for all theme updates with --all flag + Given a WP install + + When I run `wp theme install twentyfourteen --version=1.0` + Then STDOUT should not be empty + + When I run `wp theme check-update --all` + Then STDOUT should be a table containing rows: + | name | status | version | + | twentyfourteen | inactive | 1.0 | + And STDOUT should contain: + """ + update_version + """ + And the return code should be 0 + + Scenario: Check for theme updates in different output formats + Given a WP install + + When I run `wp theme install twentyfourteen --version=1.0` + Then STDOUT should not be empty + + When I run `wp theme check-update --format=json` + Then STDOUT should be JSON containing: + """ + [{"name":"twentyfourteen","status":"inactive","version":"1.0"}] + """ + And the return code should be 0 + + When I run `wp theme check-update --format=csv` + Then STDOUT should contain: + """ + name,status,version,update_version + """ + And STDOUT should contain: + """ + twentyfourteen,inactive,1.0 + """ + And the return code should be 0 + + Scenario: Check for theme updates with custom fields + Given a WP install + + When I run `wp theme install twentyfourteen --version=1.0` + Then STDOUT should not be empty + + When I run `wp theme check-update --fields=name,version` + Then STDOUT should be a table containing rows: + | name | version | + | twentyfourteen | 1.0 | + And the return code should be 0 + + Scenario: Check for theme updates when no specific theme has updates + Given a WP install + + When I run `wp theme install twentytwelve` + Then STDOUT should not be empty + + When I run `wp theme check-update twentytwelve` + Then STDOUT should contain: + """ + Success: All themes are up to date. + """ + And the return code should be 0 diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index ef5b061f..52a258c1 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -115,6 +115,99 @@ public function status( $args ) { parent::status( $args ); } + /** + * Checks for plugin updates without performing them. + * + * Lists the available plugin updates. Similar to `wp core check-update`. + * + * ## OPTIONS + * + * [...] + * : One or more plugins to check for updates. + * + * [--all] + * : If set, all plugins will be checked for updates. + * + * [--field=] + * : Prints the value of a single field for each update. + * + * [--fields=] + * : Limit the output to specific object fields. Defaults to name,status,version,update_version. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * --- + * + * ## EXAMPLES + * + * # Check for plugin updates + * $ wp plugin check-update + * +-----------+--------+---------+----------------+ + * | name | status | version | update_version | + * +-----------+--------+---------+----------------+ + * | akismet | active | 4.1.0 | 4.1.1 | + * +-----------+--------+---------+----------------+ + * + * # List plugins with available updates in JSON format + * $ wp plugin check-update --format=json + * [{"name":"akismet","status":"active","version":"4.1.0","update_version":"4.1.1"}] + */ + public function check_update( $args, $assoc_args ) { + // Force WordPress to check for updates. + call_user_func( $this->upgrade_refresh ); + + $all = Utils\get_flag_value( $assoc_args, 'all', false ); + + if ( $all ) { + $args = array_map( + function ( $file ) { + return Utils\get_plugin_name( $file ); + }, + array_keys( $this->get_all_plugins() ) + ); + } + + $items = $this->get_item_list(); + + // Filter to only plugins with available updates + $items_with_updates = array_filter( + $items, + function ( $item ) { + return 'available' === $item['update']; + } + ); + + // If specific plugins requested, filter to those + if ( ! empty( $args ) ) { + $items_with_updates = array_filter( + $items_with_updates, + function ( $item ) use ( $args ) { + return in_array( $item['name'], $args, true ); + } + ); + } + + if ( empty( $items_with_updates ) ) { + WP_CLI::success( 'All plugins are up to date.' ); + return; + } + + // Set default fields for check-update output + if ( ! isset( $assoc_args['fields'] ) ) { + $assoc_args['fields'] = 'name,status,version,update_version'; + } + + $formatter = $this->get_formatter( $assoc_args ); + $formatter->display_items( array_values( $items_with_updates ) ); + } + /** * Searches the WordPress.org plugin directory. * diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 5ae8459f..cae5dcc2 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -108,6 +108,99 @@ public function status( $args ) { parent::status( $args ); } + /** + * Checks for theme updates without performing them. + * + * Lists the available theme updates. Similar to `wp core check-update`. + * + * ## OPTIONS + * + * [...] + * : One or more themes to check for updates. + * + * [--all] + * : If set, all themes will be checked for updates. + * + * [--field=] + * : Prints the value of a single field for each update. + * + * [--fields=] + * : Limit the output to specific object fields. Defaults to name,status,version,update_version. + * + * [--format=] + * : Render output in a particular format. + * --- + * default: table + * options: + * - table + * - csv + * - json + * - yaml + * --- + * + * ## EXAMPLES + * + * # Check for theme updates + * $ wp theme check-update + * +------------+----------+---------+----------------+ + * | name | status | version | update_version | + * +------------+----------+---------+----------------+ + * | twentytwelve | inactive | 2.0 | 2.1 | + * +------------+----------+---------+----------------+ + * + * # List themes with available updates in JSON format + * $ wp theme check-update --format=json + * [{"name":"twentytwelve","status":"inactive","version":"2.0","update_version":"2.1"}] + */ + public function check_update( $args, $assoc_args ) { + // Force WordPress to check for updates. + call_user_func( $this->upgrade_refresh ); + + $all = Utils\get_flag_value( $assoc_args, 'all', false ); + + if ( $all ) { + $args = array_map( + function ( $theme ) { + return $theme->get_stylesheet(); + }, + $this->get_all_themes() + ); + } + + $items = $this->get_item_list(); + + // Filter to only themes with available updates + $items_with_updates = array_filter( + $items, + function ( $item ) { + return 'available' === $item['update']; + } + ); + + // If specific themes requested, filter to those + if ( ! empty( $args ) ) { + $items_with_updates = array_filter( + $items_with_updates, + function ( $item ) use ( $args ) { + return in_array( $item['name'], $args, true ); + } + ); + } + + if ( empty( $items_with_updates ) ) { + WP_CLI::success( 'All themes are up to date.' ); + return; + } + + // Set default fields for check-update output + if ( ! isset( $assoc_args['fields'] ) ) { + $assoc_args['fields'] = 'name,status,version,update_version'; + } + + $formatter = $this->get_formatter( $assoc_args ); + $formatter->display_items( array_values( $items_with_updates ) ); + } + /** * Searches the WordPress.org theme directory. * From da431b3dcc83001861d8d946e158619c460f3443 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 16:25:53 +0000 Subject: [PATCH 3/8] Fix trailing whitespace in check-update methods Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Plugin_Command.php | 2 +- src/Theme_Command.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 52a258c1..a3ad36e3 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -175,7 +175,7 @@ function ( $file ) { } $items = $this->get_item_list(); - + // Filter to only plugins with available updates $items_with_updates = array_filter( $items, diff --git a/src/Theme_Command.php b/src/Theme_Command.php index cae5dcc2..a306fe54 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -168,7 +168,7 @@ function ( $theme ) { } $items = $this->get_item_list(); - + // Filter to only themes with available updates $items_with_updates = array_filter( $items, From 0f4b688146b2c0328094f40fd6af82b5787542c2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 9 Nov 2025 11:29:33 +0000 Subject: [PATCH 4/8] Add @subcommand check-update annotations Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- src/Plugin_Command.php | 2 ++ src/Theme_Command.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index a3ad36e3..7b2c8572 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -158,6 +158,8 @@ public function status( $args ) { * # List plugins with available updates in JSON format * $ wp plugin check-update --format=json * [{"name":"akismet","status":"active","version":"4.1.0","update_version":"4.1.1"}] + * + * @subcommand check-update */ public function check_update( $args, $assoc_args ) { // Force WordPress to check for updates. diff --git a/src/Theme_Command.php b/src/Theme_Command.php index a306fe54..9eacabdd 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -151,6 +151,8 @@ public function status( $args ) { * # List themes with available updates in JSON format * $ wp theme check-update --format=json * [{"name":"twentytwelve","status":"inactive","version":"2.0","update_version":"2.1"}] + * + * @subcommand check-update */ public function check_update( $args, $assoc_args ) { // Force WordPress to check for updates. From 68cb95cf04f126fa5433282fc5988fef326cbe3b Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 16:34:45 +0100 Subject: [PATCH 5/8] Fix tests --- features/plugin-check-update.feature | 73 +++++++++------------------- features/theme-check-update.feature | 68 +++++++++----------------- src/Plugin_Command.php | 7 +++ src/Theme_Command.php | 16 +++--- 4 files changed, 57 insertions(+), 107 deletions(-) diff --git a/features/plugin-check-update.feature b/features/plugin-check-update.feature index c4f9bb71..2d01fed0 100644 --- a/features/plugin-check-update.feature +++ b/features/plugin-check-update.feature @@ -7,29 +7,28 @@ Feature: Check for plugin updates When I run `wp plugin install wordpress-importer --activate` Then STDOUT should not be empty - When I run `wp plugin check-update` + When I run `wp plugin check-update --all` Then STDOUT should contain: """ Success: All plugins are up to date. """ - And the return code should be 0 - @require-wp-5.2 - Scenario: Check for plugin updates with updates available - Given a WP install + When I run `wp plugin check-update wordpress-importer` + Then STDOUT should contain: + """ + Success: All plugins are up to date. + """ - When I run `wp plugin install wordpress-importer --version=0.5 --activate` - Then STDOUT should not be empty + Scenario: Check for plugin updates should throw an error unless --all given + Given a WP install - When I run `wp plugin check-update` - Then STDOUT should be a table containing rows: - | name | status | version | - | wordpress-importer | active | 0.5 | - And STDOUT should contain: + When I try `wp plugin check-update` + Then the return code should be 1 + And STDERR should be: """ - update_version + Error: Please specify one or more plugins, or use --all. """ - And the return code should be 0 + And STDOUT should be empty @require-wp-5.2 Scenario: Check for specific plugin updates @@ -38,18 +37,11 @@ Feature: Check for plugin updates When I run `wp plugin install wordpress-importer --version=0.5` Then STDOUT should not be empty - When I run `wp plugin install akismet` - Then STDOUT should not be empty - - When I run `wp plugin check-update wordpress-importer` - Then STDOUT should be a table containing rows: - | name | status | version | - | wordpress-importer | inactive | 0.5 | - And STDOUT should contain: + When I run `wp plugin check-update wordpress-importer --format=csv` + Then STDOUT should contain: """ - update_version + wordpress-importer,inactive,0.5, """ - And the return code should be 0 @require-wp-5.2 Scenario: Check for all plugin updates with --all flag @@ -58,15 +50,11 @@ Feature: Check for plugin updates When I run `wp plugin install wordpress-importer --version=0.5 --activate` Then STDOUT should not be empty - When I run `wp plugin check-update --all` - Then STDOUT should be a table containing rows: - | name | status | version | - | wordpress-importer | active | 0.5 | - And STDOUT should contain: + When I run `wp plugin check-update --all --format=csv` + Then STDOUT should contain: """ - update_version + wordpress-importer,active,0.5, """ - And the return code should be 0 @require-wp-5.2 Scenario: Check for plugin updates in different output formats @@ -75,14 +63,13 @@ Feature: Check for plugin updates When I run `wp plugin install wordpress-importer --version=0.5` Then STDOUT should not be empty - When I run `wp plugin check-update --format=json` + When I run `wp plugin check-update wordpress-importer --format=json` Then STDOUT should be JSON containing: """ [{"name":"wordpress-importer","status":"inactive","version":"0.5"}] """ - And the return code should be 0 - When I run `wp plugin check-update --format=csv` + When I run `wp plugin check-update wordpress-importer --format=csv` Then STDOUT should contain: """ name,status,version,update_version @@ -91,7 +78,6 @@ Feature: Check for plugin updates """ wordpress-importer,inactive,0.5 """ - And the return code should be 0 @require-wp-5.2 Scenario: Check for plugin updates with custom fields @@ -100,22 +86,7 @@ Feature: Check for plugin updates When I run `wp plugin install wordpress-importer --version=0.5` Then STDOUT should not be empty - When I run `wp plugin check-update --fields=name,version` + When I run `wp plugin check-update wordpress-importer --fields=name,version` Then STDOUT should be a table containing rows: | name | version | | wordpress-importer | 0.5 | - And the return code should be 0 - - @require-wp-5.2 - Scenario: Check for plugin updates when no specific plugin has updates - Given a WP install - - When I run `wp plugin install wordpress-importer` - Then STDOUT should not be empty - - When I run `wp plugin check-update wordpress-importer` - Then STDOUT should contain: - """ - Success: All plugins are up to date. - """ - And the return code should be 0 diff --git a/features/theme-check-update.feature b/features/theme-check-update.feature index 77522553..864fe22b 100644 --- a/features/theme-check-update.feature +++ b/features/theme-check-update.feature @@ -6,28 +6,28 @@ Feature: Check for theme updates When I run `wp theme install twentytwelve` Then STDOUT should not be empty - When I run `wp theme check-update` + When I run `wp theme check-update --all` Then STDOUT should contain: """ Success: All themes are up to date. """ - And the return code should be 0 - Scenario: Check for theme updates with updates available - Given a WP install + When I run `wp theme check-update twentytwelve` + Then STDOUT should contain: + """ + Success: All themes are up to date. + """ - When I run `wp theme install twentyfourteen --version=1.0` - Then STDOUT should not be empty + Scenario: Check for theme updates should throw an error unless --all given + Given a WP install - When I run `wp theme check-update` - Then STDOUT should be a table containing rows: - | name | status | version | - | twentyfourteen | inactive | 1.0 | - And STDOUT should contain: + When I try `wp theme check-update` + Then the return code should be 1 + And STDERR should be: """ - update_version + Error: Please specify one or more themes, or use --all. """ - And the return code should be 0 + And STDOUT should be empty Scenario: Check for specific theme updates Given a WP install @@ -38,15 +38,11 @@ Feature: Check for theme updates When I run `wp theme install twentytwelve` Then STDOUT should not be empty - When I run `wp theme check-update twentyfourteen` - Then STDOUT should be a table containing rows: - | name | status | version | - | twentyfourteen | inactive | 1.0 | - And STDOUT should contain: + When I run `wp theme check-update twentyfourteen --format=csv` + Then STDOUT should contain: """ - update_version + twentyfourteen,inactive,1.0, """ - And the return code should be 0 Scenario: Check for all theme updates with --all flag Given a WP install @@ -54,15 +50,11 @@ Feature: Check for theme updates When I run `wp theme install twentyfourteen --version=1.0` Then STDOUT should not be empty - When I run `wp theme check-update --all` - Then STDOUT should be a table containing rows: - | name | status | version | - | twentyfourteen | inactive | 1.0 | - And STDOUT should contain: + When I run `wp theme check-update --all --format=csv` + Then STDOUT should contain: """ - update_version + twentyfourteen,inactive,1.0, """ - And the return code should be 0 Scenario: Check for theme updates in different output formats Given a WP install @@ -70,14 +62,13 @@ Feature: Check for theme updates When I run `wp theme install twentyfourteen --version=1.0` Then STDOUT should not be empty - When I run `wp theme check-update --format=json` + When I run `wp theme check-update twentyfourteen --format=json` Then STDOUT should be JSON containing: """ [{"name":"twentyfourteen","status":"inactive","version":"1.0"}] """ - And the return code should be 0 - When I run `wp theme check-update --format=csv` + When I run `wp theme check-update twentyfourteen --format=csv` Then STDOUT should contain: """ name,status,version,update_version @@ -86,7 +77,6 @@ Feature: Check for theme updates """ twentyfourteen,inactive,1.0 """ - And the return code should be 0 Scenario: Check for theme updates with custom fields Given a WP install @@ -94,21 +84,7 @@ Feature: Check for theme updates When I run `wp theme install twentyfourteen --version=1.0` Then STDOUT should not be empty - When I run `wp theme check-update --fields=name,version` + When I run `wp theme check-update twentyfourteen --fields=name,version` Then STDOUT should be a table containing rows: | name | version | | twentyfourteen | 1.0 | - And the return code should be 0 - - Scenario: Check for theme updates when no specific theme has updates - Given a WP install - - When I run `wp theme install twentytwelve` - Then STDOUT should not be empty - - When I run `wp theme check-update twentytwelve` - Then STDOUT should contain: - """ - Success: All themes are up to date. - """ - And the return code should be 0 diff --git a/src/Plugin_Command.php b/src/Plugin_Command.php index 7b2c8572..ec4ea59f 100644 --- a/src/Plugin_Command.php +++ b/src/Plugin_Command.php @@ -162,6 +162,13 @@ public function status( $args ) { * @subcommand check-update */ public function check_update( $args, $assoc_args ) { + $all = Utils\get_flag_value( $assoc_args, 'all', false ); + + $args = $this->check_optional_args_and_all( $args, $all ); + if ( ! $args ) { + return; + } + // Force WordPress to check for updates. call_user_func( $this->upgrade_refresh ); diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 9eacabdd..318ffa73 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -155,20 +155,16 @@ public function status( $args ) { * @subcommand check-update */ public function check_update( $args, $assoc_args ) { - // Force WordPress to check for updates. - call_user_func( $this->upgrade_refresh ); - $all = Utils\get_flag_value( $assoc_args, 'all', false ); - if ( $all ) { - $args = array_map( - function ( $theme ) { - return $theme->get_stylesheet(); - }, - $this->get_all_themes() - ); + $args = $this->check_optional_args_and_all( $args, $all ); + if ( ! $args ) { + return; } + // Force WordPress to check for updates. + call_user_func( $this->upgrade_refresh ); + $items = $this->get_item_list(); // Filter to only themes with available updates From 7c89401fb85065ab701372ebd61ef84a1620c83e Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 16:37:29 +0100 Subject: [PATCH 6/8] PHPStan fix --- src/Theme_Command.php | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/Theme_Command.php b/src/Theme_Command.php index 318ffa73..0eda7416 100644 --- a/src/Theme_Command.php +++ b/src/Theme_Command.php @@ -170,21 +170,11 @@ public function check_update( $args, $assoc_args ) { // Filter to only themes with available updates $items_with_updates = array_filter( $items, - function ( $item ) { - return 'available' === $item['update']; + function ( $item ) use ( $args ) { + return in_array( $item['name'], $args, true ) && 'available' === $item['update']; } ); - // If specific themes requested, filter to those - if ( ! empty( $args ) ) { - $items_with_updates = array_filter( - $items_with_updates, - function ( $item ) use ( $args ) { - return in_array( $item['name'], $args, true ); - } - ); - } - if ( empty( $items_with_updates ) ) { WP_CLI::success( 'All themes are up to date.' ); return; From 5102cceabef0126c951c28abc506105b31de9184 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 17:10:58 +0100 Subject: [PATCH 7/8] Force install theme --- features/theme-check-update.feature | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/features/theme-check-update.feature b/features/theme-check-update.feature index 864fe22b..7c88fdd0 100644 --- a/features/theme-check-update.feature +++ b/features/theme-check-update.feature @@ -32,7 +32,7 @@ Feature: Check for theme updates Scenario: Check for specific theme updates Given a WP install - When I run `wp theme install twentyfourteen --version=1.0` + When I run `wp theme install twentyfourteen --version=1.0 --force` Then STDOUT should not be empty When I run `wp theme install twentytwelve` @@ -47,7 +47,7 @@ Feature: Check for theme updates Scenario: Check for all theme updates with --all flag Given a WP install - When I run `wp theme install twentyfourteen --version=1.0` + When I run `wp theme install twentyfourteen --version=1.0 --force` Then STDOUT should not be empty When I run `wp theme check-update --all --format=csv` @@ -59,7 +59,7 @@ Feature: Check for theme updates Scenario: Check for theme updates in different output formats Given a WP install - When I run `wp theme install twentyfourteen --version=1.0` + When I run `wp theme install twentyfourteen --version=1.0 --force` Then STDOUT should not be empty When I run `wp theme check-update twentyfourteen --format=json` @@ -81,7 +81,7 @@ Feature: Check for theme updates Scenario: Check for theme updates with custom fields Given a WP install - When I run `wp theme install twentyfourteen --version=1.0` + When I run `wp theme install twentyfourteen --version=1.0 --force` Then STDOUT should not be empty When I run `wp theme check-update twentyfourteen --fields=name,version` From 50d893a2b457b97ecf277313fc2914f2a8156fcd Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 10 Nov 2025 18:23:17 +0100 Subject: [PATCH 8/8] Fix more tests --- features/theme-check-update.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/theme-check-update.feature b/features/theme-check-update.feature index 7c88fdd0..e190bc6f 100644 --- a/features/theme-check-update.feature +++ b/features/theme-check-update.feature @@ -3,7 +3,7 @@ Feature: Check for theme updates Scenario: Check for theme updates with no updates available Given a WP install - When I run `wp theme install twentytwelve` + When I run `wp theme install twentytwelve --force` Then STDOUT should not be empty When I run `wp theme check-update --all` @@ -35,7 +35,7 @@ Feature: Check for theme updates When I run `wp theme install twentyfourteen --version=1.0 --force` Then STDOUT should not be empty - When I run `wp theme install twentytwelve` + When I run `wp theme install twentytwelve --force` Then STDOUT should not be empty When I run `wp theme check-update twentyfourteen --format=csv`