Translate WordPress with GTranslate - Version 2.8.4

Version Description

  • New option to select in which menu the selector should appear
Download this release

Release Info

Developer edo888
Plugin Icon 128x128 Translate WordPress with GTranslate
Version 2.8.4
Comparing to
See all releases

Code changes from version 2.8.3 to 2.8.4

Files changed (2) hide show
  1. gtranslate.php +22 -16
  2. readme.txt +4 -1
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
- Version: 2.8.3
7
  Author: Edvard Ananyan
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -47,16 +47,19 @@ if(is_admin()) {
47
  $data = get_option('GTranslate');
48
  GTranslate::load_defaults($data);
49
 
50
- if($data['show_in_primary_menu']) {
51
  add_filter('wp_nav_menu_items', 'gtranslate_menu_item', 10, 2);
52
  function gtranslate_menu_item($items, $args) {
53
- if($args->theme_location == 'primary')
 
 
 
54
  $items .= '<li style="position:relative;" class="menu-item menu-item-gtranslate"><div style="position:absolute;">'.GTranslate::get_widget_code(false).'</div></li>';
55
  return $items;
56
  }
57
  }
58
 
59
- if($data['floating_language_selector'] != 'no' and !$data['show_in_primary_menu'] and !is_admin()) {
60
  add_action('wp_footer', 'gtranslate_display_floating');
61
  function gtranslate_display_floating() {
62
  $data = get_option('GTranslate');
@@ -254,7 +257,7 @@ function RefreshDoWidgetCode() {
254
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
255
  var enterprise_version = jQuery('#enterprise_version:checked').length > 0 ? true : false;
256
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
257
- var show_in_primary_menu = jQuery('#show_in_primary_menu:checked').length > 0 ? true : false;
258
  var floating_language_selector = jQuery('#floating_language_selector').val();
259
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
260
 
@@ -300,12 +303,6 @@ function RefreshDoWidgetCode() {
300
  jQuery('#flag_size_option').show();
301
  }
302
 
303
- if(show_in_primary_menu) {
304
- jQuery('#floating_option').hide();
305
- } else {
306
- jQuery('#floating_option').show();
307
- }
308
-
309
  if(pro_version && enterprise_version)
310
  pro_version = false;
311
 
@@ -600,7 +597,7 @@ jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
600
  jQuery('#enterprise_version').attr('checked', '$enterprise_version'.length > 0);
601
  jQuery('#url_translation').attr('checked', '$url_translation'.length > 0);
602
  jQuery('#new_window').attr('checked', '$new_window'.length > 0);
603
- jQuery('#show_in_primary_menu').attr('checked', '$show_in_primary_menu'.length > 0);
604
  jQuery('#floating_language_selector').val('$floating_language_selector');
605
  jQuery('#analytics').attr('checked', '$analytics'.length > 0);
606
  jQuery('#load_jquery').attr('checked', '$load_jquery'.length > 0);
@@ -855,8 +852,17 @@ foreach($alt_flags as $flag)
855
  <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
856
  </tr>
857
  <tr>
858
- <td class="option_name"><?php _e('Show in primary menu', 'gtranslate'); ?>:</td>
859
- <td><input id="show_in_primary_menu" name="show_in_primary_menu" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
 
 
 
 
 
 
 
 
 
860
  </tr>
861
  <tr id="floating_option">
862
  <td class="option_name"><?php _e('Show floating language selector', 'gtranslate'); ?>:</td>
@@ -1063,7 +1069,7 @@ foreach($alt_flags as $flag)
1063
  $data['enterprise_version'] = isset($_POST['enterprise_version']) ? intval($_POST['enterprise_version']) : '';
1064
  $data['url_translation'] = isset($_POST['url_translation']) ? intval($_POST['url_translation']) : '';
1065
  $data['new_window'] = isset($_POST['new_window']) ? intval($_POST['new_window']) : '';
1066
- $data['show_in_primary_menu'] = isset($_POST['show_in_primary_menu']) ? intval($_POST['show_in_primary_menu']) : '';
1067
  $data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
1068
  $data['analytics'] = isset($_POST['analytics']) ? intval($_POST['analytics']) : '';
1069
  $data['load_jquery'] = isset($_POST['load_jquery']) ? intval($_POST['load_jquery']) : '';
@@ -1116,7 +1122,7 @@ foreach($alt_flags as $flag)
1116
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
1117
  $data['url_translation'] = isset($data['url_translation']) ? $data['url_translation'] : '';
1118
  $data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
1119
- $data['show_in_primary_menu'] = isset($data['show_in_primary_menu']) ? $data['show_in_primary_menu'] : '';
1120
  $data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
1121
  $data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
1122
  $data['load_jquery'] = isset($data['load_jquery']) ? $data['load_jquery'] : '1';
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
+ Version: 2.8.4
7
  Author: Edvard Ananyan
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
47
  $data = get_option('GTranslate');
48
  GTranslate::load_defaults($data);
49
 
50
+ if(!empty($data['show_in_menu'])) {
51
  add_filter('wp_nav_menu_items', 'gtranslate_menu_item', 10, 2);
52
  function gtranslate_menu_item($items, $args) {
53
+ $data = get_option('GTranslate');
54
+ GTranslate::load_defaults($data);
55
+
56
+ if($args->theme_location == $data['show_in_menu'])
57
  $items .= '<li style="position:relative;" class="menu-item menu-item-gtranslate"><div style="position:absolute;">'.GTranslate::get_widget_code(false).'</div></li>';
58
  return $items;
59
  }
60
  }
61
 
62
+ if($data['floating_language_selector'] != 'no' and !is_admin()) {
63
  add_action('wp_footer', 'gtranslate_display_floating');
64
  function gtranslate_display_floating() {
65
  $data = get_option('GTranslate');
257
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
258
  var enterprise_version = jQuery('#enterprise_version:checked').length > 0 ? true : false;
259
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
260
+ var show_in_menu = jQuery('#show_in_menu').val();
261
  var floating_language_selector = jQuery('#floating_language_selector').val();
262
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
263
 
303
  jQuery('#flag_size_option').show();
304
  }
305
 
 
 
 
 
 
 
306
  if(pro_version && enterprise_version)
307
  pro_version = false;
308
 
597
  jQuery('#enterprise_version').attr('checked', '$enterprise_version'.length > 0);
598
  jQuery('#url_translation').attr('checked', '$url_translation'.length > 0);
599
  jQuery('#new_window').attr('checked', '$new_window'.length > 0);
600
+ jQuery('#show_in_menu').val('$show_in_menu');
601
  jQuery('#floating_language_selector').val('$floating_language_selector');
602
  jQuery('#analytics').attr('checked', '$analytics'.length > 0);
603
  jQuery('#load_jquery').attr('checked', '$load_jquery'.length > 0);
852
  <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
853
  </tr>
854
  <tr>
855
+ <td class="option_name"><?php _e('Show in menu', 'gtranslate'); ?>:</td>
856
+ <td>
857
+ <select id="show_in_menu" name="show_in_menu">
858
+ <option value="" selected> - <?php _e('None', 'gtranslate'); ?> - </option>
859
+ <?php $menus = get_registered_nav_menus(); ?>
860
+ <?php foreach($menus as $location => $description): ?>
861
+ <option value="<?php echo $location; ?>"><?php echo $description; ?></option>
862
+ <?php endforeach; ?>
863
+ </select>
864
+ <!--input id="show_in_primary_menu" name="show_in_primary_menu" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/-->
865
+ </td>
866
  </tr>
867
  <tr id="floating_option">
868
  <td class="option_name"><?php _e('Show floating language selector', 'gtranslate'); ?>:</td>
1069
  $data['enterprise_version'] = isset($_POST['enterprise_version']) ? intval($_POST['enterprise_version']) : '';
1070
  $data['url_translation'] = isset($_POST['url_translation']) ? intval($_POST['url_translation']) : '';
1071
  $data['new_window'] = isset($_POST['new_window']) ? intval($_POST['new_window']) : '';
1072
+ $data['show_in_menu'] = isset($_POST['show_in_menu']) ? sanitize_text_field($_POST['show_in_menu']) : '';
1073
  $data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
1074
  $data['analytics'] = isset($_POST['analytics']) ? intval($_POST['analytics']) : '';
1075
  $data['load_jquery'] = isset($_POST['load_jquery']) ? intval($_POST['load_jquery']) : '';
1122
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
1123
  $data['url_translation'] = isset($data['url_translation']) ? $data['url_translation'] : '';
1124
  $data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
1125
+ $data['show_in_menu'] = isset($data['show_in_menu']) ? $data['show_in_menu'] : ((isset($data['show_in_primary_menu']) and $data['show_in_primary_menu'] == 1) ? 'primary' : '');
1126
  $data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
1127
  $data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
1128
  $data['load_jquery'] = isset($data['load_jquery']) ? $data['load_jquery'] : '1';
readme.txt CHANGED
@@ -4,7 +4,7 @@ Author: Edvard Ananyan
4
  Tags: translation proxy, localization, translate, translation, localization, google translate, language, multilingual, multilanguage, bilingual, tradurre, traducir, traduire, traduzione, ubersetzung, mehrsprachig, oversette, oversatta, vertaling, vertaler, meertalig, polylang, qtranslate, transposh
5
  Requires at least: 2.8
6
  Tested up to: 4.7
7
- Stable tag: 2.8.3
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
@@ -410,6 +410,9 @@ You need to go to the language you want to edit, for instance, French: http://do
410
 
411
  == Changelog ==
412
 
 
 
 
413
  = 2.8.3 =
414
  * Added URL add-on to easily enable sub-directory URL structure (paid)
415
  * New option to easily enable URL Translation
4
  Tags: translation proxy, localization, translate, translation, localization, google translate, language, multilingual, multilanguage, bilingual, tradurre, traducir, traduire, traduzione, ubersetzung, mehrsprachig, oversette, oversatta, vertaling, vertaler, meertalig, polylang, qtranslate, transposh
5
  Requires at least: 2.8
6
  Tested up to: 4.7
7
+ Stable tag: 2.8.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
410
 
411
  == Changelog ==
412
 
413
+ = 2.8.4 =
414
+ * New option to select in which menu the selector should appear
415
+
416
  = 2.8.3 =
417
  * Added URL add-on to easily enable sub-directory URL structure (paid)
418
  * New option to easily enable URL Translation