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