PluginProbe
CSS & JavaScript Toolbox / 6.0.14
CSS & JavaScript Toolbox v6.0.14
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.0.14, at css-js-toolbox.php

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