From 8ca330f48faae2c97830c2b03f158ea03bf06402 Mon Sep 17 00:00:00 2001 From: nimrod-cohen Date: Tue, 19 Nov 2024 12:05:35 +0200 Subject: [PATCH] fix bug and add flag and long name --- assets/css/admin.css | 6 ++++++ assets/css/admin.css.map | 2 +- assets/css/admin.scss | 8 ++++++++ assets/js/admin.js | 15 +++++++++++++-- fv-country-blocker.php | 2 +- readme.md | 2 +- 6 files changed, 30 insertions(+), 5 deletions(-) diff --git a/assets/css/admin.css b/assets/css/admin.css index 52a551c..d1b11e4 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -2,6 +2,12 @@ color: red; } +#test-ip img.flag { + width: 16px; + height: 11px; + margin-right: 5px; +} + .fv-country-list { max-height: 400px; overflow-y: scroll; diff --git a/assets/css/admin.css.map b/assets/css/admin.css.map index 94146fd..80e5723 100644 --- a/assets/css/admin.css.map +++ b/assets/css/admin.css.map @@ -1 +1 @@ -{"version":3,"sources":["admin.scss","admin.css"],"names":[],"mappings":"AAAA;EACE,UAAA;ACCF;;ADEA;EACE,iBAAA;EACA,kBAAA;EACA,sBAAA;EACA,aAAA;ACCF;ADCE;EACE,qBAAA;EACA,YAAA;EACA,mBAAA;ACCJ;ADCI;EACE,qBAAA;EACA,YAAA;EACA,mBAAA;ACCN;ADGE;EACE,WAAA;EACA,YAAA;EACA,iBAAA;EACA,sBAAA;ACDJ;ADGI;EACE,WAAA;EACA,YAAA;EACA,iBAAA;ACDN;;ADMA;EACE,WAAA;EACA,gBAAA;ACHF;;ADOE;EACE,gBAAA;EACA,WAAA;EACA,mBAAA;EACA,sBAAA;EACA,iBAAA;ACJJ;;ADQA;EACE,gBAAA;EACA,WAAA;EACA,mBAAA;EACA,sBAAA;EACA,iBAAA;ACLF","file":"admin.css"} \ No newline at end of file +{"version":3,"sources":["admin.scss","admin.css"],"names":[],"mappings":"AAAA;EACE,UAAA;ACCF;;ADGE;EACE,WAAA;EACA,YAAA;EACA,iBAAA;ACAJ;;ADIA;EACE,iBAAA;EACA,kBAAA;EACA,sBAAA;EACA,aAAA;ACDF;ADGE;EACE,qBAAA;EACA,YAAA;EACA,mBAAA;ACDJ;ADGI;EACE,qBAAA;EACA,YAAA;EACA,mBAAA;ACDN;ADKE;EACE,WAAA;EACA,YAAA;EACA,iBAAA;EACA,sBAAA;ACHJ;ADKI;EACE,WAAA;EACA,YAAA;EACA,iBAAA;ACHN;;ADQA;EACE,WAAA;EACA,gBAAA;ACLF;;ADSE;EACE,gBAAA;EACA,WAAA;EACA,mBAAA;EACA,sBAAA;EACA,iBAAA;ACNJ;;ADUA;EACE,gBAAA;EACA,WAAA;EACA,mBAAA;EACA,sBAAA;EACA,iBAAA;ACPF","file":"admin.css"} \ No newline at end of file diff --git a/assets/css/admin.scss b/assets/css/admin.scss index 0a77726..4120adb 100644 --- a/assets/css/admin.scss +++ b/assets/css/admin.scss @@ -2,6 +2,14 @@ color: red; } +#test-ip { + img.flag { + width: 16px; + height: 11px; + margin-right: 5px; + } +} + .fv-country-list { max-height: 400px; overflow-y: scroll; diff --git a/assets/js/admin.js b/assets/js/admin.js index fa5d86e..832aa9e 100644 --- a/assets/js/admin.js +++ b/assets/js/admin.js @@ -103,12 +103,23 @@ document.addEventListener('DOMContentLoaded', () => { }) }); + const capitalize = s => + s + .split(' ') + .map(w => w.charAt(0).toUpperCase() + w.slice(1)) + .join(' '); + const data = await response.json(); const result = document.querySelector('.test-ip-result'); + result.innerHTML = ''; if (data.success) { - result.textContent = data.country; + const country = document.querySelector(`label.country-item[data-code='${data.data.toLowerCase()}']`); + const img = country.querySelector('img'); + const clone = img.cloneNode(true); + result.innerHTML = `${capitalize(country.dataset.longName)}`; + result.insertBefore(clone, result.firstChild); } else { - result.textContent = data.data; + result.textContent = `Failed: ${data.data}`; } } finally { e.target.disabled = false; diff --git a/fv-country-blocker.php b/fv-country-blocker.php index 4bbb039..1bab875 100644 --- a/fv-country-blocker.php +++ b/fv-country-blocker.php @@ -3,7 +3,7 @@ * Plugin Name: FV Country Blocker * Plugin URI: https://github.com/nimrod-cohen/fv-country-blocker * Description: Block visitors from specific countries using MaxMind GeoIP database. - * Version: 1.1.0 + * Version: 1.1.1 * Author: nimrod-cohen * Author URI: https://github.com/nimrod-cohen/fv-country-blocker * License: GPL-2.0+ diff --git a/readme.md b/readme.md index 75641cb..82dda24 100644 --- a/readme.md +++ b/readme.md @@ -4,7 +4,7 @@ Tags: country blocker, IP blocker, geo-blocking, security Requires at least: 5.0 Tested up to: 6.0 Requires PHP: 7.0 -Stable tag: 1.1.0 +Stable tag: 1.1.1 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html