WC_Domination

WooCommerce Domination main class.

Defined (1)

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

/woocommerce-domination.php  
  1. class WC_Domination { 
  2.  
  3. /** 
  4. * Plugin version. 
  5. * @var string 
  6. */ 
  7. const VERSION = '1.1.4'; 
  8.  
  9. /** 
  10. * Instance of this class. 
  11. * @var object 
  12. */ 
  13. protected static $instance = null; 
  14.  
  15. /** 
  16. * Initialize the plugin public actions. 
  17. */ 
  18. private function __construct() { 
  19. // Load plugin text domain 
  20. add_action( 'init', array( $this, 'load_plugin_textdomain' ) ); 
  21.  
  22. // Checks with WooCommerce is installed. 
  23. if ( defined( 'WC_VERSION' ) && version_compare( WC_VERSION, '2.1', '>=' ) ) { 
  24. if ( current_user_can( 'manage_woocommerce' ) ) { 
  25. $this->includes(); 
  26.  
  27. if ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) { 
  28. $this->admin_includes(); 
  29.  
  30. add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 999 ); 
  31. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 999 ); 
  32. } else { 
  33. add_action( 'admin_notices', array( $this, 'woocommerce_missing_notice' ) ); 
  34.  
  35. /** 
  36. * Return an instance of this class. 
  37. * @return object A single instance of this class. 
  38. */ 
  39. public static function get_instance() { 
  40. // If the single instance hasn't been set, set it now. 
  41. if ( null == self::$instance ) { 
  42. self::$instance = new self; 
  43.  
  44. return self::$instance; 
  45.  
  46. /** 
  47. * Load the plugin text domain for translation. 
  48. */ 
  49. public function load_plugin_textdomain() { 
  50. $locale = apply_filters( 'plugin_locale', get_locale(), 'woocommerce-domination' ); 
  51.  
  52. load_textdomain( 'woocommerce-domination', trailingslashit( WP_LANG_DIR ) . 'woocommerce-domination/woocommerce-domination-' . $locale . '.mo' ); 
  53. load_plugin_textdomain( 'woocommerce-domination', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' ); 
  54.  
  55. /** 
  56. * Includes. 
  57. */ 
  58. private function includes() { 
  59. include_once 'includes/class-wc-domination-admin-bar.php'; 
  60.  
  61. /** 
  62. * Admin includes. 
  63. */ 
  64. private function admin_includes() { 
  65. include_once 'includes/admin/class-wc-domination-admin.php'; 
  66.  
  67. /** 
  68. * Public scripts. 
  69. */ 
  70. public function enqueue_scripts() { 
  71. wp_enqueue_style( 'woocommerce-domination-menus', plugins_url( 'assets/css/menus.css', __FILE__ ), array(), self::VERSION ); 
  72.  
  73. /** 
  74. * WooCommerce fallback notice. 
  75. * @return string 
  76. */ 
  77. public function woocommerce_missing_notice() { 
  78. echo '<div class="error"><p><strong>' . __( 'WooCommerce Domination is inactive.', 'woocommerce-domination' ) . '</strong> ' . sprintf( __( 'You must install and active the %s 2.1 or later for the WooCommerce Domination work.', 'woocommerce-domination' ), '<a href="http://wordpress.org/extend/plugins/woocommerce/">' . __( 'WooCommerce', 'woocommerce-domination' ) . '</a>' ) . '</p></div>';