Load session during cron, but not other frontend classes

Closes #7183 @claudiosmweb
This commit is contained in:
Mike Jolley 2015-07-16 17:32:31 +01:00
parent cbf373ab3c
commit 3e8228161d
1 changed files with 12 additions and 8 deletions

View File

@ -218,6 +218,11 @@ final class WooCommerce {
$this->frontend_includes();
}
if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) {
include_once( 'includes/abstracts/abstract-wc-session.php' );
include_once( 'includes/class-wc-session-handler.php' );
}
if ( $this->is_request( 'cron' ) && 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) {
include_once( 'includes/class-wc-tracker.php' );
}
@ -225,7 +230,7 @@ final class WooCommerce {
$this->query = include( 'includes/class-wc-query.php' ); // The main query class
$this->api = include( 'includes/class-wc-api.php' ); // API Class
include_once( 'includes/class-wc-auth.php' ); // Auth Class
include_once( 'includes/class-wc-auth.php' ); // Auth Class
include_once( 'includes/class-wc-post-types.php' ); // Registers post types
include_once( 'includes/abstracts/abstract-wc-product.php' ); // Products
include_once( 'includes/abstracts/abstract-wc-order.php' ); // Orders
@ -246,8 +251,6 @@ final class WooCommerce {
public function frontend_includes() {
include_once( 'includes/wc-cart-functions.php' );
include_once( 'includes/wc-notice-functions.php' );
include_once( 'includes/abstracts/abstract-wc-session.php' );
include_once( 'includes/class-wc-session-handler.php' );
include_once( 'includes/wc-template-hooks.php' );
include_once( 'includes/class-wc-template-loader.php' ); // Template Loader
include_once( 'includes/class-wc-frontend-scripts.php' ); // Frontend Scripts
@ -282,13 +285,14 @@ final class WooCommerce {
$this->countries = new WC_Countries(); // Countries class
$this->integrations = new WC_Integrations(); // Integrations class
// Session class, handles session data for users - can be overwritten if custom handler is needed
if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) {
$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
$this->session = new $session_class();
}
// Classes/actions loaded for the frontend and for ajax requests
if ( $this->is_request( 'frontend' ) ) {
// Session class, handles session data for users - can be overwritten if custom handler is needed
$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
// Class instances
$this->session = new $session_class();
$this->cart = new WC_Cart(); // Cart class, stores the cart contents
$this->customer = new WC_Customer(); // Customer class, handles data such as customer location
}