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