diff --git a/woocommerce.php b/woocommerce.php index 874f1847c27..425611d8ca3 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -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 }