From 6c3922b6195e213f3201f44f9979e1f34f200476 Mon Sep 17 00:00:00 2001 From: Ben Everard Date: Mon, 17 Aug 2020 16:12:49 +0100 Subject: [PATCH 1/2] Fixed English translation bug. --- src/Translation.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Translation.php b/src/Translation.php index c822493..b741c72 100644 --- a/src/Translation.php +++ b/src/Translation.php @@ -394,6 +394,10 @@ function getDuplicateOfId($post_id = NULL) { $post_id = get_the_ID(); } + if ( $this->getPostLanguage($post_id) !== $this->getLanguageCode() ) { + return true; + } + if ( ! metadata_exists('post', $post_id, '_icl_lang_duplicate_of') ) { return false; } @@ -415,6 +419,10 @@ function getPostLanguage($post_id = NULL) $post_details = apply_filters('wpml_post_language_details', NULL, $post_id); + if (is_wp_error($post_details)) { + return 'en'; + } + return $post_details['language_code']; } @@ -502,6 +510,10 @@ function translateFilter(string $content, int $post_id, string $key) { // get the original post language $original_language = $this->getPostLanguage($original_id); + if ( ! $original_language ) { + return $content; + } + // return if the original and current languages are the same if ( $original_language === $this->getLanguageCode() ) { return $content; From 6afa1a01780a9926c10892c0f1cda96cdb974049 Mon Sep 17 00:00:00 2001 From: Ben Everard Date: Mon, 17 Aug 2020 16:13:06 +0100 Subject: [PATCH 2/2] Version bump --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d420489..6c25c0e 100755 --- a/README.md +++ b/README.md @@ -3,4 +3,4 @@ The Idea Bureau, WordPresss Foundation A collection of classes to base WordPress theme functionality on -Version 1.0.4 +Version 1.0.5