PluginProbe
CSS & JavaScript Toolbox / trunk
CSS & JavaScript Toolbox vtrunk
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
← All changes | css-js-toolbox.php +56 -31 11trunk View file →
@@ -2,11 +2,13 @@
2 2 /*
3 3 Plugin Name: CSS & JavaScript Toolbox
4 4 Plugin URI: https://css-javascript-toolbox.com/
5 5 Description: Easily add CSS, JavaScript, HTML and PHP code to unique CJT code blocks and assign them anywhere on your website.
6 -Version: 11
6 +Version: 12.0.7
7 7 Author: Wipeout Media
8 8 Author URI: https://css-javascript-toolbox.com
9 +Text Domain: css-javascript-toolbox
10 +Domain Path: /locals/languages/
9 11 License:
10 12
11 13 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.
12 14
@@ -83,13 +85,13 @@
83 85 */
84 86 const DB_VERSION = '1.7';
85 87
86 88 /**
87 - * put your comment there...
89 + * Minimum PHP version required to run the plugin.
88 90 *
89 - * @var mixed
91 + * @var string
90 92 */
91 - CONST ENV_PHP_MIN_VERSION = '5.3';
93 + CONST ENV_PHP_MIN_VERSION = '7.4';
92 94
93 95 /**
94 96 *
95 97 */
@@ -97,9 +99,9 @@
97 99
98 100 /**
99 101 *
100 102 */
101 - const VERSION = '11';
103 + const VERSION = '12.0.7';
102 104
103 105 /**
104 106 *
105 107 */
@@ -231,10 +233,11 @@
231 233 return self::$instance;
232 234 }
233 235
234 236 /**
235 - * put your comment there...
237 + * Check the PHP version and register an admin notice when it is too old.
236 238 *
239 + * @return bool TRUE when the environment can run the plugin.
237 240 */
238 241 public static function isCompatibleEnvironment()
239 242 {
240 243
@@ -239,13 +242,10 @@
239 242 {
240 243
241 244 if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
242 245 {
246 + add_action( 'admin_notices', 'cjtIncompatiblePHPNotice' );
243 247
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;
@@ -352,21 +352,26 @@
352 352 * @return boolean TRUE.
353 353 */
354 354 public function onconnected( $observer, $state )
355 355 {
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!
356 + // Always connect the access point!
363 357 return $state;
364 -
365 358 }
366 359
367 360 }// End Class
368 361
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 &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>
369 + Current PHP Version: <strong><?php echo esc_html( phpversion() ); ?></strong>
370 + </p>
371 + </div>
372 +<?php }
373 +
369 374 // Dont run if environment (e.g PHP version) is incomaptible
370 375 if ( ! CJTPlugin::isCompatibleEnvironment() )
371 376 {
372 377 return;
@@ -375,18 +380,38 @@
375 380 // Initialize events!
376 381 CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
377 382
378 383 // Let's Go!
379 -function deprecatedPHPCheck()
380 -{ ?>
381 - <div class="notice notice-error">
382 - <p><strong>CJT</strong>: CSS & JavaScript Toolbox need PHP version 7.3 or greater to operate properly. Please ask your hosting provider to update the PHP version.<br>
383 - Current PHP Version: <strong><?php echo phpversion(); ?></strong>
384 - </p>
385 - </div>
386 -<?php }
384 +CJTPlugin::getInstance();
387 385
388 -if ( version_compare( phpversion(), 7, '>=' ) ) {
389 - CJTPlugin::getInstance();
390 -} else {
391 - add_action( 'admin_notices', 'deprecatedPHPCheck' );
392 -}
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 +}