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