From f8219f5acbeee2d845b2ec8301fc709c847cdf0e Mon Sep 17 00:00:00 2001 From: eug-L Date: Thu, 12 Nov 2026 11:11:03 +0800 Subject: [PATCH 1/2] fix: run only pending upgrades and record current plugin version The upgrade manager stored each upgrade's version instead of the current plugin version, so tawkto-version stayed at 0.9.0 and the upgrades re-ran on every request. The 0.9.0 upgrade then reset the Javascript API key, breaking Secure Mode for logged-in visitors. - Only run upgrades newer than the stored version and up to the current one - Store the current plugin version once after the upgrades run - Only initialise the security option in the 0.9.0 upgrade if it is missing - Add 0.9.4 changelog entry --- tawkto/readme.txt | 4 ++++ tawkto/upgrade.manager.php | 20 ++++++++------------ tawkto/upgrades/version.090.php | 4 +++- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tawkto/readme.txt b/tawkto/readme.txt index ec9ee80..a7bd100 100644 --- a/tawkto/readme.txt +++ b/tawkto/readme.txt @@ -71,6 +71,10 @@ Note: You will need a free tawk.to account: [Create one for free here!](https:// == Changelog == += 0.9.4 = +* Supported version bump to 7.1 +* Fix Javascript API key being reset after plugin update + = 0.9.3 = * Supported version bump to 6.9 diff --git a/tawkto/upgrade.manager.php b/tawkto/upgrade.manager.php index 7f7af50..ebf81e1 100644 --- a/tawkto/upgrade.manager.php +++ b/tawkto/upgrade.manager.php @@ -58,21 +58,17 @@ public function start() { return; } - // special case: we've never set the version before. - // All plugins prior to the current version needs the upgrade. - if ( version_compare( $this->prev_ver, $this->curr_ver ) < 0 ) { - // are there upgrade steps depending on how out-of-date? - foreach ( $this->upgrades as $upgrade_ver => $upgrade ) { - // only run upgrades if upgrade version is lower than - // and equal to the current version. - if ( version_compare( $upgrade_ver, $this->curr_ver ) <= 0 ) { - $this->do_upgrade( $upgrade_ver ); - } - - update_option( $this->version_var_name, $upgrade_ver ); + // only run upgrades newer than the previously installed version and + // up to the current version. If the version was never recorded, + // prev_ver is empty and every upgrade runs. + foreach ( $this->upgrades as $upgrade_ver => $upgrade ) { + if ( version_compare( $upgrade_ver, $this->prev_ver ) > 0 && + version_compare( $upgrade_ver, $this->curr_ver ) <= 0 ) { + $this->do_upgrade( $upgrade_ver ); } } + update_option( $this->version_var_name, $this->curr_ver ); } /** diff --git a/tawkto/upgrades/version.090.php b/tawkto/upgrades/version.090.php index 2c41eeb..c85350a 100644 --- a/tawkto/upgrades/version.090.php +++ b/tawkto/upgrades/version.090.php @@ -25,6 +25,8 @@ public static function upgrade() { update_option( TawkTo_Settings::TAWK_VISIBILITY_OPTIONS, $visibility ); } - update_option( TawkTo_Settings::TAWK_SECURITY_OPTIONS, array( 'js_api_key' => '' ) ); + if ( ! get_option( TawkTo_Settings::TAWK_SECURITY_OPTIONS, false ) ) { + update_option( TawkTo_Settings::TAWK_SECURITY_OPTIONS, array( 'js_api_key' => '' ) ); + } } } From c44d5b5b0c8233d198b945a2e10c7d11fd4b581d Mon Sep 17 00:00:00 2001 From: eug-L Date: Thu, 12 Nov 2026 12:39:19 +0800 Subject: [PATCH 2/2] chore: Bump versions to 0.9.5 - Move the Javascript API key fix to the 0.9.5 changelog entry - Refresh composer.lock content-hash --- composer.json | 2 +- composer.lock | 2 +- package-lock.json | 2 +- package.json | 2 +- tawkto/readme.txt | 6 ++++-- tawkto/tawkto.php | 2 +- tawkto/templates/widget.php | 4 ++-- 7 files changed, 11 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index fd14953..5659c12 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Wordpress plugin for tawk.to", "type": "project", "license": "GPL-3.0", - "version": "0.9.4", + "version": "0.9.5", "require": { "tawk/url-utils": "2.0.1" }, diff --git a/composer.lock b/composer.lock index b6abd8b..bb4ae98 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "cdc366926c7feaedafc83315708262e0", + "content-hash": "e2d0c8c93a2e744310ebcac698cd3832", "packages": [ { "name": "tawk/url-utils", diff --git a/package-lock.json b/package-lock.json index cc4fe40..69ed99c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tawk-wordpress", - "version": "0.9.4", + "version": "0.9.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index fa026de..6b29a6b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tawk-wordpress", - "version": "0.9.4", + "version": "0.9.5", "description": "tawk.to wordpress plugin", "main": "index.js", "directories": { diff --git a/tawkto/readme.txt b/tawkto/readme.txt index a7bd100..c537d81 100644 --- a/tawkto/readme.txt +++ b/tawkto/readme.txt @@ -4,7 +4,7 @@ Tags: tawk.to,tawk,free live chat,ai chat,chat widget Requires at least: 2.7 Requires PHP: 5.6 Tested up to: 7.1 -Stable tag: 0.9.4 +Stable tag: 0.9.5 License: GPLv3 License URI: https://www.gnu.org/licenses/gpl-3.0.html @@ -71,9 +71,11 @@ Note: You will need a free tawk.to account: [Create one for free here!](https:// == Changelog == += 0.9.5 = +* Fix Javascript API key being reset after plugin update + = 0.9.4 = * Supported version bump to 7.1 -* Fix Javascript API key being reset after plugin update = 0.9.3 = * Supported version bump to 6.9 diff --git a/tawkto/tawkto.php b/tawkto/tawkto.php index 8574f50..19767a4 100644 --- a/tawkto/tawkto.php +++ b/tawkto/tawkto.php @@ -6,7 +6,7 @@ * Plugin Name: Tawk.to Live Chat * Plugin URI: https://www.tawk.to * Description: Embeds Tawk.to live chat widget to your site - * Version: 0.9.4 + * Version: 0.9.5 * Author: Tawkto * Text Domain: tawk-to-live-chat * License: GPLv3 diff --git a/tawkto/templates/widget.php b/tawkto/templates/widget.php index e66f7ee..66ec820 100644 --- a/tawkto/templates/widget.php +++ b/tawkto/templates/widget.php @@ -8,7 +8,7 @@ ?> - + - +