Skip to content

Commit 3fa117f

Browse files
committed
Merge branch 'main' into copilot/add-plugin-dependencies-support
2 parents dd00c51 + e311239 commit 3fa117f

File tree

11 files changed

+171
-12
lines changed

11 files changed

+171
-12
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ jobs:
1717

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

2222
- name: Check existence of composer.json file
2323
id: check_composer_file
24-
uses: andstor/file-existence-action@v3
24+
uses: andstor/file-existence-action@076e0072799f4942c8bc574a82233e1e4d13e9d6 # v3
2525
with:
2626
files: "composer.json"
2727

2828
- name: Set up PHP environment
2929
if: steps.check_composer_file.outputs.files_exists == 'true'
30-
uses: shivammathur/setup-php@v2
30+
uses: shivammathur/setup-php@44454db4f0199b8b9685a5d763dc37cbf79108e1 # v2
3131
with:
3232
php-version: 'latest'
3333
ini-values: zend.assertions=1, error_reporting=-1, display_errors=On
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Install Composer dependencies & cache dependencies
4040
if: steps.check_composer_file.outputs.files_exists == 'true'
41-
uses: ramsey/composer-install@v3
41+
uses: ramsey/composer-install@3cf229dc2919194e9e36783941438d17239e8520 # v3
4242
env:
4343
COMPOSER_ROOT_VERSION: dev-${{ github.event.repository.default_branch }}
4444
with:

.github/workflows/issue-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ name: Issue and PR Triage
1313
required: false
1414
type: string
1515

16+
permissions:
17+
issues: write
18+
pull-requests: write
19+
actions: write
20+
contents: read
21+
models: read
22+
1623
jobs:
1724
issue-triage:
1825
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main

.github/workflows/regenerate-readme.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ on:
1010
- "features/**"
1111
- "README.md"
1212

13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
1317
jobs:
1418
regenerate-readme:
1519
uses: wp-cli/.github/.github/workflows/reusable-regenerate-readme.yml@main

.github/workflows/welcome-new-contributors.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
- main
88
- master
99

10+
permissions:
11+
pull-requests: write
12+
1013
jobs:
1114
welcome:
1215
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
245245
**OPTIONS**
246246

247247
<plugin|zip|url>...
248-
One or more plugins to install. Accepts a plugin slug, the path to a local zip file, or a URL to a remote zip file.
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.
249249

250250
[--version=<version>]
251251
If set, get that particular version from wordpress.org, instead of the
@@ -325,6 +325,16 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
325325
Plugin updated successfully
326326
Success: Installed 1 of 1 plugins.
327327

328+
# Install from a WordPress.org plugin directory URL
329+
$ wp plugin install https://wordpress.org/plugins/akismet/
330+
Detected WordPress.org plugins directory URL, using slug: akismet
331+
Installing Akismet Anti-spam: Spam Protection (3.1.11)
332+
Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
333+
Unpacking the package...
334+
Installing the plugin...
335+
Plugin installed successfully.
336+
Success: Installed 1 of 1 plugins.
337+
328338

329339

330340
### wp plugin is-active
@@ -1036,7 +1046,7 @@ wp theme install <theme|zip|url>... [--version=<version>] [--force] [--ignore-re
10361046
**OPTIONS**
10371047

10381048
<theme|zip|url>...
1039-
One or more themes to install. Accepts a theme slug, the path to a local zip file, or a URL to a remote zip file.
1049+
One or more themes to install. Accepts a theme slug, the path to a local zip file, a URL to a remote zip file, or a URL to a WordPress.org theme directory.
10401050

10411051
[--version=<version>]
10421052
If set, get that particular version from wordpress.org, instead of the
@@ -1075,6 +1085,16 @@ wp theme install <theme|zip|url>... [--version=<version>] [--force] [--ignore-re
10751085
# Install from a remote zip file
10761086
$ wp theme install http://s3.amazonaws.com/bucketname/my-theme.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef
10771087

1088+
# Install from a WordPress.org theme directory URL
1089+
$ wp theme install https://wordpress.org/themes/twentysixteen/
1090+
Detected WordPress.org themes directory URL, using slug: twentysixteen
1091+
Installing Twenty Sixteen (1.2)
1092+
Downloading install package from http://downloads.wordpress.org/theme/twentysixteen.1.2.zip...
1093+
Unpacking the package...
1094+
Installing the theme...
1095+
Theme installed successfully.
1096+
Success: Installed 1 of 1 themes.
1097+
10781098

10791099

10801100
### wp theme is-active
@@ -1178,6 +1198,7 @@ These fields will be displayed by default for each theme:
11781198
* version
11791199
* update_version
11801200
* auto_update
1201+
* type
11811202

11821203
These fields are optionally available:
11831204

@@ -1190,9 +1211,9 @@ These fields are optionally available:
11901211

11911212
# List inactive themes.
11921213
$ wp theme list --status=inactive --format=csv
1193-
name,status,update,version,update_version,auto_update
1194-
twentyfourteen,inactive,none,3.8,,off
1195-
twentysixteen,inactive,available,3.0,3.1,off
1214+
name,status,update,version,update_version,auto_update,type
1215+
twentyfourteen,inactive,none,3.8,,off,classic
1216+
twentysixteen,inactive,available,3.0,3.1,off,classic
11961217

11971218

11981219

features/plugin-activate.feature

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,26 @@ Feature: Activate WordPress plugins
154154
Success:
155155
"""
156156
And the return code should be 0
157+
158+
Scenario: Activating a plugin that generates unexpected output shows the output in debug mode
159+
Given a wp-content/plugins/output-plugin.php file:
160+
"""
161+
<?php
162+
/**
163+
* Plugin Name: Output Plugin
164+
* Description: This plugin generates unexpected output during activation
165+
* Author: WP-CLI tests
166+
*/
167+
echo "Unexpected output from plugin activation";
168+
"""
169+
170+
When I try `wp plugin activate output-plugin --debug`
171+
Then STDERR should contain:
172+
"""
173+
Warning: Failed to activate plugin. The plugin generated unexpected output.
174+
"""
175+
And STDERR should contain:
176+
"""
177+
Debug (plugin): Unexpected output: Unexpected output from plugin activation
178+
"""
179+
And the return code should be 1

features/plugin-install.feature

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,35 @@ Feature: Install WordPress plugins
273273
"""
274274
Error: No plugins installed.
275275
"""
276+
277+
Scenario: Install plugin using WordPress.org directory URL
278+
Given a WP install
279+
280+
When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/`
281+
Then STDOUT should contain:
282+
"""
283+
Detected WordPress.org plugins directory URL, using slug: hello-dolly
284+
"""
285+
And the return code should be 0
286+
287+
When I run `wp plugin list --name=hello-dolly --field=status`
288+
Then STDOUT should be:
289+
"""
290+
inactive
291+
"""
292+
293+
Scenario: Install and activate plugin using WordPress.org directory URL
294+
Given a WP install
295+
296+
When I run `wp plugin install https://wordpress.org/plugins/hello-dolly/ --activate`
297+
Then STDOUT should contain:
298+
"""
299+
Detected WordPress.org plugins directory URL, using slug: hello-dolly
300+
"""
301+
And the return code should be 0
302+
303+
When I run `wp plugin list --name=hello-dolly --field=status`
304+
Then STDOUT should be:
305+
"""
306+
active
307+
"""

features/theme-install.feature

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,31 @@ Feature: Install WordPress themes
158158
"""
159159
Error: No themes installed.
160160
"""
161+
162+
Scenario: Install theme using WordPress.org directory URL
163+
When I run `wp theme install https://wordpress.org/themes/twentytwelve/`
164+
Then STDOUT should contain:
165+
"""
166+
Detected WordPress.org themes directory URL, using slug: twentytwelve
167+
"""
168+
And the return code should be 0
169+
170+
When I run `wp theme list --name=twentytwelve --field=status`
171+
Then STDOUT should be:
172+
"""
173+
inactive
174+
"""
175+
176+
Scenario: Install and activate theme using WordPress.org directory URL
177+
When I run `wp theme install https://wordpress.org/themes/twentyeleven/ --activate`
178+
Then STDOUT should contain:
179+
"""
180+
Detected WordPress.org themes directory URL, using slug: twentyeleven
181+
"""
182+
And the return code should be 0
183+
184+
When I run `wp theme list --name=twentyeleven --field=status`
185+
Then STDOUT should be:
186+
"""
187+
active
188+
"""

src/Plugin_Command.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,16 @@ public function activate( $args, $assoc_args = [] ) {
401401
$message = wp_strip_all_tags( $message );
402402
$message = str_replace( 'Error: ', '', $message );
403403
WP_CLI::warning( "Failed to activate plugin. {$message}" );
404+
// If the error is due to unexpected output, display it for debugging
405+
if ( 'unexpected_output' === $result->get_error_code() ) {
406+
/**
407+
* @var string $output
408+
*/
409+
$output = $result->get_error_data();
410+
if ( ! empty( $output ) ) {
411+
WP_CLI::debug( "Unexpected output: {$output}", 'plugin' );
412+
}
413+
}
404414
++$errors;
405415
} else {
406416
$this->active_output( $plugin->name, $plugin->file, $network_wide, 'activate' );
@@ -631,7 +641,7 @@ protected function install_from_repo( $slug, $assoc_args ) {
631641
}
632642

633643
if ( ! $compatible_php ) {
634-
return new WP_Error( 'requirements_not_met', "This plugin does not work with your version of PHP. Minimum PHP required is $compatible_php" );
644+
return new WP_Error( 'requirements_not_met', "This plugin does not work with your version of PHP. Minimum PHP required is $requires_php" );
635645
}
636646
}
637647

@@ -994,7 +1004,7 @@ protected function filter_item_list( $items, $args ) {
9941004
* ## OPTIONS
9951005
*
9961006
* <plugin|zip|url>...
997-
* : One or more plugins to install. Accepts a plugin slug, the path to a local zip file, or a URL to a remote zip file.
1007+
* : 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.
9981008
*
9991009
* [--version=<version>]
10001010
* : If set, get that particular version from wordpress.org, instead of the
@@ -1086,6 +1096,16 @@ protected function filter_item_list( $items, $args ) {
10861096
* Installing My Plugin (3.5.0)
10871097
* Plugin installed successfully.
10881098
* Success: Installed 3 of 3 plugins.
1099+
*
1100+
* # Install from a WordPress.org plugin directory URL
1101+
* $ wp plugin install https://wordpress.org/plugins/akismet/
1102+
* Detected WordPress.org plugins directory URL, using slug: akismet
1103+
* Installing Akismet Anti-spam: Spam Protection (3.1.11)
1104+
* Downloading install package from https://downloads.wordpress.org/plugin/akismet.3.1.11.zip...
1105+
* Unpacking the package...
1106+
* Installing the plugin...
1107+
* Plugin installed successfully.
1108+
* Success: Installed 1 of 1 plugins.
10891109
*/
10901110
public function install( $args, $assoc_args ) {
10911111

src/Theme_Command.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ protected function filter_item_list( $items, $args ) {
497497
* ## OPTIONS
498498
*
499499
* <theme|zip|url>...
500-
* : One or more themes to install. Accepts a theme slug, the path to a local zip file, or a URL to a remote zip file.
500+
* : One or more themes to install. Accepts a theme slug, the path to a local zip file, a URL to a remote zip file, or a URL to a WordPress.org theme directory.
501501
*
502502
* [--version=<version>]
503503
* : If set, get that particular version from wordpress.org, instead of the
@@ -535,6 +535,16 @@ protected function filter_item_list( $items, $args ) {
535535
*
536536
* # Install from a remote zip file
537537
* $ wp theme install http://s3.amazonaws.com/bucketname/my-theme.zip?AWSAccessKeyId=123&Expires=456&Signature=abcdef
538+
*
539+
* # Install from a WordPress.org theme directory URL
540+
* $ wp theme install https://wordpress.org/themes/twentysixteen/
541+
* Detected WordPress.org themes directory URL, using slug: twentysixteen
542+
* Installing Twenty Sixteen (1.2)
543+
* Downloading install package from http://downloads.wordpress.org/theme/twentysixteen.1.2.zip...
544+
* Unpacking the package...
545+
* Installing the theme...
546+
* Theme installed successfully.
547+
* Success: Installed 1 of 1 themes.
538548
*/
539549
public function install( $args, $assoc_args ) {
540550
if ( count( $args ) > 1 && Utils\get_flag_value( $assoc_args, 'activate', false ) ) {

0 commit comments

Comments
 (0)