Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:wp-graphql/wp-graphql-woocommerc…
Browse files Browse the repository at this point in the history
…e into develop
  • Loading branch information
kidunot89 committed Jul 7, 2021
2 parents c4be144 + a702bee commit 4451c32
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
3 changes: 3 additions & 0 deletions access-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*
* @package WPGraphQL\WooCommerce
* @since 0.0.1
* @deprecated v0.10.2
*
* Will be removed in v0.11.0. Some functions will be relocated.
*/

/**
Expand Down
3 changes: 3 additions & 0 deletions class-woographql-inflect.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
* @link https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b
* @package WPGraphQL\WooCommerce
* @since 0.0.4
* @deprecated v0.10.2
*
* Will be removed in v0.11.0. Functionality will be no longer in use.
*/

if ( ! class_exists( 'WooGraphQL_Inflect' ) ) :
Expand Down
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 45 additions & 3 deletions includes/class-wp-graphql-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,56 @@ public function __wakeup() {
*/
private function includes() {

// Autoload Required Classes.
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && false !== WPGRAPHQL_WOOCOMMERCE_AUTOLOAD ) {
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php';
/**
* WPGRAPHQL_AUTOLOAD can be set to "false" to prevent the autoloader from running.
* In most cases, this is not something that should be disabled, but some environments
* may bootstrap their dependencies in a global autoloader that will autoload files
* before we get to this point, and requiring the autoloader again can trigger fatal errors.
*
* The codeception tests are an example of an environment where adding the autoloader again causes issues
* so this is set to false for tests.
*/
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && true === WPGRAPHQL_WOOCOMMERCE_AUTOLOAD ) {
if ( file_exists( WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php' ) ) {
// Autoload Required Classes.
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php';
}

/**
* If GraphQL class doesn't exist, then dependencies cannot be
* detected. This likely means the user cloned the repo from Github
* but did not run `composer install`
*/
if ( ! class_exists( 'Firebase\JWT\JWT' ) ) {
add_action(
'admin_notices',
function () {
if ( ! current_user_can( 'manage_options' ) ) {
return;
}

echo sprintf(
'<div class="notice notice-error">' .
'<p>%s</p>' .
'</div>',
esc_html__(
'WooGraphQL appears to have been installed without it\'s dependencies. It will not work properly until dependencies are installed. This likely means you have cloned WPGraphQL from Github and need to run the command `composer install`.',
'wp-graphql-woocommerce'
)
);
}
);

return false;
}
}

// Required non-autoloaded classes.
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'access-functions.php';
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'class-woographql-inflect.php';
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'includes/functions.php';

return true;
}

/**
Expand Down
3 changes: 3 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*
* @package WPGraphQL\WooCommerce
* @since 0.3.1
* @deprecated v0.10.2
*
* Will be removed in v0.11.0
*/

namespace WPGraphQL\WooCommerce\Functions;
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}

if ( ! defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && false !== getenv( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) ) {
define( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD', getenv( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) );
define( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD', true );
}

if ( ! defined( 'GRAPHQL_JWT_AUTH_SECRET_KEY' ) ) {
Expand Down

0 comments on commit 4451c32

Please sign in to comment.