PluginProbe
CSS & JavaScript Toolbox / 12.0.7
CSS & JavaScript Toolbox v12.0.7
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 +48 -48 1212.0.7 View file →
@@ -2,12 +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: 12.0
6 +Version: 12.0.7
7 7 Author: Wipeout Media
8 -Stable tag: 12.0
9 8 Author URI: https://css-javascript-toolbox.com
9 +Text Domain: css-javascript-toolbox
10 +Domain Path: /locals/languages/
10 11 License:
11 12
12 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.
13 14
@@ -84,13 +85,13 @@
84 85 */
85 86 const DB_VERSION = '1.7';
86 87
87 88 /**
88 - * put your comment there...
89 + * Minimum PHP version required to run the plugin.
89 90 *
90 - * @var mixed
91 + * @var string
91 92 */
92 - CONST ENV_PHP_MIN_VERSION = '5.3';
93 + CONST ENV_PHP_MIN_VERSION = '7.4';
93 94
94 95 /**
95 96 *
96 97 */
@@ -98,9 +99,9 @@
98 99
99 100 /**
100 101 *
101 102 */
102 - const VERSION = '11';
103 + const VERSION = '12.0.7';
103 104
104 105 /**
105 106 *
106 107 */
@@ -232,10 +233,11 @@
232 233 return self::$instance;
233 234 }
234 235
235 236 /**
236 - * put your comment there...
237 + * Check the PHP version and register an admin notice when it is too old.
237 238 *
239 + * @return bool TRUE when the environment can run the plugin.
238 240 */
239 241 public static function isCompatibleEnvironment()
240 242 {
241 243
@@ -240,13 +242,10 @@
240 242 {
241 243
242 244 if ( version_compare( PHP_VERSION, self::ENV_PHP_MIN_VERSION, '<' ) )
243 245 {
246 + add_action( 'admin_notices', 'cjtIncompatiblePHPNotice' );
244 247
245 - $importHTMLFileCode = 'require "includes" . DIRECTORY_SEPARATOR . "html" . DIRECTORY_SEPARATOR . "incompatible_environment_message.html.php";';
246 -
247 - add_action( 'admin_notices', create_function( '', $importHTMLFileCode ) );
248 -
249 248 return false;
250 249 }
251 250
252 251 return true;
@@ -353,21 +352,26 @@
353 352 * @return boolean TRUE.
354 353 */
355 354 public function onconnected( $observer, $state )
356 355 {
357 -
358 - // In all cases that we'll process the request load the localization file.
359 - load_plugin_textdomain( CJTOOLBOX_TEXT_DOMAIN, false, CJTOOLBOX_LANGUAGES );
360 -
361 - do_action( CJTPluggableHelper::ACTION_CJT_TEXT_DOMAIN_LOADED );
362 -
363 - // Always connet the access point!
356 + // Always connect the access point!
364 357 return $state;
365 -
366 358 }
367 359
368 360 }// End Class
369 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 +
370 374 // Dont run if environment (e.g PHP version) is incomaptible
371 375 if ( ! CJTPlugin::isCompatibleEnvironment() )
372 376 {
373 377 return;
@@ -376,42 +380,38 @@
376 380 // Initialize events!
377 381 CJTPlugin::define( 'CJTPlugin', array( 'hookType' => CJTWordpressEvents::HOOK_FILTER ) );
378 382
379 383 // Let's Go!
380 -function deprecatedPHPCheck()
381 -{ ?>
382 - <div class="notice notice-error">
383 - <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>
384 - Current PHP Version: <strong><?php echo phpversion(); ?></strong>
385 - </p>
386 - </div>
387 -<?php }
384 +CJTPlugin::getInstance();
388 385
389 -if ( version_compare( phpversion(), 7, '>=' ) ) {
390 - CJTPlugin::getInstance();
391 -} else {
392 - add_action( 'admin_notices', 'deprecatedPHPCheck' );
393 -}
394 -
395 386 add_action( 'upgrader_process_complete', 'upgradeCheck',10, 2 );
396 387
397 388 function upgradeCheck( $upgrader_object, $options ) {
398 - $CJTPluginPath = plugin_basename( __FILE__ );
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 + }
399 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 +
400 412 global $wpdb;
401 - $table_name = $wpdb->base_prefix.'cjtoolbox_blocks';
413 + $table_name = $wpdb->base_prefix . 'cjtoolbox_blocks';
402 414 $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_name ) );
403 - $preCheck = get_option( '__existing_cjt_user' );
404 415
405 - if ( $options['action'] == 'update' && $options['type'] == 'plugin' ) {
406 - foreach( $options['plugins'] as $each_plugin ) {
407 - if ( $each_plugin == $CJTPluginPath ) {
408 - $preCheck = get_option( '__existing_cjt_user' );
409 -
410 - // Only create it once.
411 - if ( empty( $preCheck ) ) {
412 - update_option( '__existing_cjt_user', $wpdb->get_var( $query ) === $table_name ? 'true' : 'false' );
413 - }
414 - }
415 - }
416 - }
416 + update_option( '__existing_cjt_user', $wpdb->get_var( $query ) === $table_name ? 'true' : 'false' );
417 417 }