Skip to content

Commit b6334de

Browse files
Merge pull request #810 from wp-cli/theme-is-installed
Implement `wp theme is-installed`
2 parents c1df168 + 1bd8e82 commit b6334de

4 files changed

Lines changed: 32 additions & 7 deletions

File tree

features/plugin.feature

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@ Feature: Manage WordPress plugins
3131
Status: Active
3232
"""
3333

34-
When I run `wp plugin is-installed zombieland && echo "Zombieland"`
35-
Then STDOUT should contain:
36-
"""
37-
Zombieland
38-
"""
39-
4034
When I run `wp plugin status`
4135
Then STDOUT should not be empty
4236

features/upgradables.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ Feature: Manage WordPress themes and plugins
88
And I run `wp <type> path`
99
And save STDOUT as {CONTENT_DIR}
1010

11+
When I try `wp <type> is-installed <item>`
12+
Then the return code should be 1
13+
And STDERR should be empty
14+
1115
When I try `wp <type> get <item>`
1216
Then the return code should be 1
1317
And STDERR should not be empty
@@ -19,6 +23,9 @@ Feature: Manage WordPress themes and plugins
1923
<type_name> installed successfully
2024
"""
2125

26+
When I try `wp <type> is-installed <item>`
27+
Then the return code should be 0
28+
2229
When I run `wp <type> get <item>`
2330
Then STDOUT should be a table containing rows:
2431
| Field | Value |

php/commands/plugin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ function uninstall( $args, $assoc_args = array() ) {
440440
}
441441

442442
/**
443-
* Check if the plugin is installed
443+
* Check if the plugin is installed.
444444
*
445445
* ## OPTIONS
446446
*

php/commands/theme.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,30 @@ function update( $args, $assoc_args ) {
312312
parent::update_many( $args, $assoc_args );
313313
}
314314

315+
/**
316+
* Check if the theme is installed.
317+
*
318+
* ## OPTIONS
319+
*
320+
* <theme>
321+
* : The theme to check.
322+
*
323+
* ## EXAMPLES
324+
*
325+
* wp theme is-installed twentytwelve
326+
*
327+
* @subcommand is-installed
328+
*/
329+
function is_installed( $args, $assoc_args = array() ) {
330+
$theme = wp_get_theme( $args[0] );
331+
332+
if ( $theme->exists() ) {
333+
exit( 0 );
334+
} else {
335+
exit( 1 );
336+
}
337+
}
338+
315339
/**
316340
* Delete a theme.
317341
*

0 commit comments

Comments
 (0)