Skip to content

Commit

Permalink
v6.2-a12: * 🐞**Cloud** Fixed a continual new version detection.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hai Zheng committed Mar 15, 2024
1 parent 2bbde09 commit cd115a1
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 29 deletions.
4 changes: 2 additions & 2 deletions litespeed-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Plugin Name: LiteSpeed Cache
* Plugin URI: https://www.litespeedtech.com/products/cache-plugins/wordpress-acceleration
* Description: High-performance page caching and site optimization from LiteSpeed
* Version: 6.2-a11
* Version: 6.2-a12
* Author: LiteSpeed Technologies
* Author URI: https://www.litespeedtech.com
* License: GPLv3
Expand Down Expand Up @@ -34,7 +34,7 @@
return;
}

!defined('LSCWP_V') && define('LSCWP_V', '6.2-a11');
!defined('LSCWP_V') && define('LSCWP_V', '6.2-a12');

!defined('LSCWP_CONTENT_DIR') && define('LSCWP_CONTENT_DIR', WP_CONTENT_DIR);
!defined('LSCWP_DIR') && define('LSCWP_DIR', __DIR__ . '/'); // Full absolute path '/var/www/html/***/wp-content/plugins/litespeed-cache/' or MU
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ The vast majority of plugins and themes are compatible with LiteSpeed Cache. The
* **Cache** PHP v8 warning in page redirection cache ablitity fix. (Issue#617 dcx15)
* **Cloud** Fixed a typo in parsing cloud msg which prevented error messages to show.
* **Cloud** Carried on PHP ver for better version detection purpose.
* 🐞**Cloud** Fixed a continual new version detection.
* **CDN** Auto CDN setup compatibility with WP v5.3-.
* **GUI** Further filtered admin banner messages to prevent from existing danger code in database.
* **REST** Fixed a potential PHP warning in REST check when param is empty. (metikar)
Expand Down
4 changes: 2 additions & 2 deletions src/rest.cls.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ public function is_rest($url = false)
// Debug2::debug( '[Util] is_rest check [base] ', $rest_url );
// Debug2::debug( '[Util] is_rest check [curr] ', $current_url );
// Debug2::debug( '[Util] is_rest check [curr2] ', wp_parse_url( add_query_arg( array( ) ) ) );
if($current_url!==false && !empty($current_url['path']) && $rest_url!==false && !empty($rest_url['path'])){
if ($current_url !== false && !empty($current_url['path']) && $rest_url !== false && !empty($rest_url['path'])) {
return strpos($current_url['path'], $rest_url['path']) === 0;
}

return false;
}
}
52 changes: 27 additions & 25 deletions tpl/banner/new_version.php
Original file line number Diff line number Diff line change
@@ -1,51 +1,53 @@
<?php

namespace LiteSpeed;
defined( 'WPINC' ) || exit;

defined('WPINC') || exit;

/**
* NOTE: Only show for single site
*/
if ( is_multisite() ) {
if (is_multisite()) {
return;
}

if ( $this->conf( Base::O_AUTO_UPGRADE ) ) {
if ($this->conf(Base::O_AUTO_UPGRADE)) {
return;
}

$current = get_site_transient( 'update_plugins' );
if ( ! isset( $current->response[ Core::PLUGIN_FILE ] ) ) {
$current = get_site_transient('update_plugins');
if (!isset($current->response[Core::PLUGIN_FILE])) {
return;
}

$last_check = empty( $this->_summary[ 'new_version.last_check' ] ) ? 0 : $this->_summary[ 'new_version.last_check' ];
$last_check = empty($this->_summary['new_version.last_check']) ? 0 : $this->_summary['new_version.last_check'];
// Check once in a half day
if ( time() - $last_check > 43200 ) {
Admin_Display::save_summary( array( 'new_version.last_check' => time() ) );
if (time() - $last_check > 43200) {
GUI::save_summary(array('new_version.last_check' => time()));

// Detect version
$auto_v = Cloud::version_check( 'new_version_banner' );
if ( ! empty( $auto_v[ 'latest' ] ) ) {
Admin_Display::save_summary( array( 'new_version.v' => $auto_v[ 'latest' ] ) );
$auto_v = Cloud::version_check('new_version_banner');
if (!empty($auto_v['latest'])) {
GUI::save_summary(array('new_version.v' => $auto_v['latest']));
}
// After detect, don't show, just return and show next time
return;
}

if ( ! isset( $this->_summary[ 'new_version.v' ] ) ) {
if (!isset($this->_summary['new_version.v'])) {
return;
}

// Check if current version is newer than auto_v or not
if ( version_compare( Core::VER, $this->_summary[ 'new_version.v' ], '>=' ) ) {
if (version_compare(Core::VER, $this->_summary['new_version.v'], '>=')) {
return;
}

//********** Can show now **********//

$this->_promo_true = true;

if ( $check_only ) {
if ($check_only) {
return;
}

Expand All @@ -54,44 +56,44 @@
<div class="litespeed-banner-promo-logo"></div>

<div class="litespeed-banner-promo-content">
<h3 class="litespeed-banner-title litespeed-top15"><?php echo __( 'LiteSpeed Cache', 'litespeed-cache' ); ?>: <?php echo __( 'New Version Available!', 'litespeed-cache' ); ?></h3>
<h3 class="litespeed-banner-title litespeed-top15"><?php echo __('LiteSpeed Cache', 'litespeed-cache'); ?>: <?php echo __('New Version Available!', 'litespeed-cache'); ?></h3>
<div class="litespeed-banner-description">
<div class="litespeed-banner-description-padding-right-15">
<p class="litespeed-banner-desciption-content">
<?php echo sprintf( __( 'New release %s is available now.', 'litespeed-cache' ), 'v' . $this->_summary[ 'new_version.v' ] ); ?>
<?php echo sprintf(__('New release %s is available now.', 'litespeed-cache'), 'v' . $this->_summary['new_version.v']); ?>
</p>
</div>
<div class="litespeed-row-flex litespeed-banner-description">
<div class="litespeed-banner-description-padding-right-15">
<?php $url = Utility::build_url( Router::ACTION_ACTIVATION, Activation::TYPE_UPGRADE ); ?>
<?php $url = Utility::build_url(Router::ACTION_ACTIVATION, Activation::TYPE_UPGRADE); ?>
<a href="<?php echo $url; ?>" class="button litespeed-btn-success litespeed-btn-mini">
<i class="dashicons dashicons-image-rotate">&nbsp;</i>
<?php echo __( 'Upgrade', 'litespeed-cache' ); ?>
<?php echo __('Upgrade', 'litespeed-cache'); ?>
</a>
</div>
<div class="litespeed-banner-description-padding-right-15">
<?php
$cfg = array( Conf::TYPE_SET . '[' . Base::O_AUTO_UPGRADE . ']' => 1 );
$url = Utility::build_url( Router::ACTION_CONF, Conf::TYPE_SET, false, null, $cfg );
$cfg = array(Conf::TYPE_SET . '[' . Base::O_AUTO_UPGRADE . ']' => 1);
$url = Utility::build_url(Router::ACTION_CONF, Conf::TYPE_SET, false, null, $cfg);
?>
<a href="<?php echo $url; ?>" class="button litespeed-btn-primary litespeed-btn-mini">
<i class="dashicons dashicons-update">&nbsp;</i>
<?php echo __( 'Turn On Auto Upgrade', 'litespeed-cache' ); ?>
<?php echo __('Turn On Auto Upgrade', 'litespeed-cache'); ?>
</a>
</div>
<div class="litespeed-banner-description-padding-right-15">
<?php $url = Utility::build_url( Core::ACTION_DISMISS, GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'new_version' ) ); ?>
<?php $url = Utility::build_url(Core::ACTION_DISMISS, GUI::TYPE_DISMISS_PROMO, false, null, array('promo_tag' => 'new_version')); ?>
<a href="<?php echo $url; ?>" class="button litespeed-btn-warning litespeed-btn-mini">
<?php echo __( 'Maybe Later', 'litespeed-cache' ); ?>
<?php echo __('Maybe Later', 'litespeed-cache'); ?>
</a>
</div>
</div>
</div>
</div>

<div>
<?php $dismiss_url = Utility::build_url( Core::ACTION_DISMISS, GUI::TYPE_DISMISS_PROMO, false, null, array( 'promo_tag' => 'new_version', 'later' => 1 ) ); ?>
<?php $dismiss_url = Utility::build_url(Core::ACTION_DISMISS, GUI::TYPE_DISMISS_PROMO, false, null, array('promo_tag' => 'new_version', 'later' => 1)); ?>
<span class="screen-reader-text">Dismiss this notice.</span>
<a href="<?php echo $dismiss_url; ?>" class="litespeed-notice-dismiss">X</a>
</div>
</div>
</div>

0 comments on commit cd115a1

Please sign in to comment.