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 +72 -146 12.08.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,27 +239,24 @@
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')));
296 257 // Build Extension plugin path
297 - $pluginPath = WP_PLUGIN_DIR . "/{$extension['name']}";
258 + $pluginPath = ABSPATH . PLUGINDIR . "/{$extension['name']}";
298 259 // Set runtime variables.
299 260 $this->extensions[$class]['runtime']['classFile'] = "{$pluginPath}/{$extension['name']}.class.php";
300 261 // Load definition.
301 262 $definitionXML = $extension['defDoc'];
@@ -316,33 +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 - // 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 281 // If frameworkVersion is not provided assume its 0 (Older version)
346 282 // before frameworkversion chech even supported.
347 283 // otherwise compare it with current frameworkversion
348 284 // If the version MAJOR is different current
@@ -371,9 +307,9 @@
371 307 CJTPlugin::on((string) $event->attributes()->type, $callback);
372 308 }
373 309 }
374 310 }
375 - else { // If manual load specified just
311 + else { // If manual load specified just
376 312 if (class_exists($class)) { // Make sure the class is loaded!
377 313 $this->onloaded($class, $extension, $definitionXML, call_user_func($callback));
378 314 }
379 315 }
@@ -382,12 +318,12 @@
382 318 // Hook for processing incomaptible extensions.
383 319 add_action('admin_notices', array(& $this, 'processIncompatibles'));
384 320 }
385 321 }
386 -
322 +
387 323 /**
388 324 * put your comment there...
389 - *
325 + *
390 326 * @param mixed $pluginName
391 327 */
392 328 public function & getDefDoc($pluginName) {
393 329 # Find if cached or create it
@@ -396,9 +332,9 @@
396 332 $pluginXMLFile = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $pluginName . DIRECTORY_SEPARATOR . "{$pluginName}.xml";
397 333 // Extension might removed while its license key still in the database
398 334 // Make sure the extension still exists
399 335 if (file_exists($pluginXMLFile)) {
400 - $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
336 + $this->defDocs[$pluginName] = new SimpleXMLElement(file_get_contents($pluginXMLFile));
401 337 }
402 338 else {
403 339 # Return null when extension is absent!
404 340 $this->defDocs[$pluginName] = null;
@@ -408,22 +344,20 @@
408 344 }
409 345
410 346 /**
411 347 * put your comment there...
412 - *
348 + *
413 349 */
414 350 public function & getFiles2ClassesMap() {
415 - return $this->file2Classmap;
351 + return $this->file2Classmap;
416 352 }
417 -
353 +
418 354 /**
419 355 * put your comment there...
420 - *
356 + *
421 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!!!
422 358 */
423 359 public function processIncompatibles() {
424 - global $current_screen;
425 -
426 360 // Proces only if in CJT page.
427 361 if (!preg_match('/\/plugins\.php|page\=cjtoolbox/', $_SERVER['REQUEST_URI'])) {
428 362 return;
429 363 }
@@ -430,9 +364,9 @@
430 364 // INitialize.
431 365 $message = cssJSToolbox::getText('CJT detects incompatible installed extensions, listed below with status message for every extension:');
432 366 $list = '';
433 367 // For every compatible extension add
434 - // an list item with details
368 + // an list item with details
435 369 // if there is an update available or provide
436 370 // a direct link to CJT website if no upgrade is available.
437 371 // Upgrade wont be available in case no license key is activated!
438 372 foreach ($this->incompatibilies as $class => $extension) {
@@ -438,24 +372,16 @@
438 372 foreach ($this->incompatibilies as $class => $extension) {
439 373 // Show details.
440 374 $pluginInfo = get_plugin_data($extension['pluginFile']);
441 375 // 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";
376 + $list .= "<li><a target='_blank' href='{$pluginInfo['PluginURI']}'>{$pluginInfo['Name']}</a> (Status: {$extension['incompatibleMessage']['flag']}, Message: {$extension['incompatibleMessage']['msg']})</li>\n";
445 377 }
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 378 // Output full message.
454 379 // 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>";
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>";
458 384 }
459 385
460 386 } // End class.
461 387