Translate WordPress with GTranslate - Version 2.0.5

Version Description

  • New widget look has been added: Nice dropdown with flags
  • Hiding and showing options in settings interface to be user friendly
Download this release

Release Info

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

Code changes from version 2.0.4 to 2.0.5

Files changed (6) hide show
  1. arrow_down.png +0 -0
  2. gtranslate.php +164 -26
  3. readme.txt +8 -2
  4. screenshot-2.jpg +0 -0
  5. screenshot-3.jpg +0 -0
  6. switcher.png +0 -0
arrow_down.png ADDED
Binary file
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: http://gtranslate.net/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="http://gtranslate.net/forum/">GTranslate Forum</a>.
6
- Version: 2.0.4
7
  Author: Edvard Ananyan
8
  Author URI: http://gtranslate.net
9
 
@@ -78,6 +78,7 @@ class GTranslate extends WP_Widget {
78
  $wp_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
79
 
80
  wp_enqueue_style('gtranslate-style', $wp_plugin_url.'/gtranslate-style'.$data['flag_size'].'.css');
 
81
  }
82
 
83
  function widget($args) {
@@ -141,7 +142,8 @@ function RefreshDoWidgetCode() {
141
  var new_line = "\\n";
142
  var widget_preview = '<!-- GTranslate: http://gtranslate.net/ -->'+new_line;
143
  var widget_code = '';
144
- var translation_method = jQuery('#translation_method').val();
 
145
  var default_language = jQuery('#default_language').val();
146
  var flag_size = jQuery('#flag_size').val();
147
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
@@ -149,8 +151,36 @@ function RefreshDoWidgetCode() {
149
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
150
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
151
 
152
- if(pro_version || enterprise_version)
153
  translation_method = 'redirect';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
 
155
  if(pro_version && enterprise_version)
156
  pro_version = false;
@@ -178,7 +208,8 @@ function RefreshDoWidgetCode() {
178
  widget_preview += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"><\/script>'+new_line;
179
  } else if(translation_method == 'on_fly' || translation_method == 'redirect' || translation_method == 'onfly') {
180
  // Adding flags
181
- if(jQuery('#show_flags:checked').length) {
 
182
  jQuery.each(languages, function(i, val) {
183
  lang = language_codes[i];
184
  if(jQuery('#fincl_langs'+lang+':checked').length) {
@@ -198,8 +229,9 @@ function RefreshDoWidgetCode() {
198
  }
199
 
200
  // Adding dropdown
201
- if(jQuery('#show_dropdown:checked').length) {
202
- if(jQuery('#show_flags:checked').length && jQuery('#add_new_line:checked').length)
 
203
  widget_preview += '<br />';
204
  else
205
  widget_preview += ' ';
@@ -217,6 +249,8 @@ function RefreshDoWidgetCode() {
217
 
218
  // Adding onfly html and css
219
  if(translation_method == 'onfly') {
 
 
220
  widget_code += '<style type="text/css">'+new_line;
221
  widget_code += '<!--'+new_line;
222
  widget_code += "#goog-gt-tt {display:none !important;}"+new_line;
@@ -236,7 +270,63 @@ function RefreshDoWidgetCode() {
236
  widget_code += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"><\/script>'+new_line;
237
  }
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  // Adding javascript
 
 
240
  widget_code += new_line+new_line;
241
  widget_code += '<script type="text/javascript">'+new_line;
242
  widget_code += '/* <![CDATA[ */'+new_line;
@@ -281,6 +371,10 @@ function RefreshDoWidgetCode() {
281
  widget_code += 'function gfg(name) {name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(location.href);if(results==null)return "";return results[1];}'+new_line;
282
  } else if(translation_method == 'onfly') {
283
  widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var teCombo;var sel=document.getElementsByTagName('select');for(var i=0;i<sel.length;i++)if(sel[i].className=='goog-te-combo')teCombo=sel[i];if(document.getElementById('google_translate_element2')==null||document.getElementById('google_translate_element2').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,'change');GTranslateFireEvent(teCombo,'change')}}"+new_line;
 
 
 
 
284
  }
285
 
286
  widget_code += '/* ]]> */'+new_line;
@@ -303,6 +397,8 @@ function ShowWidgetPreview(widget_preview) {
303
 
304
  jQuery('head').append( jQuery('<link rel="stylesheet" type="text/css" />').attr('href', '$wp_plugin_url/gtranslate-style'+jQuery('#flag_size').val()+'.css') );
305
  jQuery('#widget_preview').html(widget_preview);
 
 
306
  }
307
 
308
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
@@ -311,13 +407,41 @@ jQuery('#new_window').attr('checked', '$new_window'.length > 0);
311
  jQuery('#analytics').attr('checked', '$analytics'.length > 0);
312
  jQuery('#load_jquery').attr('checked', '$load_jquery'.length > 0);
313
  jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
314
- jQuery('#show_dropdown').attr('checked', '$show_dropdown'.length > 0);
315
- jQuery('#show_flags').attr('checked', '$show_flags'.length > 0);
316
 
317
  jQuery('#default_language').val('$default_language');
318
- jQuery('#translation_method').val('$translation_method');
 
319
  jQuery('#flag_size').val('$flag_size');
320
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
321
  if(jQuery('#widget_code').val() == '')
322
  RefreshDoWidgetCode();
323
  else
@@ -344,7 +468,7 @@ foreach($fincl_langs as $lang)
344
  <h3 id="settings">Widget options</h3>
345
  <div class="inside">
346
  <table style="width:100%;" cellpadding="4">
347
- <tr>
348
  <td class="option_name">Translation method:</td>
349
  <td>
350
  <select id="translation_method" name="translation_method" onChange="RefreshDoWidgetCode()">
@@ -353,6 +477,17 @@ foreach($fincl_langs as $lang)
353
  <option value="onfly">On Fly</option>
354
  </select>
355
  </td>
 
 
 
 
 
 
 
 
 
 
 
356
  </tr>
357
  <tr>
358
  <td class="option_name">Default language:</td>
@@ -453,10 +588,6 @@ foreach($fincl_langs as $lang)
453
  </select>
454
  </td>
455
  </tr>
456
- <tr>
457
- <td class="option_name">Open in new window:</td>
458
- <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
459
- </tr>
460
  <tr>
461
  <td class="option_name">Analytics:</td>
462
  <td><input id="analytics" name="analytics" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
@@ -469,11 +600,16 @@ foreach($fincl_langs as $lang)
469
  <td class="option_name">Operate with Enterprise version:</td>
470
  <td><input id="enterprise_version" name="enterprise_version" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
471
  </tr>
472
- <tr>
 
 
 
 
 
473
  <td class="option_name">Show flags:</td>
474
  <td><input id="show_flags" name="show_flags" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
475
- </tr>
476
- <tr>
477
  <td class="option_name">Flag size:</td>
478
  <td>
479
  <select id="flag_size" name="flag_size" onchange="RefreshDoWidgetCode()">
@@ -483,7 +619,7 @@ foreach($fincl_langs as $lang)
483
  </select>
484
  </td>
485
  </tr>
486
- <tr>
487
  <td class="option_name" colspan="2">Flag languages:<br /><br />
488
 
489
  <div>
@@ -557,15 +693,15 @@ foreach($fincl_langs as $lang)
557
  <br /><br />
558
  </td>
559
  </tr>
560
- <tr>
561
  <td class="option_name">Line break after flags:</td>
562
  <td><input id="add_new_line" name="add_new_line" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
563
  </tr>
564
- <tr>
565
  <td class="option_name">Show dropdown:</td>
566
  <td><input id="show_dropdown" name="show_dropdown" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
567
- </tr>
568
- <tr>
569
  <td class="option_name" colspan="2">Dropdown languages:<br /><br />
570
  <div>
571
  <div style="width:25%;float:left;">
@@ -794,10 +930,11 @@ foreach($fincl_langs as $lang)
794
  $data['analytics'] = isset($_POST['analytics']) ? $_POST['analytics'] : '';
795
  $data['load_jquery'] = isset($_POST['load_jquery']) ? $_POST['load_jquery'] : '';
796
  $data['add_new_line'] = isset($_POST['add_new_line']) ? $_POST['add_new_line'] : '';
797
- $data['show_dropdown'] = isset($_POST['show_dropdown']) ? $_POST['show_dropdown'] : '';
798
- $data['show_flags'] = isset($_POST['show_flags']) ? $_POST['show_flags'] : '';
799
  $data['default_language'] = $_POST['default_language'];
800
  $data['translation_method'] = $_POST['translation_method'];
 
801
  $data['flag_size'] = $_POST['flag_size'];
802
  $data['widget_code'] = stripslashes($_POST['widget_code']);
803
  $data['incl_langs'] = $_POST['incl_langs'];
@@ -814,11 +951,12 @@ foreach($fincl_langs as $lang)
814
  $data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
815
  $data['load_jquery'] = isset($data['load_jquery']) ? $data['load_jquery'] : '1';
816
  $data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
817
- $data['show_dropdown'] = isset($data['show_dropdown']) ? $data['show_dropdown'] : '1';
818
- $data['show_flags'] = isset($data['show_flags']) ? $data['show_flags'] : '1';
819
  $data['default_language'] = isset($data['default_language']) ? $data['default_language'] : 'en';
820
  $data['translation_method'] = isset($data['translation_method']) ? $data['translation_method'] : 'onfly';
821
  if($data['translation_method'] == 'on_fly') $data['translation_method'] = 'redirect';
 
822
  $data['flag_size'] = isset($data['flag_size']) ? $data['flag_size'] : '16';
823
  $data['widget_code'] = isset($data['widget_code']) ? $data['widget_code'] : '';
824
  $data['incl_langs'] = isset($data['incl_langs']) ? $data['incl_langs'] : array();
3
  Plugin Name: GTranslate
4
  Plugin URI: http://gtranslate.net/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="http://gtranslate.net/forum/">GTranslate Forum</a>.
6
+ Version: 2.0.5
7
  Author: Edvard Ananyan
8
  Author URI: http://gtranslate.net
9
 
78
  $wp_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
79
 
80
  wp_enqueue_style('gtranslate-style', $wp_plugin_url.'/gtranslate-style'.$data['flag_size'].'.css');
81
+ wp_enqueue_script('jquery');
82
  }
83
 
84
  function widget($args) {
142
  var new_line = "\\n";
143
  var widget_preview = '<!-- GTranslate: http://gtranslate.net/ -->'+new_line;
144
  var widget_code = '';
145
+ var translation_method = 'onfly'; //jQuery('#translation_method').val();
146
+ var widget_look = jQuery('#widget_look').val();
147
  var default_language = jQuery('#default_language').val();
148
  var flag_size = jQuery('#flag_size').val();
149
  var pro_version = jQuery('#pro_version:checked').length > 0 ? true : false;
151
  var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
152
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
153
 
154
+ if(pro_version || enterprise_version) {
155
  translation_method = 'redirect';
156
+ jQuery('#new_window_option').show();
157
+ } else {
158
+ jQuery('#new_window_option').hide();
159
+ }
160
+
161
+ if(widget_look == 'dropdown' || widget_look == 'flags_dropdown') {
162
+ jQuery('#dropdown_languages_option').show();
163
+ } else {
164
+ jQuery('#dropdown_languages_option').hide();
165
+ }
166
+
167
+ if(widget_look == 'flags' || widget_look == 'flags_dropdown' || widget_look == 'dropdown_with_flags') {
168
+ jQuery('#flag_languages_option').show();
169
+ } else {
170
+ jQuery('#flag_languages_option').hide();
171
+ }
172
+
173
+ if(widget_look == 'flags' || widget_look == 'dropdown' || widget_look == 'dropdown_with_flags') {
174
+ jQuery('#line_break_option').hide();
175
+ } else {
176
+ jQuery('#line_break_option').show();
177
+ }
178
+
179
+ if(widget_look == 'dropdown_with_flags' || widget_look == 'dropdown') {
180
+ jQuery('#flag_size_option').hide();
181
+ } else {
182
+ jQuery('#flag_size_option').show();
183
+ }
184
 
185
  if(pro_version && enterprise_version)
186
  pro_version = false;
208
  widget_preview += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"><\/script>'+new_line;
209
  } else if(translation_method == 'on_fly' || translation_method == 'redirect' || translation_method == 'onfly') {
210
  // Adding flags
211
+ if(widget_look == 'flags' || widget_look == 'flags_dropdown' /* jQuery('#show_flags:checked').length */) {
212
+ //console.log('adding flags');
213
  jQuery.each(languages, function(i, val) {
214
  lang = language_codes[i];
215
  if(jQuery('#fincl_langs'+lang+':checked').length) {
229
  }
230
 
231
  // Adding dropdown
232
+ if(widget_look == 'dropdown' || widget_look == 'flags_dropdown' /* jQuery('#show_dropdown:checked').length */) {
233
+ //console.log('adding dropdown');
234
+ if(/* jQuery('#show_flags:checked').length*/ (widget_look == 'flags' || widget_look == 'flags_dropdown') && jQuery('#add_new_line:checked').length)
235
  widget_preview += '<br />';
236
  else
237
  widget_preview += ' ';
249
 
250
  // Adding onfly html and css
251
  if(translation_method == 'onfly') {
252
+ //console.log('adding onfly html, css and javascript');
253
+
254
  widget_code += '<style type="text/css">'+new_line;
255
  widget_code += '<!--'+new_line;
256
  widget_code += "#goog-gt-tt {display:none !important;}"+new_line;
270
  widget_code += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"><\/script>'+new_line;
271
  }
272
 
273
+ if(widget_look == 'dropdown_with_flags') {
274
+ // Adding slider html
275
+ widget_preview += '<div class="switcher notranslate">'+new_line;
276
+ widget_preview += '<div class="selected">'+new_line;
277
+ widget_preview += '<a href="#" onclick="return false;"><span class="gflag" style="background-position:-'+languages_map[default_language.replace('-', '')+'_x']+'px -'+languages_map[default_language.replace('-', '')+'_y']+'px;"><img src="$wp_plugin_url/blank.png" height="'+16+'" width="'+16+'" alt="'+default_language+'" /></span>'+languages[language_codes.indexOf(default_language)]+'</a>'+new_line;
278
+ widget_preview += '</div>'+new_line;
279
+ widget_preview += '<div class="option">'+new_line;
280
+ jQuery.each(languages, function(i, val) {
281
+ lang = language_codes[i];
282
+ if(jQuery('#fincl_langs'+lang+':checked').length) {
283
+ lang_name = val;
284
+ flag_x = languages_map[lang.replace('-', '')+'_x'];
285
+ flag_y = languages_map[lang.replace('-', '')+'_y'];
286
+
287
+ var href = '#';
288
+ if(pro_version)
289
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
290
+ else if(enterprise_version)
291
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
292
+
293
+ widget_preview += '<a href="'+href+'" onclick="doGTranslate(\''+default_language+'|'+lang+'\');jQuery(this).parent().parent().find(\'div.selected a\').html(jQuery(this).html());return false;" title="'+lang_name+'" class="nturl'+(default_language == lang ? ' selected' : '')+'"><span class="gflag" style="background-position:-'+flag_x+'px -'+flag_y+'px;"><img src="$wp_plugin_url/blank.png" height="'+16+'" width="'+16+'" alt="'+lang+'" /></span>'+lang_name+'</a>';
294
+ }
295
+ });
296
+
297
+ widget_preview += '</div>'+new_line;
298
+ widget_preview += '</div>'+new_line;
299
+
300
+ // Adding slider javascript
301
+ widget_preview += '<script type="text/javascript">'+new_line;
302
+ widget_preview += "jQuery('.switcher .selected').click(function() {if(!(jQuery('.switcher .option').is(':visible'))) {jQuery('.switcher .option').stop(true,true).delay(50).slideDown(800);}});"+new_line;
303
+ widget_preview += "jQuery('body').not('.switcher .selected').mousedown(function() {if(jQuery('.switcher .option').is(':visible')) {jQuery('.switcher .option').stop(true,true).delay(300).slideUp(800);}});"+new_line;
304
+ widget_preview += '<\/script>'+new_line;
305
+
306
+ // Adding slider css
307
+ widget_preview += '<style type="text/css">'+new_line;
308
+ widget_preview += '<!--'+new_line;
309
+ widget_preview += 'span.gflag {font-size:16px;padding:1px 0;background-repeat:no-repeat;background-image:url($wp_plugin_url/16.png);}'+new_line;
310
+ widget_preview += 'span.gflag img {border:0;margin-top:2px;}'+new_line;
311
+ widget_preview += '.switcher {font-family:Arial;font-size:10pt;text-align:left;cursor:pointer;overflow:hidden;width:163px;line-height:16px;}'+new_line;
312
+ widget_preview += '.switcher a {text-decoration:none;display:block;font-size:10pt;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}'+new_line;
313
+ widget_preview += '.switcher a span.gflag {margin-right:3px;padding:0;display:block;float:left;}'+new_line;
314
+ widget_preview += '.switcher .selected {background:#FFFFFF url($wp_plugin_url/switcher.png) repeat-x;position:relative;z-index:9999;}'+new_line;
315
+ widget_preview += '.switcher .selected a {border:1px solid #CCCCCC;background:url($wp_plugin_url/arrow_down.png) 146px center no-repeat;color:#666666;padding:3px 5px;width:151px;}'+new_line;
316
+ widget_preview += '.switcher .selected a:hover {background:#F0F0F0 url($wp_plugin_url/arrow_down.png) 146px center no-repeat;}'+new_line;
317
+ widget_preview += '.switcher .option {position:relative;z-index:9998;border-left:1px solid #CCCCCC;border-right:1px solid #CCCCCC;border-bottom:1px solid #CCCCCC;background-color:#EEEEEE;display:none;width:161px;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;}'+new_line;
318
+ widget_preview += '.switcher .option a {color:#000;padding:3px 5px;}'+new_line;
319
+ widget_preview += '.switcher .option a:hover {background:#FFC;}'+new_line;
320
+ widget_preview += '.switcher .option a.selected {background:#FFC;}'+new_line;
321
+ widget_preview += '#selected_lang_name {float: none;}'+new_line;
322
+ widget_preview += '.l_name {float: none !important;margin: 0;}'+new_line;
323
+ widget_preview += '-->'+new_line;
324
+ widget_preview += '</style>'+new_line+new_line;
325
+ }
326
+
327
  // Adding javascript
328
+ //console.log('adding doGTranslate javascript');
329
+
330
  widget_code += new_line+new_line;
331
  widget_code += '<script type="text/javascript">'+new_line;
332
  widget_code += '/* <![CDATA[ */'+new_line;
371
  widget_code += 'function gfg(name) {name=name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");var regexS="[\\?&]"+name+"=([^&#]*)";var regex=new RegExp(regexS);var results=regex.exec(location.href);if(results==null)return "";return results[1];}'+new_line;
372
  } else if(translation_method == 'onfly') {
373
  widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}function doGTranslate(lang_pair){if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var teCombo;var sel=document.getElementsByTagName('select');for(var i=0;i<sel.length;i++)if(sel[i].className=='goog-te-combo')teCombo=sel[i];if(document.getElementById('google_translate_element2')==null||document.getElementById('google_translate_element2').innerHTML.length==0||teCombo.length==0||teCombo.innerHTML.length==0){setTimeout(function(){doGTranslate(lang_pair)},500)}else{teCombo.value=lang;GTranslateFireEvent(teCombo,'change');GTranslateFireEvent(teCombo,'change')}}"+new_line;
374
+ if(widget_look == 'dropdown_with_flags') {
375
+ widget_code += "function GTranslateGetCurrentLang() {var keyValue = document.cookie.match('(^|;) ?googtrans=([^;]*)(;|$)');return keyValue ? keyValue[2].split('/')[2] : null;}"+new_line;
376
+ widget_code += "if(GTranslateGetCurrentLang() != null)jQuery(document).ready(function() {jQuery('div.switcher div.selected a').html(jQuery('div.switcher div.option').find('span.gflag img[alt=\"'+GTranslateGetCurrentLang()+'\"]').parent().parent().html());});"+new_line;
377
+ }
378
  }
379
 
380
  widget_code += '/* ]]> */'+new_line;
397
 
398
  jQuery('head').append( jQuery('<link rel="stylesheet" type="text/css" />').attr('href', '$wp_plugin_url/gtranslate-style'+jQuery('#flag_size').val()+'.css') );
399
  jQuery('#widget_preview').html(widget_preview);
400
+ if(jQuery('#widget_look').val() == 'dropdown_with_flags')
401
+ jQuery('#widget_preview').prepend('<p style="color:#f44;margin-top:5px;">This look is new, if you are having issues, please post on <a href="http://gtranslate.net/forum/" target="_blank">GTranslate Forum</a></p>');
402
  }
403
 
404
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
407
  jQuery('#analytics').attr('checked', '$analytics'.length > 0);
408
  jQuery('#load_jquery').attr('checked', '$load_jquery'.length > 0);
409
  jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
410
+ //jQuery('#show_dropdown').attr('checked', '$show_dropdown'.length > 0);
411
+ //jQuery('#show_flags').attr('checked', '$show_flags'.length > 0);
412
 
413
  jQuery('#default_language').val('$default_language');
414
+ //jQuery('#translation_method').val('$translation_method');
415
+ jQuery('#widget_look').val('$widget_look');
416
  jQuery('#flag_size').val('$flag_size');
417
 
418
+ if(jQuery('#pro_version:checked').length || jQuery('#enterprise_version:checked').length)
419
+ jQuery('#new_window_option').show();
420
+
421
+ if('$widget_look' == 'dropdown' || '$widget_look' == 'flags_dropdown') {
422
+ jQuery('#dropdown_languages_option').show();
423
+ } else {
424
+ jQuery('#dropdown_languages_option').hide();
425
+ }
426
+
427
+ if('$widget_look' == 'flags' || '$widget_look' == 'flags_dropdown' || '$widget_look' == 'dropdown_with_flags') {
428
+ jQuery('#flag_languages_option').show();
429
+ } else {
430
+ jQuery('#flag_languages_option').hide();
431
+ }
432
+
433
+ if('$widget_look' == 'flags' || '$widget_look' == 'dropdown' || '$widget_look' == 'dropdown_with_flags') {
434
+ jQuery('#line_break_option').hide();
435
+ } else {
436
+ jQuery('#line_break_option').show();
437
+ }
438
+
439
+ if('$widget_look' == 'dropdown_with_flags' || '$widget_look' == 'dropdown') {
440
+ jQuery('#flag_size_option').hide();
441
+ } else {
442
+ jQuery('#flag_size_option').show();
443
+ }
444
+
445
  if(jQuery('#widget_code').val() == '')
446
  RefreshDoWidgetCode();
447
  else
468
  <h3 id="settings">Widget options</h3>
469
  <div class="inside">
470
  <table style="width:100%;" cellpadding="4">
471
+ <!--tr>
472
  <td class="option_name">Translation method:</td>
473
  <td>
474
  <select id="translation_method" name="translation_method" onChange="RefreshDoWidgetCode()">
477
  <option value="onfly">On Fly</option>
478
  </select>
479
  </td>
480
+ </tr-->
481
+ <tr>
482
+ <td class="option_name">Widget look:</td>
483
+ <td>
484
+ <select id="widget_look" name="widget_look" onChange="RefreshDoWidgetCode()">
485
+ <option value="flags_dropdown">Flags and dropdown</option>
486
+ <option value="dropdown_with_flags">Nice dropdown with flags</option>
487
+ <option value="dropdown">Dropdown</option>
488
+ <option value="flags">Flags</option>
489
+ </select>
490
+ </td>
491
  </tr>
492
  <tr>
493
  <td class="option_name">Default language:</td>
588
  </select>
589
  </td>
590
  </tr>
 
 
 
 
591
  <tr>
592
  <td class="option_name">Analytics:</td>
593
  <td><input id="analytics" name="analytics" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
600
  <td class="option_name">Operate with Enterprise version:</td>
601
  <td><input id="enterprise_version" name="enterprise_version" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
602
  </tr>
603
+ <tr id="new_window_option" style="display:none;">
604
+ <td class="option_name">Open in new window:</td>
605
+ <td><input id="new_window" name="new_window" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
606
+ </tr>
607
+
608
+ <!--tr>
609
  <td class="option_name">Show flags:</td>
610
  <td><input id="show_flags" name="show_flags" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
611
+ </tr-->
612
+ <tr id="flag_size_option">
613
  <td class="option_name">Flag size:</td>
614
  <td>
615
  <select id="flag_size" name="flag_size" onchange="RefreshDoWidgetCode()">
619
  </select>
620
  </td>
621
  </tr>
622
+ <tr id="flag_languages_option" style="display:none;">
623
  <td class="option_name" colspan="2">Flag languages:<br /><br />
624
 
625
  <div>
693
  <br /><br />
694
  </td>
695
  </tr>
696
+ <tr id="line_break_option" style="display:none;">
697
  <td class="option_name">Line break after flags:</td>
698
  <td><input id="add_new_line" name="add_new_line" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
699
  </tr>
700
+ <!--tr>
701
  <td class="option_name">Show dropdown:</td>
702
  <td><input id="show_dropdown" name="show_dropdown" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
703
+ </tr-->
704
+ <tr id="dropdown_languages_option" style="display:none;">
705
  <td class="option_name" colspan="2">Dropdown languages:<br /><br />
706
  <div>
707
  <div style="width:25%;float:left;">
930
  $data['analytics'] = isset($_POST['analytics']) ? $_POST['analytics'] : '';
931
  $data['load_jquery'] = isset($_POST['load_jquery']) ? $_POST['load_jquery'] : '';
932
  $data['add_new_line'] = isset($_POST['add_new_line']) ? $_POST['add_new_line'] : '';
933
+ //$data['show_dropdown'] = isset($_POST['show_dropdown']) ? $_POST['show_dropdown'] : '';
934
+ //$data['show_flags'] = isset($_POST['show_flags']) ? $_POST['show_flags'] : '';
935
  $data['default_language'] = $_POST['default_language'];
936
  $data['translation_method'] = $_POST['translation_method'];
937
+ $data['widget_look'] = $_POST['widget_look'];
938
  $data['flag_size'] = $_POST['flag_size'];
939
  $data['widget_code'] = stripslashes($_POST['widget_code']);
940
  $data['incl_langs'] = $_POST['incl_langs'];
951
  $data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
952
  $data['load_jquery'] = isset($data['load_jquery']) ? $data['load_jquery'] : '1';
953
  $data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
954
+ //$data['show_dropdown'] = isset($data['show_dropdown']) ? $data['show_dropdown'] : '1';
955
+ //$data['show_flags'] = isset($data['show_flags']) ? $data['show_flags'] : '1';
956
  $data['default_language'] = isset($data['default_language']) ? $data['default_language'] : 'en';
957
  $data['translation_method'] = isset($data['translation_method']) ? $data['translation_method'] : 'onfly';
958
  if($data['translation_method'] == 'on_fly') $data['translation_method'] = 'redirect';
959
+ $data['widget_look'] = isset($data['widget_look']) ? $data['widget_look'] : 'flags_dropdown';
960
  $data['flag_size'] = isset($data['flag_size']) ? $data['flag_size'] : '16';
961
  $data['widget_code'] = isset($data['widget_code']) ? $data['widget_code'] : '';
962
  $data['incl_langs'] = isset($data['incl_langs']) ? $data['incl_langs'] : array();
readme.txt CHANGED
@@ -4,7 +4,7 @@ Author: Edvard Ananyan
4
  Tags: widget, plugin, sidebar, google, translate, translation, automatic translator, google translate, ajax translator, jquery translator, language translator, google translator, language translate, google language translator, translation, translate, multi language
5
  Requires at least: 2.8
6
  Tested up to: 4.4
7
- Stable tag: 2.0.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://www.paypal.me/EdvardAnanyan/10
@@ -374,10 +374,16 @@ You need to go to the language you want to edit, for instance, French: http://do
374
 
375
  == Screenshots ==
376
 
377
- 1. Main View
 
 
378
 
379
  == Changelog ==
380
 
 
 
 
 
381
  = 2.0.4 =
382
  * Added 34 new languages!
383
  * Support for wordpress 4.4
4
  Tags: widget, plugin, sidebar, google, translate, translation, automatic translator, google translate, ajax translator, jquery translator, language translator, google translator, language translate, google language translator, translation, translate, multi language
5
  Requires at least: 2.8
6
  Tested up to: 4.4
7
+ Stable tag: 2.0.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://www.paypal.me/EdvardAnanyan/10
374
 
375
  == Screenshots ==
376
 
377
+ 1. Dropdown with flags
378
+ 2. Nice dropdown with flags (closed)
379
+ 3. Nice dropdown with flags (open)
380
 
381
  == Changelog ==
382
 
383
+ = 2.0.5 =
384
+ * New widget look has been added: Nice dropdown with flags
385
+ * Hiding and showing options in settings interface to be user friendly
386
+
387
  = 2.0.4 =
388
  * Added 34 new languages!
389
  * Support for wordpress 4.4
screenshot-2.jpg ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
switcher.png ADDED
Binary file