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
embedfamily 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
wpdbtables when given a table filter and not given the--all-tables-with-prefixor the--all-tablesoption. - Do not ignore the
--scopeoption when given the--networkoption. - 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:core download:- Skips cache also when ZIP URL is
'http://'to nightly build [#44].
- Skips cache also when ZIP URL is
core update:core verify-checksums- Warns when files prefixed with
wp-are included in WordPress root [#28].
- Warns when files prefixed with
db *:- Uses new
after_wp_config_loadhook for early invocation ofdbcommands [#57].
- Uses new
db check/cli/create/drop/export/import/optimize/query/repair/reset:- Adds
--dbuserand--dbpassoptions to all the heightened privilege commands, and extra arguments option tocheck,optimizeandrepair[#75].
- Adds
db search:- NOTE: See Backward Compatibility breaks above on treatment of table filter arguments [#4624].
db size:db tables:- NOTE: See Backward Compatibility breaks above on treatment of table filter arguments [#4624].
export:- Adds
--with_attachmentsoption to force including attachments when--post__inhas been specified. [#16].
- Adds
media image-size: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 *:package browse/list:- Catches exception if browsing/listing packages and Composer can’t access a repository [#60].
package install/uninstall:- Reverts
composer.jsonon memory limit error [#64].
- Reverts
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:post create:- Accepts category slugs in
--post_categoryand checks if incorrect ids or slugs given [#129].
- Accepts category slugs in
post delete:- Corrects delete message [#124].
post generate:- Adds support for generating a specific
post_title[#94].
- Adds support for generating a specific
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 latestsupportsHtmlAPI, 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:scaffold plugin-tests:scaffold post-type:scaffold taxonomy:scaffold theme-tests:- Adds theme_root filter to
tests/bootstrap.phpto make sure theme’sfunctions.phpgets loaded [#116].
- Adds theme_root filter to
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
@whento override class@when[#4458]. - Pulls links from help texts into footnotes [#4465].
- Implements command namespaces [#4470].
- Generates
get_site_url()withoutset_url_scheme()[#4473]. - Introduces new
after_wp_config_loadhook (used to invokewp 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-mysqlin Debian build [#4511]. - Supports
'longdesc'as command argument when registering a command [#4513], [#4636]. - Improves Extractor error messages [#4510].
- Runs
wp cache flushandwp search-replaceon 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 ofwpdbversion [#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, drzraf, ecotechie, emgk, eriktorsner, fjarrett, gitlost, grantpalin, gziolo, inetbiz, kirtangajjar, LC43, lukecav, marcochiesi, marksabbath, miya0001, mm-pagely, neonardo1, ntwb, ocean90, playmono, rkialashaki, runofthemill, ryotsun, sagarprajapati, schlessera, Shelob9, ssnepenthe, swissspidy, szepeviktor, terriann, thrijith, vbaranovskiy-plesk, vigilanteweb, websupporter