From 789d0b160b2c5affaa8ff1467b5ac4c6111dc89e Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 8 Aug 2024 09:25:24 +0600 Subject: [PATCH 1/2] fix: Translation cache not flashing-after-updating-plugin-language-directory-files --- includes/functions.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/includes/functions.php b/includes/functions.php index ff96872e08..5de538ecd2 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -2950,8 +2950,10 @@ function dokan_get_translations_for_plugin_domain( $domain, $language_dir = null * @return array */ function dokan_get_jed_locale_data( $domain, $language_dir = null ) { + $plugin_language_dir = WP_LANG_DIR . '/plugins/'; + // get transient key - $transient_key = sprintf( 'dokan_i18n-%s-%d-%s', $domain, filectime( $language_dir ), get_user_locale() ); + $transient_key = sprintf( 'dokan_i18n-%s-%d-%d-%s', $domain, filectime( $language_dir ), filectime( $plugin_language_dir ), get_user_locale() ); // check if data exists on cache or not $locale = Cache::get_transient( $transient_key ); From a104d51d53308bbd79563c10208b4bfbfc0f24a0 Mon Sep 17 00:00:00 2001 From: Asad Nur Date: Thu, 8 Aug 2024 15:16:20 +0600 Subject: [PATCH 2/2] refactor: Transient key formation for dokan_get_jed_locale_data global function --- includes/functions.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 5de538ecd2..b084168e76 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -2950,10 +2950,12 @@ function dokan_get_translations_for_plugin_domain( $domain, $language_dir = null * @return array */ function dokan_get_jed_locale_data( $domain, $language_dir = null ) { - $plugin_language_dir = WP_LANG_DIR . '/plugins/'; + $plugin_language_dir = WP_LANG_DIR . '/plugins/'; + $language_dir_time = ! empty( $language_dir ) ? filectime( $language_dir ) : 0; + $plugin_language_dir_time = ! empty( $plugin_language_dir ) ? filectime( $plugin_language_dir ) : 0; // get transient key - $transient_key = sprintf( 'dokan_i18n-%s-%d-%d-%s', $domain, filectime( $language_dir ), filectime( $plugin_language_dir ), get_user_locale() ); + $transient_key = sprintf( 'dokan_i18n-%s-%d-%d-%s', $domain, $language_dir_time, $plugin_language_dir_time, get_user_locale() ); // check if data exists on cache or not $locale = Cache::get_transient( $transient_key );