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