Weglot Translate – Translate your WP website - Version 1.8.2

Version Description

  • Fix pb when permalinks has no ending slash
  • Add notif when plugin is not congigured
Download this release

Release Info

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

Code changes from version 1.8.1 to 1.8.2

Files changed (2) hide show
  1. readme.txt +6 -1
  2. weglot.php +23 -8
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.9
6
- Stable tag: 1.8.1
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -147,6 +147,11 @@ See changelog for upgrade changes.
147
 
148
  == Changelog ==
149
 
 
 
 
 
 
150
  = 1.8.1 =
151
  * Fix redirection on woocommerce
152
 
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.9
6
+ Stable tag: 1.8.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
147
 
148
  == Changelog ==
149
 
150
+ = 1.8.2 =
151
+ * Fix pb when permalinks has no ending slash
152
+ * Add notif when plugin is not congigured
153
+
154
+
155
  = 1.8.1 =
156
  * Fix redirection on woocommerce
157
 
weglot.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * @package Weglot
4
- * @version 1.8.1
5
  */
6
 
7
  /*
@@ -12,7 +12,7 @@ Author: Weglot Translate team
12
  Author URI: https://weglot.com/
13
  Text Domain: weglot
14
  Domain Path: /languages/
15
- Version: 1.8.1
16
  */
17
 
18
  /*
@@ -83,7 +83,7 @@ do_action( 'weg_fs_loaded' );
83
 
84
 
85
 
86
- define( 'WEGLOT_VERSION', '1.8.1' );
87
  define( 'WEGLOT_DIR', dirname( __FILE__ ) );
88
  define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
89
  define( 'WEGLOT_DIRURL', plugin_dir_url( __FILE__ ) );
@@ -180,7 +180,6 @@ class Weglot {
180
 
181
  //add_filter( 'wp_mail' , array( &$this, 'translate_emails'), 10,1);
182
 
183
-
184
  $apikey = get_option( 'project_key' );
185
  $this->translator = $apikey ? new \Weglot\Client( $apikey ) : null;
186
  $this->allowed = $apikey ? get_option( 'wg_allowed' ) : true;
@@ -201,6 +200,8 @@ class Weglot {
201
  }
202
  } elseif ( $this->allowed == 0 ) {
203
  add_action( 'admin_notices', array( &$this, 'wg_admin_notice1' ),0 );
 
 
204
  }
205
  }
206
 
@@ -304,6 +305,14 @@ class Weglot {
304
  <?php
305
  }
306
 
 
 
 
 
 
 
 
 
307
  public function filter_woocommerce_get_cart_url( $wc_get_page_permalink ) {
308
  if($this->currentlang != $this->original_l) {
309
  return $this->replaceUrl($wc_get_page_permalink, $this->currentlang);
@@ -316,13 +325,20 @@ class Weglot {
316
  public function filter_woocommerce_get_checkout_order_received_url( $order_received_url ) {
317
 
318
  if($this->currentlang != $this->original_l) {
319
- return $this->replaceUrl($order_received_url, $this->currentlang);
 
 
 
320
  }
321
  else {
322
  if(isset($_SERVER['HTTP_REFERER'])) {
323
  $l = $this->getLangFromUrl($this->URLToRelative( $_SERVER['HTTP_REFERER']));
324
- if($l && $l != $this->original_l)
325
- return $this->replaceUrl($order_received_url, $l);
 
 
 
 
326
  }
327
  return $order_received_url;
328
  }
@@ -784,7 +800,6 @@ class Weglot {
784
  $query = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
785
  $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
786
 
787
- $path = rtrim($path, '/') . '/';
788
 
789
  if ( $l == '' ) {
790
  return $url;
1
  <?php
2
  /**
3
  * @package Weglot
4
+ * @version 1.8.2
5
  */
6
 
7
  /*
12
  Author URI: https://weglot.com/
13
  Text Domain: weglot
14
  Domain Path: /languages/
15
+ Version: 1.8.2
16
  */
17
 
18
  /*
83
 
84
 
85
 
86
+ define( 'WEGLOT_VERSION', '1.8.2' );
87
  define( 'WEGLOT_DIR', dirname( __FILE__ ) );
88
  define( 'WEGLOT_BNAME', plugin_basename( __FILE__ ) );
89
  define( 'WEGLOT_DIRURL', plugin_dir_url( __FILE__ ) );
180
 
181
  //add_filter( 'wp_mail' , array( &$this, 'translate_emails'), 10,1);
182
 
 
183
  $apikey = get_option( 'project_key' );
184
  $this->translator = $apikey ? new \Weglot\Client( $apikey ) : null;
185
  $this->allowed = $apikey ? get_option( 'wg_allowed' ) : true;
200
  }
201
  } elseif ( $this->allowed == 0 ) {
202
  add_action( 'admin_notices', array( &$this, 'wg_admin_notice1' ),0 );
203
+ } elseif ( !$apikey ) {
204
+ add_action( 'admin_notices', array( &$this, 'wg_admin_notice4' ),0 );
205
  }
206
  }
207
 
305
  <?php
306
  }
307
 
308
+ public function wg_admin_notice4() {
309
+ ?>
310
+ <div class="error settings-error notice is-dismissible">
311
+ <p><?php echo sprintf( esc_html__( 'Weglot Translate is installed but not yet configured, you need to configure Weglot here : %1$sWeglot configuration page%2$s. The configuration takes only 1 minute! ', 'weglot' ), '<a href="'.admin_url().'admin.php?page=Weglot">', '</a>'); ?></p>
312
+ </div>
313
+ <?php
314
+ }
315
+
316
  public function filter_woocommerce_get_cart_url( $wc_get_page_permalink ) {
317
  if($this->currentlang != $this->original_l) {
318
  return $this->replaceUrl($wc_get_page_permalink, $this->currentlang);
325
  public function filter_woocommerce_get_checkout_order_received_url( $order_received_url ) {
326
 
327
  if($this->currentlang != $this->original_l) {
328
+ if(substr(get_option( 'permalink_structure' ),-1) == '/')
329
+ return str_replace('?key','/?key',$this->replaceUrl($order_received_url, $this->currentlang));
330
+ else
331
+ return $this->replaceUrl($order_received_url, $this->currentlang);
332
  }
333
  else {
334
  if(isset($_SERVER['HTTP_REFERER'])) {
335
  $l = $this->getLangFromUrl($this->URLToRelative( $_SERVER['HTTP_REFERER']));
336
+ if($l && $l != $this->original_l) {
337
+ if(substr(get_option( 'permalink_structure' ),-1) == '/')
338
+ return str_replace('?key','/?key',$this->replaceUrl($order_received_url, $l));
339
+ else
340
+ return $this->replaceUrl($order_received_url, $l);
341
+ }
342
  }
343
  return $order_received_url;
344
  }
800
  $query = isset( $parsed_url['query'] ) ? '?' . $parsed_url['query'] : '';
801
  $fragment = isset( $parsed_url['fragment'] ) ? '#' . $parsed_url['fragment'] : '';
802
 
 
803
 
804
  if ( $l == '' ) {
805
  return $url;