Translate WordPress with GTranslate - Version 2.0.7

Version Description

  • PHP notice and warning messages fixed
Download this release

Release Info

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

Code changes from version 2.0.6 to 2.0.7

Files changed (2) hide show
  1. gtranslate.php +33 -20
  2. readme.txt +4 -1
gtranslate.php CHANGED
@@ -1,15 +1,15 @@
1
  <?php
2
  /*
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.6
7
  Author: Edvard Ananyan
8
- Author URI: http://gtranslate.net
9
 
10
  */
11
 
12
- /* Copyright 2010 - 2015 Edvard Ananyan (email : edo888@gmail.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@ if(is_admin()) {
42
  }
43
 
44
  class GTranslate extends WP_Widget {
45
- function activate() {
46
  $data = array(
47
  'gtranslate_title' => 'Website Translator',
48
  );
@@ -52,27 +52,27 @@ class GTranslate extends WP_Widget {
52
  add_option('GTranslate', $data);
53
  }
54
 
55
- function deactivate() {
56
  // delete_option('GTranslate');
57
  }
58
 
59
- function update_message($plugin_data, $r) {
60
  return print '<div style="color:#f33;">It is highly recommended to update to the latest version! <img src="//gtranslate.net/wp-logo.png" style="height:13px;vertical-align:middle;" border="0" title="GTranslate - your window to the world" alt="GTranslate"></div>';
61
  }
62
 
63
- function control() {
64
  $data = get_option('GTranslate');
65
  ?>
66
  <p><label>Title: <input name="gtranslate_title" type="text" class="widefat" value="<?php echo $data['gtranslate_title']; ?>"/></label></p>
67
  <p>Please go to Settings -> GTranslate for configuration.</p>
68
  <?php
69
  if (isset($_POST['gtranslate_title'])){
70
- $data['gtranslate_title'] = attribute_escape($_POST['gtranslate_title']);
71
  update_option('GTranslate', $data);
72
  }
73
  }
74
 
75
- function enqueue_scripts() {
76
  $data = get_option('GTranslate');
77
  GTranslate::load_defaults($data);
78
  $wp_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
@@ -81,7 +81,20 @@ class GTranslate extends WP_Widget {
81
  wp_enqueue_script('jquery');
82
  }
83
 
84
- function widget($args) {
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  $data = get_option('GTranslate');
86
  GTranslate::load_defaults($data);
87
 
@@ -104,22 +117,22 @@ class GTranslate extends WP_Widget {
104
  return $data['widget_code'];
105
  }
106
 
107
- function register() {
108
- wp_register_sidebar_widget('gtranslate', 'GTranslate', array('GTranslate', 'widget'), array('description' => __('Google Automatic Translations')));
109
  wp_register_widget_control('gtranslate', 'GTranslate', array('GTranslate', 'control'));
110
  }
111
 
112
- function admin_menu() {
113
  add_options_page('GTranslate Options', 'GTranslate', 'administrator', 'gtranslate_options', array('GTranslate', 'options'));
114
  }
115
 
116
- function options() {
117
  ?>
118
  <div class="wrap">
119
  <div id="icon-options-general" class="icon32"><br/></div>
120
  <h2><img src="//gtranslate.net/wp-logo.png" border="0" title="GTranslate - your window to the world" alt="GTranslate"></h2>
121
  <?php
122
- if($_POST['save'])
123
  GTranslate::control_options();
124
  $data = get_option('GTranslate');
125
  GTranslate::load_defaults($data);
@@ -140,7 +153,7 @@ var languages_map = {en_x: 0, en_y: 0, ar_x: 100, ar_y: 0, bg_x: 200, bg_y: 0, z
140
 
141
  function RefreshDoWidgetCode() {
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();
@@ -919,7 +932,7 @@ foreach($fincl_langs as $lang)
919
  <?php
920
  }
921
 
922
- function control_options() {
923
  check_admin_referer('gtranslate-save');
924
 
925
  $data = get_option('GTranslate');
@@ -933,7 +946,7 @@ foreach($fincl_langs as $lang)
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']);
@@ -944,7 +957,7 @@ foreach($fincl_langs as $lang)
944
  update_option('GTranslate', $data);
945
  }
946
 
947
- function load_defaults(& $data) {
948
  $data['pro_version'] = isset($data['pro_version']) ? $data['pro_version'] : '';
949
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
950
  $data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
1
  <?php
2
  /*
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="http://gtranslate.net/forum/">GTranslate Forum</a>.
6
+ Version: 2.0.7
7
  Author: Edvard Ananyan
8
+ Author URI: https://gtranslate.io
9
 
10
  */
11
 
12
+ /* Copyright 2010 - 2016 Edvard Ananyan (email : edo888@gmail.com)
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
42
  }
43
 
44
  class GTranslate extends WP_Widget {
45
+ public static function activate() {
46
  $data = array(
47
  'gtranslate_title' => 'Website Translator',
48
  );
52
  add_option('GTranslate', $data);
53
  }
54
 
55
+ public static function deactivate() {
56
  // delete_option('GTranslate');
57
  }
58
 
59
+ public static function update_message($plugin_data, $r) {
60
  return print '<div style="color:#f33;">It is highly recommended to update to the latest version! <img src="//gtranslate.net/wp-logo.png" style="height:13px;vertical-align:middle;" border="0" title="GTranslate - your window to the world" alt="GTranslate"></div>';
61
  }
62
 
63
+ public static function control() {
64
  $data = get_option('GTranslate');
65
  ?>
66
  <p><label>Title: <input name="gtranslate_title" type="text" class="widefat" value="<?php echo $data['gtranslate_title']; ?>"/></label></p>
67
  <p>Please go to Settings -> GTranslate for configuration.</p>
68
  <?php
69
  if (isset($_POST['gtranslate_title'])){
70
+ $data['gtranslate_title'] = esc_attr($_POST['gtranslate_title']);
71
  update_option('GTranslate', $data);
72
  }
73
  }
74
 
75
+ public static function enqueue_scripts() {
76
  $data = get_option('GTranslate');
77
  GTranslate::load_defaults($data);
78
  $wp_plugin_url = trailingslashit( get_bloginfo('wpurl') ).PLUGINDIR.'/'. dirname( plugin_basename(__FILE__) );
81
  wp_enqueue_script('jquery');
82
  }
83
 
84
+ public function widget($args, $instance) {
85
+ $data = get_option('GTranslate');
86
+ GTranslate::load_defaults($data);
87
+
88
+ echo $args['before_widget'];
89
+ echo $args['before_title'] . $data['gtranslate_title'] . $args['after_title'];
90
+ if(empty($data['widget_code']))
91
+ echo '<b>Notice:</b> Please configure GTranslate from WP-Admin -> Settings -> GTranslate to see it in action.';
92
+ else
93
+ echo $data['widget_code'];
94
+ echo $args['after_widget'];
95
+ }
96
+
97
+ public static function widget2($args) {
98
  $data = get_option('GTranslate');
99
  GTranslate::load_defaults($data);
100
 
117
  return $data['widget_code'];
118
  }
119
 
120
+ public static function register() {
121
+ wp_register_sidebar_widget('gtranslate', 'GTranslate', array('GTranslate', 'widget2'), array('description' => __('Google Automatic Translations')));
122
  wp_register_widget_control('gtranslate', 'GTranslate', array('GTranslate', 'control'));
123
  }
124
 
125
+ public static function admin_menu() {
126
  add_options_page('GTranslate Options', 'GTranslate', 'administrator', 'gtranslate_options', array('GTranslate', 'options'));
127
  }
128
 
129
+ public static function options() {
130
  ?>
131
  <div class="wrap">
132
  <div id="icon-options-general" class="icon32"><br/></div>
133
  <h2><img src="//gtranslate.net/wp-logo.png" border="0" title="GTranslate - your window to the world" alt="GTranslate"></h2>
134
  <?php
135
+ if(isset($_POST['save']) and $_POST['save'])
136
  GTranslate::control_options();
137
  $data = get_option('GTranslate');
138
  GTranslate::load_defaults($data);
153
 
154
  function RefreshDoWidgetCode() {
155
  var new_line = "\\n";
156
+ var widget_preview = '<!-- GTranslate: https://gtranslate.io/ -->'+new_line;
157
  var widget_code = '';
158
  var translation_method = 'onfly'; //jQuery('#translation_method').val();
159
  var widget_look = jQuery('#widget_look').val();
932
  <?php
933
  }
934
 
935
+ public static function control_options() {
936
  check_admin_referer('gtranslate-save');
937
 
938
  $data = get_option('GTranslate');
946
  //$data['show_dropdown'] = isset($_POST['show_dropdown']) ? $_POST['show_dropdown'] : '';
947
  //$data['show_flags'] = isset($_POST['show_flags']) ? $_POST['show_flags'] : '';
948
  $data['default_language'] = $_POST['default_language'];
949
+ $data['translation_method'] = 'onfly'; //$_POST['translation_method'];
950
  $data['widget_look'] = $_POST['widget_look'];
951
  $data['flag_size'] = $_POST['flag_size'];
952
  $data['widget_code'] = stripslashes($_POST['widget_code']);
957
  update_option('GTranslate', $data);
958
  }
959
 
960
+ public static function load_defaults(& $data) {
961
  $data['pro_version'] = isset($data['pro_version']) ? $data['pro_version'] : '';
962
  $data['enterprise_version'] = isset($data['enterprise_version']) ? $data['enterprise_version'] : '';
963
  $data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
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.6
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
@@ -380,6 +380,9 @@ You need to go to the language you want to edit, for instance, French: http://do
380
 
381
  == Changelog ==
382
 
 
 
 
383
  = 2.0.6 =
384
  * Updated option names to be clear
385
 
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.7
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
380
 
381
  == Changelog ==
382
 
383
+ = 2.0.7 =
384
+ * PHP notice and warning messages fixed
385
+
386
  = 2.0.6 =
387
  * Updated option names to be clear
388