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.
|
2013-05-02 11:29:20 +00:00
|
|
|
* Version: 2.1-bleeding
|
2012-03-20 13:22:35 +00:00
|
|
|
* Author: WooThemes
|
|
|
|
* Author URI: http://woothemes.com
|
2012-12-18 12:04:33 +00:00
|
|
|
* Requires at least: 3.5
|
2012-12-13 15:27:47 +00:00
|
|
|
* Tested up to: 3.5
|
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
|
|
|
|
*/
|
2013-09-12 13:41:02 +00:00
|
|
|
if ( ! defined( 'ABSPATH' ) )
|
|
|
|
exit; // Exit if accessed directly
|
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
|
|
|
|
*/
|
|
|
|
public $version = '2.1-bleeding';
|
|
|
|
|
|
|
|
/**
|
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;
|
|
|
|
|
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() {
|
|
|
|
if ( is_null( self::$_instance ) )
|
|
|
|
self::$_instance = new self();
|
|
|
|
return self::$_instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Cloning is forbidden.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
|
|
|
*/
|
|
|
|
public function __clone() {
|
|
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '2.1' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Unserializing instances of this class is forbidden.
|
|
|
|
*
|
|
|
|
* @since 2.1
|
|
|
|
*/
|
|
|
|
public function __wakeup() {
|
|
|
|
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?' ), '2.1' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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() {
|
|
|
|
// Auto-load classes on demand
|
2013-07-25 15:29:25 +00:00
|
|
|
if ( function_exists( "__autoload" ) )
|
2013-06-11 14:21:14 +00:00
|
|
|
spl_autoload_register( "__autoload" );
|
2013-07-25 15:29:25 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
spl_autoload_register( array( $this, 'autoload' ) );
|
|
|
|
|
2013-07-25 15:29:25 +00:00
|
|
|
// Define constants
|
2013-10-24 18:36:22 +00:00
|
|
|
$this->define_constants();
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// Include required files
|
|
|
|
$this->includes();
|
|
|
|
|
|
|
|
// Init API
|
|
|
|
$this->api = new WC_API();
|
|
|
|
|
|
|
|
// Hooks
|
|
|
|
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
|
|
|
|
add_action( 'widgets_init', array( $this, 'include_widgets' ) );
|
|
|
|
add_action( 'init', array( $this, 'init' ), 0 );
|
2013-08-23 15:58:19 +00:00
|
|
|
add_action( 'init', array( $this, 'include_template_functions' ) );
|
2013-10-23 11:55:40 +00:00
|
|
|
add_action( 'init', array( 'WC_Shortcodes', 'init' ) );
|
2013-09-12 13:41:02 +00:00
|
|
|
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
|
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-09-12 13:41:02 +00:00
|
|
|
if ( method_exists( $this, $key ) )
|
|
|
|
return $this->$key();
|
|
|
|
else switch( $key ) {
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'template_url':
|
2013-10-24 18:36:22 +00:00
|
|
|
_deprecated_argument( 'Woocommerce->template_url', '2.1', 'WC_TEMPLATE_PATH constant' );
|
|
|
|
return WC_TEMPLATE_PATH;
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'messages':
|
|
|
|
_deprecated_argument( 'Woocommerce->messages', '2.1', 'The "messages" field is moved to the messages helper class.' );
|
2013-09-12 13:41:02 +00:00
|
|
|
return $this->session->get( 'wc_messages', array() );
|
2013-06-11 14:21:14 +00:00
|
|
|
case 'errors':
|
|
|
|
_deprecated_argument( 'Woocommerce->errors', '2.1', 'The "errors" field is moved to the messages helper class.' );
|
2013-09-12 13:41:02 +00:00
|
|
|
return $this->session->get( 'wc_errors', array() );
|
2013-06-11 14:21:14 +00:00
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
/**
|
|
|
|
* Show action links on the plugin screen
|
|
|
|
*
|
|
|
|
* @param mixed $links
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function action_links( $links ) {
|
|
|
|
return array_merge( array(
|
2013-10-22 16:26:18 +00:00
|
|
|
'<a href="' . admin_url( 'admin.php?page=wc-settings' ) . '">' . __( 'Settings', 'woocommerce' ) . '</a>',
|
2013-10-22 17:20:33 +00:00
|
|
|
'<a href="' . esc_url( apply_filters( 'woocommerce_docs_url', 'http://docs.woothemes.com/documentation/plugins/woocommerce/', 'woocommerce' ) ) . '">' . __( 'Docs', 'woocommerce' ) . '</a>',
|
|
|
|
'<a href="' . esc_url( apply_filters( 'woocommerce_support_url', 'http://support.woothemes.com/' ) ) . '">' . __( 'Premium Support', 'woocommerce' ) . '</a>',
|
2013-09-12 13:41:02 +00:00
|
|
|
), $links );
|
|
|
|
}
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
/**
|
|
|
|
* Auto-load WC classes on demand to reduce memory consumption.
|
|
|
|
*
|
|
|
|
* @param mixed $class
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function autoload( $class ) {
|
|
|
|
|
|
|
|
$class = strtolower( $class );
|
|
|
|
|
|
|
|
if ( strpos( $class, 'wc_gateway_' ) === 0 ) {
|
|
|
|
|
|
|
|
$path = $this->plugin_path() . '/includes/gateways/' . trailingslashit( substr( str_replace( '_', '-', $class ), 11 ) );
|
|
|
|
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
|
|
|
|
|
|
|
if ( is_readable( $path . $file ) ) {
|
|
|
|
include_once( $path . $file );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif ( strpos( $class, 'wc_shipping_' ) === 0 ) {
|
|
|
|
|
|
|
|
$path = $this->plugin_path() . '/includes/shipping/' . trailingslashit( substr( str_replace( '_', '-', $class ), 12 ) );
|
|
|
|
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
|
|
|
|
|
|
|
if ( is_readable( $path . $file ) ) {
|
|
|
|
include_once( $path . $file );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif ( strpos( $class, 'wc_shortcode_' ) === 0 ) {
|
|
|
|
|
|
|
|
$path = $this->plugin_path() . '/includes/shortcodes/';
|
|
|
|
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
|
|
|
|
2013-08-06 10:41:20 +00:00
|
|
|
if ( is_readable( $path . $file ) ) {
|
|
|
|
include_once( $path . $file );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
} elseif ( strpos( $class, 'wc_meta_box' ) === 0 ) {
|
|
|
|
|
|
|
|
$path = $this->plugin_path() . '/includes/admin/post-types/meta-boxes/';
|
|
|
|
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
if ( is_readable( $path . $file ) ) {
|
|
|
|
include_once( $path . $file );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( strpos( $class, 'wc_' ) === 0 ) {
|
|
|
|
|
|
|
|
$path = $this->plugin_path() . '/includes/';
|
|
|
|
$file = 'class-' . str_replace( '_', '-', $class ) . '.php';
|
|
|
|
|
|
|
|
if ( is_readable( $path . $file ) ) {
|
|
|
|
include_once( $path . $file );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-24 18:36:22 +00:00
|
|
|
/**
|
|
|
|
* Define WC Constants
|
|
|
|
*/
|
|
|
|
private function define_constants() {
|
|
|
|
define( 'WC_PLUGIN_FILE', __FILE__ );
|
|
|
|
define( 'WC_VERSION', $this->version );
|
|
|
|
define( 'WOOCOMMERCE_VERSION', WC_VERSION ); // Backwards compat
|
|
|
|
|
|
|
|
if ( ! defined( 'WC_TEMPLATE_PATH' ) )
|
|
|
|
define( 'WC_TEMPLATE_PATH', $this->template_path() );
|
|
|
|
|
|
|
|
if ( ! defined( 'WC_ROUNDING_PRECISION' ) )
|
|
|
|
define( 'WC_ROUNDING_PRECISION', 4 );
|
|
|
|
|
|
|
|
// 1 = PHP_ROUND_HALF_UP, 2 = PHP_ROUND_HALF_DOWN
|
|
|
|
if ( ! defined( 'WC_TAX_ROUNDING_MODE' ) )
|
|
|
|
define( 'WC_TAX_ROUNDING_MODE', get_option( 'woocommerce_prices_include_tax' ) == 'yes' ? 2 : 1 );
|
|
|
|
|
|
|
|
if ( ! defined( 'WC_DELIMITER' ) )
|
|
|
|
define( 'WC_DELIMITER', '|' );
|
|
|
|
}
|
|
|
|
|
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() {
|
2013-08-09 16:11:15 +00:00
|
|
|
include( 'includes/wc-core-functions.php' );
|
2013-07-25 15:29:25 +00:00
|
|
|
include( 'includes/class-wc-install.php' );
|
2013-08-09 16:11:15 +00:00
|
|
|
include( 'includes/class-wc-download-handler.php' );
|
|
|
|
include( 'includes/class-wc-comments.php' );
|
2013-11-12 17:43:30 +00:00
|
|
|
include( 'includes/class-wc-post-data.php' );
|
2013-06-11 14:59:54 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
if ( is_admin() )
|
2013-07-24 16:01:36 +00:00
|
|
|
include_once( 'includes/admin/class-wc-admin.php' );
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
if ( defined('DOING_AJAX') )
|
|
|
|
$this->ajax_includes();
|
2013-07-24 16:01:36 +00:00
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
if ( ! is_admin() || defined('DOING_AJAX') )
|
|
|
|
$this->frontend_includes();
|
|
|
|
|
2013-07-23 16:05:01 +00:00
|
|
|
// Query class
|
|
|
|
$this->query = include( 'includes/class-wc-query.php' ); // The main query class
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// Post types
|
2013-09-12 13:41:02 +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
|
2013-06-11 14:59:54 +00:00
|
|
|
include_once( 'includes/abstracts/abstract-wc-product.php' ); // Products
|
|
|
|
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
|
2013-11-01 20:05:02 +00:00
|
|
|
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)
|
2013-09-12 13:41:02 +00:00
|
|
|
include_once( 'includes/class-wc-product-factory.php' ); // Product factory
|
2013-06-11 14:21:14 +00:00
|
|
|
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
|
2013-09-03 12:03:05 +00:00
|
|
|
include_once( 'includes/class-wc-https.php' ); // https Helper
|
2013-06-11 14:21:14 +00:00
|
|
|
|
2013-08-23 15:58:19 +00:00
|
|
|
// Include template hooks in time for themes to remove/modify them
|
|
|
|
include_once( 'includes/wc-template-hooks.php' );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Include required ajax files.
|
|
|
|
*/
|
|
|
|
public function ajax_includes() {
|
2013-09-12 13:41:02 +00:00
|
|
|
include_once( 'woocommerce-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() {
|
2013-09-12 13:41:02 +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
|
2013-06-11 14:21:14 +00:00
|
|
|
include_once( 'includes/class-wc-cart.php' ); // The main cart class
|
|
|
|
include_once( 'includes/class-wc-tax.php' ); // Tax class
|
2013-09-12 13:41:02 +00:00
|
|
|
include_once( 'includes/class-wc-customer.php' ); // Customer class
|
|
|
|
include_once( 'includes/abstracts/abstract-wc-session.php' ); // Abstract for session implementations
|
|
|
|
include_once( 'includes/class-wc-session-handler.php' ); // WC Session class
|
|
|
|
include_once( 'includes/class-wc-shortcodes.php' ); // Shortcodes class
|
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() {
|
2013-08-09 16:11:15 +00:00
|
|
|
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
|
|
|
*/
|
|
|
|
public function include_widgets() {
|
2013-06-11 14:59:54 +00:00
|
|
|
include_once( 'includes/abstracts/abstract-wc-widget.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-cart.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-products.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-layered-nav.php' );
|
|
|
|
include_once( 'includes/widgets/class-wc-widget-layered-nav-filters.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-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();
|
|
|
|
|
|
|
|
// Load class instances
|
2013-09-12 13:41:02 +00:00
|
|
|
$this->product_factory = new WC_Product_Factory(); // Product Factory to create new product instances
|
2013-06-11 14:21:14 +00:00
|
|
|
$this->countries = new WC_Countries(); // Countries class
|
|
|
|
$this->integrations = new WC_Integrations(); // Integrations class
|
|
|
|
|
|
|
|
// Classes/actions loaded for the frontend and for ajax requests
|
|
|
|
if ( ! is_admin() || defined('DOING_AJAX') ) {
|
|
|
|
|
|
|
|
// Session class, handles session data for customers - can be overwritten if custom handler is needed
|
|
|
|
$session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
|
|
|
|
|
|
|
|
// Class instances
|
2013-09-12 13:41:02 +00:00
|
|
|
$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
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Email Actions
|
2013-09-23 15:51:43 +00:00
|
|
|
$email_actions = array(
|
|
|
|
'woocommerce_low_stock',
|
|
|
|
'woocommerce_no_stock',
|
|
|
|
'woocommerce_product_on_backorder',
|
|
|
|
'woocommerce_order_status_pending_to_processing',
|
|
|
|
'woocommerce_order_status_pending_to_completed',
|
|
|
|
'woocommerce_order_status_pending_to_on-hold',
|
|
|
|
'woocommerce_order_status_failed_to_processing',
|
|
|
|
'woocommerce_order_status_failed_to_completed',
|
|
|
|
'woocommerce_order_status_completed',
|
|
|
|
'woocommerce_new_customer_note',
|
|
|
|
'woocommerce_created_customer'
|
|
|
|
);
|
2013-06-11 14:21:14 +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 );
|
2013-06-11 14:21:14 +00:00
|
|
|
|
|
|
|
// Init action
|
|
|
|
do_action( 'woocommerce_init' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load Localisation files.
|
|
|
|
*
|
|
|
|
* Note: the first-loaded translation file overrides any following ones if the same translation is present
|
|
|
|
*/
|
|
|
|
public function load_plugin_textdomain() {
|
|
|
|
$locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce' );
|
|
|
|
|
|
|
|
// Admin Locale
|
|
|
|
if ( is_admin() ) {
|
|
|
|
load_textdomain( 'woocommerce', WP_LANG_DIR . "/woocommerce/woocommerce-admin-$locale.mo" );
|
2013-10-10 12:59:46 +00:00
|
|
|
load_textdomain( 'woocommerce', dirname( __FILE__ ) . "/i18n/languages/woocommerce-admin-$locale.mo" );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Frontend Locale
|
|
|
|
load_textdomain( 'woocommerce', WP_LANG_DIR . "/woocommerce/woocommerce-$locale.mo" );
|
|
|
|
|
|
|
|
if ( apply_filters( 'woocommerce_load_alt_locale', false ) )
|
2013-06-11 14:59:54 +00:00
|
|
|
load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages/alt" );
|
2013-06-11 14:21:14 +00:00
|
|
|
else
|
2013-06-11 14:59:54 +00:00
|
|
|
load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages" );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2013-09-12 13:41:02 +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() {
|
2013-06-11 14:21:14 +00:00
|
|
|
// Post thumbnail support
|
|
|
|
if ( ! current_theme_supports( 'post-thumbnails', 'product' ) ) {
|
|
|
|
add_theme_support( 'post-thumbnails' );
|
|
|
|
remove_post_type_support( 'post', 'thumbnail' );
|
|
|
|
remove_post_type_support( 'page', 'thumbnail' );
|
|
|
|
} else {
|
|
|
|
add_post_type_support( 'product', 'thumbnail' );
|
|
|
|
}
|
|
|
|
|
2013-09-12 13:41:02 +00:00
|
|
|
// Add image sizes
|
|
|
|
$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'] );
|
|
|
|
|
2013-06-11 14:21:14 +00:00
|
|
|
// IIS
|
|
|
|
if ( ! isset($_SERVER['REQUEST_URI'] ) ) {
|
|
|
|
$_SERVER['REQUEST_URI'] = substr( $_SERVER['PHP_SELF'], 1 );
|
|
|
|
if ( isset( $_SERVER['QUERY_STRING'] ) )
|
|
|
|
$_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// NGINX Proxy
|
|
|
|
if ( ! isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_SERVER['HTTP_REMOTE_ADDR'] ) )
|
|
|
|
$_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_REMOTE_ADDR'];
|
|
|
|
|
|
|
|
if ( ! isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTP_HTTPS'] ) )
|
|
|
|
$_SERVER['HTTPS'] = $_SERVER['HTTP_HTTPS'];
|
|
|
|
|
|
|
|
// Support for hosts which don't use HTTPS, and use HTTP_X_FORWARDED_PROTO
|
|
|
|
if ( ! isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' )
|
|
|
|
$_SERVER['HTTPS'] = '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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() {
|
2013-10-24 18:36:22 +00:00
|
|
|
return apply_filters( 'WC_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
|
|
|
|
*
|
|
|
|
* @param mixed $request
|
|
|
|
* @param mixed $ssl (default: null)
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function api_request_url( $request, $ssl = null ) {
|
|
|
|
if ( is_null( $ssl ) ) {
|
|
|
|
$scheme = parse_url( get_option( 'home' ), PHP_URL_SCHEME );
|
|
|
|
} elseif ( $ssl ) {
|
|
|
|
$scheme = 'https';
|
|
|
|
} else {
|
|
|
|
$scheme = 'http';
|
|
|
|
}
|
|
|
|
|
2013-08-23 19:29:24 +00:00
|
|
|
if ( get_option('permalink_structure') ) {
|
|
|
|
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.
|
2013-09-25 03:11:42 +00:00
|
|
|
* @internal param array $args (default: array())
|
2013-09-12 13:41:02 +00:00
|
|
|
* @return void
|
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
|
|
|
|
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
|
|
|
*
|
2013-09-12 13:41:02 +00:00
|
|
|
* @return WC_Email
|
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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Transient_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Transient_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Nonce_Helper helper
|
|
|
|
* @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-06-11 14:21:14 +00:00
|
|
|
_deprecated_function( 'Woocommerce->verify_nonce', '2.1', 'WC_Nonce_Helper->verify_nonce' );
|
2013-09-25 12:12:48 +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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Shortcode_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Attribute_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Attribute_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Attribute_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Attribute_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Attribute_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Body_Class_Helper helper
|
|
|
|
* @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
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Body_Class_Helper helper
|
|
|
|
* @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-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_error', '2.1', 'wc_add_error' );
|
|
|
|
wc_add_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-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->add_message', '2.1', 'wc_add_message' );
|
|
|
|
wc_add_message( $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-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->clear_messages', '2.1', 'wc_clear_messages' );
|
|
|
|
wc_clear_messages();
|
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-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->error_count', '2.1', 'wc_error_count' );
|
|
|
|
return wc_error_count();
|
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-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->message_count', '2.1', 'wc_message_count' );
|
|
|
|
return wc_message_count();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Messages_Helper helper
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_errors() {
|
|
|
|
_deprecated_function( 'Woocommerce->get_errors', '2.1', 'WC_Messages_Helper->get_errors' );
|
2013-09-12 13:41:02 +00:00
|
|
|
return $this->session->get( 'wc_errors', array() );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Messages_Helper helper
|
|
|
|
* @return mixed
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function get_messages() {
|
|
|
|
_deprecated_function( 'Woocommerce->get_messages', '2.1', 'WC_Messages_Helper->get_messages' );
|
2013-09-12 13:41:02 +00:00
|
|
|
return $this->session->get( 'wc_messages', array() );
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Messages_Helper helper
|
|
|
|
*/
|
2013-06-11 14:21:14 +00:00
|
|
|
public function show_messages() {
|
2013-06-11 14:59:54 +00:00
|
|
|
_deprecated_function( 'Woocommerce->show_messages', '2.1', 'wc_print_messages()' );
|
|
|
|
wc_print_messages();
|
2013-06-11 14:21:14 +00:00
|
|
|
}
|
|
|
|
|
2013-09-25 03:11:42 +00:00
|
|
|
/**
|
|
|
|
* @deprecated 2.1.0 Access via the WC_Messages_Helper helper
|
|
|
|
*/
|
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();
|