From 0694e288c80b96948732fe9eb3c1f72dfa53dfdc Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Thu, 12 Dec 2024 00:39:26 -0200 Subject: [PATCH 1/5] Prefer use constant time --- inc/api-call/validate-api-key.php | 4 ++-- inc/api-key.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/api-call/validate-api-key.php b/inc/api-call/validate-api-key.php index 3a24be3..7ea93c4 100644 --- a/inc/api-call/validate-api-key.php +++ b/inc/api-call/validate-api-key.php @@ -193,7 +193,7 @@ function wplng_api_call_validate_api_key( $api_key = '' ) { set_transient( 'wplng_api_key_error', $error_message, - 60 * 5 + MINUTE_IN_SECONDS * 5 ); } else { @@ -205,7 +205,7 @@ function wplng_api_call_validate_api_key( $api_key = '' ) { set_transient( 'wplng_api_key_error', __( 'API returned an unexpected response.', 'wplingua' ), - 60 * 5 + MINUTE_IN_SECONDS * 5 ); } diff --git a/inc/api-key.php b/inc/api-key.php index 064db17..7f24650 100644 --- a/inc/api-key.php +++ b/inc/api-key.php @@ -160,7 +160,7 @@ function wplng_get_api_data() { set_transient( 'wplng_api_key_data', wp_json_encode( $data_checked ), - 60 * 60 * 12 + HOUR_IN_SECONDS * 12 ); } From 10ee0d88803e461e5d335c944cd0fccb045af221 Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Thu, 12 Dec 2024 00:48:07 -0200 Subject: [PATCH 2/5] Optimize DB fo cache transient --- inc/slug.php | 3 ++- inc/translation.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/inc/slug.php b/inc/slug.php index 28fb510..e293a18 100644 --- a/inc/slug.php +++ b/inc/slug.php @@ -485,7 +485,8 @@ function wplng_get_slugs_from_query() { } else { set_transient( 'wplng_cached_slugs', - $slugs + $slugs, + MONTH_IN_SECONDS ); } diff --git a/inc/translation.php b/inc/translation.php index b4382c9..6dd950e 100644 --- a/inc/translation.php +++ b/inc/translation.php @@ -189,7 +189,8 @@ function wplng_get_translations_from_query() { set_transient( 'wplng_cached_translations', - $translations + $translations, + MONTH_IN_SECONDS ); return $translations; From 11b8cb175e5506340fc27b9e0ad4e4f57a47cdbc Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Thu, 12 Dec 2024 02:25:18 -0200 Subject: [PATCH 3/5] Switcher in menu: Add option no name displayed --- data.php | 1 + inc/switcher-nav-menu.php | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/data.php b/data.php index 603420b..8ec8161 100644 --- a/data.php +++ b/data.php @@ -460,6 +460,7 @@ function wplng_data_switcher_nav_menu_valid_name_format() { 'o' => __( 'Original name', 'wplingua' ), 't' => __( 'Translated name', 'wplingua' ), 'i' => __( 'Language ID', 'wplingua' ), + 'n' => __( 'No display', 'wplingua' ), ); } diff --git a/inc/switcher-nav-menu.php b/inc/switcher-nav-menu.php index 8f2eda9..0ca20a4 100644 --- a/inc/switcher-nav-menu.php +++ b/inc/switcher-nav-menu.php @@ -47,6 +47,11 @@ function wplng_switcher_nav_menu_args_from_href( $href ) { return false; } + // Check if names or fags are displayed + if ( 'n' === $match[1] && 'n' === $match[2] ) { + $match[1] = 'o'; + } + // Return the $args array checked return array( @@ -166,9 +171,13 @@ function wplng_switcher_nav_menu_replace_items( $items ) { ); break; - default: // case 'i' + case 'i': $title = strtoupper( $language_current_id ); break; + + default: // case 'n' + $title = ''; + break; } $new_item->ID = 'wplng-language-' . $language_current_id; @@ -217,9 +226,13 @@ function wplng_switcher_nav_menu_replace_items( $items ) { ); break; - default: // case 'i' + case 'i': $title = strtoupper( $language_website['id'] ); break; + + default: // case 'n' + $title = ''; + break; } $new_item->ID = 'wplng-language-' . $language_website['id']; @@ -286,9 +299,13 @@ function wplng_switcher_nav_menu_replace_items( $items ) { ); break; - default: // case 'i' + case 'i': // case 'i' $title = strtoupper( $language_target['id'] ); break; + + default: // case 'n' + $title = ''; + break; } $new_item->ID = 'wplng-language-' . $language_target['id']; From a8496ae16add057c534d8e267ba76564979c87fc Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Sun, 15 Dec 2024 18:26:45 -0200 Subject: [PATCH 4/5] Readme review --- readme.txt | 2 +- wplingua.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index b769fff..c00e67e 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,5 @@ === wpLingua - Automatic translation - Translate and make website multilingual === -Contributors: wpr0ck, lyly13 +Contributors: wpr0ck, lyly13, wplingua Donate link: https://wplingua.com/ Tags: translate, translation, multilingual, localization, language Requires at least: 6.0 diff --git a/wplingua.php b/wplingua.php index 34b3f5f..e2e66c7 100644 --- a/wplingua.php +++ b/wplingua.php @@ -3,7 +3,7 @@ * Plugin Name: wpLingua * Plugin URI: https://wplingua.com/ * Description: An all-in-one solution that makes your websites multilingual and translates them automatically, without word or page limits. The highlights: a free first language, an on-page visual editor for editing translations, a customizable language switcher, search engine optimization (SEO), self-hosted data and more! - * Author: wpLingua Team + * Author: wpLingua Translation Service * Author URI: https://wplingua.com/ * Text Domain: wplingua * Domain Path: /languages/ From 80d4369953083df3c35be3f56c813e7e467a5936 Mon Sep 17 00:00:00 2001 From: Julien MA Jacob Date: Sun, 15 Dec 2024 22:04:17 -0200 Subject: [PATCH 5/5] Update changelog and version number --- readme.txt | 7 ++++++- wplingua.php | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/readme.txt b/readme.txt index c00e67e..29f4cdd 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://wplingua.com/ Tags: translate, translation, multilingual, localization, language Requires at least: 6.0 Tested up to: 6.7 -Stable tag: 2.1.4 +Stable tag: 2.1.5 Requires PHP: 7.4 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -174,6 +174,11 @@ No, not at the moment but in the meantime, you can easily display the language s == Changelog == += 2.1.5 = + +* New option for switcher in menu: Use only flag +* Optimizing cache for translations and slugs + = 2.1.4 = * Better management of translated slugs diff --git a/wplingua.php b/wplingua.php index e2e66c7..87dd984 100644 --- a/wplingua.php +++ b/wplingua.php @@ -7,7 +7,7 @@ * Author URI: https://wplingua.com/ * Text Domain: wplingua * Domain Path: /languages/ - * Version: 2.1.4 + * Version: 2.1.5 * Requires PHP: 7.4 * License: GPL v2 or later * License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -24,7 +24,7 @@ define( 'WPLNG_API_URL', 'https://api.wplingua.com' ); define( 'WPLNG_API_VERSION', '2.0' ); define( 'WPLNG_API_SSLVERIFY', true ); -define( 'WPLNG_PLUGIN_VERSION', '2.1.4' ); +define( 'WPLNG_PLUGIN_VERSION', '2.1.5' ); define( 'WPLNG_PLUGIN_FILE', plugin_basename( __FILE__ ) ); define( 'WPLNG_PLUGIN_PATH', dirname( __FILE__ ) ); define( 'WPLNG_MAX_TRANSLATIONS', 256 );