Version Description
(01/02/2021) = * Small fixes following major release
Download this release
Release Info
Developer | remyb92 |
Plugin | Weglot Translate – Translate your WP website |
Version | 3.3.1 |
Comparing to | |
See all releases |
Code changes from version 3.3.0 to 3.3.1
- readme.txt +5 -1
- src/actions/front/class-translate-page-weglot.php +3 -2
- src/services/class-redirect-service-weglot.php +2 -2
- src/services/class-replace-link-service-weglot.php +5 -1
- vendor/autoload.php +1 -1
- vendor/composer/InstalledVersions.php +5 -5
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +5 -5
- vendor/composer/installed.json +6 -6
- vendor/composer/installed.php +5 -5
- vendor/weglot/weglot-php/src/Util/Url.php +14 -3
- weglot.php +2 -2
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: translate, multilingual, language, translation, localization
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 3.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -183,6 +183,10 @@ See changelog for upgrade changes.
|
|
183 |
|
184 |
== Changelog ==
|
185 |
|
|
|
|
|
|
|
|
|
186 |
= 3.3.0 (18/01/2021) =
|
187 |
* Full refacto of the code
|
188 |
* Add: custom language
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.5
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 3.3.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
183 |
|
184 |
== Changelog ==
|
185 |
|
186 |
+
= 3.3.1 (01/02/2021) =
|
187 |
+
* Small fixes following major release
|
188 |
+
|
189 |
+
|
190 |
= 3.3.0 (18/01/2021) =
|
191 |
* Full refacto of the code
|
192 |
* Add: custom language
|
src/actions/front/class-translate-page-weglot.php
CHANGED
@@ -223,10 +223,11 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
223 |
// We initialize the URL here for the first time, the current language might be wrong in case of ajax with the language in a referer because at this time wp_doing_ajax is always false.
|
224 |
$this->current_language = $this->request_url_services->get_current_language();
|
225 |
|
226 |
-
if ( $original_language === $this->current_language
|
227 |
return;
|
228 |
}
|
229 |
-
$_SERVER['REQUEST_URI'] = $this->request_url_services->get_weglot_url()->
|
|
|
230 |
}
|
231 |
|
232 |
/**
|
223 |
// We initialize the URL here for the first time, the current language might be wrong in case of ajax with the language in a referer because at this time wp_doing_ajax is always false.
|
224 |
$this->current_language = $this->request_url_services->get_current_language();
|
225 |
|
226 |
+
if ( $original_language === $this->current_language ) {
|
227 |
return;
|
228 |
}
|
229 |
+
$_SERVER['REQUEST_URI'] = $this->request_url_services->get_weglot_url()->getPathPrefix() .
|
230 |
+
$this->request_url_services->get_weglot_url()->getPathAndQuery();
|
231 |
}
|
232 |
|
233 |
/**
|
src/services/class-redirect-service-weglot.php
CHANGED
@@ -97,7 +97,7 @@ class Redirect_Service_Weglot {
|
|
97 |
$destination_languages_external = $this->language_services->get_destination_languages_external( $this->request_url_services->is_allowed_private() );
|
98 |
$browser_language = $this->language_services->get_language_from_internal( $server_lang );
|
99 |
|
100 |
-
if (
|
101 |
in_array( $browser_language->getExternalCode(), $destination_languages_external ) && // phpcs:ignore
|
102 |
$this->language_services->get_original_language() === $this->request_url_services->get_current_language()
|
103 |
) {
|
@@ -106,7 +106,7 @@ class Redirect_Service_Weglot {
|
|
106 |
exit();
|
107 |
}
|
108 |
|
109 |
-
if (
|
110 |
! in_array( $browser_language->getExternalCode(), $destination_languages_external ) // phpcs:ignore
|
111 |
&& $browser_language !== $this->language_services->get_original_language()
|
112 |
&& $this->language_services->get_original_language() === $this->request_url_services->get_current_language()
|
97 |
$destination_languages_external = $this->language_services->get_destination_languages_external( $this->request_url_services->is_allowed_private() );
|
98 |
$browser_language = $this->language_services->get_language_from_internal( $server_lang );
|
99 |
|
100 |
+
if ( isset($browser_language) &&
|
101 |
in_array( $browser_language->getExternalCode(), $destination_languages_external ) && // phpcs:ignore
|
102 |
$this->language_services->get_original_language() === $this->request_url_services->get_current_language()
|
103 |
) {
|
106 |
exit();
|
107 |
}
|
108 |
|
109 |
+
if ( isset($browser_language) &&
|
110 |
! in_array( $browser_language->getExternalCode(), $destination_languages_external ) // phpcs:ignore
|
111 |
&& $browser_language !== $this->language_services->get_original_language()
|
112 |
&& $this->language_services->get_original_language() === $this->request_url_services->get_current_language()
|
src/services/class-replace-link-service-weglot.php
CHANGED
@@ -49,7 +49,11 @@ class Replace_Link_Service_Weglot {
|
|
49 |
* @return string
|
50 |
*/
|
51 |
public function replace_url( $url, $language ) {
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
}
|
54 |
|
55 |
/**
|
49 |
* @return string
|
50 |
*/
|
51 |
public function replace_url( $url, $language ) {
|
52 |
+
$replaced_url = $this->request_url_services->create_url_object( $url )->getForLanguage( $language );
|
53 |
+
if($replaced_url)
|
54 |
+
return $replaced_url;
|
55 |
+
else
|
56 |
+
return $url;
|
57 |
}
|
58 |
|
59 |
/**
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInit5b4fed4d41063bcd672b0df22fbd5f1e::getLoader();
|
vendor/composer/InstalledVersions.php
CHANGED
@@ -29,7 +29,7 @@ private static $installed = array (
|
|
29 |
'aliases' =>
|
30 |
array (
|
31 |
),
|
32 |
-
'reference' => '
|
33 |
'name' => 'weglot/translate-wordpress',
|
34 |
),
|
35 |
'versions' =>
|
@@ -68,7 +68,7 @@ private static $installed = array (
|
|
68 |
'aliases' =>
|
69 |
array (
|
70 |
),
|
71 |
-
'reference' => '
|
72 |
),
|
73 |
'weglot/translation-definitions' =>
|
74 |
array (
|
@@ -81,12 +81,12 @@ private static $installed = array (
|
|
81 |
),
|
82 |
'weglot/weglot-php' =>
|
83 |
array (
|
84 |
-
'pretty_version' => '1.1.
|
85 |
-
'version' => '1.1.
|
86 |
'aliases' =>
|
87 |
array (
|
88 |
),
|
89 |
-
'reference' => '
|
90 |
),
|
91 |
),
|
92 |
);
|
29 |
'aliases' =>
|
30 |
array (
|
31 |
),
|
32 |
+
'reference' => 'ebf8f5f851495a0cfc74bcfa78e0ac15c954a4de',
|
33 |
'name' => 'weglot/translate-wordpress',
|
34 |
),
|
35 |
'versions' =>
|
68 |
'aliases' =>
|
69 |
array (
|
70 |
),
|
71 |
+
'reference' => 'ebf8f5f851495a0cfc74bcfa78e0ac15c954a4de',
|
72 |
),
|
73 |
'weglot/translation-definitions' =>
|
74 |
array (
|
81 |
),
|
82 |
'weglot/weglot-php' =>
|
83 |
array (
|
84 |
+
'pretty_version' => '1.1.2',
|
85 |
+
'version' => '1.1.2.0',
|
86 |
'aliases' =>
|
87 |
array (
|
88 |
),
|
89 |
+
'reference' => '9e43202ae8b6d9320dca83e8c42d12f067b52671',
|
90 |
),
|
91 |
),
|
92 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -24,15 +24,15 @@ class ComposerAutoloaderInitb3218cce4e3202ba135172f06516602f
|
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
-
spl_autoload_register(array('
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
29 |
-
spl_autoload_unregister(array('
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
-
call_user_func(\Composer\Autoload\
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
@@ -53,19 +53,19 @@ class ComposerAutoloaderInitb3218cce4e3202ba135172f06516602f
|
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
-
$includeFiles = Composer\Autoload\
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
-
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
-
function
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit5b4fed4d41063bcd672b0df22fbd5f1e
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
24 |
|
25 |
require __DIR__ . '/platform_check.php';
|
26 |
|
27 |
+
spl_autoload_register(array('ComposerAutoloaderInit5b4fed4d41063bcd672b0df22fbd5f1e', 'loadClassLoader'), true, true);
|
28 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
29 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit5b4fed4d41063bcd672b0df22fbd5f1e', 'loadClassLoader'));
|
30 |
|
31 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
32 |
if ($useStaticLoader) {
|
33 |
require __DIR__ . '/autoload_static.php';
|
34 |
|
35 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::getInitializer($loader));
|
36 |
} else {
|
37 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
38 |
foreach ($map as $namespace => $path) {
|
53 |
$loader->register(true);
|
54 |
|
55 |
if ($useStaticLoader) {
|
56 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::$files;
|
57 |
} else {
|
58 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
59 |
}
|
60 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
61 |
+
composerRequire5b4fed4d41063bcd672b0df22fbd5f1e($fileIdentifier, $file);
|
62 |
}
|
63 |
|
64 |
return $loader;
|
65 |
}
|
66 |
}
|
67 |
|
68 |
+
function composerRequire5b4fed4d41063bcd672b0df22fbd5f1e($fileIdentifier, $file)
|
69 |
{
|
70 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
71 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
@@ -58,10 +58,10 @@ class ComposerStaticInitb3218cce4e3202ba135172f06516602f
|
|
58 |
public static function getInitializer(ClassLoader $loader)
|
59 |
{
|
60 |
return \Closure::bind(function () use ($loader) {
|
61 |
-
$loader->prefixLengthsPsr4 =
|
62 |
-
$loader->prefixDirsPsr4 =
|
63 |
-
$loader->prefixesPsr0 =
|
64 |
-
$loader->classMap =
|
65 |
|
66 |
}, null, ClassLoader::class);
|
67 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
58 |
public static function getInitializer(ClassLoader $loader)
|
59 |
{
|
60 |
return \Closure::bind(function () use ($loader) {
|
61 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::$prefixLengthsPsr4;
|
62 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::$prefixDirsPsr4;
|
63 |
+
$loader->prefixesPsr0 = ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::$prefixesPsr0;
|
64 |
+
$loader->classMap = ComposerStaticInit5b4fed4d41063bcd672b0df22fbd5f1e::$classMap;
|
65 |
|
66 |
}, null, ClassLoader::class);
|
67 |
}
|
vendor/composer/installed.json
CHANGED
@@ -190,17 +190,17 @@
|
|
190 |
},
|
191 |
{
|
192 |
"name": "weglot/weglot-php",
|
193 |
-
"version": "1.1.
|
194 |
-
"version_normalized": "1.1.
|
195 |
"source": {
|
196 |
"type": "git",
|
197 |
"url": "https://github.com/weglot/weglot-php.git",
|
198 |
-
"reference": "
|
199 |
},
|
200 |
"dist": {
|
201 |
"type": "zip",
|
202 |
-
"url": "https://api.github.com/repos/weglot/weglot-php/zipball/
|
203 |
-
"reference": "
|
204 |
"shasum": ""
|
205 |
},
|
206 |
"require": {
|
@@ -213,7 +213,7 @@
|
|
213 |
"codeception/codeception": "^2.4",
|
214 |
"vlucas/phpdotenv": "^2.4"
|
215 |
},
|
216 |
-
"time": "
|
217 |
"type": "library",
|
218 |
"installation-source": "dist",
|
219 |
"autoload": {
|
190 |
},
|
191 |
{
|
192 |
"name": "weglot/weglot-php",
|
193 |
+
"version": "1.1.2",
|
194 |
+
"version_normalized": "1.1.2.0",
|
195 |
"source": {
|
196 |
"type": "git",
|
197 |
"url": "https://github.com/weglot/weglot-php.git",
|
198 |
+
"reference": "9e43202ae8b6d9320dca83e8c42d12f067b52671"
|
199 |
},
|
200 |
"dist": {
|
201 |
"type": "zip",
|
202 |
+
"url": "https://api.github.com/repos/weglot/weglot-php/zipball/9e43202ae8b6d9320dca83e8c42d12f067b52671",
|
203 |
+
"reference": "9e43202ae8b6d9320dca83e8c42d12f067b52671",
|
204 |
"shasum": ""
|
205 |
},
|
206 |
"require": {
|
213 |
"codeception/codeception": "^2.4",
|
214 |
"vlucas/phpdotenv": "^2.4"
|
215 |
},
|
216 |
+
"time": "2021-02-01T09:03:49+00:00",
|
217 |
"type": "library",
|
218 |
"installation-source": "dist",
|
219 |
"autoload": {
|
vendor/composer/installed.php
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
-
'reference' => '
|
10 |
'name' => 'weglot/translate-wordpress',
|
11 |
),
|
12 |
'versions' =>
|
@@ -45,7 +45,7 @@
|
|
45 |
'aliases' =>
|
46 |
array (
|
47 |
),
|
48 |
-
'reference' => '
|
49 |
),
|
50 |
'weglot/translation-definitions' =>
|
51 |
array (
|
@@ -58,12 +58,12 @@
|
|
58 |
),
|
59 |
'weglot/weglot-php' =>
|
60 |
array (
|
61 |
-
'pretty_version' => '1.1.
|
62 |
-
'version' => '1.1.
|
63 |
'aliases' =>
|
64 |
array (
|
65 |
),
|
66 |
-
'reference' => '
|
67 |
),
|
68 |
),
|
69 |
);
|
6 |
'aliases' =>
|
7 |
array (
|
8 |
),
|
9 |
+
'reference' => 'ebf8f5f851495a0cfc74bcfa78e0ac15c954a4de',
|
10 |
'name' => 'weglot/translate-wordpress',
|
11 |
),
|
12 |
'versions' =>
|
45 |
'aliases' =>
|
46 |
array (
|
47 |
),
|
48 |
+
'reference' => 'ebf8f5f851495a0cfc74bcfa78e0ac15c954a4de',
|
49 |
),
|
50 |
'weglot/translation-definitions' =>
|
51 |
array (
|
58 |
),
|
59 |
'weglot/weglot-php' =>
|
60 |
array (
|
61 |
+
'pretty_version' => '1.1.2',
|
62 |
+
'version' => '1.1.2.0',
|
63 |
'aliases' =>
|
64 |
array (
|
65 |
),
|
66 |
+
'reference' => '9e43202ae8b6d9320dca83e8c42d12f067b52671',
|
67 |
),
|
68 |
),
|
69 |
);
|
vendor/weglot/weglot-php/src/Util/Url.php
CHANGED
@@ -279,10 +279,21 @@ class Url
|
|
279 |
|
280 |
//We need to change the path to the original path if there are custom URL
|
281 |
if(isset($this->customUrls[$this->currentLanguage->getInternalCode()])) {
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
}
|
|
|
286 |
}
|
287 |
|
288 |
$url = $this->getHost() . $this->getPathPrefix() . $this->getPath();
|
279 |
|
280 |
//We need to change the path to the original path if there are custom URL
|
281 |
if(isset($this->customUrls[$this->currentLanguage->getInternalCode()])) {
|
282 |
+
$slugs = explode('/', $this->path);
|
283 |
+
foreach ($slugs as $k => $slug) {
|
284 |
+
if(empty($slug))
|
285 |
+
continue;
|
286 |
+
|
287 |
+
foreach( $this->customUrls[$this->currentLanguage->getInternalCode()] as $translatedURL => $originalURL ) {
|
288 |
+
if($slug === $originalURL) {
|
289 |
+
$slugs[$k] = 404; //If we receive a not translated slug we return a 404. For example if we have /fr/products but should have /fr/produits we should have a 404
|
290 |
+
}
|
291 |
+
if($slug === $translatedURL) {
|
292 |
+
$slugs[$k] = $originalURL;
|
293 |
+
}
|
294 |
+
}
|
295 |
}
|
296 |
+
$this->path = implode('/' , $slugs);
|
297 |
}
|
298 |
|
299 |
$url = $this->getHost() . $this->getPathPrefix() . $this->getPath();
|
weglot.php
CHANGED
@@ -7,7 +7,7 @@ Author: Weglot Translate team
|
|
7 |
Author URI: https://weglot.com/
|
8 |
Text Domain: weglot
|
9 |
Domain Path: /languages/
|
10 |
-
Version: 3.3.
|
11 |
*/
|
12 |
|
13 |
/**
|
@@ -22,7 +22,7 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
22 |
define( 'WEGLOT_NAME', 'Weglot' );
|
23 |
define( 'WEGLOT_SLUG', 'weglot-translate' );
|
24 |
define( 'WEGLOT_OPTION_GROUP', 'group-weglot-translate' );
|
25 |
-
define( 'WEGLOT_VERSION', '3.3.
|
26 |
define( 'WEGLOT_PHP_MIN', '5.4' );
|
27 |
define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
|
28 |
define( 'WEGLOT_DIR', __DIR__ );
|
7 |
Author URI: https://weglot.com/
|
8 |
Text Domain: weglot
|
9 |
Domain Path: /languages/
|
10 |
+
Version: 3.3.1
|
11 |
*/
|
12 |
|
13 |
/**
|
22 |
define( 'WEGLOT_NAME', 'Weglot' );
|
23 |
define( 'WEGLOT_SLUG', 'weglot-translate' );
|
24 |
define( 'WEGLOT_OPTION_GROUP', 'group-weglot-translate' );
|
25 |
+
define( 'WEGLOT_VERSION', '3.3.1' );
|
26 |
define( 'WEGLOT_PHP_MIN', '5.4' );
|
27 |
define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
|
28 |
define( 'WEGLOT_DIR', __DIR__ );
|