Skip to content

Commit ebe48a2

Browse files
committed
Merge branch 'main' into copilot/add-plugin-theme-language-update-check
2 parents 6a924f0 + a8dc5aa commit ebe48a2

14 files changed

Lines changed: 347 additions & 14 deletions

‎.github/workflows/code-quality.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ on:
66
branches:
77
- main
88
- master
9+
schedule:
10+
- cron: '17 2 * * *' # Run every day on a seemly random time.
911

1012
jobs:
1113
code-quality:

‎.github/workflows/copilot-setup-steps.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
steps:
1919
- name: Checkout code
20-
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
20+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2121

2222
- name: Check existence of composer.json file
2323
id: check_composer_file

‎.typos.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[default]
2+
extend-ignore-re = [
3+
"(?Rm)^.*(#|//)\\s*spellchecker:disable-line$",
4+
"(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on",
5+
"(#|//)\\s*spellchecker:ignore-next-line\\n.*"
6+
]
7+
8+
[default.extend-words]
9+
Automattic = "Automattic"

‎README.md‎

Lines changed: 13 additions & 1 deletion
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
@@ -398,6 +406,10 @@ wp plugin is-active <plugin> [--network]
398406

399407
Returns exit code 0 when active, 1 when not active.
400408

409+
If the plugin does not exist but is still in WordPress's active plugins storage
410+
(such as the active plugins option or the sitewide plugins option for network-activated plugins),
411+
a warning will be emitted.
412+
401413
**OPTIONS**
402414

403415
<plugin>

‎features/plugin-activate.feature‎

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,51 @@ Feature: Activate WordPress plugins
177177
Debug (plugin): Unexpected output: Unexpected output from plugin activation
178178
"""
179179
And the return code should be 1
180+
181+
Scenario: Force activate an already active plugin to re-run activation hooks
182+
Given a wp-content/plugins/force-test.php file:
183+
"""
184+
<?php
185+
/**
186+
* Plugin Name: Force Test Plugin
187+
* Description: Test plugin for force activation
188+
* Author: WP-CLI tests
189+
*/
190+
191+
register_activation_hook( __FILE__, function() {
192+
@file_put_contents( WP_CONTENT_DIR . '/activation-test.txt', 'Activation hook was run' );
193+
});
194+
"""
195+
196+
When I run `wp plugin activate force-test`
197+
Then STDOUT should contain:
198+
"""
199+
Plugin 'force-test' activated.
200+
"""
201+
And the return code should be 0
202+
And the wp-content/activation-test.txt file should exist
203+
204+
# Remove the file to test if it gets recreated with --force
205+
When I run `rm wp-content/activation-test.txt`
206+
207+
# Try activating without --force (should skip)
208+
And I try `wp plugin activate force-test`
209+
Then STDERR should contain:
210+
"""
211+
Warning: Plugin 'force-test' is already active.
212+
"""
213+
And STDOUT should be:
214+
"""
215+
Success: Plugin already activated.
216+
"""
217+
And the return code should be 0
218+
And the wp-content/activation-test.txt file should not exist
219+
220+
# Now try with --force (should re-run activation hooks)
221+
When I run `wp plugin activate force-test --force`
222+
Then STDOUT should contain:
223+
"""
224+
Plugin 'force-test' activated.
225+
"""
226+
And the return code should be 0
227+
And the wp-content/activation-test.txt file should exist

‎features/plugin-is-active.feature‎

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
Feature: Check if a WordPress plugin is active
2+
3+
Background:
4+
Given a WP install
5+
6+
Scenario: Check if an active plugin is active
7+
When I run `wp plugin activate akismet`
8+
Then STDOUT should contain:
9+
"""
10+
Success:
11+
"""
12+
13+
When I run `wp plugin is-active akismet`
14+
Then the return code should be 0
15+
16+
Scenario: Check if an inactive plugin is not active
17+
When I run `wp plugin activate akismet`
18+
Then STDOUT should contain:
19+
"""
20+
Success:
21+
"""
22+
23+
When I run `wp plugin deactivate akismet`
24+
Then STDOUT should contain:
25+
"""
26+
Success:
27+
"""
28+
29+
When I try `wp plugin is-active akismet`
30+
Then the return code should be 1
31+
32+
Scenario: Check if a non-existent plugin is not active
33+
When I try `wp plugin is-active non-existent-plugin`
34+
Then the return code should be 1
35+
36+
Scenario: Warn when plugin is in active_plugins but file does not exist
37+
When I run `wp plugin activate akismet`
38+
Then STDOUT should contain:
39+
"""
40+
Success:
41+
"""
42+
43+
When I run `wp plugin is-active akismet`
44+
Then the return code should be 0
45+
46+
# Remove the plugin directory
47+
When I run `wp plugin path akismet --dir`
48+
Then save STDOUT as {PLUGIN_PATH}
49+
50+
When I run `rm -rf {PLUGIN_PATH}`
51+
Then the return code should be 0
52+
53+
# Now the plugin file is gone but still in active_plugins
54+
When I try `wp plugin is-active akismet`
55+
Then STDERR should contain:
56+
"""
57+
Warning: Plugin 'akismet' is marked as active but the plugin file does not exist.
58+
"""
59+
And the return code should be 1
60+
61+
Scenario: Warn when network-activated plugin is in active_sitewide_plugins but file does not exist
62+
Given a WP multisite install
63+
64+
When I run `wp plugin activate akismet --network`
65+
Then STDOUT should contain:
66+
"""
67+
Success:
68+
"""
69+
70+
When I run `wp plugin is-active akismet --network`
71+
Then the return code should be 0
72+
73+
# Remove the plugin directory
74+
When I run `wp plugin path akismet --dir`
75+
Then save STDOUT as {PLUGIN_PATH}
76+
77+
When I run `rm -rf {PLUGIN_PATH}`
78+
Then the return code should be 0
79+
80+
# Now the plugin file is gone but still in active_sitewide_plugins
81+
When I try `wp plugin is-active akismet --network`
82+
Then STDERR should contain:
83+
"""
84+
Warning: Plugin 'akismet' is marked as active but the plugin file does not exist.
85+
"""
86+
And the return code should be 1

‎features/plugin-list-wporg-status.feature‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Feature: Check the status of plugins on WordPress.org
7878
"error": "not_found"
7979
}
8080
"""
81-
And that HTTP requests to https://plugins.trac.wordpress.org/log/never-wporg?limit=1&mode=stop_on_copy&format=rss will respond with:
81+
And that HTTP requests to https://plugins.trac.wordpress.org/log/never-wporg/?limit=1&mode=stop_on_copy&format=rss will respond with:
8282
"""
8383
HTTP/1.1 404
8484
Content-Type: application/rss+xml;charset=utf-8

‎features/plugin-update.feature‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,25 @@ Feature: Update WordPress plugins
267267
"""
268268
Success: Updated 1 of 1 plugins (1 skipped).
269269
"""
270+
271+
@require-wp-5.2
272+
Scenario: Updating all plugins should show the name of each plugin as it is updated
273+
Given a WP install
274+
And I run `wp plugin delete akismet`
275+
276+
When I run `wp plugin install health-check --version=1.5.0`
277+
Then STDOUT should not be empty
278+
279+
When I run `wp plugin install wordpress-importer --version=0.5`
280+
Then STDOUT should not be empty
281+
282+
When I try `wp plugin update --all`
283+
Then STDOUT should contain:
284+
"""
285+
Updating Health Check & Troubleshooting...
286+
"""
287+
288+
And STDOUT should contain:
289+
"""
290+
Success: Updated 2 of 2 plugins.
291+
"""

‎features/theme-update.feature‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,25 @@ Feature: Update WordPress themes
154154
"""
155155
1.1.1
156156
"""
157+
158+
@require-wp-4.5
159+
Scenario: Updating all themes should show the name of each theme as it is updated
160+
Given a WP install
161+
And I run `wp theme delete --all --force`
162+
163+
When I run `wp theme install moina --version=1.0.2`
164+
Then STDOUT should not be empty
165+
166+
When I run `wp theme install twentytwelve --version=1.0`
167+
Then STDOUT should not be empty
168+
169+
When I try `wp theme update --all`
170+
Then STDOUT should contain:
171+
"""
172+
Updating Moina...
173+
"""
174+
175+
And STDOUT should contain:
176+
"""
177+
Success: Updated 2 of 2 themes.
178+
"""

‎phpcs.xml.dist‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<exclude-pattern>*/src/WP_CLI/CommandWithUpgrade\.php$</exclude-pattern>
6262
<exclude-pattern>*/src/WP_CLI/(CommandWith|DestructivePlugin|DestructiveTheme)Upgrader\.php$</exclude-pattern>
6363
<exclude-pattern>*/src/WP_CLI/Parse(Plugin|Theme)NameInput\.php$</exclude-pattern>
64+
<exclude-pattern>*/src/WP_CLI/ExtensionUpgraderSkin\.php$</exclude-pattern>
6465
</rule>
6566

6667
<!-- Exclude classes from UselessOverridingMethod sniff as the method is used for generating docs. -->

0 commit comments

Comments
 (0)