WP-CLI – Selecting PHP version

Got the same problem! Just switch the php version. On my server PHP5.6 was default for apache, while CLI was configured with PHP7.1. After installing WP-CLI, with wp –info I got this result: PHP binary: /usr/bin/php7.1 PHP version: 7.1.5-1+deb.sury.org~xenial+1 php.ini used: /etc/php/7.1/cli/php.ini WP-CLI root dir: phar://wp-cli.phar And when i used the wp core install command … Read more

Why is it important to deactivate a plugin before deleting it?

Generally, plugins have some functionality hooked onto the deactivation action. This could be clearing cache, resetting options, you name it. Therefore the best practice is to deactivate them first, so they have the opportunity to clean up and execute whatever functionality they have hooked onto the deactivate event. Now if the plugin is broken and … Read more

WP-CLI not recognizing commercial plugin updates

What you experienced may be some network level problem or someone temporary removed the download resources. For instance before the update. Most of the details you can get from the source code https://github.com/wp-cli/wp-cli. Plugin update function in there looks like this. function update( $args, $assoc_args ) { if ( isset( $assoc_args[‘version’] ) ) { foreach … Read more

Fastest way (least amount of steps) to locally import a remote database using WP-CLI

Since WP-CLI 0.24.0 you can now use aliases which enable you to import a remote database quite easily. By using aliases, you can run WP-CLI commands against another WP-CLI install. That install could be a remote machine. With this in mind I’ve hacked together a bash alias that chains together several WP-CLI commands to pull … Read more

How I prevent a plugin to be loaded when doing WP-CLI?

One of the first things WordPress does to load plugins is get the active plugins as saved in the database: $active_plugins = (array) get_option( ‘active_plugins’, array() ); Since it uses get_option() we can use the option_active_plugins filter to modify the list of active plugins on the fly. function wpse_301282_disable_plugin( $active_plugins ) { if ( defined( … Read more

how to update serialized options programatically?

WP-CLI is definitely the answer to this after the update to 1.4.0 which introduced the pluck and patch commands for accessing serialized data in WordPress. The pluck command takes this format for grabbing serialized values wp option pluck <key> <key-name> For example in the active_plugins option you can grab first item wp option pluck active_plugins … Read more