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