Created
December 25, 2021 01:48
-
-
Save baizmandesign/05a2480e7e9ed64aeb8e8233afee7f00 to your computer and use it in GitHub Desktop.
flywheel wp-cli support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the two lines below need to be added to ~/.wp-cli/config.yml or the appropriate configuration file. | |
# see https://make.wordpress.org/cli/handbook/references/config/#config-files for details about the location and name of wp-cli's config files. | |
require: | |
- flywheel.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** From Emerson Carter at Flywheel Support. | |
* Grants the ability to execute WP CLI commands remotely. | |
* Place this file in ~/.wp-cli. | |
* @link https://danielbachhuber.com/tip/wp-ssh-custom-path/ | |
*/ | |
WP_CLI::add_hook( 'before_ssh', function() { | |
$host = WP_CLI\Utils\parse_ssh_url( WP_CLI::get_runner()->config['ssh'], PHP_URL_HOST ); | |
$flywheel_path = 'WP_CLI_SSH_PRE_CMD=export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' ; | |
// FIXME: replace with correct hostnames or SSH host aliases. | |
$flywheel_hosts = [ 'your-host-1', 'your-host-2', 'your-host-3', ] ; | |
// only add path to flywheel hosts. | |
if ( in_array ( $host, $flywheel_hosts ) ) { | |
putenv( $flywheel_path ); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment