File tree Expand file tree Collapse file tree 3 files changed +57
-0
lines changed
Expand file tree Collapse file tree 3 files changed +57
-0
lines changed Original file line number Diff line number Diff line change @@ -738,3 +738,45 @@ Feature: Manage WordPress themes
738738 """
739739 Warning: example: This update requires PHP version 100
740740 """
741+
742+ @require-wp-5.9
743+ Scenario : Check theme type field for block themes
744+ Given a WP install
745+
746+ When I run `wp theme install twentytwentyfour`
747+ Then STDOUT should contain:
748+ """
749+ Theme installed successfully.
750+ """
751+
752+ When I run `wp theme list --fields=name,type`
753+ Then STDOUT should be a table containing rows:
754+ | name | type |
755+ | twentytwentyfour | block |
756+
757+ When I run `wp theme get twentytwentyfour --field=type`
758+ Then STDOUT should be:
759+ """
760+ block
761+ """
762+
763+ Scenario : Check theme type field for classic themes
764+ Given a WP install
765+
766+ When I run `wp theme install twentytwelve`
767+ Then STDOUT should contain:
768+ """
769+ Theme installed successfully.
770+ """
771+
772+ When I run `wp theme list --fields=name,type --name=twentytwelve`
773+ Then STDOUT should be a table containing rows:
774+ | name | type |
775+ | twentytwelve | classic |
776+
777+ When I run `wp theme get twentytwelve --field=type`
778+ Then STDOUT should be:
779+ """
780+ classic
781+ """
782+
Original file line number Diff line number Diff 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 () {
@@ -612,6 +613,7 @@ public function get( $args, $assoc_args ) {
612613 'tags ' ,
613614 'theme_root ' ,
614615 'theme_root_uri ' ,
616+ 'type ' ,
615617 ];
616618 $ theme_obj = new stdClass ();
617619 foreach ( $ theme_vars as $ var ) {
@@ -621,6 +623,12 @@ public function get( $args, $assoc_args ) {
621623 $ theme_obj ->status = $ this ->get_status ( $ theme );
622624 $ theme_obj ->description = wordwrap ( $ theme_obj ->description );
623625
626+ // Determine theme type (block or classic). is_block_theme() was added in WP 5.9.
627+ $ theme_obj ->type = 'classic ' ;
628+ if ( method_exists ( $ theme , 'is_block_theme ' ) && $ theme ->is_block_theme () ) {
629+ $ theme_obj ->type = 'block ' ;
630+ }
631+
624632 if ( empty ( $ assoc_args ['fields ' ] ) ) {
625633 $ assoc_args ['fields ' ] = $ theme_vars ;
626634 }
Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments