PluginProbe
CSS & JavaScript Toolbox / 6.1.3
CSS & JavaScript Toolbox v6.1.3
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
css-javascript-toolbox / css-js-toolbox.php

css-js-toolbox.php in CSS & JavaScript Toolbox 6.1.3, at css-js-toolbox.php

316 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: CSS & JavaScript Toolbox
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.3
7 Author: Wipeout Media
8 Author URI: http://css-javascript-toolbox.com/
9 License:
10
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.
16
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.
25 */
26
27 // Disallow direct access.
28 defined('ABSPATH') or die("Access denied");
29
30 /** * */
31 define('CJTOOLBOX_PLUGIN_BASE', basename(dirname(__FILE__)) . '/' . basename(__FILE__));
32
33 /** * */
34 define('CJTOOLBOX_PLUGIN_FILE', __FILE__);
35
36 /** CJT Name */
37 define('CJTOOLBOX_NAME', plugin_basename(dirname(__FILE__)));
38
39 /** CJT Text Domain used for localize texts */
40 define('CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME);
41
42 /** */
43 define('CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/');
44
45 /** CJT Absoulte path */
46 define('CJTOOLBOX_PATH', dirname(__FILE__));
47
48 /** Dont use!! @deprecated */
49 define('CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework');
50
51 /** Access Points path */
52 define('CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points');
53
54 /** Frmaework path */
55 define('CJTOOLBOX_FRAMEWORK', CJTOOLBOX_INCLUDE_PATH); // Alias to include path!
56
57 // Class Autoload Added @since 6.2.
58 require 'autoload.inc.php';
59
60 // Import dependencies
61 require_once CJTOOLBOX_FRAMEWORK . '/php/includes.class.php';
62 require_once CJTOOLBOX_FRAMEWORK . '/events/definition.class.php';
63 require_once CJTOOLBOX_FRAMEWORK . '/events/events.class.php';
64 require_once CJTOOLBOX_FRAMEWORK . '/events/wordpress.class.php';
65 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.interface.php';
66 require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.class.php';
67
68 // Initialize events engine/system!
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';
72
73 /**
74 * CJT Plugin interface.
75 *
76 * The CJT Plugin is maximum deferred.
77 * All functionality here is just to detect if the request should be processed!
78 *
79 * The main class is located css-js-toolbox.class.php cssJSToolbox class
80 * The plugin is fully developed using Model-View-Controller design pattern.
81 *
82 * access.points directory has all the entry points that processed by the Plugin.
83 *
84 * @package CJT
85 * @author Ahmed Said
86 * @version 6
87 */
88 class CJTPlugin extends CJTHookableClass {
89
90 /**
91 *
92 */
93 const DB_VERSION = '1.1-CE';
94
95 /**
96 *
97 */
98 const VERSION = '6.1.3 CE';
99
100 /**
101 *
102 */
103 const DB_VERSION_OPTION_NAME = 'cjtoolbox_db_version';
104
105 /**
106 *
107 */
108 const PLUGIN_REQUEST_ID = 'cjtoolbox';
109
110 /**
111 * put your comment there...
112 *
113 * @var mixed
114 */
115 protected $accessPoints;
116
117 /**
118 * put your comment there...
119 *
120 * @var mixed
121 */
122 protected $extensions;
123
124 /**
125 * put your comment there...
126 *
127 * @var mixed
128 */
129 protected $installed;
130
131 /**
132 * put your comment there...
133 *
134 * @var CJTPlugin
135 */
136 protected static $instance;
137
138 /**
139 * put your comment there...
140 *
141 * @var mixed
142 */
143 protected $mainAC;
144
145 /**
146 * put your comment there...
147 *
148 * @var mixed
149 */
150 protected $onloaddbversion = array('parameters' => array('dbVersion'));
151
152 /**
153 * put your comment there...
154 *
155 * @var mixed
156 */
157 protected $onimportbasefile = array('parameters' => array('file'));
158
159 /**
160 * put your comment there...
161 *
162 * @var mixed
163 */
164 protected $onimportcontroller = array('parameters' => array('file'));
165
166 /**
167 * put your comment there...
168 *
169 * @var mixed
170 */
171 protected $onimportmodel = array('parameters' => array('file'));
172
173 /**
174 * put your comment there...
175 *
176 */
177 protected function __construct() {
178 // Hookable!
179 parent::__construct();
180 // Allow access points to utilize from CJTPlugin functionality
181 // even if the call is recursive inside getInstance/construct methods!!!
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);
186 // Load plugin and all installed extensions!.
187 $this->load();
188 $this->loadExtensions();
189 // Run MAIN access point!
190 $this->main();
191 }
192
193 /**
194 * put your comment there...
195 *
196 */
197 public function extensions() {
198 return $this->extensions;
199 }
200
201 /**
202 * put your comment there...
203 *
204 */
205 public function getAccessPoint($name) {
206 return $this->accessPoints[$name];
207 }
208
209 /**
210 * put your comment there...
211 *
212 */
213 public static function getInstance() {
214 if (!self::$instance) {
215 self::$instance = new CJTPlugin();
216 }
217 return self::$instance;
218 }
219
220 /**
221 * put your comment there...
222 *
223 */
224 public function isInstalled() {
225 return $this->installed;
226 }
227
228 /**
229 * put your comment there...
230 *
231 */
232 public function listen() {
233 // For now we've only admin access points! Future versions might has something changed!
234 if (is_admin()) {
235 // Import access points core classes.
236 require_once 'framework/access-points/page.class.php';
237 require_once 'framework/access-points/directory-spider.class.php';
238 // Get access points!
239 $accessPoints = CJTAccessPointsDirectorySpider::getInstance('CJT', CJTOOLBOX_ACCESS_POINTS);
240 // For every access point create instance and LISTEN to the request!
241 foreach ($accessPoints as $name => $info) {
242 /**
243 * @var CJTAccessPoint
244 */
245 $this->accessPoints[$name] = $point = $accessPoints->point()->listen();
246 // We need to do some work with there is a connected access point.
247 $point->onconnected = array(&$this, 'onconnected');
248 }
249 }
250 // Chaining!
251 return $this;
252 }
253
254 /**
255 * put your comment there...
256 *
257 */
258 protected function load() {
259 // Bootstrap the Plugin!
260 require_once $this->onimportbasefile('css-js-toolbox.class.php');
261 cssJSToolbox::getInstance();
262 // Load MVC framework core!
263 require_once $this->onimportmodel(CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php');
264 require_once $this->onimportcontroller(CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php');
265 // Chaining!
266 return $this;
267 }
268
269 /**
270 * put your comment there...
271 *
272 */
273 protected function loadExtensions() {
274 // Load extensions lib!
275 require_once 'framework/extensions/extensions.class.php';
276 $this->extensions = new CJTExtensions();
277 // Load all extensions!
278 $this->extensions->load();
279 // Chaining!
280 return $this;
281 }
282
283 /**
284 * Run MAIN access point!
285 *
286 * @return $this
287 */
288 protected function main() {
289 // Access point base class is a dependency!
290 require_once 'framework/access-points/access-point.class.php';
291 // Run Main Acces Point!
292 include_once 'access.points/main.accesspoint.php';
293 $this->mainAC = new CJTMainAccessPoint();
294 $this->mainAC->listen();
295 }
296
297 /**
298 * Called When any In-Listen-State (ILS) Access point is
299 * connected (called by Wordpress hooking system).
300 *
301 * @return boolean TRUE.
302 */
303 public function onconnected($observer, $state) {
304 // In all cases that we'll process the request load the localization file.
305 load_plugin_textdomain(CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES);
306 // Always connet the access point!
307 return $state;
308 }
309
310 }// End Class
311
312 // Initialize events!
313 CJTPlugin::define('CJTPlugin', array('hookType' => CJTWordpressEvents::HOOK_FILTER));
314
315 // Let's Go!
316 CJTPlugin::getInstance();