PluginProbe
CSS & JavaScript Toolbox / 8.0
CSS & JavaScript Toolbox v8.0
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
← All changes | framework/extensions/extensions.class.php +73 -153 11.68.0 View file →
@@ -1,7 +1,7 @@
1 1 <?php
2 2 /**
3 -*
3 +*
4 4 */
5 5
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
@@ -6,136 +6,128 @@
6 6 // Disallow direct access.
7 7 defined('ABSPATH') or die("Access denied");
8 8
9 9 /**
10 -*
10 +*
11 11 */
12 12 class CJTExtensions extends CJTHookableClass {
13 -
13 +
14 14 /**
15 - *
15 + *
16 16 */
17 17 const CACHE_OPTION_NAME = 'cjt_extensions';
18 -
18 +
19 19 /**
20 - *
20 + *
21 21 */
22 22 const LOAD_METHOD = 'getInvolved';
23 -
23 +
24 24 /**
25 - *
25 + *
26 26 */
27 - const PREFIXS = 'cjte-,css-javascript-toolbox-';
28 -
27 + const PREFIX = 'cjte-';
28 +
29 29 /**
30 30 * put your comment there...
31 - *
31 + *
32 32 * @var mixed
33 33 */
34 34 protected $defDocs;
35 -
35 +
36 36 /**
37 37 * put your comment there...
38 - *
38 + *
39 39 * @var mixed
40 40 */
41 41 protected $extensions;
42 -
42 +
43 43 /**
44 44 * put your comment there...
45 - *
45 + *
46 46 * @var mixed
47 47 */
48 48 protected $file2Classmap;
49 -
49 +
50 50 /**
51 51 * put your comment there...
52 - *
52 + *
53 53 * @var mixed
54 54 */
55 55 protected $incompatibilies;
56 -
57 - /**
58 - * put your comment there...
59 - *
60 - * @var mixed
61 - */
62 - protected $incompatibleAddons = array();
63 -
64 -
56 +
65 57 /**
66 58 * put your comment there...
67 - *
59 + *
68 60 * @var mixed
69 61 */
70 62 protected $loadMethod;
71 -
63 +
72 64 /**
73 65 * put your comment there...
74 - *
66 + *
75 67 * @var mixed
76 68 */
77 69 protected $onautoload = array('parameters' => array('file', 'class'));
78 -
70 +
79 71 /**
80 72 * put your comment there...
81 - *
73 + *
82 74 * @var mixed
83 75 */
84 76 protected $onbindevent = array('parameters' => array('event', 'callback'));
85 -
77 +
86 78 /**
87 79 * put your comment there...
88 - *
80 + *
89 81 * @var mixed
90 82 */
91 83 protected $ondetectextension = array('parameters' => array('extension'));
92 -
84 +
93 85 /**
94 86 * put your comment there...
95 - *
87 + *
96 88 * @var mixed
97 89 */
98 90 protected $ongetactiveplugins = array('parameters' => array('plugins'));
99 -
91 +
100 92 /**
101 93 * put your comment there...
102 - *
94 + *
103 95 * @var mixed
104 96 */
105 97 protected $onload = array('parameters' => array('params'));
106 -
98 +
107 99 /**
108 100 * put your comment there...
109 - *
101 + *
110 102 * @var mixed
111 103 */
112 104 protected $onloadcallback = array('parameters' => array('callback'));
113 -
105 +
114 106 /**
115 107 * put your comment there...
116 - *
108 + *
117 109 * @var mixed
118 110 */
119 111 protected $onloaddefinition = array('parameters' => array('definition'));
120 -
112 +
121 113 /***
122 114 * put your comment there...
123 - *
115 + *
124 116 * @var mixed
125 117 */
126 118 protected $ontregisterautoload = array('parameters' => array('callback'));
127 -
119 +
128 120 /**
129 121 * put your comment there...
130 - *
122 + *
131 123 * @var mixed
132 124 */
133 125 protected $onreloadcacheparameters = array('parameters' => array('params'));
134 -
126 +
135 127 /**
136 128 * put your comment there...
137 - *
129 + *
138 130 * @var mixed
139 131 */
140 132 protected $onloaded = array(
141 133 'hookType' => CJTWordpressEvents::HOOK_ACTION,
@@ -140,23 +132,22 @@
140 132 protected $onloaded = array(
141 133 'hookType' => CJTWordpressEvents::HOOK_ACTION,
142 134 'parameters' => array('class', 'extension', 'definition', 'result')
143 135 );
144 -
136 +
145 137 /**
146 138 * put your comment there...
147 - *
139 + *
148 140 * @var mixed
149 141 */
150 142 protected $prefix;
151 -
143 +
152 144 /**
153 145 * put your comment there...
154 - *
146 + *
155 147 * @param mixed $className
156 148 */
157 - public function _autoload($className) {
158 -
149 + public function __autoload($className) {
159 150 // Load only classed defined on the list!
160 151 if (isset($this->extensions[$className])) {
161 152 $classFile = $this->onautoload($this->extensions[$className]['runtime']['classFile'], $className);
162 153 // Import class file!
@@ -162,61 +153,35 @@
162 153 // Import class file!
163 154 require_once $classFile;
164 155 }
165 156 }
166 -
157 +
167 158 /**
168 159 * put your comment there...
169 - *
160 + *
170 161 * @param mixed $prefix
171 162 * @param mixed $loadMethod
172 163 * @return CJTExtensions
173 164 */
174 - public function __construct($prefix = self::PREFIXS, $loadMethod = self::LOAD_METHOD) {
165 + public function __construct($prefix = self::PREFIX, $loadMethod = self::LOAD_METHOD) {
175 166 // Hookable!
176 167 parent::__construct();
177 -
178 - // Initialize incomapiblt addons meta data
179 - $this->incompatibleAddons = array(
180 -
181 - 'css-javascript-toolbox-plus' => array(
182 - '9.4',
183 - '<',
184 - 'Aborted',
185 -
186 - function() {
187 -
188 - ob_start();
189 -
190 - require CJTOOLBOX_PATH . DIRECTORY_SEPARATOR . 'includes' .
191 - DIRECTORY_SEPARATOR . 'html' . DIRECTORY_SEPARATOR .
192 - 'incompatible_cjtplus_version.html.php';
193 -
194 - $content = ob_get_clean();
195 -
196 - return $content;
197 - }
198 -
199 - ),
200 -
201 - );
202 -
203 168 // Initializing!
204 - $this->prefix = explode( ',', $prefix );
169 + $this->prefix = $prefix;
205 170 $this->loadMethod = $loadMethod;
206 171 }
207 -
172 +
208 173 /**
209 174 * put your comment there...
210 - *
175 + *
211 176 */
212 177 public function __destruct() {
213 - spl_autoload_unregister(array($this, '_autoload'));
178 + spl_autoload_unregister(array($this, '__autoload'));
214 179 }
215 -
180 +
216 181 /**
217 182 * put your comment there...
218 - *
183 + *
219 184 * @param mixed $reload
220 185 * @return CJTExtensions
221 186 */
222 187 public function & getExtensions($reload = false) {
@@ -225,22 +190,15 @@
225 190 if ($reload || (!($extensions = $this->extensions) && !($extensions = get_option(self::CACHE_OPTION_NAME, array())))) {
226 191 //Resting!
227 192 $this->file2Classmap = array();
228 193 $extensions = array();
229 - # Get all active plugins
230 - $activePlugins = wp_get_active_and_valid_plugins();
231 - # Get Network plugins
232 - if (is_multisite()) {
233 - $activePlugins = array_merge(wp_get_active_network_plugins(), $activePlugins);
234 - }
235 194 // filter all installed Plugins to fetch all out Extensions!
236 - $activePlugins = $this->ongetactiveplugins($activePlugins);
195 + $activePlugins = $this->ongetactiveplugins(wp_get_active_and_valid_plugins());
237 196 foreach ($activePlugins as $file) {
238 197 $pluginDir = dirname($file);
239 198 $pluginName = basename($pluginDir);
240 199 // Any plugin with our prefix is a CJT extension!
241 - if ( ( strpos( $pluginName, $this->prefix[0] ) === 0 ) ||
242 - ( strpos( $pluginName, $this->prefix[1] ) === 0 ) ) {
200 + if (strpos($pluginName, $this->prefix) === 0) {
243 201 // CJT Extsnsion must has the definition XML file!
244 202 // First try for Edition-Specific file
245 203 // if not exists try the generic one.
246 204 $xmlFile = "{$pluginDir}/{$pluginName}.xml";
@@ -275,27 +233,24 @@
275 233 $this->extensions = $this->onload($extensions);
276 234 // Chaining
277 235 return $this->extensions;
278 236 }
279 -
237 +
280 238 /**
281 239 * put your comment there...
282 - *
240 + *
283 241 */
284 242 public function load() {
285 -
286 243 // Initialize.
287 244 $frameworkVersion = new CJT_Framework_Version_Version(CJTPlugin::FW_Version);
288 -
289 245 // Auto load CJT extensions files when requested.
290 - spl_autoload_register($this->ontregisterautoload(array($this, '_autoload')));
291 -
246 + spl_autoload_register($this->ontregisterautoload(array($this, '__autoload')));
292 247 // Load all CJT extensions!
293 248 foreach ($this->getExtensions() as $class => $extension) {
294 249 // Filters!
295 250 extract($this->onload($extension, compact('class', 'extension')));
296 251 // Build Extension plugin path
297 - $pluginPath = WP_PLUGIN_DIR . "/{$extension['name']}";
252 + $pluginPath = ABSPATH . PLUGINDIR . "/{$extension['name']}";
298 253 // Set runtime variables.
299 254 $this->extensions[$class]['runtime']['classFile'] = "{$pluginPath}/{$extension['name']}.class.php";
300 255 // Load definition.
301 256 $definitionXML = $extension['defDoc'];
@@ -316,33 +271,8 @@
316 271 // Callback filter
317 272 $callback = $this->onloadcallback($callback);
318 273 // If auto load is speicifd then import class file and bind events.
319 274 if ($extension['definition']['primary']['loadMethod'] == 'auto') {
320 -
321 - // Don't load Incompatible extensions/addons
322 - if (isset($this->incompatibleAddons[$extension['name']])) {
323 -
324 - require_once ABSPATH . DIRECTORY_SEPARATOR . 'wp-admin' .
325 - DIRECTORY_SEPARATOR . 'includes' .
326 - DIRECTORY_SEPARATOR . 'plugin.php';
327 -
328 - $incomapatibleAddon = $this->incompatibleAddons[$extension['name']];
329 - $addonVersion = get_plugin_data($extension['pluginFile'], false, false)['Version'];
330 - $currentVersion = get_plugin_data( CJTOOLBOX_PLUGIN_FILE )['Version'];
331 -
332 - // Only show notice if addon version is less than 11.
333 - if ( $addonVersion < 11) {
334 -
335 - $extension['incompatibleMessage']['flag'] = $incomapatibleAddon[2];
336 - $extension['incompatibleMessage']['msg'] = $incomapatibleAddon[3];
337 -
338 - $this->incompatibilies[$pluginPath] = $extension;
339 -
340 - continue;
341 - }
342 -
343 - }
344 -
345 275 // If frameworkVersion is not provided assume its 0 (Older version)
346 276 // before frameworkversion chech even supported.
347 277 // otherwise compare it with current frameworkversion
348 278 // If the version MAJOR is different current
@@ -371,9 +301,9 @@
371 301 CJTPlugin::on((string) $event->attributes()->type, $callback);
372 302 }
373 303 }
374 304 }
375 - else { // If manual load specified just
305 + else { // If manual load specified just
376 306 if (class_exists($class)) { // Make sure the class is loaded!
377 307 $this->onloaded($class, $extension, $definitionXML, call_user_func($callback));
378 308 }
379 309 }
@@ -382,12 +312,12 @@
382 312 // Hook for processing incomaptible extensions.
383 313 add_action('admin_notices', array(& $this, 'processIncompatibles'));
384 314 }
385 315 }
386 -
316 +
387 317 /**
388 318 * put your comment there...
389 - *
319 + *
390 320 * @param mixed $pluginName
391 321 */
392 322 public function & getDefDoc($pluginName) {
393 323 # Find if cached or create it
@@ -396,9 +326,9 @@
396 326 $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $pluginName . DIRECTORY_SEPARATOR . "{$pluginName}.xml";
397 327 // Extension might removed while its license key still in the database
398 328 // Make sure the extension still exists
399 329 if (file_exists($pluginXMLFile)) {
400 - $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
330 + $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
401 331 }
402 332 else {
403 333 # Return null when extension is absent!
404 334 $this->defDocs[$pluginName] = null;
@@ -408,22 +338,20 @@
408 338 }
409 339
410 340 /**
411 341 * put your comment there...
412 - *
342 + *
413 343 */
414 344 public function & getFiles2ClassesMap() {
415 - return $this->file2Classmap;
345 + return $this->file2Classmap;
416 346 }
417 -
347 +
418 348 /**
419 349 * put your comment there...
420 - *
350 + *
421 351 * @TODO: REMOVE HTML-MARKUP. CJT PLUGIN NEVER WRITE MARKUP IMIXED WITH HTML. ITS VERY BAD PROGRAMMING PRACTICE. THIS WILL BE REMOVED NEXT TIME AS WE IN RUSH!!!
422 352 */
423 353 public function processIncompatibles() {
424 - global $current_screen;
425 -
426 354 // Proces only if in CJT page.
427 355 if (!preg_match('/\/plugins\.php|page\=cjtoolbox/', $_SERVER['REQUEST_URI'])) {
428 356 return;
429 357 }
@@ -430,9 +358,9 @@
430 358 // INitialize.
431 359 $message = cssJSToolbox::getText('CJT detects incompatible installed extensions, listed below with status message for every extension:');
432 360 $list = '';
433 361 // For every compatible extension add
434 - // an list item with details
362 + // an list item with details
435 363 // if there is an update available or provide
436 364 // a direct link to CJT website if no upgrade is available.
437 365 // Upgrade wont be available in case no license key is activated!
438 366 foreach ($this->incompatibilies as $class => $extension) {
@@ -438,24 +366,16 @@
438 366 foreach ($this->incompatibilies as $class => $extension) {
439 367 // Show details.
440 368 $pluginInfo = get_plugin_data($extension['pluginFile']);
441 369 // List item Markup
442 - $list .= is_callable($extension['incompatibleMessage']['msg']) ?
443 - "<li style='list-style-type:none'>{$extension['incompatibleMessage']['msg']()}</li>" :
444 - "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
370 + $list .= "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
445 371 }
446 -
447 - $noticeClasses = 'cjt-incomaptible-extensions-notice notice notice-error';
448 -
449 - if ( $current_screen->id !== 'toplevel_page_cjtoolbox' ) {
450 - $noticeClasses .= ' is-dismissible';
451 - }
452 -
453 372 // Output full message.
454 373 // TODO: BAD PRACTICE1!!!!! NEVER MIX HTML WITH PHP, JUST TEMPORARY1!!!
455 - echo "<div class='$noticeClasses' style='font-size:14px;font-weight:bold;margin-top: 20px;'>
456 - <ul style='list-style-type: circle;font-size: 12px;'>{$list}</ul>
457 - </div>";
374 + echo "<div class='cjt-incomaptible-extensions-notice updated' style='font-size:14px;font-weight:bold;padding-top:11px'>
375 + <span>{$message}</span>
376 + <ul style='list-style-type: circle;padding-left: 27px;font-size: 12px;'>{$list}</ul>
377 + </div>";
458 378 }
459 379
460 380 } // End class.
461 381