| 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: 7.2 |
| 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.6'; |
| 94 |
|
| 95 |
/** |
| 96 |
* |
| 97 |
*/ |
| 98 |
const Edition = 'free'; |
| 99 |
|
| 100 |
/** |
| 101 |
* |
| 102 |
*/ |
| 103 |
const FW_Version = '3.0'; |
| 104 |
|
| 105 |
/** |
| 106 |
* |
| 107 |
*/ |
| 108 |
const VERSION = '7.2-CE' ; |
| 109 |
|
| 110 |
/** |
| 111 |
* |
| 112 |
*/ |
| 113 |
const DB_VERSION_OPTION_NAME = 'cjtoolbox_db_version'; |
| 114 |
|
| 115 |
/** |
| 116 |
* |
| 117 |
*/ |
| 118 |
const PLUGIN_REQUEST_ID = 'cjtoolbox'; |
| 119 |
|
| 120 |
/** |
| 121 |
* put your comment there... |
| 122 |
* |
| 123 |
* @var mixed |
| 124 |
*/ |
| 125 |
protected $accessPoints; |
| 126 |
|
| 127 |
/** |
| 128 |
* put your comment there... |
| 129 |
* |
| 130 |
* @var mixed |
| 131 |
*/ |
| 132 |
protected $extensions; |
| 133 |
|
| 134 |
/** |
| 135 |
* put your comment there... |
| 136 |
* |
| 137 |
* @var mixed |
| 138 |
*/ |
| 139 |
protected $installed; |
| 140 |
|
| 141 |
/** |
| 142 |
* put your comment there... |
| 143 |
* |
| 144 |
* @var CJTPlugin |
| 145 |
*/ |
| 146 |
protected static $instance; |
| 147 |
|
| 148 |
/** |
| 149 |
* put your comment there... |
| 150 |
* |
| 151 |
* @var mixed |
| 152 |
*/ |
| 153 |
protected $mainAC; |
| 154 |
|
| 155 |
/** |
| 156 |
* put your comment there... |
| 157 |
* |
| 158 |
* @var mixed |
| 159 |
*/ |
| 160 |
protected $onloaddbversion = array('parameters' => array('dbVersion')); |
| 161 |
|
| 162 |
/** |
| 163 |
* put your comment there... |
| 164 |
* |
| 165 |
* @var mixed |
| 166 |
*/ |
| 167 |
protected $onimportbasefile = array('parameters' => array('file')); |
| 168 |
|
| 169 |
/** |
| 170 |
* put your comment there... |
| 171 |
* |
| 172 |
* @var mixed |
| 173 |
*/ |
| 174 |
protected $onimportcontroller = array('parameters' => array('file')); |
| 175 |
|
| 176 |
/** |
| 177 |
* put your comment there... |
| 178 |
* |
| 179 |
* @var mixed |
| 180 |
*/ |
| 181 |
protected $onimportmodel = array('parameters' => array('file')); |
| 182 |
|
| 183 |
/** |
| 184 |
* put your comment there... |
| 185 |
* |
| 186 |
* @var mixed |
| 187 |
*/ |
| 188 |
protected $onload = array('parameters' => array('instance')); |
| 189 |
|
| 190 |
/** |
| 191 |
* put your comment there... |
| 192 |
* |
| 193 |
*/ |
| 194 |
protected function __construct() { |
| 195 |
// Hookable! |
| 196 |
parent::__construct(); |
| 197 |
// Allow access points to utilize from CJTPlugin functionality |
| 198 |
// even if the call is recursive inside getInstance/construct methods!!! |
| 199 |
self::$instance = $this; |
| 200 |
// Read vars! |
| 201 |
$dbVersion = $this->onloaddbversion(get_option(self::DB_VERSION_OPTION_NAME)); |
| 202 |
$this->installed = (($dbVersion) == self::DB_VERSION); |
| 203 |
// Load plugin and all installed extensions!. |
| 204 |
$this->load(); |
| 205 |
$this->loadExtensions(); |
| 206 |
// Run MAIN access point! |
| 207 |
$this->main(); |
| 208 |
} |
| 209 |
|
| 210 |
/** |
| 211 |
* put your comment there... |
| 212 |
* |
| 213 |
*/ |
| 214 |
public function & extensions() { |
| 215 |
return $this->extensions; |
| 216 |
} |
| 217 |
|
| 218 |
/** |
| 219 |
* put your comment there... |
| 220 |
* |
| 221 |
*/ |
| 222 |
public function getAccessPoint($name) { |
| 223 |
return $this->accessPoints[$name]; |
| 224 |
} |
| 225 |
|
| 226 |
/** |
| 227 |
* put your comment there... |
| 228 |
* |
| 229 |
*/ |
| 230 |
public static function getInstance() { |
| 231 |
if (!self::$instance) { |
| 232 |
self::$instance = new CJTPlugin(); |
| 233 |
} |
| 234 |
return self::$instance; |
| 235 |
} |
| 236 |
|
| 237 |
/** |
| 238 |
* put your comment there... |
| 239 |
* |
| 240 |
*/ |
| 241 |
public function isInstalled() { |
| 242 |
return $this->installed; |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* put your comment there... |
| 247 |
* |
| 248 |
*/ |
| 249 |
public function listen() { |
| 250 |
// For now we've only admin access points! Future versions might has something changed! |
| 251 |
if (is_admin()) { |
| 252 |
// Import access points core classes. |
| 253 |
require_once 'framework/access-points/page.class.php'; |
| 254 |
require_once 'framework/access-points/directory-spider.class.php'; |
| 255 |
// Get access points! |
| 256 |
$accessPoints = CJTAccessPointsDirectorySpider::getInstance('CJT', CJTOOLBOX_ACCESS_POINTS); |
| 257 |
// For every access point create instance and LISTEN to the request! |
| 258 |
foreach ($accessPoints as $name => $info) { |
| 259 |
/** |
| 260 |
* @var CJTAccessPoint |
| 261 |
*/ |
| 262 |
$this->accessPoints[$name] = $point = $accessPoints->point()->listen(); |
| 263 |
// We need to do some work with there is a connected access point. |
| 264 |
$point->onconnected = array(&$this, 'onconnected'); |
| 265 |
} |
| 266 |
} |
| 267 |
// Chaining! |
| 268 |
return $this; |
| 269 |
} |
| 270 |
|
| 271 |
/** |
| 272 |
* put your comment there... |
| 273 |
* |
| 274 |
*/ |
| 275 |
protected function load() { |
| 276 |
// Bootstrap the Plugin! |
| 277 |
require_once $this->onimportbasefile('css-js-toolbox.class.php'); |
| 278 |
cssJSToolbox::getInstance(); |
| 279 |
// Load MVC framework core! |
| 280 |
require_once $this->onimportmodel(CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php'); |
| 281 |
require_once $this->onimportcontroller(CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php'); |
| 282 |
// Chaining! |
| 283 |
return $this; |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* put your comment there... |
| 288 |
* |
| 289 |
*/ |
| 290 |
protected function loadExtensions() { |
| 291 |
// Load extensions lib! |
| 292 |
require_once 'framework/extensions/extensions.class.php'; |
| 293 |
$this->extensions = new CJTExtensions(); |
| 294 |
// Load all extensions! |
| 295 |
$this->extensions->load(); |
| 296 |
// Chaining! |
| 297 |
return $this; |
| 298 |
} |
| 299 |
|
| 300 |
/** |
| 301 |
* Run MAIN access point! |
| 302 |
* |
| 303 |
* @return $this |
| 304 |
*/ |
| 305 |
protected function main() { |
| 306 |
// Fire laod event |
| 307 |
$this->onload($this); |
| 308 |
// Access point base class is a dependency! |
| 309 |
require_once 'framework/access-points/access-point.class.php'; |
| 310 |
// Run Main Acces Point! |
| 311 |
include_once 'access.points/main.accesspoint.php'; |
| 312 |
$this->mainAC = new CJTMainAccessPoint(); |
| 313 |
$this->mainAC->listen(); |
| 314 |
} |
| 315 |
|
| 316 |
/** |
| 317 |
* Called When any In-Listen-State (ILS) Access point is |
| 318 |
* connected (called by Wordpress hooking system). |
| 319 |
* |
| 320 |
* @return boolean TRUE. |
| 321 |
*/ |
| 322 |
public function onconnected($observer, $state) { |
| 323 |
// In all cases that we'll process the request load the localization file. |
| 324 |
load_plugin_textdomain(CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES); |
| 325 |
// Always connet the access point! |
| 326 |
return $state; |
| 327 |
} |
| 328 |
|
| 329 |
}// End Class |
| 330 |
|
| 331 |
// Initialize events! |
| 332 |
CJTPlugin::define('CJTPlugin', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); |
| 333 |
|
| 334 |
// Let's Go! |
| 335 |
CJTPlugin::getInstance(); |