PluginProbe
Tracking Code Manager / 1.11.8
Tracking Code Manager v1.11.8
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 All 29 releases
← All changes | includes/classes/utils/Plugin.php +237 -242 trunk1.11.8 View file →
@@ -1,242 +1,237 @@
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 -}
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 +}