Skip to content

Commit 2e81665

Browse files
committed
Merge branch 'main' into copilot/add-plugin-theme-language-update-check
2 parents a6cd761 + a6ef00a commit 2e81665

8 files changed

Lines changed: 304 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
253253
**OPTIONS**
254254

255255
<plugin|zip|url>...
256-
One or more plugins to install. Accepts a plugin slug, the path to a local zip file, a URL to a remote zip file, or a URL to a WordPress.org plugin directory.
256+
One or more plugins to install. Accepts a plugin slug, the path to a local zip file, a URL to a remote zip file or PHP file, or a URL to a WordPress.org plugin directory.
257257

258258
[--version=<version>]
259259
If set, get that particular version from wordpress.org, instead of the
@@ -336,6 +336,11 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
336336
Plugin updated successfully
337337
Success: Installed 1 of 1 plugins.
338338

339+
# Install from a remote PHP file
340+
$ wp plugin install https://example.com/my-plugin.php
341+
Installing My Plugin (1.0.0)
342+
Downloading plugin file from https://example.com/my-plugin.php...
343+
339344
# Install a plugin with all its dependencies
340345
$ wp plugin install my-plugin --with-dependencies
341346
Installing Required Plugin 1 (1.2.3)

features/plugin-update.feature

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,94 @@ Feature: Update WordPress plugins
268268
Success: Updated 1 of 1 plugins (1 skipped).
269269
"""
270270

271+
# Tests for --auto-update-indicated feature
272+
# Note: These tests verify the flag handling and error cases.
273+
# The actual update behavior when autoupdate is true from the server
274+
# cannot be easily tested as it requires mocking WordPress.org API responses.
275+
# The update functionality itself is handled by the existing update_many method.
276+
277+
@require-wp-5.2
278+
Scenario: Show auto_update_indicated field in plugin list
279+
Given a WP install
280+
281+
When I run `wp plugin install wordpress-importer --version=0.5 --force`
282+
Then STDOUT should not be empty
283+
284+
When I run `wp plugin list --fields=name,version,update,auto_update_indicated`
285+
Then STDOUT should be a table containing rows:
286+
| name | version | update | auto_update_indicated |
287+
| wordpress-importer | 0.5 | available | no |
288+
289+
@require-wp-5.2
290+
Scenario: Using --auto-update-indicated flag when no plugins have auto-update indicated
291+
Given a WP install
292+
293+
When I run `wp plugin install wordpress-importer --version=0.5 --force`
294+
Then STDOUT should not be empty
295+
296+
When I run `wp plugin update --auto-update-indicated`
297+
Then STDOUT should be:
298+
"""
299+
Success: No plugins with server-indicated automatic updates available.
300+
"""
301+
302+
@require-wp-5.2
303+
Scenario: Error when using --version with --auto-update-indicated
304+
Given a WP install
305+
306+
When I try `wp plugin update --auto-update-indicated --version=1.0.0`
307+
Then STDERR should be:
308+
"""
309+
Error: Cannot use --version with --auto-update-indicated. The version is determined by the server.
310+
"""
311+
And the return code should be 1
312+
313+
@require-wp-5.2
314+
Scenario: Error when using --minor with --auto-update-indicated
315+
Given a WP install
316+
317+
When I try `wp plugin update --auto-update-indicated --minor`
318+
Then STDERR should be:
319+
"""
320+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
321+
"""
322+
And the return code should be 1
323+
324+
@require-wp-5.2
325+
Scenario: Error when using --patch with --auto-update-indicated
326+
Given a WP install
327+
328+
When I try `wp plugin update --auto-update-indicated --patch`
329+
Then STDERR should be:
330+
"""
331+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
332+
"""
333+
And the return code should be 1
334+
335+
@require-wp-5.2
336+
Scenario: Error when specifying plugin names with --auto-update-indicated
337+
Given a WP install
338+
339+
When I try `wp plugin update akismet --auto-update-indicated`
340+
Then STDERR should be:
341+
"""
342+
Error: Cannot specify plugin names with --auto-update-indicated. This flag updates all plugins with server-indicated automatic updates.
343+
"""
344+
And the return code should be 1
345+
346+
@require-wp-5.2
347+
Scenario: Preview updates with --auto-update-indicated and --dry-run
348+
Given a WP install
349+
350+
When I run `wp plugin install wordpress-importer --version=0.5 --force`
351+
Then STDOUT should not be empty
352+
353+
When I run `wp plugin update --auto-update-indicated --dry-run`
354+
Then STDOUT should be:
355+
"""
356+
Success: No plugins with server-indicated automatic updates available.
357+
"""
358+
271359
@require-wp-5.2
272360
Scenario: Updating all plugins should show the name of each plugin as it is updated
273361
Given a WP install

features/plugin.feature

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,44 @@ Feature: Manage WordPress plugins
298298
"""
299299
And the return code should be 0
300300

301+
@require-wp-5.2
302+
Scenario: Network activate all plugins when some are already active on a single site
303+
Given a WP multisite install
304+
And I run `wp plugin delete --all`
305+
306+
When I run `wp plugin install debug-bar`
307+
And I run `wp plugin install wordpress-importer --activate`
308+
Then STDOUT should contain:
309+
"""
310+
Plugin 'wordpress-importer' activated.
311+
"""
312+
313+
When I run `wp plugin list --fields=name,status`
314+
Then STDOUT should be a table containing rows:
315+
| name | status |
316+
| debug-bar | inactive |
317+
| wordpress-importer | active |
318+
319+
When I run `wp plugin activate --all --network`
320+
Then STDOUT should contain:
321+
"""
322+
Plugin 'debug-bar' network activated.
323+
"""
324+
And STDOUT should contain:
325+
"""
326+
Plugin 'wordpress-importer' network activated.
327+
"""
328+
And STDOUT should contain:
329+
"""
330+
Success: Network activated 2 of 2 plugins.
331+
"""
332+
333+
When I run `wp plugin list --fields=name,status`
334+
Then STDOUT should be a table containing rows:
335+
| name | status |
336+
| debug-bar | active-network |
337+
| wordpress-importer | active-network |
338+
301339
Scenario: List plugins
302340
Given a WP install
303341

features/theme-update.feature

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,87 @@ Feature: Update WordPress themes
155155
1.1.1
156156
"""
157157

158+
# Tests for --auto-update-indicated feature
159+
# Note: These tests verify the flag handling and error cases.
160+
# The actual update behavior when autoupdate is true from the server
161+
# cannot be easily tested as it requires mocking WordPress.org API responses.
162+
# The update functionality itself is handled by the existing update_many method.
163+
164+
Scenario: Show auto_update_indicated field in theme list
165+
Given a WP install
166+
167+
When I run `wp theme install twentytwelve --version=3.0 --force`
168+
Then STDOUT should not be empty
169+
170+
When I run `wp theme list --fields=name,version,update,auto_update_indicated`
171+
Then STDOUT should be a table containing rows:
172+
| name | version | update | auto_update_indicated |
173+
| twentytwelve | 3.0 | available | no |
174+
175+
Scenario: Using --auto-update-indicated flag when no themes have auto-update indicated
176+
Given a WP install
177+
178+
When I run `wp theme install twentytwelve --version=3.0 --force`
179+
Then STDOUT should not be empty
180+
181+
When I run `wp theme update --auto-update-indicated`
182+
Then STDOUT should be:
183+
"""
184+
Success: No themes with server-indicated automatic updates available.
185+
"""
186+
187+
Scenario: Error when using --version with --auto-update-indicated
188+
Given a WP install
189+
190+
When I try `wp theme update --auto-update-indicated --version=1.0.0`
191+
Then STDERR should be:
192+
"""
193+
Error: Cannot use --version with --auto-update-indicated. The version is determined by the server.
194+
"""
195+
And the return code should be 1
196+
197+
Scenario: Error when using --minor with --auto-update-indicated
198+
Given a WP install
199+
200+
When I try `wp theme update --auto-update-indicated --minor`
201+
Then STDERR should be:
202+
"""
203+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
204+
"""
205+
And the return code should be 1
206+
207+
Scenario: Error when using --patch with --auto-update-indicated
208+
Given a WP install
209+
210+
When I try `wp theme update --auto-update-indicated --patch`
211+
Then STDERR should be:
212+
"""
213+
Error: Cannot use --minor or --patch with --auto-update-indicated. The version is determined by the server.
214+
"""
215+
And the return code should be 1
216+
217+
Scenario: Error when specifying theme names with --auto-update-indicated
218+
Given a WP install
219+
220+
When I try `wp theme update twentytwelve --auto-update-indicated`
221+
Then STDERR should be:
222+
"""
223+
Error: Cannot specify theme names with --auto-update-indicated. This flag updates all themes with server-indicated automatic updates.
224+
"""
225+
And the return code should be 1
226+
227+
Scenario: Preview updates with --auto-update-indicated and --dry-run
228+
Given a WP install
229+
230+
When I run `wp theme install twentytwelve --version=3.0 --force`
231+
Then STDOUT should not be empty
232+
233+
When I run `wp theme update --auto-update-indicated --dry-run`
234+
Then STDOUT should be:
235+
"""
236+
Success: No themes with server-indicated automatic updates available.
237+
"""
238+
158239
@require-wp-4.5
159240
Scenario: Updating all themes should show the name of each theme as it is updated
160241
Given a WP install

src/Plugin_Command.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,9 @@ public function activate( $args, $assoc_args = [] ) {
477477
}
478478
foreach ( $plugins as $plugin ) {
479479
$status = $this->get_status( $plugin->file );
480-
if ( $all && ! $force && in_array( $status, [ 'active', 'active-network' ], true ) ) {
480+
// When using --all flag, skip plugins that are already in the target state.
481+
$skip_statuses = $network_wide ? array( 'active-network' ) : array( 'active', 'active-network' );
482+
if ( $all && ! $force && in_array( $status, $skip_statuses, true ) ) {
481483
continue;
482484
}
483485
// Network-active is the highest level of activation status.
@@ -820,6 +822,9 @@ protected function install_from_repo( $slug, $assoc_args ) {
820822
* [--insecure]
821823
* : Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
822824
*
825+
* [--auto-update-indicated]
826+
* : Only update plugins where the server response indicates an automatic update. Updates to the version indicated by the server, not necessarily the latest version. Cannot be used with `--version`, `--minor`, or `--patch`.
827+
*
823828
* ## EXAMPLES
824829
*
825830
* $ wp plugin update bbpress --version=dev
@@ -871,6 +876,11 @@ protected function install_from_repo( $slug, $assoc_args ) {
871876
public function update( $args, $assoc_args ) {
872877
$all = Utils\get_flag_value( $assoc_args, 'all', false );
873878

879+
// Handle --auto-update-indicated flag if present.
880+
if ( $this->handle_auto_update_indicated( $args, $assoc_args ) ) {
881+
return;
882+
}
883+
874884
$args = $this->check_optional_args_and_all( $args, $all );
875885
if ( ! $args ) {
876886
return;
@@ -919,8 +929,9 @@ protected function get_item_list() {
919929
$duplicate_names[ $name ] = array();
920930
}
921931

922-
$requires = isset( $update_info ) && isset( $update_info['requires'] ) ? $update_info['requires'] : null;
923-
$requires_php = isset( $update_info ) && isset( $update_info['requires_php'] ) ? $update_info['requires_php'] : null;
932+
$requires = isset( $update_info ) && isset( $update_info['requires'] ) ? $update_info['requires'] : null;
933+
$requires_php = isset( $update_info ) && isset( $update_info['requires_php'] ) ? $update_info['requires_php'] : null;
934+
$auto_update_indicated = isset( $update_info ) && isset( $update_info['autoupdate'] ) ? (bool) $update_info['autoupdate'] : false;
924935

925936
// If an update has requires_php set, check to see if the local version of PHP meets that requirement
926937
// The plugins update API already filters out plugins that don't meet WordPress requirements, but does not
@@ -962,6 +973,7 @@ protected function get_item_list() {
962973
'description' => wordwrap( $details['Description'] ),
963974
'file' => $file,
964975
'auto_update' => in_array( $file, $auto_updates, true ),
976+
'auto_update_indicated' => $auto_update_indicated,
965977
'author' => $details['Author'],
966978
'tested_up_to' => '',
967979
'requires' => $requires,
@@ -1888,6 +1900,7 @@ public function delete( $args, $assoc_args ) {
18881900
* * requires_php
18891901
* * wporg_status
18901902
* * wporg_last_updated
1903+
* * auto_update_indicated
18911904
*
18921905
* ## EXAMPLES
18931906
*

src/Theme_Command.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,9 @@ public function get( $args, $assoc_args ) {
786786
* [--insecure]
787787
* : Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
788788
*
789+
* [--auto-update-indicated]
790+
* : Only update themes where the server response indicates an automatic update. Updates to the version indicated by the server, not necessarily the latest version. Cannot be used with `--version`, `--minor`, or `--patch`.
791+
*
789792
* ## EXAMPLES
790793
*
791794
* # Update multiple themes
@@ -836,6 +839,11 @@ public function get( $args, $assoc_args ) {
836839
public function update( $args, $assoc_args ) {
837840
$all = Utils\get_flag_value( $assoc_args, 'all', false );
838841

842+
// Handle --auto-update-indicated flag if present.
843+
if ( $this->handle_auto_update_indicated( $args, $assoc_args ) ) {
844+
return;
845+
}
846+
839847
$args = $this->check_optional_args_and_all( $args, $all );
840848
if ( ! $args ) {
841849
return;
@@ -1040,6 +1048,7 @@ public function delete( $args, $assoc_args ) {
10401048
* * update_id
10411049
* * title
10421050
* * description
1051+
* * auto_update_indicated
10431052
*
10441053
* ## EXAMPLES
10451054
*

0 commit comments

Comments
 (0)