Fix Problems with WP-CLI after Updating to WordPress 4.4

I’m a big fan of WP-CLI (WordPress command line interface), which makes it easy to manage your WordPress sites from the command line or terminal (especially when you have multiple sites). One of the nice things WP-CLI allows you to do is to update the WordPress core software via a simple command:

wp core update

You can also update your WordPress plugins this way, either individually, or all at once (for one site) by issuing this simple command:

wp plugin update --all

Why WP-CLI stopped working with WordPress Version 4.4

Normally, updating plugins with WP-CLI is a breeze, but after first updating some sites to WordPress version 4.4, I suddenly began running into some trouble: updating many plugins via WP-CLI no longer works, and instead, I get a Fatal error: Class ‘WP_Widget’ not found PHP error at the command line.

The WP_Widget class is built into WordPress core, of course, and there’s no way WordPress would have released a completely broken piece of software where this class suddenly disappeared. Nevertheless, many plugins have the issue; the file that triggers the PHP error varies depending on which plugin you’re trying to update (e.g. /wp-content/plugins/gravityforms/widget.php), but the error message itself remains the same.

Updating plugins via the WordPress dashboard, however, still works fine. So what gives?

As it turns out, WP-CLI just needs to be upgraded to be compatible with WordPress 4.4, as explained here. Fortunately, the solution is easy.

All you need to do is to issue the following three Terminal commands, based on the WP-CLI installation guide:

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

That’s it! This should fix any issues you might be running into with WP-CLI being broken after the upgrade to WordPress 4.4.