WP-CLI v2.0.0 Release Notes

This is a big one! 67 awesome contributors have collaborated over 364 pull requests to bring you WP-CLI v2!

Before going over the detailed change log, let’s discuss a few key areas of this update in more detail. There’s also a “Breaking changes” further down in the document.

“Framework” & “Bundle” are now two separate packages

This is the main change we planned to include with version 2 of WP-CLI. From v2 onwards, the “framework” is a separate package from the “bundle” that is used to build the Phar file you can download. The framework is now contained within the wp-cli/wp-cli package, while the bundling has moved on to the wp-cli/wp-cli-bundle.

Agreed, this does not sound like such a big deal, but in terms of development experience and maintenance effort, it is a tremendous improvement, making almost every future change faster and simpler.

What does that mean for users working with the Phar version of WP-CLI ?

Nothing much, really. Apart from some of the debugging information containing different paths, you won’t see much of a difference. One of the goals was to not disrupt current usage more than necessary. If you only ever download the WP-CLI Phar and use that to control your sites, you should not need to care about this change.

What does this mean for site owners using WP-CLI through Composer ?

They will rejoice! The framework itself has gotten rid of most of its problematic dependencies. If you compare the dependencies of v1.5.1 with those of v2.0.0, you’ll see that the list is drastically shorter. Also, the most problematic set of the dependencies, the hard requirement on an old version of Symfony, is gone. The only Symfony component we still have (yet) is symfony/finder, as there’s no upper version limit for that one.

Most of the more problematic dependencies actually came from the WP-CLI package manager (wp-cli/package-command). That command is not only optional now, there’s also no valid reason to use it at all when pulling WP-CLI in via Composer directly.

This also means that you will not see WP-CLI automatically pull in all bundled commands automatically. Let’s say, you need the wp-cli/db-command for some maintenance tasks for your site. With v1.5.1, this would have pulled in the entire WP-CLI bundle as a dependency. With v2.0.0, it will only pull in the lean framework as a dependency, nothing more. You’ll end up with a WP-CLI active on your site that contains the commands clihelp (as the two “built-ins”) and db.

As a nice side-benefit, this makes WP-CLI run much faster in such scenarios, as it only loads what is effectively needed for the site. The difference might not seem like much, but depending on how you use in in your scripts, it can make a big difference.

What does this mean for developers working on third-party WP-CLI commands?

Splitting everything up has provided a few additional perks for developers (see also the next section about the testing improvements). Everything is leaner, and the dependency resolutions are less problematic, as we got rid of that one nasty circular dependency (command requires framework => framework equals bundle => bundle requires command).

However, dependency declarations need to be more explicit now. If you require wp-cli/wp-cli, this will only provide the pure framework. You cannot implicitly rely on any of the bundled commands in that case, you’ll have to explicitly require any additional command you might need.

Testing framework is now a separate package

One of the things that bothered me a lot while maintaining WP-CLI was the fact that the testing infrastructure was “scaffolded” into the individual command packages (just as it is into the third-party commands). This basically means that we copy-pasted the code in there, and if the code needs to change (because of a bug being fixed or an improvement being made), we have to create changes in every single package to overwrite the copy-pasted version of the testing code with an updated one.

Now we have the testing infrastructure abstracted away into a separate package: wp-cli/wp-cli-tests. For this first iteration, it includes out-of-the-box support for PHP linting, PHP Code Sniffer checks (including the WordPress Coding Standards and the PHP Compatibility Checks), PHPUnit unit tests and Behat functional tests. They are set up in such a way that they detect whether they should run, based on config files or test files presence.

A simple composer test will run all of the tests in order. But you can also run them individually, through composer lint|phpcs|phpunit|behat. Adding further configuration flags can be done as well, but you need to remember to prepend them with a double-dash ( --) first, otherwise the arguments will be interpreted by Composer itself.

For the most important tests, the functional Behat tests, you can also define some constants to adapt the environment in which to test. For example, testing against a specific version of WordPress can be done by providing the WP_VERSION constant: WP_VERSION=4.2 composer behat. This constant also understands latest and trunk correctly.

In general, the tests are set up in such a way that you’ll face less differences between what you get locally and what you’ll get inside of the Travis CI checks.

And given that the tests can now be worked on in one central location, we’re already thinking about what our next steps are to further improve them, like letting you easily re-run only the failed scenarios from last run or automatically retrying failures on Travis to make sure it was not a random intermittent timeout or similar.

New command: i18n make-pot

@swissspidy has spent countless hours working on a new command that has now finally made it into the official WP-CLI bundle. We now introduce you to the i18n command family and its first usable subcommand, i18n make-pot.

What started out as an exploration at first is now a robust tool that is already being used in production systems and is even planned to replace the default translation tool bundled with WordPress Core. It supports both PHP and JavaScript, can manipulate and put into shape multiple files and even detected bugs in the original Core tooling.

This can now easily be including in whatever automated tooling you use for your site/plugin/theme development, and should make your translation work much smoother. Here’s a quick rundown of the main features:

  • Automatically detects plugins and themes and extracts file headers.
  • Allows extraction of only a specific text domain.
  • Supports JavaScript string extraction, even for JSX and ESNext.
  • Allows merging the resulting POT file with an existing one, e.g. one created by Babel.
  • Powerful rules to include/exclude specific directories (minified JS files, vendor, .git folder, etc.).
  • Supports extracting strings from WordPress core the same way it’s done today with 4 different projects. See https://github.com/wp-cli/i18n-command/pull/69 for examples.
  • Can warn about strings with wrong placeholders, as well as misleading or missing translator comments. This could be very useful for core but also plugin/developers to improve polyglots UX.

A big shoutout to @swissspidy for the fabulous work he did on that command!

Minor Framework enhancements

New WordPress action: 'cli_init'

We introduced a new action 'cli_init' that will be triggered by WP-CLI during the 'plugins_loaded' action. This can be used as a conditional trigger for loading WP_CLI specific code, in case you don’t want to use the constants we already provide, for whatever reason.

This being a WordPress action, it adds a bit more flexibility to the process of loading a WP-CLI command, like for example one plugin being able to unhook the commands of another plugin.

New command: config edit

Easily open your wp-config.php in your favorite editor (configured through the EDITOR environment variable). Once you save within that editor, the wp-config.php will be correctly updated.

Note: This works through SSH/vagrant/docker tunnels as well, but keep in mind that it will use the EDITOR of the remote system, which should be something like vim (=> “how to exit the vim editor” 😉).

# Launch system editor to edit wp-config.php file
$ wp config edit

# Edit wp-config.php file in a specific editor
$ EDITOR=vim wp config edit

New command: config shuffle-salts

This refreshes the salts stored in your wp-config.php file, which are cryptographic values used for authentication and other security-related functionality. Regulary refreshing these salts could be considered “security hygiene” for a site.

The command will generate the salts locally if your PHP server environment is cryptographically secure enough to do so, and falls back to the remote wordpress.org API endpoint if not.

# Get new salts for your wp-config.php file
$ wp config shuffle-salts
Success: Shuffled the salt keys.

New command: db columns

Get a tabular view of the table schema for a given table. It shows you how the individual columns of the table have been defined, which default values they use and what extra functionality might be attached to them.

$ wp db columns wp_posts
+-----------------------+---------------------+------+-----+---------------------+----------------+
|         Field         |        Type         | Null | Key |       Default       |     Extra      |
+-----------------------+---------------------+------+-----+---------------------+----------------+
| ID                    | bigint(20) unsigned | NO   | PRI |                     | auto_increment |
| post_author           | bigint(20) unsigned | NO   | MUL | 0                   |                |
| post_date             | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_date_gmt         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_content          | longtext            | NO   |     |                     |                |
| post_title            | text                | NO   |     |                     |                |
| post_excerpt          | text                | NO   |     |                     |                |
| post_status           | varchar(20)         | NO   |     | publish             |                |
| comment_status        | varchar(20)         | NO   |     | open                |                |
| ping_status           | varchar(20)         | NO   |     | open                |                |
| post_password         | varchar(255)        | NO   |     |                     |                |
| post_name             | varchar(200)        | NO   | MUL |                     |                |
| to_ping               | text                | NO   |     |                     |                |
| pinged                | text                | NO   |     |                     |                |
| post_modified         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_modified_gmt     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |
| post_content_filtered | longtext            | NO   |     |                     |                |
| post_parent           | bigint(20) unsigned | NO   | MUL | 0                   |                |
| guid                  | varchar(255)        | NO   |     |                     |                |
| menu_order            | int(11)             | NO   |     | 0                   |                |
| post_type             | varchar(20)         | NO   | MUL | post                |                |
| post_mime_type        | varchar(100)        | NO   |     |                     |                |
| comment_count         | bigint(20)          | NO   |     | 0                   |                |
+-----------------------+---------------------+------+-----+---------------------+----------------+

New command: db clean

We already had db reset, but that dropped the entire database… which is not a nice thing to do if there’s more than a default WordPress site in there 😱!

The new db clean will only drop the tables that are actually part of the current WordPress installation and leave the rest of the database instance intact.

# Delete all tables that match the current site prefix.
$ wp db clean --yes
Success: Tables dropped.

New command: site meta

We’ve added CRUD methods adddeletegetlistpatch, pluck and update for the “site meta” entities.

Oh, and while you are wondering… Yes, you are right, WordPress does not have “site meta” entities. But we didn’t lose our minds: WordPress will introduce “site meta”, together with a wp_site_meta table, with its 5.0 version. We just like to be prepared, that’s all… 😜

# Set site meta
$ wp site meta set 123 bio "Mary is a WordPress developer."
Success: Updated custom field 'bio'.

# Get site meta
$ wp site meta get 123 bio
Mary is a WordPress developer.

# Update site meta
$ wp site meta update 123 bio "Mary is an awesome WordPress developer."
Success: Updated custom field 'bio'.

# Delete site meta
$ wp site meta delete 123 bio
Success: Deleted custom field.

New command: user check-password

You can now let WordPress tell you whether a given password is valid for a specific user. This is NOT an endorsement to build your authentication layer with Bash scripts! But who knows what exotic automation needs the DevOps folks will come up with…

The command will let you know through a shell exit code whether the password was valid or not, so you can use it directly in if conditionals.

# Check whether given credentials are valid; exit status 0 if valid, otherwise 1
$ wp user check-password admin adminpass
$ echo $?
1

# Bash script for checking whether given credentials are valid or not
if ! $(wp user check-password $USER $PASSWORD); then
    notify-send "Invalid Credentials";
fi

New commands: language plugin and language theme

They both come with the following subcommands: install, update, uninstall, list and is-installed (which was added to core language as well).

You can now fully control all of the language files of your installation individually.

# Install the Dutch theme language pack.
$ wp language plugin install hello-dolly nl_NL
Success: Language installed.

# Uninstall the Dutch theme language pack.
$ wp language plugin uninstall hello-dolly nl_NL
Success: Language uninstalled.

# List installed theme language packages.
$ wp language plugin list --status=installed
+----------+--------------+-------------+-----------+-----------+---------------------+
| language | english_name | native_name | status | update | updated |
+----------+--------------+-------------+-----------+-----------+---------------------+
| nl_NL | Dutch | Nederlands | installed | available | 2016-05-13 08:12:50 |
+----------+--------------+-------------+-----------+-----------+---------------------+

Changes to existing command

  • db size now knows about ISO size units as well
  • option list got a new --unserialize flag
  • post generate can now deal with --post_date_gmt
  • user update now allows you to --skip-email
  • eval-file can read from STDIN
  • Both plugin uninstall and plugin delete can now act on --all plugins at once
  • cap list can now --show-grant
  • cap add , seeing what its list sibling had done, grew a new --grant flag
  • role list can now print a single --field=<field>
  • scaffold _s learned the new --woocommerce trick
  • search-replace lets you set a --regex-limit

Automated README.md updates

If you have ever contributed to WP-CLI and made a change to a command signature or documentation, you probably had me tell you that you needed to regenerate the README.md as well using the wp scaffold package-readme . --force command. No more!

We have now added a package wp-cli/regenerate-readme that automates this process. It adds both a precommit and a postcommit git hook that collaborate to transparently regenerate the README.md file behind the scenes and then amend your commit to add the required changes automatically.

This has not been deployed to all command packages yet while we still experiment with some of the finer points of its implementation, but you’ll slowly see the annoying “please regenerate README.md kthxbye” reminders from my side disappear and become forgotten artifacts of the past.

Improved debug output

The debug output was always a bit sparse for WP-CLI. This is why we took the opportunity of v2 to improve upon it and make it more useful. It will now add debug messages for the hooks that are triggered, or details about how commands are being loaded or deferred. This will be very useful for third-party command developers that ignore why their command is not properly registered.

We’ll make sure to add even more useful debugging information in the future.

Small side note: To make debugging work as early as possible, it is now smart enough to just store all messages until the logger it needs to send them to becomes available. This means you don’t need to worry about the timing here, if the WP_CLI exits for your code, the debugger is good to go!

Breaking changes

Here are a few things you need to be aware of when moving from ^v1 to ^v2:

  • An obvious breaking change is the bump to the minimum version of PHP. This will break for anyone trying to run WP-CLI on PHP 5.3.
  • The separation of the “framework” and the “bundle” into two separate packages will cause a breaking change if a third-party command is being pulled-in via Composer AND that third-party command relies on running bundled commands as well. This will seldom be the case and will be an easy fix. Installations using the Phar will not be impacted.
  • As many dependencies could be removed from the framework by not including the package manager automatically, any third-party command that relies on one of the removed Symfony packages or other dependencies AND hasn’t declared that requirement in its own Composer configuration will break. This will seldom be the case and will be an easy fix. Installations using the Phar will not be impacted as the package manager still comes with these requirements included.
  • The versions of some the dependencies will be bumped. If you happen to not lock WP-CLI into a specific version constraint, but do so for some of its dependencies, you might see a version constraint conflict when using Composer.
  • Any external code that relies on internal file structure, file naming or other internal details that are not part of the provided API could run the risk of breaking due to us moving things around from v1 to v2. This should hopefully not ever be the case, but you never know…
  • As a side-effect of adding the --all flag to plugin uninstall, a breaking change was introduced for consistency reasons. Whereas WP-CLI used to consider uninstalling a non-existent plugin as a “Success: Plugin already uninstalled”, it will now throw an error “Error: No plugin uninstalled”.
  • We did our best to avoid unnecessary breaking changes. But with a big structural change like we have here, the devil’s in the details. Let us know if you hit any other issues!

Complete change log

wp-cli/wp-cli-bundle

  • Bundle wp-cli/i18n-command [#9]

wp-cli/wp-cli

  • Add Inflector class and convenience function for pluralizing nouns [#4881]
  • Adapt regular expression in make-phar test to skip wiki links [#4873]
  • PHPCS Config Refresh [#4867]
  • Fix PHP version check [#4864]
  • Trigger new 'cli_init' hook during WordPress 'plugins_loaded' action. [#4861]
  • add template for core-command to phar [#4854]
  • Fall back to full string instead of $mode on PHP < 7 [#4853]
  • Refactoring wp-cli/wp-cli to represent the framework only, not the bundle [#4851]
  • Remove WP 4.4 requirement [#4845]
  • Fix —skip-theme tests [#4843]
  • Fix shell scripting issues in ci/deploy.sh [#4842]
  • Fix shell scripting issues in bin/wp [#4841]
  • Additional quoting in ci/prepare.sh [#4840]
  • Lock wp-completion.bash to v1.5.1 [#4839]
  • Remove Gemnasium badge, as the service was shut down [#4815]
  • Use latest search-replace package to fix tests broken due to privacy policy change [#4807]
  • Turn 'latest' into version number [#4806]
  • Update packages to fix broken tests due to WP5.0 [#4804]
  • Switch to fixed package command [#4803]
  • Bump lowest PHP version to test to 5.4 [#4798]
  • Add a missing accepted output format to wp cli alias [#4765]
  • Improve the descriptions of the --skip-plugins and --skip-themes flags [#4759]
  • Include sublinks in README.md to popular installation methods [#4756]
  • ABSPATH defined [#4743]
  • Skip wp_blogmeta table for back compat [#4736]
  • Introduce \WP_CLI\Utils\normalize_path function. Using it for ABSPATH constant. [#4718]
  • Undo temporary one-off @require-php-5.4 in bootstrap test. [#4716]
  • Revert “Require minimum PHP 5.4” [#4715]
  • Skip pre-commit hook in auto-composer-update [#4711]
  • Revert “update wp cli info” [#4702]
  • Remove : from cli update info check. [#4697]
  • Only check staged files during the pre-commit PHPCS verification [#4696]
  • Empty domain in framework test after get_sites_by_path change. [#4695]
  • Append uniq_id() when extracting file from Phar [#4692]
  • Support launching system editor with specific temp file extension [#4691]
  • Script to create the Git pre-commit hook. [#4622]
  • Update wp cli info [#4613]

wp-cli/handbook

  • Add documentation on how to troubleshoot [#243]
  • Use <example.com> as placeholder [#242]
  • Fix typos in <code-review.md> [#239] & [#241]
  • Remove Dead Link [#238]
  • Update docs for installing WP-CLI via brew [#236]
  • Add quotes to the alias [#235]
  • Adapt signing procedure to use proper key [#232]
  • Added the optimize WP CLI command of the WP-Optimize Plugin [#231]
  • Add an updraftplus WP CLI command [#228]
  • Fix grammar in documentation paragraph [#226]
  • Add a LICENSE file to the repo [#224]
  • Incorporate a few strategic mentions of the wp-cli/ideas repo [#223]
  • Remove the wish list from the website [#222]
  • Document WP_CLI_PHP_ARGS in WP-CLI config document [#221]
  • Mention the Docker installing method [#220]
  • Document issue of creating a post with Latin characters in title [#214]
  • Add BOM in wp-config.php as a common issue. [#212]
  • Add WP_CLI_PHP to Environment variables [#211]
  • Fix missing quote in documentation [#210]
  • Separate non-bundled install; generate against current WP-CLI instance. [#207]
  • Update Daniel’s relationship to the project [#206]

wp-cli/wp-cli.github.com

  • Updated <index.md> for Spanish language [#313]
  • Remove Gemnasium badge [#312]
  • Update pt_BR translation [#311]
  • Add a LICENSE file to the repo [#309]
  • Add note about only using the English version as source for translations [#308]
  • Translate homepage into Spanish [#307]
  • Changed http to https in all wp-cli.org links. [#305]

wp-cli/autoload-splitter

  • Package is now obsolete as of v2.0.0

wp-cli/cache-command

  • Adapt package for framework v2 [#32]

wp-cli/checksum-command

  • Make soft changes more flexible for plugin checksums [#43]
  • More flexible soft change checks (issue #34) [#41]
  • Add backslash to the regex for matching Windows paths correctly [#39]
  • Scaffold correct GitHub labels [#37]
  • Adapt package for framework v2 [#50]

wp-cli/config-command

  • Fix library version to ^1.2.1 [#53]
  • Removed leftover remove() operation [#52]
  • Introduce config edit command [#48]
  • Add higher timeout config value [#67]
  • Adapt package for framework v2 [#66]
  • Ensure file_put_contents() writes to the wp-config.php path [#63]
  • Add shuffle-salts command [#62]
  • Set WP_CACHE_KEY_SALT [#59]

wp-cli/core-command

  • Bring template files over from wp-cli/wp-cli [#73]
  • Fix mustache template file path [#77] & [#78]
  • Sanitize database at the end of install to prevent duplicate data [#76]
  • Adapt package for framework v2 [#81]

wp-cli/cron-command

  • Adapt package for framework v2 [#29]

wp-cli/db-command

  • Add db columns command [#100]
  • Count users instead of posts for the smoke test [#98]
  • Fix test failure due to introduction of wp_blogmeta table [#94]
  • Add db clean command [#93]
  • Add examples for exporting certain posts [#90]
  • pass --column-statistics=0 to mysqldump command [#105]
  • Add ISO size formats to db size [#104]
  • Adapt package for framework v2 [#110]

wp-cli/embed-command

  • Adapt package for framework v2 [#38]
  • Scaffold missing top-level commands [#35]

wp-cli/entity-command

  • Fix tests after Core’s introduction of a default “Privacy Policy” page [#177]
  • Abstract meta CRUD into methods [#174]
  • Remove duplicative --user_email=<user-email> argument [#173]
  • Turn latest into actual version number [#171]
  • Improve the formatting of various format parameter documentation [#168]
  • Add site meta sub-command [#159]
  • Add --unserialize flag to option list command [#156]
  • Add --from-post=<post_id> flag to create duplicate posts [#154]
  • Properly clone objects for comparison [#152]
  • Fix missing quote in documentation [#147]
  • Fix category list count [#146]
  • Add user check-password subcommand [#144]
  • Replace ‘install’ to ‘installation.’ [#187]
  • Add support for --post_date_gmt in post generate [#184]
  • Optional --skip-email flag for wp user update [#155]
  • Adapt package for framework v2 [#192]

wp-cli/eval-command

  • Adapt package for framework v2 [#27]
  • Support eval-file from STDIN (implementation for #19) [#21]

wp-cli/export-command

  • Start with an empty site to avoid count issues [#36]
  • Adapt package for framework v2 [#44]

wp-cli/extension-command

  • Add missing templates to this repository [#107]
  • Replace retired themes used in tests with new ones [#105]
  • Introduce theme mod list [#100]
  • Refresh README.md and test suite prior to v1.1.10 release. [#89]
  • Allow for modern-wordpress redirect [#85]
  • Add --all flag for plugin uninstall command [#84]
  • Fix mustache file paths [#109] & [#112]
  • Search: Add plugin or theme’s URL on <wordpress.org> [#108]
  • Add --all flag to plugin delete [#103]
  • Adapt package for framework v2 [#116]

wp-cli/i18n-command

  • Prepare for v2 release [#72]
  • WordPress Core support [#69]
  • Check for more mistakes in translatable strings [#64]
  • Separate translation extraction from Po file writing [#63]
  • Make PhpFunctionsScanner extensible [#62]
  • Separate command argument handling from actual __invoke() [#60]
  • Add --headers parameter [#58]
  • Add X-Generator header to POT file [#57]
  • Print some more helpful debug messages [#56]
  • Factor directory iterator as a trait [#54]
  • Text domain header [#43]
  • Add @when before_wp_load to command namespace [#42]
  • Add option to extract strings with any text domain [#38]
  • Correctly pass exclude option to JsCodeExtractor [#37]
  • Add warning when a string has two different translator comments [#34]
  • Exclude some common directories [#32]
  • Add ability to merge with existing POT file [#31]
  • JavaScript String Extraction [#26]
  • Don’t try to extract anything when there are no PHP files [#24]
  • Add more tests related to translator comments [#23]
  • Standardize file names [#21]
  • Extract all supported functions. [#13]

wp-cli/import-command

  • Adapt post/page generation to make them resilient to added privacy policy page [#25]
  • Adapt package for framework v2 [#30]

wp-cli/language-command

  • Revert “Add plugin and theme command” [#28]
  • Adapt package for framework v2 [#43]
  • Use download_url() in language pack upgrader [#41]
  • Enable updating languages for individual plugins and themes [#40]
  • Warn if no plugin or theme has been specified [#38]
  • Add is-installed command to check if a given language is installed [#36]
  • Update language core update --dry-run message [#32]
  • Add language plugin and language theme command. [#29]

wp-cli/media-command

  • Adapt package for framework v2 [#85]
  • Update examples in documentation [#81]
  • Reinstate ghostscript/imagick install and fix bmp name in regenerate test. [#69]
  • Document how to fetch attachment URL after import [#68]
  • Clear WP object cache periodically on media regenerate/import. [#62]

wp-cli/package-command

  • Assume default package name if composer.json file cannot be retrieved [#78]
  • Avoid using Composer CA bundle if in phar. [#73]
  • Move test-command to wp-cli-test Github organization [#66]
  • Extract SSL certificate from Phar first before using it in Composer [#83]
  • Adapt package for framework v2 [#87]
  • Exclude broken Composer version [#91]

wp-cli/php-cli-tools

  • Remove double semi-colon [#130]
  • Fix potential endless loop in prompt() [#129]
  • Fix off-by-1 error in progress bar examples [#128]
  • Add optional $msg parameter to cli\Progress\Bar::tick() [#126]

wp-cli/rewrite-command

  • Adapt package for framework v2 [#20]

wp-cli/role-command

  • add --show-grant argument to wp cap list and --grant to wp cap add [#19]
  • Add --field=<field> support to listing roles [#17]
  • Adapt package for framework v2 [#23]

wp-cli/scaffold-command

  • Skip PHPUnit tests for PHP 7.2+ [#145]
  • Modify scaffold block to create index.js [#142]
  • Fix theme-specific paths in scaffolded blocks [#137]
  • Add PHP 7.2 to CI templates [#135]
  • Exclude tests/test-sample.php via the phpunit.xml.dist file [#134]
  • Fix sed -i option on MacOS [#132]
  • Use correct default $WP_TESTS_DIR on MacOS [#131]
  • Use phpunit 6.5.6 for PHP 7.2 to get around core test incompat. [#125]
  • Fix WPCS in theme-tests generation [#121]
  • Switch CircleCI template to CircleCI 2.0. [#115]
  • Correct 'add_new_item' label [#163]
  • Exclude string from escape warning [#162]
  • Update PHPCS default rule set [#161]
  • Add --woocommerce flag to scaffold _s command [#159]
  • Add PHPCompatibility sniffs to scaffolded [#154]
  • Add escaping for block title [#153]
  • Remove 'wp-blocks' from style dependency [#151]
  • Add function_exists() check to block PHP template [#147]
  • Adapt package for framework v2 [#166]

wp-cli/search-replace-command

  • Fix tests that are broken due to the addition of a “Privacy Policy” page [#78]
  • Handle incomplete class (un)serialization gracefully [#76]
  • Handle PCRE errors gracefully [#75]
  • Remove “Site Not Found” message from multisite usage [#69]
  • Fix broken GUID test [#81]
  • Improve --regex-limit logic [#70]
  • Adapt package for framework v2 [#86]
  • Add --regex-limit option. [#62]

wp-cli/server-command

  • Adapt package for framework v2 [#42]

wp-cli/shell-command

  • Adapt package for framework v2 [#25]
  • Better explain the --basic flag [#23]

wp-cli/widget-command

  • Adapt package for framework v2 [#19]

Contributors

Here’s the complete list of the fantastic folks that have helped make this happen:

@2020media, @abhijitrakas, @ajitbohra, @alpipego, @austinginder, @benlk, @BhargavBhandari90, @burhandodhy, @chesio, @CodeProKid, @danielbachhuber, @drzraf, @emirpprime, @ericgopak, @erlendeide, @felicianotech, @felipeelia, @fumikito, @GaryJones, @ghost, @gitlost, @greatislander, @JanVoracek, @janw-oostendorp, @javorszky, @jblz, @jmichaelward, @johnbillion, @josephfusco, @kirtangajjar, @kshaner, @lalaithan, @lf-jeremy, @libertamohamed, @marcovalloni, @marksabbath, @miya0001, @MoisesMN, @montu1996, @NicktheGeek, @ocean90, @pdaalder, @pekapl, @pixolin, @pjeby, @pmbaldha, @ptrkcsk, @ryanjbonnell, @sagarnasit, @salcode, @sasagar, @schlessera, @spacedmonkey, @spicecadet, @stevegrunwell, @strandtc, @svenkaptein, @swissspidy, @terriann, @thrijith, @tiagohillebrandt, @tomjn, @torounit, @wojsmol, @wp-make-coffee, @yousan, @zipofar

A big thank you to all involved! ❤️

#release, #v2-0-0

GPG Signature Change

Starting from May 31st, 2018 (from WP-CLI version 1.5.1 onwards), the GPG key that is used to sign the releases has changed.

Here’s the new public key for signed releases:

-----BEGIN PGP PUBLIC KEY BLOCK-----

mQENBFsQEBkBCADfGAhxQ71XaIk31SjD8dNH3uVNtPh/2SIIhYbObMvEG6uoMucP
t3jCsnkh/veKBkJ+HJ/XcARGoFYdaCZo5PTORBWOwHmeWPbu7aiAM4v3EKPc8wZP
jabtEejwZrRFlSlAu5YL25ldz5KNgvGOBdje9jUi2iovQ4lfjMEuH2sXhmDQPbDW
22Fb2xinvmlnyf5kJn9ADiWm6VEnaNvaL96TCC1iUrMJmYI0m29j2sVbKJIq8ZBO
CgtY4llPC7QskWw8VXEAq2WnQeZMVLqxOSoRDy/qUvw0RR+DfiXsrHjBxAH4uvHK
zUdnMl1Qbh2A/rfcsIaJubXg5pUXwF7TCvSPABEBAAG0JVdQLUNMSSBSZWxlYXNl
cyA8cmVsZWFzZXNAd3AtY2xpLm9yZz6JAU4EEwEIADgCGwMFCwkIBwIGFQgJCgsC
BBYCAwECHgECF4AWIQRjr3qhUGfAVhb93YijoujyJvC8BgUCWxAQ7AAKCRCjoujy
JvC8BmYTCACPEYQr89U/H/iQcI012UaOSLYLx+Qj9oA7p9gv2mZSBHNSijzhnizo
QBEg7q7BXF8B8UqL9ZhUWfG9PiR8kkFbBN1sIY0RM5cFltb3cJthVH4ZV8SUiGW6
zIOd8m5JXVnekmZyJFpufxDHms6F3Z2RNUbdZSp2Mj+5p/a4GtJhfGGpfYBbXOxG
gdx5dmipjlxfP5M3YL4QCJoySB+sY92de5b3S3tqmj7ldb/GRvN/7XjoMDwbRso6
jrhGtk8TjtAV0l/VdjebpI6zivrDLYDQq5vwi6hGPl7k88ElU47vaJiJX5yXaJ/k
LFQ3g8raFQq69nqcDjJLGds+Y+lAXrtzuQENBFsQEBkBCAC9ZUHiXbBLvCejMXKK
vFpKaVsovI6RBU8l0sC+00yvpP+TJmRXracnesTqHyTlhAUMhpbFvG0mBMBdROt5
IPRZ2S9JdJKZFVqO7Nop0elO8wUe6rsEHisUbEP49BcqDHGxfEnB/MubnJO1hHEH
1ftnZBEQW3jNagOTikki9675qF4ONvaSeCY9DkHa4lbau24SzePvtWuxYGsdX+Jf
ikFxq8N2ArPlSoVv/DKEbl5dgz1hYFJ9qBKoXSbaKk1TxZ4bA8nxcznZHS+8Lirv
tEjB8Z68Hz+pXIFJBbchC/FMatZC2hjFobedc4dT3nxf5iiH9XsHI5bqp3UEsPlx
8LP5ABEBAAGJATYEGAEIACACGwwWIQRjr3qhUGfAVhb93YijoujyJvC8BgUCWxAR
IQAKCRCjoujyJvC8BhGMCACkNhkshrOYDRoOwny8m1mI2nSIU0KnjEruaeAXrY2T
5VHNfLkTX3wD2HYO97r1CvUNBUWpmTwSicK0Z6TCDp4A9Oi+z5CA/5zBT/iydC6E
czNAPUehdLKka9Qs0vrVq22S0dDiA4xXZUvQpoo8VUKlvau9igF98mbd56U89s3L
gg7O72A/4x7rhDO0Q+U8SIBJtFmEHIcu6gHkooQW3d7opHKCjbnyqxDQ/iUY3b8o
n75TXnDJWbjCFTiTMyVTeyQfK0Us8FbJNXhMMagalRQu/sBH56S7Cg2OLciQB1B2
sLbhbfYDXYriI/OGVIPvCEIH6FX4+KiFy7RS+0JthI0R
=fQDM
-----END PGP PUBLIC KEY BLOCK-----

You can find the above current (as well as the old) key in the README.md file of the wp-cli/builds repository, as well as in the form of a downloadable file in that same repository: wp-cli/builds/wp-cli.pgp.

The new key is configured to be the following user:

WP-CLI Releases (releases@wp-cli.org)

The new key will not expire.

In case you have problems with using this key, please open an issue in wp-cli/wp-cli.

#gpg, #key, #release, #signing

Version 1.5.1 released

A new release is upon us!

We’re excited to bring you WP-CLI v1.5.1, an intermediary bugfix release with a total of 52 merged pull requests since v1.5.0 in January 2018.

About this release

This is a bugfix release, which means that you shouldn’t expect major feature enhancements. We’re working hard on v2.0.0 which is planned for the summer, and all new features will have to wait for that big one.

Notable features

Yes, I just said not to expect any new features. However, a small number of features managed to sneak into this release nevertheless.

Edit your config files with ease

The config command now has a new config edit function that opens the wp-config.php file in your favorite editor for easy changes. You can configure the editor to be used through the EDITOR environment variable [#48].

Get better insight into your capabilities

Although WordPress is able to have a capability be set to false, to effectively mean an explicit  “deny” of that capability, WP-CLI did not yet show that distinction. It only let you know that the capability was defined, but not whether it was negated, giving the false impression of it being “allowed” instead.

This has now changed, and you can get a complete picture of how the capabilities are set by adding the --show-grant to the cap list command [#19].

Breaking change: Note that the default behavior of cap list has slightly changed because of that. Whereas the previous version showed a capability set to false alongside the normal capabilities, a simple cap list without the new --show-grant flag will now hide the capabilities that are set to false, effectively returning only the capabilities that are actually “granted”.

Bugs that were fixed

Framework

  • Show help text even when proc_(open|close) aren’t available [#4758]
  • Normalize Mac tar output [#4674]
  • Tests should not depend on external commands [#4673]
  • Fix phpunit extractor, glob, behat tests [#4672]
  • Move phpunit PHP directive tests to behat [#4675]
  • Only run phpcs against PHP files on pre-commit hook [#4755]

Commands

  • plugin verify-checksums
    • Make soft change detection more flexible [#41]
    • Add backslash to the regex for matching Windows paths correctly [#39]
  • config
  • package
    • Assume default package name if composer.json file cannot be retrieved [#78]
    • Avoid using Composer CA bundle if in phar [#72]
  • scaffold block
    • Fix theme-specific paths in scaffolded blocks [#137]
    • Modify scaffold block to create index.js [#142]
  • scaffold plugin
    • Exclude tests/test-sample.php via the phpunit.xml.dist file [#134]
  • scaffold plugin-tests | theme-tests
    • Fix WPCS in theme-tests generation [#121]
    • Use correct default $WP_TESTS_DIR on MacOS [#131]
    • Fix sed -i option on MacOS [#132]
    • Switch CircleCI template to CircleCI 2.0 [#115]
    • Add PHP 7.2 to CI templates [#135]
  • search-replace
    • Handle incomplete class (un)serialization gracefully [#76]
    • Handle PCRE errors gracefully [#75]
    • Remove “Site Not Found” message from multisite usage [#69]

Contributors to this release (15 total)

danielbachhuber, emirpprime, ericgopak, felicianotech, gitlost, johnbillion, kshaner, lalaithan, pdaalder, ptrkcsk, salcode, schlessera, stevegrunwell, thrijith, torounit

#release, #v1-5-1

Version 1.5.0 released

It’s release day again!

We’re excited to bring you WP-CLI v1.5.0, with a total of 279 merged pull requests since v1.4.1 in November 2017.

This release was led by the tireless Martin Burke (@gitlost), who made sure no bug went unsquashed and no edge case untested.

New committer

  • Pascal (@swissspidy) lives in Zurich, Switzerland. Amongst other contributions, he’s been doing the hard work on the embed family of commands.

Plugin checksum verification

WP-CLI can now verify the integrity of your installed plugins through the new plugin verify-checksums command (in addition to the already existing core verify-checksums command). [#15], [#26]

# Verify the files of all installed plugins against their official checksums.
$ wp plugin verify-checksums --all
+-------------+---------------+-------------------------+
| plugin_name | file          | message                 |
+-------------+---------------+-------------------------+
| gutenberg   | backdoor.php  | File was added          |
| gutenberg   | gutenberg.php | Checksum does not match |
+-------------+---------------+-------------------------+
Error: Only verified 1 of 2 plugins (1 failed).

Note: This is a first iteration on this functionality, and it still comes with a few limitations:

  • It only works for plugins that are hosted in the official plugin repository.
  • It only works for recent versions of these plugins, as we haven’t yet rolled out code on the wordpress.org backend to retroactively generate the checksums for older versions.

Please keep these limitations in mind when you plan on using this new command.

As we will further iterate on this project to allow verification of all free themes from the themes repository, and later hopefully also third-party plugins/themes, we welcome any and all feedback to the current implementation.

WordPress config file manipulations

Managing your wp-config.php file just got a whole lot easier! Not only did we improve the config get and included both a config has and a filterable config list command… No, we finally bring you full WordPress Config file manipulation with the new config set and config delete commands. [#42], [#44]

# Get the table_prefix as defined in wp-config.php file.
$ wp config get table_prefix
wp_

# Check whether the DB_PASSWORD constant exists in the wp-config.php file.
$ wp config has DB_PASSWORD
(return exit code)

# List only database user and password from wp-config.php file.
$ wp config list DB_USER DB_PASSWORD --strict
+-------------+-------+----------+
| key         | value | type     |
+-------------+-------+----------+
| DB_USER     | root  | constant |
| DB_PASSWORD | root  | constant |
+-------------+-------+----------+

Big thanks to @fjarrett for the awesome work on the wp-cli/wp-config-transformer package that powers the changes to wp-config.php.

oEmbed management

The new embed command allows you to inspect and manipulate the oEmbed object, for instance you can clear the cached values for a particular post with

$ wp embed cache clear 123
Success: Cleared oEmbed cache.

or reset the cached values with

$ wp embed cache trigger 123
Success: Caching triggered!

You can find out what the embed HTML is for a URL with fetch:

$ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ
[youtube https://www.youtube.com/watch?v=dQw4w9WgXcQ?feature=oembed&w=525&h=295]

or look at exactly what the provider is returning by using the --raw option:

$ wp embed fetch https://www.youtube.com/watch?v=dQw4w9WgXcQ --raw
{"height":295,"thumbnail_height":360,"provider_name":"YouTube","provider_url":"https:\/\/www.youtube.com\/","author_name":"RickAstleyVEVO","width":525,"version":"1.0","thumbnail_width":480,"author_url":"https:\/\/www.youtube.com\/user\/RickAstleyVEVO","html":"<iframe width=\"525\" height=\"295\" src=\"https:\/\/www.youtube.com\/embed\/dQw4w9WgXcQ?feature=oembed\" frameborder=\"0\" allow=\"autoplay; encrypted-media\" allowfullscreen><\/iframe>","title":"Rick Astley - Never Gonna Give You Up","thumbnail_url":"https:\/\/i.ytimg.com\/vi\/dQw4w9WgXcQ\/hqdefault.jpg","type":"video"}

And lots more!

Array argument support (post meta for now)

The --meta_input option of the post create and post update commands now accepts JSON-formatted arrays, so you can add or update your post and its meta in one go:

$ wp post create --post_title='Title' --post_content='Content.' --meta_input='{"key1":"value1","key2":"value2"}
Success: Created post 123.

A great time saver, as you’d previously have to run three separate commands to get the same result.

This rather innocuous change means we can finally accept associative arrays as parameter arguments, through the use of this JSON syntax. The --meta_input parameter is probably just the first of many more to come. Let us know if you can think of other potential use cases for this syntax.

Everything else in v1.5.0

Backward Compatibility breaks

Please note that a framework change [#4624] alters the behavior of table filter arguments to the db search, db tables and search-replace commands.

The table filter arguments now:

  • Respect registered wpdb tables when given a table filter and not given the --all-tables-with-prefix or the --all-tables option.
  • Do not ignore the --scope option when given the --network option.
  • Tables are always returned in sorted order.

Also note that option list no longer shows transients by default [#127].

New and notable

  • user reset-password: Resets a user’s password [#119].
  • Command descriptions now follow the WordPress norm and use the third person singular, thanks DrewAPicture !

Command improvements

  • cli info:
    • Displays OS & shell information [#4604], [#4610].
  • core download:
    • Skips cache also when ZIP URL is 'http://' to nightly build [#44].
  • core update:
    • Ignores SSL trigger_error in WP get_core_checksums() [#48].
    • Strips wp-content/ using ZipArchive to always allow --skip-content [#59].
  • core verify-checksums
    • Warns when files prefixed with wp- are included in WordPress root [#28].
  • db *:
    • Uses new after_wp_config_load hook for early invocation of db commands [#57].
  • db check/cli/create/drop/export/import/optimize/query/repair/reset:
    • Adds --dbuser and --dbpass options to all the heightened privilege commands, and extra arguments option to check, optimize and repair [#75].
  • db search:
    • NOTE: See Backward Compatibility breaks above on treatment of table filter arguments [#4624].
  • db size:
    • Ensures default value of --size_format=<format> argument is always bytes [#69].
    • Includes support for TB and GB database size formats [#81].
  • db tables:
    • NOTE: See Backward Compatibility breaks above on treatment of table filter arguments [#4624].
  • export:
    • Adds --with_attachments option to force including attachments when --post__in has been specified. [#16].
  • media image-size:
    • Adds size ratio to output [#58], [#59].
  • media regenerate:
    • Does not throw PHP warning if no sizes metadata [#61].
  • option get:
    • Display error message if option doesn’t exist [#126].
  • option list:
    • Defaults to not showing transients [#127].
  • package *:
    • Caters for mixed-case package names [#49], [#50].
    • Adds GITHUB_TOKEN and COMPOSER_AUTH handling [#47].
  • package browse/list:
    • Catches exception if browsing/listing packages and Composer can’t access a repository [#60].
  • package install/uninstall:
    • Reverts composer.json on memory limit error [#64].
  • package install:
    • Retrieves package name from correct branch [#65].
  • plugin install:
    • Uses the Github project name as the plugin directory for Github archive URLs [#81]
  • post create/update:
    • Adds the ability to add multiple metadata by passing JSON-formatted arrays to --meta_input [#133], [#138].
  • post create:
    • Accepts category slugs in --post_category and checks if incorrect ids or slugs given [#129].
  • post delete:
    • Corrects delete message [#124].
  • post generate:
    • Adds support for generating a specific post_title [#94].
  • scaffold block:
    • Scaffolds a basic Gutenberg block for a plugin or theme [#96].
    • Adds inline documentation based on the Gutenberg Handbook, generates style.css, supports latest supportsHtml API, WordPress Coding Standards fixes [#107].
    • Updates PHP template to latest recommended method [#111].
  • scaffold child-theme:
    • Generates WordPress Coding Standards compliant code [#117].
  • scaffold plugin:
    • Adds a default task to scaffolded Gruntfile.js [#87].
    • Generates WordPress Coding Standards compliant code [#120].
  • scaffold plugin-tests:
    • Uses Composer to determine which PHPUnit version to install, instead of keying off Travis environment variable [#75].
    • Adds XML declaration to phpunit.xml.dist [#78].
    • Uses updated error message in bootstrap.php [#90].
    • Removes Composer vendor directory from Travis CI cache [#99].
  • scaffold post-type:
    • Trims dashicon- from dashicon argument to prevent duplicated string [#70].
    • Refreshes scaffolded post type labels [#84].
    • Generates WordPress Coding Standards compliant code [#110].
  • scaffold taxonomy:
    • Adds term_updated_messages to scaffolded taxonomies [#82].
    • Generates WordPress Coding Standards compliant code [#112].
  • scaffold theme-tests:
    • Adds theme_root filter to tests/bootstrap.php to make sure theme’s functions.php gets loaded [#116].
  • search-replace:
    • NOTE: See Backward Compatibility breaks above on treatment of table filter arguments [#4624].
    • Adds --skip-tables=<tables> argument to exclude specific tables [#48].
    • Disables report tables without index when using --report-change-only [#54].
    • General improvements to reporting, including disabling table display when no tables to output [#57].
    • Fixes not quoting non-integer primary keys [#59], [#63].
  • user remove-caps:
    • Errors if the cap doesn’t exist or is inherited from a role [#125].

Framework enhancements

  • Improves warning when can’t create cache directory [#4456].
  • Allows method @when to override class @when [#4458].
  • Pulls links from help texts into footnotes [#4465].
  • Implements command namespaces [#4470].
  • Generates get_site_url() without set_url_scheme() [#4473].
  • Introduces new after_wp_config_load hook (used to invoke wp db * early) [#4488].
  • Gets the hostname automatically with vagrant ssh-config [#4495].
  • Indicates other WP installs in db when install isn’t found [#4476].
  • Permits use of php7.1-mysql in Debian build [#4511].
  • Supports 'longdesc' as command argument when registering a command [#4513], [#4636].
  • Improves Extractor error messages [#4510].
  • Runs wp cache flush and wp search-replace on multisite even when site isn’t found [#4527].
  • Fixes prompting on Windows git/cygwin bash [#4547].
  • Doesn’t show 'sitecategories' table unless global terms are enabled [#4552].
  • Ensures late-registered registered commands appear in usage [#4564].
  • Improves Windows compatibility on invoking a proc and using more.com [#4572], [#4595].
  • Uses a softer PHP requirement in RPM build [#4571].
  • Only provides dictionary-based suggestions if they produce valid options [#4590].
  • Adds interval argument to make_progress_bar() [#4603].
  • Adds Utils\esc_like() polyfill of wpdb version [#4612].
  • Deals correctly with wildcards in wp_get_table_names() (see Backward Compatibility breaks above) [#4624].
  • Adds shell array parsing helper [#4623], [#4635].
  • Checks for readability of WordPress core files [#4626].
  • Adds some more suggestions for mistyped arguments [#4577].

Contributors to this release (39 total)
ahmadawais, BhargavBhandari90, danielbachhuber, davidbhayes, DrewAPicture, drzrafecotechie, emgk, eriktorsner, fjarrett, gitlost, grantpalin, gziolo, inetbiz, kirtangajjar, LC43, lukecav, marcochiesi, marksabbath, miya0001, mm-pagely, neonardo1, ntwb, ocean90, playmonorkialashaki, runofthemill, ryotsun, sagarprajapati, schlessera, Shelob9, ssnepenthe, swissspidy, szepeviktor, terriann, thrijith, vbaranovskiy-plesk, vigilanteweb, websupporter

#cli, #release, #v1-5-0