A new release of WP-CLIWP-CLIWP-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 available as of today: WP-CLI v2.7.0. For this release, we had 48 contributors collaborate to get 195 pull requests merged. 🎉
As always, big thanks to the WP-CLI sponsors that make the continued maintenance possible. ❤️
This is a small release with the main purpose of getting some much needed bug fixes into a stable version. Nevertheless, we also have a few new features that I’ll want to highlight. As always, you can also skip directly to the detailed changelog if you prefer.
Support for docker-compose run
The --ssh flag and ssh configuration key (and along with them the remote execution aliases) have learned a new scheme: docker-compose-run:.
The docker: and docker-compose: schemes for the ssh option are useful, but they only work when the target container is already running and therefore supports running a shell command via docker[-compose] exec.
With the support of the new docker-compose-run scheme in place you could put the following config into the root of any project that uses wordpressdevelop/cli and then simply use wp <cmd> instead of npm run env:cli -- <cmd> or docker-compose run cli -- <cmd>.
Customizable global parameters
It was not previously possible to extend the list of parameters without modifying the WP-CLI source files. While we are still considering different options for making the global parameters extensibleExtensibleThis is the ability to add additional functionality to the code. Plugins extend the WordPress core software. via a clean APIAPIAn 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., we already needed a short-term solution for a specific use case.
Because of this, we now introduced a set of small changes that allow the global parameters to be adapted on a “platform level”. This means that, for now, you can change the global parameters, but only if you control the environment in which WP-CLI is being executed in. This functionality works through the combination of the following changes:
A new constant WP_CLI_CONFIG_SPEC_FILTER_CALLBACK is being checked to filterFilterFilters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. the array that the config-spec.php file has provided.
A new environment variable WP_CLI_EARLY_REQUIRE is checked to allow for the environment to provide extra PHPPHPPHP (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. bootstrapping logic.
You can use both of these to let the WP_CLI_EARLY_REQUIRE load a PHP file that defines a new filter callback and then sets the WP_CLI_CONFIG_SPEC_FILTER_CALLBACK to point to that filter.
This test snippet shows an example of how these two mechanisms can be used in tandem:
Download WordPress CoreCoreCore is the set of software required to run WordPress. The Core Development Team builds WordPress. files without extracting them
Previously, you could already use the core download command not only to retrieve the set of files from the WordPress central servers. But we did not have a way to solely download a ZIP archive of WordPress Core instead.
Now you can do so via the --extract flag. This is on by default to keep with the current behavior, but you can now switch extraction off by adding the --no-extract flag.
Why would you do that, if it is a single file download you could also trigger via wget or curl? Well, for one, it uses the HTTPHTTPHTTP 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. stack of WordPress/WP-CLI to do the download. And what’s more, it allows you to use the smart WP-CLI flags like --version to automatically retrieve the file from the right URLURLA specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org.
Directly install a specific locale
Previously, when you wanted to install a locale of WordPress Core other than the default en_US, you had to first run a wp core install, and then switch the locale in a second step.
Now, WP-CLI allows you to select a specific locale right away via core install‘s new --locale flag.
Ordering of the db size results
To quickly see what the biggest tables in your installation are, you can now make use of the new --order and --orderby flags. The most useful example would be to use --orderby=size --order=desc to get the largest tables first.
Clean duplicate metaMetaMeta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. values
Due to limitations of the WordPress database schema, the WordPress importer can end up inadvertently creating duplicate post meta entries if the import is run multiple times.
WP-CLI has now learned a new command to remove duplicate post meta values for a given meta key.
# Delete duplicate post meta.
wp post meta clean-duplicates 1234 enclosure
Success: Cleaned up duplicate 'enclosure' meta values.
Exclude select plugins on certain pluginPluginA 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 commands
The plugin commands activate, deactivate, delete and uninstall now accept an additional --exclude flag if you use their --all flag.
The --exclude accepts a comma-separated list of plugin slugs, and allows you to do operations in the vein of “deactivate all plugins except for these few ones”.
# Deactivate all plugins with exclusion
$ wp plugin deactivate --all --exclude=hello,wordpress-seo
Plugin 'contact-form-7' deactivated.
Plugin 'ninja-forms' deactivated.
Success: Deactivated 2 of 2 plugins.
Multiple changes to the i18n support
In our ongoing effort to further internationalization support within GutenbergGutenbergThe 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/, we have made yet another around of i18n changes and additions.
Most of the changes deal with changes to block.json and theme.json, in order to support all the latest fields and mechanisms.
Also, there is now a new update-po command. Up until now, if you added a new translation to one of your plugins, you could update the messages.pot file with make-pot, but you’d have to update existing po files with the new translation by hand. With the new i18n update-po (which is a WP-CLI alternative to msgmerge), you get around this without requiring manual edits.
And finally, i18n now supports PHP Blade templates as an additional input format to parse for translations.
Detailed change log
To avoid too much noise in the list above, the following types of pull requests have been omitted:
PRs that only bumped dependencies to their latest version.
Fix broken tests due to DB connection failure error message change [#224]
Stop reordering most MySQLMySQLMySQL 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/. arguments [#221]
Add support for --order, --orderby flags in db size command [#226]
Support filtering for users without a role with --role=none [#360]
Sync user-contributed example to user delete [#358]
Add post meta clean-duplicates <id> <key> command [#366]
You must be logged in to post a comment.