Weglot Translate – Translate your WP website - Version 1.7

Version Description

  • Add 6 languages
  • Translate microdata
  • New element translated
Download this release

Release Info

Developer remyb92
Plugin Icon 128x128 Weglot Translate – Translate your WP website
Version 1.7
Comparing to
See all releases

Code changes from version 1.6.1 to 1.7

WGUtils.php CHANGED
@@ -24,8 +24,6 @@ class WGUtils {
24
  return $english ? 'Bulgarian' : 'български';
25
  case 'bs':
26
  return $english ? 'Bosnian' : 'Bosanski';
27
- case 'cy':
28
- return $english ? 'Welsh' : 'Cymraeg';
29
  case 'vi':
30
  return $english ? 'Vietnamese' : 'Tiếng Việt';
31
  case 'hu':
@@ -134,6 +132,18 @@ class WGUtils {
134
  return $english ? 'Hindi' : 'हिंदी';
135
  case 'ur':
136
  return $english ? 'Urdu' : 'اردو';
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
  }
139
 
24
  return $english ? 'Bulgarian' : 'български';
25
  case 'bs':
26
  return $english ? 'Bosnian' : 'Bosanski';
 
 
27
  case 'vi':
28
  return $english ? 'Vietnamese' : 'Tiếng Việt';
29
  case 'hu':
132
  return $english ? 'Hindi' : 'हिंदी';
133
  case 'ur':
134
  return $english ? 'Urdu' : 'اردو';
135
+ case "bn":
136
+ return $english ? "Bengali" : "বাংলা";
137
+ case "fj":
138
+ return $english ? "Fijian" : "Fidžin";
139
+ case "sm":
140
+ return $english ? "Samoan" : "Samoa";
141
+ case "ty":
142
+ return $english ? "Tahitian" : "Tahitian";
143
+ case "to":
144
+ return $english ? "Tongan" : "Tonga";
145
+ case "cy":
146
+ return $english ? "Welsh" : "Cymraeg";
147
  }
148
  }
149
 
WeglotPHPClient/src/Client.php CHANGED
@@ -61,6 +61,10 @@ class Client {
61
  return true;
62
  }
63
 
 
 
 
 
64
 
65
  public function checkPlaceholder( $row ) {
66
  return ( ! is_numeric( $this->full_trim( $row->placeholder ) )
@@ -112,6 +116,14 @@ class Client {
112
  return true;
113
  }
114
 
 
 
 
 
 
 
 
 
115
  function searchForId( $id, $array ) {
116
  foreach ( $array as $key => $val ) {
117
  if ( $val['uid'] === $id ) {
@@ -165,6 +177,15 @@ class Client {
165
  ),
166
  ),
167
 
 
 
 
 
 
 
 
 
 
168
 
169
  "td"
170
  => array(
@@ -247,6 +268,16 @@ class Client {
247
  'property' => 'data-hover',
248
  't' => 1,
249
  'type' => 'a_dho',
 
 
 
 
 
 
 
 
 
 
250
  ),
251
  ),
252
 
@@ -283,6 +314,35 @@ class Client {
283
  }
284
  }
285
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  $title = 'Empty title';
287
  foreach ( $html->find( 'title' ) as $k => $row ) {
288
  if($row->innertext != '')
@@ -308,24 +368,50 @@ class Client {
308
  'words' => $words,
309
  );
310
  $results = $this->doRequest( self::API_BASE . '/translate?api_key=' . $this->api_key,$parameters );
 
311
  $json = json_decode( $results,true );
312
  if ( json_last_error() == JSON_ERROR_NONE ) {
313
  $answer = $json;
314
  if ( isset( $answer['to_words'] ) ) {
315
  $translated_words = $answer['to_words'];
316
- if ( count( $nodes ) == count( $translated_words ) ) {
 
317
  for ( $i = 0;$i < count( $nodes );$i++ ) {
318
 
319
- $property = $nodes[ $i ]['property'];
320
- $nodes[ $i ]['node']->$property = $translated_words[ $i ];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
 
322
- if ( $nodes[ $i ]['type'] == 'image_src' ) {
323
- $nodes[ $i ]['node']->src = $translated_words[ $i ];
324
- if ( $nodes[ $i ]['node']->hasAttribute( 'srcset' ) && $nodes[ $i ]['node']->srcset != '' && $translated_words[ $i ] != $words[ $i ]['w'] ) {
325
- $nodes[ $i ]['node']->srcset = '';
326
- }
327
- }
328
- }
329
  return $html->save();
330
  } else {
331
  throw new WeglotException( 'Unknown error with Weglot Api (0006)' );
@@ -438,7 +524,61 @@ class Client {
438
  }
439
  }
440
 
441
- function url_origin( $s, $use_forwarded_host = false ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
442
  $ssl = ( ! empty( $s['HTTPS'] ) && $s['HTTPS'] == 'on') ? true : false;
443
  $sp = strtolower( $s['SERVER_PROTOCOL'] );
444
  $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . (($ssl) ? 's' : '');
61
  return true;
62
  }
63
 
64
+ public function checkRad_obt ($row ) {
65
+ return true;
66
+ }
67
+
68
 
69
  public function checkPlaceholder( $row ) {
70
  return ( ! is_numeric( $this->full_trim( $row->placeholder ) )
116
  return true;
117
  }
118
 
119
+ public function checkA_dco( $row ) {
120
+ return true;
121
+ }
122
+
123
+ public function checkA_dte( $row ) {
124
+ return true;
125
+ }
126
+
127
  function searchForId( $id, $array ) {
128
  foreach ( $array as $key => $val ) {
129
  if ( $val['uid'] === $id ) {
177
  ),
178
  ),
179
 
180
+ "input[type='radio']"
181
+ => array(
182
+ array(
183
+ 'property' => 'data-order_button_text',
184
+ 't' => 2,
185
+ 'type' => 'rad_obt',
186
+ ),
187
+ ),
188
+
189
 
190
  "td"
191
  => array(
268
  'property' => 'data-hover',
269
  't' => 1,
270
  'type' => 'a_dho',
271
+ ),
272
+ array(
273
+ 'property' => 'data-content',
274
+ 't' => 1,
275
+ 'type' => 'a_dco',
276
+ ),
277
+ array(
278
+ 'property' => 'data-text',
279
+ 't' => 1,
280
+ 'type' => 'a_dte',
281
  ),
282
  ),
283
 
314
  }
315
  }
316
 
317
+
318
+
319
+ $microData = array("description");
320
+ $jsons = array();
321
+ $nbJsonStrings = 0;
322
+
323
+
324
+ foreach ( $html->find( 'script[type="application/ld+json"]' ) as $k => $row ) {
325
+ $mustAddjson = false;
326
+ $json = json_decode($row->innertext,true);
327
+ if (json_last_error() === JSON_ERROR_NONE) {
328
+ foreach($microData as $key) {
329
+
330
+ $path = explode(">", $key);
331
+ $value = $this->getValue($json,$path);
332
+
333
+ if(isset($value)) {
334
+ $mustAddjson = true;
335
+ $this->addValues($value, $words, $nbJsonStrings);
336
+ }
337
+
338
+ }
339
+
340
+ if($mustAddjson) {
341
+ array_push($jsons, array('node' => $row, 'json' => $json));
342
+ }
343
+ }
344
+ }
345
+
346
  $title = 'Empty title';
347
  foreach ( $html->find( 'title' ) as $k => $row ) {
348
  if($row->innertext != '')
368
  'words' => $words,
369
  );
370
  $results = $this->doRequest( self::API_BASE . '/translate?api_key=' . $this->api_key,$parameters );
371
+
372
  $json = json_decode( $results,true );
373
  if ( json_last_error() == JSON_ERROR_NONE ) {
374
  $answer = $json;
375
  if ( isset( $answer['to_words'] ) ) {
376
  $translated_words = $answer['to_words'];
377
+
378
+ if ( (count( $nodes ) + $nbJsonStrings ) == count( $translated_words ) ) {
379
  for ( $i = 0;$i < count( $nodes );$i++ ) {
380
 
381
+ $property = $nodes[$i]['property'];
382
+ $type = $nodes[$i]['type'];
383
+
384
+ if ($type == "meta_desc") {
385
+ $nodes[$i]['node']->$property = htmlspecialchars($translated_words[$i]);
386
+ } else {
387
+ $nodes[$i]['node']->$property = $translated_words[$i];
388
+ }
389
+
390
+
391
+ if ($nodes[$i]['type'] == 'img_src') {
392
+ $nodes[$i]['node']->src = $translated_words[$i];
393
+ if ($nodes[$i]['node']->hasAttribute('srcset') && $nodes[$i]['node']->srcset != '' && $translated_words[$i] != $words[$i]['w']) {
394
+ $nodes[$i]['node']->srcset = '';
395
+ }
396
+ }
397
+ }
398
+ $index = count( $nodes );
399
+ for ( $j = 0;$j < count( $jsons );$j++ ) {
400
+ $jsonArray = $jsons[$j]['json'];
401
+ $node = $jsons[$j]['node'];
402
+ foreach($microData as $key) {
403
+
404
+ $path = explode(">", $key);
405
+ $hasV = $this->getValue($jsonArray,$path);
406
+
407
+ if(isset($hasV)) {
408
+ $this->setValues($jsonArray,$path,$translated_words, $index);
409
+ }
410
+ }
411
+ $node->innertext = json_encode($jsonArray,JSON_PRETTY_PRINT);
412
+
413
+ }
414
 
 
 
 
 
 
 
 
415
  return $html->save();
416
  } else {
417
  throw new WeglotException( 'Unknown error with Weglot Api (0006)' );
524
  }
525
  }
526
 
527
+
528
+ function addValues( $value, &$words, &$nbJsonStrings )
529
+ {
530
+ if (is_array($value)) {
531
+ foreach ($value as $key => $val) {
532
+ $this->addValues($val, $words, $nbJsonStrings);
533
+ }
534
+
535
+ }
536
+ else {
537
+ array_push(
538
+ $words, array(
539
+ 't' => 1,
540
+ 'w' => $value,
541
+ )
542
+ );
543
+ $nbJsonStrings++;
544
+ }
545
+ }
546
+
547
+ function setValues(&$data, $path, $translatedwords,&$index) {
548
+
549
+ $temp = &$data;
550
+ foreach ($path as $key) {
551
+ if (array_key_exists($key, $temp))
552
+ $temp = &$temp[$key];
553
+ else
554
+ return null;
555
+ }
556
+
557
+ if (is_array($temp)) {
558
+ foreach ($temp as $key => &$val) {
559
+ $this->setValues($val, null, $translatedwords, $index) ;
560
+ }
561
+ } else {
562
+ $temp = $translatedwords[$index];
563
+ $index++;
564
+ }
565
+
566
+ return;
567
+ }
568
+
569
+ function getValue($data, $path) {
570
+ $temp = $data;
571
+ foreach ( $path as $key ) {
572
+ if(array_key_exists($key,$temp))
573
+ $temp = $temp[$key];
574
+ else
575
+ return null;
576
+ }
577
+ return $temp ;
578
+ }
579
+
580
+
581
+ function url_origin( $s, $use_forwarded_host = false ) {
582
  $ssl = ( ! empty( $s['HTTPS'] ) && $s['HTTPS'] == 'on') ? true : false;
583
  $sp = strtolower( $s['SERVER_PROTOCOL'] );
584
  $protocol = substr( $sp, 0, strpos( $sp, '/' ) ) . (($ssl) ? 's' : '');
includes/wg-settings-page.php CHANGED
@@ -430,6 +430,42 @@ if ( WGUtils::isLanguageRTL( $this->original_l ) ) { // Right lo left language
430
  echo 'selected'; }
431
  ?>
432
  value="ur"><?php esc_html_e( 'Urdu', 'weglot' ); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
433
  </select>
434
  </td>
435
  </tr>
@@ -804,6 +840,42 @@ if ( WGUtils::isLanguageRTL( $this->original_l ) ) { // Right lo left language
804
  echo 'selected'; }
805
  ?>
806
  value="ur"><?php esc_html_e( 'Urdu', 'weglot' ); ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
807
  </select>
808
  </div>
809
  <input id="destination_input_hidden" type="text" class="wg-input-text" name="destination_l" value="<?php echo esc_attr( get_option( 'destination_l' ) ); ?>" placeholder="en,es" required style="display:none;" />
@@ -1061,7 +1133,7 @@ text-align: right;
1061
  <?php esc_html_e( 'Love Weglot? Give us 5 stars on WordPress.org :)', 'weglot' ); ?>
1062
  </a>
1063
  <br><br>
1064
- <i class="fa fa-question-circle" aria-hidden="true" style="font-size : 17px;"></i><p style="display:inline-block; margin-left:5px;"><?php echo sprintf( esc_html__( 'If you need any help, you can contact us via our live chat at %1$sweglot.com%2$s or email us at support@weglot.com.', 'weglot' ), '<a href="https://weglot.com/" target="_blank">','</a>' ); ?></p>
1065
- <br><br><br>
1066
  <h2></h2>
1067
  </div>
430
  echo 'selected'; }
431
  ?>
432
  value="ur"><?php esc_html_e( 'Urdu', 'weglot' ); ?></option>
433
+ <option
434
+ <?php
435
+ if ( esc_attr( get_option( 'original_l' ) ) == 'bn' ) {
436
+ echo 'selected'; }
437
+ ?>
438
+ value="bn"><?php esc_html_e( 'Bengali', 'weglot' ); ?></option>
439
+ <option
440
+ <?php
441
+ if ( esc_attr( get_option( 'original_l' ) ) == 'fj' ) {
442
+ echo 'selected'; }
443
+ ?>
444
+ value="fj"><?php esc_html_e( 'Fijian', 'weglot' ); ?></option>
445
+ <option
446
+ <?php
447
+ if ( esc_attr( get_option( 'original_l' ) ) == 'sm' ) {
448
+ echo 'selected'; }
449
+ ?>
450
+ value="sm"><?php esc_html_e( 'Samoan', 'weglot' ); ?></option>
451
+ <option
452
+ <?php
453
+ if ( esc_attr( get_option( 'original_l' ) ) == 'ty' ) {
454
+ echo 'selected'; }
455
+ ?>
456
+ value="ty"><?php esc_html_e( 'Tahitian', 'weglot' ); ?></option>
457
+ <option
458
+ <?php
459
+ if ( esc_attr( get_option( 'original_l' ) ) == 'to' ) {
460
+ echo 'selected'; }
461
+ ?>
462
+ value="to"><?php esc_html_e( 'Tongan', 'weglot' ); ?></option>
463
+ <option
464
+ <?php
465
+ if ( esc_attr( get_option( 'original_l' ) ) == 'cy' ) {
466
+ echo 'selected'; }
467
+ ?>
468
+ value="cy"><?php esc_html_e( 'Welsh', 'weglot' ); ?></option>
469
  </select>
470
  </td>
471
  </tr>
840
  echo 'selected'; }
841
  ?>
842
  value="ur"><?php esc_html_e( 'Urdu', 'weglot' ); ?></option>
843
+ <option
844
+ <?php
845
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'bn' ) !== false ) {
846
+ echo 'selected'; }
847
+ ?>
848
+ value="bn"><?php esc_html_e( 'Bengali', 'weglot' ); ?></option>
849
+ <option
850
+ <?php
851
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'fj' ) !== false ) {
852
+ echo 'selected'; }
853
+ ?>
854
+ value="fj"><?php esc_html_e( 'Fijian', 'weglot' ); ?></option>
855
+ <option
856
+ <?php
857
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'sm' ) !== false ) {
858
+ echo 'selected'; }
859
+ ?>
860
+ value="sm"><?php esc_html_e( 'Samoan', 'weglot' ); ?></option>
861
+ <option
862
+ <?php
863
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'ty' ) !== false ) {
864
+ echo 'selected'; }
865
+ ?>
866
+ value="ty"><?php esc_html_e( 'Tahitian', 'weglot' ); ?></option>
867
+ <option
868
+ <?php
869
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'to' ) !== false ) {
870
+ echo 'selected'; }
871
+ ?>
872
+ value="to"><?php esc_html_e( 'Tongan', 'weglot' ); ?></option>
873
+ <option
874
+ <?php
875
+ if ( strpos( esc_attr( get_option( 'destination_l' ) ) , 'cy' ) !== false ) {
876
+ echo 'selected'; }
877
+ ?>
878
+ value="cy"><?php esc_html_e( 'Welsh', 'weglot' ); ?></option>
879
  </select>
880
  </div>
881
  <input id="destination_input_hidden" type="text" class="wg-input-text" name="destination_l" value="<?php echo esc_attr( get_option( 'destination_l' ) ); ?>" placeholder="en,es" required style="display:none;" />
1133
  <?php esc_html_e( 'Love Weglot? Give us 5 stars on WordPress.org :)', 'weglot' ); ?>
1134
  </a>
1135
  <br><br>
1136
+ <i class="fa fa-question-circle" aria-hidden="true" style="font-size : 17px;"></i><p style="display:inline-block; margin-left:5px;"><?php echo sprintf( esc_html__( 'If you need any help, you can contact us via our live chat at %1$sweglot.com%2$s or email us at support@weglot.com.', 'weglot' ), '<a href="https://weglot.com/" target="_blank">','</a>' ).'<br>'.sprintf( esc_html__( 'You can also check our %1$sFAQ%2$s','weglot' ), '<a href="http://support.weglot.com/" target="_blank">','</a>'); ?></p>
1137
+ <br><br><br>
1138
  <h2></h2>
1139
  </div>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: remyb92
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: 4.8
6
- Stable tag: 1.6.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -143,6 +143,11 @@ See changelog for upgrade changes.
143
 
144
  == Changelog ==
145
 
 
 
 
 
 
146
  = 1.6.1 =
147
  * Fix url when non standard characters
148
  * change freemius image
@@ -364,4 +369,4 @@ See changelog for upgrade changes.
364
  * Fix LTR CSS, api v2 transmit strings type, fix regex escaping
365
 
366
  = 0.40 =
367
- * Add PDF translate, fix simple dom limit, uninstall hook, no &lt;/body&gt; case.
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: 4.8
6
+ Stable tag: 1.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
143
 
144
  == Changelog ==
145
 
146
+ = 1.7 =
147
+ * Add 6 languages
148
+ * Translate microdata
149
+ * New element translated
150
+
151
  = 1.6.1 =
152
  * Fix url when non standard characters
153
  * change freemius image
369
  * Fix LTR CSS, api v2 transmit strings type, fix regex escaping
370
 
371
  = 0.40 =
372
+ * Add PDF translate, fix simple dom limit, uninstall hook, no &lt;/body&gt; case.
resources/wp-weglot-admin-js.js CHANGED
@@ -233,8 +233,6 @@ jQuery(
233
  return english ? "Bulgarian" : "български";
234
  case "bs":
235
  return english ? "Bosnian" : "Bosanski";
236
- case "cy":
237
- return english ? "Welsh" : "Cymraeg";
238
  case "vi":
239
  return english ? "Vietnamese" : "Tiếng Việt";
240
  case "hu":
@@ -343,6 +341,18 @@ jQuery(
343
  return english ? "Hindi" : "हिंदी";
344
  case "ur":
345
  return english ? "Urdu" : "اردو";
 
 
 
 
 
 
 
 
 
 
 
 
346
  }
347
  }
348
 
233
  return english ? "Bulgarian" : "български";
234
  case "bs":
235
  return english ? "Bosnian" : "Bosanski";
 
 
236
  case "vi":
237
  return english ? "Vietnamese" : "Tiếng Việt";
238
  case "hu":
341
  return english ? "Hindi" : "हिंदी";
342
  case "ur":
343
  return english ? "Urdu" : "اردو";
344
+ case "bn":
345
+ return english ? "Bengali" : "বাংলা";
346
+ case "fj":
347
+ return english ? "Fijian" : "Fidžin";
348
+ case "sm":
349
+ return english ? "Samoan" : "Samoa";
350
+ case "ty":
351
+ return english ? "Tahitian" : "Tahitian";
352
+ case "to":
353
+ return english ? "Tongan" : "Tonga";
354
+ case "cy":
355
+ return english ? "Welsh" : "Cymraeg";
356
  }
357
  }
358
 
resources/wp-weglot-css.css CHANGED
@@ -164,7 +164,7 @@
164
  .wg-flags a:before {
165
  background-image: url(../images/rect_mate.png);
166
  background-size: auto 100%;
167
- border-radius: 5px;
168
  width: 30px;
169
  height: 20px;
170
  }
@@ -230,6 +230,12 @@
230
  .wg-li.ja a:before { background-position: -3480px 0; }
231
  .wg-li.hi a:before { background-position: -1170px 0; }
232
  .wg-li.ur a:before { background-position: -3180px 0; }
 
 
 
 
 
 
233
 
234
  .wg-flags.flag-1 a:before {
235
  background-image: url("../images/rect_bright.png");
@@ -299,6 +305,13 @@
299
  .wg-li.flag-1.ja a:before { background-position: -3617px 0; }
300
  .wg-li.flag-1.hi a:before { background-position: -3329px 0; }
301
  .wg-li.flag-1.ur a:before { background-position: -5600px 0; }
 
 
 
 
 
 
 
302
 
303
  .wg-flags.flag-2 a:before {
304
  background-image: url("../images/square_flag.png");
@@ -368,6 +381,12 @@
368
  .wg-li.flag-2.ja a:before { background-position: -1920px 0; }
369
  .wg-li.flag-2.hi a:before { background-position: -1728px 0; }
370
  .wg-li.flag-2.ur a:before { background-position: -1128px 0; }
 
 
 
 
 
 
371
 
372
  .wg-flags.flag-3 a:before {
373
  background-image: url("../images/circular_flag.png");
@@ -437,3 +456,9 @@
437
  .wg-li.flag-3.ja a:before { background-position: -2448px 0; }
438
  .wg-li.flag-3.hi a:before { background-position: -2304px 0; }
439
  .wg-li.flag-3.ur a:before { background-position: -1992px 0; }
 
 
 
 
 
 
164
  .wg-flags a:before {
165
  background-image: url(../images/rect_mate.png);
166
  background-size: auto 100%;
167
+ border-radius: 0px;
168
  width: 30px;
169
  height: 20px;
170
  }
230
  .wg-li.ja a:before { background-position: -3480px 0; }
231
  .wg-li.hi a:before { background-position: -1170px 0; }
232
  .wg-li.ur a:before { background-position: -3180px 0; }
233
+ .wg-li.bn a:before { background-position: -5400px 0; }
234
+ .wg-li.fj a:before { background-position: -1710px 0; }
235
+ .wg-li.sm a:before { background-position: -4620px 0; }
236
+ .wg-li.ty a:before { background-position: -6270px 0; }
237
+ .wg-li.to a:before { background-position: -6540px 0; }
238
+ .wg-li.cy a:before { background-position: -6420px 0; }
239
 
240
  .wg-flags.flag-1 a:before {
241
  background-image: url("../images/rect_bright.png");
305
  .wg-li.flag-1.ja a:before { background-position: -3617px 0; }
306
  .wg-li.flag-1.hi a:before { background-position: -3329px 0; }
307
  .wg-li.flag-1.ur a:before { background-position: -5600px 0; }
308
+ .wg-li.flag-1.ur a:before { background-position: -5600px 0; }
309
+ .wg-li.flag-1.bn a:before { background-position: -609px 0; }
310
+ .wg-li.flag-1.fj a:before { background-position: -2497px 0; }
311
+ .wg-li.flag-1.sm a:before { background-position: -6369px 0; }
312
+ .wg-li.flag-1.ty a:before { background-position: -2593px 0; }
313
+ .wg-li.flag-1.to a:before { background-position: -7456px 0; }
314
+ .wg-li.flag-1.cy a:before { background-position: -8129px 0; }
315
 
316
  .wg-flags.flag-2 a:before {
317
  background-image: url("../images/square_flag.png");
381
  .wg-li.flag-2.ja a:before { background-position: -1920px 0; }
382
  .wg-li.flag-2.hi a:before { background-position: -1728px 0; }
383
  .wg-li.flag-2.ur a:before { background-position: -1128px 0; }
384
+ .wg-li.flag-2.bn a:before { background-position: -4056px 0; }
385
+ .wg-li.flag-2.fj a:before { background-position: -576px 0; }
386
+ .wg-li.flag-2.sm a:before { background-position: -3408px 0; }
387
+ .wg-li.flag-2.ty a:before { background-position: -4512px 0; }
388
+ .wg-li.flag-2.to a:before { background-position: -3264px 0; }
389
+ .wg-li.flag-2.cy a:before { background-position: -4848px 0; }
390
 
391
  .wg-flags.flag-3 a:before {
392
  background-image: url("../images/circular_flag.png");
456
  .wg-li.flag-3.ja a:before { background-position: -2448px 0; }
457
  .wg-li.flag-3.hi a:before { background-position: -2304px 0; }
458
  .wg-li.flag-3.ur a:before { background-position: -1992px 0; }
459
+ .wg-li.flag-3.bn a:before { background-position: -4488px 0; }
460
+ .wg-li.flag-3.fj a:before { background-position: -0px 0; }
461
+ .wg-li.flag-3.sm a:before { background-position: -1248px 0; }
462
+ .wg-li.flag-3.ty a:before { background-position: -1512px 0; }
463
+ .wg-li.flag-3.to a:before { background-position: -1680px 0; }
464
+ .wg-li.flag-3.cy a:before { background-position: -5040px 0; }
simple_html_dom.php CHANGED
@@ -1010,6 +1010,7 @@ class simple_html_dom
1010
  'nobr'=>array('nobr'=>1),
1011
  'b'=>array('b'=>1),
1012
  'option'=>array('option'=>1),
 
1013
  );
1014
 
1015
  function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
@@ -1053,6 +1054,7 @@ class simple_html_dom
1053
  // strip out <script> tags
1054
  $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
1055
  $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
 
1056
  // strip out <style> tags
1057
  $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
1058
  $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
1010
  'nobr'=>array('nobr'=>1),
1011
  'b'=>array('b'=>1),
1012
  'option'=>array('option'=>1),
1013
+ 'source'=>array('source'=>1)
1014
  );
1015
 
1016
  function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1054
  // strip out <script> tags
1055
  $this->remove_noise("'<\s*script[^>]*[^/]>(.*?)<\s*/\s*script\s*>'is");
1056
  $this->remove_noise("'<\s*script\s*>(.*?)<\s*/\s*script\s*>'is");
1057
+ $this->remove_noise("'<\s*noscript\s*>(.*?)<\s*/\s*noscript\s*>'is");
1058
  // strip out <style> tags
1059
  $this->remove_noise("'<\s*style[^>]*[^/]>(.*?)<\s*/\s*style\s*>'is");
1060
  $this->remove_noise("'<\s*style\s*>(.*?)<\s*/\s*style\s*>'is");
weglot.php CHANGED
@@ -1,18 +1,18 @@
1
  <?php
2
  /**
3
  * @package Weglot
4
- * @version 1.6.1
5
  */
6
 
7
  /*
8
  Plugin Name: Weglot Translate
9
  Plugin URI: http://wordpress.org/plugins/Weglot/
10
  Description: Translate your website into multiple languages in minutes without doing any coding. Fully SEO compatible.
11
- Author: Remy B
12
  Author URI: https://weglot.com/
13
  Text Domain: weglot
14
  Domain Path: /languages/
15
- Version: 1.6.1
16
  */
17
 
18
  /*
@@ -83,7 +83,7 @@ do_action( 'weg_fs_loaded' );
83
 
84
 
85
 
86
- define( 'WEGLOT_VERSION', '1.6.1' );
87
  define( 'WEGLOT_DIR', dirname( __FILE__ ) );
88
  define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
89
  define( 'WEGLOT_DIRURL', plugin_dir_url( __FILE__ ) );
@@ -174,6 +174,9 @@ class Weglot {
174
  $GLOBALS['text_direction'] = 'ltr';
175
  }
176
 
 
 
 
177
  $apikey = get_option( 'project_key' );
178
  $this->translator = $apikey ? new \Weglot\Client( $apikey ) : null;
179
  $this->allowed = $apikey ? get_option( 'wg_allowed' ) : true;
@@ -297,6 +300,10 @@ class Weglot {
297
  <?php
298
  }
299
 
 
 
 
 
300
  public function wg_switcher_creation() {
301
  $button = Weglot::Instance()->returnWidgetCode();
302
  echo wp_kses( $button, $this->getAllowedTags());
@@ -422,7 +429,7 @@ class Weglot {
422
  false) {
423
 
424
  $d = explode( ',',preg_replace( '/\s+/', '', trim( $this->destination_l,',' ) ) );
425
- $accepted = array( 'sq', 'en', 'ar', 'hy', 'az', 'af', 'eu', 'be', 'bg', 'bs', 'vi', 'hu', 'ht', 'nl', 'el', 'ka', 'da', 'he', 'id', 'ga', 'it', 'is', 'es', 'kk', 'ca', 'ky', 'zh', 'tw', 'ko', 'lv', 'lt', 'mg', 'ms', 'mt', 'mk', 'mn', 'de', 'no', 'fa', 'pl', 'pt', 'ro', 'ru', 'sr', 'sk', 'sl', 'sw', 'tg', 'th', 'tr', 'uz', 'uk', 'fi', 'fr', 'hr', 'cs', 'sv', 'et', 'ja', 'hi', 'ur' );
426
  foreach ( $d as $k => $l ) {
427
  if ( ! in_array( $l,$accepted ) || $l == $this->original_l ) {
428
  unset( $d[ $k ] );
@@ -580,11 +587,9 @@ class Weglot {
580
  }
581
  $translatedPage = $this->translator->translateDomFromTo( $final,$this->original_l,$l ); // $page is your html page
582
 
583
-
584
-
585
-
586
  $this->modifyLink('/<a([^\>]+?)?href=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'A');
587
  $this->modifyLink('/<([^\>]+?)?data-link=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'DATALINK');
 
588
  $this->modifyLink('/<([^\>]+?)?data-cart-url=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'DATACART');
589
  $this->modifyLink('/<form([^\>]+?)?action=(\"|\')([^\s\>]+?)(\"|\')/',$translatedPage,$l,'FORM');
590
  $this->modifyLink('/<option (.*?)?(\"|\')([^\s\>]+?)(\"|\')(.*?)?>/',
@@ -655,6 +660,14 @@ class Weglot {
655
 
656
  }
657
 
 
 
 
 
 
 
 
 
658
  public function replaceDATACART(&$translatedPage,$current_url,$l,$quote1,
659
  $quote2,$sometags = null, $sometags2 = null) {
660
 
@@ -698,7 +711,7 @@ class Weglot {
698
  }
699
 
700
  public function isLinkAFile($current_url) {
701
- $files = array('pdf','rar','doc','docx','.jpg','.jpeg','.png');
702
  foreach ($files as $file) {
703
  if ( WGUtils::endsWith( $current_url,'.'.$file )) {
704
  return true;
1
  <?php
2
  /**
3
  * @package Weglot
4
+ * @version 1.7
5
  */
6
 
7
  /*
8
  Plugin Name: Weglot Translate
9
  Plugin URI: http://wordpress.org/plugins/Weglot/
10
  Description: Translate your website into multiple languages in minutes without doing any coding. Fully SEO compatible.
11
+ Author: Weglot Translate team
12
  Author URI: https://weglot.com/
13
  Text Domain: weglot
14
  Domain Path: /languages/
15
+ Version: 1.7
16
  */
17
 
18
  /*
83
 
84
 
85
 
86
+ define( 'WEGLOT_VERSION', '1.7' );
87
  define( 'WEGLOT_DIR', dirname( __FILE__ ) );
88
  define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
89
  define( 'WEGLOT_DIRURL', plugin_dir_url( __FILE__ ) );
174
  $GLOBALS['text_direction'] = 'ltr';
175
  }
176
 
177
+
178
+ add_filter( 'woocommerce_get_cart_url' , array( &$this,'filter_woocommerce_get_cart_url'));
179
+
180
  $apikey = get_option( 'project_key' );
181
  $this->translator = $apikey ? new \Weglot\Client( $apikey ) : null;
182
  $this->allowed = $apikey ? get_option( 'wg_allowed' ) : true;
300
  <?php
301
  }
302
 
303
+ function filter_woocommerce_get_cart_url( $wc_get_page_permalink ) {
304
+ return $this->replaceUrl($wc_get_page_permalink, $this->currentlang );
305
+ }
306
+
307
  public function wg_switcher_creation() {
308
  $button = Weglot::Instance()->returnWidgetCode();
309
  echo wp_kses( $button, $this->getAllowedTags());
429
  false) {
430
 
431
  $d = explode( ',',preg_replace( '/\s+/', '', trim( $this->destination_l,',' ) ) );
432
+ $accepted = array( 'sq', 'en', 'ar', 'hy', 'az', 'af', 'eu', 'be', 'bg', 'bs', 'vi', 'hu', 'ht', 'nl', 'el', 'ka', 'da', 'he', 'id', 'ga', 'it', 'is', 'es', 'kk', 'ca', 'ky', 'zh', 'tw', 'ko', 'lv', 'lt', 'mg', 'ms', 'mt', 'mk', 'mn', 'de', 'no', 'fa', 'pl', 'pt', 'ro', 'ru', 'sr', 'sk', 'sl', 'sw', 'tg', 'th', 'tr', 'uz', 'uk', 'fi', 'fr', 'hr', 'cs', 'sv', 'et', 'ja', 'hi', 'ur','bn','fj','sm','ty','to','cy' );
433
  foreach ( $d as $k => $l ) {
434
  if ( ! in_array( $l,$accepted ) || $l == $this->original_l ) {
435
  unset( $d[ $k ] );
587
  }
588
  $translatedPage = $this->translator->translateDomFromTo( $final,$this->original_l,$l ); // $page is your html page
589
 
 
 
 
590
  $this->modifyLink('/<a([^\>]+?)?href=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'A');
591
  $this->modifyLink('/<([^\>]+?)?data-link=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'DATALINK');
592
+ $this->modifyLink('/<([^\>]+?)?data-url=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'DATAURL');
593
  $this->modifyLink('/<([^\>]+?)?data-cart-url=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$l,'DATACART');
594
  $this->modifyLink('/<form([^\>]+?)?action=(\"|\')([^\s\>]+?)(\"|\')/',$translatedPage,$l,'FORM');
595
  $this->modifyLink('/<option (.*?)?(\"|\')([^\s\>]+?)(\"|\')(.*?)?>/',
660
 
661
  }
662
 
663
+ public function replaceDATAURL(&$translatedPage,$current_url,$l,$quote1,
664
+ $quote2,$sometags = null, $sometags2 = null) {
665
+ $translatedPage = preg_replace( '/<' . preg_quote( $sometags,'/' ) . 'data-url=' . preg_quote( $quote1 . $current_url . $quote2,'/' ) . '/'
666
+ ,'<' . $sometags . 'data-url=' . $quote1 . $this->replaceUrl(
667
+ $current_url,$l ) . $quote2,$translatedPage );
668
+
669
+ }
670
+
671
  public function replaceDATACART(&$translatedPage,$current_url,$l,$quote1,
672
  $quote2,$sometags = null, $sometags2 = null) {
673
 
711
  }
712
 
713
  public function isLinkAFile($current_url) {
714
+ $files = array('pdf','rar','doc','docx','jpg','jpeg','png');
715
  foreach ($files as $file) {
716
  if ( WGUtils::endsWith( $current_url,'.'.$file )) {
717
  return true;