Skip to content

Commit 4451c32

Browse files
committed
Merge branch 'develop' of github.com:wp-graphql/wp-graphql-woocommerce into develop
2 parents c4be144 + a702bee commit 4451c32

File tree

6 files changed

+56
-5
lines changed

6 files changed

+56
-5
lines changed

access-functions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*
55
* @package WPGraphQL\WooCommerce
66
* @since 0.0.1
7+
* @deprecated v0.10.2
8+
*
9+
* Will be removed in v0.11.0. Some functions will be relocated.
710
*/
811

912
/**

class-woographql-inflect.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* @link https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b
1010
* @package WPGraphQL\WooCommerce
1111
* @since 0.0.4
12+
* @deprecated v0.10.2
13+
*
14+
* Will be removed in v0.11.0. Functionality will be no longer in use.
1215
*/
1316

1417
if ( ! class_exists( 'WooGraphQL_Inflect' ) ) :

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/class-wp-graphql-woocommerce.php

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,56 @@ public function __wakeup() {
137137
*/
138138
private function includes() {
139139

140-
// Autoload Required Classes.
141-
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && false !== WPGRAPHQL_WOOCOMMERCE_AUTOLOAD ) {
142-
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php';
140+
/**
141+
* WPGRAPHQL_AUTOLOAD can be set to "false" to prevent the autoloader from running.
142+
* In most cases, this is not something that should be disabled, but some environments
143+
* may bootstrap their dependencies in a global autoloader that will autoload files
144+
* before we get to this point, and requiring the autoloader again can trigger fatal errors.
145+
*
146+
* The codeception tests are an example of an environment where adding the autoloader again causes issues
147+
* so this is set to false for tests.
148+
*/
149+
if ( defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && true === WPGRAPHQL_WOOCOMMERCE_AUTOLOAD ) {
150+
if ( file_exists( WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php' ) ) {
151+
// Autoload Required Classes.
152+
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'vendor/autoload.php';
153+
}
154+
155+
/**
156+
* If GraphQL class doesn't exist, then dependencies cannot be
157+
* detected. This likely means the user cloned the repo from Github
158+
* but did not run `composer install`
159+
*/
160+
if ( ! class_exists( 'Firebase\JWT\JWT' ) ) {
161+
add_action(
162+
'admin_notices',
163+
function () {
164+
if ( ! current_user_can( 'manage_options' ) ) {
165+
return;
166+
}
167+
168+
echo sprintf(
169+
'<div class="notice notice-error">' .
170+
'<p>%s</p>' .
171+
'</div>',
172+
esc_html__(
173+
'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`.',
174+
'wp-graphql-woocommerce'
175+
)
176+
);
177+
}
178+
);
179+
180+
return false;
181+
}
143182
}
144183

145184
// Required non-autoloaded classes.
146185
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'access-functions.php';
147186
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'class-woographql-inflect.php';
187+
require_once WPGRAPHQL_WOOCOMMERCE_PLUGIN_DIR . 'includes/functions.php';
188+
189+
return true;
148190
}
149191

150192
/**

includes/functions.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*
55
* @package WPGraphQL\WooCommerce
66
* @since 0.3.1
7+
* @deprecated v0.10.2
8+
*
9+
* Will be removed in v0.11.0
710
*/
811

912
namespace WPGraphQL\WooCommerce\Functions;

tests/_data/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010

1111
if ( ! defined( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) && false !== getenv( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) ) {
12-
define( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD', getenv( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD' ) );
12+
define( 'WPGRAPHQL_WOOCOMMERCE_AUTOLOAD', true );
1313
}
1414

1515
if ( ! defined( 'GRAPHQL_JWT_AUTH_SECRET_KEY' ) ) {

0 commit comments

Comments
 (0)