# css-javascript-toolbox/trunk/css-js-toolbox.php

CSS &amp; JavaScript Toolbox, version trunk. 418 lines.

- Page: https://pluginprobe.com/plugins/css-javascript-toolbox/trunk/code/css-js-toolbox.php
- Raw: https://pluginprobe.com/plugins/css-javascript-toolbox/trunk/raw/css-js-toolbox.php
- Modified: 2026-08-26T15:02:26+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/css-javascript-toolbox/trunk/code/css-js-toolbox.php#L10-L20`.

```php
<?php
/*
Plugin Name: CSS & JavaScript Toolbox
Plugin URI: https://css-javascript-toolbox.com/
Description: Easily add CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them anywhere on your website.
Version: 12.0.7
Author: Wipeout Media
Author URI: https://css-javascript-toolbox.com
Text Domain: css-javascript-toolbox
Domain Path: /locals/languages/
License:

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.

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.
*/

// Disallow direct access.
defined( 'ABSPATH' ) or die( 'Access denied' );


/** * */
define( 'CJTOOLBOX_PLUGIN_BASE', basename( dirname( __FILE__ ) ) . '/' . basename( __FILE__ ) );

/** * */
define( 'CJTOOLBOX_PLUGIN_FILE', __FILE__ );

/** CJT Name */
define( 'CJTOOLBOX_NAME', plugin_basename( dirname( __FILE__ ) ) );

/** CJT Text Domain used for localize texts */
define( 'CJTOOLBOX_TEXT_DOMAIN', CJTOOLBOX_NAME );

/**  */
define( 'CJTOOLBOX_LANGUAGES', CJTOOLBOX_NAME . '/locals/languages/' );

/** CJT Absoulte path */
define( 'CJTOOLBOX_PATH', dirname( __FILE__ ) );

/** Dont use!! @deprecated */
define( 'CJTOOLBOX_INCLUDE_PATH', CJTOOLBOX_PATH . '/framework' );

/** Access Points  path */
define( 'CJTOOLBOX_ACCESS_POINTS', CJTOOLBOX_PATH . '/access.points' );

/** Frmaework path */
define('CJTOOLBOX_FRAMEWORK', CJTOOLBOX_INCLUDE_PATH); // Alias to include path!

// Class Autoload Added @since 6.2.
require 'autoload.inc.php';

// Import dependencies
require_once CJTOOLBOX_FRAMEWORK . '/php/includes.class.php';
require_once CJTOOLBOX_FRAMEWORK . '/events/definition.class.php';
require_once CJTOOLBOX_FRAMEWORK . '/events/events.class.php';
require_once CJTOOLBOX_FRAMEWORK . '/events/wordpress.class.php';
require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.interface.php';
require_once CJTOOLBOX_FRAMEWORK . '/events/hookable.class.php';

// Initialize events engine/system!
CJTWordpressEvents::_init( array( 'hookType' => CJTWordpressEvents::HOOK_ACTION ) );
CJTWordpressEvents::$paths[ 'subjects' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/subjects';
CJTWordpressEvents::$paths[ 'observers' ][ 'core' ] = CJTOOLBOX_FRAMEWORK . '/events/observers';

/**
* CJT Plugin interface.
*
* The CJT Plugin is maximum deferred.
* All functionality here is just to detect if the request should be processed!
*
* The main class is located css-js-toolbox.class.php cssJSToolbox class
* The plugin is fully developed using Model-View-Controller design pattern.
*
* access.points directory has all the entry points that processed by the Plugin.
*
* @package CJT
* @author Ahmed Said
* @version 6
*/
class CJTPlugin extends CJTHookableClass
{

	/**
	*
	*/
	const DB_VERSION = '1.7';

    /**
    * Minimum PHP version required to run the plugin.
    *
    * @var string
    */
    CONST ENV_PHP_MIN_VERSION = '7.4';

	/**
	*
	*/
	const FW_Version = '5.0';

	/**
	*
	*/
	const VERSION = '12.0.7';

	/**
	*
	*/
	const DB_VERSION_OPTION_NAME = 'cjtoolbox_db_version';

	/**
	*
	*/
	const PLUGIN_REQUEST_ID = 'cjtoolbox';

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $accessPoints;

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $extensions;

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $installed;

	/**
	* put your comment there...
	*
	* @var CJTPlugin
	*/
	protected static $instance;

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $mainAC;

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $onloaddbversion = array( 'parameters' => array( 'dbVersion' ) );

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $onimportcontroller = array( 'parameters' => array( 'file' ) );

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $onimportmodel  = array( 'parameters' => array( 'file' ) );

	/**
	* put your comment there...
	*
	* @var mixed
	*/
	protected $onload = array( 'parameters' => array( 'instance' ) );

	/**
	* put your comment there...
	*
	*/
	protected function __construct()
    {
		// Hookable!
		parent::__construct();

		// Allow access points to utilize from CJTPlugin functionality
		// even if the call is recursive inside getInstance/construct methods!!!
		self::$instance = $this;

		// Installation version
		$dbVersion = $this->onloaddbversion( get_option( self::DB_VERSION_OPTION_NAME ) );
		$this->installed = ( ( $dbVersion ) == self::DB_VERSION );

		// Load plugin and all installed extensions!.
		$this->load();
		$this->loadExtensions();

		// Run MAIN access point!
		$this->main();
	}

	/**
	* put your comment there...
	*
	*/
	public function & extensions()
    {
		return $this->extensions;
	}

	/**
	* put your comment there...
	*
	*/
	public function getAccessPoint( $name )
    {
		return $this->accessPoints[ $name ];
	}

	/**
	* put your comment there...
	*
	*/
	public static function getInstance()
    {

		if ( ! self::$instance )
        {
			self::$instance = new CJTPlugin();
		}

		return self::$instance;
	}

    /**
    * Check the PHP version and register an admin notice when it is too old.
    *
    * @return bool TRUE when the environment can run the plugin.
    */
    public static function isCompatibleEnvironment()
    {

        if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
        {
            add_action( 'admin_notices', 'cjtIncompatiblePHPNotice' );

            return false;
        }

        return true;
    }
	/**
	* put your comment there...
	*
	*/
	public function isInstalled()
    {
		return $this->installed;
	}

	/**
	* put your comment there...
	*
	*/
	public function listen()
    {
		// For now we've only admin access points! Future versions might has something changed!
		if ( is_admin() )
        {

			// Import access points core classes.
			require_once 'framework/access-points/page.class.php';
			require_once 'framework/access-points/directory-spider.class.php';

			// Get access points!
			$accessPoints = CJTAccessPointsDirectorySpider::getInstance( 'CJT', CJTOOLBOX_ACCESS_POINTS );

			// For every access point create instance and LISTEN to the request!
			foreach ( $accessPoints as $name => $info )
            {
				/**
				* @var CJTAccessPoint
				*/
				$this->accessPoints[ $name ] = $point = $accessPoints->point()->listen();

				// We need to do some work with there is a connected access point.
				$point->onconnected = array( & $this, 'onconnected' );

			}

		}

		return $this;
	}

	/**
	* put your comment there...
	*
	*/
	protected function load()
    {
		// Bootstrap the Plugin!
		cssJSToolbox::getInstance();

		// Load MVC framework core!
		require_once $this->onimportmodel( CJTOOLBOX_MVC_FRAMEWOK . '/model.inc.php' );
		require_once $this->onimportcontroller( CJTOOLBOX_MVC_FRAMEWOK . '/controller.inc.php' );

		return $this;
	}

	/**
	* put your comment there...
	*
	*/
	protected function loadExtensions()
    {
		// Load extensions lib!
		require_once 'framework/extensions/extensions.class.php';

		$this->extensions = new CJTExtensions();
		$this->extensions->load();

		return $this;
	}

	/**
	* Run MAIN access point!
	*
	* @return $this
	*/
	protected function main()
    {
		// Fire laod event
		$this->onload( $this );

		// Access point base class is a dependency!
		require_once 'framework/access-points/access-point.class.php';

		// Run Main Acces Point!
		include_once 'access.points/main.accesspoint.php';

		$this->mainAC = new CJTMainAccessPoint();
		$this->mainAC->listen();
	}

	/**
	* Called When any In-Listen-State (ILS) Access point is
	* connected (called by Wordpress hooking system).
	*
	* @return boolean TRUE.
	*/
	public function onconnected( $observer, $state )
	{
		// Always connect the access point!
		return $state;
	}

}// End Class

/**
* Admin notice shown when the site runs an unsupported PHP version.
*/
function cjtIncompatiblePHPNotice()
{ ?>
	<div class="notice notice-error">
		<p><strong>CJT</strong>: CSS &amp; 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>
		Current PHP Version: <strong><?php echo esc_html( phpversion() ); ?></strong>
		</p>
	</div>
<?php }

// Dont run if environment (e.g PHP version) is incomaptible
if ( ! CJTPlugin::isCompatibleEnvironment() )
{
    return;
}

// Initialize events!
CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );

// Let's Go!
CJTPlugin::getInstance();

add_action( 'upgrader_process_complete', 'upgradeCheck',10, 2 );

function upgradeCheck( $upgrader_object, $options ) {
	// Bulk plugin updates are the only case we care about. Bail early on
	// everything else so we never touch the DB on unrelated upgrades.
	if ( ! isset( $options['action'], $options['type'] ) ) {
		return;
	}

	if ( $options['action'] !== 'update' || $options['type'] !== 'plugin' ) {
		return;
	}

	if ( empty( $options['plugins'] ) || ! is_array( $options['plugins'] ) ) {
		return;
	}

	if ( ! in_array( plugin_basename( __FILE__ ), $options['plugins'], true ) ) {
		return;
	}

	// Only ever record this once.
	if ( ! empty( get_option( '__existing_cjt_user' ) ) ) {
		return;
	}

	global $wpdb;
	$table_name = $wpdb->base_prefix . 'cjtoolbox_blocks';
	$query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );

	update_option( '__existing_cjt_user', $wpdb->get_var( $query ) === $table_name ? 'true' : 'false' );
}

```
