Phew, it’s finally here! Although there are not that many new features, we had a lot of work being done behind the scenes, to make future releases smoother. A lot of the processes have been improved, and we’ve managed to squash quite a few bugs while doing so.
A team of 57 contributors has collaborated on this release to get 347 pull requests merged. I’ll briefly go over some of the more noteworthy stuff, but as always, you can also skip directly to the detailed changelog or examine the breaking changes section if you’re impatient.
New Committer
- Thrijith Thankachan (@thrijith) is from Surat, India. He works for rtCamp as a WordPress Engineer and he is the developer behind the two new commands
alias
and maintenance-mode
.
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/ code standard
Through the initiative of @jrf, and with the outstanding help from @thrijith, @wojsmol & @williampatton, we now have a WP-CLI code standard that we can enforce.
For any package, you can just run composer phpcs
to verify that your code meets the CS requirements. Basic formatting issues can be automatically corrected through vendor/bin/phpcbf
(a Composer script will soon follow for that).
The goal of this big effort is to reduce the back & forth on pull requests and thus reduce the maintenance burden. For most pull requests, whitespace issues and code style issues represent the bulk of the time and effort required by the maintainers. With enforced and automated coding standards, everyone saves time and the discussion more often revolves around the actual logic that solves the problem, instead of alignment issues and spacing rules.
This is all pretty fresh, so stay tuned while more extensive documentation and updates to the tooling will follow.
New command to manage aliases
The old wp cli alias
has finally grown up and has become a complete CRUD interface for managing your WP-CLI aliases. You can alias list
to retrieve your current configuration, alias get
to retrieve an individual alias, and alias add|update|delete
to make changes.
While experimenting with these commands, please remember that you need to work around the already active global parameters. This is why we had to add a prefix (--set-<flag>
) to all the flags that let you configure the aliases. So, updating the SSH Secure SHell - a protocol for securely connecting to a remote system in addition to or in place of a password. connection string for an alias is done through alias update <key> --set-ssh=<ssh>
. If you would use --ssh
instead to configure it, you’d actually immediately connect to that SSH target instead.
# List alias information.
$ wp cli alias list
---
@all: Run command against every registered alias.
@local:
user: wpcli
path: /Users/wpcli/sites/testsite
# Get alias information.
$ wp cli alias get @dev
ssh: dev@somedeve.env:12345/home/dev/
# Add alias.
$ wp cli alias add prod --set-ssh=login@host --set-path=/path/to/wordpress/install/ --set-user=wpcli
Success: Added '@prod' alias.
# Update alias.
$ wp cli alias update @prod --set-user=newuser --set-path=/new/path/to/wordpress/install/
Success: Updated 'prod' alias.
# Delete alias.
$ wp cli alias delete @prod
Success: Deleted '@prod' alias.
New command to control maintenance mode
WP-CLI now lets you enable or disable the WordPress maintenance mode with the two simple commands maintenance activate
and maintenance deactivate
. You can query the current status with maintenance status
(for humans) or maintenance is-active
(for easy shell scripting).
# Activate Maintenance mode.
$ wp maintenance-mode activate
Enabling Maintenance mode...
Success: Activated Maintenance mode.
# Deactivate Maintenance mode.
$ wp maintenance-mode deactivate
Disabling Maintenance mode...
Success: Deactivated Maintenance mode.
# Display Maintenance mode status.
$ wp maintenance-mode status
Maintenance mode is active.
# Get Maintenance mode status for scripting purpose.
$ wp maintenance-mode is-active
$ echo $?
1
WP-CLI “binaries”
The eval-file
had a small, innocuous tweak. When it encounters a “shebang“, a first line in a file that starts with #!
, it will strip that line and try to run the rest of the file through 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. http://php.net/manual/en/intro-whatis.php.’s eval()
.
For folks not used to working in Unix shells, that might sound rather useless, but this shebang is actually a construct that your shell understands, and that lets you tell the shell how to execute the file.
As an example, here’s a file that contains such a shebang and actually points to WP-CLI’s eval-file
command:
#!/bin/env wp eval-file
<?php
echo get_bloginfo('name');
With that file structure, you can now rename that script file to something like blogname
and make it executable. It now behaves like any other shell tool, and will use WP-CLI as a shell framework for retrieving the current blog’s name.
Have fun experimenting with this new functionality, and don’t forget to share the more interesting use cases you can think of with the rest of the community!
Breaking changes
Name changes
While going through the code to make it fit for actually enforcing our new WP-CLI coding standard, we decided to rename some of the more internal functions, methods and properties to make the experience more consistent.
Although we took great care to figure out what we could safely rename and what needed to stay intact, there might be some edge cases where people are nevertheless directly coupling to some bit of internal code.
This is mostly relevant if you extend
one of the WP-CLI classes to override default behavior.
Removal of framework files from test package
The test package included a few framework files that were used to make the FeatureContext logic work. However, as wp-cli/wp-cli
was a hard requirement for wp-cli/wp-cli-tests
anyway, we removed these framework files and had the test package pull them in through the dependency.
In case you were directly coupling your code to these files as they were found in wp-cli/wp-cli-tests
(which is unlikely), then you’ll have to change your code to refer to these same files in the wp-cli/wp-cli
package. See the pull request for more details.
Consistent display of serialized meta Meta 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
Serialized data has been displayed very inconsistently, with some commands showing them as is (option list
), and some commands unserializing them automatically for display (post meta list
).
We’ve changed this so that they all show the values as they are stored, to avoid surprises.
This is a breaking change, however, and if you happened to rely on the automatic unserialization, you’ll be glad to hear that the affected commands now provide an optional --unserialize
flag to get back to the old behavior. You can even put this flag into your global config to permanently stick with the old behavior.
Affected commands are: comment meta get|list
, network meta get|list
, post meta get|list
, user meta get|list
.
Complete change log
All repositories
- Implement CS checking based on the
WP_CLI_CS
ruleset - Add PHP 7.3 to Travis CI build matrix
- Move PHP 5.4 tests from
WP_VERSION=latest
to 5.1
- Bundle new maintenance-mode command [#113]
- Add a GitHub GitHub 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/ setting for label to
dependencies.yml
[#74] - Try removing “ignore-platform-reqs” from Dependencies.yml [#72]
- Add
dependencies.yml
file to define auto-updates [#70]
- Always reattach subcommands [#5203]
- Add warning message to let the user know when
WP_CLI_SSH_PRE_CMD
is in use [#5197] - Add
aliases
subcommand for backwards compatibility [#5194] - Avoid double registration of commands [#5193]
- Add default titles to release checklists [#5168]
- Limit ranges of PHP versions in Composer [#5142]
- Add checklists for regular and patch releases [#5141]
- Add flags to include / exclude views in
wp_get_table_names()
[#5128] - Internalize
array_column()
shim, because package is abandoned [#5126] - Add command to manage aliases [#5122]
- Introduce ability to override
wp-config.php
path with env var WP_CONFIG_PATH
[#5119] - Support persistent 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/. connections [#5115]
- Fixed documented return type for
make_progress_bar()
[#5112] - Fix
FileCache::export()
not ensuring parent directories exist for $target
[#5103] - Switch
ext-readline
to ‘suggest’ instead of a hard requirement [#5102] - Update docblock for
add_command()
to properly reflect the return value [#5099] - Fix failing test under WP 5.1 [#5094]
- Update
parse_str_to_argv()
regex to be more accurate [#5090] - Update ISSUE_TEMPLATE [#5078]
- Ensure cache directories are accessible [#5068]
- Add
dependencies.yml
file to define auto-updates [#5066] - Add
WP_CLI::has_config()
method [#5063] - Change to “Happy publishing.” per change in core Core is the set of software required to run WordPress. The Core Development Team builds WordPress. [#5059]
- Adapt outdated links in
ISSUE_TEMPLATE
file [#5056] - Fix typo: Autolaoder => Autoloader [#5055]
- Update example of
wp config create
[#317] - Update link of
backwpup
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 [#315] - Update release checklist documentation to point to the issue templates [#306]
- Add
wp cli info
as first environment info [#305] - Document the
<scheme>
part of the --ssh
flag [#299] - Add documentation for the
--foo[=<bar>]
to command-cookbook.md
[#293] - Document
WP_CLI_CUSTOM_SHELL
environment variable [#292] - Change references to paths being in
.bash_profile
to .bashrc
[#290] - Update roadmap [#287]
- Add instructions for checking additional configuration files for PHP
memory_limit
[#286] - Update the ‘using a custom PHP binary’ link [#285]
- Update
hosting-companies.md
[#284] - Update link to command list in Quick Start [#282]
- Add a note about potential connection issues when using MySQL >= 8.0. [#280]
- Composer installation instructions are dated and incorrect [#279]
- Update broken links on Command Cookbook page [#276]
- Switch to githubusercontent per other submission [#322]
- pt_BR – Version update and minor adjustments [#321]
- Redirect blog to site [#320]
- Make soft change detection more flexible [#41]
- Add backslash to the regex for matching Windows paths correctly [#39]
- Update template based on latest version [#88]
- Change
Happy blogging.
to Happy publishing.
in wp-config.php
template [#82]
- Replace instances of
wp.dev
with example.com
[#115] - Change to “Happy publishing.” per change in core [#103]
- Modify tests to correctly verify
--force-regex
flag [#50]
- Allow deleting multiple options at once [#247]
- Fix logic error in presence of ‘site meta’ check [#244]
- Add count to post-type and taxonomy A taxonomy is a way to group things together. In WordPress, some common taxonomies are category, link, tag, or post format. https://codex.wordpress.org/Taxonomies#Default_Taxonomies. commands [#241]
- Reset option value to default for privacy policy on site empty [#236]
- Migrate term from a taxonomy to another one [#234]
- Include ‘supports’ field when fetching a single post type [#233]
- Check for
STDIN
if --post_content
is used [#189] - Rename
phpunit.xml
to phpunit.xml.dist
[#252]
- Strips out
#! /bin/bash
and similar at the beginning of PHP files [#35] - Fix handling of
__FILE__
and __DIR__
constants in eval()
‘d code. [#38]
- Identify non-writable directory as such [#54]
- Add the
--page
parameter to the theme search
command [#167] - Allow deleting the currently active theme [#158]
- Display warning in plugin list info if plugin version is higher than expected [#157]
- Fix success message example on plugin uninstall [#148]
- Handle extension activation for WP error or extension not found [#146]
- Set Language 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. directly to prevent exceptions [#150]
- Fix make-pot tests [#135]
- Add script file name to 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. translation files [#134]
- Improve language handling when creating JSON files [#133]
- Add support for nested theme folders [#130]
- Prevent possible PHP notice in IterableCodeExtractor [#129]
- Extend PotGenerator to improve plural forms output [#128]
- Remove project header comments for comments audit [#123]
- Change
LanguagePackUpgrader::download_package
signature [#82]
- Refactored aspects of the image collection and determination of sizes [#103]
- Adapt framework requirement [#103]
- Update success message position [#29]
- Add
--show-grant
argument to cap list
and --grant
to cap add
[#19] - Add
--field=<field>
support to listing roles [#17]
- Prevent creating unregisterable blocks due to invalid plugin slug [#203]
- Add
dependencies.yml
to plugin .distignore
[#202] - Add DeployHQ
.deployignore
to ignored files in .distignore
[#201] - Ignore various 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/. config files in plugin
.distignore
[#200] - Update links to blocks documentation [#199]
- Swapped out the .dev Google TLD for the .test RFC protected domain in doc examples [#107]
- Better explain the
--basic
flag [#23] - Close already opened process while prompting [#36]
- Add possibility to change the shell binary [#33]
- Fix a bug where adding superadmins would crash if none existed before [#22]
- Fix parsing of escaped quotes [#16]
- Normalize the newline to prevent an issue coming from OSX [#14]
- Change to “Happy publishing.” per change in core [#13]
- Add
.gitattributes
file [#12]
Contributors
@abhijitrakas, @afragen, @ajitbohra, @amieiro, @andreamk, @andrewminion-luminfire, @anthony-curtis, @atanas-angelov-dev, @cwales92, @D9Dan, @danielbachhuber, @DavidHickman, @dependencies[bot], @desrosj, @diggy, @emirpprime, @felipeelia, @jankimoradiya, @jbwtech, @jcomack, @jonathanbardo, @jrfnl, @Juberstine, @killua99, @kimdcottrell, @korikori, @kuoko, @kushalraha, @lanresmith, @localheinz, @luc122c, @man4toman, @mkaz, @mrmakadia94, @msaggiorato, @Mte90, @musicaljoeker, @nickdavis, @nishitlangaliya, @Nomafin, @pattonwebz, @rosswintle, @salcode, @shashank3105, @Sidsector9, @spicecadet, @ssnepenthe, @swissspidy, @thrijith, @tomjn, @tyrann0us, @Umang8, @villuorav, @websupporter, @wojsmol, @XedinUnknown
#release, #v2-2-0