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