What’s New in WP-CLI

#
By Mike Davey, Senior Editor

Command line interfaces offer speed, flexibility, and the ability to automate repetitive tasks. In this article, we look into the features and enhancements in WP-CLI v2.10.0, and provide an update on the most recent WP-CLI Hack Day.

We’re big fans of the WordPress command line. If you’re new to WP-CLi, make sure to check out how to install WP-CLI, our guide on WP-CLI command structure, some of the best WP-CLI packages for developers, and see how to automate even more development tasks by using WP-CLI with Robo.

New i18n make-php Command

One of the standout features in WP-CLI v2.10.0 is the introduction of the i18n make-php command. This command aligns with the Performant Translations feature included in WordPress 6.5, which aims to speed up translations by using PHP files instead of MO files.

With this new command, developers can now create PHP files for all PO files in the current directory or for a specific PO file in a designated directory.

Improved Theme Updates

Another notable enhancement in this release is the ability to update themes to minor or patch versions only. Similar to the existing functionality for plugin updates, developers can now use the --minor and --patch flags when updating themes to ensure they only receive the latest minor or patch version, respectively.

This granular control over theme updates can be particularly useful for maintaining a stable and consistent WordPress environment, especially for mission-critical sites.

Multiple User Role Management

The user add-role and user remove-role commands have been improved to support adding or removing multiple roles for a given user. Developers can now easily manage a user’s roles by simply providing a list of roles as separate arguments.

This streamlined approach to user role management can be beneficial for tasks such as onboarding, offboarding, or adjusting user permissions across a WordPress site or network.

Filtering Site Lists by User

When working with a WordPress multisite network, the site list command now includes a new --site_user flag. This allows developers to filter the list of sites to only those that a specific user is a part of.

This feature can be particularly useful for administrative tasks related to access control or user offboarding, as it provides a more targeted view of the sites a user is associated with.

Bug Fixes and Improvements

In addition to the new features, this release also includes a significant number of bug fixes and general improvements to the WP-CLI framework. These range from addressing PHP deprecation warnings and improving SQLite compatibility to enhancing the overall stability and reliability of the tool. See the release notes for a complete list, but we’ve pulled a few of the more significant ones below.

  • Improved SQLite Compatibility: One of the notable improvements in this release is the enhanced compatibility with SQLite databases. The WP-CLI team has made several changes to improve the handling of SQLite, including updates to the db-command, entity-command, and extension-command packages.

  • Handling of Unparseable Tags: WP-CLI now includes a fix for gracefully handling unparseable tags, by adding a try/catch clause around the SemVer parsing, and some unit tests to verify the behavior.

  • Verbosity and Quiet Flags in SSH Command: The ssh command in WP-CLI has been updated to allow for more granular control over the verbosity and quiet levels based on the --debug flag. This gives developers the ability to fine-tune the output and logging behavior when executing remote commands, which can be valuable for debugging and troubleshooting purposes.

  • Handling of CRLF Line Endings in admin.php: The WP-CLI team has addressed an issue where PHP fatals could occur when the admin.php file had CRLF line endings.

WP-CLI Hack Day

The third WP-CLI Hack Day brought together contributors for a real-time collaboration session that saw 15 pull requests merged. The pull requests address a range of enhancements from updating the docker runner for better path resolution to adding support for GitHub release installations. An addition six pull requests received substantial progress, including adding commands for managing signups on multisite and pluck/patch commands for caches and transients.

Wrapping Up

The latest WP-CLI update packs some handy new features and improvements. The i18n make-php command, better theme updates, and enhanced user role management are all welcome additions. The recent WP-CLI Hack Day was also a success, with contributors adding new functionality and refining existing tools. It’s great to see the community staying engaged and pushing the project forward.

What would you like to see in future WP-CLI releases? More commands for managing WordPress sites and networks? Deeper integration with popular developer tools? Let us know in the comments.

About the Author

Mike Davey Senior Editor

Mike is an editor and writer based in Hamilton, Ontario, with an extensive background in business-to-business communications and marketing. His hobbies include reading, writing, and wrangling his four children.