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