2011-08-10 17:11:11 +00:00
|
|
|
<?php
|
2012-03-20 13:22:35 +00:00
|
|
|
/**
|
|
|
|
* Plugin Name: WooCommerce
|
|
|
|
* Plugin URI: http://www.woothemes.com/woocommerce/
|
|
|
|
* Description: An e-commerce toolkit that helps you sell anything. Beautifully.
|
2014-10-08 14:07:12 +00:00
|
|
|
* Version: 2.3-bleeding
|
2012-03-20 13:22:35 +00:00
|
|
|
* Author: WooThemes
|
|
|
|
* Author URI: http://woothemes.com
|
2014-09-24 09:57:39 +00:00
|
|
|
* Requires at least: 4.0
|
2014-09-08 11:18:11 +00:00
|
|
|
* Tested up to: 4.0
|
2012-08-07 08:38:08 +00:00
|
|
|
*
|
2012-03-20 13:22:35 +00:00
|
|
|
* Text Domain: woocommerce
|
2012-12-28 10:54:02 +00:00
|
|
|
* Domain Path: /i18n/languages/
|
2012-08-07 08:38:08 +00:00
|
|
|
*
|
2012-03-20 13:22:35 +00:00
|
|
|
* @package WooCommerce
|
|
|
|
* @category Core
|
|
|
|
* @author WooThemes
|
|
|
|
*/
|
2014-01-08 15:30:06 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
exit; // Exit if accessed directly
|
2014-01-08 15:30:06 +00:00
|
|
|
}
|
2011-08-10 17:11:11 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
if ( ! class_exists( 'WooCommerce' ) ) :
|
2013-08-09 16:11:15 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
/**
|
|
|
|
* Main WooCommerce Class
|
|
|
|
*
|
|
|
|
* @class WooCommerce
|
2013-08-09 16:11:15 +00:00
|
|
|
* @version 2.1.0
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
|
|
|
final class WooCommerce {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2014-10-08 14:07:12 +00:00
|
|
|
public $version = '2.3.0';
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
/**
|
2013-09-12 13:41:02 +00:00
|
|
|
* @var WooCommerce The single instance of the class
|
|
|
|
* @since 2.1
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
protected static $_instance = null;
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-09-26 12:11:33 +00:00
|
|
|
/**
|
|
|
|
* @var WC_Session session
|
|
|
|
*/
|
|
|
|
public $session = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Query $query
|
|
|
|
*/
|
|
|
|
public $query = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Product_Factory $product_factory
|
|
|
|
*/
|
|
|
|
public $product_factory = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Countries $countries
|
|
|
|
*/
|
|
|
|
public $countries = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Integrations $integrations
|
|
|
|
*/
|
|
|
|
public $integrations = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Cart $cart
|
|
|
|
*/
|
|
|
|
public $cart = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var WC_Customer $customer
|
|
|
|
*/
|
|
|
|
public $customer = null;
|
|
|
|
|
2014-07-03 11:38:55 +00:00
|
|
|
/**
|
2014-08-31 05:41:40 +00:00
|
|
|
* @var WC_Order_Factory $order_factory
|
|
|
|
*/
|
|
|
|
public $order_factory = null;
|
2014-07-03 11:38:55 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
/**
|
|
|
|
* Main WooCommerce Instance
|
|
|
|
*
|
|
|
|
* Ensures only one instance of WooCommerce is loaded or can be loaded.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
|
|
|
* @static
|
|
|
|
* @see WC()
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return WooCommerce - Main instance
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
|
|
|
public static function instance() {
|
2013-12-08 21:25:57 +00:00
|
|
|
if ( is_null( self::$_instance ) ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
self::$_instance = new self();
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
return self::$_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cloning is forbidden.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
|
|
|
*/
|
|
|
|
public function __clone() {
|
2014-02-17 13:14:41 +00:00
|
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woocommerce' ), '2.1' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unserializing instances of this class is forbidden.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
|
|
|
*/
|
|
|
|
public function __wakeup() {
|
2014-02-17 13:14:41 +00:00
|
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woocommerce' ), '2.1' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WooCommerce Constructor.
|
|
|
|
* @access public
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return WooCommerce
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
|
|
|
public function __construct() {
|
2013-10-24 18:36:22 +00:00
|
|
|
$this->define_constants();
|
2013-06-11 14:21:14 +00:00
|
|
|
$this->includes();
|
|
|
|
|
2014-11-19 17:12:56 +00:00
|
|
|
// Init WC API
|
2013-06-11 14:21:14 +00:00
|
|
|
$this->api = new WC_API();
|
|
|
|
|
|
|
|
// Hooks
|
2014-07-31 06:47:55 +00:00
|
|
|
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
|
|
|
|
add_action( 'after_setup_theme', array( $this, 'include_template_functions' ), 11 );
|
2013-06-11 14:21:14 +00:00
|
|
|
add_action( 'init', array( $this, 'init' ), 0 );
|
2013-10-23 11:55:40 +00:00
|
|
|
add_action( 'init', array( 'WC_Shortcodes', 'init' ) );
|
2014-11-19 22:53:05 +00:00
|
|
|
add_action( 'widgets_init', array( $this, 'widget_includes' ) );
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// Loaded action
|
|
|
|
do_action( 'woocommerce_loaded' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Auto-load in-accessible properties on demand.
|
|
|
|
*
|
|
|
|
* @param mixed $key
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function __get( $key ) {
|
2013-12-08 21:25:57 +00:00
|
|
|
if ( method_exists( $this, $key ) ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
return $this->$key();
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2014-11-19 22:42:03 +00:00
|
|
|
|
|
|
|
switch( $key ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'template_url':
|
2014-06-19 12:43:10 +00:00
|
|
|
_deprecated_argument( 'Woocommerce->template_url', '2.1', 'Use WC()->template_path()' );
|
|
|
|
return $this->template_path();
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'messages':
|
2014-01-20 15:21:50 +00:00
|
|
|
_deprecated_argument( 'Woocommerce->messages', '2.1', 'Use wc_get_notices' );
|
|
|
|
return wc_get_notices( 'success' );
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'errors':
|
2014-01-20 15:21:50 +00:00
|
|
|
_deprecated_argument( 'Woocommerce->errors', '2.1', 'Use wc_get_notices' );
|
|
|
|
return wc_get_notices( 'error' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-19 22:50:13 +00:00
|
|
|
/**
|
|
|
|
* Define constant if not already set
|
|
|
|
* @param string $name
|
|
|
|
* @param string $value
|
|
|
|
*/
|
|
|
|
private function define( $name, $value ) {
|
|
|
|
if ( ! defined( $name ) ) {
|
|
|
|
define( $name, $value );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-24 18:36:22 +00:00
|
|
|
/**
|
|
|
|
* Define WC Constants
|
|
|
|
*/
|
|
|
|
private function define_constants() {
|
2014-11-19 22:50:13 +00:00
|
|
|
$upload_dir = wp_upload_dir();
|
|
|
|
|
|
|
|
$this->define( 'WC_PLUGIN_FILE', __FILE__ );
|
|
|
|
$this->define( 'WC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
|
|
|
|
$this->define( 'WC_VERSION', $this->version );
|
|
|
|
$this->define( 'WOOCOMMERCE_VERSION', $this->version );
|
|
|
|
$this->define( 'WC_ROUNDING_PRECISION', 4 );
|
|
|
|
$this->define( 'WC_TAX_ROUNDING_MODE', 'yes' === get_option( 'woocommerce_prices_include_tax', 'no' ) ? 2 : 1 );
|
|
|
|
$this->define( 'WC_DELIMITER', '|' );
|
|
|
|
$this->define( 'WC_LOG_DIR', $upload_dir['basedir'] . '/wc-logs/' );
|
2013-10-24 18:36:22 +00:00
|
|
|
}
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
/**
|
|
|
|
* Include required core files used in admin and on the frontend.
|
|
|
|
*/
|
2013-10-24 18:36:22 +00:00
|
|
|
private function includes() {
|
2014-11-19 17:12:56 +00:00
|
|
|
include_once( 'includes/class-wc-autoloader.php' );
|
2014-02-28 13:55:40 +00:00
|
|
|
include_once( 'includes/wc-core-functions.php' );
|
|
|
|
include_once( 'includes/class-wc-install.php' );
|
|
|
|
include_once( 'includes/class-wc-download-handler.php' );
|
|
|
|
include_once( 'includes/class-wc-comments.php' );
|
|
|
|
include_once( 'includes/class-wc-post-data.php' );
|
2013-06-11 14:59:54 +00:00
|
|
|
|
2013-12-08 21:25:57 +00:00
|
|
|
if ( is_admin() ) {
|
2013-07-24 16:01:36 +00:00
|
|
|
include_once( 'includes/admin/class-wc-admin.php' );
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-07-24 16:01:36 +00:00
|
|
|
|
2014-01-23 04:36:24 +00:00
|
|
|
if ( defined( 'DOING_AJAX' ) ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
$this->ajax_includes();
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-07-24 16:01:36 +00:00
|
|
|
|
2014-01-23 04:36:24 +00:00
|
|
|
if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
$this->frontend_includes();
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-07-23 16:05:01 +00:00
|
|
|
// Query class
|
2014-08-31 05:41:40 +00:00
|
|
|
$this->query = include( 'includes/class-wc-query.php' ); // The main query class
|
2013-07-23 16:05:01 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// Post types
|
2014-08-31 05:41:40 +00:00
|
|
|
include_once( 'includes/class-wc-post-types.php' ); // Registers post types
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// API Class
|
|
|
|
include_once( 'includes/class-wc-api.php' );
|
|
|
|
|
|
|
|
// Include abstract classes
|
2014-08-31 05:41:40 +00:00
|
|
|
include_once( 'includes/abstracts/abstract-wc-product.php' ); // Products
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-order.php' ); // Orders
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-settings-api.php' ); // Settings API (for gateways, shipping, and integrations)
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-shipping-method.php' ); // A Shipping method
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-payment-gateway.php' ); // A Payment gateway
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-integration.php' ); // An integration with a service
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// Classes (used on all pages)
|
2014-08-31 05:41:40 +00:00
|
|
|
include_once( 'includes/class-wc-product-factory.php' ); // Product factory
|
|
|
|
include_once( 'includes/class-wc-countries.php' ); // Defines countries and states
|
|
|
|
include_once( 'includes/class-wc-integrations.php' ); // Loads integrations
|
|
|
|
include_once( 'includes/class-wc-cache-helper.php' ); // Cache Helper
|
2014-05-28 16:06:00 +00:00
|
|
|
|
|
|
|
// Download/update languages
|
|
|
|
include_once( 'includes/class-wc-language-pack-upgrader.php' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include required ajax files.
|
|
|
|
*/
|
|
|
|
public function ajax_includes() {
|
2014-08-31 05:41:40 +00:00
|
|
|
include_once( 'includes/class-wc-ajax.php' ); // Ajax functions for admin and the front-end
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include required frontend files.
|
|
|
|
*/
|
|
|
|
public function frontend_includes() {
|
2014-06-04 10:16:19 +00:00
|
|
|
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' );
|
2014-08-31 05:41:40 +00:00
|
|
|
include_once( 'includes/class-wc-template-loader.php' ); // Template Loader
|
|
|
|
include_once( 'includes/class-wc-frontend-scripts.php' ); // Frontend Scripts
|
|
|
|
include_once( 'includes/class-wc-form-handler.php' ); // Form Handlers
|
|
|
|
include_once( 'includes/class-wc-cart.php' ); // The main cart class
|
|
|
|
include_once( 'includes/class-wc-tax.php' ); // Tax class
|
|
|
|
include_once( 'includes/class-wc-customer.php' ); // Customer class
|
|
|
|
include_once( 'includes/class-wc-shortcodes.php' ); // Shortcodes class
|
|
|
|
include_once( 'includes/class-wc-https.php' ); // https Helper
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function used to Init WooCommerce Template Functions - This makes them pluggable by plugins and themes.
|
|
|
|
*/
|
|
|
|
public function include_template_functions() {
|
2014-06-04 10:16:19 +00:00
|
|
|
if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
|
|
|
|
include_once( 'includes/wc-template-functions.php' );
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-12 13:41:02 +00:00
|
|
|
* Include core widgets
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
2014-11-19 22:53:05 +00:00
|
|
|
public function widget_includes() {
|
2013-06-11 14:59:54 +00:00
|
|
|
include_once( 'includes/abstracts/abstract-wc-widget.php' );
|
2014-11-19 17:12:56 +00:00
|
|
|
include_once( 'includes/widgets/class-wc-widget-cart.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-layered-nav-filters.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-layered-nav.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-price-filter.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-product-categories.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-product-search.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-product-tag-cloud.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-products.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-recent-reviews.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-recently-viewed.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-top-rated-products.php' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Init WooCommerce when WordPress Initialises.
|
|
|
|
*/
|
|
|
|
public function init() {
|
2013-09-12 13:41:02 +00:00
|
|
|
// Before init action
|
2013-06-11 14:21:14 +00:00
|
|
|
do_action( 'before_woocommerce_init' );
|
|
|
|
|
|
|
|
// Set up localisation
|
|
|
|
$this->load_plugin_textdomain();
|
|
|
|
|
2014-10-03 09:52:11 +00:00
|
|
|
// Template debug mode
|
2014-11-19 22:50:13 +00:00
|
|
|
$status_options = get_option( 'woocommerce_status_options', array() );
|
|
|
|
if ( ! empty( $status_options['template_debug_mode'] ) && current_user_can( 'manage_options' ) ) {
|
|
|
|
$this->define( 'WC_TEMPLATE_DEBUG_MODE', true );
|
|
|
|
} else {
|
|
|
|
$this->define( 'WC_TEMPLATE_DEBUG_MODE', false );
|
2014-10-03 09:52:11 +00:00
|
|
|
}
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// Load class instances
|
2014-08-31 05:41:40 +00:00
|
|
|
$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
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// Classes/actions loaded for the frontend and for ajax requests
|
2014-01-23 04:36:24 +00:00
|
|
|
if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
|
2014-06-04 10:16:19 +00:00
|
|
|
// 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' );
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// Class instances
|
2014-06-04 10:16:19 +00:00
|
|
|
$this->session = new $session_class();
|
2014-08-31 05:41:40 +00:00
|
|
|
$this->cart = new WC_Cart(); // Cart class, stores the cart contents
|
|
|
|
$this->customer = new WC_Customer(); // Customer class, handles data such as customer location
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Email Actions
|
2014-10-21 09:52:07 +00:00
|
|
|
$email_actions = apply_filters( 'woocommerce_email_actions', array(
|
2013-09-23 15:51:43 +00:00
|
|
|
'woocommerce_low_stock',
|
|
|
|
'woocommerce_no_stock',
|
|
|
|
'woocommerce_product_on_backorder',
|
|
|
|
'woocommerce_order_status_pending_to_processing',
|
|
|
|
'woocommerce_order_status_pending_to_completed',
|
2014-10-29 14:05:43 +00:00
|
|
|
'woocommerce_order_status_pending_to_cancelled',
|
2013-09-23 15:51:43 +00:00
|
|
|
'woocommerce_order_status_pending_to_on-hold',
|
|
|
|
'woocommerce_order_status_failed_to_processing',
|
|
|
|
'woocommerce_order_status_failed_to_completed',
|
2014-10-15 14:21:46 +00:00
|
|
|
'woocommerce_order_status_on-hold_to_processing',
|
2014-10-29 14:05:43 +00:00
|
|
|
'woocommerce_order_status_on-hold_to_cancelled',
|
2013-09-23 15:51:43 +00:00
|
|
|
'woocommerce_order_status_completed',
|
|
|
|
'woocommerce_new_customer_note',
|
|
|
|
'woocommerce_created_customer'
|
2014-10-21 09:52:07 +00:00
|
|
|
) );
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2014-06-04 10:16:19 +00:00
|
|
|
foreach ( $email_actions as $action ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
add_action( $action, array( $this, 'send_transactional_email' ), 10, 10 );
|
2014-06-04 10:16:19 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2014-07-30 20:27:50 +00:00
|
|
|
// webhooks
|
|
|
|
$this->load_webhooks();
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// Init action
|
|
|
|
do_action( 'woocommerce_init' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load Localisation files.
|
|
|
|
*
|
2014-11-19 16:39:26 +00:00
|
|
|
* Note: the first-loaded translation file overrides any following ones if the same translation is present.
|
|
|
|
*
|
|
|
|
* Admin Locales are found in:
|
|
|
|
* - WP_LANG_DIR/woocommerce/woocommerce-admin-LOCALE.mo
|
|
|
|
* - WP_LANG_DIR/plugins/woocommerce-admin-LOCALE.mo
|
|
|
|
*
|
|
|
|
* Frontend/global Locales found in:
|
|
|
|
* - WP_LANG_DIR/woocommerce/woocommerce-LOCALE.mo
|
|
|
|
* - woocommerce/i18n/languages/woocommerce-LOCALE.mo (which if not found falls back to:)
|
|
|
|
* - WP_LANG_DIR/plugins/woocommerce-LOCALE.mo
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
|
|
|
public function load_plugin_textdomain() {
|
|
|
|
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce' );
|
|
|
|
|
|
|
|
if ( is_admin() ) {
|
2014-11-19 16:39:26 +00:00
|
|
|
load_textdomain( 'woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-admin-' . $locale . '.mo' );
|
|
|
|
load_textdomain( 'woocommerce', WP_LANG_DIR . '/plugins/woocommerce-admin-' . $locale . '.mo' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
2014-05-28 16:06:00 +00:00
|
|
|
|
2014-11-19 16:39:26 +00:00
|
|
|
load_textdomain( 'woocommerce', WP_LANG_DIR . '/woocommerce/woocommerce-' . $locale . '.mo' );
|
2014-09-19 09:29:19 +00:00
|
|
|
load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages" );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-08-31 05:41:40 +00:00
|
|
|
* Ensure theme and server variable compatibility and setup image sizes.
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function setup_environment() {
|
2014-06-23 15:29:15 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.2 Use WC()->template_path()
|
|
|
|
*/
|
2014-11-19 22:50:13 +00:00
|
|
|
$this->define( 'WC_TEMPLATE_PATH', $this->template_path() );
|
2014-06-23 15:29:15 +00:00
|
|
|
|
2014-10-27 14:59:22 +00:00
|
|
|
$this->add_thumbnail_support();
|
|
|
|
$this->add_image_sizes();
|
|
|
|
$this->fix_server_vars();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ensure post thumbnail support is turned on
|
|
|
|
*/
|
|
|
|
private function add_thumbnail_support() {
|
2014-06-23 15:29:15 +00:00
|
|
|
if ( ! current_theme_supports( 'post-thumbnails' ) ) {
|
2014-07-30 20:27:50 +00:00
|
|
|
add_theme_support( 'post-thumbnails' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
2014-06-23 15:29:15 +00:00
|
|
|
add_post_type_support( 'product', 'thumbnail' );
|
2014-10-27 14:59:22 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2014-10-27 14:59:22 +00:00
|
|
|
/**
|
|
|
|
* Add WC Image sizes to WP
|
|
|
|
*
|
|
|
|
* @since 2.3
|
|
|
|
*/
|
|
|
|
private function add_image_sizes() {
|
2013-09-12 13:41:02 +00:00
|
|
|
$shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
|
|
|
|
$shop_catalog = wc_get_image_size( 'shop_catalog' );
|
|
|
|
$shop_single = wc_get_image_size( 'shop_single' );
|
|
|
|
|
|
|
|
add_image_size( 'shop_thumbnail', $shop_thumbnail['width'], $shop_thumbnail['height'], $shop_thumbnail['crop'] );
|
|
|
|
add_image_size( 'shop_catalog', $shop_catalog['width'], $shop_catalog['height'], $shop_catalog['crop'] );
|
|
|
|
add_image_size( 'shop_single', $shop_single['width'], $shop_single['height'], $shop_single['crop'] );
|
2014-10-27 14:59:22 +00:00
|
|
|
}
|
2013-09-12 13:41:02 +00:00
|
|
|
|
2014-10-27 14:59:22 +00:00
|
|
|
/**
|
|
|
|
* Fix `$_SERVER` variables for various setups.
|
|
|
|
*
|
|
|
|
* Note: Removed IIS handling due to wp_fix_server_vars()
|
|
|
|
*
|
|
|
|
* @since 2.3
|
|
|
|
*/
|
|
|
|
private function fix_server_vars() {
|
2013-06-11 14:21:14 +00:00
|
|
|
// NGINX Proxy
|
2013-12-08 21:25:57 +00:00
|
|
|
if ( ! isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_SERVER['HTTP_REMOTE_ADDR'] ) ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_REMOTE_ADDR'];
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2014-11-19 16:39:26 +00:00
|
|
|
if ( ! isset( $_SERVER['HTTPS'] ) ) {
|
|
|
|
if ( ! empty( $_SERVER['HTTP_HTTPS'] ) ) {
|
|
|
|
$_SERVER['HTTPS'] = $_SERVER['HTTP_HTTPS'];
|
|
|
|
} elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
|
|
|
|
$_SERVER['HTTPS'] = '1';
|
|
|
|
}
|
2013-12-08 21:25:57 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Helper functions ******************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the plugin url.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function plugin_url() {
|
2013-06-11 14:59:54 +00:00
|
|
|
return untrailingslashit( plugins_url( '/', __FILE__ ) );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the plugin path.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function plugin_path() {
|
2013-06-11 14:59:54 +00:00
|
|
|
return untrailingslashit( plugin_dir_path( __FILE__ ) );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/**
|
|
|
|
* Get the template path.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function template_path() {
|
2014-06-23 15:31:49 +00:00
|
|
|
return apply_filters( 'woocommerce_template_path', 'woocommerce/' );
|
2013-09-12 13:41:02 +00:00
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get Ajax URL.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function ajax_url() {
|
|
|
|
return admin_url( 'admin-ajax.php', 'relative' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the WC API URL for a given request
|
|
|
|
*
|
2014-09-07 23:37:55 +00:00
|
|
|
* @param string $request
|
2013-06-11 14:21:14 +00:00
|
|
|
* @param mixed $ssl (default: null)
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function api_request_url( $request, $ssl = null ) {
|
|
|
|
if ( is_null( $ssl ) ) {
|
2014-08-27 20:24:45 +00:00
|
|
|
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
|
2013-06-11 14:21:14 +00:00
|
|
|
} elseif ( $ssl ) {
|
|
|
|
$scheme = 'https';
|
|
|
|
} else {
|
|
|
|
$scheme = 'http';
|
|
|
|
}
|
|
|
|
|
2014-08-31 05:41:40 +00:00
|
|
|
if ( get_option( 'permalink_structure' ) ) {
|
2013-08-23 19:29:24 +00:00
|
|
|
return esc_url_raw( trailingslashit( home_url( '/wc-api/' . $request, $scheme ) ) );
|
|
|
|
} else {
|
|
|
|
return esc_url_raw( add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) ) );
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-12 13:41:02 +00:00
|
|
|
* Init the mailer and call the notifications for the current filter.
|
2014-08-31 05:41:40 +00:00
|
|
|
*
|
2013-09-25 03:11:42 +00:00
|
|
|
* @internal param array $args (default: array())
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function send_transactional_email() {
|
|
|
|
$this->mailer();
|
|
|
|
$args = func_get_args();
|
|
|
|
do_action_ref_array( current_filter() . '_notification', $args );
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2014-07-30 20:27:50 +00:00
|
|
|
/**
|
|
|
|
* Load & enqueue active webhooks
|
|
|
|
*
|
|
|
|
* @since 2.2
|
|
|
|
*/
|
|
|
|
public function load_webhooks() {
|
|
|
|
|
|
|
|
$args = array(
|
|
|
|
'fields' => 'ids',
|
|
|
|
'post_type' => 'shop_webhook',
|
|
|
|
'post_status' => 'publish',
|
|
|
|
);
|
|
|
|
|
|
|
|
$query = new WP_Query( $args );
|
|
|
|
|
|
|
|
if ( ! empty( $query->posts ) ) {
|
|
|
|
|
|
|
|
foreach ( $query->posts as $id ) {
|
|
|
|
$webhook = new WC_Webhook( $id );
|
|
|
|
$webhook->enqueue();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/** Load Instances on demand **********************************************/
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/**
|
|
|
|
* Get Checkout Class.
|
|
|
|
*
|
|
|
|
* @return WC_Checkout
|
|
|
|
*/
|
|
|
|
public function checkout() {
|
|
|
|
return WC_Checkout::instance();
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/**
|
|
|
|
* Get gateways class
|
|
|
|
*
|
|
|
|
* @return WC_Payment_Gateways
|
|
|
|
*/
|
|
|
|
public function payment_gateways() {
|
|
|
|
return WC_Payment_Gateways::instance();
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/**
|
|
|
|
* Get shipping class
|
|
|
|
*
|
|
|
|
* @return WC_Shipping
|
|
|
|
*/
|
|
|
|
public function shipping() {
|
|
|
|
return WC_Shipping::instance();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-12 13:41:02 +00:00
|
|
|
* Email Class.
|
2013-06-11 14:21:14 +00:00
|
|
|
*
|
2014-09-07 23:37:55 +00:00
|
|
|
* @return WC_Emails
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function mailer() {
|
|
|
|
return WC_Emails::instance();
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Deprecated methods *********************************************************/
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $image_size
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function get_image_size( $image_size ) {
|
|
|
|
_deprecated_function( 'Woocommerce->get_image_size', '2.1', 'wc_get_image_size()' );
|
|
|
|
return wc_get_image_size( $image_size );
|
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @return WC_Logger
|
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function logger() {
|
|
|
|
_deprecated_function( 'Woocommerce->logger', '2.1', 'new WC_Logger()' );
|
|
|
|
return new WC_Logger();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @return WC_Validation
|
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function validation() {
|
|
|
|
_deprecated_function( 'Woocommerce->validation', '2.1', 'new WC_Validation()' );
|
|
|
|
return new WC_Validation();
|
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $post
|
|
|
|
* @return WC_Product
|
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
public function setup_product_data( $post ) {
|
|
|
|
_deprecated_function( 'Woocommerce->setup_product_data', '2.1', 'wc_setup_product_data' );
|
|
|
|
return wc_setup_product_data( $post );
|
|
|
|
}
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $content
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-09-03 12:03:05 +00:00
|
|
|
public function force_ssl( $content ) {
|
|
|
|
_deprecated_function( 'Woocommerce->force_ssl', '2.1', 'WC_HTTPS::force_https_url' );
|
|
|
|
return WC_HTTPS::force_https_url( $content );
|
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param int $post_id
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function clear_product_transients( $post_id = 0 ) {
|
2013-08-09 16:11:15 +00:00
|
|
|
_deprecated_function( 'Woocommerce->clear_product_transients', '2.1', 'wc_delete_product_transients' );
|
|
|
|
wc_delete_product_transients( $post_id );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Inline_Javascript_Helper helper
|
|
|
|
* @param $code
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function add_inline_js( $code ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_inline_js', '2.1', 'wc_enqueue_js' );
|
|
|
|
wc_enqueue_js( $code );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $action
|
|
|
|
* @param bool $referer
|
|
|
|
* @param bool $echo
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function nonce_field( $action, $referer = true , $echo = true ) {
|
2013-06-11 16:55:55 +00:00
|
|
|
_deprecated_function( 'Woocommerce->nonce_field', '2.1', 'wp_nonce_field' );
|
|
|
|
return wp_nonce_field('woocommerce-' . $action, '_wpnonce', $referer, $echo );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $action
|
|
|
|
* @param string $url
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function nonce_url( $action, $url = '' ) {
|
2013-06-11 16:55:55 +00:00
|
|
|
_deprecated_function( 'Woocommerce->nonce_url', '2.1', 'wp_nonce_url' );
|
|
|
|
return wp_nonce_url( $url , 'woocommerce-' . $action );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $action
|
|
|
|
* @param string $method
|
|
|
|
* @param bool $error_message
|
|
|
|
* @return bool
|
|
|
|
*/
|
2013-06-11 16:55:55 +00:00
|
|
|
public function verify_nonce( $action, $method = '_POST', $error_message = false ) {
|
2013-11-26 16:52:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->verify_nonce', '2.1', 'wp_verify_nonce' );
|
2014-02-11 13:38:53 +00:00
|
|
|
if ( ! isset( $method[ '_wpnonce' ] ) ) {
|
|
|
|
return false;
|
|
|
|
}
|
2013-12-16 02:14:16 +00:00
|
|
|
return wp_verify_nonce( $method[ '_wpnonce' ], 'woocommerce-' . $action );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $function
|
|
|
|
* @param array $atts
|
|
|
|
* @param array $wrapper
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function shortcode_wrapper( $function, $atts = array(), $wrapper = array( 'class' => 'woocommerce', 'before' => null, 'after' => null ) ) {
|
2013-08-09 16:11:15 +00:00
|
|
|
_deprecated_function( 'Woocommerce->shortcode_wrapper', '2.1', 'WC_Shortcodes::shortcode_wrapper' );
|
|
|
|
return WC_Shortcodes::shortcode_wrapper( $function, $atts, $wrapper );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return object
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_attribute_taxonomies() {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_attribute_taxonomies', '2.1', 'wc_get_attribute_taxonomies' );
|
|
|
|
return wc_get_attribute_taxonomies();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $name
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function attribute_taxonomy_name( $name ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->attribute_taxonomy_name', '2.1', 'wc_attribute_taxonomy_name' );
|
|
|
|
return wc_attribute_taxonomy_name( $name );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $name
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function attribute_label( $name ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->attribute_label', '2.1', 'wc_attribute_label' );
|
|
|
|
return wc_attribute_label( $name );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $name
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function attribute_orderby( $name ) {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->attribute_orderby', '2.1', 'wc_attribute_orderby' );
|
|
|
|
return wc_attribute_orderby( $name );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return array
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_attribute_taxonomy_names() {
|
2013-09-12 13:41:02 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_attribute_taxonomy_names', '2.1', 'wc_get_attribute_taxonomy_names' );
|
|
|
|
return wc_get_attribute_taxonomy_names();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @return array
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_coupon_discount_types() {
|
2013-06-28 09:23:20 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_coupon_discount_types', '2.1', 'wc_get_coupon_types' );
|
|
|
|
return wc_get_coupon_types();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param string $type
|
|
|
|
* @return string
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_coupon_discount_type( $type = '' ) {
|
2013-06-28 09:23:20 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_coupon_discount_type', '2.1', 'wc_get_coupon_type' );
|
|
|
|
return wc_get_coupon_type( $type );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $class
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function add_body_class( $class ) {
|
2013-08-09 16:11:15 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_body_class', '2.1' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @param $classes
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function output_body_class( $classes ) {
|
2013-08-09 16:11:15 +00:00
|
|
|
_deprecated_function( 'Woocommerce->output_body_class', '2.1' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $error
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function add_error( $error ) {
|
2013-11-13 04:29:03 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_error', '2.1', 'wc_add_notice' );
|
|
|
|
wc_add_notice( $error, 'error' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @param $message
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function add_message( $message ) {
|
2013-11-13 04:32:29 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_message', '2.1', 'wc_add_notice' );
|
|
|
|
wc_add_notice( $message );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function clear_messages() {
|
2013-11-13 04:35:15 +00:00
|
|
|
_deprecated_function( 'Woocommerce->clear_messages', '2.1', 'wc_clear_notices' );
|
|
|
|
wc_clear_notices();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @return int
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function error_count() {
|
2013-11-13 04:34:11 +00:00
|
|
|
_deprecated_function( 'Woocommerce->error_count', '2.1', 'wc_notice_count' );
|
2013-11-27 16:15:53 +00:00
|
|
|
return wc_notice_count( 'error' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0
|
|
|
|
* @return int
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function message_count() {
|
2013-11-13 04:35:33 +00:00
|
|
|
_deprecated_function( 'Woocommerce->message_count', '2.1', 'wc_notice_count' );
|
2013-11-27 16:15:53 +00:00
|
|
|
return wc_notice_count( 'message' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_errors() {
|
2013-11-13 23:57:06 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_errors', '2.1', 'wc_get_notices( "error" )' );
|
|
|
|
return wc_get_notices( 'error' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
* @return mixed
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_messages() {
|
2013-11-13 23:57:06 +00:00
|
|
|
_deprecated_function( 'Woocommerce->get_messages', '2.1', 'wc_get_notices( "success" )' );
|
|
|
|
return wc_get_notices( 'success' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function show_messages() {
|
2013-11-13 04:34:55 +00:00
|
|
|
_deprecated_function( 'Woocommerce->show_messages', '2.1', 'wc_print_notices()' );
|
|
|
|
wc_print_notices();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
2014-01-20 15:21:50 +00:00
|
|
|
* @deprecated 2.1.0
|
2013-09-25 03:11:42 +00:00
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function set_messages() {
|
2013-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->set_messages', '2.1' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
endif;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the main instance of WC to prevent the need to use globals.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
2013-09-25 13:10:40 +00:00
|
|
|
* @return WooCommerce
|
2013-06-11 14:21:14 +00:00
|
|
|
*/
|
|
|
|
function WC() {
|
|
|
|
return WooCommerce::instance();
|
|
|
|
}
|
2011-12-08 12:50:50 +00:00
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
// Global for backwards compatibility.
|
2013-06-13 13:36:12 +00:00
|
|
|
$GLOBALS['woocommerce'] = WC();
|