1 <?php
  2 /**
  3  * Plugin Name: WooCommerce
  4  * Plugin URI: http://www.woothemes.com/woocommerce/
  5  * Description: An e-commerce toolkit that helps you sell anything. Beautifully.
  6  * Version: 2.1.10
  7  * Author: WooThemes
  8  * Author URI: http://woothemes.com
  9  * Requires at least: 3.8
 10  * Tested up to: 3.9
 11  *
 12  * Text Domain: woocommerce
 13  * Domain Path: /i18n/languages/
 14  *
 15  * @package WooCommerce
 16  * @category Core
 17  * @author WooThemes
 18  */
 19 if ( ! defined( 'ABSPATH' ) ) {
 20     exit; // Exit if accessed directly
 21 }
 22 
 23 if ( ! class_exists( 'WooCommerce' ) ) :
 24 
 25 /**
 26  * Main WooCommerce Class
 27  *
 28  * @class WooCommerce
 29  * @version 2.1.0
 30  */
 31 final class WooCommerce {
 32 
 33     /**
 34      * @var string
 35      */
 36     public $version = '2.1.10';
 37 
 38     /**
 39      * @var WooCommerce The single instance of the class
 40      * @since 2.1
 41      */
 42     protected static $_instance = null;
 43 
 44     /**
 45      * @var WC_Session session
 46      */
 47     public $session = null;
 48 
 49     /**
 50      * @var WC_Query $query
 51      */
 52     public $query = null;
 53 
 54     /**
 55      * @var WC_Product_Factory $product_factory
 56      */
 57     public $product_factory = null;
 58 
 59     /**
 60      * @var WC_Countries $countries
 61      */
 62     public $countries = null;
 63 
 64     /**
 65      * @var WC_Integrations $integrations
 66      */
 67     public $integrations = null;
 68 
 69     /**
 70      * @var WC_Cart $cart
 71      */
 72     public $cart = null;
 73 
 74     /**
 75      * @var WC_Customer $customer
 76      */
 77     public $customer = null;
 78 
 79     /**
 80      * Main WooCommerce Instance
 81      *
 82      * Ensures only one instance of WooCommerce is loaded or can be loaded.
 83      *
 84      * @since 2.1
 85      * @static
 86      * @see WC()
 87      * @return WooCommerce - Main instance
 88      */
 89     public static function instance() {
 90         if ( is_null( self::$_instance ) ) {
 91             self::$_instance = new self();
 92         }
 93         return self::$_instance;
 94     }
 95 
 96     /**
 97      * Cloning is forbidden.
 98      *
 99      * @since 2.1
100      */
101     public function __clone() {
102         _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woocommerce' ), '2.1' );
103     }
104 
105     /**
106      * Unserializing instances of this class is forbidden.
107      *
108      * @since 2.1
109      */
110     public function __wakeup() {
111         _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'woocommerce' ), '2.1' );
112     }
113 
114     /**
115      * WooCommerce Constructor.
116      * @access public
117      * @return WooCommerce
118      */
119     public function __construct() {
120         // Auto-load classes on demand
121         if ( function_exists( "__autoload" ) ) {
122             spl_autoload_register( "__autoload" );
123         }
124 
125         spl_autoload_register( array( $this, 'autoload' ) );
126 
127         // Define constants
128         $this->define_constants();
129 
130         // Include required files
131         $this->includes();
132 
133         // Init API
134         $this->api = new WC_API();
135 
136         // Hooks
137         add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
138         add_action( 'widgets_init', array( $this, 'include_widgets' ) );
139         add_action( 'init', array( $this, 'init' ), 0 );
140         add_action( 'init', array( $this, 'include_template_functions' ) );
141         add_action( 'init', array( 'WC_Shortcodes', 'init' ) );
142         add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
143 
144         // Loaded action
145         do_action( 'woocommerce_loaded' );
146     }
147 
148     /**
149      * Auto-load in-accessible properties on demand.
150      *
151      * @param mixed $key
152      * @return mixed
153      */
154     public function __get( $key ) {
155         if ( method_exists( $this, $key ) ) {
156             return $this->$key();
157         }
158         else switch( $key ) {
159             case 'template_url':
160                 _deprecated_argument( 'Woocommerce->template_url', '2.1', 'WC_TEMPLATE_PATH constant' );
161                 return WC_TEMPLATE_PATH;
162             case 'messages':
163                 _deprecated_argument( 'Woocommerce->messages', '2.1', 'Use wc_get_notices' );
164                 return wc_get_notices( 'success' );
165             case 'errors':
166                 _deprecated_argument( 'Woocommerce->errors', '2.1', 'Use wc_get_notices' );
167                 return wc_get_notices( 'error' );
168             default:
169                 return false;
170         }
171     }
172 
173     /**
174      * Show action links on the plugin screen
175      *
176      * @param mixed $links
177      * @return array
178      */
179     public function action_links( $links ) {
180         return array_merge( array(
181             '<a href="' . admin_url( 'admin.php?page=wc-settings' ) . '">' . __( 'Settings', 'woocommerce' ) . '</a>',
182             '<a href="' . esc_url( apply_filters( 'woocommerce_docs_url', 'http://docs.woothemes.com/documentation/plugins/woocommerce/', 'woocommerce' ) ) . '">' . __( 'Docs', 'woocommerce' ) . '</a>',
183             '<a href="' . esc_url( apply_filters( 'woocommerce_support_url', 'http://support.woothemes.com/' ) ) . '">' . __( 'Premium Support', 'woocommerce' ) . '</a>',
184         ), $links );
185     }
186 
187     /**
188      * Auto-load WC classes on demand to reduce memory consumption.
189      *
190      * @param mixed $class
191      * @return void
192      */
193     public function autoload( $class ) {
194         $path  = null;
195         $class = strtolower( $class );
196         $file = 'class-' . str_replace( '_', '-', $class ) . '.php';
197 
198         if ( strpos( $class, 'wc_gateway_' ) === 0 ) {
199             $path = $this->plugin_path() . '/includes/gateways/' . trailingslashit( substr( str_replace( '_', '-', $class ), 11 ) );
200         } elseif ( strpos( $class, 'wc_shipping_' ) === 0 ) {
201             $path = $this->plugin_path() . '/includes/shipping/' . trailingslashit( substr( str_replace( '_', '-', $class ), 12 ) );
202         } elseif ( strpos( $class, 'wc_shortcode_' ) === 0 ) {
203             $path = $this->plugin_path() . '/includes/shortcodes/';
204         } elseif ( strpos( $class, 'wc_meta_box' ) === 0 ) {
205             $path = $this->plugin_path() . '/includes/admin/post-types/meta-boxes/';
206         } elseif ( strpos( $class, 'wc_admin' ) === 0 ) {
207             $path = $this->plugin_path() . '/includes/admin/';
208         }
209 
210         if ( $path && is_readable( $path . $file ) ) {
211             include_once( $path . $file );
212             return;
213         }
214 
215         // Fallback
216         if ( strpos( $class, 'wc_' ) === 0 ) {
217             $path = $this->plugin_path() . '/includes/';
218         }
219 
220         if ( $path && is_readable( $path . $file ) ) {
221             include_once( $path . $file );
222             return;
223         }
224     }
225 
226     /**
227      * Define WC Constants
228      */
229     private function define_constants() {
230         define( 'WC_PLUGIN_FILE', __FILE__ );
231         define( 'WC_VERSION', $this->version );
232         define( 'WOOCOMMERCE_VERSION', WC_VERSION ); // Backwards compat
233 
234         if ( ! defined( 'WC_TEMPLATE_PATH' ) ) {
235             define( 'WC_TEMPLATE_PATH', $this->template_path() );
236         }
237         
238         if ( ! defined( 'WC_ROUNDING_PRECISION' ) ) {
239             define( 'WC_ROUNDING_PRECISION', 4 );
240         }
241 
242         // 1 = PHP_ROUND_HALF_UP, 2 = PHP_ROUND_HALF_DOWN
243         if ( ! defined( 'WC_TAX_ROUNDING_MODE' ) ) {
244             define( 'WC_TAX_ROUNDING_MODE', get_option( 'woocommerce_prices_include_tax' ) === 'yes' ? 2 : 1 ); 
245         }
246 
247         if ( ! defined( 'WC_DELIMITER' ) ) {
248             define( 'WC_DELIMITER', '|' );
249         }
250     }
251 
252     /**
253      * Include required core files used in admin and on the frontend.
254      */
255     private function includes() {
256         include_once( 'includes/wc-core-functions.php' );
257         include_once( 'includes/class-wc-install.php' );
258         include_once( 'includes/class-wc-download-handler.php' );
259         include_once( 'includes/class-wc-comments.php' );
260         include_once( 'includes/class-wc-post-data.php' );
261         include_once( 'includes/abstracts/abstract-wc-session.php' );
262         include_once( 'includes/class-wc-session-handler.php' );
263 
264         if ( is_admin() ) {
265             include_once( 'includes/admin/class-wc-admin.php' );
266         }
267 
268         if ( defined( 'DOING_AJAX' ) ) {
269             $this->ajax_includes();
270         }
271 
272         if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
273             $this->frontend_includes();
274         }
275 
276         // Query class
277         $this->query = include( 'includes/class-wc-query.php' );                // The main query class
278 
279         // Post types
280         include_once( 'includes/class-wc-post-types.php' );                     // Registers post types
281 
282         // API Class
283         include_once( 'includes/class-wc-api.php' );
284 
285         // Include abstract classes
286         include_once( 'includes/abstracts/abstract-wc-product.php' );           // Products
287         include_once( 'includes/abstracts/abstract-wc-settings-api.php' );      // Settings API (for gateways, shipping, and integrations)
288         include_once( 'includes/abstracts/abstract-wc-shipping-method.php' );   // A Shipping method
289         include_once( 'includes/abstracts/abstract-wc-payment-gateway.php' );   // A Payment gateway
290         include_once( 'includes/abstracts/abstract-wc-integration.php' );       // An integration with a service
291 
292         // Classes (used on all pages)
293         include_once( 'includes/class-wc-product-factory.php' );                // Product factory
294         include_once( 'includes/class-wc-countries.php' );                      // Defines countries and states
295         include_once( 'includes/class-wc-integrations.php' );                   // Loads integrations
296         include_once( 'includes/class-wc-cache-helper.php' );                   // Cache Helper
297         include_once( 'includes/class-wc-https.php' );                          // https Helper
298 
299         // Include template hooks in time for themes to remove/modify them
300         include_once( 'includes/wc-template-hooks.php' );
301     }
302 
303     /**
304      * Include required ajax files.
305      */
306     public function ajax_includes() {
307         include_once( 'includes/class-wc-ajax.php' );                   // Ajax functions for admin and the front-end
308     }
309 
310     /**
311      * Include required frontend files.
312      */
313     public function frontend_includes() {
314         include_once( 'includes/class-wc-template-loader.php' );        // Template Loader
315         include_once( 'includes/class-wc-frontend-scripts.php' );       // Frontend Scripts
316         include_once( 'includes/class-wc-form-handler.php' );           // Form Handlers
317         include_once( 'includes/class-wc-cart.php' );                   // The main cart class
318         include_once( 'includes/class-wc-tax.php' );                    // Tax class
319         include_once( 'includes/class-wc-customer.php' );               // Customer class
320         include_once( 'includes/class-wc-shortcodes.php' );             // Shortcodes class
321     }
322 
323     /**
324      * Function used to Init WooCommerce Template Functions - This makes them pluggable by plugins and themes.
325      */
326     public function include_template_functions() {
327         include_once( 'includes/wc-template-functions.php' );
328     }
329 
330     /**
331      * Include core widgets
332      */
333     public function include_widgets() {
334         include_once( 'includes/abstracts/abstract-wc-widget.php' );
335         include_once( 'includes/widgets/class-wc-widget-cart.php' );
336         include_once( 'includes/widgets/class-wc-widget-products.php' );
337         include_once( 'includes/widgets/class-wc-widget-layered-nav.php' );
338         include_once( 'includes/widgets/class-wc-widget-layered-nav-filters.php' );
339         include_once( 'includes/widgets/class-wc-widget-price-filter.php' );
340         include_once( 'includes/widgets/class-wc-widget-product-categories.php' );
341         include_once( 'includes/widgets/class-wc-widget-product-search.php' );
342         include_once( 'includes/widgets/class-wc-widget-product-tag-cloud.php' );
343         include_once( 'includes/widgets/class-wc-widget-recent-reviews.php' );
344         include_once( 'includes/widgets/class-wc-widget-recently-viewed.php' );
345         include_once( 'includes/widgets/class-wc-widget-top-rated-products.php' );
346     }
347 
348     /**
349      * Init WooCommerce when WordPress Initialises.
350      */
351     public function init() {
352         // Before init action
353         do_action( 'before_woocommerce_init' );
354 
355         // Set up localisation
356         $this->load_plugin_textdomain();
357 
358         // Session class, handles session data for users - can be overwritten if custom handler is needed
359         $session_class = apply_filters( 'woocommerce_session_handler', 'WC_Session_Handler' );
360 
361         // Load class instances
362         $this->product_factory = new WC_Product_Factory();     // Product Factory to create new product instances
363         $this->countries       = new WC_Countries();            // Countries class
364         $this->integrations    = new WC_Integrations();     // Integrations class
365         $this->session         = new $session_class();
366 
367         // Classes/actions loaded for the frontend and for ajax requests
368         if ( ! is_admin() || defined( 'DOING_AJAX' ) ) {
369             // Class instances
370             $this->cart     = new WC_Cart();                // Cart class, stores the cart contents
371             $this->customer = new WC_Customer();            // Customer class, handles data such as customer location
372         }
373 
374         // Email Actions
375         $email_actions = array(
376             'woocommerce_low_stock',
377             'woocommerce_no_stock',
378             'woocommerce_product_on_backorder',
379             'woocommerce_order_status_pending_to_processing',
380             'woocommerce_order_status_pending_to_completed',
381             'woocommerce_order_status_pending_to_on-hold',
382             'woocommerce_order_status_failed_to_processing',
383             'woocommerce_order_status_failed_to_completed',
384             'woocommerce_order_status_completed',
385             'woocommerce_new_customer_note',
386             'woocommerce_created_customer'
387         );
388 
389         foreach ( $email_actions as $action )
390             add_action( $action, array( $this, 'send_transactional_email' ), 10, 10 );
391 
392         // Init action
393         do_action( 'woocommerce_init' );
394     }
395 
396     /**
397      * Load Localisation files.
398      *
399      * Note: the first-loaded translation file overrides any following ones if the same translation is present
400      */
401     public function load_plugin_textdomain() {
402         $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce' );
403 
404         // Admin Locale
405         if ( is_admin() ) {
406             load_textdomain( 'woocommerce', WP_LANG_DIR . "/woocommerce/woocommerce-admin-$locale.mo" );
407             load_textdomain( 'woocommerce', dirname( __FILE__ ) . "/i18n/languages/woocommerce-admin-$locale.mo" );
408         }
409         
410         // Global + Frontend Locale
411         load_textdomain( 'woocommerce', WP_LANG_DIR . "/woocommerce/woocommerce-$locale.mo" );
412         load_plugin_textdomain( 'woocommerce', false, plugin_basename( dirname( __FILE__ ) ) . "/i18n/languages" );
413     }
414 
415     /**
416      * Ensure theme and server variable compatibility and setup image sizes..
417      */
418     public function setup_environment() {
419         // Post thumbnail support
420         if ( ! current_theme_supports( 'post-thumbnails', 'product' ) ) {
421             add_theme_support( 'post-thumbnails' );
422             remove_post_type_support( 'post', 'thumbnail' );
423             remove_post_type_support( 'page', 'thumbnail' );
424         } else {
425             add_post_type_support( 'product', 'thumbnail' );
426         }
427 
428         // Add image sizes
429         $shop_thumbnail = wc_get_image_size( 'shop_thumbnail' );
430         $shop_catalog   = wc_get_image_size( 'shop_catalog' );
431         $shop_single    = wc_get_image_size( 'shop_single' );
432 
433         add_image_size( 'shop_thumbnail', $shop_thumbnail['width'], $shop_thumbnail['height'], $shop_thumbnail['crop'] );
434         add_image_size( 'shop_catalog', $shop_catalog['width'], $shop_catalog['height'], $shop_catalog['crop'] );
435         add_image_size( 'shop_single', $shop_single['width'], $shop_single['height'], $shop_single['crop'] );
436 
437         // IIS
438         if ( ! isset($_SERVER['REQUEST_URI'] ) ) {
439             $_SERVER['REQUEST_URI'] = substr( $_SERVER['PHP_SELF'], 1 );
440             if ( isset( $_SERVER['QUERY_STRING'] ) ) {
441                 $_SERVER['REQUEST_URI'].='?'.$_SERVER['QUERY_STRING'];
442             }
443         }
444 
445         // NGINX Proxy
446         if ( ! isset( $_SERVER['REMOTE_ADDR'] ) && isset( $_SERVER['HTTP_REMOTE_ADDR'] ) ) {
447             $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_REMOTE_ADDR'];
448         }
449 
450         if ( ! isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTP_HTTPS'] ) ) {
451             $_SERVER['HTTPS'] = $_SERVER['HTTP_HTTPS'];
452         }
453 
454         // Support for hosts which don't use HTTPS, and use HTTP_X_FORWARDED_PROTO
455         if ( ! isset( $_SERVER['HTTPS'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https' ) {
456             $_SERVER['HTTPS'] = '1';
457         }
458     }
459 
460     /** Helper functions ******************************************************/
461 
462     /**
463      * Get the plugin url.
464      *
465      * @return string
466      */
467     public function plugin_url() {
468         return untrailingslashit( plugins_url( '/', __FILE__ ) );
469     }
470 
471     /**
472      * Get the plugin path.
473      *
474      * @return string
475      */
476     public function plugin_path() {
477         return untrailingslashit( plugin_dir_path( __FILE__ ) );
478     }
479 
480     /**
481      * Get the template path.
482      *
483      * @return string
484      */
485     public function template_path() {
486         return apply_filters( 'WC_TEMPLATE_PATH', 'woocommerce/' );
487     }
488 
489     /**
490      * Get Ajax URL.
491      *
492      * @return string
493      */
494     public function ajax_url() {
495         return admin_url( 'admin-ajax.php', 'relative' );
496     }
497 
498     /**
499      * Return the WC API URL for a given request
500      *
501      * @param mixed $request
502      * @param mixed $ssl (default: null)
503      * @return string
504      */
505     public function api_request_url( $request, $ssl = null ) {
506         if ( is_null( $ssl ) ) {
507             $scheme = parse_url( get_option( 'home' ), PHP_URL_SCHEME );
508         } elseif ( $ssl ) {
509             $scheme = 'https';
510         } else {
511             $scheme = 'http';
512         }
513 
514         if ( get_option('permalink_structure') ) {
515             return esc_url_raw( trailingslashit( home_url( '/wc-api/' . $request, $scheme ) ) );
516         } else {
517             return esc_url_raw( add_query_arg( 'wc-api', $request, trailingslashit( home_url( '', $scheme ) ) ) );
518         }
519     }
520 
521     /**
522      * Init the mailer and call the notifications for the current filter.
523      * @internal param array $args (default: array())
524      * @return void
525      */
526     public function send_transactional_email() {
527         $this->mailer();
528         $args = func_get_args();
529         do_action_ref_array( current_filter() . '_notification', $args );
530     }
531 
532     /** Load Instances on demand **********************************************/
533 
534     /**
535      * Get Checkout Class.
536      *
537      * @return WC_Checkout
538      */
539     public function checkout() {
540         return WC_Checkout::instance();
541     }
542 
543     /**
544      * Get gateways class
545      *
546      * @return WC_Payment_Gateways
547      */
548     public function payment_gateways() {
549         return WC_Payment_Gateways::instance();
550     }
551 
552     /**
553      * Get shipping class
554      *
555      * @return WC_Shipping
556      */
557     public function shipping() {
558         return WC_Shipping::instance();
559     }
560 
561     /**
562      * Email Class.
563      *
564      * @return WC_Email
565      */
566     public function mailer() {
567         return WC_Emails::instance();
568     }
569 
570     /** Deprecated methods *********************************************************/
571 
572     /**
573      * @deprecated 2.1.0
574      * @param $image_size
575      * @return array
576      */
577     public function get_image_size( $image_size ) {
578         _deprecated_function( 'Woocommerce->get_image_size', '2.1', 'wc_get_image_size()' );
579         return wc_get_image_size( $image_size );
580     }
581 
582     /**
583      * @deprecated 2.1.0
584      * @return WC_Logger
585      */
586     public function logger() {
587         _deprecated_function( 'Woocommerce->logger', '2.1', 'new WC_Logger()' );
588         return new WC_Logger();
589     }
590 
591     /**
592      * @deprecated 2.1.0
593      * @return WC_Validation
594      */
595     public function validation() {
596         _deprecated_function( 'Woocommerce->validation', '2.1', 'new WC_Validation()' );
597         return new WC_Validation();
598     }
599 
600     /**
601      * @deprecated 2.1.0
602      * @param $post
603      * @return WC_Product
604      */
605     public function setup_product_data( $post ) {
606         _deprecated_function( 'Woocommerce->setup_product_data', '2.1', 'wc_setup_product_data' );
607         return wc_setup_product_data( $post );
608     }
609 
610     /**
611      * @deprecated 2.1.0
612      * @param $content
613      * @return string
614      */
615     public function force_ssl( $content ) {
616         _deprecated_function( 'Woocommerce->force_ssl', '2.1', 'WC_HTTPS::force_https_url' );
617         return WC_HTTPS::force_https_url( $content );
618     }
619 
620     /**
621      * @deprecated 2.1.0
622      * @param int $post_id
623      */
624     public function clear_product_transients( $post_id = 0 ) {
625         _deprecated_function( 'Woocommerce->clear_product_transients', '2.1', 'wc_delete_product_transients' );
626         wc_delete_product_transients( $post_id );
627     }
628 
629     /**
630      * @deprecated 2.1.0 Access via the WC_Inline_Javascript_Helper helper
631      * @param $code
632      */
633     public function add_inline_js( $code ) {
634         _deprecated_function( 'Woocommerce->add_inline_js', '2.1', 'wc_enqueue_js' );
635         wc_enqueue_js( $code );
636     }
637 
638     /**
639      * @deprecated 2.1.0
640      * @param      $action
641      * @param bool $referer
642      * @param bool $echo
643      * @return string
644      */
645     public function nonce_field( $action, $referer = true , $echo = true ) {
646         _deprecated_function( 'Woocommerce->nonce_field', '2.1', 'wp_nonce_field' );
647         return wp_nonce_field('woocommerce-' . $action, '_wpnonce', $referer, $echo );
648     }
649 
650     /**
651      * @deprecated 2.1.0
652      * @param        $action
653      * @param string $url
654      * @return string
655      */
656     public function nonce_url( $action, $url = '' ) {
657         _deprecated_function( 'Woocommerce->nonce_url', '2.1', 'wp_nonce_url' );
658         return wp_nonce_url( $url , 'woocommerce-' . $action );
659     }
660 
661     /**
662      * @deprecated 2.1.0
663      * @param        $action
664      * @param string $method
665      * @param bool   $error_message
666      * @return bool
667      */
668     public function verify_nonce( $action, $method = '_POST', $error_message = false ) {
669         _deprecated_function( 'Woocommerce->verify_nonce', '2.1', 'wp_verify_nonce' );
670         if ( ! isset( $method[ '_wpnonce' ] ) ) {
671             return false;
672         }
673         return wp_verify_nonce( $method[ '_wpnonce' ], 'woocommerce-' . $action );
674     }
675 
676     /**
677      * @deprecated 2.1.0
678      * @param       $function
679      * @param array $atts
680      * @param array $wrapper
681      * @return string
682      */
683     public function shortcode_wrapper( $function, $atts = array(), $wrapper = array( 'class' => 'woocommerce', 'before' => null, 'after' => null ) ) {
684         _deprecated_function( 'Woocommerce->shortcode_wrapper', '2.1', 'WC_Shortcodes::shortcode_wrapper' );
685         return WC_Shortcodes::shortcode_wrapper( $function, $atts, $wrapper );
686     }
687 
688     /**
689      * @deprecated 2.1.0
690      * @return object
691      */
692     public function get_attribute_taxonomies() {
693         _deprecated_function( 'Woocommerce->get_attribute_taxonomies', '2.1', 'wc_get_attribute_taxonomies' );
694         return wc_get_attribute_taxonomies();
695     }
696 
697     /**
698      * @deprecated 2.1.0
699      * @param $name
700      * @return string
701      */
702     public function attribute_taxonomy_name( $name ) {
703         _deprecated_function( 'Woocommerce->attribute_taxonomy_name', '2.1', 'wc_attribute_taxonomy_name' );
704         return wc_attribute_taxonomy_name( $name );
705     }
706 
707     /**
708      * @deprecated 2.1.0
709      * @param $name
710      * @return string
711      */
712     public function attribute_label( $name ) {
713         _deprecated_function( 'Woocommerce->attribute_label', '2.1', 'wc_attribute_label' );
714         return wc_attribute_label( $name );
715     }
716 
717     /**
718      * @deprecated 2.1.0
719      * @param $name
720      * @return string
721      */
722     public function attribute_orderby( $name ) {
723         _deprecated_function( 'Woocommerce->attribute_orderby', '2.1', 'wc_attribute_orderby' );
724         return wc_attribute_orderby( $name );
725     }
726 
727     /**
728      * @deprecated 2.1.0
729      * @return array
730      */
731     public function get_attribute_taxonomy_names() {
732         _deprecated_function( 'Woocommerce->get_attribute_taxonomy_names', '2.1', 'wc_get_attribute_taxonomy_names' );
733         return wc_get_attribute_taxonomy_names();
734     }
735 
736     /**
737      * @deprecated 2.1.0
738      * @return array
739      */
740     public function get_coupon_discount_types() {
741         _deprecated_function( 'Woocommerce->get_coupon_discount_types', '2.1', 'wc_get_coupon_types' );
742         return wc_get_coupon_types();
743     }
744 
745     /**
746      * @deprecated 2.1.0
747      * @param string $type
748      * @return string
749      */
750     public function get_coupon_discount_type( $type = '' ) {
751         _deprecated_function( 'Woocommerce->get_coupon_discount_type', '2.1', 'wc_get_coupon_type' );
752         return wc_get_coupon_type( $type );
753     }
754 
755     /**
756      * @deprecated 2.1.0
757      * @param $class
758      */
759     public function add_body_class( $class ) {
760         _deprecated_function( 'Woocommerce->add_body_class', '2.1' );
761     }
762 
763     /**
764      * @deprecated 2.1.0
765      * @param $classes
766      */
767     public function output_body_class( $classes ) {
768         _deprecated_function( 'Woocommerce->output_body_class', '2.1' );
769     }
770 
771     /**
772      * @deprecated 2.1.0
773      * @param $error
774      */
775     public function add_error( $error ) {
776         _deprecated_function( 'Woocommerce->add_error', '2.1', 'wc_add_notice' );
777         wc_add_notice( $error, 'error' );
778     }
779 
780     /**
781      * @deprecated 2.1.0
782      * @param $message
783      */
784     public function add_message( $message ) {
785         _deprecated_function( 'Woocommerce->add_message', '2.1', 'wc_add_notice' );
786         wc_add_notice( $message );
787     }
788 
789     /**
790      * @deprecated 2.1.0
791      */
792     public function clear_messages() {
793         _deprecated_function( 'Woocommerce->clear_messages', '2.1', 'wc_clear_notices' );
794         wc_clear_notices();
795     }
796 
797     /**
798      * @deprecated 2.1.0
799      * @return int
800      */
801     public function error_count() {
802         _deprecated_function( 'Woocommerce->error_count', '2.1', 'wc_notice_count' );
803         return wc_notice_count( 'error' );
804     }
805 
806     /**
807      * @deprecated 2.1.0
808      * @return int
809      */
810     public function message_count() {
811         _deprecated_function( 'Woocommerce->message_count', '2.1', 'wc_notice_count' );
812         return wc_notice_count( 'message' );
813     }
814 
815     /**
816      * @deprecated 2.1.0
817      * @return mixed
818      */
819     public function get_errors() {
820         _deprecated_function( 'Woocommerce->get_errors', '2.1', 'wc_get_notices( "error" )' );
821         return wc_get_notices( 'error' );
822     }
823 
824     /**
825      * @deprecated 2.1.0
826      * @return mixed
827      */
828     public function get_messages() {
829         _deprecated_function( 'Woocommerce->get_messages', '2.1', 'wc_get_notices( "success" )' );
830         return wc_get_notices( 'success' );
831     }
832 
833     /**
834      * @deprecated 2.1.0
835      */
836     public function show_messages() {
837         _deprecated_function( 'Woocommerce->show_messages', '2.1', 'wc_print_notices()' );
838         wc_print_notices();
839     }
840 
841     /**
842      * @deprecated 2.1.0
843      */
844     public function set_messages() {
845         _deprecated_function( 'Woocommerce->set_messages', '2.1' );
846     }
847 }
848 
849 endif;
850 
851 /**
852  * Returns the main instance of WC to prevent the need to use globals.
853  *
854  * @since  2.1
855  * @return WooCommerce
856  */
857 function WC() {
858     return WooCommerce::instance();
859 }
860 
861 // Global for backwards compatibility.
862 $GLOBALS['woocommerce'] = WC();
863 
WooCommerce API documentation generated by ApiGen 2.8.0