Cron.php
8 years ago
Ecommerce.php
7 years ago
Language.php
10 years ago
Logger.php
8 years ago
MobileDetect.php
8 years ago
Options.php
8 years ago
Plugin.php
10 years ago
Properties.php
10 years ago
Tracking.php
8 years ago
Utils.php
8 years ago
Plugin.php
238 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | define('TCMP_PLUGINS_NO_PLUGINS', 10000); |
| 5 | define('TCMP_PLUGINS_WOOCOMMERCE', 10001); |
| 6 | define('TCMP_PLUGINS_EDD', 10002); |
| 7 | define('TCMP_PLUGINS_WP_ECOMMERCE', 10003); |
| 8 | define('TCMP_PLUGINS_WP_SPSC', 10004); |
| 9 | define('TCMP_PLUGINS_S2MEMBER', 10005); |
| 10 | define('TCMP_PLUGINS_MEMBERS', 10006); |
| 11 | define('TCMP_PLUGINS_CART66', 10007); |
| 12 | define('TCMP_PLUGINS_ESHOP', 10008); |
| 13 | define('TCMP_PLUGINS_JIGOSHOP', 10009); |
| 14 | define('TCMP_PLUGINS_MARKETPRESS', 10010); |
| 15 | define('TCMP_PLUGINS_SHOPP', 10011); |
| 16 | define('TCMP_PLUGINS_SIMPLE_WP_ECOMMERCE', 10012); |
| 17 | define('TCMP_PLUGINS_CF7', 10013); |
| 18 | define('TCMP_PLUGINS_GRAVITY', 10014); |
| 19 | define('TCMP_PLUGINS_TRACKING_CODE_MANAGER', 10015); |
| 20 | define('TCMP_PLUGINS_TRACKING_CODE_MANAGER_PRO', 10016); |
| 21 | |
| 22 | class TCMP_Plugin { |
| 23 | function __construct() { |
| 24 | } |
| 25 | |
| 26 | function getName($pluginId) { |
| 27 | $result=''; |
| 28 | switch ($pluginId) { |
| 29 | case TCMP_PLUGINS_WOOCOMMERCE: |
| 30 | $result='WooCommerce'; |
| 31 | break; |
| 32 | case TCMP_PLUGINS_EDD: |
| 33 | $result='Easy Digital Download'; |
| 34 | break; |
| 35 | case TCMP_PLUGINS_WP_ECOMMERCE: |
| 36 | $result='WP eCommerce'; |
| 37 | break; |
| 38 | case TCMP_PLUGINS_WP_SPSC: |
| 39 | $result='WordPress Simple Paypal Shopping Cart'; |
| 40 | break; |
| 41 | case TCMP_PLUGINS_S2MEMBER: |
| 42 | $result='s2member'; |
| 43 | break; |
| 44 | case TCMP_PLUGINS_MEMBERS: |
| 45 | $result='Members'; |
| 46 | break; |
| 47 | case TCMP_PLUGINS_CART66: |
| 48 | $result='Cart66 Lite :: WordPress Ecommerce'; |
| 49 | break; |
| 50 | case TCMP_PLUGINS_ESHOP: |
| 51 | $result='eShop'; |
| 52 | break; |
| 53 | case TCMP_PLUGINS_JIGOSHOP: |
| 54 | $result='Jigoshop'; |
| 55 | break; |
| 56 | case TCMP_PLUGINS_MARKETPRESS: |
| 57 | $result='MarketPress - WordPress eCommerce'; |
| 58 | break; |
| 59 | case TCMP_PLUGINS_SHOPP: |
| 60 | $result='Shopp'; |
| 61 | break; |
| 62 | case TCMP_PLUGINS_SIMPLE_WP_ECOMMERCE: |
| 63 | $result='iThemes Exchange: Simple WP Ecommerce'; |
| 64 | break; |
| 65 | case TCMP_PLUGINS_CF7: |
| 66 | $result='Contact Form 7'; |
| 67 | break; |
| 68 | case TCMP_PLUGINS_GRAVITY: |
| 69 | $result='Gravity Form'; |
| 70 | break; |
| 71 | case TCMP_PLUGINS_TRACKING_CODE_MANAGER: |
| 72 | $result='Tracking Code Manager'; |
| 73 | break; |
| 74 | case TCMP_PLUGINS_TRACKING_CODE_MANAGER_PRO: |
| 75 | $result='Tracking Code Manager PRO'; |
| 76 | break; |
| 77 | } |
| 78 | return $result; |
| 79 | } |
| 80 | function isActive($pluginId) { |
| 81 | global $tcmp; |
| 82 | |
| 83 | $php=''; |
| 84 | $class=''; |
| 85 | $constant=''; |
| 86 | switch ($pluginId) { |
| 87 | case TCMP_PLUGINS_WOOCOMMERCE: |
| 88 | $php='woocommerce/woocommerce.php'; |
| 89 | $class='WooCommerce'; |
| 90 | $constant='WOOCOMMERCE_VERSION'; |
| 91 | break; |
| 92 | case TCMP_PLUGINS_EDD: |
| 93 | $php='easy-digital-downloads/easy-digital-downloads.php'; |
| 94 | $class='Easy_Digital_Downloads'; |
| 95 | $constant='EDD_SL_VERSION'; |
| 96 | break; |
| 97 | case TCMP_PLUGINS_WP_ECOMMERCE: |
| 98 | $class='WP_eCommerce'; |
| 99 | $constant='WPSC_VERSION'; |
| 100 | break; |
| 101 | case TCMP_PLUGINS_WP_SPSC: |
| 102 | $constant='WP_CART_VERSION'; |
| 103 | break; |
| 104 | case TCMP_PLUGINS_S2MEMBER: |
| 105 | $constant='WS_PLUGIN__S2MEMBER_VERSION'; |
| 106 | break; |
| 107 | case TCMP_PLUGINS_MEMBERS: |
| 108 | $constant='MEMBERS_VERSION'; |
| 109 | break; |
| 110 | case TCMP_PLUGINS_CART66: |
| 111 | $class='Cart66'; |
| 112 | $constant='CART66_VERSION_NUMBER'; |
| 113 | break; |
| 114 | case TCMP_PLUGINS_ESHOP: |
| 115 | $constant='ESHOP_VERSION'; |
| 116 | break; |
| 117 | case TCMP_PLUGINS_JIGOSHOP: |
| 118 | $constant='JIGOSHOP_VERSION'; |
| 119 | break; |
| 120 | case TCMP_PLUGINS_MARKETPRESS: |
| 121 | $class='MarketPress'; |
| 122 | $constant='MP_LITE'; |
| 123 | break; |
| 124 | case TCMP_PLUGINS_SHOPP: |
| 125 | $constant='ESHOP_VERSION'; |
| 126 | break; |
| 127 | case TCMP_PLUGINS_SIMPLE_WP_ECOMMERCE: |
| 128 | $class='IT_Exchange'; |
| 129 | $constant=''; |
| 130 | break; |
| 131 | case TCMP_PLUGINS_CF7: |
| 132 | $constant='WPCF7_VERSION'; |
| 133 | break; |
| 134 | case TCMP_PLUGINS_GRAVITY: |
| 135 | $constant=''; |
| 136 | break; |
| 137 | case TCMP_PLUGINS_TRACKING_CODE_MANAGER: |
| 138 | $constant='TCMP_PLUGIN_VERSION'; |
| 139 | break; |
| 140 | case TCMP_PLUGINS_TRACKING_CODE_MANAGER_PRO: |
| 141 | $constant='TCMP_PLUGIN_VERSION'; |
| 142 | break; |
| 143 | } |
| 144 | $result=$this->isPluginActive($class, $constant, $php); |
| 145 | return $result; |
| 146 | } |
| 147 | |
| 148 | private function isPluginActive($class='', $constant='', $plugin='') { |
| 149 | $result=FALSE; |
| 150 | $result=($result || ($class!='' && class_exists($class))); |
| 151 | $result=($result || ($constant!='' && defined($constant))); |
| 152 | //require plugin.php |
| 153 | //$result=($result || ($plugin!='' && is_plugin_active($plugin))); |
| 154 | return $result; |
| 155 | } |
| 156 | |
| 157 | function getVersion($pluginId) { |
| 158 | $constant=''; |
| 159 | $version=''; |
| 160 | switch ($pluginId) { |
| 161 | case TCMP_PLUGINS_WOOCOMMERCE: |
| 162 | $constant='WOOCOMMERCE_VERSION'; |
| 163 | break; |
| 164 | case TCMP_PLUGINS_EDD: |
| 165 | $constant='EDD_SL_VERSION'; |
| 166 | break; |
| 167 | case TCMP_PLUGINS_WP_ECOMMERCE: |
| 168 | $constant='WPSC_VERSION'; |
| 169 | break; |
| 170 | case TCMP_PLUGINS_WP_SPSC: |
| 171 | $constant='WP_CART_VERSION'; |
| 172 | break; |
| 173 | case TCMP_PLUGINS_S2MEMBER: |
| 174 | $constant='WS_PLUGIN__S2MEMBER_VERSION'; |
| 175 | break; |
| 176 | case TCMP_PLUGINS_MEMBERS: |
| 177 | $constant='MEMBERS_VERSION'; |
| 178 | break; |
| 179 | case TCMP_PLUGINS_CART66: |
| 180 | $constant='CART66_VERSION_NUMBER'; |
| 181 | break; |
| 182 | case TCMP_PLUGINS_ESHOP: |
| 183 | $constant='ESHOP_VERSION'; |
| 184 | break; |
| 185 | case TCMP_PLUGINS_JIGOSHOP: |
| 186 | $constant='JIGOSHOP_VERSION'; |
| 187 | break; |
| 188 | case TCMP_PLUGINS_MARKETPRESS: |
| 189 | global $mp; |
| 190 | $version=$mp->version; |
| 191 | break; |
| 192 | case TCMP_PLUGINS_SHOPP: |
| 193 | $constant='ESHOP_VERSION'; |
| 194 | break; |
| 195 | case TCMP_PLUGINS_SIMPLE_WP_ECOMMERCE: |
| 196 | $version=$GLOBALS['it_exchange']['version']; |
| 197 | break; |
| 198 | case TCMP_PLUGINS_CF7: |
| 199 | $constant='WPCF7_VERSION'; |
| 200 | break; |
| 201 | case TCMP_PLUGINS_GRAVITY: |
| 202 | $constant=''; |
| 203 | break; |
| 204 | } |
| 205 | if($version=='' && $constant!='') { |
| 206 | $version=(defined($constant) ? constant($constant) : ''); |
| 207 | } |
| 208 | return $version; |
| 209 | } |
| 210 | |
| 211 | function getActivePlugins($ids) { |
| 212 | return $this->getActivePlugins($ids, TRUE); |
| 213 | } |
| 214 | function getPlugins($ids, $onlyActive=TRUE) { |
| 215 | $array=array(); |
| 216 | if(!is_array($ids)) { |
| 217 | $ids=array(intval($ids)); |
| 218 | } |
| 219 | |
| 220 | foreach($ids as $id) { |
| 221 | if(!$onlyActive || $this->isActive($id)) { |
| 222 | $name=$this->getName($id); |
| 223 | $version=$this->getVersion($id); |
| 224 | |
| 225 | $v=array( |
| 226 | 'id'=>$id |
| 227 | , 'name'=>$name |
| 228 | , 'version'=>$version |
| 229 | , 'active'=>$this->isActive($id) |
| 230 | ); |
| 231 | $array[$name]=$v; |
| 232 | } |
| 233 | } |
| 234 | ksort($array); |
| 235 | return $array; |
| 236 | } |
| 237 | } |
| 238 |