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

Running WP Cron on multisite the right way

I think the best way is to use WP-CLI but you’d need to write a bash script to do this. Here is one that should do it for you: WP_PATH=”/path/to/wp” for SITE_URL in = $(wp site list –fields=domain,path,archived,deleted –format=csv –path=”$WP_PATH” | grep “,0,0$” | awk -F ‘,’ ‘{print $1 $2}’) do for EVENT_HOOK in $(wp … Read more

Detect if WP is running under WP-CLI

Within the php/wp-cli.php we find these lines: // Can be used by plugins/themes to check if WP-CLI is running or not define( ‘WP_CLI’, true ); define( ‘WP_CLI_VERSION’, trim( file_get_contents( WP_CLI_ROOT . ‘/VERSION’ ) ) ); define( ‘WP_CLI_START_MICROTIME’, microtime( true ) ); so you could check if WP_CLI or WP_CLI_VERSION are defined.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)