PluginProbe ʕ •ᴥ•ʔ
Tracking Code Manager / 2.8.0
Tracking Code Manager v2.8.0
2.8.0 2.7.0 trunk 1.11.8 1.11.9 1.12.0 1.12.1 1.12.2 1.12.3 1.4 1.5 2.0.0 2.0.1 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0
tracking-code-manager / includes / classes / utils / Plugin.php
tracking-code-manager / includes / classes / utils Last commit date
Cron.php 4 years ago Ecommerce.php 4 years ago Language.php 4 years ago Logger.php 1 month ago MobileDetect.php 1 month ago Options.php 2 weeks ago Plugin.php 1 month ago Properties.php 4 years ago Tracking.php 1 month ago Utils.php 1 month ago
Plugin.php
243 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 // Delegates to getPlugins() with $onlyActive = true. This used to call
215 // itself, which recursed until the process ran out of stack; it had no
216 // callers, so the fault stayed latent.
217 return $this->getPlugins( $ids, true );
218 }
219 function getPlugins( $ids, $onlyActive = true ) {
220 $array = array();
221 if ( ! is_array( $ids ) ) {
222 $ids = array( intval( $ids ) );
223 }
224
225 foreach ( $ids as $id ) {
226 if ( ! $onlyActive || $this->isActive( $id ) ) {
227 $name = $this->getName( $id );
228 $version = $this->getVersion( $id );
229
230 $v = array(
231 'id' => $id,
232 'name' => $name,
233 'version' => $version,
234 'active' => $this->isActive( $id ),
235 );
236 $array[ $name ] = $v;
237 }
238 }
239 ksort( $array );
240 return $array;
241 }
242 }
243