Welcome to 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/!
WP-CLI is the official command line tool for interacting with and managing your WordPress sites.
Want to submit your first pull request to 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/? We’ve identified a few good first issues for you to get your feet wet:
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.1. For this release, we had 4 contributors collaborate to get 12 pull requests merged.
As always, big thanks to the WP-CLI sponsors that make the continued maintenance possible.
This is a patch release to fix a few regressions that were introduced with release v2.7.0.
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 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. 8.1 fatal error with --orderby=size and --size_format=mb [#230]
Avoid throwing error when excluding missing 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 [#332]
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>.
# wp-cli.yml
ssh: docker-compose-run:cli
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]
Fix JSONJSONJSON, 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. formatting in feature file [#368]
Add post meta clean-duplicates <id> <key> command [#366]
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.6.0. For this release, we had 57 contributors collaborate to get 311 pull requests merged. 🎉
The pandemic is still controlling our daily lives, and as a side-effect we still notice a significant reduction in contributors to WP-CLI, probably due to the lack of in-person contributor days.
As always, big thanks to the WP-CLI sponsors that make the continued maintenance possible – even with a reduced number of contributors. ❤️
Apart from the numerous bug fixes that were included in this release, we also managed to snuggle in a few new features that add to the power or convenience of your CLICLICommand Line Interface. Terminal (Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress. experience, so I want to spend a few paragraphs going over some of the noteworthy changes. As always, you can also skip directly to the detailed changelog if you prefer.
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. 8.1 Support
WP-CLI now officially supports PHP 8.1. All commands are being extensively tested against PHP 8 and the actual development is currently being done on PHP 8.1 as well.
However, keep in mind that PHP 8.1 support is not fully there for WordPress CoreCoreCore is the set of software required to run WordPress. The Core Development Team builds WordPress., and especially for a large part of plugins and themes. Due to the nature of the changes that PHP 8.1 brings about, it is very easy to break perfectly compatible WordPress Core or WP-CLI via the actions/filters system. Keep this in mind when trying to diagnose PHP 8.1 compatibility issues and trying to deduce where the erroneous code is to be found.
Tabular data showing a timeline with supported PHP releases, with only 8.0 and 8.1 currently in active support.
For those of you who are not closely following the PHP release cycles, please be aware that only PHP 8.0 and 8.1 are currently actively supported versions. WP-CLI sticks with the WordPress Core PHP support policy (+ 1 year), which means we’re still spending huge amounts of efforts to keep everything running all the way down to PHP 5.6 at the moment.
If you want to help the maintainers in their work, please ensure that all your sites run on the latest PHP versions, and nag your hosting providers to move everything over to the latest and greatest. WordPress will only bump the minimum version when the number of active sites on PHP 5.6 has dropped to an insignificant amount.
New commands for managing application passwords
The following commands were added to allow CLI users to create and manage WordPress application passwords:
wp user application-password list
wp user application-password get
wp user application-password exists
wp user application-password update
wp user application-password record-usage
wp user application-password create
wp user application-password delete
WP-CLI examples of creating a new application password and then listing all existing application passwords for that same user.
Although you could technically already work with application passwords by directly controlling the WordPress user-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. table, this now provides 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. that abstracts away the technical implementation. See the Application Passwords: Integration Guide to find out more about how to use them.
New global flag: --context
A new global flag --context=<context> was added which allows users to select the WordPress context in which WP-CLI is supposed to execute its command(s).
One of the main goals is to allow WP-CLI to run updates on premium plugins and themes without requiring any special setup. From our initial testing, this allows a large range of popular premium extensions to just work™️ with WP-CLI in terms of their update procedures.
Possible values for this flag with this initial release:
cli: The context which has been the default before introduction of this flag. This is something in-between a frontend and an admin request, to get around some of the quirks of WordPress when running on the console.
admin: A context that simulates running a command as if it would be executed in the administration backend. This is meant to be used to get around issues with plugins that limit functionality behind an is_admin() check.
auto: Switches between cli and admin depending on which command is being used. For this initial release, all wp plugin * and wp theme * commands will use admin, while all other commands will use cli.
frontend: [WIP] This does nothing yet.
Roadmap: By default, the --context flag will be set to cli with this initial release (v2.6.0). With WP-CLI v2.7.0, the default will change to auto. This gradual deployment will allow hosters and site owners to run tests on v2.6.0 by manually setting the context before the default behavior is changed.
If you want to use the future default of --context=auto right away in your present operations, you can do so by adding the necessary context: auto line to your global wp-cli.yml configuration file. Feel free to check the documentation on WP-CLI configuration files if this is new to you.
We also have a new hook to support this new global flag: before_registering_contexts. This hook behaves like a 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. with one argument: array<string, Context> $contexts. When hooking into this hook, the callback should return (a potentially modified) $contexts value. This can be used to remove or override bundled contexts or add new ones.
To make this work, the hook functionality in WP-CLI (provided via WP_CLI::do_hook()) was modified to return the first argument if arguments were provided.
Thanks to Cloudways for the special support and testing of this new flag with the goal of solving the “premium updates problem” for everyone.
Configurable WP-CLI cache settings
The WP-CLI file cache can now be configured via the following environment variables:
WP_CLI_CACHE_DIR – Directory in which to store the cached files. Default value: "$home/.wp-cli/cache".
WP_CLI_CACHE_EXPIRY – Time after which cached files are automatically purged, in seconds. Default value: 15552000 (6 months).
WP_CLI_CACHE_MAX_SIZE – Total size of the file cache after which older files are purged, in bytes. Default value: 314572800 (300 MB).
This not only allows you to fine-tune the WP-CLI cache behavior for the best balance between available storage and bandwidth usage, it could also be used to share cache storage between installations/users (beware the security implications, though!).
Use custom names/locations for the wp-config.php file
The different config * commands now accept a new flag --config-file=<filepath> that allow you point the different manipulations towards a custom location, that might not even fully adhere to conventions for the WordPress wp-config.php file.
This allows you for example to use the config set command for a configuration file outside of the WordPress document root (and parent folder).
Keep in mind that you’re on your own when it comes to making WordPress understand the structure and bootstrap correctly!
Generate a dotenv file from your existing wp-config.php file
For all the 12-factor app fans out there, WP-CLI has learnt a new format for its config list command: --format=dotenv. This will take the existing configuration key/value pairs in your wp-config.php file and render them in a format that you can use in a .env file.
WP-CLI example of list the contents of the wp-config.php file into a file in dotenv format and then showing the result.
Combine with the previously mentioned --config-file to extract the dotenv file from an arbitrary location, even without a WordPress installation present.
Allow 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/theme enumeration without forcing an update check
Previously, when you run plugin list or theme list, WP-CLI would automatically run a check in the background to see if updates are available. This is slow and expensive to do, and might not always be what is needed, especially in scripting scenarios.
This automatic check for updates can now be disabled for these two commands with the --skip-update-check flag. This can drastically speed up some scripts and make them more reliable.
New flag --strict for adapting the filtering of taxonomies by post type
When retrieving taxonomies for a given post type, the old default behavior of WordPress (through the use of get_taxonomies()) is to only show those taxonomies that have as a sole associated post type the requested one. Taxonomies that have multiple associated post types, including the requested one, are not returned.
WordPress had added a newer mechanism via get_object_taxonomies() that would return all taxonomies that are in some way associated with the requested post type, even if other post types are associated as well.
WP-CLI now has a new --strict flag for the taxonomy list command that defines whether the strict filtering (the old default) should be used, or the more sensible inclusive approach should be used via --no-strict (or --strict=false).
We’ve opted to make this new, more sensible approach (i.e. --no-strict) the new default, so be mindful of that if you’re using taxonomy list in a script somewhere.
Another round of improvements to the i18n * commands
As with all of the recent releases, the i18n * commands have received yet another round of overall improvements to keep in sync with the localisation requirements of WordPress Core.
From new flags like --subtract-and-merge, --update-mo-files & --location and multiple improvements to the way JavascriptJavaScriptJavaScript 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/. syntax is parsed all the way up to the support for the new theme.json format, all your localization needs should be accounted for (at least for now).
Make your to check out the detailed logs to find out more and play around with the new functionality when you get the chance!
With super admin permissions come super admin consequences!
WP-CLI now mirrors the behavior of WordPress core and triggers various hooksHooksIn WordPress theme and development, hooks are functions that can be applied to an action or a Filter in WordPress. Actions are functions performed when a certain event occurs in WordPress. Filters allow you to modify certain functions. Arguments used to hook both filters and actions look the same. when you grant or revoke the super admin status to users.
The following actions are being triggered now but the super-admin add & super-admin remove commands:
revoked_super_admin (after changes, executed only on success)
Changes to the default branches
In order to make the language used in the code and documentation of WP-CLI more inclusive, work has started to change the name of default branch across all repositories. From now on, the default branch name across the WP-CLI GitHubGitHubGitHub is a website that offers online implementation of git repositories that can easily be shared, copied and modified by other developers. Public repositories are free to host, private repositories require a paid subscription. GitHub introduced the concept of the ‘pull request’ where code changes done in branches by contributors can be reviewed and discussed before being merged be the repository owner. https://github.com/ organization is main.
This change is currently a work in progress, as it unfortunately causes open pull requests to be automatically closed and often become unsalvageable. The current progress of this effort can be monitored here: wp-cli/wp-cli#5598.
Keep this in mind when you want to check out the latest development state of a repository or contribute by creating a PR!
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.
DeployDeployLaunching code from a local development environment to the production web server, so that it's available to visitors. from main branch [#385]
Adapt feature test to use HTTPSHTTPSHTTPS is an acronym for Hyper Text Transfer Protocol Secure. HTTPS is the secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to. The 'S' at the end of HTTPS stands for 'Secure'. It means all communications between your browser and the website are encrypted. This is especially helpful for protecting sensitive data like banking information. with example.com [#78]
Promote a non-200 response from the cron spawn test to an error [#66]
Update example input to reflect example output [#326]
Document default post type filtering for post list command [#321]
Correct the home URLURLA specific web address of a website or web page on the Internet, such as a website’s URL www.wordpress.org when listing sites [#312]
Fix categoryCategoryThe 'category' taxonomy lets you group posts / content together that share a common bond. Categories are pre-defined and broad ranging., tag and term names missing in export [#86]
Add the_title_export filter and cdata for item title to export [#77]
Remove now unneeded workaround in JS scanner [#256]
Extract strings for translation from theme.jsonJSONJSON, 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. [#254]
Append new widgets to the bottom of a sidebarSidebarA sidebar in WordPress is referred to a widget-ready area used by WordPress themes to display information that is not a part of the main content. It is not always a vertical column on the side. It can be a horizontal rectangle below or above the content area, footer, header, or any where in the theme. [#52]
You must be logged in to post a comment.