WC_Darwin_Pricing_Integration

WooCommerce Darwin Pricing Integration main class.

Defined (1)

The class is defined in the following location(s).

/woocommerce-darwin-pricing-integration.php  
  1. class WC_Darwin_Pricing_Integration { 
  2.  
  3. /** 
  4. * Plugin version. 
  5. * @var string 
  6. */ 
  7. const VERSION = '1.2.0'; 
  8.  
  9. /** 
  10. * Instance of this class. 
  11. * @var object 
  12. */ 
  13. protected static $instance = null; 
  14.  
  15. /** 
  16. * Initialize the plugin. 
  17. */ 
  18. private function __construct() { 
  19. // Load plugin text domain 
  20. add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 
  21.  
  22. // Checks whith WooCommerce is installed. 
  23. if ( class_exists( 'WC_Integration' ) && defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1-beta-1', '>=' ) ) { 
  24. include_once 'includes/class-wc-darwin-pricing.php'; 
  25.  
  26. // Register the integration. 
  27. add_filter( 'woocommerce_integrations', array( $this, 'add_integration' ) ); 
  28. } else { 
  29. add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); 
  30.  
  31. /** 
  32. * Return an instance of this class. 
  33. * @return object A single instance of this class. 
  34. */ 
  35. public static function get_instance() { 
  36. // If the single instance hasn't been set, set it now. 
  37. if ( null == self::$instance ) { 
  38. self::$instance = new self; 
  39.  
  40. return self::$instance; 
  41.  
  42. /** 
  43. * Load the plugin text domain for translation. 
  44. * @return void 
  45. */ 
  46. public function load_plugin_textdomain() { 
  47. $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-darwin-pricing-integration' ); 
  48.  
  49. load_textdomain( 'woocommerce-darwin-pricing-integration', trailingslashit( WP_LANG_DIR ) . 'woocommerce-darwin-pricing-integration/woocommerce-darwin-pricing-integration-' . $locale . '.mo' ); 
  50. load_plugin_textdomain( 'woocommerce-darwin-pricing-integration', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
  51.  
  52. /** 
  53. * WooCommerce fallback notice. 
  54. * @return string 
  55. */ 
  56. public function woocommerce_missing_notice() { 
  57. echo '<div class="error"><p>' . sprintf( __( 'The WooCommerce Darwin Pricing Integration depends on the last version of %s to work!', 'woocommerce-darwin-pricing-integration' ), '<a href="http://www.woothemes.com/woocommerce/" target="_blank">' . __( 'WooCommerce', 'woocommerce-darwin-pricing-integration' ) . '</a>' ) . '</p></div>'; 
  58.  
  59. /** 
  60. * Add a new integration to WooCommerce. 
  61. * @param array $integrations WooCommerce integrations. 
  62. * @return array Darwin Pricing integration. 
  63. */ 
  64. public function add_integration( $integrations ) { 
  65. $integrations[] = 'WC_Darwin_Pricing'; 
  66.  
  67. return $integrations;