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