wp-cli PHP Notice after moving server behind load balancer

Check if isset() first. It will not always be set (that is what the undefined index is referring to): I took this from user temuraru $isSecure = false; if (isset($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] == ‘on’) { $isSecure = true; } elseif (!empty($_SERVER[‘HTTP_X_FORWARDED_PROTO’]) && $_SERVER[‘HTTP_X_FORWARDED_PROTO’] == ‘https’ || !empty($_SERVER[‘HTTP_X_FORWARDED_SSL’]) && $_SERVER[‘HTTP_X_FORWARDED_SSL’] == ‘on’) { $isSecure = true; … Read more

How to run wp cli from a wp hook?

Depends on what you want to do. If you want to run the PHP code that’s behind the WP-CLI code you might consider looking at https://github.com/wp-cli/entity-command Maybe you don’t actually need WP-CLI but the corresponding code behind it. Most WP-CLI commands have WordPress equivalents. For example of what I was trying to do today, the … Read more

WP-CLI media import error

I figured it out, with some help. You have to be on the same server where the files are located to use wp media import. The steps are: Log out of ssh connection Log into the remote server using sftp Upload the files using sftp, then log out Log back in using ssh Then you … Read more

wp_clear_object_cache() is deprecated. What should I use instead?

The function wp_cache_flush() should help you but is not the same one. The function runs on the global $wp_object_cache and set a new empty array, different to the WP CLI deprecated function wp_clear_object_cache for different keys of the global var. function wp_clear_object_cache() { global $wpdb, $wp_object_cache; $wpdb->queries = []; if ( ! is_object( $wp_object_cache ) … Read more

Generate Sub-Comments with WP-CLI [closed]

Currently it is not available in WP CLI. See https://github.com/wp-cli/wp-cli/blob/master/php/commands/comment.php#L136 If you want, you can have your own customized comment generation command. See command cookbook. http://wp-cli.org/docs/commands-cookbook/