Version Description
(09/05/2019) = * Bugfix: Weglot switcher on menu * Add : Translate all JSON-LD
Download this release
Release Info
Developer | remyb92 |
Plugin | Weglot Translate – Translate your WP website |
Version | 3.0.3 |
Comparing to | |
See all releases |
Code changes from version 3.0.2 to 3.0.3
- bootstrap.php +1 -0
- readme.txt +5 -1
- src/actions/admin/class-customize-menu-weglot.php +2 -2
- src/actions/front/class-translate-page-weglot.php +1 -0
- src/services/class-option-service-weglot.php +7 -8
- src/services/class-translate-json-ld.php +303 -0
- src/services/class-translate-service-weglot.php +5 -0
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +4 -4
- vendor/composer/installed.json +4 -4
- vendor/galbar/jsonpath +1 -1
- weglot.php +2 -2
bootstrap.php
CHANGED
@@ -65,6 +65,7 @@ abstract class Context_Weglot {
|
|
65 |
'\WeglotWP\Services\Href_Lang_Service_Weglot',
|
66 |
'\WeglotWP\Services\Menu_Options_Service_Weglot',
|
67 |
'\WeglotWP\Services\Translate_Json_Service',
|
|
|
68 |
];
|
69 |
|
70 |
self::$context->set_services( $services );
|
65 |
'\WeglotWP\Services\Href_Lang_Service_Weglot',
|
66 |
'\WeglotWP\Services\Menu_Options_Service_Weglot',
|
67 |
'\WeglotWP\Services\Translate_Json_Service',
|
68 |
+
'\WeglotWP\Services\Translate_Json_Ld',
|
69 |
];
|
70 |
|
71 |
self::$context->set_services( $services );
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: translate, multilingual, language, translation, localization
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.1
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 3.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -153,6 +153,10 @@ See changelog for upgrade changes.
|
|
153 |
|
154 |
== Changelog ==
|
155 |
|
|
|
|
|
|
|
|
|
156 |
= 3.0.2 (24/04/2019) =
|
157 |
* Bugfix: Fixed saving custom CSS
|
158 |
* Bugfix: Auto detection of a bot (google, bing,...)
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 5.1
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 3.0.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
153 |
|
154 |
== Changelog ==
|
155 |
|
156 |
+
= 3.0.3 (09/05/2019) =
|
157 |
+
* Bugfix: Weglot switcher on menu
|
158 |
+
* Add : Translate all JSON-LD
|
159 |
+
|
160 |
= 3.0.2 (24/04/2019) =
|
161 |
* Bugfix: Fixed saving custom CSS
|
162 |
* Bugfix: Auto detection of a bot (google, bing,...)
|
src/actions/admin/class-customize-menu-weglot.php
CHANGED
@@ -98,7 +98,7 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
|
|
98 |
|
99 |
wp_enqueue_script( 'weglot_nav_menu', WEGLOT_URL_DIST . '/nav-js.js', [ 'jquery' ], WEGLOT_VERSION );
|
100 |
|
101 |
-
$data['title'] =
|
102 |
$data['options'] = $this->option_services->get_option_by_key_v3( 'menu_switcher' );
|
103 |
$data['list_options'] = $this->menu_options_services->get_list_options_menu_switcher();
|
104 |
|
@@ -131,7 +131,7 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
|
|
131 |
<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $_nav_menu_placeholder ); ?>" /> <?php esc_html_e( 'Weglot Switcher', 'weglot' ); ?>
|
132 |
</label>
|
133 |
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-type]" value="custom" />
|
134 |
-
<input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-title]" value="
|
135 |
<input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-url]" value="#weglot_switcher" />
|
136 |
<input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-classes]" />
|
137 |
</li>
|
98 |
|
99 |
wp_enqueue_script( 'weglot_nav_menu', WEGLOT_URL_DIST . '/nav-js.js', [ 'jquery' ], WEGLOT_VERSION );
|
100 |
|
101 |
+
$data['title'] = 'Weglot switcher'; // No translate this!
|
102 |
$data['options'] = $this->option_services->get_option_by_key_v3( 'menu_switcher' );
|
103 |
$data['list_options'] = $this->menu_options_services->get_list_options_menu_switcher();
|
104 |
|
131 |
<input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $_nav_menu_placeholder ); ?>" /> <?php esc_html_e( 'Weglot Switcher', 'weglot' ); ?>
|
132 |
</label>
|
133 |
<input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-type]" value="custom" />
|
134 |
+
<input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-title]" value="Weglot Switcher" /> <!-- // No translate this! -->
|
135 |
<input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-url]" value="#weglot_switcher" />
|
136 |
<input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-classes]" />
|
137 |
</li>
|
src/actions/front/class-translate-page-weglot.php
CHANGED
@@ -88,6 +88,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
88 |
'elementor_ajax', // Elementor since 2.5
|
89 |
'ct_get_svg_icon_sets', // Oxygen
|
90 |
'oxy_render_nav_menu', // Oxygen
|
|
|
91 |
] );
|
92 |
|
93 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
|
88 |
'elementor_ajax', // Elementor since 2.5
|
89 |
'ct_get_svg_icon_sets', // Oxygen
|
90 |
'oxy_render_nav_menu', // Oxygen
|
91 |
+
'hotel_booking_ajax_add_to_cart', // Hotel booking plugin
|
92 |
] );
|
93 |
|
94 |
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
|
src/services/class-option-service-weglot.php
CHANGED
@@ -120,15 +120,14 @@ class Option_Service_Weglot {
|
|
120 |
'timeout' => 15,
|
121 |
] );
|
122 |
|
123 |
-
if ( is_wp_error( $response ) ) {
|
124 |
-
return [
|
125 |
-
'success' => false,
|
126 |
-
'result' => [],
|
127 |
-
];
|
128 |
-
}
|
129 |
-
|
130 |
try {
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
$this->options_cdn = $body;
|
133 |
|
134 |
set_transient( 'weglot_cache_cdn', $body, apply_filters( 'weglot_get_options_from_cdn_cache_duration', 300 ) );
|
120 |
'timeout' => 15,
|
121 |
] );
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
try {
|
124 |
+
if ( is_wp_error( $response ) ) {
|
125 |
+
$response = $this->get_options_from_api_with_api_key( $this->get_api_key_private() );
|
126 |
+
$body = $response["result"];
|
127 |
+
}
|
128 |
+
else{
|
129 |
+
$body = json_decode( $response['body'], true );
|
130 |
+
}
|
131 |
$this->options_cdn = $body;
|
132 |
|
133 |
set_transient( 'weglot_cache_cdn', $body, apply_filters( 'weglot_get_options_from_cdn_cache_duration', 300 ) );
|
src/services/class-translate-json-ld.php
ADDED
@@ -0,0 +1,303 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 3.0.3
|
22 |
+
*/
|
23 |
+
class Translate_Json_Ld {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @since 3.0.3
|
27 |
+
* @var integer
|
28 |
+
*/
|
29 |
+
protected $index = 0;
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @since 3.0.3
|
33 |
+
* @var integer
|
34 |
+
*/
|
35 |
+
protected $limit = 0;
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @since 3.0.3
|
39 |
+
* @var array
|
40 |
+
*/
|
41 |
+
protected $indexes = [];
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @since 3.0.3
|
45 |
+
* @var array
|
46 |
+
*/
|
47 |
+
protected $collections = [];
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @since 3.0.3
|
51 |
+
* @var integer
|
52 |
+
*/
|
53 |
+
protected $index_json_collections = [];
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @since 3.0.3
|
57 |
+
* @var integer
|
58 |
+
*/
|
59 |
+
protected $limit_json_collections = [];
|
60 |
+
|
61 |
+
/**
|
62 |
+
* @since 3.0.3
|
63 |
+
* @var array
|
64 |
+
*/
|
65 |
+
protected $keys_json_ld_translate = [
|
66 |
+
'name',
|
67 |
+
'description',
|
68 |
+
'headline',
|
69 |
+
'articleSection'
|
70 |
+
];
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @since 3.0.3
|
74 |
+
*/
|
75 |
+
public function __construct() {
|
76 |
+
$this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
|
77 |
+
$this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
|
78 |
+
$this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @since 3.0.3
|
83 |
+
*
|
84 |
+
* @param array $json
|
85 |
+
* @param string $path
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
protected function check_json_to_translate( $json, $path = '$' ) {
|
89 |
+
foreach ( $json as $key => $val ) {
|
90 |
+
if ( is_array( $val ) ) {
|
91 |
+
if ( is_string( $key ) ) {
|
92 |
+
if ( false === strpos( $key, '.' ) && false === strpos( $key, '@' ) ) {
|
93 |
+
$newpath = "$path.$key";
|
94 |
+
} else {
|
95 |
+
$newpath = sprintf( '%s["%s"]', $path, $key );
|
96 |
+
}
|
97 |
+
} else {
|
98 |
+
$newpath = sprintf( '%s[%s]', $path, $key );
|
99 |
+
}
|
100 |
+
|
101 |
+
$this->check_json_to_translate( $val, $newpath );
|
102 |
+
} else {
|
103 |
+
if ( false === strpos( $key, '.' ) ) {
|
104 |
+
$newpath = "$path.$key";
|
105 |
+
} else {
|
106 |
+
$newpath = sprintf( '%s["%s"]', $path, $key );
|
107 |
+
}
|
108 |
+
|
109 |
+
if ( Helper_Json_Inline_Weglot::is_ajax_html( $val ) ) {
|
110 |
+
try {
|
111 |
+
$parser = $this->parser_services->get_parser();
|
112 |
+
$words = $parser->parse( $val );
|
113 |
+
if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
|
114 |
+
continue;
|
115 |
+
}
|
116 |
+
$this->collections = array_merge( $this->collections, $words->jsonSerialize() );
|
117 |
+
$this->limit = $this->index + $words->count();
|
118 |
+
$this->indexes[ $newpath ] = [
|
119 |
+
'start' => $this->index,
|
120 |
+
'limit' => $this->limit,
|
121 |
+
]; //phpcs:ignore
|
122 |
+
$this->index += $words->count();
|
123 |
+
} catch ( \Exception $e ) {
|
124 |
+
continue;
|
125 |
+
}
|
126 |
+
} else {
|
127 |
+
if ( in_array( $key, $this->keys_json_ld_translate, true ) ) {
|
128 |
+
try {
|
129 |
+
$parser = $this->parser_services->get_parser();
|
130 |
+
$words = $parser->parse( $val );
|
131 |
+
if ( ! $words instanceof WordCollection || $words->count() < 1 ) {
|
132 |
+
continue;
|
133 |
+
}
|
134 |
+
$this->collections = array_merge( $this->collections, $words->jsonSerialize() );
|
135 |
+
$this->limit = $this->index + $words->count();
|
136 |
+
$this->indexes[ $newpath ] = [
|
137 |
+
'start' => $this->index,
|
138 |
+
'limit' => $this->limit,
|
139 |
+
];
|
140 |
+
$this->index += $words->count();
|
141 |
+
} catch ( \Exception $e ) {
|
142 |
+
continue;
|
143 |
+
}
|
144 |
+
}
|
145 |
+
}
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
return [
|
150 |
+
$this->indexes,
|
151 |
+
$this->collections,
|
152 |
+
];
|
153 |
+
}
|
154 |
+
|
155 |
+
/**
|
156 |
+
* @since 3.0.3
|
157 |
+
* @return string
|
158 |
+
*/
|
159 |
+
protected function handle_translate_jsons() {
|
160 |
+
$parser = $this->parser_services->get_parser();
|
161 |
+
|
162 |
+
// Translate endpoint parameters
|
163 |
+
$params = [
|
164 |
+
'language_from' => weglot_get_original_language(),
|
165 |
+
'language_to' => weglot_get_current_language(),
|
166 |
+
];
|
167 |
+
|
168 |
+
if ( $parser->getConfigProvider() instanceof ServerConfigProvider ) {
|
169 |
+
$parser->getConfigProvider()->loadFromServer();
|
170 |
+
}
|
171 |
+
|
172 |
+
$params = array_merge( $params, $parser->getConfigProvider()->asArray() );
|
173 |
+
|
174 |
+
$translate = new TranslateEntry( $params );
|
175 |
+
$word_collection = $translate->getInputWords();
|
176 |
+
foreach ( $this->collections as $value ) {
|
177 |
+
$word_collection->addOne( new WordEntry( $value['w'], $value['t'] ) );
|
178 |
+
}
|
179 |
+
|
180 |
+
$translate = new Translate( $translate, $parser->getClient() );
|
181 |
+
return $translate->handle();
|
182 |
+
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
*
|
187 |
+
* @param string $json
|
188 |
+
* @param string $key
|
189 |
+
* @param array $data
|
190 |
+
* @return void
|
191 |
+
*/
|
192 |
+
protected function replace_json_content( $json, $key, $data ){
|
193 |
+
|
194 |
+
$json_object = new JsonObject( $json );
|
195 |
+
|
196 |
+
list( $output_words, $input_words ) = $data;
|
197 |
+
|
198 |
+
$array_keys_indexes = array_keys($this->indexes);
|
199 |
+
for ( $i= $this->index_json_collections[$key]; $i < $this->limit_json_collections[$key] ; $i++) {
|
200 |
+
|
201 |
+
$path = $array_keys_indexes[$i];
|
202 |
+
$index = $this->indexes[ $path ];
|
203 |
+
$y = 0;
|
204 |
+
|
205 |
+
do {
|
206 |
+
if ( is_null( $input_words[ $y ] ) || is_null( $output_words[ $y ] ) ) {
|
207 |
+
$y++;
|
208 |
+
continue;
|
209 |
+
}
|
210 |
+
|
211 |
+
$input_word = $input_words[ $y ]->getWord();
|
212 |
+
$output_word = $output_words[ $y ]->getWord();
|
213 |
+
$str = $json_object->get( $path )[0];
|
214 |
+
|
215 |
+
$json_object->set( $path, str_replace( $input_word, $output_word, $str ) );
|
216 |
+
$y++;
|
217 |
+
} while ( $y < $index['limit'] );
|
218 |
+
}
|
219 |
+
|
220 |
+
return json_decode( $json_object->getJson(), JSON_PRETTY_PRINT );
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* @since 3.0.3
|
225 |
+
* @param array simple_html_dom_node $jsons
|
226 |
+
* @param array $translated_words
|
227 |
+
* @return array simple_html_dom_node
|
228 |
+
*/
|
229 |
+
public function replace_jsons_translated( $jsons, $translated_words ){
|
230 |
+
$output_words = $translated_words->getOutputWords();
|
231 |
+
|
232 |
+
if ( $output_words->count() !== count( $this->collections ) || $output_words->count() === 0 ) {
|
233 |
+
return $jsons;
|
234 |
+
}
|
235 |
+
|
236 |
+
$input_words = $translated_words->getInputWords();
|
237 |
+
$i = 0;
|
238 |
+
|
239 |
+
foreach ( $jsons as $key => $row ) {
|
240 |
+
$json = json_decode($row->innertext, true);
|
241 |
+
if ( json_last_error() !== JSON_ERROR_NONE) {
|
242 |
+
continue;
|
243 |
+
}
|
244 |
+
|
245 |
+
$json = $this->replace_json_content($json, $key, [
|
246 |
+
$output_words,
|
247 |
+
$input_words
|
248 |
+
]);
|
249 |
+
|
250 |
+
$row->innertext = json_encode($json, JSON_PRETTY_PRINT);
|
251 |
+
|
252 |
+
}
|
253 |
+
|
254 |
+
return $jsons;
|
255 |
+
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* @since 3.0.3
|
260 |
+
* @param string $dom
|
261 |
+
* @return string
|
262 |
+
*/
|
263 |
+
public function handle( $dom ) {
|
264 |
+
|
265 |
+
$dom = \WGSimpleHtmlDom\str_get_html(
|
266 |
+
$dom,
|
267 |
+
true,
|
268 |
+
true,
|
269 |
+
WG_DEFAULT_TARGET_CHARSET,
|
270 |
+
false
|
271 |
+
);
|
272 |
+
|
273 |
+
$this->keys_json_ld_translate = apply_filters( 'weglot_keys_json_ld_translate', $this->keys_json_ld_translate );
|
274 |
+
|
275 |
+
$jsons = $dom->find( 'script[type="application/ld+json"]' );
|
276 |
+
foreach ( $jsons as $key => $row ) {
|
277 |
+
$json = json_decode($row->innertext, true);
|
278 |
+
if ( json_last_error() !== JSON_ERROR_NONE) {
|
279 |
+
continue;
|
280 |
+
}
|
281 |
+
|
282 |
+
$this->index_json_collections[$key] = count($this->collections);
|
283 |
+
$this->check_json_to_translate($json);
|
284 |
+
$this->limit_json_collections[$key] = count($this->collections);
|
285 |
+
|
286 |
+
}
|
287 |
+
|
288 |
+
$translated_words = null;
|
289 |
+
try {
|
290 |
+
$translated_words = $this->handle_translate_jsons();
|
291 |
+
} catch (\Exception $e) {
|
292 |
+
return $dom->save();
|
293 |
+
}
|
294 |
+
|
295 |
+
|
296 |
+
$translated_jsons = $this->replace_jsons_translated( $jsons, $translated_words );
|
297 |
+
|
298 |
+
return $dom->save();
|
299 |
+
}
|
300 |
+
}
|
301 |
+
|
302 |
+
|
303 |
+
|
src/services/class-translate-service-weglot.php
CHANGED
@@ -31,6 +31,7 @@ class Translate_Service_Weglot {
|
|
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 |
|
@@ -118,6 +119,10 @@ class Translate_Service_Weglot {
|
|
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 |
|
123 |
$translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
|
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 |
+
$this->translate_json_ld_services = weglot_get_service( 'Translate_Json_Ld' );
|
35 |
}
|
36 |
|
37 |
|
119 |
$translated_content = weglot_get_service( 'Caldera_Translate' )->translate_words( $translated_content );
|
120 |
}
|
121 |
|
122 |
+
if( apply_filters( 'weglot_translate_json_ld', true ) ){
|
123 |
+
$translated_content = $this->translate_json_ld_services->handle( $translated_content );
|
124 |
+
}
|
125 |
+
|
126 |
$translated_content = $this->other_translate_services->translate_words( $translated_content );
|
127 |
|
128 |
$translated_content = apply_filters( 'weglot_html_treat_page', $translated_content );
|
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 ComposerAutoloaderInitb4e5615aa57ee5c377f456d80cee608d::getLoader();
|
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 ComposerAutoloaderInit4d1d13c56b817ee29d5e8e760c5618e4
|
|
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 ComposerAutoloaderInit4d1d13c56b817ee29d5e8e760c5618e4
|
|
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 ComposerAutoloaderInitb4e5615aa57ee5c377f456d80cee608d
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitb4e5615aa57ee5c377f456d80cee608d', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitb4e5615aa57ee5c377f456d80cee608d', '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\ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d::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\ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequireb4e5615aa57ee5c377f456d80cee608d($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequireb4e5615aa57ee5c377f456d80cee608d($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',
|
@@ -67,9 +67,9 @@ class ComposerStaticInit4d1d13c56b817ee29d5e8e760c5618e4
|
|
67 |
public static function getInitializer(ClassLoader $loader)
|
68 |
{
|
69 |
return \Closure::bind(function () use ($loader) {
|
70 |
-
$loader->prefixLengthsPsr4 =
|
71 |
-
$loader->prefixDirsPsr4 =
|
72 |
-
$loader->prefixesPsr0 =
|
73 |
|
74 |
}, null, ClassLoader::class);
|
75 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
67 |
public static function getInitializer(ClassLoader $loader)
|
68 |
{
|
69 |
return \Closure::bind(function () use ($loader) {
|
70 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d::$prefixLengthsPsr4;
|
71 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d::$prefixDirsPsr4;
|
72 |
+
$loader->prefixesPsr0 = ComposerStaticInitb4e5615aa57ee5c377f456d80cee608d::$prefixesPsr0;
|
73 |
|
74 |
}, null, ClassLoader::class);
|
75 |
}
|
vendor/composer/installed.json
CHANGED
@@ -6,12 +6,12 @@
|
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/Galbar/JsonPath-PHP.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/Galbar/JsonPath-PHP/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
@@ -22,7 +22,7 @@
|
|
22 |
"sami/sami": ">=3.3.0",
|
23 |
"satooshi/php-coveralls": ">=1.0.1"
|
24 |
},
|
25 |
-
"time": "
|
26 |
"type": "library",
|
27 |
"installation-source": "source",
|
28 |
"autoload": {
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/Galbar/JsonPath-PHP.git",
|
9 |
+
"reference": "3820fd4da177f5cf180aa47260d57086e4e4ba29"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/Galbar/JsonPath-PHP/zipball/3820fd4da177f5cf180aa47260d57086e4e4ba29",
|
14 |
+
"reference": "3820fd4da177f5cf180aa47260d57086e4e4ba29",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"require": {
|
22 |
"sami/sami": ">=3.3.0",
|
23 |
"satooshi/php-coveralls": ">=1.0.1"
|
24 |
},
|
25 |
+
"time": "2019-05-06T10:17:27+00:00",
|
26 |
"type": "library",
|
27 |
"installation-source": "source",
|
28 |
"autoload": {
|
vendor/galbar/jsonpath
CHANGED
@@ -1 +1 @@
|
|
1 |
-
Subproject commit
|
1 |
+
Subproject commit 3820fd4da177f5cf180aa47260d57086e4e4ba29
|
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.0.
|
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.0.
|
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.0.3
|
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.0.3');
|
26 |
define('WEGLOT_PHP_MIN', '5.4');
|
27 |
define('WEGLOT_BNAME', plugin_basename(__FILE__));
|
28 |
define('WEGLOT_DIR', __DIR__ );
|