Version Description
(06/03/2019) = * Add : Prevent elementor ajax action on 2.5 * Add : Compatibility with Caldera Forms * Add : Prevent ajax MMP Map * Changed: Improved AJAX translation performance * Bugfix: No translate link on weglot menu item * Bugfix: meta og facebook * Bugfix: prevent undefined index on widget
Download this release
Release Info
Developer | remyb92 |
Plugin | Weglot Translate – Translate your WP website |
Version | 2.6.0 |
Comparing to | |
See all releases |
Code changes from version 2.5.0 to 2.6.0
- bootstrap.php +3 -0
- composer.json +2 -1
- readme.txt +11 -2
- src/actions/front/class-search-weglot.php +1 -1
- src/actions/front/class-translate-page-weglot.php +5 -1
- src/domcheckers/class-meta-facebook-image.php +1 -1
- src/helpers/class-helper-json-inline-weglot.php +17 -0
- src/helpers/class-helper-keys-json-weglot.php +7 -3
- src/services/class-option-service-weglot.php +1 -0
- src/services/class-other-translate-service-weglot.php +0 -1
- src/services/class-translate-json-service.php +238 -0
- src/services/class-translate-service-weglot.php +16 -67
- src/third/calderaforms/class-caldera-active.php +38 -0
- src/third/calderaforms/class-caldera-translate.php +55 -0
- src/third/ninjaforms/class-ninja-translate-json-weglot.php +0 -1
- src/third/woocommerce/class-wc-filter-urls-weglot.php +6 -1
- src/third/woocommerce/class-wc-translate-weglot.php +0 -1
- src/widgets/class-widget-selector-weglot.php +2 -2
- vendor/autoload.php +1 -1
- vendor/composer/autoload_namespaces.php +2 -0
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +18 -4
- vendor/composer/installed.json +50 -0
- vendor/galbar/jsonpath +1 -0
- weglot-functions.php +1 -1
- weglot.php +2 -2
bootstrap.php
CHANGED
@@ -51,6 +51,8 @@ abstract class Context_Weglot {
|
|
51 |
'\WeglotWP\Third\NinjaForms\Ninja_Active_Weglot',
|
52 |
'\WeglotWP\Third\NinjaForms\Ninja_Translate_Json_Weglot',
|
53 |
'\WeglotWP\Third\Amp\Amp_Service_Weglot',
|
|
|
|
|
54 |
'\WeglotWP\Services\User_Api_Service_Weglot',
|
55 |
'\WeglotWP\Services\Other_Translate_Service_Weglot',
|
56 |
'\WeglotWP\Services\Dom_Checkers_Service_Weglot',
|
@@ -61,6 +63,7 @@ abstract class Context_Weglot {
|
|
61 |
'\WeglotWP\Services\Private_Language_Service_Weglot',
|
62 |
'\WeglotWP\Services\Href_Lang_Service_Weglot',
|
63 |
'\WeglotWP\Services\Menu_Options_Service_Weglot',
|
|
|
64 |
];
|
65 |
|
66 |
self::$context->set_services( $services );
|
51 |
'\WeglotWP\Third\NinjaForms\Ninja_Active_Weglot',
|
52 |
'\WeglotWP\Third\NinjaForms\Ninja_Translate_Json_Weglot',
|
53 |
'\WeglotWP\Third\Amp\Amp_Service_Weglot',
|
54 |
+
'\WeglotWP\Third\CalderaForms\Caldera_Translate',
|
55 |
+
'\WeglotWP\Third\CalderaForms\Caldera_Active',
|
56 |
'\WeglotWP\Services\User_Api_Service_Weglot',
|
57 |
'\WeglotWP\Services\Other_Translate_Service_Weglot',
|
58 |
'\WeglotWP\Services\Dom_Checkers_Service_Weglot',
|
63 |
'\WeglotWP\Services\Private_Language_Service_Weglot',
|
64 |
'\WeglotWP\Services\Href_Lang_Service_Weglot',
|
65 |
'\WeglotWP\Services\Menu_Options_Service_Weglot',
|
66 |
+
'\WeglotWP\Services\Translate_Json_Service',
|
67 |
];
|
68 |
|
69 |
self::$context->set_services( $services );
|
composer.json
CHANGED
@@ -13,7 +13,8 @@
|
|
13 |
}
|
14 |
],
|
15 |
"require": {
|
16 |
-
"weglot/weglot-php": "^0.5"
|
|
|
17 |
},
|
18 |
"require-dev": {
|
19 |
"squizlabs/php_codesniffer": "*",
|
13 |
}
|
14 |
],
|
15 |
"require": {
|
16 |
+
"weglot/weglot-php": "^0.5",
|
17 |
+
"galbar/jsonpath": "dev-master"
|
18 |
},
|
19 |
"require-dev": {
|
20 |
"squizlabs/php_codesniffer": "*",
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: remyb92, gmulti, wysija
|
3 |
Tags: translate,translation,language,multilingual,bilingual,international,localization,multilanguage,multi language,translations,translator,multilangues,traduction,traducteur,ubersetzung,mehrsprachig,traduccion,traduzione,vertaling,vertaler,meertalig
|
4 |
Requires at least: 4.5
|
5 |
-
Tested up to: 5.
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -153,6 +153,15 @@ See changelog for upgrade changes.
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
= 2.5.0 (07/02/2019) =
|
157 |
* Add : Compatibility with Ninja Forms
|
158 |
* Add : DOM Checker on input type reset
|
2 |
Contributors: remyb92, gmulti, wysija
|
3 |
Tags: translate,translation,language,multilingual,bilingual,international,localization,multilanguage,multi language,translations,translator,multilangues,traduction,traducteur,ubersetzung,mehrsprachig,traduccion,traduzione,vertaling,vertaler,meertalig
|
4 |
Requires at least: 4.5
|
5 |
+
Tested up to: 5.1
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 2.6.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 2.6.0 (06/03/2019) =
|
157 |
+
* Add : Prevent elementor ajax action on 2.5
|
158 |
+
* Add : Compatibility with Caldera Forms
|
159 |
+
* Add : Prevent ajax MMP Map
|
160 |
+
* Changed: Improved AJAX translation performance
|
161 |
+
* Bugfix: No translate link on weglot menu item
|
162 |
+
* Bugfix: meta og facebook
|
163 |
+
* Bugfix: prevent undefined index on widget
|
164 |
+
|
165 |
= 2.5.0 (07/02/2019) =
|
166 |
* Add : Compatibility with Ninja Forms
|
167 |
* Add : DOM Checker on input type reset
|
src/actions/front/class-search-weglot.php
CHANGED
@@ -62,7 +62,7 @@ class Search_Weglot implements Hooks_Interface_Weglot {
|
|
62 |
|
63 |
try {
|
64 |
$parser = $this->parser_services->get_parser();
|
65 |
-
$this->old_search = $query->query_vars[
|
66 |
$this->new_search = $parser->translate( $query->query_vars[ 's' ], $current_language, $original_language ); //phpcs:ignore
|
67 |
|
68 |
if ( empty( $this->new_search ) ) {
|
62 |
|
63 |
try {
|
64 |
$parser = $this->parser_services->get_parser();
|
65 |
+
$this->old_search = $query->query_vars['s'];
|
66 |
$this->new_search = $parser->translate( $query->query_vars[ 's' ], $current_language, $original_language ); //phpcs:ignore
|
67 |
|
68 |
if ( empty( $this->new_search ) ) {
|
src/actions/front/class-translate-page-weglot.php
CHANGED
@@ -86,6 +86,8 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
86 |
'wpestate_ajax_add_booking', // WP Estate theme
|
87 |
'wpestate_ajax_check_booking_valability', // WP Estate theme
|
88 |
'mailster_get_template', // Mailster Pro,
|
|
|
|
|
89 |
] );
|
90 |
|
91 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
|
@@ -148,12 +150,14 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
148 |
return;
|
149 |
}
|
150 |
|
151 |
-
$file = apply_filters( 'weglot_debug_file', WEGLOT_DIR . '/
|
152 |
|
153 |
if ( defined( 'WEGLOT_DEBUG' ) && WEGLOT_DEBUG && file_exists( $file ) ) {
|
154 |
$this->translate_services->set_original_language( weglot_get_original_language() );
|
155 |
$this->translate_services->set_current_language( $this->request_url_services->get_current_language() );
|
|
|
156 |
echo $this->translate_services->weglot_treat_page( file_get_contents( $file ) ); //phpcs:ignore
|
|
|
157 |
} else {
|
158 |
$this->translate_services->weglot_translate();
|
159 |
}
|
86 |
'wpestate_ajax_add_booking', // WP Estate theme
|
87 |
'wpestate_ajax_check_booking_valability', // WP Estate theme
|
88 |
'mailster_get_template', // Mailster Pro,
|
89 |
+
'mmp_map_settings', // MMP Map,
|
90 |
+
'elementor_ajax', // Elementor since 2.5
|
91 |
] );
|
92 |
|
93 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
|
150 |
return;
|
151 |
}
|
152 |
|
153 |
+
$file = apply_filters( 'weglot_debug_file', WEGLOT_DIR . '/tests/templates/wp-api-posts.json' );
|
154 |
|
155 |
if ( defined( 'WEGLOT_DEBUG' ) && WEGLOT_DEBUG && file_exists( $file ) ) {
|
156 |
$this->translate_services->set_original_language( weglot_get_original_language() );
|
157 |
$this->translate_services->set_current_language( $this->request_url_services->get_current_language() );
|
158 |
+
header( 'Content-Type: application/json' );
|
159 |
echo $this->translate_services->weglot_treat_page( file_get_contents( $file ) ); //phpcs:ignore
|
160 |
+
die;
|
161 |
} else {
|
162 |
$this->translate_services->weglot_translate();
|
163 |
}
|
src/domcheckers/class-meta-facebook-image.php
CHANGED
@@ -15,7 +15,7 @@ class Meta_Facebook_Image extends AbstractDomChecker {
|
|
15 |
/**
|
16 |
* {@inheritdoc}
|
17 |
*/
|
18 |
-
const DOM = "meta[
|
19 |
/**
|
20 |
* {@inheritdoc}
|
21 |
*/
|
15 |
/**
|
16 |
* {@inheritdoc}
|
17 |
*/
|
18 |
+
const DOM = "meta[property='og:image'], meta[property='og:image:secure_url']";
|
19 |
/**
|
20 |
* {@inheritdoc}
|
21 |
*/
|
src/helpers/class-helper-json-inline-weglot.php
CHANGED
@@ -55,4 +55,21 @@ abstract class Helper_Json_Inline_Weglot {
|
|
55 |
public static function is_json( $string ) {
|
56 |
return is_string( $string ) && is_array( \json_decode( $string, true ) ) && ( JSON_ERROR_NONE === \json_last_error() ) ? true : false;
|
57 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
55 |
public static function is_json( $string ) {
|
56 |
return is_string( $string ) && is_array( \json_decode( $string, true ) ) && ( JSON_ERROR_NONE === \json_last_error() ) ? true : false;
|
57 |
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @since 2.3.0
|
61 |
+
*
|
62 |
+
* @param string $string
|
63 |
+
* @return boolean
|
64 |
+
*/
|
65 |
+
public static function is_ajax_html( $string ) {
|
66 |
+
$preg_match_ajax_html = apply_filters( 'weglot_is_ajax_html_regex', '/<(a|div|span|p|i|aside|input|textarea|select|h1|h2|h3|h4|meta|button|form|li|strong|ul|option)/' );
|
67 |
+
$result = preg_match_all( $preg_match_ajax_html, $string, $m, PREG_PATTERN_ORDER );
|
68 |
+
|
69 |
+
if ( isset( $string[0] ) && '{' !== $string[0] && $result && $result >= 1 ) {
|
70 |
+
return true;
|
71 |
+
} else {
|
72 |
+
return false;
|
73 |
+
}
|
74 |
+
}
|
75 |
}
|
src/helpers/class-helper-keys-json-weglot.php
CHANGED
@@ -15,7 +15,11 @@ abstract class Helper_Keys_Json_Weglot {
|
|
15 |
*/
|
16 |
protected static $keys = [
|
17 |
'contact-form-7' => [
|
18 |
-
'message'
|
|
|
|
|
|
|
|
|
19 |
],
|
20 |
];
|
21 |
|
@@ -36,8 +40,8 @@ abstract class Helper_Keys_Json_Weglot {
|
|
36 |
$keys_translate = self::get_keys();
|
37 |
$path = weglot_get_rest_current_url_path();
|
38 |
|
39 |
-
foreach ( $keys_translate as $key_translate => $value) {
|
40 |
-
if ( empty( $key_translate ) || strpos( $path, $key_translate ) === false) {
|
41 |
continue;
|
42 |
}
|
43 |
|
15 |
*/
|
16 |
protected static $keys = [
|
17 |
'contact-form-7' => [
|
18 |
+
'message',
|
19 |
+
],
|
20 |
+
'/' => [
|
21 |
+
'post_title',
|
22 |
+
'rendered',
|
23 |
],
|
24 |
];
|
25 |
|
40 |
$keys_translate = self::get_keys();
|
41 |
$path = weglot_get_rest_current_url_path();
|
42 |
|
43 |
+
foreach ( $keys_translate as $key_translate => $value ) {
|
44 |
+
if ( empty( $key_translate ) || strpos( $path, $key_translate ) === false ) {
|
45 |
continue;
|
46 |
}
|
47 |
|
src/services/class-option-service-weglot.php
CHANGED
@@ -96,6 +96,7 @@ class Option_Service_Weglot {
|
|
96 |
$exclude_blocks[] = '#wpadminbar';
|
97 |
$exclude_blocks[] = '#query-monitor';
|
98 |
$exclude_blocks[] = '.menu-item-weglot';
|
|
|
99 |
|
100 |
return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
|
101 |
}
|
96 |
$exclude_blocks[] = '#wpadminbar';
|
97 |
$exclude_blocks[] = '#query-monitor';
|
98 |
$exclude_blocks[] = '.menu-item-weglot';
|
99 |
+
$exclude_blocks[] = '.menu-item-weglot a';
|
100 |
|
101 |
return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
|
102 |
}
|
src/services/class-other-translate-service-weglot.php
CHANGED
@@ -6,7 +6,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
-
use Weglot\Client\Api\WordCollection;
|
10 |
use Weglot\Client\Api\WordEntry;
|
11 |
use Weglot\Client\Api\Enum\WordType;
|
12 |
use Weglot\Client\Client;
|
6 |
exit;
|
7 |
}
|
8 |
|
|
|
9 |
use Weglot\Client\Api\WordEntry;
|
10 |
use Weglot\Client\Api\Enum\WordType;
|
11 |
use Weglot\Client\Client;
|
src/services/class-translate-json-service.php
ADDED
@@ -0,0 +1,238 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WeglotWP\Services;
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
|
10 |
+
use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
|
11 |
+
|
12 |
+
use Weglot\Client\Api\WordCollection;
|
13 |
+
use Weglot\Client\Api\TranslateEntry;
|
14 |
+
use Weglot\Client\Endpoint\Translate;
|
15 |
+
use Weglot\Client\Api\WordEntry;
|
16 |
+
use Weglot\Client\Api\Enum\WordType;
|
17 |
+
use JsonPath\JsonObject;
|
18 |
+
use Weglot\Parser\ConfigProvider\ServerConfigProvider;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @since 2.6.0
|
22 |
+
*/
|
23 |
+
class Translate_Json_Service {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @since 2.6.0
|
27 |
+
* @var integer
|
28 |
+
*/
|
29 |
+
protected $index = 0;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @since 2.6.0
|
33 |
+
* @var integer
|
34 |
+
*/
|
35 |
+
protected $limit = 0;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @since 2.6.0
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
protected $indexes = [];
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @since 2.6.0
|
45 |
+
* @var array
|
46 |
+
*/
|
47 |
+
protected $collections = [];
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @since 2.6.0
|
51 |
+
*/
|
52 |
+
public function __construct() {
|
53 |
+
$this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
|
54 |
+
$this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
|
55 |
+
$this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @since 2.6.0
|
60 |
+
*
|
61 |
+
* @param array $json
|
62 |
+
* @param string $path
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
protected function check_json_to_translate( $json, $path = '$' ) {
|
66 |
+
foreach ( $json as $key => $val ) {
|
67 |
+
if ( is_array( $val ) ) {
|
68 |
+
if ( is_string( $key ) ) {
|
69 |
+
if ( false === strpos( $key, '.' ) ) {
|
70 |
+
$newpath = "$path.$key";
|
71 |
+
} else {
|
72 |
+
$newpath = sprintf( '%s["%s"]', $path, $key );
|
73 |
+
}
|
74 |
+
} else {
|
75 |
+
$newpath = sprintf( '%s[%s]', $path, $key );
|
76 |
+
}
|
77 |
+
|
78 |
+
$this->check_json_to_translate( $val, $newpath );
|
79 |
+
} else {
|
80 |
+
if ( false === strpos( $key, '.' ) ) {
|
81 |
+
$newpath = "$path.$key";
|
82 |
+
} else {
|
83 |
+
$newpath = sprintf( '%s["%s"]', $path, $key );
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
|
87 |
+
try {
|
88 |
+
$parser = $this->parser_services->get_parser();
|
89 |
+
$words = $parser->parse( $val );
|
90 |
+
if ( ! $words instanceof WordCollection ) {
|
91 |
+
continue;
|
92 |
+
}
|
93 |
+
$this->collections = array_merge( $this->collections, $words->jsonSerialize() );
|
94 |
+
$this->limit = $this->index + $words->count();
|
95 |
+
$this->indexes[ $newpath ] = [
|
96 |
+
'start' => $this->index,
|
97 |
+
'limit' => $this->limit,
|
98 |
+
]; //phpcs:ignore
|
99 |
+
$this->index += $words->count();
|
100 |
+
} catch ( \Exception $e ) {
|
101 |
+
continue;
|
102 |
+
}
|
103 |
+
} else {
|
104 |
+
if ( Helper_Keys_Json_Weglot::translate_key_for_path( $key ) ) {
|
105 |
+
try {
|
106 |
+
$parser = $this->parser_services->get_parser();
|
107 |
+
$words = $parser->parse( $val );
|
108 |
+
if ( ! $words instanceof WordCollection ) {
|
109 |
+
continue;
|
110 |
+
}
|
111 |
+
$this->collections = array_merge( $this->collections, $words->jsonSerialize() );
|
112 |
+
$this->limit = $this->index + $words->count();
|
113 |
+
$this->indexes[ $newpath ] = [
|
114 |
+
'start' => $this->index,
|
115 |
+
'limit' => $this->limit,
|
116 |
+
];
|
117 |
+
$this->index += $words->count();
|
118 |
+
} catch ( \Exception $e ) {
|
119 |
+
continue;
|
120 |
+
}
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
return [
|
127 |
+
$this->indexes,
|
128 |
+
$this->collections,
|
129 |
+
];
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* @since 2.6.0
|
134 |
+
* @param array $json
|
135 |
+
* @return JsonObject
|
136 |
+
*/
|
137 |
+
protected function translate_json_strings( $json ) {
|
138 |
+
$parser = $this->parser_services->get_parser();
|
139 |
+
|
140 |
+
// Translate endpoint parameters
|
141 |
+
$params = [
|
142 |
+
'language_from' => weglot_get_original_language(),
|
143 |
+
'language_to' => weglot_get_current_language(),
|
144 |
+
];
|
145 |
+
|
146 |
+
if ( $parser->getConfigProvider() instanceof ServerConfigProvider ) {
|
147 |
+
$parser->getConfigProvider()->loadFromServer();
|
148 |
+
}
|
149 |
+
|
150 |
+
$params = array_merge( $params, $parser->getConfigProvider()->asArray() );
|
151 |
+
$json_object = new JsonObject( $json );
|
152 |
+
try {
|
153 |
+
$translate = new TranslateEntry( $params );
|
154 |
+
$word_collection = $translate->getInputWords();
|
155 |
+
foreach ( $this->collections as $value ) {
|
156 |
+
$word_collection->addOne( new WordEntry( $value['w'], $value['t'] ) );
|
157 |
+
}
|
158 |
+
} catch ( \Exception $e ) {
|
159 |
+
return $json_object;
|
160 |
+
}
|
161 |
+
|
162 |
+
$translate = new Translate( $translate, $parser->getClient() );
|
163 |
+
$translated = $translate->handle();
|
164 |
+
|
165 |
+
$output_words = $translated->getOutputWords();
|
166 |
+
|
167 |
+
if ( $output_words->count() !== count( $this->collections ) || $output_words->count() === 0 ) {
|
168 |
+
return $json_object;
|
169 |
+
}
|
170 |
+
|
171 |
+
$input_words = $translated->getInputWords();
|
172 |
+
$i = 0;
|
173 |
+
|
174 |
+
foreach ( $this->indexes as $path => $index ) {
|
175 |
+
do {
|
176 |
+
if ( is_null( $input_words[ $i ] ) || is_null( $output_words[ $i ] ) ) {
|
177 |
+
$i++;
|
178 |
+
continue;
|
179 |
+
}
|
180 |
+
|
181 |
+
$input_word = $input_words[ $i ]->getWord();
|
182 |
+
$output_word = $output_words[ $i ]->getWord();
|
183 |
+
$str = $json_object->get( $path )[0];
|
184 |
+
|
185 |
+
$json_object->set( $path, str_replace( $input_word, $output_word, $str ) );
|
186 |
+
$i++;
|
187 |
+
} while ( $i < $index['limit'] );
|
188 |
+
}
|
189 |
+
|
190 |
+
return $json_object;
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
/**
|
195 |
+
* @since 2.6.0
|
196 |
+
* @param array $json
|
197 |
+
* @return array
|
198 |
+
*/
|
199 |
+
public function replace_json_links( $json ) {
|
200 |
+
$replace_urls = apply_filters( 'weglot_ajax_replace_urls', [ 'redirecturl', 'url', 'link' ] );
|
201 |
+
|
202 |
+
foreach ( $json as $key => $val ) {
|
203 |
+
if ( is_array( $val ) ) {
|
204 |
+
$json[ $key ] = $this->replace_json_links( $val );
|
205 |
+
} else {
|
206 |
+
if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
|
207 |
+
$json[ $key ] = $this->replace_url_services->replace_link_in_dom( $val );
|
208 |
+
} else {
|
209 |
+
if ( in_array( $key, $replace_urls, true ) ) {
|
210 |
+
$json[ $key ] = $this->replace_link_services->replace_url( $val );
|
211 |
+
}
|
212 |
+
}
|
213 |
+
}
|
214 |
+
}
|
215 |
+
|
216 |
+
return $json;
|
217 |
+
}
|
218 |
+
|
219 |
+
|
220 |
+
/**
|
221 |
+
* @since 2.6.0
|
222 |
+
* @param array $json
|
223 |
+
* @param mixed $path
|
224 |
+
* @return JsonObject
|
225 |
+
*/
|
226 |
+
public function translate_json( $json ) {
|
227 |
+
$this->check_json_to_translate( $json );
|
228 |
+
$json_object = $this->translate_json_strings( $json );
|
229 |
+
$json = json_decode( $json_object->getJson(), true );
|
230 |
+
|
231 |
+
$json = $this->replace_json_links( $json );
|
232 |
+
|
233 |
+
return $json;
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
|
238 |
+
|
src/services/class-translate-service-weglot.php
CHANGED
@@ -20,15 +20,17 @@ class Translate_Service_Weglot {
|
|
20 |
* @since 2.3.0
|
21 |
*/
|
22 |
public function __construct() {
|
23 |
-
$this->option_services
|
24 |
-
$this->request_url_services
|
25 |
-
$this->replace_url_services
|
26 |
-
$this->replace_link_services
|
27 |
-
$this->parser_services
|
28 |
-
$this->wc_active_services
|
29 |
-
$this->ninja_active_services
|
30 |
-
$this->
|
31 |
-
$this->
|
|
|
|
|
32 |
}
|
33 |
|
34 |
|
@@ -96,13 +98,11 @@ class Translate_Service_Weglot {
|
|
96 |
switch ( $type ) {
|
97 |
case 'json':
|
98 |
$json = \json_decode( $content, true );
|
99 |
-
$content = $this->
|
100 |
-
$content = $this->replace_link_array( $content );
|
101 |
$content = apply_filters( 'weglot_json_treat_page', $content );
|
102 |
|
103 |
return wp_json_encode( $content );
|
104 |
case 'html':
|
105 |
-
$content = $this->fix_menu_link( $content );
|
106 |
$translated_content = $parser->translate( $content, $this->original_language, $this->current_language ); // phpcs:ignore
|
107 |
|
108 |
if ( $this->wc_active_services->is_active() ) {
|
@@ -113,6 +113,10 @@ class Translate_Service_Weglot {
|
|
113 |
// Improve this with multiple service
|
114 |
$translated_content = weglot_get_service( 'Ninja_Translate_Json_Weglot' )->translate_words( $translated_content );
|
115 |
}
|
|
|
|
|
|
|
|
|
116 |
|
117 |
$translated_content = $this->other_translate_services->translate_words( $translated_content );
|
118 |
|
@@ -176,61 +180,6 @@ class Translate_Service_Weglot {
|
|
176 |
return $array;
|
177 |
}
|
178 |
|
179 |
-
/**
|
180 |
-
* Replace links for JSON translate
|
181 |
-
*
|
182 |
-
* @since 2.3.0
|
183 |
-
*
|
184 |
-
* @param array $array
|
185 |
-
* @return array
|
186 |
-
*/
|
187 |
-
public function replace_link_array( $array ) {
|
188 |
-
$array_not_ajax_html = apply_filters( 'weglot_array_not_ajax_html', [ 'redirecturl', 'url' ] );
|
189 |
-
|
190 |
-
foreach ( $array as $key => $val ) {
|
191 |
-
if ( is_array( $val ) ) {
|
192 |
-
$array[ $key ] = $this->replace_link_array( $val );
|
193 |
-
} else {
|
194 |
-
if ( $this->is_ajax_html( $val ) ) {
|
195 |
-
$array[ $key ] = $this->replace_url_services->replace_link_in_dom( $val );
|
196 |
-
}
|
197 |
-
}
|
198 |
-
}
|
199 |
-
|
200 |
-
return $array;
|
201 |
-
}
|
202 |
-
|
203 |
-
/**
|
204 |
-
* @since 2.3.0
|
205 |
-
*
|
206 |
-
* @param string $string
|
207 |
-
* @return boolean
|
208 |
-
*/
|
209 |
-
protected function is_ajax_html( $string ) {
|
210 |
-
$preg_match_ajax_html = apply_filters( 'weglot_is_ajax_html_regex', '/<(a|div|span|p|i|aside|input|textarea|select|h1|h2|h3|h4|meta|button|form|li|strong|ul|option)/' );
|
211 |
-
$result = preg_match_all( $preg_match_ajax_html, $string, $m, PREG_PATTERN_ORDER );
|
212 |
-
|
213 |
-
if ( isset( $string[0] ) && '{' !== $string[0] && $result && $result >= 1 ) {
|
214 |
-
return true;
|
215 |
-
} else {
|
216 |
-
return false;
|
217 |
-
}
|
218 |
-
}
|
219 |
-
|
220 |
-
|
221 |
-
/**
|
222 |
-
* @since 2.3.0.2
|
223 |
-
*
|
224 |
-
* Check if there are Weglot menu links and make sure there is the data-wg-notranslate
|
225 |
-
* @param string $content
|
226 |
-
* @return string
|
227 |
-
*/
|
228 |
-
public function fix_menu_link( $content ) {
|
229 |
-
$content = preg_replace( '#<a([^\>]+?)?href="(http|https):\/\/\[weglot_#', '<a$1 data-wg-notranslate="true" href="$2://[weglot_', $content );
|
230 |
-
|
231 |
-
return $content;
|
232 |
-
}
|
233 |
-
|
234 |
|
235 |
/**
|
236 |
* @since 2.3.0
|
20 |
* @since 2.3.0
|
21 |
*/
|
22 |
public function __construct() {
|
23 |
+
$this->option_services = weglot_get_service( 'Option_Service_Weglot' );
|
24 |
+
$this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
|
25 |
+
$this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
|
26 |
+
$this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
|
27 |
+
$this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
|
28 |
+
$this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
|
29 |
+
$this->ninja_active_services = weglot_get_service( 'Ninja_Active_Weglot' );
|
30 |
+
$this->caldera_active_services = weglot_get_service( 'Caldera_Active' );
|
31 |
+
$this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
|
32 |
+
$this->translate_json_service = weglot_get_service( 'Translate_Json_Service' );
|
33 |
+
$this->generate_switcher_service = weglot_get_service( 'Generate_Switcher_Service_Weglot' );
|
34 |
}
|
35 |
|
36 |
|
98 |
switch ( $type ) {
|
99 |
case 'json':
|
100 |
$json = \json_decode( $content, true );
|
101 |
+
$content = $this->translate_json_service->translate_json( $json );
|
|
|
102 |
$content = apply_filters( 'weglot_json_treat_page', $content );
|
103 |
|
104 |
return wp_json_encode( $content );
|
105 |
case 'html':
|
|
|
106 |
$translated_content = $parser->translate( $content, $this->original_language, $this->current_language ); // phpcs:ignore
|
107 |
|
108 |
if ( $this->wc_active_services->is_active() ) {
|
113 |
// Improve this with multiple service
|
114 |
$translated_content = weglot_get_service( 'Ninja_Translate_Json_Weglot' )->translate_words( $translated_content );
|
115 |
}
|
116 |
+
if ( $this->caldera_active_services->is_active() ) {
|
117 |
+
// Improve this with multiple service
|
118 |
+
$translated_content = weglot_get_service( 'Caldera_Translate' )->translate_words( $translated_content );
|
119 |
+
}
|
120 |
|
121 |
$translated_content = $this->other_translate_services->translate_words( $translated_content );
|
122 |
|
180 |
return $array;
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
/**
|
185 |
* @since 2.3.0
|
src/third/calderaforms/class-caldera-active.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WeglotWP\Third\CalderaForms;
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
use WeglotWP\Models\Third_Active_Interface_Weglot;
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Caldera_Active
|
16 |
+
*
|
17 |
+
* @since 2.6.0
|
18 |
+
*/
|
19 |
+
class Caldera_Active implements Third_Active_Interface_Weglot {
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @since 2.6.0
|
23 |
+
* @return boolean
|
24 |
+
*/
|
25 |
+
public function is_active() {
|
26 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
27 |
+
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
28 |
+
}
|
29 |
+
|
30 |
+
$active = true;
|
31 |
+
|
32 |
+
if ( ! is_plugin_active( 'caldera-forms/caldera-core.php' ) ) {
|
33 |
+
$active = false;
|
34 |
+
}
|
35 |
+
|
36 |
+
return apply_filters( 'weglot_caldera_forms_is_active', $active );
|
37 |
+
}
|
38 |
+
}
|
src/third/calderaforms/class-caldera-translate.php
ADDED
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WeglotWP\Third\CalderaForms;
|
4 |
+
|
5 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
6 |
+
exit;
|
7 |
+
}
|
8 |
+
|
9 |
+
|
10 |
+
use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Caldera_Translate
|
14 |
+
*
|
15 |
+
* @since 2.6.0
|
16 |
+
*/
|
17 |
+
class Caldera_Translate {
|
18 |
+
protected function translate_entries( $dom ) {
|
19 |
+
$parser = weglot_get_service( 'Parser_Service_Weglot' )->get_parser();
|
20 |
+
return $parser->translate( $dom, weglot_get_original_language(), weglot_get_current_language() ); // phpcs:ignore
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @since 2.6.0
|
25 |
+
*
|
26 |
+
* @param string $content
|
27 |
+
* @return array
|
28 |
+
*/
|
29 |
+
protected function translate_script_html_template( $content ) {
|
30 |
+
preg_match_all( '#<script type="text\/html"(.*?)>([\s\S]*)<\/script>#mU', $content, $match );
|
31 |
+
|
32 |
+
if ( ! isset( $match[2] ) || empty( $match[2][0] ) ) {
|
33 |
+
return $content;
|
34 |
+
}
|
35 |
+
|
36 |
+
foreach ( $match[2] as $key => $template_html ) {
|
37 |
+
$dom_translate = $this->translate_entries( $template_html );
|
38 |
+
$content = str_replace( $match[2][$key], $dom_translate, $content );
|
39 |
+
}
|
40 |
+
|
41 |
+
return $content;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @since 2.6.0
|
46 |
+
*
|
47 |
+
* @param string $content
|
48 |
+
* @return string
|
49 |
+
*/
|
50 |
+
public function translate_words( $content ) {
|
51 |
+
$content = $this->translate_script_html_template( $content );
|
52 |
+
|
53 |
+
return $content;
|
54 |
+
}
|
55 |
+
}
|
src/third/ninjaforms/class-ninja-translate-json-weglot.php
CHANGED
@@ -6,7 +6,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
-
use Weglot\Client\Api\WordCollection;
|
10 |
use Weglot\Client\Api\WordEntry;
|
11 |
use Weglot\Client\Api\Enum\WordType;
|
12 |
use Weglot\Client\Client;
|
6 |
exit;
|
7 |
}
|
8 |
|
|
|
9 |
use Weglot\Client\Api\WordEntry;
|
10 |
use Weglot\Client\Api\Enum\WordType;
|
11 |
use Weglot\Client\Client;
|
src/third/woocommerce/class-wc-filter-urls-weglot.php
CHANGED
@@ -29,7 +29,7 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
|
|
29 |
|
30 |
/**
|
31 |
* @since 2.0
|
32 |
-
* @version 2.0
|
33 |
* @see Hooks_Interface_Weglot
|
34 |
*
|
35 |
* @return void
|
@@ -48,6 +48,11 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
|
|
48 |
add_filter( 'woocommerce_login_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
49 |
add_filter( 'woocommerce_registration_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
50 |
add_filter( 'woocommerce_cart_item_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
|
|
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
/**
|
29 |
|
30 |
/**
|
31 |
* @since 2.0
|
32 |
+
* @version 2.6.0
|
33 |
* @see Hooks_Interface_Weglot
|
34 |
*
|
35 |
* @return void
|
48 |
add_filter( 'woocommerce_login_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
49 |
add_filter( 'woocommerce_registration_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
50 |
add_filter( 'woocommerce_cart_item_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
|
51 |
+
|
52 |
+
/**
|
53 |
+
* @since 2.6.0
|
54 |
+
*/
|
55 |
+
add_filter( 'woocommerce_get_cart_page_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
|
56 |
}
|
57 |
|
58 |
/**
|
src/third/woocommerce/class-wc-translate-weglot.php
CHANGED
@@ -6,7 +6,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
-
use Weglot\Client\Api\WordCollection;
|
10 |
use Weglot\Client\Api\WordEntry;
|
11 |
use Weglot\Client\Api\Enum\WordType;
|
12 |
use Weglot\Client\Client;
|
6 |
exit;
|
7 |
}
|
8 |
|
|
|
9 |
use Weglot\Client\Api\WordEntry;
|
10 |
use Weglot\Client\Api\Enum\WordType;
|
11 |
use Weglot\Client\Client;
|
src/widgets/class-widget-selector-weglot.php
CHANGED
@@ -32,8 +32,8 @@ class Widget_Selector_Weglot extends \WP_Widget {
|
|
32 |
if ( ! weglot_current_url_is_eligible() ) {
|
33 |
return;
|
34 |
}
|
35 |
-
|
36 |
-
$title = apply_filters( 'widget_title', $
|
37 |
|
38 |
$tt = ( ! empty( $title ) ) ? $args['before_title'] . $title . $args['after_title'] : '';
|
39 |
|
32 |
if ( ! weglot_current_url_is_eligible() ) {
|
33 |
return;
|
34 |
}
|
35 |
+
$title = (isset($instance['title'])) ? $instance['title'] : '';
|
36 |
+
$title = apply_filters( 'widget_title', $title );
|
37 |
|
38 |
$tt = ( ! empty( $title ) ) ? $args['before_title'] . $title . $args['after_title'] : '';
|
39 |
|
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 ComposerAutoloaderInit329d0bcd8475cb063db4d6c047ac2ecc::getLoader();
|
vendor/composer/autoload_namespaces.php
CHANGED
@@ -7,4 +7,6 @@ $baseDir = dirname($vendorDir);
|
|
7 |
|
8 |
return array(
|
9 |
'WGSimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
|
|
|
|
|
10 |
);
|
7 |
|
8 |
return array(
|
9 |
'WGSimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
|
10 |
+
'Utilities\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar'),
|
11 |
+
'JsonPath\\' => array($vendorDir . '/galbar/jsonpath/src/Galbar'),
|
12 |
);
|
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 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInit329d0bcd8475cb063db4d6c047ac2ecc
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInit329d0bcd8475cb063db4d6c047ac2ecc', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInit329d0bcd8475cb063db4d6c047ac2ecc', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequire329d0bcd8475cb063db4d6c047ac2ecc($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequire329d0bcd8475cb063db4d6c047ac2ecc($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
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',
|
@@ -40,14 +40,28 @@ class ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79
|
|
40 |
0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
|
41 |
),
|
42 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
);
|
44 |
|
45 |
public static function getInitializer(ClassLoader $loader)
|
46 |
{
|
47 |
return \Closure::bind(function () use ($loader) {
|
48 |
-
$loader->prefixLengthsPsr4 =
|
49 |
-
$loader->prefixDirsPsr4 =
|
50 |
-
$loader->prefixesPsr0 =
|
51 |
|
52 |
}, null, ClassLoader::class);
|
53 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
40 |
0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
|
41 |
),
|
42 |
),
|
43 |
+
'U' =>
|
44 |
+
array (
|
45 |
+
'Utilities\\' =>
|
46 |
+
array (
|
47 |
+
0 => __DIR__ . '/..' . '/galbar/jsonpath/src/Galbar',
|
48 |
+
),
|
49 |
+
),
|
50 |
+
'J' =>
|
51 |
+
array (
|
52 |
+
'JsonPath\\' =>
|
53 |
+
array (
|
54 |
+
0 => __DIR__ . '/..' . '/galbar/jsonpath/src/Galbar',
|
55 |
+
),
|
56 |
+
),
|
57 |
);
|
58 |
|
59 |
public static function getInitializer(ClassLoader $loader)
|
60 |
{
|
61 |
return \Closure::bind(function () use ($loader) {
|
62 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc::$prefixLengthsPsr4;
|
63 |
+
$loader->prefixDirsPsr4 = ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc::$prefixDirsPsr4;
|
64 |
+
$loader->prefixesPsr0 = ComposerStaticInit329d0bcd8475cb063db4d6c047ac2ecc::$prefixesPsr0;
|
65 |
|
66 |
}, null, ClassLoader::class);
|
67 |
}
|
vendor/composer/installed.json
CHANGED
@@ -1,4 +1,54 @@
|
|
1 |
[
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
{
|
3 |
"name": "psr/cache",
|
4 |
"version": "1.0.1",
|
1 |
[
|
2 |
+
{
|
3 |
+
"name": "galbar/jsonpath",
|
4 |
+
"version": "dev-master",
|
5 |
+
"version_normalized": "9999999-dev",
|
6 |
+
"source": {
|
7 |
+
"type": "git",
|
8 |
+
"url": "https://github.com/Galbar/JsonPath-PHP.git",
|
9 |
+
"reference": "ea104b4f835388018f4bd529a2dace88617d5be6"
|
10 |
+
},
|
11 |
+
"dist": {
|
12 |
+
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/Galbar/JsonPath-PHP/zipball/ea104b4f835388018f4bd529a2dace88617d5be6",
|
14 |
+
"reference": "ea104b4f835388018f4bd529a2dace88617d5be6",
|
15 |
+
"shasum": ""
|
16 |
+
},
|
17 |
+
"require": {
|
18 |
+
"php": ">=5.4"
|
19 |
+
},
|
20 |
+
"require-dev": {
|
21 |
+
"phpunit/phpunit": "~4.0",
|
22 |
+
"sami/sami": ">=3.3.0",
|
23 |
+
"satooshi/php-coveralls": ">=1.0.1"
|
24 |
+
},
|
25 |
+
"time": "2018-12-11T15:07:59+00:00",
|
26 |
+
"type": "library",
|
27 |
+
"installation-source": "source",
|
28 |
+
"autoload": {
|
29 |
+
"psr-0": {
|
30 |
+
"JsonPath\\": "src/Galbar/",
|
31 |
+
"Utilities\\": "src/Galbar/"
|
32 |
+
}
|
33 |
+
},
|
34 |
+
"notification-url": "https://packagist.org/downloads/",
|
35 |
+
"license": [
|
36 |
+
"Apache-2.0"
|
37 |
+
],
|
38 |
+
"authors": [
|
39 |
+
{
|
40 |
+
"name": "Alessio Linares",
|
41 |
+
"email": "alessio@alessio.cc",
|
42 |
+
"role": "Software Engineer"
|
43 |
+
}
|
44 |
+
],
|
45 |
+
"description": "JSONPath implementation for querying and updating JSON objects",
|
46 |
+
"keywords": [
|
47 |
+
"json",
|
48 |
+
"jsonpath",
|
49 |
+
"path"
|
50 |
+
]
|
51 |
+
},
|
52 |
{
|
53 |
"name": "psr/cache",
|
54 |
"version": "1.0.1",
|
vendor/galbar/jsonpath
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
Subproject commit ea104b4f835388018f4bd529a2dace88617d5be6
|
weglot-functions.php
CHANGED
@@ -241,5 +241,5 @@ function weglot_get_private_languages() {
|
|
241 |
function weglot_get_rest_current_url_path() {
|
242 |
$prefix = rest_get_url_prefix();
|
243 |
$current_url = wp_parse_url( add_query_arg( [] ) );
|
244 |
-
return $current_url['path'];
|
245 |
}
|
241 |
function weglot_get_rest_current_url_path() {
|
242 |
$prefix = rest_get_url_prefix();
|
243 |
$current_url = wp_parse_url( add_query_arg( [] ) );
|
244 |
+
return apply_filters( 'weglot_get_rest_current_url_path', $current_url['path'] );
|
245 |
}
|
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: 2.
|
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', '2.
|
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: 2.6.0
|
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', '2.6.0');
|
26 |
define('WEGLOT_PHP_MIN', '5.4');
|
27 |
define('WEGLOT_BNAME', plugin_basename(__FILE__));
|
28 |
define('WEGLOT_DIR', __DIR__ );
|