PluginProbe
CSS & JavaScript Toolbox / 8.0.3
CSS & JavaScript Toolbox v8.0.3
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 +71 -146 118.0.3 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) {
@@ -237,10 +202,9 @@
237 202 foreach ($activePlugins as $file) {
238 203 $pluginDir = dirname($file);
239 204 $pluginName = basename($pluginDir);
240 205 // Any plugin with our prefix is a CJT extension!
241 - if ( ( strpos( $pluginName, $this->prefix[0] ) === 0 ) ||
242 - ( strpos( $pluginName, $this->prefix[1] ) === 0 ) ) {
206 + if (strpos($pluginName, $this->prefix) === 0) {
243 207 // CJT Extsnsion must has the definition XML file!
244 208 // First try for Edition-Specific file
245 209 // if not exists try the generic one.
246 210 $xmlFile = "{$pluginDir}/{$pluginName}.xml";
@@ -275,21 +239,18 @@
275 239 $this->extensions = $this->onload($extensions);
276 240 // Chaining
277 241 return $this->extensions;
278 242 }
279 -
243 +
280 244 /**
281 245 * put your comment there...
282 - *
246 + *
283 247 */
284 248 public function load() {
285 -
286 249 // Initialize.
287 250 $frameworkVersion = new CJT_Framework_Version_Version(CJTPlugin::FW_Version);
288 -
289 251 // Auto load CJT extensions files when requested.
290 - spl_autoload_register($this->ontregisterautoload(array($this, '_autoload')));
291 -
252 + spl_autoload_register($this->ontregisterautoload(array($this, '__autoload')));
292 253 // Load all CJT extensions!
293 254 foreach ($this->getExtensions() as $class => $extension) {
294 255 // Filters!
295 256 extract($this->onload($extension, compact('class', 'extension')));
@@ -316,34 +277,8 @@
316 277 // Callback filter
317 278 $callback = $this->onloadcallback($callback);
318 279 // If auto load is speicifd then import class file and bind events.
319 280 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 - if (version_compare($addonVersion,
333 - $currentVersion,
334 - $incomapatibleAddon[1])) {
335 -
336 - $extension['incompatibleMessage']['flag'] = $incomapatibleAddon[2];
337 - $extension['incompatibleMessage']['msg'] = $incomapatibleAddon[3];
338 -
339 - $this->incompatibilies[$pluginPath] = $extension;
340 -
341 - continue;
342 - }
343 -
344 - }
345 -
346 281 // If frameworkVersion is not provided assume its 0 (Older version)
347 282 // before frameworkversion chech even supported.
348 283 // otherwise compare it with current frameworkversion
349 284 // If the version MAJOR is different current
@@ -372,9 +307,9 @@
372 307 CJTPlugin::on((string) $event->attributes()->type, $callback);
373 308 }
374 309 }
375 310 }
376 - else { // If manual load specified just
311 + else { // If manual load specified just
377 312 if (class_exists($class)) { // Make sure the class is loaded!
378 313 $this->onloaded($class, $extension, $definitionXML, call_user_func($callback));
379 314 }
380 315 }
@@ -383,12 +318,12 @@
383 318 // Hook for processing incomaptible extensions.
384 319 add_action('admin_notices', array(& $this, 'processIncompatibles'));
385 320 }
386 321 }
387 -
322 +
388 323 /**
389 324 * put your comment there...
390 - *
325 + *
391 326 * @param mixed $pluginName
392 327 */
393 328 public function & getDefDoc($pluginName) {
394 329 # Find if cached or create it
@@ -397,9 +332,9 @@
397 332 $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $pluginName . DIRECTORY_SEPARATOR . "{$pluginName}.xml";
398 333 // Extension might removed while its license key still in the database
399 334 // Make sure the extension still exists
400 335 if (file_exists($pluginXMLFile)) {
401 - $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
336 + $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
402 337 }
403 338 else {
404 339 # Return null when extension is absent!
405 340 $this->defDocs[$pluginName] = null;
@@ -409,22 +344,20 @@
409 344 }
410 345
411 346 /**
412 347 * put your comment there...
413 - *
348 + *
414 349 */
415 350 public function & getFiles2ClassesMap() {
416 - return $this->file2Classmap;
351 + return $this->file2Classmap;
417 352 }
418 -
353 +
419 354 /**
420 355 * put your comment there...
421 - *
356 + *
422 357 * @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!!!
423 358 */
424 359 public function processIncompatibles() {
425 - global $current_screen;
426 -
427 360 // Proces only if in CJT page.
428 361 if (!preg_match('/\/plugins\.php|page\=cjtoolbox/', $_SERVER['REQUEST_URI'])) {
429 362 return;
430 363 }
@@ -431,9 +364,9 @@
431 364 // INitialize.
432 365 $message = cssJSToolbox::getText('CJT detects incompatible installed extensions, listed below with status message for every extension:');
433 366 $list = '';
434 367 // For every compatible extension add
435 - // an list item with details
368 + // an list item with details
436 369 // if there is an update available or provide
437 370 // a direct link to CJT website if no upgrade is available.
438 371 // Upgrade wont be available in case no license key is activated!
439 372 foreach ($this->incompatibilies as $class => $extension) {
@@ -439,24 +372,16 @@
439 372 foreach ($this->incompatibilies as $class => $extension) {
440 373 // Show details.
441 374 $pluginInfo = get_plugin_data($extension['pluginFile']);
442 375 // List item Markup
443 - $list .= is_callable($extension['incompatibleMessage']['msg']) ?
444 - "<li style='list-style-type:none'>{$extension['incompatibleMessage']['msg']()}</li>" :
445 - "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
376 + $list .= "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
446 377 }
447 -
448 - $noticeClasses = 'cjt-incomaptible-extensions-notice notice notice-error';
449 -
450 - if ( $current_screen->id !== 'toplevel_page_cjtoolbox' ) {
451 - $noticeClasses .= ' is-dismissible';
452 - }
453 -
454 378 // Output full message.
455 379 // TODO: BAD PRACTICE1!!!!! NEVER MIX HTML WITH PHP, JUST TEMPORARY1!!!
456 - echo "<div class='$noticeClasses' style='font-size:14px;font-weight:bold;margin-top: 20px;'>
457 - <ul style='list-style-type: circle;font-size: 12px;'>{$list}</ul>
458 - </div>";
380 + echo "<div class='cjt-incomaptible-extensions-notice updated' style='font-size:14px;font-weight:bold;padding-top:11px'>
381 + <span>{$message}</span>
382 + <ul style='list-style-type: circle;padding-left: 27px;font-size: 12px;'>{$list}</ul>
383 + </div>";
459 384 }
460 385
461 386 } // End class.
462 387