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 | css-js-toolbox.php +121 -189 11.28.1 View file →
@@ -1,46 +1,45 @@
1 1 <?php
2 2 /*
3 3 Plugin Name: CSS & JavaScript Toolbox
4 -Plugin URI: https://css-javascript-toolbox.com/
5 -Description: Easily add CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them anywhere on your website.
6 -Version: 11.2
7 -Author: Wipeout Media
8 -Author URI: https://css-javascript-toolbox.com
4 +Plugin URI: http://css-javascript-toolbox.com/
5 +Description: CJT Plugin for WordPress to easily add custom CSS and JavaScript to individual pages
6 +Version: 8.1
7 +Author: Wipeout Media
8 +Author URI: http://css-javascript-toolbox.com
9 9 License:
10 10
11 11 The Software is package as a WordPress¨ plugin. The PHP code associated with the Software is licensed under the GPL version 2.0 license (as found at http://www.gnu.org/licenses/gpl-2.0.txt GNU/GPLv2 or "GPLv2"). You may redistribute, repackage, and modify the PHP code as you see fit and as consistent with GPLv2.
12 12
13 -The remaining portions of the Software ("Proprietary Portion"), which includes all images, cascading style sheets, and JavaScript are NOT licensed under GPLv2 and are considered proprietary to Licensor and are solely licensed under the remaining terms of this Agreement. The Proprietary Portion may not be redistributed, repackaged, or otherwise modified.
13 +The remaining portions of the Software ("Proprietary Portion"), which includes all images, cascading style sheets, and JavaScript are NOT licensed under GPLv2 and are considered proprietary to Licensor and are solely licensed under the remaining terms of this Agreement. The Proprietary Portion may not be redistributed, repackaged, or otherwise modified.
14 14 */
15 15
16 16 // Disallow direct access.
17 -defined( 'ABSPATH' ) or die( 'Access denied' );
17 +defined('ABSPATH') or die("Access denied");
18 18
19 -
20 19 /** * */
21 -define( 'CJTOOLBOX_PLUGIN_BASE', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
20 +define('CJTOOLBOX_PLUGIN_BASE', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
22 21
23 22 /** * */
24 -define( 'CJTOOLBOX_PLUGIN_FILE', __FILE__ );
23 +define('CJTOOLBOX_PLUGIN_FILE', __FILE__);
25 24
26 25 /** CJT Name */
27 -define( 'CJTOOLBOX_NAME', plugin_basename( dirname( __FILE__ ) ) );
26 +define('CJTOOLBOX_NAME', plugin_basename(dirname(__FILE__)));
28 27
29 28 /** CJT Text Domain used for localize texts */
30 -define( 'CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME );
29 +define('CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME);
31 30
32 31 /** */
33 -define( 'CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/' );
32 +define('CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/');
34 33
35 34 /** CJT Absoulte path */
36 -define( 'CJTOOLBOX_PATH', dirname( __FILE__ ) );
35 +define('CJTOOLBOX_PATH', dirname(__FILE__));
37 36
38 37 /** Dont use!! @deprecated */
39 -define( 'CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework' );
38 +define('CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework');
40 39
41 40 /** Access Points path */
42 -define( 'CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points' );
41 +define('CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points');
43 42
44 43 /** Frmaework path */
45 44 define('CJTOOLBOX_FRAMEWORK', CJTOOLBOX_INCLUDE_PATH); // Alias to include path!
46 45
@@ -55,338 +54,271 @@
55 54 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.interface.php';
56 55 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.class.php';
57 56
58 57 // Initialize events engine/system!
59 -CJTWordpressEvents::_init( array( 'hookType' => CJTWordpressEvents::HOOK_ACTION ) );
60 -CJTWordpressEvents::$paths[ 'subjects' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/subjects';
61 -CJTWordpressEvents::$paths[ 'observers' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/observers';
58 +CJTWordpressEvents::__init(array('hookType' => CJTWordpressEvents::HOOK_ACTION));
59 +CJTWordpressEvents::$paths['subjects']['core'] = CJTOOLBOX_FRAMEWORK . '/events/subjects';
60 +CJTWordpressEvents::$paths['observers']['core'] = CJTOOLBOX_FRAMEWORK . '/events/observers';
62 61
63 62 /**
64 63 * CJT Plugin interface.
65 -*
64 +*
66 65 * The CJT Plugin is maximum deferred.
67 66 * All functionality here is just to detect if the request should be processed!
68 -*
67 +*
69 68 * The main class is located css-js-toolbox.class.php cssJSToolbox class
70 69 * The plugin is fully developed using Model-View-Controller design pattern.
71 -*
70 +*
72 71 * access.points directory has all the entry points that processed by the Plugin.
73 -*
72 +*
74 73 * @package CJT
75 74 * @author Ahmed Said
76 75 * @version 6
77 76 */
78 -class CJTPlugin extends CJTHookableClass
79 -{
77 +class CJTPlugin extends CJTHookableClass {
80 78
81 79 /**
82 - *
80 + *
83 81 */
84 - const DB_VERSION = '1.7';
85 -
86 - /**
87 - * put your comment there...
88 - *
89 - * @var mixed
90 - */
91 - CONST ENV_PHP_MIN_VERSION = '5.3';
92 -
82 + const DB_VERSION = '1.6';
83 +
93 84 /**
94 - *
85 + *
95 86 */
96 - const FW_Version = '5.0';
97 -
87 + const FW_Version = '4.0';
88 +
98 89 /**
99 - *
90 + *
100 91 */
101 - const VERSION = '11';
102 -
92 + const VERSION = '8.1' ;
93 +
103 94 /**
104 - *
95 + *
105 96 */
106 97 const DB_VERSION_OPTION_NAME = 'cjtoolbox_db_version';
107 98
108 99 /**
109 - *
100 + *
110 101 */
111 102 const PLUGIN_REQUEST_ID = 'cjtoolbox';
112 -
103 +
113 104 /**
114 105 * put your comment there...
115 - *
106 + *
116 107 * @var mixed
117 108 */
118 109 protected $accessPoints;
119 -
110 +
120 111 /**
121 112 * put your comment there...
122 - *
113 + *
123 114 * @var mixed
124 115 */
125 116 protected $extensions;
126 -
117 +
127 118 /**
128 119 * put your comment there...
129 - *
120 + *
130 121 * @var mixed
131 122 */
132 123 protected $installed;
133 -
124 +
134 125 /**
135 126 * put your comment there...
136 - *
127 + *
137 128 * @var CJTPlugin
138 129 */
139 130 protected static $instance;
140 -
131 +
141 132 /**
142 133 * put your comment there...
143 - *
134 + *
144 135 * @var mixed
145 136 */
146 137 protected $mainAC;
147 -
138 +
148 139 /**
149 140 * put your comment there...
150 - *
141 + *
151 142 * @var mixed
152 143 */
153 - protected $onloaddbversion = array( 'parameters' => array( 'dbVersion' ) );
154 -
144 + protected $onloaddbversion = array('parameters' => array('dbVersion'));
145 +
155 146 /**
156 147 * put your comment there...
157 - *
148 + *
158 149 * @var mixed
159 150 */
160 - protected $onimportcontroller = array( 'parameters' => array( 'file' ) );
161 -
151 + protected $onimportbasefile = array('parameters' => array('file'));
152 +
162 153 /**
163 154 * put your comment there...
164 - *
155 + *
165 156 * @var mixed
166 157 */
167 - protected $onimportmodel = array( 'parameters' => array( 'file' ) );
168 -
158 + protected $onimportcontroller = array('parameters' => array('file'));
159 +
169 160 /**
170 161 * put your comment there...
171 - *
162 + *
172 163 * @var mixed
173 164 */
174 - protected $onload = array( 'parameters' => array( 'instance' ) );
165 + protected $onimportmodel = array('parameters' => array('file'));
166 +
167 + /**
168 + * put your comment there...
169 + *
170 + * @var mixed
171 + */
172 + protected $onload = array('parameters' => array('instance'));
175 173
176 174 /**
177 175 * put your comment there...
178 - *
176 + *
179 177 */
180 - protected function __construct()
181 - {
178 + protected function __construct() {
182 179 // Hookable!
183 180 parent::__construct();
184 -
185 181 // Allow access points to utilize from CJTPlugin functionality
186 182 // even if the call is recursive inside getInstance/construct methods!!!
187 - self::$instance = $this;
188 -
189 - // Installation version
190 - $dbVersion = $this->onloaddbversion( get_option( self::DB_VERSION_OPTION_NAME ) );
191 - $this->installed = ( ( $dbVersion ) == self::DB_VERSION );
192 -
183 + self::$instance = $this;
184 + // Read vars!
185 + $dbVersion = $this->onloaddbversion(get_option(self::DB_VERSION_OPTION_NAME));
186 + $this->installed = (($dbVersion) == self::DB_VERSION);
193 187 // Load plugin and all installed extensions!.
194 188 $this->load();
195 189 $this->loadExtensions();
196 -
197 190 // Run MAIN access point!
198 191 $this->main();
199 192 }
200 -
193 +
201 194 /**
202 195 * put your comment there...
203 - *
196 + *
204 197 */
205 - public function & extensions()
206 - {
207 - return $this->extensions;
198 + public function & extensions() {
199 + return $this->extensions;
208 200 }
209 -
201 +
210 202 /**
211 203 * put your comment there...
212 - *
204 + *
213 205 */
214 - public function getAccessPoint( $name )
215 - {
216 - return $this->accessPoints[ $name ];
206 + public function getAccessPoint($name) {
207 + return $this->accessPoints[$name];
217 208 }
218 -
209 +
219 210 /**
220 211 * put your comment there...
221 - *
212 + *
222 213 */
223 - public static function getInstance()
224 - {
225 -
226 - if ( ! self::$instance )
227 - {
214 + public static function getInstance() {
215 + if (!self::$instance) {
228 216 self::$instance = new CJTPlugin();
229 217 }
230 -
231 218 return self::$instance;
232 219 }
233 -
234 - /**
235 - * put your comment there...
236 - *
237 - */
238 - public static function isCompatibleEnvironment()
239 - {
240 -
241 - if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
242 - {
243 -
244 - $importHTMLFileCode = 'require "includes" . DIRECTORY_SEPARATOR . "html" . DIRECTORY_SEPARATOR . "incompatible_environment_message.html.php";';
245 -
246 - add_action( 'admin_notices', create_function( '', $importHTMLFileCode ) );
247 -
248 - return false;
249 - }
250 -
251 - return true;
252 - }
220 +
253 221 /**
254 222 * put your comment there...
255 - *
223 + *
256 224 */
257 - public function isInstalled()
258 - {
259 - return $this->installed;
225 + public function isInstalled() {
226 + return $this->installed;
260 227 }
261 -
228 +
262 229 /**
263 230 * put your comment there...
264 - *
231 + *
265 232 */
266 - public function listen()
267 - {
233 + public function listen() {
268 234 // For now we've only admin access points! Future versions might has something changed!
269 - if ( is_admin() )
270 - {
271 -
235 + if (is_admin()) {
272 236 // Import access points core classes.
273 237 require_once 'framework/access-points/page.class.php';
274 238 require_once 'framework/access-points/directory-spider.class.php';
275 -
276 239 // Get access points!
277 - $accessPoints = CJTAccessPointsDirectorySpider::getInstance( 'CJT', CJTOOLBOX_ACCESS_POINTS );
278 -
240 + $accessPoints = CJTAccessPointsDirectorySpider::getInstance('CJT', CJTOOLBOX_ACCESS_POINTS);
279 241 // For every access point create instance and LISTEN to the request!
280 - foreach ( $accessPoints as $name => $info )
281 - {
242 + foreach ($accessPoints as $name => $info) {
282 243 /**
283 244 * @var CJTAccessPoint
284 245 */
285 - $this->accessPoints[ $name ] = $point = $accessPoints->point()->listen();
286 -
246 + $this->accessPoints[$name] = $point = $accessPoints->point()->listen();
287 247 // We need to do some work with there is a connected access point.
288 - $point->onconnected = array( & $this, 'onconnected' );
289 -
248 + $point->onconnected = array(&$this, 'onconnected');
290 249 }
291 -
292 250 }
293 -
251 + // Chaining!
294 252 return $this;
295 253 }
296 -
254 +
297 255 /**
298 256 * put your comment there...
299 - *
257 + *
300 258 */
301 - protected function load()
302 - {
259 + protected function load() {
303 260 // Bootstrap the Plugin!
261 + require_once $this->onimportbasefile('css-js-toolbox.class.php');
304 262 cssJSToolbox::getInstance();
305 -
306 263 // Load MVC framework core!
307 - require_once $this->onimportmodel( CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php' );
308 - require_once $this->onimportcontroller( CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php' );
309 -
264 + require_once $this->onimportmodel(CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php');
265 + require_once $this->onimportcontroller(CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php');
266 + // Chaining!
310 267 return $this;
311 268 }
312 -
269 +
313 270 /**
314 271 * put your comment there...
315 - *
272 + *
316 273 */
317 - protected function loadExtensions()
318 - {
274 + protected function loadExtensions() {
319 275 // Load extensions lib!
320 276 require_once 'framework/extensions/extensions.class.php';
321 -
322 277 $this->extensions = new CJTExtensions();
278 + // Load all extensions!
323 279 $this->extensions->load();
324 -
280 + // Chaining!
325 281 return $this;
326 282 }
327 -
283 +
328 284 /**
329 285 * Run MAIN access point!
330 - *
286 + *
331 287 * @return $this
332 288 */
333 - protected function main()
334 - {
289 + protected function main() {
335 290 // Fire laod event
336 - $this->onload( $this );
337 -
291 + $this->onload($this);
338 292 // Access point base class is a dependency!
339 293 require_once 'framework/access-points/access-point.class.php';
340 -
341 294 // Run Main Acces Point!
342 295 include_once 'access.points/main.accesspoint.php';
343 -
344 296 $this->mainAC = new CJTMainAccessPoint();
345 297 $this->mainAC->listen();
346 298 }
347 -
299 +
348 300 /**
349 - * Called When any In-Listen-State (ILS) Access point is
301 + * Called When any In-Listen-State (ILS) Access point is
350 302 * connected (called by Wordpress hooking system).
351 - *
303 + *
352 304 * @return boolean TRUE.
353 305 */
354 - public function onconnected( $observer, $state )
306 + public function onconnected($observer, $state)
355 307 {
356 -
357 308 // In all cases that we'll process the request load the localization file.
358 - load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
359 -
309 + load_plugin_textdomain(CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES);
310 +
360 311 do_action( CJTPluggableHelper::ACTION_CJT_TEXT_DOMAIN_LOADED );
361 -
312 +
362 313 // Always connet the access point!
363 314 return $state;
364 -
315 +
365 316 }
366 -
317 +
367 318 }// End Class
368 319
369 -// Dont run if environment (e.g PHP version) is incomaptible
370 -if ( ! CJTPlugin::isCompatibleEnvironment() )
371 -{
372 - return;
373 -}
374 -
375 320 // Initialize events!
376 -CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
321 +CJTPlugin::define('CJTPlugin', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
377 322
378 323 // Let's Go!
379 -function deprecatedPHPCheck()
380 -{ ?>
381 - <div class="notice notice-error">
382 - <p><strong>CJT</strong>: CSS & JavaScript Toolbox need PHP version 7.3 or greater to operate properly. Please ask your hosting provider to update the PHP version.<br>
383 - Current PHP Version: <strong><?php echo phpversion(); ?></strong>
384 - </p>
385 - </div>
386 -<?php }
387 -
388 -if ( version_compare( phpversion(), 7, '>=' ) ) {
389 - CJTPlugin::getInstance();
390 -} else {
391 - add_action( 'admin_notices', 'deprecatedPHPCheck' );
392 -}
324 +CJTPlugin::getInstance();