PluginProbe
CSS & JavaScript Toolbox / 7.2
CSS & JavaScript Toolbox v7.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 +137 -219 trunk7.2 View file →
@@ -1,48 +1,56 @@
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.7
7 -Author: Wipeout Media
8 -Author URI: https://css-javascript-toolbox.com
9 -Text Domain: css-javascript-toolbox
10 -Domain Path: /locals/languages/
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: 7.2
7 +Author: Wipeout Media
8 +Author URI: http://css-javascript-toolbox.com
11 9 License:
12 10
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.
11 +Copyright (c) 2011, Wipeout Media.
12 +This program is free software; you can redistribute it and/or
13 +modify it under the terms of the GNU General Public License
14 +as published by the Free Software Foundation; either version 2
15 +of the License, or (at your option) any later version.
14 16
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.
17 +This program is distributed in the hope that it will be useful,
18 +but WITHOUT ANY WARRANTY; without even the implied warranty of
19 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 +GNU General Public License for more details.
21 +
22 +You should have received a copy of the GNU General Public License
23 +along with this program; if not, write to the Free Software
24 +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 25 */
17 26
18 27 // Disallow direct access.
19 -defined( 'ABSPATH' ) or die( 'Access denied' );
28 +defined('ABSPATH') or die("Access denied");
20 29
21 -
22 30 /** * */
23 -define( 'CJTOOLBOX_PLUGIN_BASE', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );
31 +define('CJTOOLBOX_PLUGIN_BASE', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
24 32
25 33 /** * */
26 -define( 'CJTOOLBOX_PLUGIN_FILE', __FILE__ );
34 +define('CJTOOLBOX_PLUGIN_FILE', __FILE__);
27 35
28 36 /** CJT Name */
29 -define( 'CJTOOLBOX_NAME', plugin_basename( dirname( __FILE__ ) ) );
37 +define('CJTOOLBOX_NAME', plugin_basename(dirname(__FILE__)));
30 38
31 39 /** CJT Text Domain used for localize texts */
32 -define( 'CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME );
40 +define('CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME);
33 41
34 42 /** */
35 -define( 'CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/' );
43 +define('CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/');
36 44
37 45 /** CJT Absoulte path */
38 -define( 'CJTOOLBOX_PATH', dirname( __FILE__ ) );
46 +define('CJTOOLBOX_PATH', dirname(__FILE__));
39 47
40 48 /** Dont use!! @deprecated */
41 -define( 'CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework' );
49 +define('CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework');
42 50
43 51 /** Access Points path */
44 -define( 'CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points' );
52 +define('CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points');
45 53
46 54 /** Frmaework path */
47 55 define('CJTOOLBOX_FRAMEWORK', CJTOOLBOX_INCLUDE_PATH); // Alias to include path!
48 56
@@ -57,361 +65,271 @@
57 65 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.interface.php';
58 66 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.class.php';
59 67
60 68 // Initialize events engine/system!
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';
69 +CJTWordpressEvents::__init(array('hookType' => CJTWordpressEvents::HOOK_ACTION));
70 +CJTWordpressEvents::$paths['subjects']['core'] = CJTOOLBOX_FRAMEWORK . '/events/subjects';
71 +CJTWordpressEvents::$paths['observers']['core'] = CJTOOLBOX_FRAMEWORK . '/events/observers';
64 72
65 73 /**
66 74 * CJT Plugin interface.
67 -*
75 +*
68 76 * The CJT Plugin is maximum deferred.
69 77 * All functionality here is just to detect if the request should be processed!
70 -*
78 +*
71 79 * The main class is located css-js-toolbox.class.php cssJSToolbox class
72 80 * The plugin is fully developed using Model-View-Controller design pattern.
73 -*
81 +*
74 82 * access.points directory has all the entry points that processed by the Plugin.
75 -*
83 +*
76 84 * @package CJT
77 85 * @author Ahmed Said
78 86 * @version 6
79 87 */
80 -class CJTPlugin extends CJTHookableClass
81 -{
88 +class CJTPlugin extends CJTHookableClass {
82 89
83 90 /**
84 - *
91 + *
85 92 */
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 -
93 + const DB_VERSION = '1.6';
94 +
95 95 /**
96 - *
96 + *
97 97 */
98 - const FW_Version = '5.0';
99 -
98 + const Edition = 'free';
99 +
100 100 /**
101 - *
101 + *
102 102 */
103 - const VERSION = '12.0.7';
104 -
103 + const FW_Version = '3.0';
104 +
105 105 /**
106 - *
106 + *
107 107 */
108 + const VERSION = '7.2-CE' ;
109 +
110 + /**
111 + *
112 + */
108 113 const DB_VERSION_OPTION_NAME = 'cjtoolbox_db_version';
109 114
110 115 /**
111 - *
116 + *
112 117 */
113 118 const PLUGIN_REQUEST_ID = 'cjtoolbox';
114 -
119 +
115 120 /**
116 121 * put your comment there...
117 - *
122 + *
118 123 * @var mixed
119 124 */
120 125 protected $accessPoints;
121 -
126 +
122 127 /**
123 128 * put your comment there...
124 - *
129 + *
125 130 * @var mixed
126 131 */
127 132 protected $extensions;
128 -
133 +
129 134 /**
130 135 * put your comment there...
131 - *
136 + *
132 137 * @var mixed
133 138 */
134 139 protected $installed;
135 -
140 +
136 141 /**
137 142 * put your comment there...
138 - *
143 + *
139 144 * @var CJTPlugin
140 145 */
141 146 protected static $instance;
142 -
147 +
143 148 /**
144 149 * put your comment there...
145 - *
150 + *
146 151 * @var mixed
147 152 */
148 153 protected $mainAC;
149 -
154 +
150 155 /**
151 156 * put your comment there...
152 - *
157 + *
153 158 * @var mixed
154 159 */
155 - protected $onloaddbversion = array( 'parameters' => array( 'dbVersion' ) );
156 -
160 + protected $onloaddbversion = array('parameters' => array('dbVersion'));
161 +
157 162 /**
158 163 * put your comment there...
159 - *
164 + *
160 165 * @var mixed
161 166 */
162 - protected $onimportcontroller = array( 'parameters' => array( 'file' ) );
163 -
167 + protected $onimportbasefile = array('parameters' => array('file'));
168 +
164 169 /**
165 170 * put your comment there...
166 - *
171 + *
167 172 * @var mixed
168 173 */
169 - protected $onimportmodel = array( 'parameters' => array( 'file' ) );
170 -
174 + protected $onimportcontroller = array('parameters' => array('file'));
175 +
171 176 /**
172 177 * put your comment there...
173 - *
178 + *
174 179 * @var mixed
175 180 */
176 - protected $onload = array( 'parameters' => array( 'instance' ) );
181 + protected $onimportmodel = array('parameters' => array('file'));
182 +
183 + /**
184 + * put your comment there...
185 + *
186 + * @var mixed
187 + */
188 + protected $onload = array('parameters' => array('instance'));
177 189
178 190 /**
179 191 * put your comment there...
180 - *
192 + *
181 193 */
182 - protected function __construct()
183 - {
194 + protected function __construct() {
184 195 // Hookable!
185 196 parent::__construct();
186 -
187 197 // Allow access points to utilize from CJTPlugin functionality
188 198 // even if the call is recursive inside getInstance/construct methods!!!
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 -
199 + self::$instance = $this;
200 + // Read vars!
201 + $dbVersion = $this->onloaddbversion(get_option(self::DB_VERSION_OPTION_NAME));
202 + $this->installed = (($dbVersion) == self::DB_VERSION);
195 203 // Load plugin and all installed extensions!.
196 204 $this->load();
197 205 $this->loadExtensions();
198 -
199 206 // Run MAIN access point!
200 207 $this->main();
201 208 }
202 -
209 +
203 210 /**
204 211 * put your comment there...
205 - *
212 + *
206 213 */
207 - public function & extensions()
208 - {
209 - return $this->extensions;
214 + public function & extensions() {
215 + return $this->extensions;
210 216 }
211 -
217 +
212 218 /**
213 219 * put your comment there...
214 - *
220 + *
215 221 */
216 - public function getAccessPoint( $name )
217 - {
218 - return $this->accessPoints[ $name ];
222 + public function getAccessPoint($name) {
223 + return $this->accessPoints[$name];
219 224 }
220 -
225 +
221 226 /**
222 227 * put your comment there...
223 - *
228 + *
224 229 */
225 - public static function getInstance()
226 - {
227 -
228 - if ( ! self::$instance )
229 - {
230 + public static function getInstance() {
231 + if (!self::$instance) {
230 232 self::$instance = new CJTPlugin();
231 233 }
232 -
233 234 return self::$instance;
234 235 }
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 - }
236 +
253 237 /**
254 238 * put your comment there...
255 - *
239 + *
256 240 */
257 - public function isInstalled()
258 - {
259 - return $this->installed;
241 + public function isInstalled() {
242 + return $this->installed;
260 243 }
261 -
244 +
262 245 /**
263 246 * put your comment there...
264 - *
247 + *
265 248 */
266 - public function listen()
267 - {
249 + public function listen() {
268 250 // For now we've only admin access points! Future versions might has something changed!
269 - if ( is_admin() )
270 - {
271 -
251 + if (is_admin()) {
272 252 // Import access points core classes.
273 253 require_once 'framework/access-points/page.class.php';
274 254 require_once 'framework/access-points/directory-spider.class.php';
275 -
276 255 // Get access points!
277 - $accessPoints = CJTAccessPointsDirectorySpider::getInstance( 'CJT', CJTOOLBOX_ACCESS_POINTS );
278 -
256 + $accessPoints = CJTAccessPointsDirectorySpider::getInstance('CJT', CJTOOLBOX_ACCESS_POINTS);
279 257 // For every access point create instance and LISTEN to the request!
280 - foreach ( $accessPoints as $name => $info )
281 - {
258 + foreach ($accessPoints as $name => $info) {
282 259 /**
283 260 * @var CJTAccessPoint
284 261 */
285 - $this->accessPoints[ $name ] = $point = $accessPoints->point()->listen();
286 -
262 + $this->accessPoints[$name] = $point = $accessPoints->point()->listen();
287 263 // We need to do some work with there is a connected access point.
288 - $point->onconnected = array( & $this, 'onconnected' );
289 -
264 + $point->onconnected = array(&$this, 'onconnected');
290 265 }
291 -
292 266 }
293 -
267 + // Chaining!
294 268 return $this;
295 269 }
296 -
270 +
297 271 /**
298 272 * put your comment there...
299 - *
273 + *
300 274 */
301 - protected function load()
302 - {
275 + protected function load() {
303 276 // Bootstrap the Plugin!
277 + require_once $this->onimportbasefile('css-js-toolbox.class.php');
304 278 cssJSToolbox::getInstance();
305 -
306 279 // 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 -
280 + require_once $this->onimportmodel(CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php');
281 + require_once $this->onimportcontroller(CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php');
282 + // Chaining!
310 283 return $this;
311 284 }
312 -
285 +
313 286 /**
314 287 * put your comment there...
315 - *
288 + *
316 289 */
317 - protected function loadExtensions()
318 - {
290 + protected function loadExtensions() {
319 291 // Load extensions lib!
320 292 require_once 'framework/extensions/extensions.class.php';
321 -
322 293 $this->extensions = new CJTExtensions();
294 + // Load all extensions!
323 295 $this->extensions->load();
324 -
296 + // Chaining!
325 297 return $this;
326 298 }
327 -
299 +
328 300 /**
329 301 * Run MAIN access point!
330 - *
302 + *
331 303 * @return $this
332 304 */
333 - protected function main()
334 - {
305 + protected function main() {
335 306 // Fire laod event
336 - $this->onload( $this );
337 -
307 + $this->onload($this);
338 308 // Access point base class is a dependency!
339 309 require_once 'framework/access-points/access-point.class.php';
340 -
341 310 // Run Main Acces Point!
342 311 include_once 'access.points/main.accesspoint.php';
343 -
344 312 $this->mainAC = new CJTMainAccessPoint();
345 313 $this->mainAC->listen();
346 314 }
347 -
315 +
348 316 /**
349 - * Called When any In-Listen-State (ILS) Access point is
317 + * Called When any In-Listen-State (ILS) Access point is
350 318 * connected (called by Wordpress hooking system).
351 - *
319 + *
352 320 * @return boolean TRUE.
353 321 */
354 - public function onconnected( $observer, $state )
355 - {
356 - // Always connect the access point!
322 + public function onconnected($observer, $state) {
323 + // In all cases that we'll process the request load the localization file.
324 + load_plugin_textdomain(CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES);
325 + // Always connet the access point!
357 326 return $state;
358 327 }
359 -
328 +
360 329 }// End Class
361 330
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 -
380 331 // Initialize events!
381 -CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
332 +CJTPlugin::define('CJTPlugin', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
382 333
383 334 // Let's Go!
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 -}
335 +CJTPlugin::getInstance();