Skip to content

Commit

Permalink
Add support for wp-cli commands via /bin folder
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronHolbrook committed Apr 12, 2019
1 parent 6b45daf commit 17db241
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 35 deletions.
35 changes: 0 additions & 35 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,35 +0,0 @@
<?php

namespace Zeek\WP_Util;

use Zeek\WP_Util\ErrorHandling;
use function A7\autoload;
use function Zeek\WP_Util\get_env_value;

function bootstrap( $dir ) {
/**
* Load .env file and set up constants
*/
Constants::init( $dir );

/**
* Add Sentry Error Logging
*/
ErrorHandling::init();

/**
* Enable WP Util Behaviors
*/
new Behaviors();

/**
* Kick off third party integrations as dictated by our .env variables
*/
new ThirdParty\Init();

/**
* Autoload all php files in /src/
* // @todo ensure this path exists
*/
autoload( $dir . '/src' );
}
40 changes: 40 additions & 0 deletions src/bootstrap/bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Zeek\WP_Util;

use Zeek\WP_Util\ErrorHandling;
use function A7\autoload;
use function Zeek\WP_Util\get_env_value;
use Zeek\WP_Util\ThirdParty\Init;

function bootstrap( $dir ) {
/**
* Load .env file and set up constants
*/
Constants::init( $dir );

/**
* Add Sentry Error Logging
*/
ErrorHandling::init();

/**
* Enable WP Util Behaviors
*/
new Behaviors();

/**
* Kick off third party integrations as dictated by our .env variables
*/
new ThirdParty\Init();

/**
* Autoload all php files in /src/
*/
autoload( $dir . '/src' );

/**
* Load /bin folder for any wp cli commands safely
*/
bootstrap_wp_cli_commands( $dir );
}
24 changes: 24 additions & 0 deletions src/bootstrap/wp-cli.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

namespace Zeek\WP_Util;

use function A7\autoload;

function bootstrap_wp_cli_commands( $dir ) {

// Check to see if we're currently running WP CLI
if ( ! defined( 'WP_CLI' ) ) {
return;
}

if ( true !== WP_CLI ) {
return;
}

if ( ! class_exists( 'WP_CLI' ) ) {
return;
}

// Looks like we're running wp-cli, so we can safely load the /bin folder
autoload( $dir . '/bin' );
}

0 comments on commit 17db241

Please sign in to comment.