WooCartPopUpFestiPlugin

The Woocart Popup Lite for WooCommerce WooCartPopUpFestiPlugin class.

Defined (1)

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

/plugin.php  
  1. class WooCartPopUpFestiPlugin extends FestiPlugin 
  2. protected $_version = '1.1'; 
  3. protected $_languageDomain = 'festi_cart_popup_'; 
  4. protected $_optionsPrefix = 'festi_cart_popup_';  
  5.  
  6. protected function onInit() 
  7. $this->addActionListener('plugins_loaded', 'onLanguagesInitAction'); 
  8.  
  9. if ($this->_isWoocommercePluginNotActiveWhenFestiCartPluginActive()) { 
  10. $this->addActionListener( 
  11. 'admin_notices',  
  12. 'onDisplayInfoAboutDisabledWoocommerceAction'  
  13. ); 
  14.  
  15. return false; 
  16.  
  17. parent::onInit(); 
  18. } // end onInit 
  19.  
  20. private function _isWoocommercePluginNotActiveWhenFestiCartPluginActive() 
  21. return $this->_isFestiCartPluginActive() 
  22. && !$this->_isWoocommercePluginActive(); 
  23. } // end _isWoocommercePluginNotActiveWhenFestiCartPluginActive 
  24.  
  25. public function onInstall() 
  26. if (!$this->_isWoocommercePluginActive()) { 
  27. $message = 'WooCommerce not active or not installed.'; 
  28. $this->displayError($message); 
  29. exit(); 
  30. }  
  31.  
  32. $plugin = $this->onBackendInit(); 
  33.  
  34. $plugin->onInstall(); 
  35. } // end onInstall 
  36.  
  37. public function onUninstall() 
  38. $plugin = $this->onBackendInit(); 
  39.  
  40. $plugin->onUninstall(); 
  41. } // end onUnistall 
  42.  
  43. public function onBackendInit() 
  44. $path = $this->_pluginPath.'common/WooCartPopUpBackendFestiPlugin.php'; 
  45. require_once $path; 
  46. $backend = new WooCartPopUpBackendFestiPlugin(__FILE__); 
  47. return $backend; 
  48. } // end onBackendInit 
  49.  
  50. protected function onFrontendInit() 
  51. $path = $this->_pluginPath.'common/WooCartPopUpFrontendFestiPlugin.php'; 
  52. require_once $path; 
  53. $frontend = new WooCartPopUpFrontendFestiPlugin(__FILE__); 
  54. return $frontend; 
  55. } // end onFrontendIn 
  56.  
  57.  
  58. public function onLanguagesInitAction() 
  59. load_plugin_textdomain( 
  60. $this->_languageDomain,  
  61. false,  
  62. $this->_pluginLanguagesPath 
  63. ); 
  64. } // end onLanguagesInitAction 
  65.  
  66. private function _isFestiCartPluginActive() 
  67. {  
  68. return $this->isPluginActive('woocommerce-woocartpro/plugin.php');  
  69. } // end _isFestiCartPluginActive 
  70.  
  71. private function _isWoocommercePluginActive() 
  72. {  
  73. return $this->isPluginActive('woocommerce/woocommerce.php'); 
  74. } // end _isWoocommercePluginActive 
  75.  
  76. public function &getWoocommerceInstance() 
  77. return $GLOBALS['woocommerce']; 
  78. } // end getWoocommerceInstance 
  79.  
  80. public function getPluginIconsPath($dirname = '') 
  81. return $this->getPluginImagesPath('icons/'.$dirname); 
  82. } // end getPluginIconsPath 
  83.  
  84. public function onDisplayInfoAboutDisabledWoocommerceAction() 
  85. {  
  86. $message = 'WooCommerce WooCart PopUp: '; 
  87. $message .= 'WooCommerce not active or not installed.'; 
  88. $this->displayError($message); 
  89. } //end onDisplayInfoAboutDisabledWoocommerceAction 
  90.  
  91. public function convertHexToRgb($hex) 
  92. $hex = str_replace("#", "", $hex); 
  93.  
  94. if (strlen($hex) == 3) { 
  95.  
  96. $r = hexdec(substr($hex, 0, 1).substr($hex, 0, 1)); 
  97.  
  98. $g = hexdec(substr($hex, 1, 1).substr($hex, 1, 1)); 
  99.  
  100. $b = hexdec(substr($hex, 2, 1).substr($hex, 2, 1)); 
  101. } else { 
  102. $r = hexdec(substr($hex, 0, 2)); 
  103.  
  104. $g = hexdec(substr($hex, 2, 2)); 
  105.  
  106. $b = hexdec(substr($hex, 4, 2)); 
  107.  
  108. $rgb = array($r, $g, $b); 
  109.  
  110. return $rgb; 
  111. } // end _convertHexToRgb