Merge branch 'includes'

This commit is contained in:
Mike Jolley 2017-02-16 16:28:56 +00:00
commit 36092cba54
49 changed files with 692 additions and 682 deletions

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Assets' ) ) :
if ( ! class_exists( 'WC_Admin_Assets', false ) ) :
/**
* WC_Admin_Assets Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Admin_Dashboard' ) ) :
if ( ! class_exists( 'WC_Admin_Dashboard', false ) ) :
/**
* WC_Admin_Dashboard Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
* @version 2.7.0
*/
if ( ! class_exists( 'WC_Admin_Duplicate_Product' ) ) :
if ( ! class_exists( 'WC_Admin_Duplicate_Product', false ) ) :
/**
* WC_Admin_Duplicate_Product Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Admin_Help' ) ) :
if ( ! class_exists( 'WC_Admin_Help', false ) ) :
/**
* WC_Admin_Help Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Importers' ) ) :
if ( ! class_exists( 'WC_Admin_Importers', false ) ) :
/**
* WC_Admin_Importers Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Menus' ) ) :
if ( ! class_exists( 'WC_Admin_Menus', false ) ) :
/**
* WC_Admin_Menus Class.

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Permalink_Settings' ) ) :
if ( ! class_exists( 'WC_Admin_Permalink_Settings', false ) ) :
/**
* WC_Admin_Permalink_Settings Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Post_Types' ) ) :
if ( ! class_exists( 'WC_Admin_Post_Types', false ) ) :
/**
* WC_Admin_Post_Types Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Admin_Profile' ) ) :
if ( ! class_exists( 'WC_Admin_Profile', false ) ) :
/**
* WC_Admin_Profile Class.

View File

@ -14,7 +14,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Admin_Reports' ) ) :
if ( ! class_exists( 'WC_Admin_Reports', false ) ) :
/**
* WC_Admin_Reports Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Admin_Settings' ) ) :
if ( ! class_exists( 'WC_Admin_Settings', false ) ) :
/**
* WC_Admin_Settings Class.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Accounts' ) ) :
if ( ! class_exists( 'WC_Settings_Accounts', false ) ) :
/**
* WC_Settings_Accounts.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Rest_API' ) ) :
if ( ! class_exists( 'WC_Settings_Rest_API', false ) ) :
/**
* WC_Settings_Rest_API.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Settings_Payment_Gateways' ) ) :
if ( ! class_exists( 'WC_Settings_Payment_Gateways', false ) ) :
/**
* WC_Settings_Payment_Gateways.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Emails' ) ) :
if ( ! class_exists( 'WC_Settings_Emails', false ) ) :
/**
* WC_Settings_Emails.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_General' ) ) :
if ( ! class_exists( 'WC_Settings_General', false ) ) :
/**
* WC_Admin_Settings_General.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Integrations' ) ) :
if ( ! class_exists( 'WC_Settings_Integrations', false ) ) :
/**
* WC_Settings_Integrations.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Page' ) ) :
if ( ! class_exists( 'WC_Settings_Page', false ) ) :
/**
* WC_Settings_Page.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Settings_Products' ) ) :
if ( ! class_exists( 'WC_Settings_Products', false ) ) :
/**
* WC_Settings_Products.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Settings_Shipping' ) ) :
if ( ! class_exists( 'WC_Settings_Shipping', false ) ) :
/**
* WC_Settings_Shipping.

View File

@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Settings_Tax' ) ) :
if ( ! class_exists( 'WC_Settings_Tax', false ) ) :
/**
* WC_Settings_Tax.

View File

@ -132,7 +132,7 @@ function wc_create_page( $slug, $option = '', $page_title = '', $page_content =
*/
function woocommerce_admin_fields( $options ) {
if ( ! class_exists( 'WC_Admin_Settings' ) ) {
if ( ! class_exists( 'WC_Admin_Settings', false ) ) {
include( dirname( __FILE__ ) . '/class-wc-admin-settings.php' );
}
@ -147,7 +147,7 @@ function woocommerce_admin_fields( $options ) {
*/
function woocommerce_update_options( $options, $data = null ) {
if ( ! class_exists( 'WC_Admin_Settings' ) ) {
if ( ! class_exists( 'WC_Admin_Settings', false ) ) {
include( dirname( __FILE__ ) . '/class-wc-admin-settings.php' );
}
@ -163,7 +163,7 @@ function woocommerce_update_options( $options, $data = null ) {
*/
function woocommerce_settings_get_option( $option_name, $default = '' ) {
if ( ! class_exists( 'WC_Admin_Settings' ) ) {
if ( ! class_exists( 'WC_Admin_Settings', false ) ) {
include( dirname( __FILE__ ) . '/class-wc-admin-settings.php' );
}

View File

@ -14,10 +14,6 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Legacy_API' ) ) {
include_once( dirname( __FILE__ ) . '/class-wc-legacy-api.php' );
}
class WC_API extends WC_Legacy_API {
/**

View File

@ -9,13 +9,10 @@
* @package WooCommerce/API
* @since 2.4.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Auth' ) ) :
class WC_Auth {
/**
@ -402,7 +399,4 @@ class WC_Auth {
}
}
}
endif;
return new WC_Auth();
new WC_Auth();

View File

@ -1,5 +1,4 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
@ -66,6 +65,11 @@ class WC_Autoloader {
*/
public function autoload( $class ) {
$class = strtolower( $class );
if ( 0 !== strpos( $class, 'wc_' ) ) {
return;
}
$file = $this->get_file_name_from_class( $class );
$path = '';
@ -87,7 +91,7 @@ class WC_Autoloader {
$path = $this->include_path . 'log-handlers/';
}
if ( empty( $path ) || ( ! $this->load_file( $path . $file ) && strpos( $class, 'wc_' ) === 0 ) ) {
if ( empty( $path ) || ! $this->load_file( $path . $file ) ) {
$this->load_file( $this->include_path . $file );
}
}

View File

@ -11,13 +11,17 @@
* @category Class
* @author WooThemes
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
include_once( dirname( __FILE__ ) . '/libraries/wp-async-request.php' );
include_once( dirname( __FILE__ ) . '/libraries/wp-background-process.php' );
if ( ! class_exists( 'WP_Async_Request', false ) ) {
include_once( dirname( __FILE__ ) . '/libraries/wp-async-request.php' );
}
if ( ! class_exists( 'WP_Background_Process', false ) ) {
include_once( dirname( __FILE__ ) . '/libraries/wp-background-process.php' );
}
/**
* WC_Background_Updater Class.

View File

@ -1,4 +1,8 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Enables WooCommerce, via the the command line.
*
@ -34,3 +38,5 @@ class WC_CLI {
WP_CLI::add_hook( 'after_wp_load', 'WC_CLI_Update_Command::register_commands' );
}
}
new WC_CLI;

View File

@ -226,8 +226,8 @@ class WC_Geolocation {
* @return string
*/
private static function geolocate_via_db( $ip_address ) {
if ( ! class_exists( 'WC_Geo_IP' ) ) {
include_once( dirname( __FILE__ ) . '/class-wc-geo-ip.php' );
if ( ! class_exists( 'WC_Geo_IP', false ) ) {
include_once( WC_ABSPATH . 'includes/class-wc-geo-ip.php' );
}
$gi = new WC_Geo_IP();

View File

@ -3,10 +3,6 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Session' ) ) {
include_once( dirname( __FILE__ ) . '/abstracts/abstract-wc-session.php' );
}
/**
* Handle data for the current customers session.
* Implements the WC_Session abstract class.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Email_Cancelled_Order' ) ) :
if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
/**
* Cancelled Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Completed_Order' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Completed_Order', false ) ) :
/**
* Customer Completed Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Invoice' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
/**
* Customer Invoice.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_New_Account' ) ) :
if ( ! class_exists( 'WC_Email_Customer_New_Account', false ) ) :
/**
* Customer New Account.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Note' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Note', false ) ) :
/**
* Customer Note Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_On_Hold_Order' ) ) :
if ( ! class_exists( 'WC_Email_Customer_On_Hold_Order', false ) ) :
/**
* Customer On-hold Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Processing_Order' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Processing_Order', false ) ) :
/**
* Customer Processing Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Refunded_Order' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Refunded_Order', false ) ) :
/**
* Customer Refunded Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Email_Customer_Reset_Password' ) ) :
if ( ! class_exists( 'WC_Email_Customer_Reset_Password', false ) ) :
/**
* Customer Reset Password.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Email_Failed_Order' ) ) :
if ( ! class_exists( 'WC_Email_Failed_Order', false ) ) :
/**
* Failed Order Email.

View File

@ -4,7 +4,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WC_Email' ) ) {
if ( class_exists( 'WC_Email', false ) ) {
return;
}

View File

@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WC_Eval_Math' ) ) {
if ( ! class_exists( 'WC_Eval_Math', false ) ) {
/**
* Class WC_Eval_Math. Supports basic math only (removed eval function).
*

View File

@ -1,163 +1,158 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* WP Async Request
* Abstract WP_Async_Request class.
*
* @package WP-Background-Processing
* @abstract
*/
if ( ! class_exists( 'WP_Async_Request' ) ) {
abstract class WP_Async_Request {
/**
* Abstract WP_Async_Request class.
* Prefix
*
* @abstract
* (default value: 'wp')
*
* @var string
* @access protected
*/
abstract class WP_Async_Request {
protected $prefix = 'wp';
/**
* Prefix
*
* (default value: 'wp')
*
* @var string
* @access protected
*/
protected $prefix = 'wp';
/**
* Action
*
* (default value: 'async_request')
*
* @var string
* @access protected
*/
protected $action = 'async_request';
/**
* Action
*
* (default value: 'async_request')
*
* @var string
* @access protected
*/
protected $action = 'async_request';
/**
* Identifier
*
* @var mixed
* @access protected
*/
protected $identifier;
/**
* Identifier
*
* @var mixed
* @access protected
*/
protected $identifier;
/**
* Data
*
* (default value: array())
*
* @var array
* @access protected
*/
protected $data = array();
/**
* Data
*
* (default value: array())
*
* @var array
* @access protected
*/
protected $data = array();
/**
* Initiate new async request
*/
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
}
/**
* Set data used during the request
*
* @param array $data Data.
*
* @return $this
*/
public function data( $data ) {
$this->data = $data;
return $this;
}
/**
* Dispatch the async request
*
* @return array|WP_Error
*/
public function dispatch() {
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
$args = $this->get_post_args();
return wp_remote_post( esc_url_raw( $url ), $args );
}
/**
* Get query args
*
* @return array
*/
protected function get_query_args() {
if ( property_exists( $this, 'query_args' ) ) {
return $this->query_args;
}
return array(
'action' => $this->identifier,
'nonce' => wp_create_nonce( $this->identifier ),
);
}
/**
* Get query URL
*
* @return string
*/
protected function get_query_url() {
if ( property_exists( $this, 'query_url' ) ) {
return $this->query_url;
}
return admin_url( 'admin-ajax.php' );
}
/**
* Get post args
*
* @return array
*/
protected function get_post_args() {
if ( property_exists( $this, 'post_args' ) ) {
return $this->post_args;
}
return array(
'timeout' => 0.01,
'blocking' => false,
'body' => $this->data,
'cookies' => $_COOKIE,
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
);
}
/**
* Maybe handle
*
* Check for correct nonce and pass to handler.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
check_ajax_referer( $this->identifier, 'nonce' );
$this->handle();
wp_die();
}
/**
* Handle
*
* Override this method to perform any actions required
* during the async request.
*/
abstract protected function handle();
/**
* Initiate new async request
*/
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
}
/**
* Set data used during the request
*
* @param array $data Data.
*
* @return $this
*/
public function data( $data ) {
$this->data = $data;
return $this;
}
/**
* Dispatch the async request
*
* @return array|WP_Error
*/
public function dispatch() {
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
$args = $this->get_post_args();
return wp_remote_post( esc_url_raw( $url ), $args );
}
/**
* Get query args
*
* @return array
*/
protected function get_query_args() {
if ( property_exists( $this, 'query_args' ) ) {
return $this->query_args;
}
return array(
'action' => $this->identifier,
'nonce' => wp_create_nonce( $this->identifier ),
);
}
/**
* Get query URL
*
* @return string
*/
protected function get_query_url() {
if ( property_exists( $this, 'query_url' ) ) {
return $this->query_url;
}
return admin_url( 'admin-ajax.php' );
}
/**
* Get post args
*
* @return array
*/
protected function get_post_args() {
if ( property_exists( $this, 'post_args' ) ) {
return $this->post_args;
}
return array(
'timeout' => 0.01,
'blocking' => false,
'body' => $this->data,
'cookies' => $_COOKIE,
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
);
}
/**
* Maybe handle
*
* Check for correct nonce and pass to handler.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
check_ajax_referer( $this->identifier, 'nonce' );
$this->handle();
wp_die();
}
/**
* Handle
*
* Override this method to perform any actions required
* during the async request.
*/
abstract protected function handle();
}

View File

@ -1,504 +1,500 @@
<?php
/**
* WP Background Process
*
* @package WP-Background-Processing
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! class_exists( 'WP_Background_Process' ) ) {
/**
* Abstract WP_Background_Process class.
*
* @abstract
* @package WP-Background-Processing
* @extends WP_Async_Request
*/
abstract class WP_Background_Process extends WP_Async_Request {
/**
* Abstract WP_Background_Process class.
* Action
*
* @abstract
* @extends WP_Async_Request
* (default value: 'background_process')
*
* @var string
* @access protected
*/
abstract class WP_Background_Process extends WP_Async_Request {
protected $action = 'background_process';
/**
* Action
*
* (default value: 'background_process')
*
* @var string
* @access protected
*/
protected $action = 'background_process';
/**
* Start time of current process.
*
* (default value: 0)
*
* @var int
* @access protected
*/
protected $start_time = 0;
/**
* Start time of current process.
*
* (default value: 0)
*
* @var int
* @access protected
*/
protected $start_time = 0;
/**
* Cron_hook_identifier
*
* @var mixed
* @access protected
*/
protected $cron_hook_identifier;
/**
* Cron_hook_identifier
*
* @var mixed
* @access protected
*/
protected $cron_hook_identifier;
/**
* Cron_interval_identifier
*
* @var mixed
* @access protected
*/
protected $cron_interval_identifier;
/**
* Cron_interval_identifier
*
* @var mixed
* @access protected
*/
protected $cron_interval_identifier;
/**
* Initiate new background process
*/
public function __construct() {
parent::__construct();
/**
* Initiate new background process
*/
public function __construct() {
parent::__construct();
$this->cron_hook_identifier = $this->identifier . '_cron';
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
$this->cron_hook_identifier = $this->identifier . '_cron';
$this->cron_interval_identifier = $this->identifier . '_cron_interval';
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
}
add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
/**
* Dispatch
*
* @access public
* @return void
*/
public function dispatch() {
// Schedule the cron healthcheck.
$this->schedule_event();
// Perform remote post.
return parent::dispatch();
}
/**
* Push to queue
*
* @param mixed $data Data.
*
* @return $this
*/
public function push_to_queue( $data ) {
$this->data[] = $data;
return $this;
}
/**
* Save queue
*
* @return $this
*/
public function save() {
$key = $this->generate_key();
if ( ! empty( $this->data ) ) {
update_site_option( $key, $this->data );
}
/**
* Dispatch
*
* @access public
* @return void
*/
public function dispatch() {
// Schedule the cron healthcheck.
$this->schedule_event();
return $this;
}
// Perform remote post.
return parent::dispatch();
/**
* Update queue
*
* @param string $key Key.
* @param array $data Data.
*
* @return $this
*/
public function update( $key, $data ) {
if ( ! empty( $data ) ) {
update_site_option( $key, $data );
}
/**
* Push to queue
*
* @param mixed $data Data.
*
* @return $this
*/
public function push_to_queue( $data ) {
$this->data[] = $data;
return $this;
}
return $this;
}
/**
* Delete queue
*
* @param string $key Key.
*
* @return $this
*/
public function delete( $key ) {
delete_site_option( $key );
/**
* Save queue
*
* @return $this
*/
public function save() {
$key = $this->generate_key();
return $this;
}
if ( ! empty( $this->data ) ) {
update_site_option( $key, $this->data );
}
/**
* Generate key
*
* Generates a unique key based on microtime. Queue items are
* given a unique key so that they can be merged upon save.
*
* @param int $length Length.
*
* @return string
*/
protected function generate_key( $length = 64 ) {
$unique = md5( microtime() . rand() );
$prepend = $this->identifier . '_batch_';
return $this;
}
return substr( $prepend . $unique, 0, $length );
}
/**
* Update queue
*
* @param string $key Key.
* @param array $data Data.
*
* @return $this
*/
public function update( $key, $data ) {
if ( ! empty( $data ) ) {
update_site_option( $key, $data );
}
return $this;
}
/**
* Delete queue
*
* @param string $key Key.
*
* @return $this
*/
public function delete( $key ) {
delete_site_option( $key );
return $this;
}
/**
* Generate key
*
* Generates a unique key based on microtime. Queue items are
* given a unique key so that they can be merged upon save.
*
* @param int $length Length.
*
* @return string
*/
protected function generate_key( $length = 64 ) {
$unique = md5( microtime() . rand() );
$prepend = $this->identifier . '_batch_';
return substr( $prepend . $unique, 0, $length );
}
/**
* Maybe process queue
*
* Checks whether data exists within the queue and that
* the process is not already running.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
if ( $this->is_process_running() ) {
// Background process already running.
wp_die();
}
if ( $this->is_queue_empty() ) {
// No data to process.
wp_die();
}
check_ajax_referer( $this->identifier, 'nonce' );
$this->handle();
/**
* Maybe process queue
*
* Checks whether data exists within the queue and that
* the process is not already running.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
if ( $this->is_process_running() ) {
// Background process already running.
wp_die();
}
/**
* Is queue empty
*
* @return bool
*/
protected function is_queue_empty() {
global $wpdb;
$table = $wpdb->options;
$column = 'option_name';
if ( is_multisite() ) {
$table = $wpdb->sitemeta;
$column = 'meta_key';
}
$key = $this->identifier . '_batch_%';
$count = $wpdb->get_var( $wpdb->prepare( "
SELECT COUNT(*)
FROM {$table}
WHERE {$column} LIKE %s
", $key ) );
return ( $count > 0 ) ? false : true;
if ( $this->is_queue_empty() ) {
// No data to process.
wp_die();
}
/**
* Is process running
*
* Check whether the current process is already running
* in a background process.
*/
protected function is_process_running() {
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
// Process already running.
return true;
}
check_ajax_referer( $this->identifier, 'nonce' );
return false;
$this->handle();
wp_die();
}
/**
* Is queue empty
*
* @return bool
*/
protected function is_queue_empty() {
global $wpdb;
$table = $wpdb->options;
$column = 'option_name';
if ( is_multisite() ) {
$table = $wpdb->sitemeta;
$column = 'meta_key';
}
/**
* Lock process
*
* Lock the process so that multiple instances can't run simultaneously.
* Override if applicable, but the duration should be greater than that
* defined in the time_exceeded() method.
*/
protected function lock_process() {
$this->start_time = time(); // Set start time of current process.
$key = $this->identifier . '_batch_%';
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
$count = $wpdb->get_var( $wpdb->prepare( "
SELECT COUNT(*)
FROM {$table}
WHERE {$column} LIKE %s
", $key ) );
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
return ( $count > 0 ) ? false : true;
}
/**
* Is process running
*
* Check whether the current process is already running
* in a background process.
*/
protected function is_process_running() {
if ( get_site_transient( $this->identifier . '_process_lock' ) ) {
// Process already running.
return true;
}
/**
* Unlock process
*
* Unlock the process so that other instances can spawn.
*
* @return $this
*/
protected function unlock_process() {
delete_site_transient( $this->identifier . '_process_lock' );
return false;
}
return $this;
/**
* Lock process
*
* Lock the process so that multiple instances can't run simultaneously.
* Override if applicable, but the duration should be greater than that
* defined in the time_exceeded() method.
*/
protected function lock_process() {
$this->start_time = time(); // Set start time of current process.
$lock_duration = ( property_exists( $this, 'queue_lock_time' ) ) ? $this->queue_lock_time : 60; // 1 minute
$lock_duration = apply_filters( $this->identifier . '_queue_lock_time', $lock_duration );
set_site_transient( $this->identifier . '_process_lock', microtime(), $lock_duration );
}
/**
* Unlock process
*
* Unlock the process so that other instances can spawn.
*
* @return $this
*/
protected function unlock_process() {
delete_site_transient( $this->identifier . '_process_lock' );
return $this;
}
/**
* Get batch
*
* @return stdClass Return the first batch from the queue
*/
protected function get_batch() {
global $wpdb;
$table = $wpdb->options;
$column = 'option_name';
$key_column = 'option_id';
$value_column = 'option_value';
if ( is_multisite() ) {
$table = $wpdb->sitemeta;
$column = 'meta_key';
$key_column = 'meta_id';
$value_column = 'meta_value';
}
/**
* Get batch
*
* @return stdClass Return the first batch from the queue
*/
protected function get_batch() {
global $wpdb;
$key = $this->identifier . '_batch_%';
$table = $wpdb->options;
$column = 'option_name';
$key_column = 'option_id';
$value_column = 'option_value';
$query = $wpdb->get_row( $wpdb->prepare( "
SELECT *
FROM {$table}
WHERE {$column} LIKE %s
ORDER BY {$key_column} ASC
LIMIT 1
", $key ) );
if ( is_multisite() ) {
$table = $wpdb->sitemeta;
$column = 'meta_key';
$key_column = 'meta_id';
$value_column = 'meta_value';
}
$batch = new stdClass();
$batch->key = $query->$column;
$batch->data = maybe_unserialize( $query->$value_column );
$key = $this->identifier . '_batch_%';
return $batch;
}
$query = $wpdb->get_row( $wpdb->prepare( "
SELECT *
FROM {$table}
WHERE {$column} LIKE %s
ORDER BY {$key_column} ASC
LIMIT 1
", $key ) );
/**
* Handle
*
* Pass each queue item to the task handler, while remaining
* within server memory and time limit constraints.
*/
protected function handle() {
$this->lock_process();
$batch = new stdClass();
$batch->key = $query->$column;
$batch->data = maybe_unserialize( $query->$value_column );
do {
$batch = $this->get_batch();
return $batch;
}
foreach ( $batch->data as $key => $value ) {
$task = $this->task( $value );
/**
* Handle
*
* Pass each queue item to the task handler, while remaining
* within server memory and time limit constraints.
*/
protected function handle() {
$this->lock_process();
do {
$batch = $this->get_batch();
foreach ( $batch->data as $key => $value ) {
$task = $this->task( $value );
if ( false !== $task ) {
$batch->data[ $key ] = $task;
} else {
unset( $batch->data[ $key ] );
}
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
// Batch limits reached.
break;
}
}
// Update or delete current batch.
if ( ! empty( $batch->data ) ) {
$this->update( $batch->key, $batch->data );
if ( false !== $task ) {
$batch->data[ $key ] = $task;
} else {
$this->delete( $batch->key );
unset( $batch->data[ $key ] );
}
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
$this->unlock_process();
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
// Batch limits reached.
break;
}
}
// Start next batch or complete process.
if ( ! $this->is_queue_empty() ) {
$this->dispatch();
// Update or delete current batch.
if ( ! empty( $batch->data ) ) {
$this->update( $batch->key, $batch->data );
} else {
$this->complete();
$this->delete( $batch->key );
}
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
$this->unlock_process();
// Start next batch or complete process.
if ( ! $this->is_queue_empty() ) {
$this->dispatch();
} else {
$this->complete();
}
}
/**
* Memory exceeded
*
* Ensures the batch process never exceeds 90%
* of the maximum WordPress memory.
*
* @return bool
*/
protected function memory_exceeded() {
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
$current_memory = memory_get_usage( true );
$return = false;
if ( $current_memory >= $memory_limit ) {
$return = true;
}
/**
* Memory exceeded
*
* Ensures the batch process never exceeds 90%
* of the maximum WordPress memory.
*
* @return bool
*/
protected function memory_exceeded() {
$memory_limit = $this->get_memory_limit() * 0.9; // 90% of max memory
$current_memory = memory_get_usage( true );
$return = false;
return apply_filters( $this->identifier . '_memory_exceeded', $return );
}
if ( $current_memory >= $memory_limit ) {
$return = true;
}
return apply_filters( $this->identifier . '_memory_exceeded', $return );
/**
* Get memory limit
*
* @return int
*/
protected function get_memory_limit() {
if ( function_exists( 'ini_get' ) ) {
$memory_limit = ini_get( 'memory_limit' );
} else {
// Sensible default.
$memory_limit = '128M';
}
/**
* Get memory limit
*
* @return int
*/
protected function get_memory_limit() {
if ( function_exists( 'ini_get' ) ) {
$memory_limit = ini_get( 'memory_limit' );
} else {
// Sensible default.
$memory_limit = '128M';
}
if ( ! $memory_limit || -1 === $memory_limit ) {
// Unlimited, set to 32GB.
$memory_limit = '32000M';
}
return intval( $memory_limit ) * 1024 * 1024;
if ( ! $memory_limit || -1 === $memory_limit ) {
// Unlimited, set to 32GB.
$memory_limit = '32000M';
}
/**
* Time exceeded.
*
* Ensures the batch never exceeds a sensible time limit.
* A timeout limit of 30s is common on shared hosting.
*
* @return bool
*/
protected function time_exceeded() {
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
$return = false;
return intval( $memory_limit ) * 1024 * 1024;
}
if ( time() >= $finish ) {
$return = true;
}
/**
* Time exceeded.
*
* Ensures the batch never exceeds a sensible time limit.
* A timeout limit of 30s is common on shared hosting.
*
* @return bool
*/
protected function time_exceeded() {
$finish = $this->start_time + apply_filters( $this->identifier . '_default_time_limit', 20 ); // 20 seconds
$return = false;
return apply_filters( $this->identifier . '_time_exceeded', $return );
if ( time() >= $finish ) {
$return = true;
}
/**
* Complete.
*
* Override if applicable, but ensure that the below actions are
* performed, or, call parent::complete().
*/
protected function complete() {
// Unschedule the cron healthcheck.
$this->clear_scheduled_event();
return apply_filters( $this->identifier . '_time_exceeded', $return );
}
/**
* Complete.
*
* Override if applicable, but ensure that the below actions are
* performed, or, call parent::complete().
*/
protected function complete() {
// Unschedule the cron healthcheck.
$this->clear_scheduled_event();
}
/**
* Schedule cron healthcheck
*
* @access public
* @param mixed $schedules Schedules.
* @return mixed
*/
public function schedule_cron_healthcheck( $schedules ) {
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
if ( property_exists( $this, 'cron_interval' ) ) {
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
}
/**
* Schedule cron healthcheck
*
* @access public
* @param mixed $schedules Schedules.
* @return mixed
*/
public function schedule_cron_healthcheck( $schedules ) {
$interval = apply_filters( $this->identifier . '_cron_interval', 5 );
// Adds every 5 minutes to the existing schedules.
$schedules[ $this->identifier . '_cron_interval' ] = array(
'interval' => MINUTE_IN_SECONDS * $interval,
'display' => sprintf( __( 'Every %d minutes', 'woocommerce' ), $interval ),
);
if ( property_exists( $this, 'cron_interval' ) ) {
$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
}
// Adds every 5 minutes to the existing schedules.
$schedules[ $this->identifier . '_cron_interval' ] = array(
'interval' => MINUTE_IN_SECONDS * $interval,
'display' => sprintf( __( 'Every %d minutes', 'woocommerce' ), $interval ),
);
return $schedules;
}
/**
* Handle cron healthcheck
*
* Restart the background process if not already running
* and data exists in the queue.
*/
public function handle_cron_healthcheck() {
if ( $this->is_process_running() ) {
// Background process already running.
exit;
}
if ( $this->is_queue_empty() ) {
// No data to process.
$this->clear_scheduled_event();
exit;
}
$this->handle();
return $schedules;
}
/**
* Handle cron healthcheck
*
* Restart the background process if not already running
* and data exists in the queue.
*/
public function handle_cron_healthcheck() {
if ( $this->is_process_running() ) {
// Background process already running.
exit;
}
/**
* Schedule event
*/
protected function schedule_event() {
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
}
if ( $this->is_queue_empty() ) {
// No data to process.
$this->clear_scheduled_event();
exit;
}
/**
* Clear scheduled event
*/
protected function clear_scheduled_event() {
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
$this->handle();
if ( $timestamp ) {
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
}
exit;
}
/**
* Schedule event
*/
protected function schedule_event() {
if ( ! wp_next_scheduled( $this->cron_hook_identifier ) ) {
wp_schedule_event( time(), $this->cron_interval_identifier, $this->cron_hook_identifier );
}
}
/**
* Cancel Process
*
* Stop processing queue items, clear cronjob and delete batch.
*
*/
public function cancel_process() {
if ( ! $this->is_queue_empty() ) {
$batch = $this->get_batch();
$this->delete( $batch->key );
wp_clear_scheduled_hook( $this->cron_hook_identifier );
}
/**
* Clear scheduled event
*/
protected function clear_scheduled_event() {
$timestamp = wp_next_scheduled( $this->cron_hook_identifier );
if ( $timestamp ) {
wp_unschedule_event( $timestamp, $this->cron_hook_identifier );
}
}
/**
* Task
*
* Override this method to perform any actions required on each
* queue item. Return the modified item for further processing
* in the next pass through. Or, return false to remove the
* item from the queue.
*
* @param mixed $item Queue item to iterate over.
*
* @return mixed
*/
abstract protected function task( $item );
/**
* Cancel Process
*
* Stop processing queue items, clear cronjob and delete batch.
*
*/
public function cancel_process() {
if ( ! $this->is_queue_empty() ) {
$batch = $this->get_batch();
$this->delete( $batch->key );
wp_clear_scheduled_hook( $this->cron_hook_identifier );
}
}
/**
* Task
*
* Override this method to perform any actions required on each
* queue item. Return the modified item for further processing
* in the next pass through. Or, return false to remove the
* item from the queue.
*
* @param mixed $item Queue item to iterate over.
*
* @return mixed
*/
abstract protected function task( $item );
}

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker' ) ) :
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) :
class WC_Product_Cat_Dropdown_Walker extends Walker {

View File

@ -13,7 +13,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
if ( ! class_exists( 'WC_Product_Cat_List_Walker' ) ) :
if ( ! class_exists( 'WC_Product_Cat_List_Walker', false ) ) :
class WC_Product_Cat_List_Walker extends Walker {

View File

@ -29,6 +29,8 @@ include( 'wc-account-functions.php' );
include( 'wc-term-functions.php' );
include( 'wc-attribute-functions.php' );
include( 'wc-rest-functions.php' );
include( 'wc-widget-functions.php' );
include( 'wc-webhook-functions.php' );
/**
* Filters on data used in admin and frontend.

View File

@ -14,16 +14,6 @@ if ( ! defined( 'ABSPATH' ) ) {
exit;
}
include_once( 'abstracts/abstract-wc-deprecated-hooks.php' );
include_once( 'class-wc-deprecated-action-hooks.php' );
include_once( 'class-wc-deprecated-filter-hooks.php' );
function wc_initialize_deprecated_hook_handlers() {
WC()->deprecated_hook_handlers['actions'] = new WC_Deprecated_Action_Hooks();
WC()->deprecated_hook_handlers['filters'] = new WC_Deprecated_Filter_Hooks();
}
add_action( 'woocommerce_init', 'wc_initialize_deprecated_hook_handlers' );
/**
* Runs a deprecated action with notice only if used.
*

View File

@ -234,7 +234,7 @@ function wc_product_dropdown_categories( $args = array(), $deprecated_hierarchic
function wc_walk_category_dropdown_tree() {
$args = func_get_args();
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker' ) ) {
if ( ! class_exists( 'WC_Product_Cat_Dropdown_Walker', false ) ) {
include_once( WC()->plugin_path() . '/includes/walkers/class-product-cat-dropdown-walker.php' );
}

View File

@ -252,41 +252,14 @@ final class WooCommerce {
* Include required core files used in admin and on the frontend.
*/
public function includes() {
/**
* Class autoloader.
*/
include_once( WC_ABSPATH . 'includes/class-wc-autoloader.php' );
include_once( WC_ABSPATH . 'includes/wc-core-functions.php' );
include_once( WC_ABSPATH . 'includes/class-wc-register-wp-admin-settings.php' );
include_once( WC_ABSPATH . 'includes/wc-widget-functions.php' );
include_once( WC_ABSPATH . 'includes/wc-webhook-functions.php' );
include_once( WC_ABSPATH . 'includes/class-wc-install.php' );
include_once( WC_ABSPATH . 'includes/class-wc-geolocation.php' );
include_once( WC_ABSPATH . 'includes/class-wc-download-handler.php' );
include_once( WC_ABSPATH . 'includes/class-wc-comments.php' );
include_once( WC_ABSPATH . 'includes/class-wc-post-data.php' );
include_once( WC_ABSPATH . 'includes/class-wc-ajax.php' );
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-data.php' ); // WC_Data for CRUD
include_once( WC_ABSPATH . 'includes/class-wc-data-exception.php' );
if ( $this->is_request( 'admin' ) ) {
include_once( WC_ABSPATH . 'includes/admin/class-wc-admin.php' );
}
if ( $this->is_request( 'frontend' ) ) {
$this->frontend_includes();
}
if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) {
include_once( WC_ABSPATH . 'includes/class-wc-session-handler.php' );
}
if ( $this->is_request( 'cron' ) && 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) {
include_once( WC_ABSPATH . 'includes/class-wc-tracker.php' );
}
include_once( WC_ABSPATH . 'includes/class-wc-query.php' ); // The main query class
include_once( WC_ABSPATH . 'includes/class-wc-api.php' ); // API Class
include_once( WC_ABSPATH . 'includes/class-wc-auth.php' ); // Auth Class
include_once( WC_ABSPATH . 'includes/class-wc-post-types.php' ); // Registers post types
/**
* Interfaces.
*/
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-abstract-order-data-store-interface.php' );
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-coupon-data-store-interface.php' );
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-customer-data-store-interface.php' );
@ -303,6 +276,11 @@ final class WooCommerce {
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-shipping-zone-data-store-interface.php' );
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-logger-interface.php' );
include_once( WC_ABSPATH . 'includes/interfaces/class-wc-log-handler-interface.php' );
/**
* Abstract classes.
*/
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-data.php' ); // WC_Data for CRUD
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-payment-token.php' ); // Payment Tokens
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-product.php' ); // Products
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-order.php' ); // Orders
@ -311,6 +289,24 @@ final class WooCommerce {
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-payment-gateway.php' ); // A Payment gateway
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-integration.php' ); // An integration with a service
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-log-handler.php' );
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-deprecated-hooks.php' );
include_once( WC_ABSPATH . 'includes/abstracts/abstract-wc-session.php' );
/**
* Core classes.
*/
include_once( WC_ABSPATH . 'includes/wc-core-functions.php' );
include_once( WC_ABSPATH . 'includes/class-wc-post-types.php' ); // Registers post types
include_once( WC_ABSPATH . 'includes/class-wc-install.php' );
include_once( WC_ABSPATH . 'includes/class-wc-geolocation.php' );
include_once( WC_ABSPATH . 'includes/class-wc-download-handler.php' );
include_once( WC_ABSPATH . 'includes/class-wc-comments.php' );
include_once( WC_ABSPATH . 'includes/class-wc-post-data.php' );
include_once( WC_ABSPATH . 'includes/class-wc-ajax.php' );
include_once( WC_ABSPATH . 'includes/class-wc-emails.php' );
include_once( WC_ABSPATH . 'includes/class-wc-data-exception.php' );
include_once( WC_ABSPATH . 'includes/class-wc-query.php' );
include_once( WC_ABSPATH . 'includes/class-wc-order-factory.php' ); // Order factory
include_once( WC_ABSPATH . 'includes/class-wc-product-factory.php' ); // Product factory
include_once( WC_ABSPATH . 'includes/class-wc-payment-tokens.php' ); // Payment tokens controller
include_once( WC_ABSPATH . 'includes/class-wc-shipping-zone.php' );
@ -320,7 +316,13 @@ final class WooCommerce {
include_once( WC_ABSPATH . 'includes/class-wc-integrations.php' ); // Loads integrations
include_once( WC_ABSPATH . 'includes/class-wc-cache-helper.php' ); // Cache Helper
include_once( WC_ABSPATH . 'includes/class-wc-https.php' ); // https Helper
include_once( WC_ABSPATH . 'includes/class-wc-data-store.php' ); // WC_Data_Store for CRUD
include_once( WC_ABSPATH . 'includes/class-wc-deprecated-action-hooks.php' );
include_once( WC_ABSPATH . 'includes/class-wc-deprecated-filter-hooks.php' );
/**
* Data stores - used to store and retrieve CRUD object data from the database.
*/
include_once( WC_ABSPATH . 'includes/class-wc-data-store.php' );
include_once( WC_ABSPATH . 'includes/data-stores/class-wc-data-store-wp.php' );
include_once( WC_ABSPATH . 'includes/data-stores/class-wc-coupon-data-store-cpt.php' );
include_once( WC_ABSPATH . 'includes/data-stores/class-wc-product-data-store-cpt.php' );
@ -343,9 +345,32 @@ final class WooCommerce {
include_once( WC_ABSPATH . 'includes/data-stores/class-wc-order-data-store-cpt.php' );
include_once( WC_ABSPATH . 'includes/data-stores/class-wc-order-refund-data-store-cpt.php' );
/**
* REST API.
*/
include_once( WC_ABSPATH . 'includes/class-wc-legacy-api.php' );
include_once( WC_ABSPATH . 'includes/class-wc-api.php' ); // API Class
include_once( WC_ABSPATH . 'includes/class-wc-auth.php' ); // Auth Class
include_once( WC_ABSPATH . 'includes/class-wc-register-wp-admin-settings.php' );
if ( defined( 'WP_CLI' ) && WP_CLI ) {
include_once( WC_ABSPATH . 'includes/class-wc-cli.php' );
new WC_CLI;
include_once( WC_ABSPATH . 'includes/class-wc-cli.php' );
}
if ( $this->is_request( 'admin' ) ) {
include_once( WC_ABSPATH . 'includes/admin/class-wc-admin.php' );
}
if ( $this->is_request( 'frontend' ) ) {
$this->frontend_includes();
}
if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) {
include_once( WC_ABSPATH . 'includes/class-wc-session-handler.php' );
}
if ( $this->is_request( 'cron' ) && 'yes' === get_option( 'woocommerce_allow_tracking', 'no' ) ) {
include_once( WC_ABSPATH . 'includes/class-wc-tracker.php' );
}
$this->query = new WC_Query();
@ -393,11 +418,13 @@ final class WooCommerce {
$this->load_plugin_textdomain();
// Load class instances.
$this->product_factory = new WC_Product_Factory(); // Product Factory to create new product instances
$this->order_factory = new WC_Order_Factory(); // Order Factory to create new order instances
$this->countries = new WC_Countries(); // Countries class
$this->integrations = new WC_Integrations(); // Integrations class
$this->structured_data = new WC_Structured_Data(); // Structured Data class, generates and handles structured data
$this->product_factory = new WC_Product_Factory(); // Product Factory to create new product instances
$this->order_factory = new WC_Order_Factory(); // Order Factory to create new order instances
$this->countries = new WC_Countries(); // Countries class
$this->integrations = new WC_Integrations(); // Integrations class
$this->structured_data = new WC_Structured_Data(); // Structured Data class, generates and handles structured data
$this->deprecated_hook_handlers['actions'] = new WC_Deprecated_Action_Hooks();
$this->deprecated_hook_handlers['filters'] = new WC_Deprecated_Filter_Hooks();
// Session class, handles session data for users - can be overwritten if custom handler is needed.
if ( $this->is_request( 'frontend' ) || $this->is_request( 'cron' ) ) {