Skip to content

Commit dd00c51

Browse files
authored
Merge branch 'main' into copilot/add-plugin-dependencies-support
2 parents ff81966 + 19c1410 commit dd00c51

File tree

9 files changed

+148
-22
lines changed

9 files changed

+148
-22
lines changed

.github/workflows/issue-triage.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
---
2-
name: Issue Triage
2+
name: Issue and PR Triage
33

44
'on':
55
issues:
66
types: [opened]
7+
pull_request_target:
8+
types: [opened]
79
workflow_dispatch:
810
inputs:
911
issue_number:
10-
description: 'Issue number to triage (leave empty to process all)'
12+
description: 'Issue/PR number to triage (leave empty to process all)'
1113
required: false
1214
type: string
1315

1416
jobs:
1517
issue-triage:
1618
uses: wp-cli/.github/.github/workflows/reusable-issue-triage.yml@main
1719
with:
18-
issue_number: ${{ github.event_name == 'workflow_dispatch' && inputs.issue_number || github.event.issue.number }}
20+
issue_number: >-
21+
${{
22+
(github.event_name == 'workflow_dispatch' && inputs.issue_number) ||
23+
(github.event_name == 'pull_request_target' && github.event.pull_request.number) ||
24+
(github.event_name == 'issues' && github.event.issue.number) ||
25+
''
26+
}}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: Welcome New Contributors
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
branches:
7+
- main
8+
- master
9+
10+
jobs:
11+
welcome:
12+
uses: wp-cli/.github/.github/workflows/reusable-welcome-new-contributors.yml@main

README.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,33 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--ignore-
327327

328328

329329

330+
### wp plugin is-active
331+
332+
Checks if a given plugin is active.
333+
334+
~~~
335+
wp plugin is-active <plugin> [--network]
336+
~~~
337+
338+
Returns exit code 0 when active, 1 when not active.
339+
340+
**OPTIONS**
341+
342+
<plugin>
343+
The plugin to check.
344+
345+
[--network]
346+
If set, check if plugin is network-activated.
347+
348+
**EXAMPLES**
349+
350+
# Check whether plugin is Active; exit status 0 if active, otherwise 1
351+
$ wp plugin is-active hello
352+
$ echo $?
353+
1
354+
355+
356+
330357
### wp plugin is-installed
331358

332359
Checks if a given plugin is installed.
@@ -701,6 +728,8 @@ Updates one or more plugins.
701728
wp plugin update [<plugin>...] [--all] [--exclude=<name>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure]
702729
~~~
703730

731+
**Alias:** `upgrade`
732+
704733
**OPTIONS**
705734

706735
[<plugin>...]
@@ -857,6 +886,8 @@ Deletes one or more themes.
857886
wp theme delete [<theme>...] [--all] [--force]
858887
~~~
859888

889+
**Alias:** `uninstall`
890+
860891
Removes the theme or themes from the filesystem.
861892

862893
**OPTIONS**
@@ -1046,6 +1077,30 @@ wp theme install <theme|zip|url>... [--version=<version>] [--force] [--ignore-re
10461077

10471078

10481079

1080+
### wp theme is-active
1081+
1082+
Checks if a given theme is active.
1083+
1084+
~~~
1085+
wp theme is-active <theme>
1086+
~~~
1087+
1088+
Returns exit code 0 when active, 1 when not active.
1089+
1090+
**OPTIONS**
1091+
1092+
<theme>
1093+
The theme to check.
1094+
1095+
**EXAMPLES**
1096+
1097+
# Check whether theme is Active; exit status 0 if active, otherwise 1
1098+
$ wp theme is-active twentyfifteen
1099+
$ echo $?
1100+
1
1101+
1102+
1103+
10491104
### wp theme is-installed
10501105

10511106
Checks if a given theme is installed.
@@ -1417,6 +1472,8 @@ Updates one or more themes.
14171472
wp theme update [<theme>...] [--all] [--exclude=<theme-names>] [--minor] [--patch] [--format=<format>] [--version=<version>] [--dry-run] [--insecure]
14181473
~~~
14191474

1475+
**Alias:** `upgrade`
1476+
14201477
**OPTIONS**
14211478

14221479
[<theme>...]

composer.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"plugin get",
5151
"plugin install",
5252
"plugin install-dependencies",
53+
"plugin is-active",
5354
"plugin is-installed",
5455
"plugin list",
5556
"plugin path",
@@ -65,6 +66,7 @@
6566
"theme enable",
6667
"theme get",
6768
"theme install",
69+
"theme is-active",
6870
"theme is-installed",
6971
"theme list",
7072
"theme mod",

features/theme-update.feature

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ Feature: Update WordPress themes
33
Scenario: Updating a theme with no version in the WordPress.org directory shouldn't delete the original theme
44
Given a WP install
55

6-
When I run `wp scaffold underscores wpclitesttheme`
7-
Then STDOUT should contain:
8-
"""
9-
Success: Created theme
10-
"""
11-
And the wp-content/themes/wpclitesttheme directory should exist
6+
When I run `wp theme install twentytwelve --force`
7+
And I run `wp scaffold child-theme wpclitesttheme --parent_theme=twentytwelve`
8+
Then the wp-content/themes/wpclitesttheme directory should exist
129

1310
When I try `wp theme update wpclitesttheme --version=100.0.0`
1411
Then STDERR should contain:

features/theme.feature

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ Feature: Manage WordPress themes
8787

8888
When I run `wp theme list`
8989
Then STDOUT should be a table containing rows:
90-
| name | status | update | version | update_version | auto_update |
91-
| twentytwelve | inactive | available | 1.4 | {UPDATE_VERSION} | off |
90+
| name | status | update | version | update_version | auto_update | type |
91+
| twentytwelve | inactive | available | 1.4 | {UPDATE_VERSION} | off | classic |
9292

9393
When I run `wp theme activate twentytwelve`
9494
Then STDOUT should not be empty
@@ -105,8 +105,8 @@ Feature: Manage WordPress themes
105105

106106
When I run `wp theme list`
107107
Then STDOUT should be a table containing rows:
108-
| name | status | update | version | update_version | auto_update |
109-
| twentytwelve | active | available | 1.5 | {UPDATE_VERSION} | off |
108+
| name | status | update | version | update_version | auto_update | type |
109+
| twentytwelve | active | available | 1.5 | {UPDATE_VERSION} | off | classic |
110110

111111
When I try `wp theme update`
112112
Then STDERR should be:
@@ -722,8 +722,8 @@ Feature: Manage WordPress themes
722722

723723
When I run `wp theme list`
724724
Then STDOUT should be a table containing rows:
725-
| name | status | update | version | update_version | auto_update | requires | requires_php |
726-
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 100 | 5.6 |
725+
| name | status | update | version | update_version | auto_update | type | requires | requires_php |
726+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | classic | 100 | 5.6 |
727727

728728
When I try `wp theme update example`
729729
Then STDERR should contain:
@@ -765,11 +765,41 @@ Feature: Manage WordPress themes
765765

766766
When I run `wp theme list`
767767
Then STDOUT should be a table containing rows:
768-
| name | status | update | version | update_version | auto_update | requires | requires_php |
769-
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | 3.7 | 100 |
768+
| name | status | update | version | update_version | auto_update | type | requires | requires_php |
769+
| example | inactive | unavailable | 1.0.0 | 2.0.0 | off | classic | 3.7 | 100 |
770770

771771
When I try `wp theme update example`
772772
Then STDERR should contain:
773773
"""
774774
Warning: example: This update requires PHP version 100
775775
"""
776+
777+
@require-wp-5.9
778+
Scenario: Check theme type field for block themes
779+
Given a WP install
780+
781+
When I run `wp theme list --fields=name,type`
782+
Then STDOUT should be a table containing rows:
783+
| name | type |
784+
| twentytwentyfour | block |
785+
786+
When I run `wp theme get twentytwentyfour --field=type`
787+
Then STDOUT should be:
788+
"""
789+
block
790+
"""
791+
792+
Scenario: Check theme type field for classic themes
793+
Given a WP install
794+
795+
When I run `wp theme install twentytwelve --force`
796+
And I run `wp theme list --fields=name,type --name=twentytwelve`
797+
Then STDOUT should be a table containing rows:
798+
| name | type |
799+
| twentytwelve | classic |
800+
801+
When I run `wp theme get twentytwelve --field=type`
802+
Then STDOUT should be:
803+
"""
804+
classic
805+
"""

features/upgradables.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Feature: Manage WordPress themes and plugins
5858
Then STDOUT should not be empty
5959
And save STDOUT as {UPDATE_VERSION}
6060

61-
When I run `wp <type> list`
61+
When I run `wp <type> list --fields=name,status,update,version,update_version,auto_update`
6262
Then STDOUT should be a table containing rows:
6363
| name | status | update | version | update_version | auto_update |
6464
| <item> | inactive | available | <version> | {UPDATE_VERSION} | off |

src/Theme_Command.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class Theme_Command extends CommandWithUpgrade {
6363
'version',
6464
'update_version',
6565
'auto_update',
66+
'type',
6667
];
6768

6869
public function __construct() {
@@ -587,6 +588,9 @@ public function install( $args, $assoc_args ) {
587588
* +---------+----------------+
588589
*/
589590
public function get( $args, $assoc_args ) {
591+
/**
592+
* @var \WP_Theme $theme
593+
*/
590594
$theme = $this->fetcher->get_check( $args[0] );
591595

592596
$errors = $theme->errors();
@@ -612,15 +616,23 @@ public function get( $args, $assoc_args ) {
612616
'tags',
613617
'theme_root',
614618
'theme_root_uri',
619+
'type',
615620
];
616621
$theme_obj = new stdClass();
617622
foreach ( $theme_vars as $var ) {
623+
// @phpstan-ignore-next-line
618624
$theme_obj->$var = $theme->$var;
619625
}
620626

621627
$theme_obj->status = $this->get_status( $theme );
622628
$theme_obj->description = wordwrap( $theme_obj->description );
623629

630+
// Determine theme type (block or classic). is_block_theme() was added in WP 5.9.
631+
$theme_obj->type = 'classic';
632+
if ( method_exists( $theme, 'is_block_theme' ) && $theme->is_block_theme() ) {
633+
$theme_obj->type = 'block';
634+
}
635+
624636
if ( empty( $assoc_args['fields'] ) ) {
625637
$assoc_args['fields'] = $theme_vars;
626638
}
@@ -775,7 +787,7 @@ public function is_installed( $args, $assoc_args ) {
775787
* ## OPTIONS
776788
*
777789
* <theme>
778-
* : The plugin to check.
790+
* : The theme to check.
779791
*
780792
* ## EXAMPLES
781793
*
@@ -915,6 +927,7 @@ public function delete( $args, $assoc_args ) {
915927
* * version
916928
* * update_version
917929
* * auto_update
930+
* * type
918931
*
919932
* These fields are optionally available:
920933
*
@@ -927,9 +940,9 @@ public function delete( $args, $assoc_args ) {
927940
*
928941
* # List inactive themes.
929942
* $ wp theme list --status=inactive --format=csv
930-
* name,status,update,version,update_version,auto_update
931-
* twentyfourteen,inactive,none,3.8,,off
932-
* twentysixteen,inactive,available,3.0,3.1,off
943+
* name,status,update,version,update_version,auto_update,type
944+
* twentyfourteen,inactive,none,3.8,,off,classic
945+
* twentysixteen,inactive,available,3.0,3.1,off,classic
933946
*
934947
* @subcommand list
935948
*/

src/WP_CLI/ParseThemeNameInput.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ private function get_all_themes() {
131131
$requires_php = ! empty( $theme->get( 'RequiresPHP' ) ) ? $theme->get( 'RequiresPHP' ) : '';
132132
}
133133

134+
// Determine theme type (block or classic). is_block_theme() was added in WP 5.9.
135+
$theme_type = 'classic';
136+
if ( method_exists( $theme, 'is_block_theme' ) && $theme->is_block_theme() ) {
137+
$theme_type = 'block';
138+
}
139+
134140
$items[ $stylesheet ] = [
135141
'name' => $key,
136142
'status' => $this->get_status( $theme ),
@@ -146,6 +152,7 @@ private function get_all_themes() {
146152
'requires' => $requires,
147153
'requires_php' => $requires_php,
148154
'update_unavailable_reason' => isset( $update_unavailable_reason ) ? $update_unavailable_reason : '',
155+
'type' => $theme_type,
149156
];
150157

151158
// Compare version and update information in theme list.

0 commit comments

Comments
 (0)