Skip to content

Commit 85c39cb

Browse files
authored
Merge branch 'main' into copilot/fix-plugin-deactivation-after-update
2 parents 6a597e4 + c6618db commit 85c39cb

File tree

9 files changed

+698
-12
lines changed

9 files changed

+698
-12
lines changed

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ See the WordPress [Plugin Handbook](https://developer.wordpress.org/plugins/) de
5757
Activates one or more plugins.
5858

5959
~~~
60-
wp plugin activate [<plugin>...] [--all] [--exclude=<name>] [--network]
60+
wp plugin activate [<plugin>...] [--all] [--exclude=<name>] [--network] [--force]
6161
~~~
6262

6363
**OPTIONS**
@@ -74,6 +74,9 @@ wp plugin activate [<plugin>...] [--all] [--exclude=<name>] [--network]
7474
[--network]
7575
If set, the plugin will be activated for the entire multisite network.
7676

77+
[--force]
78+
If set, deactivates and reactivates the plugin to re-run activation hooks, even if already active.
79+
7780
**EXAMPLES**
7881

7982
# Activate plugin
@@ -98,6 +101,11 @@ wp plugin activate [<plugin>...] [--all] [--exclude=<name>] [--network]
98101
Plugin 'buddypress' network activated.
99102
Success: Activated 2 of 2 plugins.
100103

104+
# Force re-running activation hooks for an already active plugin.
105+
$ wp plugin activate hello --force
106+
Plugin 'hello' activated.
107+
Success: Activated 1 of 1 plugins.
108+
101109

102110

103111
### wp plugin deactivate
@@ -245,7 +253,7 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
245253
**OPTIONS**
246254

247255
<plugin|zip|url>...
248-
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.
249257

250258
[--version=<version>]
251259
If set, get that particular version from wordpress.org, instead of the
@@ -328,6 +336,11 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
328336
Plugin updated successfully
329337
Success: Installed 1 of 1 plugins.
330338

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+
331344
# Install a plugin with all its dependencies
332345
$ wp plugin install my-plugin --with-dependencies
333346
Installing Required Plugin 1 (1.2.3)
@@ -520,6 +533,7 @@ These fields are optionally available:
520533
* requires_php
521534
* wporg_status
522535
* wporg_last_updated
536+
* auto_update_indicated
523537

524538
**EXAMPLES**
525539

@@ -790,7 +804,7 @@ wp plugin uninstall [<plugin>...] [--deactivate] [--skip-delete] [--all] [--excl
790804
Updates one or more plugins.
791805

792806
~~~
793-
wp plugin update [<plugin>...] [--all] [--exclude=<name>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure]
807+
wp plugin update [<plugin>...] [--all] [--exclude=<name>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure] [--auto-update-indicated]
794808
~~~
795809

796810
**Alias:** `upgrade`
@@ -832,6 +846,9 @@ wp plugin update [<plugin>...] [--all] [--exclude=<name>] [--minor] [--patch] [-
832846
[--insecure]
833847
Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
834848

849+
[--auto-update-indicated]
850+
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`.
851+
835852
**EXAMPLES**
836853

837854
$ wp plugin update bbpress --version=dev
@@ -1261,6 +1278,7 @@ These fields are optionally available:
12611278
* update_id
12621279
* title
12631280
* description
1281+
* auto_update_indicated
12641282

12651283
**EXAMPLES**
12661284

@@ -1545,7 +1563,7 @@ wp theme status [<theme>]
15451563
Updates one or more themes.
15461564

15471565
~~~
1548-
wp theme update [<theme>...] [--all] [--exclude=<theme-names>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure]
1566+
wp theme update [<theme>...] [--all] [--exclude=<theme-names>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure] [--auto-update-indicated]
15491567
~~~
15501568

15511569
**Alias:** `upgrade`
@@ -1587,6 +1605,9 @@ wp theme update [<theme>...] [--all] [--exclude=<theme-names>] [--minor] [--patc
15871605
[--insecure]
15881606
Retry downloads without certificate validation if TLS handshake fails. Note: This makes the request vulnerable to a MITM attack.
15891607

1608+
[--auto-update-indicated]
1609+
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`.
1610+
15901611
**EXAMPLES**
15911612

15921613
# Update multiple themes

features/plugin-install.feature

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,99 @@ Feature: Install WordPress plugins
274274
Error: No plugins installed.
275275
"""
276276

277+
Scenario: Install plugin from a single PHP file URL
278+
Given a WP install
279+
280+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --activate`
281+
Then STDOUT should contain:
282+
"""
283+
Installing
284+
"""
285+
And STDOUT should contain:
286+
"""
287+
Downloading plugin file from
288+
"""
289+
And STDOUT should contain:
290+
"""
291+
Plugin installed successfully.
292+
"""
293+
And STDOUT should contain:
294+
"""
295+
Activating
296+
"""
297+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
298+
299+
When I run `wp plugin list --field=name`
300+
Then STDOUT should contain:
301+
"""
302+
pwa-manifest-short-name
303+
"""
304+
305+
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
306+
Then STDOUT should be:
307+
"""
308+
active
309+
"""
310+
311+
Scenario: Install plugin from a single PHP file URL with --force flag
312+
Given a WP install
313+
314+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
315+
Then STDOUT should contain:
316+
"""
317+
Plugin installed successfully.
318+
"""
319+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
320+
321+
When I try `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php`
322+
Then STDERR should contain:
323+
"""
324+
Warning: Plugin already installed.
325+
"""
326+
And STDOUT should contain:
327+
"""
328+
Success: Plugin already installed.
329+
"""
330+
331+
When I run `wp plugin install https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php --force`
332+
Then STDOUT should contain:
333+
"""
334+
Plugin installed successfully.
335+
"""
336+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
337+
338+
Scenario: Install plugin from a GitHub Gist page URL
339+
Given a WP install
340+
341+
When I run `wp plugin install https://gist.github.com/westonruter/dec7d190060732e29a09751ab99cc549 --activate`
342+
Then STDOUT should contain:
343+
"""
344+
Gist resolved to raw file URL.
345+
"""
346+
And STDOUT should contain:
347+
"""
348+
Installing
349+
"""
350+
And STDOUT should contain:
351+
"""
352+
Downloading plugin file from
353+
"""
354+
And STDOUT should contain:
355+
"""
356+
Plugin installed successfully.
357+
"""
358+
And STDOUT should contain:
359+
"""
360+
Activating
361+
"""
362+
And the wp-content/plugins/pwa-manifest-short-name.php file should exist
363+
364+
When I run `wp plugin list --name=pwa-manifest-short-name --field=status`
365+
Then STDOUT should be:
366+
"""
367+
active
368+
"""
369+
277370
Scenario: Install plugin using WordPress.org directory URL
278371
Given a WP install
279372

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

0 commit comments

Comments
 (0)