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