‘Tis the season to celebrate a new release of WP-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/! 🎄
A total of 39 contributors has collaborated on this release to have a staggering 293 pull requests merged. We’ll go over the main areas now, but you also skip directly to the detailed changelog or ponder over the breaking changes section if you’re impatient.
i18n – round two!
The recent
i18n make-pot
command has replace the old
make-pot
tool in WordPress
Core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. and is now the official translation build tool for the Core. This effort has lead to numerous improvements to make it both more robust and more flexible.
Amongst the more notable changes, it can now parse
JavaScript JavaScript or JS is an object-oriented computer programming language commonly used to create interactive effects within web browsers. WordPress makes extensive use of JS for a better user experience. While PHP is executed on the server, JS executes within a user’s browser. https://www.javascript.com/. in addition to the
PHP 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. https://www.php.net/manual/en/preface.php. files, and together with the new
i18n make-json
command that lets you produce separate
JSON JSON, or JavaScript Object Notation, is a minimal, readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. files, you’re all set to make your
Gutenberg The Gutenberg project is the new Editor Interface for WordPress. The editor improves the process and experience of creating new content, making writing rich content much simpler. It uses ‘blocks’ to add richness rather than shortcodes, custom HTML etc. https://wordpress.org/gutenberg/ blocks translatable!
Translation pack improvements
We didn’t stop there with regards to making WordPress an “international success”… the
language
family of commands got several improvements and fixes. The most notable one is that
language plugin|theme update
now understands an
--all
flag, so you can update language packs for all your installed plugins/themes in one go.
# Update the language packs for all plugins.
$ wp language plugin update --all
Updating 'Japanese' translation for Akismet 3.1.11...
Downloading translation from https://downloads.wordpress.org/translation/plugin/akismet/3.1.11/ja.zip...
Translation updated successfully.
Updating 'Japanese' translation for Contact Forms 7 4.2.1...
https://downloads.wordpress.org/translation/plugin/contact-form-7/4.2.1/ja.zip...
Translation updated successfully.
Success: Updated 2/2 translation.
Partial prompting
The lesser known
--prompt
global parameter has now become even more useful. Instead of always prompting for all arguments, it skips those that were already provided, as you would probably already have expected.
One way this can be used is to prefill all arguments that you can remember and then use
--prompt
to help you with the more arcane flags.
More importantly, though, you can now prefill all the arguments that are already known inside of a script, and then add the
--prompt
argument to let the script query the remaining information from the user.
Manage the WP-CLI cache
We added two additional commands that let you manage the WP-CLI internal cache.
cli cache clear
will clear the entire cache, whereas
cli cache prune
will only clear the elements known to be stale. This latter will for example remove all the versions of WP core that you downloaded except for the most recent one.
# Remove all cached files.
$ wp cli cache clear
Success: Cache cleared.
# Remove all cached files except for the newest version of each one.
$ wp cli cache prune
Success: Cache pruned.
Better control over transients
You can now list the current transients on your site or network using the filterable
transient list
command. You can search for specific transients or exclude the ones you want to hide. You can even choose whether you want the expiration to be displayed in a human-readable or machine-parseable format.
# List all transients
$ wp transient list
+------+-------+---------------+
| name | value | expiration |
+------+-------+---------------+
| foo | bar | 39 mins |
| foo2 | bar2 | no expiration |
| foo3 | bar2 | expired |
| foo4 | bar4 | 4 hours |
+------+-------+---------------+
Furthermore, transients are now handled more consistently across
multisite 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. networks, and allow you to properly distinguish between regular transients and site transients.
Database management improvements
Also, the
db size
loved the idea of a
--human-readable
flag like in the
transient list
command so much that it got its own version. This will always use the unit that is best adapted to convey the information.
# List the size of the database in a human-readable form
$ wp db size --tables --human-readable
+---------+--------+
| Name | Size |
+---------+--------+
| my_site | 117 MB |
+---------+--------+
Furthermore, the
db import
command now understands all the flags that the
mysql
binary does, so that you can get past errors in SQL exports or adapt the result you want to see in your target site.
# Import an SQL export file that contains errors, by
# passing the --force argument to mysql binary.
$ wp db import export-with-errors.sql --force
Success: Imported from 'export-with-errors.sql'.
Smarter configuration
The
config
commands are now smarter. They not only allow you to edit the
wp-config.php
even on a broken WordPress installation, but you’re also able to retrieve the individual settings in whatever format best fits your scripting needs.
Finally, adding new configuration values or updating existing ones will now only throw errors in the most ambiguous scenarios, while they
just work for the majority use cases without the need to explicitly specify a
--type
.
Checking the existence of a post
You can now check whether a given post exists by using the new
post exists
command. It returns a shell exit code, so you can use it directly in shell conditionals.
if wp post exists 42; then
echo "Skipping post import for ID 42, it already exists."
else
echo "Importing post with ID 42..."
# ...
fi
Breaking changes
- While we had already bumped the minimum PHP version in v2.0.0 and started using PHP 5.4+ code in some places, we now actively enforce this requirement in the bootstrapping code [wp-cli#5039](https://github.com/wp-cli/wp-cli/pull/5039).
- The restructuring of the packages in v2.0.0 produced a regression which caused overrides through the package manager to not work anymore. We fixed this by completely ripping the framework out of the regular Composer autoload flow. This should now lead to less surprises when rearranging the Composer compositions, but might have side-effects in some exotic Composer setups [wp-cli#5010](https://github.com/wp-cli/wp-cli/pull/5010).
- The breaking change from v2.0.1 to throw an error for non-lowercase theme slugs was reverted, as it broke far more than we anticipated. That’s why we now break the breaking change to get back to the original behavior [extension-command#137](https://github.com/wp-cli/extension-command/pull/137). 😛
- WP-CLI tries to speak proper English now. To achieve this, we changed the output to use the real world “installation” where we were using the fantasy term “install” before [wp-cli#4946](https://github.com/wp-cli/wp-cli/pull/4946).
Complete change log
- Bump PHP version to 5.4+ for PHP Compatibility Checker [#63]
- Bump included package-command to v2.0.3 [#35]
- Remove .behat-progress.log [#25]
- Use dev-master for framework instead of tagged release [#24]
- Add
replace-label
maintenance command [#17]
- Properly reorder synopsis passed in via
$args
[#5049] - Bump PHP version check in bootstrap code to v5.4+ [#5039]
- Remove
ext-posix
requirement from Composer file [#5038] - Fix override test on Composer stack [#5036]
- PHP 7.0+: allow for changed list assignment order [#5021]
- Skip associative arguments that were already provided on
--prompt
[#5015] - Bump PHP version to 5.4+ for PHP Compatibility Checker [#5014]
- Use custom autoloader to load framework [#5010]
- Add extension requirements to
composer.json
file [#5001] - Add
ext-zip
as suggested extension [#4998] - Fix parsing of arguments for
WP_CLI::runcommand()
with launch=false
[#4989] - Match the way WordPress Core locates
wp-config.php
[#4984] - Use
dirname()
instead of ..
to locate wp-config.php
to match Core behavior [#4963] - Update README to account for the 280-character limit on Twitter [#4962]
- Use “installation” instead of “install” in documentation [#4960]
- Bump included package-command to v2.0.3 [#4957]
- Reattach existing subcommands from namespace to replacing command [#4951]
- Convert ‘install’ to ‘installation’ [#4946]
- Add sibling
vendor
folder location [#4938] - Check and display help command if requested [#4928]
- Fix
var_export
return in WP_CLI::print_value
[#4926] - Adapt README.md file for v2.0.1 release [#4924]
- Bump version to 2.1.0-alpha [#4898]
- Added
cli cache prune
& cli cache clear
commands [#4787]
- Add Savvii to hosting companies [#267]
- Update hosting-companies.md [#266]
- Update the set up and testing flow [#265]
- History | grep = even better than ctrl-r [#263]
- Please add One.com to the list [#261]
- Add lima-city to hosting companies [#258]
- Add plugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party Simple History [#257]
- Update
running-commands-remotely.md
to add ~/bin
approach [#256] - Use “installation” instead of “install” [#255]
- Fix issue with broken filename [#253]
- Document root cause to
STDOUT
PHP notice [#252] - Update with v2 changes [#251]
- Remove WP_CLI_Command class [#250]
- Include the cron jobs in the governance document [#248]
- Updated index.md – Spanish version [#316]
- Adapt index.md file for v2.0.1 release [#315]
- Rename
transient list
method to be consistent with other list commands [#49] - Introduce a list command to list all transients [#48]
- Make output of
transient type
generic to include multisite behaviour [#47] - Replace usage of global with
wp_using_ext_object_cache()
[#45] - Improve deleting site transients [#42]
- Use command namespaces instead of conditional addition [#54]
- Permit use of
wp config edit
when WP isn’t functional [#71] - Use constant as default type when adding new keys [#80]
- Add
--format
option for config get
command [#79] - Use
print_value()
instead of log()
for output of config get
[#78]
- Switch to wp-cli@dev [#92]
- Adapt install => installation in tests [#90]
- Fix tests for uncached nightly downloads [#100]
- Adapt framework requirement [#101]
- Make sure WP Cron is enabled for cron tests [#36]
- Fix comment argument test [#127]
- Adds
--human-readable
parameter to db size
command [#124] - Support all
mysql
flags while importing database [#123] - Add search and delete example [#122]
- Add new
db clean
to README.md
and configuration files [#119] - Fix combination of
--format
& --size_format
flags [#118] - Add links to mysql MySQL is a relational database management system. A database is a structured collection of data where content, configuration and other options are stored. https://www.mysql.com/. documentation [#117]
- Update readme [#204]
- Bump
site meta
test requirement to WP 5.1+ [#225] - Add missing
--description
flag logic for user create
[#217] - Expose the available query variables for comment and post queries [#213]
- Use “installation” instead of “install” [#212]
- List all entities in the package description [#208]
- Bail with a warning when deleting custom post types without
--force
[#188] - Add
post exists
command [#182]
- Adapt install => installation in tests [#33]
- Throw error in theme fetcher on non-lowercase slugs [#126]
- Raise timeout for HTTP HTTP is an acronym for Hyper Text Transfer Protocol. HTTP is the underlying protocol used by the World Wide Web and this protocol defines how messages are formatted and transmitted, and what actions Web servers and browsers should take in response to various commands. requests to 1 minute [#125]
- Revert “Throw error in theme fetcher on non-lowercase slugs” [#137]
- Failed plugin updates now throw errors [#143]
- Use “installation” instead of “install” [#139]
plugin delete <plugin-name>
not working if path has a space or & in it [#138]
- Require framework as hard dependency [#78]
- Add Composer config settings [#74]
- Improve detection of translator’s comments [#101]
- Improve regex replacement [#100]
- Replace regexes Peast can’t parse [#99]
- Allow skipping strings audit [#94]
- Update file-comment argument docs [#93]
- Set a placeholder PO-Revision-Date header The header of your site is typically the first thing people will experience. The masthead or header art located across the top of your page is part of the look and feel of your website. It can influence a visitor’s opinion about your content and you/ your organization’s brand. It may also look different on different screen sizes. [#92]
- Remove ‘foo’ file [#88]
- Include should override exclude instead of the other way around [#87]
- Support parsing minified JS files created by WebPack [#85]
- Add unit test cases for include/exclude options [#83]
- Allow passing an empty file comment [#82]
- Determine includes and excludes based on scores [#104]
- Add parsing of
.js.map
files to improve reliability of JS translations [#103] - Remove second argument to
WP_CLI::success()
[#112] - Normalize paths [#111]
- Normalize paths [#110]
- Add
i18n make-json
command [#109]
- Make sure upgrader strings are always in English [#54]
- Slug fixes [#53]
- Change access to
activate_language()
to private
[#47] - Don’t error when a translation is not yet available [#69]
- Check if array key exists to prevent undefined index notices [#67]
- Support installing translations for all installed plugins/themes [#64]
- Make use of report_batch_operation_results() for install commands [#63]
- Continue if
$available_updates
is not a array [#62] - Add tests for
wp site switch-language
[#57]
- Fix SVG regeneration test by adding an XML header to fake SVG file [#98]
- Make tests work with both install and installation strings [#100]
- Use forced width attribution as fallback only to avoid scrapping manual widths [#136]
- Fix incorrect namespace for cli\notify\xxx [#137]
- PHPCS PHP Code Sniffer, a popular tool for analyzing code quality. The WordPress Coding Standards rely on PHPCS. template: fix XML error in ruleset [#171]
- Add textdomain to block Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience. strings and update tests accordingly [#187]
- Use branch for
WP_TEST_TAG
for RC A beta version of software with the potential to be a final product, which is ready to release unless significant bugs emerge. and beta A pre-release of software that is given out to a large group of users to trial under real conditions. Beta versions have gone through alpha testing in-house and are generally fairly close in look, feel and function to the final product; however, design changes often occur as part of the process. [#186] - Missing text domain in
post_type_extended.mustache
[#184] - Work around Travis CI issue with _s download certificate [#182]
- Fix typo in Travis config [#180]
- Ignore ‘node_modules’ in PHPCS XML file [#178]
- Allow for
installation
as well as install
[#177] - Fix syntax error in
block-php.mustache
[#176] - Inc ‘menu_position’ when scaffolding a post type [#173]
- Remove Inflector Class [#172]
- Run
docker-php-ext-install
with sudo -E
in CircleCI [#188] - Split up the list of expected files to allow for WP 5.0+ changes [#195]
- Corrects NULL export values. [#93]
- Set
SERVER_ADDR
for the built-in webserver [#49]
- Add regression test for #5 [#8]
- Remove colloquialism [#6]
- Preserve leading whitespace characters on config update [#5]
- Fix regex for closing syntax in string [#9]
- Use real config filename in Exception messages [#11]
Contributors
Please give a big round of applause to these fine folks that have contributed their time and expertise to make this release possible:
@abhijitrakas,
@antigenius,
@austinginder,
@BhargavBhandari90,
@birkestroem,
@bitwombat,
@bonny,
@Calinou,
@danielbachhuber,
@dgroddick,
@emirpprime,
@fjarrett,
@frozzare,
@GaryJones,
@Grucqq,
@henrywright,
@herregroen,
@insomnux,
@jrfnl,
@KushibikiMashu,
@markjaquith,
@MoisesMN,
@Mte90,
@ocean90,
@phillipp,
@pmgarman,
@rmccue,
@siliconforks,
@soulseekah,
@swissspidy,
@szepeviktor,
@thrijith,
@torounit,
@tsmith1,
@VladimirAus,
@wojsmol,
@yahilmadakiya,
@yousan
Thank you! ❤️
#release, #v2-1-0