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