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