Skip to content

Commit 3fd9ff4

Browse files
Merge pull request #89 from wp-cli/prerelease-1.1.10
Refresh README and test suite prior to 1.1.10 release.
2 parents a4a2553 + 62439c1 commit 3fd9ff4

File tree

5 files changed

+242
-46
lines changed

5 files changed

+242
-46
lines changed

README.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ See the WordPress [Plugin Handbook](https://developer.wordpress.org/plugins/) de
5454

5555
### wp plugin activate
5656

57-
Activates a plugin.
57+
Activates one or more plugins.
5858

5959
~~~
6060
wp plugin activate [<plugin>...] [--all] [--network]
@@ -87,7 +87,7 @@ wp plugin activate [<plugin>...] [--all] [--network]
8787

8888
### wp plugin deactivate
8989

90-
Deactivates a plugin.
90+
Deactivates one or more plugins.
9191

9292
~~~
9393
wp plugin deactivate [<plugin>...] [--uninstall] [--all] [--network]
@@ -182,7 +182,7 @@ wp plugin get <plugin> [--field=<field>] [--fields=<fields>] [--format=<format>]
182182

183183
### wp plugin install
184184

185-
Installs a plugin.
185+
Installs one or more plugins.
186186

187187
~~~
188188
wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--activate] [--activate-network]
@@ -191,7 +191,7 @@ wp plugin install <plugin|zip|url>... [--version=<version>] [--force] [--activat
191191
**OPTIONS**
192192

193193
<plugin|zip|url>...
194-
A plugin slug, the path to a local zip file, or URL to a remote zip file.
194+
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.
195195

196196
[--version=<version>]
197197
If set, get that particular version from wordpress.org, instead of the
@@ -434,11 +434,23 @@ search query.
434434
**requires**: Plugin Minimum Requirements
435435
**tested**: Plugin Tested Up To
436436
**compatibility**: Plugin Compatible With
437-
**rating**: Plugin Rating
437+
**rating**: Plugin Rating in Percent and Total Number
438+
**ratings**: Plugin Ratings for each star (1-5)
438439
**num_ratings**: Number of Plugin Ratings
439440
**homepage**: Plugin Author's Homepage
440441
**description**: Plugin's Description
441442
**short_description**: Plugin's Short Description
443+
**sections**: Plugin Readme Sections: description, installation, FAQ, screenshots, other notes, and changelog
444+
**downloaded**: Plugin Download Count
445+
**last_updated**: Plugin's Last Update
446+
**added**: Plugin's Date Added to wordpress.org Repository
447+
**tags**: Plugin's Tags
448+
**versions**: Plugin's Available Versions with D/L Link
449+
**donate_link**: Plugin's Donation Link
450+
**banners**: Plugin's Banner Image Link
451+
**icons**: Plugin's Icon Image Link
452+
**active_installs**: Plugin's Number of Active Installs
453+
**contributors**: Plugin's List of Contributors
442454

443455
[--format=<format>]
444456
Render output in a particular format.
@@ -541,15 +553,15 @@ inactive, then it will be activated.
541553

542554
### wp plugin uninstall
543555

544-
Uninstalls a plugin.
556+
Uninstalls one or more plugins.
545557

546558
~~~
547-
wp plugin uninstall <plugin>... [--deactivate] [--skip-delete]
559+
wp plugin uninstall [<plugin>...] [--deactivate] [--skip-delete] [--all]
548560
~~~
549561

550562
**OPTIONS**
551563

552-
<plugin>...
564+
[<plugin>...]
553565
One or more plugins to uninstall.
554566

555567
[--deactivate]
@@ -559,6 +571,9 @@ wp plugin uninstall <plugin>... [--deactivate] [--skip-delete]
559571
If set, the plugin files will not be deleted. Only the uninstall procedure
560572
will be run.
561573

574+
[--all]
575+
If set, all plugins will be uninstalled.
576+
562577
**EXAMPLES**
563578

564579
$ wp plugin uninstall hello
@@ -721,13 +736,13 @@ wp theme activate <theme>
721736

722737
### wp theme delete
723738

724-
Deletes a theme.
739+
Deletes one or more themes.
725740

726741
~~~
727742
wp theme delete <theme>...
728743
~~~
729744

730-
Removes the theme from the filesystem.
745+
Removes the theme or themes from the filesystem.
731746

732747
**OPTIONS**
733748

@@ -860,7 +875,7 @@ wp theme get <theme> [--field=<field>] [--fields=<fields>] [--format=<format>]
860875

861876
### wp theme install
862877

863-
Installs a theme.
878+
Installs one or more themes.
864879

865880
~~~
866881
wp theme install <theme|zip|url>... [--version=<version>] [--force] [--activate]
@@ -869,7 +884,7 @@ wp theme install <theme|zip|url>... [--version=<version>] [--force] [--activate]
869884
**OPTIONS**
870885

871886
<theme|zip|url>...
872-
A theme slug, the path to a local zip file, or URL to a remote zip file.
887+
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.
873888

874889
[--version=<version>]
875890
If set, get that particular version from wordpress.org, instead of the

features/bootstrap/FeatureContext.php

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,9 @@ class FeatureContext extends BehatContext implements ClosuredContextInterface {
8787
private $running_procs = array();
8888

8989
/**
90-
* Array of variables available as {VARIABLE_NAME}. Some are always set: CORE_CONFIG_SETTINGS, SRC_DIR, CACHE_DIR, WP_VERSION-version-latest. Some are step-dependent:
91-
* RUN_DIR, SUITE_CACHE_DIR, COMPOSER_LOCAL_REPOSITORY, PHAR_PATH. Scenarios can define their own variables using "Given save" steps. Variables are reset for each scenario.
90+
* Array of variables available as {VARIABLE_NAME}. Some are always set: CORE_CONFIG_SETTINGS, SRC_DIR, CACHE_DIR, WP_VERSION-version-latest.
91+
* Some are step-dependent: RUN_DIR, SUITE_CACHE_DIR, COMPOSER_LOCAL_REPOSITORY, PHAR_PATH. One is set on use: INVOKE_WP_CLI_WITH_PHP_ARGS-args.
92+
* Scenarios can define their own variables using "Given save" steps. Variables are reset for each scenario.
9293
*/
9394
public $variables = array();
9495

@@ -117,8 +118,9 @@ private static function get_process_env_variables() {
117118
// Ensure we're using the expected `wp` binary
118119
$bin_dir = getenv( 'WP_CLI_BIN_DIR' ) ?: realpath( __DIR__ . '/../../bin' );
119120
$vendor_dir = realpath( __DIR__ . '/../../vendor/bin' );
121+
$path_separator = Utils\is_windows() ? ';' : ':';
120122
$env = array(
121-
'PATH' => $bin_dir . ':' . $vendor_dir . ':' . getenv( 'PATH' ),
123+
'PATH' => $bin_dir . $path_separator . $vendor_dir . $path_separator . getenv( 'PATH' ),
122124
'BEHAT_RUN' => 1,
123125
'HOME' => sys_get_temp_dir() . '/wp-cli-home',
124126
);
@@ -328,20 +330,57 @@ public function getHookDefinitionResources() {
328330
}
329331

330332
/**
331-
* Replace {VARIABLE_NAME}. Note that variable names can only contain uppercase letters and underscores (no numbers).
333+
* Replace standard {VARIABLE_NAME} variables and the special {INVOKE_WP_CLI_WITH_PHP_ARGS-args} and {WP_VERSION-version-latest} variables.
334+
* Note that standard variable names can only contain uppercase letters, digits and underscores and cannot begin with a digit.
332335
*/
333336
public function replace_variables( $str ) {
334-
$ret = preg_replace_callback( '/\{([A-Z_]+)\}/', array( $this, '_replace_var' ), $str );
337+
if ( false !== strpos( $str, '{INVOKE_WP_CLI_WITH_PHP_ARGS-' ) ) {
338+
$str = $this->replace_invoke_wp_cli_with_php_args( $str );
339+
}
340+
$str = preg_replace_callback( '/\{([A-Z_][A-Z_0-9]*)\}/', array( $this, 'replace_var' ), $str );
335341
if ( false !== strpos( $str, '{WP_VERSION-' ) ) {
336-
$ret = $this->_replace_wp_versions( $ret );
342+
$str = $this->replace_wp_versions( $str );
343+
}
344+
return $str;
345+
}
346+
347+
/**
348+
* Substitute {INVOKE_WP_CLI_WITH_PHP_ARGS-args} variables.
349+
*/
350+
private function replace_invoke_wp_cli_with_php_args( $str ) {
351+
static $phar_path = null, $shell_path = null;
352+
353+
if ( null === $phar_path ) {
354+
$phar_path = false;
355+
$phar_begin = '#!/usr/bin/env php';
356+
$phar_begin_len = strlen( $phar_begin );
357+
if ( ( $bin_dir = getenv( 'WP_CLI_BIN_DIR' ) ) && file_exists( $bin_dir . '/wp' ) && $phar_begin === file_get_contents( $bin_dir . '/wp', false, null, 0, $phar_begin_len ) ) {
358+
$phar_path = $bin_dir . '/wp';
359+
} else {
360+
$src_dir = dirname( dirname( __DIR__ ) );
361+
$bin_path = $src_dir . '/bin/wp';
362+
$vendor_bin_path = $src_dir . '/vendor/bin/wp';
363+
if ( file_exists( $bin_path ) && is_executable( $bin_path ) ) {
364+
$shell_path = $bin_path;
365+
} elseif ( file_exists( $vendor_bin_path ) && is_executable( $vendor_bin_path ) ) {
366+
$shell_path = $vendor_bin_path;
367+
} else {
368+
$shell_path = 'wp';
369+
}
370+
}
337371
}
338-
return $ret;
372+
373+
$str = preg_replace_callback( '/{INVOKE_WP_CLI_WITH_PHP_ARGS-([^}]*)}/', function ( $matches ) use ( $phar_path, $shell_path ) {
374+
return $phar_path ? "php {$matches[1]} {$phar_path}" : ( 'WP_CLI_PHP_ARGS=' . escapeshellarg( $matches[1] ) . ' ' . $shell_path );
375+
}, $str );
376+
377+
return $str;
339378
}
340379

341380
/**
342381
* Replace variables callback.
343382
*/
344-
private function _replace_var( $matches ) {
383+
private function replace_var( $matches ) {
345384
$cmd = $matches[0];
346385

347386
foreach ( array_slice( $matches, 1 ) as $key ) {
@@ -352,9 +391,9 @@ private function _replace_var( $matches ) {
352391
}
353392

354393
/**
355-
* Substitute "{WP_VERSION-version-latest}" variables.
394+
* Substitute {WP_VERSION-version-latest} variables.
356395
*/
357-
private function _replace_wp_versions( $str ) {
396+
private function replace_wp_versions( $str ) {
358397
static $wp_versions = null;
359398
if ( null === $wp_versions ) {
360399
$wp_versions = array();

features/bootstrap/Process.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace WP_CLI;
44

5+
use WP_CLI\Utils;
6+
57
/**
68
* Run a system process, and learn what happened.
79
*/
@@ -67,7 +69,7 @@ private function __construct() {}
6769
public function run() {
6870
$start_time = microtime( true );
6971

70-
$proc = proc_open( $this->command, self::$descriptors, $pipes, $this->cwd, $this->env );
72+
$proc = Utils\proc_open_compat( $this->command, self::$descriptors, $pipes, $this->cwd, $this->env );
7173

7274
$stdout = stream_get_contents( $pipes[1] );
7375
fclose( $pipes[1] );

0 commit comments

Comments
 (0)