RESTful WP-CLI – No rest for the weary

Like my title? Get the pun? Te he he.

I’m just back from A Day of REST, where I spoke about a more RESTful WP-CLI, and unlocking the potential of the WP REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. at the command line. It was probably the best talk I’ve ever done. You can check out my annotated slides if you haven’t already.

The talk covered the progress I’ve already made, and the hypotheticals on my mind every day when I go for a swim.

wp-rest-cli v0.1.0

Today marks v0.1.0 for wp-rest-cli. This initial release makes WP REST API endpoints available as WP-CLIWP-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/ commands. It does so by:

  • Auto-discovering endpoints from any WordPress site running WordPress 4.4 or higher.
  • Registering WP-CLI commands for the endpoints it understands.

Warning: This project is at a very early stage. Treat it as an experiment, and understand that breaking changes will be made without warning. The sky may also fall on your head.

Here’s how it works:

$ wp rest
usage: wp rest attachment <command>
   or: wp rest category <command>
   or: wp rest comment <command>
   or: wp rest meta <command>
   or: wp rest page <command>
   or: wp rest pages-revision <command>
   or: wp rest post <command>
   or: wp rest posts-revision <command>
   or: wp rest status <command>
   or: wp rest tag <command>
   or: wp rest taxonomy <command>
   or: wp rest type <command>
   or: wp rest user <command>

$ wp --http=demo.wp-api.org rest tag get 65 --format=json
{
  "id": 65,
  "link": "http://demo.wp-api.org/tag/dolor-in-sunt-placeat-molestiae-ipsam/",
  "name": "Dolor in sunt placeat molestiae ipsam",
  "slug": "dolor-in-sunt-placeat-molestiae-ipsam",
  "taxonomy": "post_tag"
}

Notice how you can use --http=<domain> to interact with a remote WordPress site. --http=<domain> must be supplied as the second argument to be used. Without it, wp-rest-cli will look for endpoints of a WordPress site in a directory specified by --path=<path> (or the current directory, if --path=<path isn’t supplied).

Using wp-rest-cli requires the latest nightly build of WP-CLI, which you can install with wp cli update --nightly. Once you’ve done so, you can install wp-rest-cli with wp package install danielbachhuber/wp-rest-cli.

Unreleased WP-CLI improvements

Wait, wp package install. What in the?

That’s right, WP-CLI now has package management. Using wp cli update --nightly, you now can:

  • wp package browse to browse packages available for installation.
  • wp package install to install a given package.
  • wp package list to list packages installed locally.
  • wp package uninstall to uninstall a given package.

While I wasn’t planning to dive down this rabbit hole during the Kickstarter project, I was finally inspired on how to finish the feature, and took a couple hours yesterday to do so. It’s amazing how you can be mentally blocked on a problem for literally two years but then, once you’re unblocked, finish it up in a short period of time.

You’ll probably run into one or more bugs with wp package. When you do, please let me know on this issue. If the bugs get too hairy, I may pull the feature from the release and revisit. But, for now, you can much more easily install and use community packages.

wp-rest-cli also makes use of another new feature: register arbitrary functions, closures, and class methods as WP-CLI commands.

For instance, given a closure $hook_command:

$hook_command = function( $args, $assoc_args ) {
    // the meat of the command
};
WP_CLI::add_command( 'hook', $hook_command, array(
    'shortdesc' => 'List callbacks registered to a given action or filter.',
    'synopsis' => array(
        array(
            'name'        => 'hook',
            'type'        => 'positional',
            'description' => 'The key for the action or filter.',
        ),
        array(
            'name'        => 'format',
            'type'        => 'assoc',
            'description' => 'List callbacks as a table, JSON, or CSV. Default: table.',
            'optional'    => true,
        ),
    ),
) );

Then, when you run wp hook init, you’ll see:

$ wp hook init
+---------------------------------+----------+---------------+
| function                        | priority | accepted_args |
+---------------------------------+----------+---------------+
| create_initial_post_types       | 0        | 1             |
| create_initial_taxonomies       | 0        | 1             |
| wp_widgets_init                 | 1        | 1             |
| smilies_init                    | 5        | 1             |
| wp_cron                         | 10       | 1             |
| _show_post_preview              | 10       | 1             |
| rest_api_init                   | 10       | 1             |
| kses_init                       | 10       | 1             |
| wp_schedule_update_checks       | 10       | 1             |
| ms_subdomain_constants          | 10       | 1             |
| maybe_add_existing_user_to_blog | 10       | 1             |
| check_theme_switched            | 99       | 1             |
+---------------------------------+----------+---------------+

Want to use this command locally? Update to the nightly, and then run wp package install danielbachhuber/wp-hook-command.

What’s next

Well… I’ve spent a ton of hours over the last month on the WP REST API. 67.03 hours of 83 budgeted, to be precise. Given there doesn’t yet seem to be an end in sight, I may reallocate ~30 hours or so out of the WP-CLI budget for continued involvement with the WP REST API. But, I do need to slow down the pace of my involvement a bit, because it’s not sustainable.

On the wp-rest-cli front, the product problems at the top of my mind are authentication and aliases.

Instead of:

wp --http=demo.wp-api.org --user=daniel:daniel rest tag create

I’d much prefer:

wp @wpapi tag create

In the example preceeding, @wpapi is an alias for both the target and authentication.

In this hypothetical universe, aliases would also be injected into the WP-CLI runtime:

$ wp @wpapi
usage: wp @wpapi attachment <command>
   or: wp @wpapi category <command>
   or: wp @wpapi comment <command>
   or: wp @wpapi meta <command>
   or: wp @wpapi page <command>
   or: wp @wpapi pages-revision <command>
   or: wp @wpapi post <command>
   or: wp @wpapi posts-revision <command>
   or: wp @wpapi status <command>
   or: wp @wpapi tag <command>
   or: wp @wpapi taxonomy <command>
   or: wp @wpapi type <command>
   or: wp @wpapi user <command>

There’s a bit of thinking to do, and code to write, to get from here to there, though.

Feeling inspired? I want to hear from you! Particularly if you’ve written custom endpoints I can test against. Please open a Github issue with questions, feedback, and violent dissent, or email me directly.

RESTful WP-CLI – The journey begins

And so the journey begins. As with most journeys, I have a mixture of emotions: excitement, anticipation, trepidation, and eagerness. Although the destination may be far away, I know I can get there as long as I consistently take steps in the right direction.

Today marks the formal kickoff of my Kickstarter project, “A more RESTFul WP-CLI“. To celebrate the occasion, I’ve launched a project page to capture high-level goals and document my progress along the journey. I’ll keep it updated as I write blog posts every couple or few weeks. Consider these blog posts both a development log and an invitation to participate — I look forward to your comments, issues and pull requests.


For the past month or so, the question at the top of my mind has been: what does it mean to “unlock the potential of the WP REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/. at the command line”? Or, even more broadly, why do this project?

These are big questions, and I consider myself fortunate to be able to explore them over the next six months or so. Here’s how I’ve unpacked them so far, in a series of loosely connected ideas:

  • WP-CLIWP-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/’s goal is to be, quantitatively, the fastest interface for developers to manage WordPress. For anything you want to do with WordPress, using WP-CLI should save you multitudes of time over doing it some other way.
  • WP-CLI and WP REST API both offer CRUD interfaces to WordPress resources. wp post list is more or less GET /wp/v2/posts. But, wp widget list doesn’t yet have an equivalent in WP REST API. We still have a ton of work to do.
  • Building the WP REST API has been, and will continue to be, an exercise of modeling how WordPress works to a consistent (RESTful) interface. Furthermore, this model is declared in a common language for clients to interpret.
  • At some point in the future, WP-CLI will be able to ditch a substantial amount of its internals when it can use the WP REST API as its interface to WordPress. WP-CLI can continue to serve as the fastest way for developers to manage WordPress, offering higher-level metaMeta 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. operations like generate, (push|pull), and clone in addition to being a seamless command line interface to WordPress internals.
  • As WordPress developers write new endpoints for the WP REST API, it will be quite powerful to have those endpoints instantly accessible through the command line, and as accessible as coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. resources. For instance, where WP-CLI currently has the wp post * commands, WP-CLI requires Easy Digital Downloads to produce its own wp edd * commands.
  • It appears to be supremely possible to deliver this project as a series of improvements to WP-CLI, shipped over one or more versions in the next couple of quarters.

Lots of threads to pull on.


I’m starting development by working towards making wp tag list work interchangably with local and remote sites. Doing so already raises a few issues:

  • WP-CLI needs to be easier to register commands on the fly. In my prototype, I had to eval() a dynamically generated class. It would be much nicer to be able to register an arbitrary function, closure, or method as a WP-CLI command.
  • When we register REST endpoints to WP-CLI on the fly, there’s the potential for them to conflict with existing commands. Furthermore, the endpoints will vary from site to site. Ideally, the commands you see should represent the commands available on the target site. I think site aliases may offer us a backwards-compatible implementation; for instance, specifying an alias like wp @prod would only expose commands available on production.
  • Remote calls will need authentication. Ideally, it should be possible to authenticate once through a supported protocol (basic, oAuth1, APIAPI An 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. key, etc.), and store these authentication details somewhere on the file server. This is potential rationale for a config management command. If you aren’t blocking web requests to wp-cli.yml and wp-cli.local.yml already, you should be.

This project is made possible thanks to the backing of many generous organizations and individuals. Thank you again for supporting me on this journey.

Platinum

Pressed offers white-label, fully managed, WordPress hosting, built on Amazon’s cloud infrastructure. Launch your own managed WordPress hosting brand and let us handle all the maintenance, updates, customer support and billing while building a new recurring revenue stream for your business.

Gold

Chris Lema is the CTO & Chief Strategist at Crowd Favorite. He’s also a WordPress evangelist, public speaker & advisor to product companies. Human Made is a leading WordPress Development, Hosting and Consultancy Firm with a global team covering Europe, The USA, and Asia/Australia.
Pagely® is the World’s first and most scalable WordPress Hosting platform: We help the biggest brands scale and secure WordPress. Pantheon is a website management platform used to build, launch, and run awesome Drupal & WordPress websites.

Silver

Individual

Aaron Jorbin, Aki Björklund, Anu Gupta, Bjørn Ensover Johansen, Brian Krogsgard, Bronson Quick, Chuck Reynolds, Corey McKrill, Daniel Hüsken, Dave McDonald, Dave Wardle, Eli Silverman, Felix Arntz, Howard Jacobson, Japh Thomson, Jason Resnick, Jeremy Felt, Justin Kopepasah, Kailey Lampert, Kevin Cristiano, Max Cutler, Mike Little, Mike Waggoner, Nate Wright, Pippin Williamson, Quasel, Ralf Hortt, Richard Aber, Richard Wiggins, Ryan Duff, Scott Kingsley Clark, Shinichi Nishikawa, Sven Hofmann, Takayuki Miyauchi, Tom McFarlin, rtCamp


Let’s go!

Version 0.22.0 released

Happy 2016! I thought you might enjoy a new WP-CLIWP-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/ release before I dive into the RESTful CLICLI Command Line Interface. Terminal (Bash) in Mac, Command Prompt in Windows, or WP-CLI for WordPress. project.

Use wp cli update to install v0.22.0, representing 137 resolved issues and pull requests. Here’s what’s new.

search-replace for love and profit

Last month, Pantheon generously sponsored 15 hours of my time to address some of the long-standing bugs in the backlog, and make a few substantial enhancements too.

Let’s start with the good stuff:

  • Performance boost! Instead of running a MYSQLMySQL 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/. LIKE statement every 1000 rows, WP-CLI now just runs it once [#2304]. On a post metaMeta 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. table of ~3.5 million rows where 75,610 rows were affected, this change improved execution time from 734.926s to 225.509s (3.3x faster).
  • Use the --export=<filename> argument to create a SQL file of your transformed data, instead of making updates to the database [#2254]. This is a helpful feature when you want to prepare a database for a new environment without having to import and then run search-replace.
  • Wildcards can be used in table names [#2233]. search-replace against just meta tables with wp search-replace <old-string> <new-string> '*meta*'. Note: the pattern needs to be quoted, as * is a special character in Bash.

I also landed a number of search-replace bug fixes and minor enhancements:

  • Recurses objects by default when replacing inside of serialized data [#2222]. Among other things, this ensures theme mods are transformed as expected. You can disable the behavior with --no-recurse-objects. But, if you do disable the behavior, I’d like to hear from you. I think this is an unnecessary option we could remove at a later date.
  • Properly escapes quotes used in search or replace strings [#2230].
  • Lets users know to flush their persistent object cache after a search-replace procedure is performed [#2236].
  • Bails early when the replacement string is the same as the search string [#2235].
  • Indicates execution time when running search/replace with --verbose [#2242].
  • Prevents unnecessary calls to $wpdb->update() when there are no replacements to be made [#2245].
  • Drops unnecessary REGEXP query when in regex mode [#2305].

Changes to supported versions

WP-CLI’s minimum supported WordPress version is now 3.7 [#2261].

We also officially support PHPPHP 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. 7 [#2330].

Everything else in v0.22.0

Improvements to wp scaffold (plugin|plugin-tests):

  • Makes Travis less noisy by only sending email notifications on the initial build failure for a branch [#2194].
  • PluginPlugin 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 headerHeader 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. follows WordPress’ PHPDoc standards [#2197].
  • Adds .dist extension to PHPUnit config file to permit overriding with a local config file [#2247]
  • Parses readme.txt to find WordPress versions to use as Travis tested versions [#2255].
  • Includes a default .gitignore [#2297].

New flags for existing commands:

  • wp core update --minor to only perform minor updates [#2256].
  • wp (post|comment|user) meta delete <id> --all to delete all meta values on a given object [#2265].
  • wp core update-db --dry-run to see whether a database needs an upgrade [#2293].
  • wp media regenerate --only-missing for faster performance on sites with lots of images where only a small number are missing sizes [#2292].
  • wp cron event run --all to execute all registered cron events [#2323].
  • wp site empty --uploads to empty a site and delete its uploads directory too [#2339].
  • wp core install --skip-email to install without email notifications [#2345].
  • wp transient (get|set|delete) --network to manage site transients [#2351].

Framework enhancements:

  • Introduces wp_version_compare() when comparing WordPress versions [#2237]. SVNSVN Apache Subversion (often abbreviated SVN, after its command name svn) is a software versioning and revision control system. Software developers use Subversion to maintain current and historical versions of files such as source code, web pages, and documentation. Its goal is to be a mostly compatible successor to the widely used Concurrent Versions System (CVS). WordPress core and the wordpress.org released code are all centrally managed through SVN. https://subversion.apache.org/. and GitGit Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Git is easy to learn and has a tiny footprint with lightning fast performance. Most modern plugin and theme development is being done with this version control system. https://git-scm.com/. tags include -src in $wp_version, which
    version_compare() doesn’t like.
  • Defers to the $PAGER environment variable when set [#2264].
  • Introduces a composer.lock file to the project, to fix dependencies to specific hashes [#2280].
  • Magically globalizes any new variables defined in wp-config.php, as they’re expected to be global [#2318].
  • If a --require=<file> is missing, specifies the context of where the missing file is referenced for easier debugging [#2336].
  • Use mustangostang/spyc instead of bundling our own copy [#2350]. The Spyc class is still available in the global namespace.
  • Introduces WP_CLIUtilsget_temp_dir() for safer temp directories [#2353].

Improvements to other commands:

  • Includes not_found label when scaffolding a custom taxonomyTaxonomy 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. [#2196].
  • Permits installing remote plugin files without .zip in filename [#2193].
  • Warns when adding a user as a super admin when the user is already a super admin [#2202].
  • Uses WP_CLI::log() instead of WP_CLI::line() in wp import, so --quiet flag is respected [#2234].
  • Adds support to wp db tables for wildcard tables (e.g. *meta*), --all-tables-with-prefix, and --format=csv [#2250].
  • Improves error message when installing a plugin or theme and the resource isn’t found [#2253,#2267].
  • Supports custom wp export filename formats with --filename_format=<format> [#2230]
  • Assumes db errors during wp install to be installation failures, and reports accordingly [#2337].
  • Exposes plugin header details at runtime for wp scaffold plugin [#2338].
  • Includes ci/behat-tags.php in wp scaffold package-tests [#2342].

Bug fixes across the board:

  • Lets help run early when WP is detected, but not installed (e.g. wp core config --help) [#2190]. Bug was introduced in v0.20.0.
  • When scaffolding a child themeChild theme A Child Theme is a customized theme based upon a Parent Theme. It’s considered best practice to create a child theme if you want to modify the CSS of your theme. https://developer.wordpress.org/themes/advanced-topics/child-themes/., creates a safe version of the parent theme slug for the child enqueue function [#2203]. Previously, if the parent slug included dashes, an invalid enqueue function would be scaffolded.
  • Suppresses error notices when looking for wp-config.php and PHP’s open_basedir is in effect [#2211].
  • Fixes error notice in WP_CLILoggersQuiet [#2210].
  • Fixes all_items label in custom post typeCustom Post Type WordPress can hold and display many different types of content. A single item of such a content is generally called a post, although post is also a specific post type. Custom Post Types gives your site the ability to have templated posts, to simplify the concept. scaffolding [#2213].
  • Ensures install-package-tests.sh actually downloads the nightly WP-CLI Phar build, and not a redirect [#2214].
  • Sets the upload_space_check_disabled to 1 when installing multisiteMultisite 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. [#2238]. This mirrors coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress.’s behavior on new installs.
  • Provides a more helpful message when image regeneration fails [#2239].
  • Properly updates menu sub-item parent when parent is deleted [#2262].
  • Stops prefixing rewrite rules with index.php when using wp rewrite structure [#2279].
  • Fixes typo in wp transient set synopsis [#2282].
  • Restores wp core verify-checksums for non-US English locales [#2287]. Bug was introduced in v0.21.0.
  • Switches to the readline library, when available, for better support of arrow keys using --prompt [#2325].
  • WP_CLIFormatter properly checks for null values on objects [#2322].
  • In wp media import, uses host instead of scheme to determine whether a file is remote or local, for Windows compatibility [#2324].
  • Ensures updating a plugin with an invalid --version=<version> specified doesn’t delete the plugin [#2346].

Contributors to this release: 2ndkauboy, coreyworrell, danielbachhuber, davidleach, duncanjbrown, ernilambar, fjarrett, gilbitron, greg-1-anderson, iandunn, jjeaton, modelm, rodrigoprimo, ryanshoover, stevector, szepeviktor, tristanpenman, x1024

You can browse the full list of resolved issues on GithubGitHub 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/.

What the survey said, 2015 edition

Many thanks to the 206 (!!!) people who took our second user survey. We appreciate your time in helping us to understand how WP-CLIWP-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/ is being adopted by the community.

Curious as to how the numbers have changed? Take a look at the summary of the first user survey from April 2014.

By the numbers

85% of respondents use WP-CLI regularly

Of this 85%, 48% use WP-CLI multiple times per day. 37% use it a couple or few times per week. Only 15% of respondents use WP-CLI infrequently or rarely.

94% of respondents use WP-CLI interactively at the command line, 66% have incorporated it into bash scripts, and 23% are using WP-CLI with Puppet, Chef, or another provisioning system. Other tools mentioned include: Capistrano, Codeception, EasyEngine, Fabric, Grunt, and SaltStack.

Most users keep WP-CLI up to date

Over 70% of respondents keep WP-CLI up to date. Here’s how the numbers break down:

  • 13% run the latest alpha. You can too with wp cli update --nightly.
  • 58% use the latest stable release (v0.20.x at time of survey).
  • 24% are using one or two versions below the latest stable. Only 5% use a very old version of WP-CLI.

Good news — if you’re writing custom commands, you can reasonably assume it’s safe to use the latest features in WP-CLI.

WP-CLI is used for an increasing variety of tasks

Like last year, the survey included “What do you use WP-CLI for?” as a free-form field. To produce a statistical summary, I tagged each response with keywords. Of 170 interpreted values:

  • 38% (65) use WP-CLI for updating WordPress coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress., themes, or plugins.
  • 22% (38) transform their database in some way using wp search-replace.
  • 17% (29) rely upon WP-CLI when performing migrations.
  • 15% (26) make use of WP-CLI’s database management features: wp db export, wp db import and wp db optimize.
  • 11% (18) depend upon WP-CLI in provisioning scripts.
  • 10% (17) scaffold new themes and plugins with wp scaffold.
  • 9% (16) write custom commands for their own needs.
  • 6% (10) generate mock posts, users and comments.
  • 3% (5) are hearty souls who use wp shell, wp eval, and wp eval-file for debugging and quick scripts.

In no particular order, here are some third-party commands and workflows mentioned: Jetpack CLI, WP Parser, ElasticPress, WP Migrate DB Pro, WP CFM, BackWPUp, wp-cli-ssh, wp-instant-setup, project-template-wordpress, and provisioning a new WordPress.org Theme Review environment.

One person said they use WP-CLI to make coffee. On behalf of everyone, I look forward to the day I can install this command from the package directory.

Feature requests

Feel like contributing to WP-CLI over the holidays? Here’s a grab bag of enhancements you could work on:

  • Better documentation (internals, extending, common workflows).
  • One single uber-command to install WordPress, including downloading files, creating the MySQLMySQL 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/. database, setting up wp-config.php, and populating database tables.
  • Suggest correct syntax when a command is incorrectly entered (e.g. git staus).
  • Improved support for managing multiple networks: wp network list, wp network create.
  • Install plugins favorited by a given WordPress.orgWordPress.org The community site where WordPress code is created and shared by the users. This is where you can download the source code for WordPress core, plugins and themes as well as the central location for community conversations and organization. https://wordpress.org/ user.
  • Verify theme and pluginPlugin 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 checksums.
  • Report when extra files are present in wp-admin or wp-includes (e.g. checksums of directories)
  • Save a template of a WordPress setup (similar to grunt {my-task}).
  • Disable all plugins except for a specific one. Or, load WP-CLI with only a given plugin active.
  • Install WordPress nightly builds without needing the betaBeta 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. plugin.
  • Provide a command to execute WP-Cron without requiring a HTTPHTTP 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. request.
  • Define custom scaffolds for themes and plugins.
  • Generate posts, pages from a sitemap CSV.
  • Magically migrate data between environments (production -> staging).
  • Add option to exclude specific tables in wp search-replace.
  • Provide a way to log in with a one-time link.

If you can’t find an existing Github issue, please create one and we can begin discussing implementation.

Thanks again to everyone who took the time to complete our user survey! May WP-CLI continue to be a shining light for your WordPress development needs.

Versions 0.21.1 and 0.20.4 released

WordPress 4.4 loads a few new files even more files in wp-settings.php. Because WP-CLIWP-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/ has a custom wp-settings-cli.php (background), WP-CLI v0.21.1 and v0.20.4 are compatibility releases to load these new files.

Importantly, due to the nature of these changes, WP-CLI versions prior to 0.20.4 will be incompatible with WordPress 4.4.

Inspect the nature of the change in this pull request.

Contributors to this release: danielbachhuber

Version 0.21.0 released

It’s been a pretty crazy week so far, and it’s only Wednesday.

As many of you are aware of, I launched a Kickstarter campaign Monday night: A more RESTful WP-CLI. Incredibly, it was 100% funded in just under 12 hours. Check out the link for more details on what I’ll be working on in early 2016.

But, I have an even more important note about supported WordPress versions:

  • WP-CLIWP-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/ v0.22.0 (the next release) will bump the minimum supported WordPress version from 3.5 to 3.7 (background).
  • WP-CLI versions prior to 0.20.3 will be incompatible with WordPress 4.4 (background).

This important note may apply to you in some way — please take action accordingly.

WP-CLI v0.21.0 represents 109 resolved issues and pull requests. Here’s what’s new.

Load WordPress with WP_CLI::get_runner()->load_wordpress();

For a while now, you’ve been able to run a WP-CLI command before WordPress loads by adding @when before_wp_load to your command docs. Now, you can load WordPress that same command.

See how wp eval makes use of WP_CLI::get_runner()->load_wordpress():

class Eval_Command extends WP_CLI_Command {

    /**
     * Execute arbitrary PHP code.
     *
     * <php-code>
     * : The code to execute, as a string.
     *
     * [--skip-wordpress]
     * : Execute code without loading WordPress.
     *
     * @when before_wp_load
     *
     * ## EXAMPLES
     *
     *     wp eval 'echo WP_CONTENT_DIR;'
     */
    public function __invoke( $args, $assoc_args ) {
        if ( null === Utilsget_flag_value( $assoc_args, 'skip-wordpress' ) ) {
            WP_CLI::get_runner()->load_wordpress();
        }
        eval( $args[0] );
    }
}

Use wp eval --skip-wordpress <code> to execute PHPPHP 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. without loading WordPress. Or, use wp eval-file --skip-wordpress <file> to, say, execute a quick and dirty script leveraging WP-CLI utilities without needing a WordPress install present.

Similarly, when you specify a --version=<version> with wp core verify-checksums, WP-CLI will check to ensure coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. files haven’t been modified — without loading WordPress.

Creating this new feature was almost like replacing the engine on a moving car.

More verbosity with --debug

When you supply the --debug flag, you’ll get more context into how WP-CLI is executing your command.

Before:

$ wp option get home --debug
http://wordpress-test.dev

After:

$ wp option get home --debug
Debug: Using default global config: /home/vagrant/.wp-cli/config.yml (0.026s)
Debug: No project config found (0.027s)
Debug: Required file from config: /srv/www/wp-rest-cli/wp-rest-cli.php (0.059s)
Debug: ABSPATH defined: /srv/www/wordpress-test.dev/ (0.06s)
Debug: Begin WordPress load (0.063s)
Debug: wp-config.php path: /srv/www/wordpress-test.dev/wp-config.php (0.065s)
Debug: Set URL: wordpress-test.dev/ (0.066s)
Debug: Loaded WordPress (0.515s)
Debug: Running command: option get (0.516s)
http://wordpress-test.dev

Make your own commands more helpful by including WP_CLI::debug( $debug_message ); at key checkpoints.

Other changes in v0.21.0

Enhancements:

  • Use wp core update-db --network to upgrade databases across an entire network; also improves verbosity for this command by providing the from and to database versions.
  • Adds a wp comment recount command for recalcuating a post’s comment count.
  • Includes wp taxonomy list, wp taxonomy get, wp post-type list and wp post-type get for getting details about registered taxonomies and post types.
  • Use --defer-term-counting with wp post update or wp post delete to recalculate term count at the end of the operation for increased performance.
  • Returns a more useful error message when running wp scaffold plugin-tests with an invalid pluginPlugin 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 slug.
  • In wp theme list, indicates a parent theme by setting the status=parent. This more clearly distinguishes between a genuinely inactive theme vs. an “inactive” theme being used as a parent theme.
  • Displays error message when trying to use wp rewrite flush --hard on a multisiteMultisite 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. install, because WordPress doesn’t generate a .htaccess file for multisite installs.
  • Permits --path for wp core download, even when WP is detected. This lets a custom WP-CLI command download WP to a subdirectory, when loaded from the scope of an existing WP install.
  • Adds --post_type__not_in argument to wp export, which can now produce an export without, say, feedbacks.
  • Permits space-delimited IDs for wp export --post__in. This makes it easier to pass IDs returned by wp post list --format=ids.
  • Includes an .editorconfig when using wp scaffold plugin.
  • Newly-generated install-wp-tests.sh files support $WP_VERSION=trunk or $WP_VERSION=nightly for running your plugin tests against WordPress trunk.
  • Warns user when wp-config.php isn’t writable for wp core multisite-convert.
  • Provides a more helpful error message when an invalid subcommand has a valid parent command.
  • Supports using WP-CLI on a WordPress instance backed by APC cache, but only after warning and requiring confirmation.
  • Sniffssniff A module for PHP Code Sniffer that analyzes code for a specific problem. Multiple stiffs are combined to create a PHPCS standard. The term is named because it detects code smells, similar to how a dog would "sniff" out food. out the custom vendor path if WP-CLI is a part of a larger Composer project.
  • Deprecates wp post url in favor of wp post list --field=url, but includes a backwards compatability shim for wp post url.
  • Supports --autoload=(yes|no) when using wp option update (requires WordPress 4.2).
  • Supports multiple comment ids for wp comment (spam|trash|approve).
  • Paginates help output on Windows using more.
  • Provides human-friendly output when rewrite rules successfully flush.

Bug fixes:

  • Generic arguments are no longer required for wp post create and wp comment create, allowing use of those commands without supplying, say, a title.
  • Accepts associative args with no right-side data.
  • Exhausts all possible options when looking for PHP binary with wp cli update. Previously, WP-CLI would try to call php directly, which would fail on systems where PHP wasn’t exposed as such.
  • Accommodates wp_new_user_notification()‘s deprecated second argument, depending on WordPress version.

You can browse the full list of resolved issues on GithubGitHub 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/.

Contributors to this release: aaemnnosttv, borekb, danielbachhuber, gmcinnes, JRGould, johnbillion, kraftbj, miya0001, ntwb, rodrigoprimo, rmccue szepeviktor, torounit, voldemortensen, ypid

Version 0.20.3 released

WordPress 4.4 loads a few new files in wp-settings.php relating to oEmbed and the REST APIREST API The REST API is an acronym for the RESTful Application Program Interface (API) that uses HTTP requests to GET, PUT, POST and DELETE data. It is how the front end of an application (think “phone app” or “website”) can communicate with the data store (think “database” or “file system”) https://developer.wordpress.org/rest-api/.. Because WP-CLIWP-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/ has a custom wp-settings-cli.php (background), WP-CLI v0.20.3 is a compatibility release to load these new files.

Importantly, due to the nature of these changes, WP-CLI versions prior to 0.20.3 will be incompatible with WordPress 4.4.

Stay tuned next week for WP-CLI v0.21.0 (which is also compatible with WordPress 4.4), the results of the user survey, and a special announcement.

You can browse the full list of resolved issues on GithubGitHub 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/.

Contributors to this release: danielbachhuber, kraftbj, rmccue

Version 0.20.2 released

Since the beginning, install-wp-tests.sh (the setup script for pluginPlugin 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 unit tests) has installed the WordPress testing framework from trunk. However, the WordPress project recently made changes to the testing framework which mean the trunk version is incompatible with older, tagged WordPress releases.

We’ve updated install-wp-tests.sh provided by WP-CLIWP-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/ to use an appropriately-tagged version of the WordPress testing framework. However, because install-wp-tests.sh is added to a plugin during the scaffolding process, plugin authors will need to update the plugin copy of the script to fix failing tests. We weren’t able to get to the entire internet, but here are some plugins that have already been updated: pantheon-systems/wp-native-php-sessions, washingtonstateuniversity/WSUWP-Plugin-Color-Palette, ethymos/delibera

You can browse the full list of resolved issues on GithubGitHub 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/.

Contributors to this release: danielbachhuber, torounit

WP-CLI and you, 2015 edition

We’d like to know how people are using WP-CLIWP-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/ so we set up a quick survey (just 5 questions). We’d appreciate it if you would fill it out. The results will be posted here, in a future blog post.

Thanks!

Version 0.20.1 released

Curious as to why you’re getting error messages in the theme update summary table? The bug, introduced in v0.20.0, is fixed in v0.20.1

You can browse the full list of resolved issues on GithubGitHub 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/.

Contributors to this release: danielbachhuber