Version 0.20.0 released

Even though WP-CLIWP-CLI WP-CLI is the Command Line Interface for WordPress, used to do administrative and development tasks in a programmatic way. The project page is http://wp-cli.org/ https://make.wordpress.org/cli/ is a mature project, we still manage to pack a great set of improvements into each release. Here’s what’s coming to you in v0.20.0.

Regex, verbose search-replace

Use the --regex flag to wp search-replace to… wait for it… use regex in your search and replace operations. And, with the --verbose flag, you’ll see each column with affected rows as the operation is performed:

$ wp post get 1 --field=title
Hello world
$ wp search-replace '(Hello)s(world)' '$2, $1' --regex --verbose
...
Checking: wp_posts.post_content
0 rows affected
Checking: wp_posts.post_title
1 rows affected
Checking: wp_posts.post_excerpt
0 rows affected
...
$ wp post get 1 --field=title
world, Hello

Note: search-replace with --regex is 15-20x slower than without. Make sure you plan for the performance hit in your migrationMigration Moving the code, database and media files for a website site from one server to another. Most typically done when changing hosting companies. plans, and use wisely.

Major bug fix: cached partial upgrade files masquerading as full upgrades

Since v0.17.0 (pull request), WP-CLI mistakenly cached partial archives in a lossy manner. More specifically, a ZIP file for a partial upgrade would be cached with the same key as a ZIP file for a full upgrade. With the file incorrectly cached, subsequent full upgrades would use the cached partial upgrade archive.

If you can’t immediately upgrade to v0.20.0, we’ve also released v0.17.2, v0.18.1, and v0.19.3 with the bug fix (pull request). The cache key was changed as well, so prior invalid WordPress archives are silently ignored.

Use wp core verify-checksums to make sure a given WordPress install has the correct copy of each file. If it doesn’t verify, use wp core download --version=$(wp core version) --force to re-install WordPress.

WP-APIAPI An API or Application Programming Interface is a software intermediary that allows programs to interact with each other and share data in limited, clearly defined ways. CLICLI Command Line Interface. Terminal (Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress.

We released v0.19.0 with this statement:

WP-API is days away from 2.0-beta1, and brings with it a powerful new interface to WordPress. In the near future, we’ll start exploring how WP-CLI can use WP-API internally. If all goes well, WP-CLI could see just one more 0.x.0 release before the big 1.0.0.

Well… it was a bold declaration. Follow danielbachhuber/wp-rest-cli for progress on the implementation. 1.0.0 will still likely be WP-CLI based on WP-API, but it’ll take a fair bit of work to get there.

Helpful one-liners

There were a couple issues opened for “how do I do X?”, which you might find helpful too:

# List plugins on each site in a network
wp site list --field=url | xargs -n 1 -I % wp plugin list --url=%

# Delete inactive plugins
wp plugin delete $(wp plugin list --status=inactive --field=name)

Other changes in v0.20.0

Enhancements:

  • The wp server command is bundled with WP-CLI. Use PHPPHP PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. http://php.net/manual/en/intro-whatis.php.’s built-in web server for a specific WordPress instance.
  • Keep up with the latest and greatest by using wp cli update --nightly. When downloading a nightly, the hash is appended to the version.
  • Added a simple wp comment generate command.
  • Cache invalidation is deferred until the end of the command when using wp term generate. This improves performance of the command.
  • wp term list supports filtering by --term_id=<term-id>.
  • Use --start_id=<post-id> to start wp export from a given post ID, or use --post_type=<post-type>,<post-type> to export a selection of post types.
  • Throws a helpful error when an invalid --url=<url> is specified on multisiteMultisite Multisite is a WordPress feature which allows users to create a network of sites on a single WordPress installation. Available since WordPress version 3.0, Multisite is a continuation of WPMU or WordPress Multiuser project. WordPress MultiUser project was discontinued and its features were included into WordPress core.https://codex.wordpress.org/Create_A_Network.. Previously, WP-CLI would fail silently, leaving the user confused as to why their command wasn’t running.
  • Create a new role from another role with wp role --clone=<role>.
  • Use --format=summary to get one-liner messages with wp (plugin|theme) update.
  • Switched away from using wp_download_language_pack() so languages can be installed with the DISALLOW_FILE_MODS constant set.

Bug fixes:

  • wp term generate tries to generate unique term names on subsequent executions. Previously, it would start its index at 0, and then error for duplicate terms.
  • Internalized wp_clean_update_cache() (used in wp core language list and wp core language update) to prevent fatals in WordPress 4.0. The function was introduced in WordPress 4.1.
  • When WordPress is detected, WP-CLI will wait until WordPress is fully loaded before executing wp help. This means plugins which add commands to an existing namespace can have theri help docs appear.
  • Corrected Travis notification syntax produced by wp scaffold plugin-tests command.
  • Supports Requests installed to parent project in WP_CLIUtilshttp_request()
  • Passes thru --allow-root in cli update to let root update WP-CLI.
  • Restored apt-get tab completion after using WP-CLI tab completion.
  • Permits categories to be assigned with wp post update.
  • Prevents wp import from using double the memory it actually needs, and save 100s of MBs on large imports.

You can browse the full list of resolved issues on GithubGitHub GitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/.

Contributors to this release: boonebgorges, danielbachhuber, janvoracek, gedex, johnbillion, kdoole, marcaddeo, miya0001, montchr, morganestes, rodrigoprimo, rmccue, scribu, stevegrunwell, szepeviktor