Weglot Translate – Translate your WP website - Version 1.4.3

Version Description

  • Compat with WP Fastest cache, improve RTL translations
Download this release

Release Info

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

Version 1.4.3

WGUtils.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WGUtils {
4
+
5
+ public static function getLangNameFromCode($code,$english) {
6
+ switch ($code) {
7
+ case "sq":
8
+ return $english ? "Albanian":"Shqip";
9
+ case "en":
10
+ return $english ? "English":"English";
11
+ case "ar":
12
+ return $english ? "Arabic":"‏العربية‏";
13
+ case "hy":
14
+ return $english ? "Armenian":"հայերեն";
15
+ case "az":
16
+ return $english ? "Azerbaijani":"Azərbaycan dili";
17
+ case "af":
18
+ return $english ? "Afrikaans":"Afrikaans";
19
+ case "eu":
20
+ return $english ? "Basque":"Euskara";
21
+ case "be":
22
+ return $english ? "Belarusian":"Беларуская";
23
+ case "bg":
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":
32
+ return $english ? "Hungarian":"Magyar";
33
+ case "ht":
34
+ return $english ? "Haitian":"Kreyòl ayisyen";
35
+ case "gl":
36
+ return $english ? "Galician":"Galego";
37
+ case "nl":
38
+ return $english ? "Dutch":"Nederlands";
39
+ case "el":
40
+ return $english ? "Greek":"Ελληνικά";
41
+ case "ka":
42
+ return $english ? "Georgian":"ქართული";
43
+ case "da":
44
+ return $english ? "Danish":"Dansk";
45
+ case "he":
46
+ return $english ? "Hebrew":"עברית";
47
+ case "id":
48
+ return $english ? "Indonesian":"Bahasa Indonesia";
49
+ case "ga":
50
+ return $english ? "Irish":"Gaeilge";
51
+ case "it":
52
+ return $english ? "Italian":"Italiano";
53
+ case "is":
54
+ return $english ? "Icelandic":"Íslenska";
55
+ case "es":
56
+ return $english ? "Spanish":"Español";
57
+ case "kk":
58
+ return $english ? "Kazakh":"Қазақша";
59
+ case "ca":
60
+ return $english ? "Catalan":"Català";
61
+ case "ky":
62
+ return $english ? "Kyrgyz":"кыргызча";
63
+ case "zh":
64
+ return $english ? "Simplified Chinese":"中文 (简体)";
65
+ case "tw":
66
+ return $english ? "Traditional Chinese":"中文 (繁體)";
67
+ case "ko":
68
+ return $english ? "Korean":"한국어";
69
+ case "lv":
70
+ return $english ? "Latvian":"Latviešu";
71
+ case "lt":
72
+ return $english ? "Lithuanian":"Lietuvių";
73
+ case "mg":
74
+ return $english ? "Malagasy":"Malagasy";
75
+ case "ms":
76
+ return $english ? "Malay":"Bahasa Melayu";
77
+ case "mt":
78
+ return $english ? "Maltese":"Malti";
79
+ case "mk":
80
+ return $english ? "Macedonian":"Македонски";
81
+ case "mn":
82
+ return $english ? "Mongolian":"Монгол";
83
+ case "de":
84
+ return $english ? "German":"Deutsch";
85
+ case "no":
86
+ return $english ? "Norwegian":"Norsk";
87
+ case "fa":
88
+ return $english ? "Persian":"فارسی";
89
+ case "pl":
90
+ return $english ? "Polish":"Polski";
91
+ case "pt":
92
+ return $english ? "Portuguese":"Português";
93
+ case "ro":
94
+ return $english ? "Romanian":"Română";
95
+ case "ru":
96
+ return $english ? "Russian":"Русский";
97
+ case "sr":
98
+ return $english ? "Serbian":"Српски";
99
+ case "sk":
100
+ return $english ? "Slovak":"Slovenčina";
101
+ case "sl":
102
+ return $english ? "Slovenian":"Slovenščina";
103
+ case "sw":
104
+ return $english ? "Swahili":"Kiswahili";
105
+ case "tg":
106
+ return $english ? "Tajik":"Тоҷикӣ";
107
+ case "th":
108
+ return $english ? "Thai":"ภาษาไทย";
109
+ case "tl":
110
+ return $english ? "Tagalog":"Tagalog";
111
+ case "tt":
112
+ return $english ? "Tatar":"Tatar";
113
+ case "tr":
114
+ return $english ? "Turkish":"Türkçe";
115
+ case "uz":
116
+ return $english ? "Uzbek":"O'zbek";
117
+ case "uk":
118
+ return $english ? "Ukrainian":"Українська";
119
+ case "fi":
120
+ return $english ? "Finnish":"Suomi";
121
+ case "fr":
122
+ return $english ? "French":"Français";
123
+ case "hr":
124
+ return $english ? "Croatian":"Hrvatski";
125
+ case "cs":
126
+ return $english ? "Czech":"Čeština";
127
+ case "sv":
128
+ return $english ? "Swedish":"Svenska";
129
+ case "et":
130
+ return $english ? "Estonian":"Eesti";
131
+ case "ja":
132
+ return $english ? "Japanese":"日本語";
133
+ case "hi":
134
+ return $english ? "Hindi":"हिंदी";
135
+ case "ur":
136
+ return $english ? "Urdu":"اردو";
137
+ }
138
+ }
139
+
140
+ public static function str_lreplace($search, $replace, $subject) {
141
+ $pos = strrpos($subject, $search);
142
+
143
+ if($pos !== false)
144
+ {
145
+ $subject = substr_replace($subject, $replace, $pos, strlen($search));
146
+ }
147
+ return $subject;
148
+ }
149
+
150
+ public static function is_HTML($string) {
151
+ return ((preg_match("/<head/",$string,$m) != 0) && !(preg_match("/<xsl/",$string,$m) != 0));
152
+ }
153
+
154
+ public static function is_AJAX_HTML($string) {
155
+ $r = preg_match_all("/<(a|div|span|p|i|aside|input|textarea|select|h1|h2|h3|h4|meta|button|form|li|strong|ul)/",$string,$m,PREG_PATTERN_ORDER);
156
+ if($string[0]!='{' && $r && $r>=2)
157
+ return true;
158
+ else
159
+ return false;
160
+ }
161
+
162
+ public static function endsWith($haystack, $needle) {
163
+ // search forward starting from end minus needle length characters
164
+ return $needle === "" || (($temp = strlen($haystack) - strlen($needle)) >= 0 && strpos($haystack, $needle, $temp) !== FALSE);
165
+ }
166
+
167
+ public static function isLanguageRTL($code) {
168
+ $rtls = array("ar","he","fa");
169
+ if(in_array($code,$rtls)) {
170
+ return true;
171
+ }
172
+ return false;
173
+ }
174
+
175
+ public static function hasLanguageRTL($arrayOfCode) {
176
+ foreach($arrayOfCode as $code) {
177
+ if(WGUtils::isLanguageRTL($code))
178
+ return true;
179
+ }
180
+ return false;
181
+ }
182
+
183
+ public static function hasLanguageLTR($arrayOfCode) {
184
+ foreach($arrayOfCode as $code) {
185
+ if(!WGUtils::isLanguageRTL($code))
186
+ return true;
187
+ }
188
+ return false;
189
+ }
190
+
191
+
192
+ public static function is_bot()
193
+ {
194
+ $ua = array_key_exists('HTTP_USER_AGENT',$_SERVER) ? $_SERVER['HTTP_USER_AGENT']:"Unknown";
195
+ if (isset($ua)) {
196
+ if (preg_match('/bot|favicon|crawl|facebook|Face|slurp|spider/i', $ua))
197
+ {
198
+ return true;
199
+
200
+ }
201
+ else
202
+ {
203
+ return false;
204
+ }
205
+ }
206
+ else {
207
+ return true;
208
+ }
209
+ }
210
+ }
WeglotPHPClient/src/Client.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace Weglot;
3
+ use WeglotSDP;
4
+ class Client
5
+ {
6
+ protected $api_key;
7
+
8
+ const API_BASE = 'https://weglot.com/api/';
9
+ //const API_BASE = 'http://weglot/api/';
10
+
11
+ function __construct($key) {
12
+ $this->api_key = $key;
13
+
14
+ if ($this->api_key == null || mb_strlen($this->api_key) == 0) {
15
+ return null;
16
+ }
17
+ }
18
+
19
+ public function hasAncestorAttribute($node,$attribute) {
20
+
21
+ $currentNode = $node;
22
+
23
+ while($currentNode->parent() && $currentNode->parent()->tag!="html") {
24
+
25
+ if(isset($currentNode->parent()->$attribute))
26
+ return true;
27
+ else
28
+ $currentNode = $currentNode->parent();
29
+ }
30
+ return false;
31
+ }
32
+
33
+ public function translateDomFromTo($dom,$l_from,$l_to) {
34
+ $html = WeglotSDP\str_get_html($dom, true, true, WG_DEFAULT_TARGET_CHARSET, false, WG_DEFAULT_BR_TEXT, WG_DEFAULT_SPAN_TEXT);
35
+ //return $html->save();
36
+ /*
37
+ $doc = new \DOMDocument();
38
+ libxml_use_internal_errors(true);
39
+ $doc->loadHTML(mb_convert_encoding($dom, 'HTML-ENTITIES', 'UTF-8'));
40
+ $xpath = new \DOMXPath($doc);
41
+ */
42
+
43
+ $exceptions = explode(",",get_option("exclude_blocks"));
44
+ array_push($exceptions,"#wpadminbar");
45
+ foreach ($exceptions as $exception) {
46
+ foreach ($html->find($exception) as $k => $row)
47
+ {
48
+ $attribute = "data-wg-notranslate";
49
+ $row->$attribute="";
50
+ }
51
+ }
52
+
53
+
54
+
55
+ $words = array();
56
+ $nodes = array();
57
+
58
+ foreach ($html->find('text') as $k => $row)
59
+ {
60
+ if($this->full_trim($row->outertext)!="" && $row->parent()->tag!="script" && $row->parent()->tag!="style" && !is_numeric($this->full_trim($row->outertext)) && !preg_match('/^\d+%$/',$this->full_trim($row->outertext))
61
+ && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
62
+ {
63
+ if(strpos($row->outertext,'[vc_') !== false) {
64
+
65
+ }
66
+ else {
67
+ array_push($words,array("t"=>"1","w"=>$row->outertext));
68
+ array_push($nodes,array('node'=>$row,'type'=>'text'));
69
+ }
70
+ }
71
+ }
72
+
73
+ foreach ($html->find('input[type=\'submit\'],input[type=\'button\']') as $k => $row)
74
+ {
75
+ if($this->full_trim($row->value)!="" && !is_numeric($this->full_trim($row->value)) && !preg_match('/^\d+%$/',$this->full_trim($row->value))
76
+ && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
77
+ {
78
+ array_push($words,array("t"=>"2","w"=>html_entity_decode($row->value)));
79
+ array_push($nodes,array('node'=>$row,'type'=>'submit'));
80
+ }
81
+ }
82
+ foreach ($html->find('input[type=\'text\'],input[type=\'password\'],input[type=\'search\'],input[type=\'email\'],input:not([type]),textarea') as $k => $row)
83
+ {
84
+ if($this->full_trim($row->placeholder)!=""
85
+ && !is_numeric($this->full_trim($row->placeholder)) && !preg_match('/^\d+%$/',$this->full_trim($row->placeholder))
86
+ && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
87
+ {
88
+ array_push($words,array("t"=>"3","w"=>html_entity_decode($row->placeholder)));
89
+ array_push($nodes,array('node'=>$row,'type'=>'placeholder'));
90
+ }
91
+ }
92
+ foreach ($html->find('meta[name="description"],meta[property="og:title"],meta[property="og:description"],meta[property="og:site_name"],meta[name="twitter:title"],meta[name="twitter:description"]') as $k => $row)
93
+ {
94
+ if($this->full_trim($row->content)!="" && !is_numeric($this->full_trim($row->content)) && !preg_match('/^\d+%$/',$this->full_trim($row->content))
95
+ && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
96
+ {
97
+ array_push($words,array("t"=>"4","w"=>$row->content));
98
+ array_push($nodes,array('node'=>$row,'type'=>'meta_desc'));
99
+ }
100
+ }
101
+ foreach ($html->find('iframe') as $k => $row)
102
+ {
103
+ if($this->full_trim($row->src)!="" && strpos($this->full_trim($row->src),'.youtube.') !== false && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
104
+ {
105
+ array_push($words,array("t"=>"5","w"=>$row->src));
106
+ array_push($nodes,array('node'=>$row,'type'=>'iframe_src'));
107
+ }
108
+ }
109
+ foreach ($html->find('img') as $k => $row)
110
+ {
111
+ if($this->full_trim($row->src)!="" && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
112
+ {
113
+ array_push($words,array("t"=>"6","w"=>$row->src));
114
+ array_push($nodes,array('node'=>$row,'type'=>'image_src'));
115
+ }
116
+ if($this->full_trim($row->alt)!="" && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
117
+ {
118
+ array_push($words,array("t"=>"7","w"=>$row->alt));
119
+ array_push($nodes,array('node'=>$row,'type'=>'image_alt'));
120
+ }
121
+ }
122
+ foreach ($html->find('a') as $k => $row)
123
+ {
124
+ if($this->full_trim($row->href)!="" && substr($this->full_trim($row->href),-4)==".pdf" && !$this->hasAncestorAttribute($row,'data-wg-notranslate'))
125
+ {
126
+ array_push($words,array("t"=>"8","w"=>$row->href));
127
+ array_push($nodes,array('node'=>$row,'type'=>'a_pdf'));
128
+ }
129
+ }
130
+
131
+
132
+
133
+ $title = "";
134
+ foreach ($html->find('title') as $k => $row) {
135
+ $title = $row->innertext;
136
+ }
137
+
138
+ $absolute_url = $this->full_url($_SERVER);
139
+ if(strpos($absolute_url,'admin-ajax.php') !== false) {
140
+ $absolute_url = $_SERVER['HTTP_REFERER'];
141
+ $title = "Ajax data";
142
+ }
143
+
144
+ $bot = $this->bot_detected();
145
+ $parameters = array("l_from"=>$l_from,"l_to"=>$l_to,"title"=>$title,"request_url"=>$absolute_url,"bot"=>$bot,"words"=>$words);
146
+ $results = $this->doRequest(self::API_BASE."v2/translate?api_key=".$this->api_key,$parameters);
147
+ $json = json_decode($results,true);
148
+ if(json_last_error() == JSON_ERROR_NONE)
149
+ {
150
+ if(isset($json['succeeded']) && ($json['succeeded']==0 || $json['succeeded']==1)) {
151
+ if($json['succeeded']==1) {
152
+ if(isset($json['answer'])) {
153
+ $answer = $json['answer'];
154
+ if(isset($answer['to_words'])) {
155
+ $translated_words = $answer['to_words'];
156
+ if(count($nodes)==count($translated_words)) {
157
+ for($i=0;$i<count($nodes);$i++) {
158
+ if($nodes[$i]['type']=='text') {
159
+ $nodes[$i]['node']->outertext = $translated_words[$i];
160
+ }
161
+ if($nodes[$i]['type']=='submit') {
162
+ $nodes[$i]['node']->setAttribute('value',$translated_words[$i]);
163
+ }
164
+ if($nodes[$i]['type']=='placeholder') {
165
+ $nodes[$i]['node']->setAttribute('placeholder',$translated_words[$i]);
166
+ }
167
+ if($nodes[$i]['type']=='meta_desc') {
168
+ $nodes[$i]['node']->content = $translated_words[$i];
169
+ }
170
+ if($nodes[$i]['type']=='iframe_src') {
171
+ $nodes[$i]['node']->src = $translated_words[$i];
172
+ }
173
+ if($nodes[$i]['type']=='image_alt') {
174
+ $nodes[$i]['node']->alt = $translated_words[$i];
175
+ }
176
+ if($nodes[$i]['type']=='image_src') {
177
+ $nodes[$i]['node']->src = $translated_words[$i];
178
+ if($nodes[$i]['node']->hasAttribute("srcset") && $nodes[$i]['node']->srcset != "" && $translated_words[$i]!=$words[$i]['w']) {
179
+ $nodes[$i]['node']->srcset = "";
180
+ }
181
+ }
182
+ if($nodes[$i]['type']=='a_pdf') {
183
+ $nodes[$i]['node']->href = $translated_words[$i];
184
+ }
185
+ }
186
+ //return $doc->saveHTML();
187
+ return $html->save();
188
+ }
189
+ else
190
+ throw new WeglotException('Unknown error with Weglot Api (0006)');
191
+ }
192
+ else
193
+ throw new WeglotException('Unknown error with Weglot Api (0005)');
194
+ }
195
+ else
196
+ throw new WeglotException('Unknown error with Weglot Api (0004)');
197
+ }
198
+ else {
199
+ $error = isset($json['error']) ? $json['error']:'Unknown error with Weglot Api (0003)';
200
+ throw new WeglotException($error);
201
+ }
202
+ }
203
+ else
204
+ throw new WeglotException('Unknown error with Weglot Api (0002) : '.$json);
205
+ }
206
+ else
207
+ throw new WeglotException('Unknown error with Weglot Api (0001) : '.json_last_error());
208
+ }
209
+
210
+ public function getUserInfo() {
211
+ $results = $this->doRequest(self::API_BASE."user-info?api_key=".$this->api_key,null);
212
+ $json = json_decode($results,true);
213
+ if(json_last_error() == JSON_ERROR_NONE)
214
+ {
215
+ if(isset($json['succeeded']) && ($json['succeeded']==0 || $json['succeeded']==1)) {
216
+ if($json['succeeded']==1) {
217
+ if(isset($json['answer'])) {
218
+ $answer = $json['answer'];
219
+ return $answer;
220
+ }
221
+ else
222
+ throw new WeglotException('Unknown error with Weglot Api (0004)');
223
+ }
224
+ else {
225
+ $error = isset($json['error']) ? $json['error']:'Unknown error with Weglot Api (0003)';
226
+ throw new WeglotException($error);
227
+ }
228
+ }
229
+ else
230
+ throw new WeglotException('Unknown error with Weglot Api (0002) : '.$json);
231
+ }
232
+ else
233
+ throw new WeglotException('Unknown error with Weglot Api (0001) : '.json_last_error());
234
+ }
235
+
236
+ public function doRequest($url,$parameters) {
237
+
238
+ if($parameters) {
239
+ $payload = json_encode($parameters);
240
+ if(json_last_error() == JSON_ERROR_NONE) {
241
+ $response = wp_remote_post( $url, array(
242
+ 'method' => 'POST',
243
+ 'timeout' => 45,
244
+ 'redirection' => 5,
245
+ 'blocking' => true,
246
+ 'headers' => array( "Content-type" => "application/json" ),
247
+ 'body' => $payload,
248
+ 'cookies' => array(),
249
+ 'sslverify' => false
250
+ )
251
+ );
252
+ }
253
+ else
254
+ throw new WeglotException('Cannot json encode parameters: '.json_last_error());
255
+
256
+ }
257
+ else {
258
+ $response = wp_remote_get( $url, array(
259
+ 'method' => 'GET',
260
+ 'timeout' => 45,
261
+ 'redirection' => 5,
262
+ 'blocking' => true,
263
+ 'headers' => array( "Content-type" => "application/json" ),
264
+ 'body' => null,
265
+ 'cookies' => array(),
266
+ 'sslverify' => false
267
+ )
268
+ );
269
+ }
270
+
271
+ if ( is_wp_error( $response ) ) {
272
+ $error_message = $response->get_error_message();
273
+ throw new WeglotException('Error doing the external request to '.$url.': '.$error_message);
274
+ } else {
275
+ return $response['body'];
276
+ }
277
+ }
278
+
279
+
280
+
281
+ function bot_detected()
282
+ {
283
+ $ua = $_SERVER['HTTP_USER_AGENT'];
284
+ if (isset($ua))
285
+ {
286
+ if (preg_match('/bot|favicon|crawl|facebook|slurp|spider/i', $ua))
287
+ {
288
+ if (strpos($ua, 'Google') !== false || strpos($ua, 'facebook') !== false || strpos($ua, 'wprocketbot') !== false || strpos($ua, 'SemrushBot') !== false) {
289
+ return 2;
290
+ }
291
+ elseif (strpos($ua, 'bing') !== false) {
292
+ return 3;
293
+ }
294
+ elseif (strpos($ua, 'yahoo') !== false) {
295
+ return 4;
296
+ }
297
+ elseif (strpos($ua, 'Baidu') !== false) {
298
+ return 5;
299
+ }
300
+ elseif (strpos($ua, 'Yandex') !== false) {
301
+ return 6;
302
+ }
303
+ else {
304
+ return 1;
305
+ }
306
+
307
+ }
308
+ else
309
+ {
310
+ return 0;
311
+ }
312
+ }
313
+ else
314
+ {
315
+ return 1;
316
+ }
317
+ }
318
+
319
+ function url_origin($s, $use_forwarded_host=false)
320
+ {
321
+ $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
322
+ $sp = strtolower($s['SERVER_PROTOCOL']);
323
+ $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
324
+ $port = $s['SERVER_PORT'];
325
+ $port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port;
326
+ $host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
327
+ $host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
328
+ return $protocol . '://' . $host;
329
+ }
330
+ function full_url($s, $use_forwarded_host=false)
331
+ {
332
+ return $this->url_origin($s, $use_forwarded_host) . $s['REQUEST_URI'];
333
+ }
334
+ function full_trim($word) {
335
+ return trim($word," \t\n\r\0\x0B\xA0�");
336
+ }
337
+ }
338
+
339
+ ?>
WeglotPHPClient/src/WeglotException.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ namespace Weglot;
3
+
4
+ class WeglotException extends \Exception
5
+ {
6
+ }
WeglotPHPClient/weglot.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'src/Client.php';
4
+ require_once 'src/WeglotException.php';
WeglotWidget.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class WeglotWidget extends WP_Widget {
4
+
5
+ public function __construct() {
6
+ parent::__construct(false, $name = __('Weglot Translate', 'weglot') );
7
+ }
8
+
9
+ public function WeglotWidget() {
10
+ parent::__construct(false, $name = __('Weglot Translate', 'weglot') );
11
+ }
12
+
13
+ public function update( $new_instance, $old_instance ) {
14
+ $instance = array();
15
+ $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? strip_tags( $new_instance['title'] ) : '';
16
+ return $instance;
17
+ }
18
+
19
+ function widget($args, $instance) {
20
+
21
+ $title = apply_filters( 'widget_title', $instance['title'] );
22
+
23
+
24
+
25
+ $tt = ( ! empty( $title ) ) ? $args['before_title'] . $title . $args['after_title']:"";
26
+
27
+ $button = Weglot::Instance()->returnWidgetCode();
28
+ echo $args['before_widget'].$tt.$button.$args['after_widget'];
29
+ }
30
+
31
+ public function form( $instance ) {
32
+ if ( isset( $instance[ 'title' ] ) ) {
33
+ $title = $instance[ 'title' ];
34
+ }
35
+ else {
36
+ $title = "";
37
+ }
38
+ // Widget admin form
39
+ ?>
40
+ <p>
41
+ <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
42
+ <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
43
+ </p>
44
+ <?php
45
+ }
46
+ }
images/weglot_fav.png ADDED
Binary file
images/weglot_fav_bw.png ADDED
Binary file
images/wgarrowdown.png ADDED
Binary file
includes/wg-settings-page.php ADDED
@@ -0,0 +1,271 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $showRTL = false;
3
+ $showLTR = false;
4
+ if(WGUtils::isLanguageRTL($this->original_l)) { //Right lo left language
5
+ if(WGUtils::hasLanguageLTR(explode(",",$this->destination_l)))
6
+ $showLTR = true;
7
+ }
8
+ else { //Left to right language
9
+ if(WGUtils::hasLanguageRTL(explode(",",$this->destination_l)))
10
+ $showRTL = true;
11
+ }
12
+ ?>
13
+ <div class="wrap">
14
+ <?php if($this->allowed==0) { ?>
15
+ <div class="wg-status-box">
16
+ <h3><?php echo sprintf(__( 'Weglot Translate service is not active because you reach the end of the trial period.', 'weglot' ),$this->userInfo['limit']); ?></h3>
17
+ <p><?php _e('To reactivate the service, please <a target="_blank" href="https://weglot.com/change-plan">upgrade your plan</a>','weglot'); ?></p>
18
+ </div>
19
+ <?php } ?>
20
+
21
+ <?php if(esc_attr(get_option('show_box'))=="on") { ?>
22
+ <div class="wgbox-blur">
23
+ <div class="wgbox">
24
+ <div class="wgclose-btn"><?php _e('Close','weglot'); ?></div>
25
+ <h3 class="wgbox-title"><?php _e('Well done! Your website is now multilingual','weglot'); ?></h3>
26
+ <p class="wgbox-text"><?php _e('Go on your website, there is a language switcher, try it :)','weglot'); ?></p>
27
+ <a class="wgbox-button button button-primary" href="<?php echo $this->home_dir; ?>/" target="_blank"><?php _e('Go on my front page','weglot'); ?></a>
28
+ <p class="wgbox-subtext"><?php _e('Next step, edit your translations directly in your Weglot account.','weglot'); ?></p>
29
+ </div>
30
+ </div>
31
+ <?php list($wgfirstlang) = explode(',', get_option("destination_l"));
32
+ if(strlen($wgfirstlang)==2) { ?>
33
+ <iframe style="visibility:hidden;" src="<?php echo $this->home_dir; ?>/<?php echo $wgfirstlang; ?>/" width=1 height =1 ></iframe>
34
+ <?php } ?>
35
+ <?php update_option('show_box','off'); } ?>
36
+ <form class="wg-widget-option-form" method="post" action="options.php">
37
+ <?php settings_fields( 'my-plugin-settings-group' ); ?>
38
+ <?php do_settings_sections( 'my-plugin-settings-group' ); ?>
39
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php _e( 'Main configuration', 'weglot' ); ?></h3>
40
+ <table class="form-table">
41
+ <tr valign="top">
42
+ <th scope="row"><?php _e( 'API Key', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php echo sprintf(__( 'Login to %s to get your API key', 'weglot' ),'<a target="_blank" href="https://weglot.com/register-wordpress">Weglot</a>'); ?></p></th>
43
+ <td><input type="text" name="project_key" value="<?php echo esc_attr( get_option('project_key') ); ?>" placeholder="wg_XXXXXXXX" required /></td>
44
+ </tr>
45
+ <tr valign="top">
46
+ <th scope="row"><?php _e( 'Original Language', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php _e( 'What is the original (current) language of your website?', 'weglot' ); ?></p></th>
47
+ <td>
48
+ <select name="original_l" style="width :200px;">
49
+ <option <?php if(esc_attr( get_option('original_l') )=="fr") { echo "selected"; } ?> value="fr"><?php _e( 'French', 'weglot' ); ?></option>
50
+ <option <?php if(esc_attr( get_option('original_l') )=="en") { echo "selected"; } ?> value="en"><?php _e( 'English', 'weglot' ); ?></option>
51
+ <option <?php if(esc_attr( get_option('original_l') )=="zh") { echo "selected"; } ?> value="zh"><?php _e( 'Simplified Chinese', 'weglot' ); ?></option>
52
+ <option <?php if(esc_attr( get_option('original_l') )=="tw") { echo "selected"; } ?> value="tw"><?php _e( 'Traditional Chinese', 'weglot' ); ?></option>
53
+ <option <?php if(esc_attr( get_option('original_l') )=="ru") { echo "selected"; } ?> value="ru"><?php _e( 'Russian', 'weglot' ); ?></option>
54
+ <option <?php if(esc_attr( get_option('original_l') )=="de") { echo "selected"; } ?> value="de"><?php _e( 'German', 'weglot' ); ?></option>
55
+ <option <?php if(esc_attr( get_option('original_l') )=="es") { echo "selected"; } ?> value="es"><?php _e( 'Spanish', 'weglot' ); ?></option>
56
+ <option <?php if(esc_attr( get_option('original_l') )=="sq") { echo "selected"; } ?> value="sq"><?php _e( 'Albanian', 'weglot' ); ?></option>
57
+ <option <?php if(esc_attr( get_option('original_l') )=="ar") { echo "selected"; } ?> value="ar"><?php _e( 'Arabic', 'weglot' ); ?></option>
58
+ <option <?php if(esc_attr( get_option('original_l') )=="hy") { echo "selected"; } ?> value="hy"><?php _e( 'Armenian', 'weglot' ); ?></option>
59
+ <option <?php if(esc_attr( get_option('original_l') )=="az") { echo "selected"; } ?> value="az"><?php _e( 'Azerbaijani', 'weglot' ); ?></option>
60
+ <option <?php if(esc_attr( get_option('original_l') )=="af") { echo "selected"; } ?> value="af"><?php _e( 'Afrikaans', 'weglot' ); ?></option>
61
+ <option <?php if(esc_attr( get_option('original_l') )=="eu") { echo "selected"; } ?> value="eu"><?php _e( 'Basque', 'weglot' ); ?></option>
62
+ <option <?php if(esc_attr( get_option('original_l') )=="be") { echo "selected"; } ?> value="be"><?php _e( 'Belarusian', 'weglot' ); ?></option>
63
+ <option <?php if(esc_attr( get_option('original_l') )=="bg") { echo "selected"; } ?> value="bg"><?php _e( 'Bulgarian', 'weglot' ); ?></option>
64
+ <option <?php if(esc_attr( get_option('original_l') )=="bs") { echo "selected"; } ?> value="bs"><?php _e( 'Bosnian', 'weglot' ); ?></option>
65
+ <option <?php if(esc_attr( get_option('original_l') )=="vi") { echo "selected"; } ?> value="vi"><?php _e( 'Vietnamese', 'weglot' ); ?></option>
66
+ <option <?php if(esc_attr( get_option('original_l') )=="hu") { echo "selected"; } ?> value="hu"><?php _e( 'Hungarian', 'weglot' ); ?></option>
67
+ <option <?php if(esc_attr( get_option('original_l') )=="ht") { echo "selected"; } ?> value="ht"><?php _e( 'Haitian', 'weglot' ); ?></option>
68
+ <option <?php if(esc_attr( get_option('original_l') )=="nl") { echo "selected"; } ?> value="nl"><?php _e( 'Dutch', 'weglot' ); ?></option>
69
+ <option <?php if(esc_attr( get_option('original_l') )=="el") { echo "selected"; } ?> value="el"><?php _e( 'Greek', 'weglot' ); ?></option>
70
+ <option <?php if(esc_attr( get_option('original_l') )=="ka") { echo "selected"; } ?> value="ka"><?php _e( 'Georgian', 'weglot' ); ?></option>
71
+ <option <?php if(esc_attr( get_option('original_l') )=="da") { echo "selected"; } ?> value="da"><?php _e( 'Danish', 'weglot' ); ?></option>
72
+ <option <?php if(esc_attr( get_option('original_l') )=="he") { echo "selected"; } ?> value="he"><?php _e( 'Hebrew', 'weglot' ); ?></option>
73
+ <option <?php if(esc_attr( get_option('original_l') )=="id") { echo "selected"; } ?> value="id"><?php _e( 'Indonesian', 'weglot' ); ?></option>
74
+ <option <?php if(esc_attr( get_option('original_l') )=="ga") { echo "selected"; } ?> value="ga"><?php _e( 'Irish', 'weglot' ); ?></option>
75
+ <option <?php if(esc_attr( get_option('original_l') )=="it") { echo "selected"; } ?> value="it"><?php _e( 'Italian', 'weglot' ); ?></option>
76
+ <option <?php if(esc_attr( get_option('original_l') )=="is") { echo "selected"; } ?> value="is"><?php _e( 'Icelandic', 'weglot' ); ?></option>
77
+ <option <?php if(esc_attr( get_option('original_l') )=="kk") { echo "selected"; } ?> value="kk"><?php _e( 'Kazakh', 'weglot' ); ?></option>
78
+ <option <?php if(esc_attr( get_option('original_l') )=="ca") { echo "selected"; } ?> value="ca"><?php _e( 'Catalan', 'weglot' ); ?></option>
79
+ <option <?php if(esc_attr( get_option('original_l') )=="ky") { echo "selected"; } ?> value="ky"><?php _e( 'Kyrgyz', 'weglot' ); ?></option>
80
+ <option <?php if(esc_attr( get_option('original_l') )=="ko") { echo "selected"; } ?> value="ko"><?php _e( 'Korean', 'weglot' ); ?></option>
81
+ <option <?php if(esc_attr( get_option('original_l') )=="lv") { echo "selected"; } ?> value="lv"><?php _e( 'Latvian', 'weglot' ); ?></option>
82
+ <option <?php if(esc_attr( get_option('original_l') )=="lt") { echo "selected"; } ?> value="lt"><?php _e( 'Lithuanian', 'weglot' ); ?></option>
83
+ <option <?php if(esc_attr( get_option('original_l') )=="mg") { echo "selected"; } ?> value="mg"><?php _e( 'Malagasy', 'weglot' ); ?></option>
84
+ <option <?php if(esc_attr( get_option('original_l') )=="ms") { echo "selected"; } ?> value="ms"><?php _e( 'Malay', 'weglot' ); ?></option>
85
+ <option <?php if(esc_attr( get_option('original_l') )=="mt") { echo "selected"; } ?> value="mt"><?php _e( 'Maltese', 'weglot' ); ?></option>
86
+ <option <?php if(esc_attr( get_option('original_l') )=="mk") { echo "selected"; } ?> value="mk"><?php _e( 'Macedonian', 'weglot' ); ?></option>
87
+ <option <?php if(esc_attr( get_option('original_l') )=="mn") { echo "selected"; } ?> value="mn"><?php _e( 'Mongolian', 'weglot' ); ?></option>
88
+ <option <?php if(esc_attr( get_option('original_l') )=="no") { echo "selected"; } ?> value="no"><?php _e( 'Norwegian', 'weglot' ); ?></option>
89
+ <option <?php if(esc_attr( get_option('original_l') )=="fa") { echo "selected"; } ?> value="fa"><?php _e( 'Persian', 'weglot' ); ?></option>
90
+ <option <?php if(esc_attr( get_option('original_l') )=="pl") { echo "selected"; } ?> value="pl"><?php _e( 'Polish', 'weglot' ); ?></option>
91
+ <option <?php if(esc_attr( get_option('original_l') )=="pt") { echo "selected"; } ?> value="pt"><?php _e( 'Portuguese', 'weglot' ); ?></option>
92
+ <option <?php if(esc_attr( get_option('original_l') )=="ro") { echo "selected"; } ?> value="ro"><?php _e( 'Romanian', 'weglot' ); ?></option>
93
+ <option <?php if(esc_attr( get_option('original_l') )=="sr") { echo "selected"; } ?> value="sr"><?php _e( 'Serbian', 'weglot' ); ?></option>
94
+ <option <?php if(esc_attr( get_option('original_l') )=="sk") { echo "selected"; } ?> value="sk"><?php _e( 'Slovak', 'weglot' ); ?></option>
95
+ <option <?php if(esc_attr( get_option('original_l') )=="sl") { echo "selected"; } ?> value="sl"><?php _e( 'Slovenian', 'weglot' ); ?></option>
96
+ <option <?php if(esc_attr( get_option('original_l') )=="sw") { echo "selected"; } ?> value="sw"><?php _e( 'Swahili', 'weglot' ); ?></option>
97
+ <option <?php if(esc_attr( get_option('original_l') )=="tg") { echo "selected"; } ?> value="tg"><?php _e( 'Tajik', 'weglot' ); ?></option>
98
+ <option <?php if(esc_attr( get_option('original_l') )=="th") { echo "selected"; } ?> value="th"><?php _e( 'Thai', 'weglot' ); ?></option>
99
+ <option <?php if(esc_attr( get_option('original_l') )=="tr") { echo "selected"; } ?> value="tr"><?php _e( 'Turkish', 'weglot' ); ?></option>
100
+ <option <?php if(esc_attr( get_option('original_l') )=="uz") { echo "selected"; } ?> value="uz"><?php _e( 'Uzbek', 'weglot' ); ?></option>
101
+ <option <?php if(esc_attr( get_option('original_l') )=="uk") { echo "selected"; } ?> value="uk"><?php _e( 'Ukrainian', 'weglot' ); ?></option>
102
+ <option <?php if(esc_attr( get_option('original_l') )=="fi") { echo "selected"; } ?> value="fi"><?php _e( 'Finnish', 'weglot' ); ?></option>
103
+ <option <?php if(esc_attr( get_option('original_l') )=="hr") { echo "selected"; } ?> value="hr"><?php _e( 'Croatian', 'weglot' ); ?></option>
104
+ <option <?php if(esc_attr( get_option('original_l') )=="cs") { echo "selected"; } ?> value="cs"><?php _e( 'Czech', 'weglot' ); ?></option>
105
+ <option <?php if(esc_attr( get_option('original_l') )=="sv") { echo "selected"; } ?> value="sv"><?php _e( 'Swedish', 'weglot' ); ?></option>
106
+ <option <?php if(esc_attr( get_option('original_l') )=="et") { echo "selected"; } ?> value="et"><?php _e( 'Estonian', 'weglot' ); ?></option>
107
+ <option <?php if(esc_attr( get_option('original_l') )=="ja") { echo "selected"; } ?> value="ja"><?php _e( 'Japanese', 'weglot' ); ?></option>
108
+ <option <?php if(esc_attr( get_option('original_l') )=="hi") { echo "selected"; } ?> value="hi"><?php _e( 'Hindi', 'weglot' ); ?></option>
109
+ <option <?php if(esc_attr( get_option('original_l') )=="ur") { echo "selected"; } ?> value="ur"><?php _e( 'Urdu', 'weglot' ); ?></option>
110
+ </select>
111
+ </td>
112
+ </tr>
113
+ <tr valign="top">
114
+ <th scope="row"><?php _e( 'Destination Languages', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php _e( 'Write the two-letters codes, separated by a comma. Supported languages are <a target="_blank" href="https://weglot.com/translation-api#languages_code">here</a>.', 'weglot' ); ?></p></th>
115
+ <td><input type="text" name="destination_l" value="<?php echo esc_attr( get_option('destination_l') ); ?>" placeholder="en,es" required /><?php if($this->userInfo['plan']<=0) { ?><p class="wg-fsubtext"><?php _e( 'On the free plan, you can only chose one language with a maximum of 2000 words. If you want to use more than 1 language and 2000 words, please <a target="_blank" href="https://weglot.com/change-plan">upgrade your plan</a>.', 'weglot' ); ?></p><?php } ?><?php if($this->userInfo['plan']>=18 && $this->userInfo['plan']<=19) { ?><p class="wg-fsubtext"><?php _e( 'On the Starter plan, you can only chose one language. If you want to use more than 1 language, please <a target="_blank" href="https://weglot.com/change-plan">upgrade your plan</a>.', 'weglot' ); ?></p><?php } ?></td>
116
+ </tr>
117
+ </table>
118
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php echo __( 'Language button appearance', 'weglot' )." ".__( '(Optional)', 'weglot' ); ?></h3>
119
+ <p class="preview-text"><?php _e( 'Preview:', 'weglot' ); ?></p><div class="wg-widget-preview"></div>
120
+ <table class="form-table">
121
+ <tr valign="top">
122
+ <th scope="row"><?php _e( 'Dropdown?', 'weglot' ); ?></th>
123
+ <td><input id="id_is_dropdown" type="checkbox" name="is_dropdown" <?php if(esc_attr(get_option('is_dropdown'))=="on") echo "checked"; ?> /><label for="id_is_dropdown" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want the button to be a dropdown box.', 'weglot' ); ?></label></td>
124
+ </tr>
125
+ <tr valign="top">
126
+ <th scope="row"><?php _e( 'With flags?', 'weglot' ); ?></th>
127
+ <td><input id="id_with_flags" type="checkbox" name="with_flags" <?php if(esc_attr(get_option('with_flags'))=="on") echo "checked"; ?> /><label for="id_with_flags" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want flags in the language button.', 'weglot' ); ?></label></td>
128
+ </tr>
129
+ <tr valign="top">
130
+ <th scope="row"><?php _e( 'Type of flags', 'weglot' ); ?></th>
131
+ <td>
132
+ <select name="type_flags" style="width :200px;">
133
+ <option <?php if(esc_attr( get_option('type_flags') )=="0") { echo "selected"; } ?> value="0"><?php _e( 'Rectangle mat', 'weglot' ); ?></option>
134
+ <option <?php if(esc_attr( get_option('type_flags') )=="1") { echo "selected"; } ?> value="1"><?php _e( 'Rectangle bright', 'weglot' ); ?></option>
135
+ <option <?php if(esc_attr( get_option('type_flags') )=="2") { echo "selected"; } ?> value="2"><?php _e( 'Square', 'weglot' ); ?></option>
136
+ <option <?php if(esc_attr( get_option('type_flags') )=="3") { echo "selected"; } ?> value="3"><?php _e( 'Circle', 'weglot' ); ?></option>
137
+ </select>
138
+ <div class="flag-style-openclose"><?php _e('Change country flags','weglot'); ?></div>
139
+ <div class="flag-style-wrapper" style="display:none;">
140
+ <select class="flag-en-type">
141
+ <option value=0><?php _e('Choose english flag:','weglot'); ?></option>
142
+ <option value=0><?php _e('United Kingdom (default)','weglot'); ?></option>
143
+ <option value=1><?php _e('United States','weglot'); ?></option>
144
+ <option value=2><?php _e('Australia','weglot'); ?></option>
145
+ <option value=3><?php _e('Canada','weglot'); ?></option>
146
+ <option value=4><?php _e('New Zealand','weglot'); ?></option>
147
+ <option value=5><?php _e('Jamaica','weglot'); ?></option>
148
+ <option value=6><?php _e('Ireland','weglot'); ?></option>
149
+ </select>
150
+ <select class="flag-es-type">
151
+ <option value=0><?php _e('Choose spanish flag:','weglot'); ?></option>
152
+ <option value=0><?php _e('Spain (default)','weglot'); ?></option>
153
+ <option value=1><?php _e('Mexico','weglot'); ?></option>
154
+ <option value=2><?php _e('Argentina','weglot'); ?></option>
155
+ <option value=3><?php _e('Colombia','weglot'); ?></option>
156
+ <option value=4><?php _e('Peru','weglot'); ?></option>
157
+ <option value=5><?php _e('Bolivia','weglot'); ?></option>
158
+ <option value=6 ><?php _e('Uruguay','weglot'); ?></option>
159
+ <option value=7 ><?php _e('Venezuela','weglot'); ?></option>
160
+ <option value=8 ><?php _e('Chile','weglot'); ?></option>
161
+ <option value=9 ><?php _e('Ecuador','weglot'); ?></option>
162
+ <option value=10><?php _e('Guatemala','weglot'); ?></option>
163
+ <option value=11><?php _e('Cuba','weglot'); ?></option>
164
+ <option value=12><?php _e('Dominican Republic','weglot'); ?></option>
165
+ <option value=13><?php _e('Honduras','weglot'); ?></option>
166
+ <option value=14><?php _e('Paraguay','weglot'); ?></option>
167
+ <option value=15><?php _e('El Salvador','weglot'); ?></option>
168
+ <option value=16><?php _e('Nicaragua','weglot'); ?></option>
169
+ <option value=17><?php _e('Costa Rica','weglot'); ?></option>
170
+ <option value=18><?php _e('Puerto Rico','weglot'); ?></option>
171
+ <option value=19><?php _e('Panama','weglot'); ?></option>
172
+ </select>
173
+ <select class="flag-pt-type">
174
+ <option value=0><?php _e('Choose portugese flag:','weglot'); ?></option>
175
+ <option value=0><?php _e('Brazil (default)','weglot'); ?></option>
176
+ <option value=1><?php _e('Portugal','weglot'); ?></option>
177
+ </select>
178
+ <p><?php _e('If you want to change another flag, just ask us.','weglot'); ?></p>
179
+ </div>
180
+ </td>
181
+ </tr>
182
+ <tr valign="top">
183
+ <th scope="row"><?php _e( 'With name?', 'weglot' ); ?></th>
184
+ <td><input id="id_with_name" type="checkbox" name="with_name" <?php if(esc_attr(get_option('with_name'))=="on") echo "checked"; ?> /><label for="id_with_name" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want to display the name of languages.', 'weglot' ); ?></label></td>
185
+ </tr>
186
+ <tr valign="top">
187
+ <th scope="row"><?php _e( 'Full name?', 'weglot' ); ?></th>
188
+ <td><input id="id_is_fullname" type="checkbox" name="is_fullname" <?php if(esc_attr(get_option('is_fullname'))=="on") echo "checked"; ?> /><label for="id_is_fullname" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want the name of the languge. Don\'t check if you want the language code.', 'weglot' ); ?></label></td>
189
+ </tr>
190
+ <tr valign="top">
191
+ <th scope="row"><?php _e( 'Override CSS', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php _e( 'Don\'t change it unless you want a specific style for your button.', 'weglot' ); ?></p></th>
192
+ <td><textarea type="text" rows = 10 cols = 30 name="override_css" placeholder="<?php _e( '.country-selector {
193
+ margin-bottom : 20px;
194
+ background-color : green!important;
195
+ }
196
+ .country-selector a {
197
+ color : blue!important;
198
+ }', 'weglot' ); ?>"><?php echo esc_attr( get_option('override_css') ); ?></textarea><textarea type="text" name="flag_css" style="display:none;" ><?php echo esc_attr( get_option('flag_css') ); ?></textarea></td>
199
+ </tr>
200
+ </table>
201
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php echo __( 'Language button position', 'weglot' )." ".__( '(Optional)', 'weglot' ); ?></h3>
202
+ <h4 style="font-size:14px;line-height: 1.3;font-weight: 600;"><?php _e( 'Where will be the language button on my website? By default, bottom right.','weglot'); ?></h4>
203
+ <table class="form-table">
204
+ <tr valign="top">
205
+ <th scope="row"><?php _e( 'In menu?', 'weglot' ); ?></th>
206
+ <td><input id="id_is_menu" type="checkbox" name="is_menu" <?php if(esc_attr(get_option('is_menu'))=="on") echo "checked"; ?> /><label for="id_is_menu" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want to display the button in the naviguation menu.', 'weglot' ); ?></label></td>
207
+ </tr>
208
+ <tr valign="top">
209
+ <th scope="row"><?php _e( 'As a widget?', 'weglot' ); ?></th>
210
+ <td><p style="font-weight: normal;font-style: italic;display: inline-block;"><?php _e( 'You can place the button in a Widget area. Go in Appearance -> Widget and drag and drop Weglot Translate widget where you want.', 'weglot' ); ?></p></td>
211
+ </tr>
212
+ <tr valign="top">
213
+ <th scope="row"><?php _e( 'With a shortcode?', 'weglot' ); ?></th>
214
+ <td><p style="font-weight: normal;font-style: italic;display: inline-block;"><?php _e( 'You can use weglot short code [weglot_switcher] wherever you want to place the button.', 'weglot' ); ?></p></td>
215
+ </tr>
216
+ <tr valign="top">
217
+ <th scope="row"><?php _e( 'In the sourcecode?', 'weglot' ); ?></th>
218
+ <td><p style="font-weight: normal;font-style: italic;display: inline-block;"><?php _e( 'You can add the code &lt;div id=&quot;weglot_here&quot;&gt;&lt;/div&gt; wherever you want in the source code of your HTML page. The button will appear at this place.', 'weglot' ); ?></p></td>
219
+ </tr>
220
+ </table>
221
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php echo __( 'Translation Exclusion', 'weglot' )." ".__( '(Optional)', 'weglot' );; ?></h3>
222
+ <p><?php _e( 'By default, every page is translated. You can exclude parts of a page or a full page here.', 'weglot' ); ?></p>
223
+ <table class="form-table">
224
+ <tr valign="top">
225
+ <th scope="row"><?php _e( 'Exclude URL here', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php _e( 'You can write regex.', 'weglot' ); ?><p></th>
226
+ <td><textarea type="text" rows = 3 cols = 30 name="exclude_url" placeholder=""><?php echo esc_attr( get_option('exclude_url') ); ?></textarea></td>
227
+ </tr>
228
+ <tr valign="top">
229
+ <th scope="row"><?php _e( 'Exclude blocks', 'weglot' ); ?><p style="font-weight:normal;margin-top:2px;"><?php _e( 'Enter CSS selectors, separated by commas', 'weglot' ); ?><p></th>
230
+ <td><textarea type="text" rows = 3 cols = 30 name="exclude_blocks" placeholder="#top-menu,footer a,.title-3"><?php echo esc_attr( get_option('exclude_blocks') ); ?></textarea></td>
231
+ </tr>
232
+ </table>
233
+ <?php if($this->userInfo['plan']>0) { ?>
234
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php echo __( 'Other options', 'weglot' )." ".__( '(Optional)', 'weglot' );; ?></h3>
235
+ <table class="form-table">
236
+ <tr valign="top">
237
+ <th scope="row"><?php _e( 'Auto redirect?', 'weglot' ); ?></th>
238
+ <td><input id="id_auto_switch" type="checkbox" name="wg_auto_switch" <?php if(esc_attr(get_option('wg_auto_switch'))=="on") echo "checked"; ?> /><label for="id_auto_switch" style="font-weight: normal;margin-left: 20px;font-style: italic;display: inline-block;"><?php _e( 'Check if you want to redirect users based on their browser language.', 'weglot' ); ?></label></td>
239
+ </tr>
240
+ </table>
241
+ <?php } ?>
242
+ <?php if($showLTR || $showRTL) {
243
+ $ltrOrRtl = $showLTR ? __('Left to Right languages','weglot'):__('Right to Left languages','weglot');
244
+ ?>
245
+ <h3 style="border-bottom:1px solid #c0c0c0;padding-bottom:10px;max-width:800px;margin-top:40px;"><?php echo __( 'Customize style for ', 'weglot' ).$ltrOrRtl." ".__( '(Optional)', 'weglot' );; ?></h3>
246
+ <table class="form-table">
247
+ <tr valign="top">
248
+ <th scope="row"><?php echo sprintf(__( 'Write CSS rules to apply for on %s page', 'weglot' ),$ltrOrRtl); ?><p style="font-weight:normal;margin-top:2px;"><p></th>
249
+ <td><textarea type="text" rows = 5 cols = 30 name="rtl_ltr_style" placeholder="<?php _e( 'body {
250
+ text-align :right;
251
+ }', 'weglot' ); ?>"><?php echo esc_attr( get_option('rtl_ltr_style') ); ?></textarea></td>
252
+ </tr>
253
+ </table>
254
+ <?php } ?>
255
+ <?php submit_button(); ?>
256
+ </form><?php if(esc_attr(get_option('show_box'))=="off") { ?><div class="wginfobox">
257
+ <h3><?php _e('Where are my translations?','weglot'); ?></h3>
258
+ <div>
259
+ <p><?php _e('You can find all your translations in your Weglot account:','weglot'); ?></p>
260
+ <a href="<?php _e('https://weglot.com/dashboard','weglot'); ?>" target="_blank" class="wg-editbtn"><?php _e('Edit my translations','weglot'); ?></a>
261
+ </div>
262
+ </div><?php } ?>
263
+ <br>
264
+ <a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/weglot?rate=5#postform">
265
+ <?php _e( 'Love Weglot? Give us 5 stars on WordPress.org :)', 'weglot' ); ?>
266
+ </a>
267
+ <br><br>
268
+ <i class="fa fa-question-circle" aria-hidden="true" style="font-size : 17px;"></i><p style="display:inline-block; margin-left:5px;"><?php _e('If you need any help, you can contact us on our live chat on <a href="https://weglot.com/" target="_blank">weglot.com</a> or email us at support@weglot.com','weglot'); ?></p>
269
+ <br><br><br>
270
+ <h2></h2>
271
+ </div>
languages/weglot-fr_FR.mo ADDED
Binary file
languages/weglot-fr_FR.po ADDED
@@ -0,0 +1,547 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Translation of Development (trunk) in French (France)
2
+ # This file is distributed under the same license as the Development (trunk) package.
3
+ msgid ""
4
+ msgstr ""
5
+ "PO-Revision-Date: 2016-09-02 12:12+0200\n"
6
+ "MIME-Version: 1.0\n"
7
+ "Content-Type: text/plain; charset=UTF-8\n"
8
+ "Content-Transfer-Encoding: 8bit\n"
9
+ "Plural-Forms: nplurals=2; plural=n > 1;\n"
10
+ "X-Generator: Poedit 1.8.6\n"
11
+ "Project-Id-Version: Development (trunk)\n"
12
+ "POT-Creation-Date: \n"
13
+ "Last-Translator: \n"
14
+ "Language-Team: \n"
15
+ "Language: fr\n"
16
+
17
+ #: weglot.php:346
18
+ msgid "Malay"
19
+ msgstr "Malais"
20
+
21
+ #: weglot.php:347
22
+ msgid "Norwegian"
23
+ msgstr "Norvégien"
24
+
25
+ #: weglot.php:348
26
+ msgid "Basque"
27
+ msgstr "Basque"
28
+
29
+ #: weglot.php:354
30
+ msgid "Destination Languages"
31
+ msgstr "Languages souhaités"
32
+
33
+ #: weglot.php:354
34
+ msgid "Write the two-letters codes, separated by a comma. Supported languages are <a target=\"_blank\" href=\"https://weglot.com/translation-api#languages_code\">here</a>."
35
+ msgstr "Inscrivez le code à deux lettres de votre langue, séparé par une virgule. Langues supportées <a target=\"_blank\" href=\"https://weglot.com/fr/translation-api#languages_code\">ici</a>."
36
+
37
+ #: weglot.php:358
38
+ msgid "Language button appearance"
39
+ msgstr "Apparence du bouton de choix de langue"
40
+
41
+ #: weglot.php:361
42
+ msgid "Where do you want your language button : (optional)."
43
+ msgstr "Ou souhaitez vous placer le bouton de choix de langue ?"
44
+
45
+ #: weglot.php:361
46
+ msgid "Select a node using its xpath"
47
+ msgstr "Selectionnez un élement en utilisant le XPath"
48
+
49
+ #: weglot.php:364
50
+ msgid "Before"
51
+ msgstr "Avant"
52
+
53
+ #: weglot.php:365
54
+ msgid "After"
55
+ msgstr "Après"
56
+
57
+ #: weglot.php:366
58
+ msgid "At the beginning of"
59
+ msgstr "Au début du noeud"
60
+
61
+ #: weglot.php:367
62
+ msgid "At the end of"
63
+ msgstr "A la fin du noeud"
64
+
65
+ #: weglot.php:369
66
+ msgid "For instance:"
67
+ msgstr "Par exemple :"
68
+
69
+ #: weglot.php:373
70
+ msgid "With flags?"
71
+ msgstr "Avec les drapeaux ?"
72
+
73
+ #: weglot.php:373
74
+ msgid "Check if you want flags in the language button."
75
+ msgstr "Cochez si vous souhaitez avoir des drapeaux dans votre bouton de choix de langue"
76
+
77
+ #: weglot.php:377
78
+ msgid "Override CSS"
79
+ msgstr "Remplacer le CSS"
80
+
81
+ #: weglot.php:377
82
+ msgid "Don't change it unless you want a specific style for your button."
83
+ msgstr "Ne changez rien sauf si vous voulez un style de bouton spécifique"
84
+
85
+ #: weglot.php:378
86
+ msgid "Write CSS rules here"
87
+ msgstr "Ecrivez vos règles CSS ici"
88
+
89
+ #: weglot.php:381
90
+ msgid "Translation Exclusion"
91
+ msgstr "Exclusion de Traduction"
92
+
93
+ #: weglot.php:382
94
+ msgid "By default, every page is translated. You can exclude parts of a page or a full page here."
95
+ msgstr "Par défaut, toutes les pages sont traduites. Vous pouvez exclure des parties de pages ou des pages entières ici."
96
+
97
+ #: weglot.php:385
98
+ msgid "Exclude URL here"
99
+ msgstr "Exclure des URL"
100
+
101
+ #: weglot.php:385
102
+ msgid "You can write regex."
103
+ msgstr "Vous pouvez utiliser des regex (expressions régulières)"
104
+
105
+ #: weglot.php:394
106
+ msgid "Love Weglot? Give us 5 stars on WordPress.org :)"
107
+ msgstr "Vous aimez Weglot ? Mettez nous 5 étoiles sur WordPress.org :)"
108
+
109
+ #. Plugin Name of the plugin/theme
110
+ msgid "Weglot"
111
+ msgstr "Weglot"
112
+
113
+ #. Plugin URI of the plugin/theme
114
+ msgid "http://wordpress.org/plugins/Weglot/"
115
+ msgstr "http://wordpress.org/plugins/Weglot/"
116
+
117
+ #. Description of the plugin/theme
118
+ msgid "Translate your website site into multiple languages in minutes without doing any code. Totally SEO compatible."
119
+ msgstr "Traduisez votre site web dans plusieurs langues en quelques minutes sans aucune ligne de code. Tout ça en étant optimisé en SEO."
120
+
121
+ #. Author of the plugin/theme
122
+ msgid "Remy B"
123
+ msgstr "Rémy B"
124
+
125
+ #: weglot.php:342
126
+ msgid "Dutch"
127
+ msgstr "Néerlandais"
128
+
129
+ #: weglot.php:343
130
+ msgid "Polish"
131
+ msgstr "Polonnais"
132
+
133
+ #: weglot.php:344
134
+ msgid "Finnish"
135
+ msgstr "Finnois"
136
+
137
+ #: weglot.php:345
138
+ msgid "Greek"
139
+ msgstr "Grec"
140
+
141
+ #: weglot.php:338
142
+ msgid "Japanese"
143
+ msgstr "Japonais"
144
+
145
+ #: weglot.php:339
146
+ msgid "Korean"
147
+ msgstr "Coréen"
148
+
149
+ #: weglot.php:340
150
+ msgid "Turkish"
151
+ msgstr "Turc"
152
+
153
+ #: weglot.php:341
154
+ msgid "Danish"
155
+ msgstr "Danois"
156
+
157
+ #: weglot.php:333
158
+ msgid "Spanish"
159
+ msgstr "Espagnol"
160
+
161
+ #: weglot.php:334
162
+ msgid "Portuguese"
163
+ msgstr "Portugais"
164
+
165
+ #: weglot.php:335
166
+ msgid "Arabic"
167
+ msgstr "Arabe"
168
+
169
+ #: weglot.php:336
170
+ msgid "Hebrew"
171
+ msgstr "Hébreu"
172
+
173
+ #: weglot.php:337
174
+ msgid "Italian"
175
+ msgstr "Italien"
176
+
177
+ #: weglot.php:330
178
+ msgid "Simplified Chinese"
179
+ msgstr "Chinois simplifié"
180
+
181
+ #: weglot.php:9876
182
+ msgid "Traditional Chinese"
183
+ msgstr "Chinois traditionnel"
184
+
185
+ #: weglot.php:331
186
+ msgid "Russian"
187
+ msgstr "Russe"
188
+
189
+ #: weglot.php:332
190
+ msgid "German"
191
+ msgstr "Allemand"
192
+
193
+ #: weglot.php:325
194
+ msgid "Original Language"
195
+ msgstr "Language d'origine"
196
+
197
+ #: weglot.php:325
198
+ msgid "What is the original (current) language of your website?"
199
+ msgstr "Quel est le language d'origine de votre site ?"
200
+
201
+ #: weglot.php:328
202
+ msgid "French"
203
+ msgstr "Français"
204
+
205
+ #: weglot.php:329
206
+ msgid "English"
207
+ msgstr "Anglais"
208
+
209
+ #: weglot.php:312
210
+ msgid "Weglot Integration"
211
+ msgstr "Intégration Weglot"
212
+
213
+ #: weglot.php:314
214
+ msgid "Login to %s to get your API key"
215
+ msgstr "Connectez vous à %s pour trouver votre clé API"
216
+
217
+ #: weglot.php:318
218
+ msgid "Main configuration"
219
+ msgstr "Configuration principale"
220
+
221
+ #: weglot.php:321
222
+ msgid "API Key"
223
+ msgstr "Clé API"
224
+
225
+ #: weglot.php:400
226
+ msgid "Dropdown?"
227
+ msgstr "Liste déroulante ?"
228
+
229
+ #: weglot.php:401
230
+ msgid "Check if you want the button to be a dropdown box."
231
+ msgstr "Cochez si vous voulez que le bouton soit une liste déroulante."
232
+
233
+ #: weglot.php:402
234
+ msgid "Full name?"
235
+ msgstr "Nom entier ?"
236
+
237
+ #: weglot.php:403
238
+ msgid "Check if you want the name of the languge. Don't check if you want the language code."
239
+ msgstr "Cochez si vous voulez le nom du language. Sinon ce sera le code du language."
240
+
241
+ #: weglot.php:404
242
+ msgid "Preview"
243
+ msgstr "Aperçu"
244
+
245
+ #: weglot.php:405
246
+ msgid "After you saved, dont forget to add \"Weglot Translate\" widget to your website by going in \"Appearance\" -> \"Widgets\". Have fun!"
247
+ msgstr "Après avoir sauvegardé, n'oubliez pas d'ajouter le widget \"Weglot Translate\" à votre site en allant dans \"Appearance\" -> \"Widgets\". Have fun!"
248
+
249
+ #: weglot.php:406
250
+ msgid "Where are my translations?"
251
+ msgstr "Où trouver mes traductions ?"
252
+
253
+ #: weglot.php:407
254
+ msgid "You can find all your translations in your Weglot account:"
255
+ msgstr "Vous pouvez trouver toutes vos traductions dans votre compte Weglot :"
256
+
257
+ #: weglot.php:408
258
+ msgid "Edit my translations"
259
+ msgstr "Modifier mes traductions"
260
+
261
+ #: weglot.php:409
262
+ msgid "https://weglot.com/dashboard"
263
+ msgstr "https://weglot.com/fr/dashboard"
264
+
265
+ #: weglot.php:410
266
+ msgid "Close"
267
+ msgstr "Fermer"
268
+
269
+ #: weglot.php:411
270
+ msgid "Well done! Your website is now multilingual"
271
+ msgstr "Bravo ! Votre site web est à présent multilingue"
272
+
273
+ #: weglot.php:412
274
+ msgid "Go on your website, there is a language switcher, try it :)"
275
+ msgstr "Allez sur votre site, il y a un bouton de langues, essayez :)"
276
+
277
+ #: weglot.php:413
278
+ msgid "Go on my front page"
279
+ msgstr "Allez sur la page d'accueil"
280
+
281
+ #: weglot.php:414
282
+ msgid "Next step, edit your translations directly in your Weglot account."
283
+ msgstr "Prochaine étape, modifiez vos traductions directement dans votre compte Weglot."
284
+
285
+ #: weglot.php:415
286
+ msgid "https://embed.tawk.to/56ae29fefe87529955d63d81/default"
287
+ msgstr "https://embed.tawk.to/56ae29fefe87529955d63d81/1aac5l822"
288
+
289
+ #: weglot.php:416
290
+ msgid "To reactivate the service, please <a target=\"_blank\" href=\"https://weglot.com/change-plan\">upgrade your plan</a>"
291
+ msgstr "Pour réactiver le service, veuillez <a target=\"_blank\" href=\"https://weglot.com/fr/change-plan\">souscrire une licence</a>"
292
+
293
+ #: weglot.php:417
294
+ msgid "Weglot Translate service is not active because you reach the end of the trial period."
295
+ msgstr "Weglot Translate n'est pas actif car vous avez êtes arrivé à la fin de la période d'essai gratuite."
296
+
297
+ #: weglot.php:418
298
+ msgid "On the free plan, you can only chose one language with a maximum of 2000 words. If you want to use more than 1 language and 2000 words, please <a target=\"_blank\" href=\"https://weglot.com/change-plan\">upgrade your plan</a>."
299
+ msgstr "Avec le plan gratuit, vous pouvez choisir une langue et maximum 2000 mots. Si vous souhaitez avoir plusieurs languages ou plus de 2000 mots, veuillez <a target=\"_blank\" href=\"https://weglot.com/fr/change-plan\">souscrire une licence</a>."
300
+
301
+ #: weglot.php:4189
302
+ msgid "On the Starter plan, you can only chose one language. If you want to use more than 1 language, please <a target=\"_blank\" href=\"https://weglot.com/change-plan\">upgrade your plan</a>."
303
+ msgstr "Avec le plan Starter, vous pouvez choisir une langue. Si vous souhaitez avoir plusieurs languages, veuillez <a target=\"_blank\" href=\"https://weglot.com/fr/change-plan\">souscrire une licence</a>."
304
+
305
+ #: weglot.php:419
306
+ msgid "Where will be the language button on my website? By default, bottom right."
307
+ msgstr "Où va apparaître le bouton de language ? Par défaut, en bas à droite."
308
+
309
+ #: weglot.php:420
310
+ msgid "You can place the button in a Widget area. Go in Appearance -> Widget and drag and drop Weglot Translate widget where you want."
311
+ msgstr "Vous pouvez placer le bouton dans une zone de widget. Allez dans Apparence -> Widget et drag & dropez le widget Weglot Translate où vous voulez."
312
+
313
+ #: weglot.php:421
314
+ msgid "(Optional)"
315
+ msgstr "(Optionnel)"
316
+
317
+ #: weglot.php:422
318
+ msgid "Customize style for "
319
+ msgstr "Modifier le style pour les "
320
+
321
+ #: weglot.php:423
322
+ msgid "Left to Right languages"
323
+ msgstr "languages Droite à Gauche"
324
+
325
+ #: weglot.php:424
326
+ msgid "Right to Left languages"
327
+ msgstr "languages Gauche à Droite"
328
+
329
+ #: weglot.php:425
330
+ msgid "Write CSS rules to apply for on %s page"
331
+ msgstr "Ecrivez vos règles CSS à appliquer sur les pages de %s"
332
+
333
+ #: weglot.php:426
334
+ msgid "Weglot Translate plugin requires at least PHP 5.3 and you have PHP %s. Please upgrade your PHP Version (you can contact your host and they will do it for you)."
335
+ msgstr "Weglot Translate nécessite au moins PHP 5.3 et vous avez PHP %s. Veuillez upgrader votre version de PHP (Vous pouvez contacter votre hébergeur, il le fera pour vous)."
336
+
337
+ #: weglot.php:426
338
+ msgid "Weglot Translate: You need to activate the mod_rewrite module. You have more information here : <a target=\"_blank\" href=\"https://codex.wordpress.org/Using_Permalinks\">Using Permalinks</a>. If you need help, just ask us directly <a target=\"_blank\" href=\"https://tawk.to/remyb\">here</a>"
339
+ msgstr "Weglot Translate : Vous devez activer le module mod_rewrite. Vous avez plus d'information ici : <a target=\"_blank\" href=\"https://codex.wordpress.org/fr:Utilisation_des_permaliens\">Utilisation des permaliens</a>. Si vous avez besoin d'aide, demandez nous directement <a target=\"_blank\" href=\"https://tawk.to/remyb\">ici</a>"
340
+
341
+ #: weglot.php:427
342
+ msgid "With name?"
343
+ msgstr "Afficher le nom ?"
344
+
345
+ #: weglot.php:428
346
+ msgid "Check if you want to display the name of languages."
347
+ msgstr "Cochez si vous souhaitez afficher le nom des langues."
348
+
349
+ #: weglot.php:429
350
+ msgid "In menu?"
351
+ msgstr "Dans le menu ?"
352
+
353
+ #: weglot.php:431
354
+ msgid "Check if you want to display the button in the naviguation menu."
355
+ msgstr "Cochez si vous voulez faire apparaître le bouton dans menu de navigation."
356
+
357
+ #: weglot.php:432
358
+ msgid "As a widget?"
359
+ msgstr "Comme Widget ?"
360
+
361
+ #: weglot.php:433
362
+ msgid "With a shortcode?"
363
+ msgstr "Avec un shortcode ?"
364
+
365
+ #: weglot.php:434
366
+ msgid "You can use weglot short code [weglot_switcher] wherever you want to place the button."
367
+ msgstr "Vous pouvez utiliser le short code [weglot_switcher] là où vous souhaitez placer le bouton."
368
+
369
+ #: weglot.php:435
370
+ msgid "In the sourcecode?"
371
+ msgstr "Dans le code source ?"
372
+
373
+ #: weglot.php:436
374
+ msgid "You can add the code &lt;div id=&quot;weglot_here&quot;&gt;&lt;/div&gt; wherever you want in the source code of your HTML page. The button will appear at this place."
375
+ msgstr "Vous pouvez ajouter le code &lt;div id=&quot;weglot_here&quot;&gt;&lt;/div&gt; là où vous voulez dans le code source de votre page HTML. Le bouton apparaîtra à cet endroit."
376
+
377
+ #: weglot.php:437
378
+ msgid "Rectangle mat"
379
+ msgstr "Rectangle mat"
380
+
381
+ #: weglot.php:438
382
+ msgid "Rectangle bright"
383
+ msgstr "Rectangle vif"
384
+
385
+ #: weglot.php:439
386
+ msgid "Square"
387
+ msgstr "Carré"
388
+
389
+ #: weglot.php:440
390
+ msgid "Circle"
391
+ msgstr "Cercle"
392
+
393
+ #: weglot.php:441
394
+ msgid "Type of flags"
395
+ msgstr "Type de drapeaux"
396
+
397
+ #: weglot.php:441
398
+ msgid "Settings"
399
+ msgstr "Réglages"
400
+
401
+ #: weglot.php:442
402
+ msgid "If you need any help, you can contact us on our live chat on <a href=\"https://weglot.com/\" target=\"_blank\">weglot.com</a> or email us at contact@weglot.com"
403
+ msgstr "Si vous avez une question, vous pouvez nous contacter directement sur notre live chat sur <a href=\"https://weglot.com/\" target=\"_blank\">weglot.com</a> ou par email sur contact@weglot.com"
404
+
405
+ #: weglot.php:443
406
+ msgid "Change country flags"
407
+ msgstr "Changez les drapeaux de pays"
408
+
409
+ #: weglot.php:444
410
+ msgid "Choose english flag:"
411
+ msgstr "Choisir le drapeau anglais"
412
+
413
+ #: weglot.php:445
414
+ msgid "Choose spanish flag:"
415
+ msgstr "Choisir le drapeau espagnol"
416
+
417
+ #: weglot.php:446
418
+ msgid "Choose portugese flag:"
419
+ msgstr "Choisir le drapeau portugais"
420
+
421
+ #: weglot.php:447
422
+ msgid "If you want to change another flag, just ask us."
423
+ msgstr "Si vous souhaitez changer un autre drapeau, demandez nous."
424
+
425
+ #: weglot.php:448
426
+ msgid "United Kingdom (default)"
427
+ msgstr "Royaume-Uni (défaut)"
428
+
429
+ #: weglot.php:449
430
+ msgid "United States"
431
+ msgstr "Etats-Unis"
432
+
433
+ #: weglot.php:450
434
+ msgid "Australia"
435
+ msgstr "Australie"
436
+
437
+ #: weglot.php:451
438
+ msgid "Spain (default)"
439
+ msgstr "Espagne (défaut)"
440
+
441
+ #: weglot.php:452
442
+ msgid "Mexico"
443
+ msgstr "Mexique"
444
+
445
+ #: weglot.php:453
446
+ msgid "Argentina"
447
+ msgstr "Argentine"
448
+
449
+ #: weglot.php:454
450
+ msgid "Colombia"
451
+ msgstr "Colombie"
452
+
453
+ #: weglot.php:455
454
+ msgid "Peru"
455
+ msgstr "Pérou"
456
+
457
+ #: weglot.php:456
458
+ msgid "Bolivia"
459
+ msgstr "Bolivie"
460
+
461
+ #: weglot.php:457
462
+ msgid "Uruguay"
463
+ msgstr "Uruguay"
464
+
465
+ #: weglot.php:458
466
+ msgid "Brazil (default)"
467
+ msgstr "Brésil (défaut)"
468
+
469
+ #: weglot.php:459
470
+ msgid "Portugal"
471
+ msgstr "Portugal"
472
+
473
+ #: weglot.php:460
474
+ msgid "Canada"
475
+ msgstr "Canada"
476
+
477
+ #: weglot.php:461
478
+ msgid "New Zealand"
479
+ msgstr "Nouvelle-Zélande"
480
+
481
+ #: weglot.php:462
482
+ msgid "Jamaica"
483
+ msgstr "Jamaïque"
484
+
485
+ #: weglot.php:463
486
+ msgid "Ireland"
487
+ msgstr "Irlande"
488
+
489
+ #: weglot.php:464
490
+ msgid "Venezuela"
491
+ msgstr "Vénezuela"
492
+
493
+ #: weglot.php:465
494
+ msgid "Chile"
495
+ msgstr "Chili"
496
+
497
+ #: weglot.php:466
498
+ msgid "Ecuador"
499
+ msgstr "Equateur"
500
+
501
+ #: weglot.php:467
502
+ msgid "Guatemala"
503
+ msgstr "Guatemala"
504
+
505
+ #: weglot.php:468
506
+ msgid "Cuba"
507
+ msgstr "Cuba"
508
+
509
+ #: weglot.php:469
510
+ msgid "Dominican Republic"
511
+ msgstr "République Dominicaine"
512
+
513
+ #: weglot.php:470
514
+ msgid "Honduras"
515
+ msgstr "Honduras"
516
+
517
+ #: weglot.php:471
518
+ msgid "Paraguay"
519
+ msgstr "Paraguay"
520
+
521
+ #: weglot.php:472
522
+ msgid "El Salvador"
523
+ msgstr "El Salvador"
524
+
525
+ #: weglot.php:473
526
+ msgid "Nicaragua"
527
+ msgstr "Nicaragua"
528
+
529
+ #: weglot.php:474
530
+ msgid "Costa Rica"
531
+ msgstr "Costa Rica"
532
+
533
+ #: weglot.php:475
534
+ msgid "Puerto Rico"
535
+ msgstr "Porto Rico"
536
+
537
+ #: weglot.php:476
538
+ msgid "Panama"
539
+ msgstr "Panama"
540
+
541
+ #: weglot.php:477
542
+ msgid "Exclude blocks"
543
+ msgstr "Exclure des blocs"
544
+
545
+ #: weglot.php:478
546
+ msgid "Enter CSS selectors, separated by commas"
547
+ msgstr "Entrez des selecteurs CSS, séparés par des virgules"
readme.txt ADDED
@@ -0,0 +1,345 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Weglot Translate - Translate your WP website ===
2
+ 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.0
5
+ Tested up to: 4.7
6
+ Stable tag: 1.4.3
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ Translate your website into multiple languages without any code. Weglot Translate is fully SEO compatible, follow multilingual Google best practices.
11
+
12
+
13
+ == Description ==
14
+ The best and easiest translation solution to translate your Wordpress website and go multilingual:
15
+ Weglot Translate detects and translates all your content in any languages and provides
16
+ a unique dashboard to edit translations or purchase professional translations to ensure the quality of translations.
17
+
18
+ With Weglot Translate, translates your website site into a multilingual website with multiple languages in minutes without doing any code.
19
+ Weglot Translate is totally SEO compatible. Weglot Translate follows Google's best practice in terms of multilingual website to serve a translated webpage with a clean source code. Every translated version of your website will be indexed by Google.
20
+
21
+ Weglot Translate is trusted by companies in e-commerce, SaaS, marketplaces, corporate websites, mobile application landing page, blogs, etc.
22
+
23
+ Check Weglot Translate in video:
24
+
25
+ [youtube http://www.youtube.com/watch?v=cdoBED8p3HQ]
26
+
27
+ Weglot Translate benefits:
28
+
29
+ - Fully compatible with every Theme and plugins : Weglot Translate will translate every strings in the page.
30
+ - 60+ translation languages available
31
+ - A unique and single place to manage all your languages and translations
32
+ - Content automatically detected and translated: content is the only thing you need to care about.
33
+ - You do not need to search for translations files (.po) or any other Wordpress source files.
34
+ - Translations constantly displayed in real-time
35
+ - Access to professional translators if you need quality translations.
36
+ - Optimized SEO in new languages with dedicated URLs : translated pages will have their dedicated URLs, as Google best practice for multilingual
37
+ - Language switch button is customizable
38
+
39
+ Is Weglot Translate free?
40
+
41
+ Weglot Translate is free for small websites (under 2000 words) with one translation language.
42
+ Weglot Translate has Free and Premium plans available: https://weglot.com/pricingwp, depending on your needs. You can always take Weglot Translate free trial version to test it.
43
+ Weglot Translate offers a professional support to premium users to help them translate their website.
44
+
45
+ Does Weglot Translate provide support?
46
+
47
+ Yes, Weglot Translate team will support everyone. Post a topic on https://wordpress.org/support/plugin/weglot or email us at support@weglot.com or speak with us on our live chat on weglot website.
48
+
49
+ Weglot Translate plugin is translated in english and french. More translations will be added.
50
+
51
+ Weglot Translate, go multilingual now.
52
+
53
+ Keywords: polylang, prisna, gts, localize, lingotek, smartling, qtranslate, loco translate, loco, google website translator, translate wordpress, translate, transposh, global translator, machine translate, wp translate, gtranslate, translator, translation
54
+
55
+ == Installation ==
56
+
57
+ = Minimum Requirements for Wegot Translate =
58
+ * WordPress 3.0 or greater
59
+ * PHP version 5.3 or greater
60
+ * Rewrite rules activated
61
+
62
+ = Installation steps for Weglot Translate =
63
+ Weglot Translate is easy to setup :
64
+
65
+ 1. Go to https://weglot.com/register-wordpress to setup an account
66
+ 2. Grab your api_key from your dashboard, it looks like "wg_XXXXXXX"
67
+ 3. Find the Weglot Translate settings page on the bottom left of your wordpress admin dashboard
68
+ 4. Add and save your api key to Weglot Translate settings, enter your website's original language and enter the translations languages you want separated by commas (for instance en,de,pt to have translations in English, German and Portuguese)
69
+ 5. Chose the appearance for the translation button (flags, list or dropdown, translation language fullname or code)
70
+ 6. Click on the Save button.
71
+ 7. (Optional) Go in Appearance -> Widgets and drag and drop "Weglot Translate" widget where you want it to appear.
72
+ 8. Refresh your web page, your website is now available in the selected translations languages. You can switch languages to see translated pages.
73
+ 9. If you want, you can edit your translations directly in your account: https://weglot.com/dashboard
74
+
75
+
76
+ == Frequently Asked Questions ==
77
+ = Is Weglot Translate free? =
78
+ Weglot Translate is a freemium plugin : it is free for small website (under 2000 words) with one translation language. If you need more, you can upgrade. Details of our pricing is here : https://weglot.com/pricingwp
79
+
80
+ In any case, you can try Weglot for 10 days for free.
81
+ = Edit my translations =
82
+ With Weglot Translate you can modify translations in "Translations" in your Weglot account, here : https://weglot.com/dashboard. If you change a translation, it's automatically saved and displayed on your website.
83
+ = Translations I edited are not displayed on my website =
84
+
85
+ All translations edited in your dashboard are automatically displayed in real-time in the translated versions of your website. If you can not see your new translations:
86
+
87
+ 1. Empty your cache plugin: it will enable new translations to be properly displayed. If it's still not showing your new translations then
88
+
89
+ 2. Go into your Weglot account and check you edited the right translations: use the search bar (at the top) to easily find translations you want to edit. Sometimes you can have 2 very similar translations and edited the wrong one.
90
+
91
+ = Change the appearance of Weglot Translate language button =
92
+ You can change one of the three set-up items in your Weglot Translate settings (with(out) flags, horizontal or dropdown menu, full language name or 2-letters code) or overwrite CSS.
93
+ = Change the position of Weglot Translate language button =
94
+ With widget areas, you can drag and drop the Weglot Translate widget.
95
+
96
+ Alternatively, use overwrite CSS to change the Weglot Translate button position or ask the Weglot Translate team at support@weglot.com. We will help you.
97
+
98
+ You can also put the button in the navigation menu by checking the option in Weglot settings page. Be aware that putting the button in the menu might change a bit the appearance of the button as there are already some style (CSS) rules active in the menu.
99
+
100
+ You can additionaly use a short code : [weglot_switcher].
101
+
102
+ Finally, you can also add &lt;div id=&quot;weglot_here&quot;&gt;&lt;/div&gt; anywhere in your code and weglot button will position at this place.
103
+ = SEO and translations =
104
+ Weglot Translate creates dedicated URL for each language to ensure a proper indexation of your translated content by Search engines (Google, ...). SEO tags are also translated and editable in your Weglot Translate account. Translated pages will be on a sub-directory.
105
+ = Translated URLs =
106
+ Weglot Translate chose to not translate URLs, as it could break URLs with non Roman alphabet (Chinese, Russian alphabets for ex) and it has no proven impact on SEO. Finally, Google, Amazon, Airbnb etc... are not doing it.
107
+ = Translate image/video =
108
+ With Weglot Translate, you can add different images for different languages. This is usefull if you have text in an image and you want to display translated image in your translated version. To do this, you can simply upload your other translated image in your gallery and then link it by going in your dashboard and search for the original URL in the translations list.
109
+ = Translations exclusions =
110
+ You can exclude pages from translations if you don't want it to be translated or just part of pages by using CSS selectors.
111
+ To do this, go in WordPress panel -> Weglot settings page and use field "Translation Exclusion".
112
+
113
+ = Translations exceptions =
114
+ You can create your own translation rules in your Weglot dashboard by clicking on Translations Options. Allowing you to:
115
+
116
+ 1. Add Exception Rules, such as "Never translate" or "Always translate" a word/expression in a custom way (for exemple if you do not want to translate your brand name).
117
+
118
+ 2. Use the "Search and Replace" tool, to easily search for a word in all your translations and replace it by the one you want.
119
+
120
+ = Support =
121
+ If you have any question about Weglot Translate, please post a topic on https://wordpress.org/support/plugin/weglot or contact us at support@weglot.com or directly using our live chat on https://weglot.com
122
+
123
+ == Instructions ==
124
+ Weglot Translate is easy to setup :
125
+
126
+ 1. Go to https://weglot.com/register-wordpress to setup an account
127
+ 2. Grab your api_key from your dashboard, it looks like "wg_XXXXXXX"
128
+ 3. Find the Weglot Translate settings page on the bottom left of your wordpress admin dashboard
129
+ 4. Add and save your api key to Weglot Translate settings, enter your website's original language and enter the translations languages you want separated by commas (for instance en,de,pt to have translations in English, German and Portuguese)
130
+ 5. Chose the appearance for the translation button (flags, list or dropdown, translation language fullname or code)
131
+ 6. Click on the Save button.
132
+ 7. (Optional) Go in Appearance -> Widgets and drag and drop "Weglot Translate" widget where you want it to appear.
133
+ 8. Refresh your web page, your website is now available in the selected translations languages. You can switch languages to see translated pages.
134
+ 9. If you want, you can edit your translations directly in your account: https://weglot.com/dashboard
135
+
136
+ == Screenshots ==
137
+
138
+ 1. Example on front : language switch button on page
139
+ 2. Weglot Translate dashboard, translation edition
140
+ 3. Weglot Translate settings page
141
+ 4. Weglot Translate switch button
142
+ 4. Weglot Translate button : a lot of design are possible
143
+
144
+ == Upgrade Notice ==
145
+ See changelog for upgrade changes.
146
+
147
+ == Changelog ==
148
+
149
+ = 1.4.3 =
150
+ * Compat with WP Fastest cache, improve RTL translations
151
+
152
+ = 1.4.2 =
153
+ * PHP 7 compat, add auto redirect feature, no more FA, no more id on switcher
154
+
155
+ = 1.4.1 =
156
+ * compat AMP, fix url bug on same language code than URL.
157
+
158
+ = 1.4.0 =
159
+ * compat precaching, URLs
160
+
161
+ = 1.3.3 =
162
+ * increase compatibility with other plugins and themes.
163
+
164
+ = 1.3.2 =
165
+ * change support email
166
+ * exclude /amp, admin bar
167
+ * language on starter plan
168
+
169
+ = 1.3.1 =
170
+ * Fix invalid links
171
+ * Handles multiple weglot_here
172
+
173
+ = 1.3.0 =
174
+ * rollbackink parsing lib
175
+ * fix srcset, dslash link
176
+
177
+ = 1.2.8 =
178
+ * parsing lib changed
179
+ * fix several small bugs
180
+
181
+ = 1.2.7 =
182
+ * Adding Traditional Chinese
183
+ * Fix og:url
184
+ * scrybs
185
+
186
+ = 1.2.6 =
187
+ * Fix jpeg translated version
188
+ * Fix moreclass and wg-notranslate on list button in menu
189
+ * Fix ajax json with html in it
190
+
191
+ = 1.2.5 =
192
+ * Add other flags for english, spanish & portugese translations
193
+ * Review style for translation button in menu
194
+ * Add translation exclusion blocks by CSS selectors
195
+
196
+
197
+ = 1.2.4 =
198
+ * Adding Hindi & Urdu translation languages.
199
+ * Adding version number on scripts.
200
+
201
+ = 1.2.3 =
202
+ * Code review and optimization
203
+
204
+ = 1.2.2 =
205
+ * WP Compliance
206
+
207
+ = 1.2.1 =
208
+ * Fix style on dropdown list
209
+ * Fix link containing "admin" word
210
+
211
+ = 1.2 =
212
+ * New choice of flags made by professional designers for your translation switch button. Rectangle mat, rectangle bright, square and circle. Enjoy!
213
+ * Add a "Settings" link under Weglot Translate in pugin list.
214
+
215
+ = 1.1 =
216
+ * Add naviguation menu hook to let user display button in menu.
217
+ * Add possibility to show only flags
218
+ * Show warnings if PHP version is under 5.2 or rewrite rules not activated
219
+ * Rename simple html dom constant and handle no php-mbstring case
220
+ * Fix front page show box when home dir
221
+
222
+ = 1.0 =
223
+ * Change portugese flag to brazilian, change limit message, starting 1.0 versioning as we reach viable product.
224
+
225
+ = Older versions =
226
+
227
+ = 0.1 =
228
+ * First version
229
+
230
+ = 0.2 =
231
+ * Fix label and languages parameters
232
+
233
+ = 0.3 =
234
+ * SEO now completly taken into account.
235
+
236
+ = 0.4 =
237
+ * small fix on links
238
+
239
+ = 0.5 =
240
+ * Fix rules + add url
241
+
242
+ = 0.6 =
243
+ * Fix rules + new button design
244
+
245
+ = 0.7 =
246
+ * Add meta translation, + regex eclusion
247
+
248
+ = 0.8 =
249
+ * Add input button, fix small bug on link
250
+
251
+ = 0.9 =
252
+ * Check rewrite rules are always here
253
+
254
+ = 0.10 =
255
+ * Quick fix for PHP 5.3
256
+
257
+ = 0.11 =
258
+ * Fix ajax, FB compat
259
+
260
+ = 0.12 =
261
+ * Handle WP_HOME
262
+
263
+ = 0.13 =
264
+ * General review
265
+
266
+ = 0.14 =
267
+ * Prepare for localization
268
+
269
+ = 0.15 =
270
+ * Change link to weglot
271
+
272
+ = 0.16 =
273
+ * Place button by default
274
+
275
+ = 0.17 =
276
+ * Fix vc_
277
+
278
+ = 0.18 =
279
+ * Fix cdata
280
+
281
+ = 0.19 =
282
+ * Http api integration
283
+
284
+ = 0.20 =
285
+ * Fix PHP 5.2 compat with anonymous function
286
+
287
+ = 0.21 =
288
+ * Change ob order for compatibility
289
+
290
+ = 0.22 =
291
+ * More flexibility in destination language
292
+
293
+ = 0.23 =
294
+ * Can have multiple youtube video for different languages
295
+
296
+ = 0.24 =
297
+ * Fix some links that had multiple lang tag
298
+
299
+ = 0.25 =
300
+ * Fix CSS style + subdirectory WP
301
+
302
+ = 0.26 =
303
+ * Now support images
304
+
305
+ = 0.27 =
306
+ * Adding 40+ languages + fix homepage bug
307
+
308
+ = 0.28 =
309
+ * Change button to customizable widget, also fix bug https+wp_home
310
+
311
+ = 0.29 =
312
+ * Fix is_html, add US flag possibility, fix link beginning with coutry code.
313
+
314
+ = 0.30 =
315
+ * Fix style, add on-boarding to help users, add link to dashboard translations.
316
+
317
+ = 0.31 =
318
+ * Adding ajax support for full html, fix style, fix link with wp_home
319
+
320
+ = 0.32 =
321
+ * Quick fix on links
322
+
323
+ = 0.33 =
324
+ * Add ajax for json-html
325
+
326
+ = 0.34 =
327
+ * Adding chat support to help user setup the plugin
328
+
329
+ = 0.35 =
330
+ * Rework classes + add search support (form tag)
331
+
332
+ = 0.36 =
333
+ * Remove trial period, replace by free plan
334
+
335
+ = 0.37 =
336
+ * More info on errors, translation limit from api
337
+
338
+ = 0.38 =
339
+ * Fix canonical transated link, support RTL & LTR customization, WG logo to meet Wp standard, translate alt attribute, add possibility to drop button anywhere
340
+
341
+ = 0.39 =
342
+ * Fix LTR CSS, api v2 transmit strings type, fix regex escaping
343
+
344
+ = 0.40 =
345
+ * Add PDF translate, fix simple dom limit, uninstall hook, no &lt;/body&gt; case.
resources/wp-weglot-admin-css.css ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wg-widget-option-form {
2
+ width : 60%;
3
+ display : inline-block;
4
+ vertical-align : top;
5
+ }
6
+ .wginfobox {
7
+ max-width : 36%;
8
+ margin-left : 4%;
9
+ display : inline-block;
10
+ background-color : white;
11
+ border : 1px solid #e0e0e0;
12
+ -webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */
13
+ -moz-box-sizing: border-box; /* Firefox, other Gecko */
14
+ box-sizing: border-box; /* Opera/IE 8+ */
15
+ vertical-align : top;
16
+ }
17
+ .wginfobox h3 {
18
+ color : white;
19
+ background-color : #24284C;
20
+ padding : 20px;
21
+ margin : 0px;
22
+ font-size: 23px;
23
+ line-height: 1.3;
24
+ }
25
+ .wginfobox div {
26
+ padding : 15px;
27
+ }
28
+ .wg-editbtn {
29
+ background: #e56b60;
30
+ color: white;
31
+ font-weight: bold;
32
+ border-radius: 0px;
33
+ border-bottom: 2px solid #B7564D;
34
+ font-size: 18px!important;
35
+ height: 37px!important;
36
+ line-height: 34px!important;
37
+ text-decoration : none;
38
+ padding : 10px 15px;
39
+ display : inline-block;
40
+ }
41
+ .wg-editbtn:hover {
42
+ color : white;
43
+ background: #E87A70;
44
+ }
45
+ .wg-editbtn p {
46
+ font-size: 15px;
47
+ }
48
+ .preview-text {
49
+ display: inline-block;
50
+ font-weight: bold;
51
+ font-size: 15px;
52
+ margin-right: 40px;
53
+ }
54
+ .wg-widget-preview {
55
+ /*border: 1px solid #e0e0e0;
56
+ background-color: white;*/
57
+ -webkit-box-sizing: border-box;
58
+ -moz-box-sizing: border-box;
59
+ box-sizing: border-box;
60
+ padding: 10px;
61
+ display: inline-block;
62
+
63
+ }
64
+ textarea,input[type="text"] {
65
+ padding : 8px!important;
66
+ vertical-align: middle;
67
+ width: 300px;
68
+ }
69
+ select {
70
+ padding : 8px!important;
71
+ height : 37px!important;
72
+ }
73
+ .country-selector {
74
+ z-Index : 100!important;
75
+ }
76
+ .wgbox-blur {
77
+ position: fixed;
78
+ top: 0;
79
+ left: 0;
80
+ display: inline-block;
81
+ width: 100%;
82
+ height: 100%;
83
+ background-color: rgba(0,0,0,0.85);
84
+ text-align: center;
85
+ z-index: 200;
86
+ }
87
+ .wgbox {
88
+ display: inline-block;
89
+ max-width: 550px;
90
+ background-color: white;
91
+ margin-top: 100px;
92
+ padding: 25px;
93
+ }
94
+ .wgbox-title {
95
+ font-size: 24px;
96
+ line-height: 1.3;
97
+ }
98
+ .wgbox-text {
99
+ font-size: 18px;
100
+ }
101
+ .wgbox-button {
102
+
103
+ }
104
+ .wgclose-btn {
105
+ float : right;
106
+ cursor : pointer;
107
+ position : relative;
108
+ top:-10px;
109
+ }
110
+ .wgclose-btn:hover {
111
+ color : #707070;
112
+ text-decoration:underline;
113
+ }
114
+ .wgbox-subtext {
115
+ font-size : 14px;
116
+ }
117
+ .wg-fsubtext {
118
+ font-size: 12px!important;
119
+ font-style: italic;
120
+ margin: 5px;
121
+ }
122
+ .wg-suberror {
123
+ color : red;
124
+ font-size: 12px!important;
125
+ margin: 5px;
126
+ }
127
+ .wg-nokkey:before {
128
+ content:'\274C';
129
+ display:inline-block;
130
+ color:red;
131
+ padding:0 6px 0 0;
132
+ font-size: 15px;
133
+ padding:0 10px;
134
+ }
135
+ .wg-okkey:before {
136
+ content: '\2713';
137
+ display: inline-block;
138
+ color: green;
139
+ padding: 0 10px;
140
+ font-size: 20px;
141
+ font-weight: bold;
142
+ padding:0 10px;
143
+ }
144
+ .wg-status-box {
145
+ margin: 50px 0;
146
+
147
+ }
148
+ .wg-status-box h3 {
149
+ color : #E87A70;
150
+ }
151
+ .wg-status-box h3:before {
152
+ content: '\26A0';
153
+ display: inline-block;
154
+ font-size: 31px;
155
+ margin: 5px 9px 0 0;
156
+ vertical-align: bottom;
157
+ }
158
+ .wg-widget-preview a {
159
+ color : black;
160
+ }
161
+ .flag-style-openclose {
162
+ display: inline-block;
163
+ font-size: 12px;
164
+ color: #51C7A7;
165
+ text-decoration: underline;
166
+ cursor: default;
167
+ margin-left: 20px;
168
+ }
169
+ .flag-style-openclose:hover{
170
+ opacity : 0.6;
171
+ }
172
+ .flag-style-wrapper {
173
+ padding : 15px 0px;
174
+ }
175
+ .flag-style-wrapper p {
176
+ font-size : 12px!important;
177
+ }
178
+ .flag-style-wrapper select {
179
+ padding : 3px!important;
180
+ font-size : 12px;
181
+ }
182
+
183
+ ::-webkit-input-placeholder {
184
+ color: #b0b0b0;
185
+ }
186
+ :-moz-placeholder { /* Firefox 18- */
187
+ color: #b0b0b0;
188
+ }
189
+ ::-moz-placeholder { /* Firefox 19+ */
190
+ color: #b0b0b0;
191
+ }
192
+ :-ms-input-placeholder {
193
+ color: #b0b0b0;
194
+ }
resources/wp-weglot-admin-js.js ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+
3
+ generateWGWidgetCode();
4
+ $( "select[name=original_l]" ).change(function() {
5
+ generateWGWidgetCode();
6
+ });
7
+ $( "select[name=type_flags]" ).change(function() {
8
+ generateWGWidgetCode();
9
+ });
10
+ $( "input[name=destination_l]" ).blur(function() {
11
+ generateWGWidgetCode();
12
+ });
13
+ $('input[name=with_flags]').change(function() {
14
+ generateWGWidgetCode();
15
+ });
16
+ $('input[name=with_name]').change(function() {
17
+ generateWGWidgetCode();
18
+ });
19
+ $('input[name=is_dropdown]').change(function() {
20
+ generateWGWidgetCode();
21
+ });
22
+ $('input[name=is_fullname]').change(function() {
23
+ generateWGWidgetCode();
24
+ });
25
+ $('input[name=is_menu]').change(function() {
26
+ if(this.checked) {
27
+ $('input[name=is_dropdown]').prop('checked', false);
28
+ generateWGWidgetCode();
29
+ }
30
+ });
31
+ $('textarea[name=override_css]').blur(function() {
32
+ var style_value = $(this).val();
33
+ if(style_value!="") {
34
+ var style = $('<style wgstyle>'+$(this).val()+'</style>');
35
+ $('style[wgstyle]').remove();
36
+ $('html > body').append(style);
37
+ generateWGWidgetCode();
38
+ }
39
+ else {
40
+ $('style[wgstyle]').remove();
41
+ }
42
+ });
43
+ $( "select.flag-en-type" ).change(function() {
44
+ refreshFlagCSS();
45
+ generateWGWidgetCode();
46
+ });
47
+ $( "select.flag-es-type" ).change(function() {
48
+ refreshFlagCSS();
49
+ generateWGWidgetCode();
50
+ });
51
+ $( "select.flag-pt-type" ).change(function() {
52
+ refreshFlagCSS();
53
+ generateWGWidgetCode();
54
+ });
55
+
56
+ $('.wgclose-btn').click(function() {
57
+ $('.wgbox-blur').hide();
58
+ });
59
+ $('.flag-style-openclose').click(function() {
60
+ $('.flag-style-wrapper').toggle();
61
+ });
62
+ $('input[name=project_key]').blur(function() {
63
+ var key = $(this).val();
64
+ $.getJSON( "https://weglot.com/api/user-info?api_key="+key, function( data ) {
65
+ $('.wg-keyres').remove();
66
+ $('input[name=project_key]').after('<span class="wg-keyres wg-okkey"></span>');
67
+ $('.wg-widget-option-form input[type=submit]').prop('disabled', false);
68
+ }).fail(function() {
69
+ $('.wg-keyres').remove();
70
+ $('input[name=project_key]').after('<span class="wg-keyres wg-nokkey"></span>')
71
+ $('.wg-widget-option-form input[type=submit]').prop('disabled', true);
72
+ });
73
+ });
74
+ function generateWGWidgetCode() {
75
+ var original = $( "select[name=original_l]" ).val();
76
+ var destination = $( "input[name=destination_l]" ).val();
77
+ var dests = destination.split(',');
78
+ var list='';
79
+
80
+ var flag_class = "";
81
+ if($('input[name=with_flags]').is(':checked')) {
82
+ flag_class += "wg-flags ";
83
+ flag_class += ($("select[name=type_flags]").val()=="0") ? "":"flag-"+$( "select[name=type_flags]" ).val()+" ";
84
+ }
85
+
86
+
87
+ if(destination.length>1) {
88
+ list +='<ul>';
89
+ for(var i=0;i<dests.length;i++) {
90
+ var d = dests[i];
91
+ var l_name = $('input[name=with_name]').is(':checked') ? ($('input[name=is_fullname]').is(':checked') ? getLangNameFromCode(d,false):d.toUpperCase()):"";
92
+ list += '<li class="wg-li '+flag_class+d+'"><a href="#">'+l_name+'</a></li>';
93
+ }
94
+ list +='</ul>';
95
+ }
96
+
97
+ var current_name = $('input[name=with_name]').is(':checked') ? ($('input[name=is_fullname]').is(':checked') ? getLangNameFromCode(original,false):original.toUpperCase()):"";
98
+
99
+ if($('input[name=is_dropdown]').is(':checked')) {
100
+ var opt_class = "wg-drop";
101
+ }
102
+ else {
103
+ var opt_class = "wg-list";
104
+ }
105
+
106
+
107
+
108
+ var style = $('<style wgstyle1>'+$('textarea[name=flag_css]').text()+'</style>');
109
+ $('style[wgstyle1]').remove();
110
+ $('html > body').append(style);
111
+
112
+
113
+ var button = '<aside id="weglot_switcher" wg-notranslate class="'+opt_class+' country-selector closed" onclick="openClose(this);"><div class="wgcurrent wg-li '+flag_class+original+'"><a href="javascript:void(0);">'+current_name+'</a></div>'+list+'</aside>';
114
+ $(".wg-widget-preview").html(button);
115
+ }
116
+
117
+ function refreshFlagCSS() {
118
+ var en_flags = new Array();
119
+ var es_flags = new Array();
120
+ var pt_flags = new Array();
121
+
122
+ en_flags[1] = [7200,7841,48,5256];
123
+ en_flags[2] = [7008,449,3048,5400];
124
+ en_flags[3] = [7040,1281,2712,4968];
125
+ en_flags[4] = [6368,5217,1224,5232];
126
+ en_flags[5] = [5216,3585,1944,4320];
127
+ en_flags[6] = [6176,3457,2016,240];
128
+
129
+ es_flags[1] = [7072,4641,3144,2016];
130
+ es_flags[2] = [5824,353,2880,1704];
131
+ es_flags[3] = [5248,1601,2568,5328];
132
+ es_flags[4] = [896,5793,1032,4296];
133
+ es_flags[5] = [4256,897,4104,3072];
134
+ es_flags[6] = [4544,7905,216,4416];
135
+ es_flags[7] = [4512,8065,192,3168];
136
+ es_flags[8] = [5184,1473,2496,5664];
137
+ es_flags[9] = [3648,2145,4677,2232];
138
+ es_flags[10] = [4704,3009,3240,1848];
139
+ es_flags[11] = [5312,1825,3936,5616];
140
+ es_flags[12] = [4800,2081,3624,5472];
141
+ es_flags[13] = [4640,3201,2160,4440];
142
+ es_flags[14] = [2752,5761,3432,1776];
143
+ es_flags[15] = [4672,2209,3360,3432];
144
+ es_flags[16] = [224,5249,3168,4776];
145
+ es_flags[17] = [6400,1729,3792,288];
146
+ es_flags[18] = [1856,5953,96,4536];
147
+ es_flags[19] = [4608,5697,1056,1872];
148
+
149
+ pt_flags[1] = [6112,5921,528,5640];
150
+
151
+ var enval = $("select.flag-en-type").val();
152
+ var esval = $("select.flag-es-type").val();
153
+ var ptval = $("select.flag-pt-type").val();
154
+
155
+
156
+ var en_style = enval<=0 ? "":".wg-li.en a:before { background-position: -"+en_flags[enval][0]+"px 0; } .wg-li.flag-1.en a:before { background-position: -"+en_flags[enval][1]+"px 0; } .wg-li.flag-2.en a:before { background-position: -"+en_flags[enval][2]+"px 0; } .wg-li.flag-3.en a:before { background-position: -"+en_flags[enval][3]+"px 0; } ";
157
+ var es_style = esval<=0 ? "":".wg-li.es a:before { background-position: -"+es_flags[esval][0]+"px 0; } .wg-li.flag-1.es a:before { background-position: -"+es_flags[esval][1]+"px 0; } .wg-li.flag-2.es a:before { background-position: -"+es_flags[esval][2]+"px 0; } .wg-li.flag-3.es a:before { background-position: -"+es_flags[esval][3]+"px 0; } ";
158
+ var pt_style = ptval<=0 ? "":".wg-li.pt a:before { background-position: -"+pt_flags[ptval][0]+"px 0; } .wg-li.flag-1.pt a:before { background-position: -"+pt_flags[ptval][1]+"px 0; } .wg-li.flag-2.pt a:before { background-position: -"+pt_flags[ptval][2]+"px 0; } .wg-li.flag-3.pt a:before { background-position: -"+pt_flags[ptval][3]+"px 0; } ";
159
+
160
+ $('textarea[name=flag_css]').text(en_style+es_style+pt_style);
161
+ }
162
+ function getLangNameFromCode (original,english) {
163
+ switch (original) {
164
+ case "sq":
165
+ return english ? "Albanian":"Shqip";
166
+ case "en":
167
+ return english ? "English":"English";
168
+ case "ar":
169
+ return english ? "Arabic":"‏العربية‏";
170
+ case "hy":
171
+ return english ? "Armenian":"հայերեն";
172
+ case "az":
173
+ return english ? "Azerbaijani":"Azərbaycan dili";
174
+ case "af":
175
+ return english ? "Afrikaans":"Afrikaans";
176
+ case "eu":
177
+ return english ? "Basque":"Euskara";
178
+ case "be":
179
+ return english ? "Belarusian":"Беларуская";
180
+ case "bg":
181
+ return english ? "Bulgarian":"български";
182
+ case "bs":
183
+ return english ? "Bosnian":"Bosanski";
184
+ case "cy":
185
+ return english ? "Welsh":"Cymraeg";
186
+ case "vi":
187
+ return english ? "Vietnamese":"Tiếng Việt";
188
+ case "hu":
189
+ return english ? "Hungarian":"Magyar";
190
+ case "ht":
191
+ return english ? "Haitian":"Kreyòl ayisyen";
192
+ case "gl":
193
+ return english ? "Galician":"Galego";
194
+ case "nl":
195
+ return english ? "Dutch":"Nederlands";
196
+ case "el":
197
+ return english ? "Greek":"Ελληνικά";
198
+ case "ka":
199
+ return english ? "Georgian":"ქართული";
200
+ case "da":
201
+ return english ? "Danish":"Dansk";
202
+ case "he":
203
+ return english ? "Hebrew":"עברית";
204
+ case "id":
205
+ return english ? "Indonesian":"Bahasa Indonesia";
206
+ case "ga":
207
+ return english ? "Irish":"Gaeilge";
208
+ case "it":
209
+ return english ? "Italian":"Italiano";
210
+ case "is":
211
+ return english ? "Icelandic":"Íslenska";
212
+ case "es":
213
+ return english ? "Spanish":"Español";
214
+ case "kk":
215
+ return english ? "Kazakh":"Қазақша";
216
+ case "ca":
217
+ return english ? "Catalan":"Català";
218
+ case "ky":
219
+ return english ? "Kyrgyz":"кыргызча";
220
+ case "zh":
221
+ return english ? "Simplified Chinese":"中文 (简体)";
222
+ case "tw":
223
+ return english ? "Traditional Chinese":"中文 (繁體)";
224
+ case "ko":
225
+ return english ? "Korean":"한국어";
226
+ case "lv":
227
+ return english ? "Latvian":"Latviešu";
228
+ case "lt":
229
+ return english ? "Lithuanian":"Lietuvių";
230
+ case "mg":
231
+ return english ? "Malagasy":"Malagasy";
232
+ case "ms":
233
+ return english ? "Malay":"Bahasa Melayu";
234
+ case "mt":
235
+ return english ? "Maltese":"Malti";
236
+ case "mk":
237
+ return english ? "Macedonian":"Македонски";
238
+ case "mn":
239
+ return english ? "Mongolian":"Монгол";
240
+ case "de":
241
+ return english ? "German":"Deutsch";
242
+ case "no":
243
+ return english ? "Norwegian":"Norsk";
244
+ case "fa":
245
+ return english ? "Persian":"فارسی";
246
+ case "pl":
247
+ return english ? "Polish":"Polski";
248
+ case "pt":
249
+ return english ? "Portuguese":"Português";
250
+ case "ro":
251
+ return english ? "Romanian":"Română";
252
+ case "ru":
253
+ return english ? "Russian":"Русский";
254
+ case "sr":
255
+ return english ? "Serbian":"Српски";
256
+ case "sk":
257
+ return english ? "Slovak":"Slovenčina";
258
+ case "sl":
259
+ return english ? "Slovenian":"Slovenščina";
260
+ case "sw":
261
+ return english ? "Swahili":"Kiswahili";
262
+ case "tg":
263
+ return english ? "Tajik":"Тоҷикӣ";
264
+ case "th":
265
+ return english ? "Thai":"ภาษาไทย";
266
+ case "tl":
267
+ return english ? "Tagalog":"Tagalog";
268
+ case "tt":
269
+ return english ? "Tatar":"Tatar";
270
+ case "tr":
271
+ return english ? "Turkish":"Türkçe";
272
+ case "uz":
273
+ return english ? "Uzbek":"O'zbek";
274
+ case "uk":
275
+ return english ? "Ukrainian":"Українська";
276
+ case "fi":
277
+ return english ? "Finnish":"Suomi";
278
+ case "fr":
279
+ return english ? "French":"Français";
280
+ case "hr":
281
+ return english ? "Croatian":"Hrvatski";
282
+ case "cs":
283
+ return english ? "Czech":"Čeština";
284
+ case "sv":
285
+ return english ? "Swedish":"Svenska";
286
+ case "et":
287
+ return english ? "Estonian":"Eesti";
288
+ case "ja":
289
+ return english ? "Japanese":"日本語";
290
+ case "hi":
291
+ return english ? "Hindi":"हिंदी";
292
+ case "ur":
293
+ return english ? "Urdu":"اردو";
294
+ }
295
+ }
296
+
297
+ });
resources/wp-weglot-css.css ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* STYLE OF WIDGET */
2
+ .country-selector {
3
+ z-Index : 9999;
4
+ text-align: left;
5
+ position: relative;
6
+ display : inline-block;
7
+ width: auto;
8
+ }
9
+ .wg-drop.country-selector {
10
+ background-color : white;
11
+ }
12
+ .country-selector a {
13
+ padding: 0 10px;
14
+ outline : none;
15
+ text-decoration: none;
16
+ float: none!important;
17
+ }
18
+ .country-selector a:focus {
19
+ outline : none;
20
+ }
21
+ .wg-drop.country-selector a {
22
+ display: block;
23
+ height: 37px;
24
+ line-height: 36px;
25
+ color : black;
26
+ font-size: 13px;
27
+ padding : 0 10px;
28
+ }
29
+ .wg-drop.country-selector :not(.wgcurrent) a {
30
+ width : 100%;
31
+ -webkit-box-sizing: border-box;
32
+ -moz-box-sizing: border-box;
33
+ box-sizing: border-box;
34
+ }
35
+ .wg-list.country-selector a:hover {
36
+ text-decoration : underline;
37
+ color : #00a0d2;
38
+ }
39
+
40
+ .wg-default {
41
+ position : fixed;
42
+ bottom : 0px;
43
+ right : 20px;
44
+ }
45
+ .wg-default.wg-list {
46
+ margin-bottom : 7px;
47
+ }
48
+ .wg-default.wg-list a {
49
+ color : black;
50
+ }
51
+ .wg-drop.country-selector .wgcurrent a{
52
+ padding-right: 40px;
53
+ }
54
+ .wg-list.country-selector .wgcurrent a{
55
+ text-decoration: underline;
56
+ }
57
+ .wg-list.country-selector .wgcurrent{
58
+ display : inline-block;
59
+ vertical-align: middle;
60
+ }
61
+
62
+ .country-selector ul {
63
+ padding: 0px;
64
+ z-index: 1010;
65
+ list-style: none;
66
+ margin: 0;
67
+ }
68
+ .wg-drop.country-selector .wgcurrent {
69
+ border: 1px solid #e0e0e0;
70
+ list-style: none;
71
+ }
72
+ .wg-drop.country-selector ul {
73
+ position: absolute;
74
+ width: 100%;
75
+ border: 1px solid #ebeef0;
76
+ background: white ;
77
+ left : 0;
78
+ top : initial;
79
+ -webkit-box-sizing: border-box;
80
+ -moz-box-sizing: border-box;
81
+ box-sizing: border-box;
82
+ }
83
+ .wg-drop.country-selector:not(.closed) ul {
84
+ display:block;
85
+ background-color: white;
86
+ }
87
+
88
+ .country-selector li {
89
+ margin : 0px;
90
+ padding : 0px;
91
+ }
92
+ .wg-list.country-selector li {
93
+ display : inline-block;
94
+ margin: 2px 0px;
95
+ vertical-align: middle;
96
+ }
97
+ .wg-drop.country-selector li {
98
+ width : 100%;
99
+ }
100
+
101
+ .wg-drop.country-selector .wgcurrent:after {
102
+ display: inline-block;
103
+ position: absolute;
104
+ top: 17px;
105
+ right: 8px;
106
+ width: 13px;
107
+ height: 7px;
108
+ image-rendering: pixelated;
109
+ background-image : url('../images/wgarrowdown.png');
110
+ background-repeat : no-repeat;
111
+ content: '';
112
+ -webkit-transition: all 200ms;
113
+ -moz-transition: all 200ms;
114
+ -ms-transition: all 200ms;
115
+ -o-transition: all 200ms;
116
+ transition: all 200ms;
117
+ }
118
+
119
+ .wg-list.country-selector ul {
120
+ display: inline-block;
121
+ vertical-align: middle;
122
+ }
123
+
124
+ .wg-drop.country-selector.closed ul {
125
+ display: none;
126
+ }
127
+ .wg-drop.country-selector.closed .wgcurrent:after {
128
+ -webkit-transform: rotate(-90deg);
129
+ -moz-transform: rotate(-90deg);
130
+ -ms-transform: rotate(-90deg);
131
+ -o-transform: rotate(-90deg);
132
+ transform: rotate(-90deg);
133
+ }
134
+ .wg-drop.weg-openup ul {
135
+ bottom : 38px;
136
+ }
137
+ .wg-drop.weg-openup .wgcurrent:after {
138
+ -webkit-transform: rotate(-180deg);
139
+ -moz-transform: rotate(-180deg);
140
+ -ms-transform: rotate(-180deg);
141
+ -o-transform: rotate(-180deg);
142
+ transform: rotate(-180deg);
143
+ }
144
+
145
+ .wg-drop.country-selector:not(.closed) a:hover {
146
+ color: #1ba0e3;
147
+ }
148
+
149
+
150
+ .wg-flags a:before {
151
+ content: "";
152
+ vertical-align: middle;
153
+ margin-right: 10px;
154
+ margin-top: -1px;
155
+ display: inline-block;
156
+ overflow: hidden;
157
+ }
158
+
159
+ /* flags style */
160
+ .wg-flags a:before {
161
+ background: url("https://d3m55resnjf8ja.cloudfront.net/rect_mate_flags_comp.png");
162
+ border-radius: 5px;
163
+ width: 32px;
164
+ height: 21px;
165
+ }
166
+
167
+ .wg-li.sq a:before { background-position: -5056px 0; }
168
+ .wg-li.en a:before { background-position: -7136px 0; }
169
+ .wg-li.ar a:before { background-position: -5504px 0; }
170
+ .wg-li.hy a:before { background-position: -4448px 0; }
171
+ .wg-li.az a:before { background-position: -384px 0; }
172
+ .wg-li.af a:before { background-position: -6560px 0; }
173
+ .wg-li.eu a:before { background-position: -7264px 0; }
174
+ .wg-li.be a:before { background-position: -5344px 0; }
175
+ .wg-li.bg a:before { background-position: -5760px 0; }
176
+ .wg-li.bs a:before { background-position: -4896px 0; }
177
+ .wg-li.vi a:before { background-position: -2656px 0; }
178
+ .wg-li.hu a:before { background-position: -5696px 0; }
179
+ .wg-li.ht a:before { background-position: -4768px 0; }
180
+ .wg-li.nl a:before { background-position: -6720px 0; }
181
+ .wg-li.el a:before { background-position: -5728px 0; }
182
+ .wg-li.ka a:before { background-position: -992px 0; }
183
+ .wg-li.da a:before { background-position: -6880px 0; }
184
+ .wg-li.he a:before { background-position: -6048px 0; }
185
+ .wg-li.id a:before { background-position: -1792px 0; }
186
+ .wg-li.ga a:before { background-position: -6176px 0; }
187
+ .wg-li.it a:before { background-position: -6752px 0; }
188
+ .wg-li.is a:before { background-position: -5664px 0; }
189
+ .wg-li.es a:before { background-position: -6592px 0; }
190
+ .wg-li.kk a:before { background-position: -5120px 0; }
191
+ .wg-li.ca a:before { background-position: -7232px 0; }
192
+ .wg-li.ky a:before { background-position: -1568px 0; }
193
+ .wg-li.zh a:before { background-position: -6976px 0; }
194
+ .wg-li.tw a:before { background-position: -6304px 0; }
195
+ .wg-li.ko a:before { background-position: -5984px 0; }
196
+ .wg-li.lv a:before { background-position: -2592px 0; }
197
+ .wg-li.lt a:before { background-position: -1984px 0; }
198
+ .wg-li.mg a:before { background-position: -736px 0; }
199
+ .wg-li.ms a:before { background-position: -5152px 0; }
200
+ .wg-li.mt a:before { background-position: -768px 0; }
201
+ .wg-li.mk a:before { background-position: -4000px 0; }
202
+ .wg-li.mn a:before { background-position: -2368px 0; }
203
+ .wg-li.de a:before { background-position: -7168px 0; }
204
+ .wg-li.no a:before { background-position: -6496px 0; }
205
+ .wg-li.fa a:before { background-position: -1248px 0; }
206
+ .wg-li.pl a:before { background-position: -6144px 0; }
207
+ .wg-li.pt a:before { background-position: -7104px 0; }
208
+ .wg-li.ro a:before { background-position: -5600px 0; }
209
+ .wg-li.ru a:before { background-position: -6688px 0; }
210
+ .wg-li.sr a:before { background-position: -5856px 0; }
211
+ .wg-li.sk a:before { background-position: -5472px 0; }
212
+ .wg-li.sl a:before { background-position: -1408px 0; }
213
+ .wg-li.sw a:before { background-position: -4416px 0; }
214
+ .wg-li.tg a:before { background-position: -832px 0; }
215
+ .wg-li.th a:before { background-position: -6272px 0; }
216
+ .wg-li.tr a:before { background-position: -6624px 0; }
217
+ .wg-li.uz a:before { background-position: -800px 0; }
218
+ .wg-li.uk a:before { background-position: -5568px 0; }
219
+ .wg-li.fi a:before { background-position: -6816px 0; }
220
+ .wg-li.fr a:before { background-position: -6784px 0; }
221
+ .wg-li.hr a:before { background-position: -6528px 0; }
222
+ .wg-li.cs a:before { background-position: -6912px 0; }
223
+ .wg-li.sv a:before { background-position: -6656px 0; }
224
+ .wg-li.et a:before { background-position: -96px 0; }
225
+ .wg-li.ja a:before { background-position: -6944px 0; }
226
+ .wg-li.hi a:before { background-position: -6080px 0; }
227
+ .wg-li.ur a:before { background-position: -2688px 0; }
228
+
229
+ .wg-flags.flag-1 a:before {
230
+ background: url("https://d3m55resnjf8ja.cloudfront.net/rect_bright_flags_comp.png");
231
+ border-radius: 0px;
232
+ width: 30px;
233
+ height: 20px;
234
+ }
235
+
236
+ .wg-li.flag-1.sq a:before { background-position: -97px 0; }
237
+ .wg-li.flag-1.en a:before { background-position: -7777px 0; }
238
+ .wg-li.flag-1.ar a:before { background-position: -6465px 0; }
239
+ .wg-li.flag-1.hy a:before { background-position: -385px 0; }
240
+ .wg-li.flag-1.az a:before { background-position: -513px 0; }
241
+ .wg-li.flag-1.af a:before { background-position: -6849px 0; }
242
+ .wg-li.flag-1.eu a:before { background-position: -8353px 0; }
243
+ .wg-li.flag-1.be a:before { background-position: -705px 0; }
244
+ .wg-li.flag-1.bg a:before { background-position: -1121px 0; }
245
+ .wg-li.flag-1.bs a:before { background-position: -929px 0; }
246
+ .wg-li.flag-1.vi a:before { background-position: -8097px 0; }
247
+ .wg-li.flag-1.hu a:before { background-position: -3265px 0; }
248
+ .wg-li.flag-1.ht a:before { background-position: -3169px 0; }
249
+ .wg-li.flag-1.nl a:before { background-position: -5121px 0; }
250
+ .wg-li.flag-1.el a:before { background-position: -2881px 0; }
251
+ .wg-li.flag-1.ka a:before { background-position: -2721px 0; }
252
+ .wg-li.flag-1.da a:before { background-position: -1985px 0; }
253
+ .wg-li.flag-1.he a:before { background-position: -3521px 0; }
254
+ .wg-li.flag-1.id a:before { background-position: -3361px 0; }
255
+ .wg-li.flag-1.ga a:before { background-position: -3457px 0; }
256
+ .wg-li.flag-1.it a:before { background-position: -3553px 0; }
257
+ .wg-li.flag-1.is a:before { background-position: -3297px 0; }
258
+ .wg-li.flag-1.es a:before { background-position: -7009px 0; }
259
+ .wg-li.flag-1.kk a:before { background-position: -3713px 0; }
260
+ .wg-li.flag-1.ca a:before { background-position: -8321px 0; }
261
+ .wg-li.flag-1.ky a:before { background-position: -3873px 0; }
262
+ .wg-li.flag-1.zh a:before { background-position: -1505px 0; }
263
+ .wg-li.flag-1.tw a:before { background-position: -6369px 0; }
264
+ .wg-li.flag-1.ko a:before { background-position: -6913px 0; }
265
+ .wg-li.flag-1.lv a:before { background-position: -3937px 0; }
266
+ .wg-li.flag-1.lt a:before { background-position: -4129px 0; }
267
+ .wg-li.flag-1.mg a:before { background-position: -4257px 0; }
268
+ .wg-li.flag-1.ms a:before { background-position: -4321px 0; }
269
+ .wg-li.flag-1.mt a:before { background-position: -4417px 0; }
270
+ .wg-li.flag-1.mk a:before { background-position: -4225px 0; }
271
+ .wg-li.flag-1.mn a:before { background-position: -4769px 0; }
272
+ .wg-li.flag-1.de a:before { background-position: -2753px 0; }
273
+ .wg-li.flag-1.no a:before { background-position: -5505px 0; }
274
+ .wg-li.flag-1.fa a:before { background-position: -3393px 0; }
275
+ .wg-li.flag-1.pl a:before { background-position: -5889px 0; }
276
+ .wg-li.flag-1.pt a:before { background-position: -993px 0; }
277
+ .wg-li.flag-1.ro a:before { background-position: -6081px 0; }
278
+ .wg-li.flag-1.ru a:before { background-position: -6113px 0; }
279
+ .wg-li.flag-1.sr a:before { background-position: -6561px 0; }
280
+ .wg-li.flag-1.sk a:before { background-position: -6689px 0; }
281
+ .wg-li.flag-1.sl a:before { background-position: -6721px 0; }
282
+ .wg-li.flag-1.sw a:before { background-position: -3745px 0; }
283
+ .wg-li.flag-1.tg a:before { background-position: -7297px 0; }
284
+ .wg-li.flag-1.th a:before { background-position: -7361px 0; }
285
+ .wg-li.flag-1.tr a:before { background-position: -7553px 0; }
286
+ .wg-li.flag-1.uz a:before { background-position: -7969px 0; }
287
+ .wg-li.flag-1.uk a:before { background-position: -7713px 0; }
288
+ .wg-li.flag-1.fi a:before { background-position: -2529px 0; }
289
+ .wg-li.flag-1.fr a:before { background-position: -2561px 0; }
290
+ .wg-li.flag-1.hr a:before { background-position: -1793px 0; }
291
+ .wg-li.flag-1.cs a:before { background-position: -1921px 0; }
292
+ .wg-li.flag-1.sv a:before { background-position: -7169px 0; }
293
+ .wg-li.flag-1.et a:before { background-position: -2337px 0; }
294
+ .wg-li.flag-1.ja a:before { background-position: -3617px 0; }
295
+ .wg-li.flag-1.hi a:before { background-position: -3329px 0; }
296
+ .wg-li.flag-1.ur a:before { background-position: -5600px 0; }
297
+
298
+ .wg-flags.flag-2 a:before {
299
+ background: url("https://d3m55resnjf8ja.cloudfront.net/square_flags_comp.png");
300
+ border-radius: 0px;
301
+ width: 24px;
302
+ height: 24px;
303
+ }
304
+
305
+ .wg-li.flag-2.sq a:before { background-position: -2976px 0; }
306
+ .wg-li.flag-2.en a:before { background-position: -312px 0; }
307
+ .wg-li.flag-2.ar a:before { background-position: -768px 0; }
308
+ .wg-li.flag-2.hy a:before { background-position: 0 0; }
309
+ .wg-li.flag-2.az a:before { background-position: -5132px 0; }
310
+ .wg-li.flag-2.af a:before { background-position: -4964px 0; }
311
+ .wg-li.flag-2.eu a:before { background-position: -5372px 0; }
312
+ .wg-li.flag-2.be a:before { background-position: -4224px 0; }
313
+ .wg-li.flag-2.bg a:before { background-position: -5036px 0; }
314
+ .wg-li.flag-2.bs a:before { background-position: -3984px 0; }
315
+ .wg-li.flag-2.vi a:before { background-position: -144px 0; }
316
+ .wg-li.flag-2.hu a:before { background-position: -2088px 0; }
317
+ .wg-li.flag-2.ht a:before { background-position: -3528px 0; }
318
+ .wg-li.flag-2.nl a:before { background-position: -1296px 0; }
319
+ .wg-li.flag-2.el a:before { background-position: -2208px 0; }
320
+ .wg-li.flag-2.ka a:before { background-position: -3744px 0; }
321
+ .wg-li.flag-2.da a:before { background-position: -2448px 0; }
322
+ .wg-li.flag-2.he a:before { background-position: -1992px 0; }
323
+ .wg-li.flag-2.id a:before { background-position: -2040px 0; }
324
+ .wg-li.flag-2.ga a:before { background-position: -2016px 0; }
325
+ .wg-li.flag-2.it a:before { background-position: -1968px 0; }
326
+ .wg-li.flag-2.is a:before { background-position: -2064px 0; }
327
+ .wg-li.flag-2.es a:before { background-position: -96px 0; }
328
+ .wg-li.flag-2.kk a:before { background-position: -1704px 0; }
329
+ .wg-li.flag-2.ca a:before { background-position: -5348px 0; }
330
+ .wg-li.flag-2.ky a:before { background-position: -1800px 0; }
331
+ .wg-li.flag-2.zh a:before { background-position: -2592px 0; }
332
+ .wg-li.flag-2.tw a:before { background-position: -3408px 0; }
333
+ .wg-li.flag-2.ko a:before { background-position: -1848px 0; }
334
+ .wg-li.flag-2.lv a:before { background-position: -1752px 0; }
335
+ .wg-li.flag-2.lt a:before { background-position: -1656px 0; }
336
+ .wg-li.flag-2.mg a:before { background-position: -1560px 0; }
337
+ .wg-li.flag-2.ms a:before { background-position: -1536px 0; }
338
+ .wg-li.flag-2.mt a:before { background-position: -1200px 0; }
339
+ .wg-li.flag-2.mk a:before { background-position: -1440px 0; }
340
+ .wg-li.flag-2.mn a:before { background-position: -4797px 0; width: 23px; }
341
+ .wg-li.flag-2.de a:before { background-position: -2256px 0; }
342
+ .wg-li.flag-2.no a:before { background-position: -4773px 0; }
343
+ .wg-li.flag-2.fa a:before { background-position: -5084px 0; }
344
+ .wg-li.flag-2.pl a:before { background-position: -984px 0; }
345
+ .wg-li.flag-2.pt a:before { background-position: -2784px 0; }
346
+ .wg-li.flag-2.ro a:before { background-position: -960px 0; }
347
+ .wg-li.flag-2.ru a:before { background-position: -936px 0; }
348
+ .wg-li.flag-2.sr a:before { background-position: -3120px 0; }
349
+ .wg-li.flag-2.sk a:before { background-position: -4152px 0; }
350
+ .wg-li.flag-2.sl a:before { background-position: -696px 0; }
351
+ .wg-li.flag-2.sw a:before { background-position: -1872px 0; }
352
+ .wg-li.flag-2.tg a:before { background-position: -264px 0; }
353
+ .wg-li.flag-2.th a:before { background-position: -456px 0; }
354
+ .wg-li.flag-2.tr a:before { background-position: -360px 0; }
355
+ .wg-li.flag-2.uz a:before { background-position: -240px 0; }
356
+ .wg-li.flag-2.uk a:before { background-position: -288px 0; }
357
+ .wg-li.flag-2.fi a:before { background-position: -2328px 0; }
358
+ .wg-li.flag-2.fr a:before { background-position: -2304px 0; }
359
+ .wg-li.flag-2.hr a:before { background-position: -4414px 0; }
360
+ .wg-li.flag-2.cs a:before { background-position: -2472px 0; }
361
+ .wg-li.flag-2.sv a:before { background-position: -552px 0; }
362
+ .wg-li.flag-2.et a:before { background-position: -2424px 0; }
363
+ .wg-li.flag-2.ja a:before { background-position: -1920px 0; }
364
+ .wg-li.flag-2.hi a:before { background-position: -1728px 0; }
365
+ .wg-li.flag-2.ur a:before { background-position: -1128px 0; }
366
+
367
+ .wg-flags.flag-3 a:before {
368
+ background: url("https://d3m55resnjf8ja.cloudfront.net/circular_flags_comp.png");
369
+ border-radius: 0px;
370
+ width: 24px;
371
+ height: 24px;
372
+ }
373
+
374
+ .wg-li.flag-3.sq a:before { background-position: -696px 0; }
375
+ .wg-li.flag-3.en a:before { background-position: -5592px 0; }
376
+ .wg-li.flag-3.ar a:before { background-position: -4944px 0; }
377
+ .wg-li.flag-3.hy a:before { background-position: -4656px 0; }
378
+ .wg-li.flag-3.az a:before { background-position: -2832px 0; }
379
+ .wg-li.flag-3.af a:before { background-position: -5064px 0; }
380
+ .wg-li.flag-3.eu a:before { background-position: -5808px 0; }
381
+ .wg-li.flag-3.be a:before { background-position: -1680px 0; }
382
+ .wg-li.flag-3.bg a:before { background-position: -600px 0; }
383
+ .wg-li.flag-3.bs a:before { background-position: -1656px 0; }
384
+ .wg-li.flag-3.vi a:before { background-position: -3504px 0; }
385
+ .wg-li.flag-3.hu a:before { background-position: -1536px 0; }
386
+ .wg-li.flag-3.ht a:before { background-position: -3720px 0; }
387
+ .wg-li.flag-3.nl a:before { background-position: -4392px 0; }
388
+ .wg-li.flag-3.el a:before { background-position: -792px 0; }
389
+ .wg-li.flag-3.ka a:before { background-position: -120px 0; }
390
+ .wg-li.flag-3.da a:before { background-position: -5304px 0; }
391
+ .wg-li.flag-3.he a:before { background-position: -168px 0; }
392
+ .wg-li.flag-3.id a:before { background-position: -3984px 0; }
393
+ .wg-li.flag-3.ga a:before { background-position: -240px 0; }
394
+ .wg-li.flag-3.it a:before { background-position: -5424px 0; }
395
+ .wg-li.flag-3.is a:before { background-position: -768px 0; }
396
+ .wg-li.flag-3.es a:before { background-position: -5760px 0; }
397
+ .wg-li.flag-3.kk a:before { background-position: -2712px 0; }
398
+ .wg-li.flag-3.ca a:before { background-position: -5784px 0; }
399
+ .wg-li.flag-3.ky a:before { background-position: -1800px 0; }
400
+ .wg-li.flag-3.zh a:before { background-position: -3456px 0; }
401
+ .wg-li.flag-3.tw a:before { background-position: -1896px 0; }
402
+ .wg-li.flag-3.ko a:before { background-position: -4848px 0; }
403
+ .wg-li.flag-3.lv a:before { background-position: -1392px 0; }
404
+ .wg-li.flag-3.lt a:before { background-position: -4224px 0; }
405
+ .wg-li.flag-3.mg a:before { background-position: -2856px 0; }
406
+ .wg-li.flag-3.ms a:before { background-position: -1488px 0; }
407
+ .wg-li.flag-3.mt a:before { background-position: -2064px 0; }
408
+ .wg-li.flag-3.mk a:before { background-position: -4824px 0; }
409
+ .wg-li.flag-3.mn a:before { background-position: -3624px 0; }
410
+ .wg-li.flag-3.de a:before { background-position: -5496px 0; }
411
+ .wg-li.flag-3.no a:before { background-position: -5448px 0; }
412
+ .wg-li.flag-3.fa a:before { background-position: -3552px 0; }
413
+ .wg-li.flag-3.pl a:before { background-position: -1032px 0; }
414
+ .wg-li.flag-3.pt a:before { background-position: -5688px 0; }
415
+ .wg-li.flag-3.ro a:before { background-position: -528px 0; }
416
+ .wg-li.flag-3.ru a:before { background-position: -4896px 0; }
417
+ .wg-li.flag-3.sr a:before { background-position: -3480px 0; }
418
+ .wg-li.flag-3.sk a:before { background-position: -5160px 0; }
419
+ .wg-li.flag-3.sl a:before { background-position: -1824px 0; }
420
+ .wg-li.flag-3.sw a:before { background-position: -3120px 0; }
421
+ .wg-li.flag-3.tg a:before { background-position: -3552px 0; }
422
+ .wg-li.flag-3.th a:before { background-position: -5712px 0; }
423
+ .wg-li.flag-3.tr a:before { background-position: -5136px 0; }
424
+ .wg-li.flag-3.uz a:before { background-position: -3888px 0; }
425
+ .wg-li.flag-3.uk a:before { background-position: -5736px 0; }
426
+ .wg-li.flag-3.fi a:before { background-position: -456px 0; }
427
+ .wg-li.flag-3.fr a:before { background-position: -4920px 0; }
428
+ .wg-li.flag-3.hr a:before { background-position: -3216px 0; }
429
+ .wg-li.flag-3.cs a:before { background-position: -4752px 0; }
430
+ .wg-li.flag-3.sv a:before { background-position: -5112px 0; }
431
+ .wg-li.flag-3.et a:before { background-position: -4344px 0; }
432
+ .wg-li.flag-3.ja a:before { background-position: -4872px 0; }
433
+ .wg-li.flag-3.hi a:before { background-position: -5568px 0; }
434
+ .wg-li.flag-3.ur a:before { background-position: -3865px 0; }
resources/wp-weglot-js.js ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function openClose(link) {
2
+ link.className = (link.className.indexOf("country-selector closed") < 0 ) ? link.className.replace("country-selector","country-selector closed"):link.className.replace("country-selector closed","country-selector");
3
+ var body = document.body,html = document.documentElement;
4
+ var page_height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight );
5
+ var h = getOffset( link).top;
6
+
7
+ var position = window.getComputedStyle(link).getPropertyValue("position");
8
+ var bottom = window.getComputedStyle(link).getPropertyValue("bottom");
9
+ var top = window.getComputedStyle(link).getPropertyValue("top");
10
+
11
+
12
+ if((position!="fixed" && h>page_height/2) || (position=="fixed" && h>100)) {
13
+ link.className += " weg-openup";
14
+ }
15
+ return false;
16
+ }
17
+
18
+ function getOffset (element) {
19
+ var top = 0, left = 0;
20
+ do {
21
+ top += element.offsetTop || 0;
22
+ left += element.offsetLeft || 0;
23
+ element = element.offsetParent;
24
+ } while(element);
25
+
26
+ return {
27
+ top: top,
28
+ left: left
29
+ };
30
+ }
simple_html_dom.php ADDED
@@ -0,0 +1,1723 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Website: http://sourceforge.net/projects/simplehtmldom/
4
+ * Acknowledge: Jose Solorzano (https://sourceforge.net/projects/php-html/)
5
+ * Contributions by:
6
+ * Yousuke Kumakura (Attribute filters)
7
+ * Vadim Voituk (Negative indexes supports of "find" method)
8
+ * Antcs (Constructor with automatically load contents either text or file/url)
9
+ *
10
+ * all affected sections have comments starting with "PaperG"
11
+ *
12
+ * Paperg - Added case insensitive testing of the value of the selector.
13
+ * Paperg - Added tag_start for the starting index of tags - NOTE: This works but not accurately.
14
+ * This tag_start gets counted AFTER \r\n have been crushed out, and after the remove_noice calls so it will not reflect the REAL position of the tag in the source,
15
+ * it will almost always be smaller by some amount.
16
+ * We use this to determine how far into the file the tag in question is. This "percentage will never be accurate as the $dom->size is the "real" number of bytes the dom was created from.
17
+ * but for most purposes, it's a really good estimation.
18
+ * Paperg - Added the forceTagsClosed to the dom constructor. Forcing tags closed is great for malformed html, but it CAN lead to parsing errors.
19
+ * Allow the user to tell us how much they trust the html.
20
+ * Paperg add the text and plaintext to the selectors for the find syntax. plaintext implies text in the innertext of a node. text implies that the tag is a text node.
21
+ * This allows for us to find tags based on the text they contain.
22
+ * Create find_ancestor_tag to see if a tag is - at any level - inside of another specific tag.
23
+ * Paperg: added parse_charset so that we know about the character set of the source document.
24
+ * NOTE: If the user's system has a routine called get_last_retrieve_url_contents_content_type availalbe, we will assume it's returning the content-type header from the
25
+ * last transfer or curl_exec, and we will parse that and use it in preference to any other method of charset detection.
26
+ *
27
+ * Found infinite loop in the case of broken html in restore_noise. Rewrote to protect from that.
28
+ * PaperG (John Schlick) Added get_display_size for "IMG" tags.
29
+ *
30
+ * Licensed under The MIT License
31
+ * Redistributions of files must retain the above copyright notice.
32
+ *
33
+ * @author S.C. Chen <me578022@gmail.com>
34
+ * @author John Schlick
35
+ * @author Rus Carroll
36
+ * @version 1.5 ($Rev: 196 $)
37
+ * @package PlaceLocalInclude
38
+ * @subpackage simple_html_dom
39
+ */
40
+ namespace WeglotSDP {
41
+ /**
42
+ * All of the Defines for the classes below.
43
+ * @author S.C. Chen <me578022@gmail.com>
44
+ */
45
+ define('WG_HDOM_TYPE_ELEMENT', 1);
46
+ define('WG_HDOM_TYPE_COMMENT', 2);
47
+ define('WG_HDOM_TYPE_TEXT', 3);
48
+ define('WG_HDOM_TYPE_ENDTAG', 4);
49
+ define('WG_HDOM_TYPE_ROOT', 5);
50
+ define('WG_HDOM_TYPE_UNKNOWN', 6);
51
+ define('WG_HDOM_QUOTE_DOUBLE', 0);
52
+ define('WG_HDOM_QUOTE_SINGLE', 1);
53
+ define('WG_HDOM_QUOTE_NO', 3);
54
+ define('WG_HDOM_INFO_BEGIN', 0);
55
+ define('WG_HDOM_INFO_END', 1);
56
+ define('WG_HDOM_INFO_QUOTE', 2);
57
+ define('WG_HDOM_INFO_SPACE', 3);
58
+ define('WG_HDOM_INFO_TEXT', 4);
59
+ define('WG_HDOM_INFO_INNER', 5);
60
+ define('WG_HDOM_INFO_OUTER', 6);
61
+ define('WG_HDOM_INFO_ENDSPACE',7);
62
+ define('WG_DEFAULT_TARGET_CHARSET', 'UTF-8');
63
+ define('WG_DEFAULT_BR_TEXT', "\r\n");
64
+ define('WG_DEFAULT_SPAN_TEXT', " ");
65
+ define('WG_MAX_FILE_SIZE', 100000000);
66
+ // helper functions
67
+ // -----------------------------------------------------------------------------
68
+ // get html dom from file
69
+ // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
70
+ function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
71
+ {
72
+ // We DO force the tags to be terminated.
73
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
74
+ // For sourceforge users: uncomment the next line and comment the retreive_url_contents line 2 lines down if it is not already done.
75
+ $contents = file_get_contents($url, $use_include_path, $context, $offset);
76
+ // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
77
+ //$contents = retrieve_url_contents($url);
78
+ if (empty($contents) || strlen($contents) > WG_MAX_FILE_SIZE)
79
+ {
80
+ return false;
81
+ }
82
+ // The second parameter can force the selectors to all be lowercase.
83
+ $dom->load($contents, $lowercase, $stripRN);
84
+ return $dom;
85
+ }
86
+
87
+ // get html dom from string
88
+ function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
89
+ {
90
+ $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
91
+ if (empty($str) || strlen($str) > WG_MAX_FILE_SIZE)
92
+ {
93
+ $dom->clear();
94
+ return false;
95
+ }
96
+ $dom->load($str, $lowercase, $stripRN);
97
+ return $dom;
98
+ }
99
+
100
+ // dump html dom tree
101
+ function dump_html_tree($node, $show_attr=true, $deep=0)
102
+ {
103
+ $node->dump($node);
104
+ }
105
+
106
+
107
+ /**
108
+ * simple html dom node
109
+ * PaperG - added ability for "find" routine to lowercase the value of the selector.
110
+ * PaperG - added $tag_start to track the start position of the tag in the total byte index
111
+ *
112
+ * @package PlaceLocalInclude
113
+ */
114
+ class simple_html_dom_node
115
+ {
116
+ public $nodetype = WG_HDOM_TYPE_TEXT;
117
+ public $tag = 'text';
118
+ public $attr = array();
119
+ public $children = array();
120
+ public $nodes = array();
121
+ public $parent = null;
122
+ // The "info" array - see WG_HDOM_INFO_... for what each element contains.
123
+ public $_ = array();
124
+ public $tag_start = 0;
125
+ private $dom = null;
126
+
127
+ function __construct($dom)
128
+ {
129
+ $this->dom = $dom;
130
+ $dom->nodes[] = $this;
131
+ }
132
+
133
+ function __destruct()
134
+ {
135
+ $this->clear();
136
+ }
137
+
138
+ function __toString()
139
+ {
140
+ return $this->outertext();
141
+ }
142
+
143
+ // clean up memory due to php5 circular references memory leak...
144
+ function clear()
145
+ {
146
+ $this->dom = null;
147
+ $this->nodes = null;
148
+ $this->parent = null;
149
+ $this->children = null;
150
+ }
151
+
152
+ // dump node's tree
153
+ function dump($show_attr=true, $deep=0)
154
+ {
155
+ $lead = str_repeat(' ', $deep);
156
+
157
+ echo $lead.$this->tag;
158
+ if ($show_attr && count($this->attr)>0)
159
+ {
160
+ echo '(';
161
+ foreach ($this->attr as $k=>$v)
162
+ echo "[$k]=>\"".$this->$k.'", ';
163
+ echo ')';
164
+ }
165
+ echo "\n";
166
+
167
+ if ($this->nodes)
168
+ {
169
+ foreach ($this->nodes as $c)
170
+ {
171
+ $c->dump($show_attr, $deep+1);
172
+ }
173
+ }
174
+ }
175
+
176
+
177
+ // Debugging function to dump a single dom node with a bunch of information about it.
178
+ function dump_node($echo=true)
179
+ {
180
+
181
+ $string = $this->tag;
182
+ if (count($this->attr)>0)
183
+ {
184
+ $string .= '(';
185
+ foreach ($this->attr as $k=>$v)
186
+ {
187
+ $string .= "[$k]=>\"".$this->$k.'", ';
188
+ }
189
+ $string .= ')';
190
+ }
191
+ if (count($this->_)>0)
192
+ {
193
+ $string .= ' $_ (';
194
+ foreach ($this->_ as $k=>$v)
195
+ {
196
+ if (is_array($v))
197
+ {
198
+ $string .= "[$k]=>(";
199
+ foreach ($v as $k2=>$v2)
200
+ {
201
+ $string .= "[$k2]=>\"".$v2.'", ';
202
+ }
203
+ $string .= ")";
204
+ } else {
205
+ $string .= "[$k]=>\"".$v.'", ';
206
+ }
207
+ }
208
+ $string .= ")";
209
+ }
210
+
211
+ if (isset($this->text))
212
+ {
213
+ $string .= " text: (" . $this->text . ")";
214
+ }
215
+
216
+ $string .= " WG_HDOM_INNER_INFO: '";
217
+ if (isset($node->_[WG_HDOM_INFO_INNER]))
218
+ {
219
+ $string .= $node->_[WG_HDOM_INFO_INNER] . "'";
220
+ }
221
+ else
222
+ {
223
+ $string .= ' NULL ';
224
+ }
225
+
226
+ $string .= " children: " . count($this->children);
227
+ $string .= " nodes: " . count($this->nodes);
228
+ $string .= " tag_start: " . $this->tag_start;
229
+ $string .= "\n";
230
+
231
+ if ($echo)
232
+ {
233
+ echo $string;
234
+ return;
235
+ }
236
+ else
237
+ {
238
+ return $string;
239
+ }
240
+ }
241
+
242
+ // returns the parent of node
243
+ // If a node is passed in, it will reset the parent of the current node to that one.
244
+ function parent($parent=null)
245
+ {
246
+ // I am SURE that this doesn't work properly.
247
+ // It fails to unset the current node from it's current parents nodes or children list first.
248
+ if ($parent !== null)
249
+ {
250
+ $this->parent = $parent;
251
+ $this->parent->nodes[] = $this;
252
+ $this->parent->children[] = $this;
253
+ }
254
+
255
+ return $this->parent;
256
+ }
257
+
258
+ // verify that node has children
259
+ function has_child()
260
+ {
261
+ return !empty($this->children);
262
+ }
263
+
264
+ // returns children of node
265
+ function children($idx=-1)
266
+ {
267
+ if ($idx===-1)
268
+ {
269
+ return $this->children;
270
+ }
271
+ if (isset($this->children[$idx])) return $this->children[$idx];
272
+ return null;
273
+ }
274
+
275
+ // returns the first child of node
276
+ function first_child()
277
+ {
278
+ if (count($this->children)>0)
279
+ {
280
+ return $this->children[0];
281
+ }
282
+ return null;
283
+ }
284
+
285
+ // returns the last child of node
286
+ function last_child()
287
+ {
288
+ if (($count=count($this->children))>0)
289
+ {
290
+ return $this->children[$count-1];
291
+ }
292
+ return null;
293
+ }
294
+
295
+ // returns the next sibling of node
296
+ function next_sibling()
297
+ {
298
+ if ($this->parent===null)
299
+ {
300
+ return null;
301
+ }
302
+
303
+ $idx = 0;
304
+ $count = count($this->parent->children);
305
+ while ($idx<$count && $this!==$this->parent->children[$idx])
306
+ {
307
+ ++$idx;
308
+ }
309
+ if (++$idx>=$count)
310
+ {
311
+ return null;
312
+ }
313
+ return $this->parent->children[$idx];
314
+ }
315
+
316
+ // returns the previous sibling of node
317
+ function prev_sibling()
318
+ {
319
+ if ($this->parent===null) return null;
320
+ $idx = 0;
321
+ $count = count($this->parent->children);
322
+ while ($idx<$count && $this!==$this->parent->children[$idx])
323
+ ++$idx;
324
+ if (--$idx<0) return null;
325
+ return $this->parent->children[$idx];
326
+ }
327
+
328
+ // function to locate a specific ancestor tag in the path to the root.
329
+ function find_ancestor_tag($tag)
330
+ {
331
+ global $debugObject;
332
+ if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
333
+
334
+ // Start by including ourselves in the comparison.
335
+ $returnDom = $this;
336
+
337
+ while (!is_null($returnDom))
338
+ {
339
+ if (is_object($debugObject)) { $debugObject->debugLog(2, "Current tag is: " . $returnDom->tag); }
340
+
341
+ if ($returnDom->tag == $tag)
342
+ {
343
+ break;
344
+ }
345
+ $returnDom = $returnDom->parent;
346
+ }
347
+ return $returnDom;
348
+ }
349
+
350
+ // get dom node's inner html
351
+ function innertext()
352
+ {
353
+ if (isset($this->_[WG_HDOM_INFO_INNER])) return $this->_[WG_HDOM_INFO_INNER];
354
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
355
+
356
+ $ret = '';
357
+ foreach ($this->nodes as $n)
358
+ $ret .= $n->outertext();
359
+ return $ret;
360
+ }
361
+
362
+ // get dom node's outer text (with tag)
363
+ function outertext()
364
+ {
365
+ global $debugObject;
366
+ if (is_object($debugObject))
367
+ {
368
+ $text = '';
369
+ if ($this->tag == 'text')
370
+ {
371
+ if (!empty($this->text))
372
+ {
373
+ $text = " with text: " . $this->text;
374
+ }
375
+ }
376
+ $debugObject->debugLog(1, 'Innertext of tag: ' . $this->tag . $text);
377
+ }
378
+
379
+ if ($this->tag==='root') return $this->innertext();
380
+
381
+ // trigger callback
382
+ if ($this->dom && $this->dom->callback!==null)
383
+ {
384
+ call_user_func_array($this->dom->callback, array($this));
385
+ }
386
+
387
+ if (isset($this->_[WG_HDOM_INFO_OUTER])) return $this->_[WG_HDOM_INFO_OUTER];
388
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
389
+
390
+ // render begin tag
391
+ if ($this->dom && $this->dom->nodes[$this->_[WG_HDOM_INFO_BEGIN]])
392
+ {
393
+ $ret = $this->dom->nodes[$this->_[WG_HDOM_INFO_BEGIN]]->makeup();
394
+ } else {
395
+ $ret = "";
396
+ }
397
+
398
+ // render inner text
399
+ if (isset($this->_[WG_HDOM_INFO_INNER]))
400
+ {
401
+ // If it's a br tag... don't return the WG_HDOM_INNER_INFO that we may or may not have added.
402
+ if ($this->tag != "br")
403
+ {
404
+ $ret .= $this->_[WG_HDOM_INFO_INNER];
405
+ }
406
+ } else {
407
+ if ($this->nodes)
408
+ {
409
+ foreach ($this->nodes as $n)
410
+ {
411
+ $ret .= $this->convert_text($n->outertext());
412
+ }
413
+ }
414
+ }
415
+
416
+ // render end tag
417
+ if (isset($this->_[WG_HDOM_INFO_END]) && $this->_[WG_HDOM_INFO_END]!=0)
418
+ $ret .= '</'.$this->tag.'>';
419
+ return $ret;
420
+ }
421
+
422
+ // get dom node's plain text
423
+ function text()
424
+ {
425
+ if (isset($this->_[WG_HDOM_INFO_INNER])) return $this->_[WG_HDOM_INFO_INNER];
426
+ switch ($this->nodetype)
427
+ {
428
+ case WG_HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
429
+ case WG_HDOM_TYPE_COMMENT: return '';
430
+ case WG_HDOM_TYPE_UNKNOWN: return '';
431
+ }
432
+ if (strcasecmp($this->tag, 'script')===0) return '';
433
+ if (strcasecmp($this->tag, 'style')===0) return '';
434
+
435
+ $ret = '';
436
+ // In rare cases, (always node type 1 or WG_HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
437
+ // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
438
+ // WHY is this happening?
439
+ if (!is_null($this->nodes))
440
+ {
441
+ foreach ($this->nodes as $n)
442
+ {
443
+ $ret .= $this->convert_text($n->text());
444
+ }
445
+
446
+ // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
447
+ if ($this->tag == "span")
448
+ {
449
+ $ret .= $this->dom->WG_DEFAULT_SPAN_TEXT;
450
+ }
451
+
452
+
453
+ }
454
+ return $ret;
455
+ }
456
+
457
+ function xmltext()
458
+ {
459
+ $ret = $this->innertext();
460
+ $ret = str_ireplace('<![CDATA[', '', $ret);
461
+ $ret = str_replace(']]>', '', $ret);
462
+ return $ret;
463
+ }
464
+
465
+ // build node's text with tag
466
+ function makeup()
467
+ {
468
+ // text, comment, unknown
469
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
470
+
471
+ $ret = '<'.$this->tag;
472
+ $i = -1;
473
+
474
+ foreach ($this->attr as $key=>$val)
475
+ {
476
+ ++$i;
477
+
478
+ // skip removed attribute
479
+ if ($val===null || $val===false)
480
+ continue;
481
+
482
+ $ret .= $this->_[WG_HDOM_INFO_SPACE][$i][0];
483
+ //no value attr: nowrap, checked selected...
484
+ if ($val===true)
485
+ $ret .= $key;
486
+ else {
487
+ switch ($this->_[WG_HDOM_INFO_QUOTE][$i])
488
+ {
489
+ case WG_HDOM_QUOTE_DOUBLE: $quote = '"'; break;
490
+ case WG_HDOM_QUOTE_SINGLE: $quote = '\''; break;
491
+ default: $quote = '';
492
+ }
493
+ $ret .= $key.$this->_[WG_HDOM_INFO_SPACE][$i][1].'='.$this->_[WG_HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
494
+ }
495
+ }
496
+ $ret = $this->dom->restore_noise($ret);
497
+ return $ret . $this->_[WG_HDOM_INFO_ENDSPACE] . '>';
498
+ }
499
+
500
+ // find elements by css selector
501
+ //PaperG - added ability for find to lowercase the value of the selector.
502
+ function find($selector, $idx=null, $lowercase=false)
503
+ {
504
+ $selectors = $this->parse_selector($selector);
505
+ if (($count=count($selectors))===0) return array();
506
+ $found_keys = array();
507
+
508
+ // find each selector
509
+ for ($c=0; $c<$count; ++$c)
510
+ {
511
+ // The change on the below line was documented on the sourceforge code tracker id 2788009
512
+ // used to be: if (($levle=count($selectors[0]))===0) return array();
513
+ if (($levle=count($selectors[$c]))===0) return array();
514
+ if (!isset($this->_[WG_HDOM_INFO_BEGIN])) return array();
515
+
516
+ $head = array($this->_[WG_HDOM_INFO_BEGIN]=>1);
517
+
518
+ // handle descendant selectors, no recursive!
519
+ for ($l=0; $l<$levle; ++$l)
520
+ {
521
+ $ret = array();
522
+ foreach ($head as $k=>$v)
523
+ {
524
+ $n = ($k===-1) ? $this->dom->root : $this->dom->nodes[$k];
525
+ //PaperG - Pass this optional parameter on to the seek function.
526
+ $n->seek($selectors[$c][$l], $ret, $lowercase);
527
+ }
528
+ $head = $ret;
529
+ }
530
+
531
+ foreach ($head as $k=>$v)
532
+ {
533
+ if (!isset($found_keys[$k]))
534
+ $found_keys[$k] = 1;
535
+ }
536
+ }
537
+
538
+ // sort keys
539
+ ksort($found_keys);
540
+
541
+ $found = array();
542
+ foreach ($found_keys as $k=>$v)
543
+ $found[] = $this->dom->nodes[$k];
544
+
545
+ // return nth-element or array
546
+ if (is_null($idx)) return $found;
547
+ else if ($idx<0) $idx = count($found) + $idx;
548
+ return (isset($found[$idx])) ? $found[$idx] : null;
549
+ }
550
+
551
+ // seek for given conditions
552
+ // PaperG - added parameter to allow for case insensitive testing of the value of a selector.
553
+ protected function seek($selector, &$ret, $lowercase=false)
554
+ {
555
+ global $debugObject;
556
+ if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
557
+
558
+ list($tag, $key, $val, $exp, $no_key) = $selector;
559
+
560
+ // xpath index
561
+ if ($tag && $key && is_numeric($key))
562
+ {
563
+ $count = 0;
564
+ foreach ($this->children as $c)
565
+ {
566
+ if ($tag==='*' || $tag===$c->tag) {
567
+ if (++$count==$key) {
568
+ $ret[$c->_[WG_HDOM_INFO_BEGIN]] = 1;
569
+ return;
570
+ }
571
+ }
572
+ }
573
+ return;
574
+ }
575
+
576
+ $end = (!empty($this->_[WG_HDOM_INFO_END])) ? $this->_[WG_HDOM_INFO_END] : 0;
577
+ if ($end==0) {
578
+ $parent = $this->parent;
579
+ while (!isset($parent->_[WG_HDOM_INFO_END]) && $parent!==null) {
580
+ $end -= 1;
581
+ $parent = $parent->parent;
582
+ }
583
+ $end += $parent->_[WG_HDOM_INFO_END];
584
+ }
585
+
586
+ for ($i=$this->_[WG_HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
587
+ $node = $this->dom->nodes[$i];
588
+
589
+ $pass = true;
590
+
591
+ if ($tag==='*' && !$key) {
592
+ if (in_array($node, $this->children, true))
593
+ $ret[$i] = 1;
594
+ continue;
595
+ }
596
+
597
+ // compare tag
598
+ if ($tag && $tag!=$node->tag && $tag!=='*') {$pass=false;}
599
+ // compare key
600
+ if ($pass && $key) {
601
+ if ($no_key) {
602
+ if (isset($node->attr[$key])) $pass=false;
603
+ } else {
604
+ if (($key != "plaintext") && !isset($node->attr[$key])) $pass=false;
605
+ }
606
+ }
607
+ // compare value
608
+ if ($pass && $key && $val && $val!=='*') {
609
+ // If they have told us that this is a "plaintext" search then we want the plaintext of the node - right?
610
+ if ($key == "plaintext") {
611
+ // $node->plaintext actually returns $node->text();
612
+ $nodeKeyValue = $node->text();
613
+ } else {
614
+ // this is a normal search, we want the value of that attribute of the tag.
615
+ $nodeKeyValue = $node->attr[$key];
616
+ }
617
+ if (is_object($debugObject)) {$debugObject->debugLog(2, "testing node: " . $node->tag . " for attribute: " . $key . $exp . $val . " where nodes value is: " . $nodeKeyValue);}
618
+
619
+ //PaperG - If lowercase is set, do a case insensitive test of the value of the selector.
620
+ if ($lowercase) {
621
+ $check = $this->match($exp, strtolower($val), strtolower($nodeKeyValue));
622
+ } else {
623
+ $check = $this->match($exp, $val, $nodeKeyValue);
624
+ }
625
+ if (is_object($debugObject)) {$debugObject->debugLog(2, "after match: " . ($check ? "true" : "false"));}
626
+
627
+ // handle multiple class
628
+ if (!$check && strcasecmp($key, 'class')===0) {
629
+ foreach (explode(' ',$node->attr[$key]) as $k) {
630
+ // Without this, there were cases where leading, trailing, or double spaces lead to our comparing blanks - bad form.
631
+ if (!empty($k)) {
632
+ if ($lowercase) {
633
+ $check = $this->match($exp, strtolower($val), strtolower($k));
634
+ } else {
635
+ $check = $this->match($exp, $val, $k);
636
+ }
637
+ if ($check) break;
638
+ }
639
+ }
640
+ }
641
+ if (!$check) $pass = false;
642
+ }
643
+ if ($pass) $ret[$i] = 1;
644
+ unset($node);
645
+ }
646
+ // It's passed by reference so this is actually what this function returns.
647
+ if (is_object($debugObject)) {$debugObject->debugLog(1, "EXIT - ret: ", $ret);}
648
+ }
649
+
650
+ protected function match($exp, $pattern, $value) {
651
+ global $debugObject;
652
+ if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
653
+
654
+ switch ($exp) {
655
+ case '=':
656
+ return ($value===$pattern);
657
+ case '!=':
658
+ return ($value!==$pattern);
659
+ case '^=':
660
+ return preg_match("/^".preg_quote($pattern,'/')."/", $value);
661
+ case '$=':
662
+ return preg_match("/".preg_quote($pattern,'/')."$/", $value);
663
+ case '*=':
664
+ if ($pattern[0]=='/') {
665
+ return preg_match($pattern, $value);
666
+ }
667
+ return preg_match("/".$pattern."/i", $value);
668
+ }
669
+ return false;
670
+ }
671
+
672
+ protected function parse_selector($selector_string) {
673
+ global $debugObject;
674
+ if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
675
+
676
+ // pattern of CSS selectors, modified from mootools
677
+ // Paperg: Add the colon to the attrbute, so that it properly finds <tag attr:ibute="something" > like google does.
678
+ // Note: if you try to look at this attribute, yo MUST use getAttribute since $dom->x:y will fail the php syntax check.
679
+ // Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
680
+ // This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
681
+ // farther study is required to determine of this should be documented or removed.
682
+ // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
683
+ $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
684
+ preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
685
+ if (is_object($debugObject)) {$debugObject->debugLog(2, "Matches Array: ", $matches);}
686
+
687
+ $selectors = array();
688
+ $result = array();
689
+ //print_r($matches);
690
+
691
+ foreach ($matches as $m) {
692
+ $m[0] = trim($m[0]);
693
+ if ($m[0]==='' || $m[0]==='/' || $m[0]==='//') continue;
694
+ // for browser generated xpath
695
+ if ($m[1]==='tbody') continue;
696
+
697
+ list($tag, $key, $val, $exp, $no_key) = array($m[1], null, null, '=', false);
698
+ if (!empty($m[2])) {$key='id'; $val=$m[2];}
699
+ if (!empty($m[3])) {$key='class'; $val=$m[3];}
700
+ if (!empty($m[4])) {$key=$m[4];}
701
+ if (!empty($m[5])) {$exp=$m[5];}
702
+ if (!empty($m[6])) {$val=$m[6];}
703
+
704
+ // convert to lowercase
705
+ if ($this->dom->lowercase) {$tag=strtolower($tag); $key=strtolower($key);}
706
+ //elements that do NOT have the specified attribute
707
+ if (isset($key[0]) && $key[0]==='!') {$key=substr($key, 1); $no_key=true;}
708
+
709
+ $result[] = array($tag, $key, $val, $exp, $no_key);
710
+ if (trim($m[7])===',') {
711
+ $selectors[] = $result;
712
+ $result = array();
713
+ }
714
+ }
715
+ if (count($result)>0)
716
+ $selectors[] = $result;
717
+ return $selectors;
718
+ }
719
+
720
+ function __get($name) {
721
+ if (isset($this->attr[$name]))
722
+ {
723
+ return $this->convert_text($this->attr[$name]);
724
+ }
725
+ switch ($name) {
726
+ case 'outertext': return $this->outertext();
727
+ case 'innertext': return $this->innertext();
728
+ case 'plaintext': return $this->text();
729
+ case 'xmltext': return $this->xmltext();
730
+ default: return array_key_exists($name, $this->attr);
731
+ }
732
+ }
733
+
734
+ function __set($name, $value) {
735
+ switch ($name) {
736
+ case 'outertext': return $this->_[WG_HDOM_INFO_OUTER] = $value;
737
+ case 'innertext':
738
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) return $this->_[WG_HDOM_INFO_TEXT] = $value;
739
+ return $this->_[WG_HDOM_INFO_INNER] = $value;
740
+ }
741
+ if (!isset($this->attr[$name])) {
742
+ $this->_[WG_HDOM_INFO_SPACE][] = array(' ', '', '');
743
+ $this->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_DOUBLE;
744
+ }
745
+ $this->attr[$name] = $value;
746
+ }
747
+
748
+ function __isset($name) {
749
+ switch ($name) {
750
+ case 'outertext': return true;
751
+ case 'innertext': return true;
752
+ case 'plaintext': return true;
753
+ }
754
+ //no value attr: nowrap, checked selected...
755
+ return (array_key_exists($name, $this->attr)) ? true : isset($this->attr[$name]);
756
+ }
757
+
758
+ function __unset($name) {
759
+ if (isset($this->attr[$name]))
760
+ unset($this->attr[$name]);
761
+ }
762
+
763
+ // PaperG - Function to convert the text from one character set to another if the two sets are not the same.
764
+ function convert_text($text)
765
+ {
766
+ global $debugObject;
767
+ if (is_object($debugObject)) {$debugObject->debugLogEntry(1);}
768
+
769
+ $converted_text = $text;
770
+
771
+ $sourceCharset = "";
772
+ $targetCharset = "";
773
+
774
+ if ($this->dom)
775
+ {
776
+ $sourceCharset = strtoupper($this->dom->_charset);
777
+ $targetCharset = strtoupper($this->dom->_target_charset);
778
+ }
779
+ if (is_object($debugObject)) {$debugObject->debugLog(3, "source charset: " . $sourceCharset . " target charaset: " . $targetCharset);}
780
+
781
+ if (!empty($sourceCharset) && !empty($targetCharset) && (strcasecmp($sourceCharset, $targetCharset) != 0))
782
+ {
783
+ // Check if the reported encoding could have been incorrect and the text is actually already UTF-8
784
+ if ((strcasecmp($targetCharset, 'UTF-8') == 0) && ($this->is_utf8($text)))
785
+ {
786
+ $converted_text = $text;
787
+ }
788
+ else
789
+ {
790
+ $converted_text = iconv($sourceCharset, $targetCharset, $text);
791
+ }
792
+ }
793
+
794
+ // Lets make sure that we don't have that silly BOM issue with any of the utf-8 text we output.
795
+ if ($targetCharset == 'UTF-8')
796
+ {
797
+ if (substr($converted_text, 0, 3) == "\xef\xbb\xbf")
798
+ {
799
+ $converted_text = substr($converted_text, 3);
800
+ }
801
+ if (substr($converted_text, -3) == "\xef\xbb\xbf")
802
+ {
803
+ $converted_text = substr($converted_text, 0, -3);
804
+ }
805
+ }
806
+
807
+ return $converted_text;
808
+ }
809
+
810
+ /**
811
+ * Returns true if $string is valid UTF-8 and false otherwise.
812
+ *
813
+ * @param mixed $str String to be tested
814
+ * @return boolean
815
+ */
816
+ static function is_utf8($str)
817
+ {
818
+ $c=0; $b=0;
819
+ $bits=0;
820
+ $len=strlen($str);
821
+ for($i=0; $i<$len; $i++)
822
+ {
823
+ $c=ord($str[$i]);
824
+ if($c > 128)
825
+ {
826
+ if(($c >= 254)) return false;
827
+ elseif($c >= 252) $bits=6;
828
+ elseif($c >= 248) $bits=5;
829
+ elseif($c >= 240) $bits=4;
830
+ elseif($c >= 224) $bits=3;
831
+ elseif($c >= 192) $bits=2;
832
+ else return false;
833
+ if(($i+$bits) > $len) return false;
834
+ while($bits > 1)
835
+ {
836
+ $i++;
837
+ $b=ord($str[$i]);
838
+ if($b < 128 || $b > 191) return false;
839
+ $bits--;
840
+ }
841
+ }
842
+ }
843
+ return true;
844
+ }
845
+ /*
846
+ function is_utf8($string)
847
+ {
848
+ //this is buggy
849
+ return (utf8_encode(utf8_decode($string)) == $string);
850
+ }
851
+ */
852
+
853
+ /**
854
+ * Function to try a few tricks to determine the displayed size of an img on the page.
855
+ * NOTE: This will ONLY work on an IMG tag. Returns FALSE on all other tag types.
856
+ *
857
+ * @author John Schlick
858
+ * @version April 19 2012
859
+ * @return array an array containing the 'height' and 'width' of the image on the page or -1 if we can't figure it out.
860
+ */
861
+ function get_display_size()
862
+ {
863
+ global $debugObject;
864
+
865
+ $width = -1;
866
+ $height = -1;
867
+
868
+ if ($this->tag !== 'img')
869
+ {
870
+ return false;
871
+ }
872
+
873
+ // See if there is aheight or width attribute in the tag itself.
874
+ if (isset($this->attr['width']))
875
+ {
876
+ $width = $this->attr['width'];
877
+ }
878
+
879
+ if (isset($this->attr['height']))
880
+ {
881
+ $height = $this->attr['height'];
882
+ }
883
+
884
+ // Now look for an inline style.
885
+ if (isset($this->attr['style']))
886
+ {
887
+ // Thanks to user gnarf from stackoverflow for this regular expression.
888
+ $attributes = array();
889
+ preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
890
+ foreach ($matches as $match) {
891
+ $attributes[$match[1]] = $match[2];
892
+ }
893
+
894
+ // If there is a width in the style attributes:
895
+ if (isset($attributes['width']) && $width == -1)
896
+ {
897
+ // check that the last two characters are px (pixels)
898
+ if (strtolower(substr($attributes['width'], -2)) == 'px')
899
+ {
900
+ $proposed_width = substr($attributes['width'], 0, -2);
901
+ // Now make sure that it's an integer and not something stupid.
902
+ if (filter_var($proposed_width, FILTER_VALIDATE_INT))
903
+ {
904
+ $width = $proposed_width;
905
+ }
906
+ }
907
+ }
908
+
909
+ // If there is a width in the style attributes:
910
+ if (isset($attributes['height']) && $height == -1)
911
+ {
912
+ // check that the last two characters are px (pixels)
913
+ if (strtolower(substr($attributes['height'], -2)) == 'px')
914
+ {
915
+ $proposed_height = substr($attributes['height'], 0, -2);
916
+ // Now make sure that it's an integer and not something stupid.
917
+ if (filter_var($proposed_height, FILTER_VALIDATE_INT))
918
+ {
919
+ $height = $proposed_height;
920
+ }
921
+ }
922
+ }
923
+
924
+ }
925
+
926
+ // Future enhancement:
927
+ // Look in the tag to see if there is a class or id specified that has a height or width attribute to it.
928
+
929
+ // Far future enhancement
930
+ // Look at all the parent tags of this image to see if they specify a class or id that has an img selector that specifies a height or width
931
+ // Note that in this case, the class or id will have the img subselector for it to apply to the image.
932
+
933
+ // ridiculously far future development
934
+ // If the class or id is specified in a SEPARATE css file thats not on the page, go get it and do what we were just doing for the ones on the page.
935
+
936
+ $result = array('height' => $height,
937
+ 'width' => $width);
938
+ return $result;
939
+ }
940
+
941
+ // camel naming conventions
942
+ function getAllAttributes() {return $this->attr;}
943
+ function getAttribute($name) {return $this->__get($name);}
944
+ function setAttribute($name, $value) {$this->__set($name, $value);}
945
+ function hasAttribute($name) {return $this->__isset($name);}
946
+ function removeAttribute($name) {$this->__set($name, null);}
947
+ function getElementById($id) {return $this->find("#$id", 0);}
948
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
949
+ function getElementByTagName($name) {return $this->find($name, 0);}
950
+ function getElementsByTagName($name, $idx=null) {return $this->find($name, $idx);}
951
+ function parentNode() {return $this->parent();}
952
+ function childNodes($idx=-1) {return $this->children($idx);}
953
+ function firstChild() {return $this->first_child();}
954
+ function lastChild() {return $this->last_child();}
955
+ function nextSibling() {return $this->next_sibling();}
956
+ function previousSibling() {return $this->prev_sibling();}
957
+ function hasChildNodes() {return $this->has_child();}
958
+ function nodeName() {return $this->tag;}
959
+ function appendChild($node) {$node->parent($this); return $node;}
960
+
961
+ }
962
+
963
+ /**
964
+ * simple html dom parser
965
+ * Paperg - in the find routine: allow us to specify that we want case insensitive testing of the value of the selector.
966
+ * Paperg - change $size from protected to public so we can easily access it
967
+ * Paperg - added ForceTagsClosed in the constructor which tells us whether we trust the html or not. Default is to NOT trust it.
968
+ *
969
+ * @package PlaceLocalInclude
970
+ */
971
+ class simple_html_dom
972
+ {
973
+ public $root = null;
974
+ public $nodes = array();
975
+ public $callback = null;
976
+ public $lowercase = false;
977
+ // Used to keep track of how large the text was when we started.
978
+ public $original_size;
979
+ public $size;
980
+ protected $pos;
981
+ protected $doc;
982
+ protected $char;
983
+ protected $cursor;
984
+ protected $parent;
985
+ protected $noise = array();
986
+ protected $token_blank = " \t\r\n";
987
+ protected $token_equal = ' =/>';
988
+ protected $token_slash = " />\r\n\t";
989
+ protected $token_attr = ' >';
990
+ // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
991
+ public $_charset = '';
992
+ public $_target_charset = '';
993
+ protected $WG_DEFAULT_BR_TEXT = "";
994
+ public $WG_DEFAULT_SPAN_TEXT = "";
995
+
996
+ // use isset instead of in_array, performance boost about 30%...
997
+ protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
998
+ protected $block_tags = array('root'=>1, 'body'=>1, 'form'=>1, 'div'=>1, 'span'=>1, 'table'=>1);
999
+ // Known sourceforge issue #2977341
1000
+ // B tags that are not closed cause us to return everything to the end of the document.
1001
+ protected $optional_closing_tags = array(
1002
+ 'tr'=>array('tr'=>1, 'td'=>1, 'th'=>1),
1003
+ 'th'=>array('th'=>1),
1004
+ 'td'=>array('td'=>1),
1005
+ 'li'=>array('li'=>1),
1006
+ 'dt'=>array('dt'=>1, 'dd'=>1),
1007
+ 'dd'=>array('dd'=>1, 'dt'=>1),
1008
+ 'dl'=>array('dd'=>1, 'dt'=>1),
1009
+ 'p'=>array('p'=>1),
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)
1016
+ {
1017
+ if ($str)
1018
+ {
1019
+ if (preg_match("/^http:\/\//i",$str) || is_file($str))
1020
+ {
1021
+ $this->load_file($str);
1022
+ }
1023
+ else
1024
+ {
1025
+ $this->load($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
1026
+ }
1027
+ }
1028
+ // Forcing tags to be closed implies that we don't trust the html, but it can lead to parsing errors if we SHOULD trust the html.
1029
+ if (!$forceTagsClosed) {
1030
+ $this->optional_closing_array=array();
1031
+ }
1032
+ $this->_target_charset = $target_charset;
1033
+ }
1034
+
1035
+ function __destruct()
1036
+ {
1037
+ $this->clear();
1038
+ }
1039
+
1040
+ // load html from string
1041
+ function load($str, $lowercase=true, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1042
+ {
1043
+ global $debugObject;
1044
+
1045
+ // prepare
1046
+ $this->prepare($str, $lowercase, $stripRN, $defaultBRText, $defaultSpanText);
1047
+ // strip out comments
1048
+ $this->remove_noise("'<!--(.*?)-->'is");
1049
+ // strip out cdata
1050
+ $this->remove_noise("'<!\[CDATA\[(.*?)\]\](>|&gt;)'is", true);
1051
+ // Per sourceforge http://sourceforge.net/tracker/?func=detail&aid=2949097&group_id=218559&atid=1044037
1052
+ // Script tags removal now preceeds style tag removal.
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");
1059
+ // strip out preformatted tags
1060
+ $this->remove_noise("'<\s*(?:code)[^>]*>(.*?)<\s*/\s*(?:code)\s*>'is");
1061
+ // strip out server side scripts
1062
+ $this->remove_noise("'(<\?)(.*?)(\?>)'s", true);
1063
+ // strip smarty scripts
1064
+ $this->remove_noise("'(\{\w)(.*?)(\})'s", true);
1065
+
1066
+ // parsing
1067
+ while ($this->parse());
1068
+ // end
1069
+ $this->root->_[WG_HDOM_INFO_END] = $this->cursor;
1070
+ $this->parse_charset();
1071
+
1072
+ // make load function chainable
1073
+ return $this;
1074
+
1075
+ }
1076
+
1077
+ // load html from file
1078
+ function load_file()
1079
+ {
1080
+ $args = func_get_args();
1081
+ $this->load(call_user_func_array('file_get_contents', $args), true);
1082
+ // Throw an error if we can't properly load the dom.
1083
+ if (($error=error_get_last())!==null) {
1084
+ $this->clear();
1085
+ return false;
1086
+ }
1087
+ }
1088
+
1089
+ // set callback function
1090
+ function set_callback($function_name)
1091
+ {
1092
+ $this->callback = $function_name;
1093
+ }
1094
+
1095
+ // remove callback function
1096
+ function remove_callback()
1097
+ {
1098
+ $this->callback = null;
1099
+ }
1100
+
1101
+ // save dom as string
1102
+ function save($filepath='')
1103
+ {
1104
+ $ret = $this->root->innertext();
1105
+ if ($filepath!=='') file_put_contents($filepath, $ret, LOCK_EX);
1106
+ return $ret;
1107
+ }
1108
+
1109
+ // find dom node by css selector
1110
+ // Paperg - allow us to specify that we want case insensitive testing of the value of the selector.
1111
+ function find($selector, $idx=null, $lowercase=false)
1112
+ {
1113
+ return $this->root->find($selector, $idx, $lowercase);
1114
+ }
1115
+
1116
+ // clean up memory due to php5 circular references memory leak...
1117
+ function clear()
1118
+ {
1119
+ foreach ($this->nodes as $n) {$n->clear(); $n = null;}
1120
+ // This add next line is documented in the sourceforge repository. 2977248 as a fix for ongoing memory leaks that occur even with the use of clear.
1121
+ if (isset($this->children)) foreach ($this->children as $n) {$n->clear(); $n = null;}
1122
+ if (isset($this->parent)) {$this->parent->clear(); unset($this->parent);}
1123
+ if (isset($this->root)) {$this->root->clear(); unset($this->root);}
1124
+ unset($this->doc);
1125
+ unset($this->noise);
1126
+ }
1127
+
1128
+ function dump($show_attr=true)
1129
+ {
1130
+ $this->root->dump($show_attr);
1131
+ }
1132
+
1133
+ // prepare HTML data and init everything
1134
+ protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1135
+ {
1136
+ $this->clear();
1137
+
1138
+ // set the length of content before we do anything to it.
1139
+ $this->size = strlen($str);
1140
+ // Save the original size of the html that we got in. It might be useful to someone.
1141
+ $this->original_size = $this->size;
1142
+
1143
+ //before we save the string as the doc... strip out the \r \n's if we are told to.
1144
+ if ($stripRN) {
1145
+ $str = str_replace("\r", " ", $str);
1146
+ $str = str_replace("\n", " ", $str);
1147
+
1148
+ // set the length of content since we have changed it.
1149
+ $this->size = strlen($str);
1150
+ }
1151
+
1152
+ $this->doc = $str;
1153
+ $this->pos = 0;
1154
+ $this->cursor = 1;
1155
+ $this->noise = array();
1156
+ $this->nodes = array();
1157
+ $this->lowercase = $lowercase;
1158
+ $this->WG_DEFAULT_BR_TEXT = $defaultBRText;
1159
+ $this->WG_DEFAULT_SPAN_TEXT = $defaultSpanText;
1160
+ $this->root = new simple_html_dom_node($this);
1161
+ $this->root->tag = 'root';
1162
+ $this->root->_[WG_HDOM_INFO_BEGIN] = -1;
1163
+ $this->root->nodetype = WG_HDOM_TYPE_ROOT;
1164
+ $this->parent = $this->root;
1165
+ if ($this->size>0) $this->char = $this->doc[0];
1166
+ }
1167
+
1168
+ // parse html content
1169
+ protected function parse()
1170
+ {
1171
+ if (($s = $this->copy_until_char('<'))==='')
1172
+ {
1173
+ return $this->read_tag();
1174
+ }
1175
+
1176
+ // text
1177
+ $node = new simple_html_dom_node($this);
1178
+ ++$this->cursor;
1179
+ $node->_[WG_HDOM_INFO_TEXT] = $s;
1180
+ $this->link_nodes($node, false);
1181
+ return true;
1182
+ }
1183
+
1184
+ // PAPERG - dkchou - added this to try to identify the character set of the page we have just parsed so we know better how to spit it out later.
1185
+ // NOTE: IF you provide a routine called get_last_retrieve_url_contents_content_type which returns the CURLINFO_CONTENT_TYPE from the last curl_exec
1186
+ // (or the content_type header from the last transfer), we will parse THAT, and if a charset is specified, we will use it over any other mechanism.
1187
+ protected function parse_charset()
1188
+ {
1189
+ global $debugObject;
1190
+
1191
+ $charset = null;
1192
+
1193
+ if (function_exists('get_last_retrieve_url_contents_content_type'))
1194
+ {
1195
+ $contentTypeHeader = get_last_retrieve_url_contents_content_type();
1196
+ $success = preg_match('/charset=(.+)/', $contentTypeHeader, $matches);
1197
+ if ($success)
1198
+ {
1199
+ $charset = $matches[1];
1200
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'header content-type found charset of: ' . $charset);}
1201
+ }
1202
+
1203
+ }
1204
+
1205
+ if (empty($charset))
1206
+ {
1207
+ $el = $this->root->find('meta[http-equiv=Content-Type]',0);
1208
+ if (!empty($el))
1209
+ {
1210
+ $fullvalue = $el->content;
1211
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag found' . $fullvalue);}
1212
+
1213
+ if (!empty($fullvalue))
1214
+ {
1215
+ $success = preg_match('/charset=(.+)/', $fullvalue, $matches);
1216
+ if ($success)
1217
+ {
1218
+ $charset = $matches[1];
1219
+ }
1220
+ else
1221
+ {
1222
+ // If there is a meta tag, and they don't specify the character set, research says that it's typically ISO-8859-1
1223
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'meta content-type tag couldn\'t be parsed. using iso-8859 default.');}
1224
+ $charset = 'ISO-8859-1';
1225
+ }
1226
+ }
1227
+ }
1228
+ }
1229
+
1230
+ // If we couldn't find a charset above, then lets try to detect one based on the text we got...
1231
+ if (empty($charset))
1232
+ {
1233
+ // Have php try to detect the encoding from the text given to us.
1234
+ if(function_exists('mb_detect_encoding')) {
1235
+ $charset = mb_detect_encoding($this->root->plaintext . "ascii", $encoding_list = array( "UTF-8", "CP1252" ) );
1236
+ }
1237
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'mb_detect found: ' . $charset);}
1238
+
1239
+ // and if this doesn't work... then we need to just wrongheadedly assume it's UTF-8 so that we can move on - cause this will usually give us most of what we need...
1240
+ if ($charset === false)
1241
+ {
1242
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'since mb_detect failed - using default of utf-8');}
1243
+ $charset = 'UTF-8';
1244
+ }
1245
+ }
1246
+
1247
+ // Since CP1252 is a superset, if we get one of it's subsets, we want it instead.
1248
+ if ((strtolower($charset) == strtolower('ISO-8859-1')) || (strtolower($charset) == strtolower('Latin1')) || (strtolower($charset) == strtolower('Latin-1')))
1249
+ {
1250
+ if (is_object($debugObject)) {$debugObject->debugLog(2, 'replacing ' . $charset . ' with CP1252 as its a superset');}
1251
+ $charset = 'CP1252';
1252
+ }
1253
+
1254
+ if (is_object($debugObject)) {$debugObject->debugLog(1, 'EXIT - ' . $charset);}
1255
+
1256
+ return $this->_charset = $charset;
1257
+ }
1258
+
1259
+ // read tag info
1260
+ protected function read_tag()
1261
+ {
1262
+ if ($this->char!=='<')
1263
+ {
1264
+ $this->root->_[WG_HDOM_INFO_END] = $this->cursor;
1265
+ return false;
1266
+ }
1267
+ $begin_tag_pos = $this->pos;
1268
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1269
+
1270
+ // end tag
1271
+ if ($this->char==='/')
1272
+ {
1273
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1274
+ // This represents the change in the simple_html_dom trunk from revision 180 to 181.
1275
+ // $this->skip($this->token_blank_t);
1276
+ $this->skip($this->token_blank);
1277
+ $tag = $this->copy_until_char('>');
1278
+
1279
+ // skip attributes in end tag
1280
+ if (($pos = strpos($tag, ' '))!==false)
1281
+ $tag = substr($tag, 0, $pos);
1282
+
1283
+ $parent_lower = strtolower($this->parent->tag);
1284
+ $tag_lower = strtolower($tag);
1285
+
1286
+ if ($parent_lower!==$tag_lower)
1287
+ {
1288
+ if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower]))
1289
+ {
1290
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1291
+ $org_parent = $this->parent;
1292
+
1293
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1294
+ $this->parent = $this->parent->parent;
1295
+
1296
+ if (strtolower($this->parent->tag)!==$tag_lower) {
1297
+ $this->parent = $org_parent; // restore origonal parent
1298
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
1299
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1300
+ return $this->as_text_node($tag);
1301
+ }
1302
+ }
1303
+ else if (($this->parent->parent) && isset($this->block_tags[$tag_lower]))
1304
+ {
1305
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1306
+ $org_parent = $this->parent;
1307
+
1308
+ while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower)
1309
+ $this->parent = $this->parent->parent;
1310
+
1311
+ if (strtolower($this->parent->tag)!==$tag_lower)
1312
+ {
1313
+ $this->parent = $org_parent; // restore origonal parent
1314
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1315
+ return $this->as_text_node($tag);
1316
+ }
1317
+ }
1318
+ else if (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower)
1319
+ {
1320
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1321
+ $this->parent = $this->parent->parent;
1322
+ }
1323
+ else
1324
+ return $this->as_text_node($tag);
1325
+ }
1326
+
1327
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1328
+ if ($this->parent->parent) $this->parent = $this->parent->parent;
1329
+
1330
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1331
+ return true;
1332
+ }
1333
+
1334
+ $node = new simple_html_dom_node($this);
1335
+ $node->_[WG_HDOM_INFO_BEGIN] = $this->cursor;
1336
+ ++$this->cursor;
1337
+ $tag = $this->copy_until($this->token_slash);
1338
+ $node->tag_start = $begin_tag_pos;
1339
+
1340
+ // doctype, cdata & comments...
1341
+ if (isset($tag[0]) && $tag[0]==='!') {
1342
+ $node->_[WG_HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1343
+
1344
+ if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
1345
+ $node->nodetype = WG_HDOM_TYPE_COMMENT;
1346
+ $node->tag = 'comment';
1347
+ } else {
1348
+ $node->nodetype = WG_HDOM_TYPE_UNKNOWN;
1349
+ $node->tag = 'unknown';
1350
+ }
1351
+ if ($this->char==='>') $node->_[WG_HDOM_INFO_TEXT].='>';
1352
+ $this->link_nodes($node, true);
1353
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1354
+ return true;
1355
+ }
1356
+
1357
+ // text
1358
+ if ($pos=strpos($tag, '<')!==false) {
1359
+ $tag = '<' . substr($tag, 0, -1);
1360
+ $node->_[WG_HDOM_INFO_TEXT] = $tag;
1361
+ $this->link_nodes($node, false);
1362
+ $this->char = $this->doc[--$this->pos]; // prev
1363
+ return true;
1364
+ }
1365
+
1366
+ if (!preg_match("/^[\w-:]+$/", $tag)) {
1367
+ $node->_[WG_HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1368
+ if ($this->char==='<') {
1369
+ $this->link_nodes($node, false);
1370
+ return true;
1371
+ }
1372
+
1373
+ if ($this->char==='>') $node->_[WG_HDOM_INFO_TEXT].='>';
1374
+ $this->link_nodes($node, false);
1375
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1376
+ return true;
1377
+ }
1378
+
1379
+ // begin tag
1380
+ $node->nodetype = WG_HDOM_TYPE_ELEMENT;
1381
+ $tag_lower = strtolower($tag);
1382
+ $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1383
+
1384
+ // handle optional closing tags
1385
+ if (isset($this->optional_closing_tags[$tag_lower]) )
1386
+ {
1387
+ while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)]))
1388
+ {
1389
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1390
+ $this->parent = $this->parent->parent;
1391
+ }
1392
+ $node->parent = $this->parent;
1393
+ }
1394
+
1395
+ $guard = 0; // prevent infinity loop
1396
+ $space = array($this->copy_skip($this->token_blank), '', '');
1397
+
1398
+ // attributes
1399
+ do
1400
+ {
1401
+ if ($this->char!==null && $space[0]==='')
1402
+ {
1403
+ //break;
1404
+ }
1405
+ $name = $this->copy_until($this->token_equal);
1406
+ if ($guard===$this->pos)
1407
+ {
1408
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1409
+ continue;
1410
+ }
1411
+ $guard = $this->pos;
1412
+
1413
+ // handle endless '<'
1414
+ if ($this->pos>=$this->size-1 && $this->char!=='>') {
1415
+ $node->nodetype = WG_HDOM_TYPE_TEXT;
1416
+ $node->_[WG_HDOM_INFO_END] = 0;
1417
+ $node->_[WG_HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1418
+ $node->tag = 'text';
1419
+ $this->link_nodes($node, false);
1420
+ return true;
1421
+ }
1422
+
1423
+ // handle mismatch '<'
1424
+ if ($this->doc[$this->pos-1]=='<') {
1425
+ $node->nodetype = WG_HDOM_TYPE_TEXT;
1426
+ $node->tag = 'text';
1427
+ $node->attr = array();
1428
+ $node->_[WG_HDOM_INFO_END] = 0;
1429
+ $node->_[WG_HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
1430
+ $this->pos -= 2;
1431
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1432
+ $this->link_nodes($node, false);
1433
+ return true;
1434
+ }
1435
+
1436
+ if ($name!=='/' && $name!=='') {
1437
+ $space[1] = $this->copy_skip($this->token_blank);
1438
+ $name = $this->restore_noise($name);
1439
+ if ($this->lowercase) $name = strtolower($name);
1440
+ if ($this->char==='=') {
1441
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1442
+ $this->parse_attr($node, $name, $space);
1443
+ }
1444
+ else {
1445
+ //no value attr: nowrap, checked selected...
1446
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_NO;
1447
+ $node->attr[$name] = true;
1448
+ if ($this->char!='>') $this->char = $this->doc[--$this->pos]; // prev
1449
+ }
1450
+ $node->_[WG_HDOM_INFO_SPACE][] = $space;
1451
+ $space = array($this->copy_skip($this->token_blank), '', '');
1452
+ }
1453
+ else
1454
+ break;
1455
+ } while ($this->char!=='>' && $this->char!=='/');
1456
+
1457
+ $this->link_nodes($node, true);
1458
+ $node->_[WG_HDOM_INFO_ENDSPACE] = $space[0];
1459
+
1460
+ // check self closing
1461
+ if ($this->copy_until_char_escape('>')==='/')
1462
+ {
1463
+ $node->_[WG_HDOM_INFO_ENDSPACE] .= '/';
1464
+ $node->_[WG_HDOM_INFO_END] = 0;
1465
+ }
1466
+ else
1467
+ {
1468
+ // reset parent
1469
+ if (!isset($this->self_closing_tags[strtolower($node->tag)])) $this->parent = $node;
1470
+ }
1471
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1472
+
1473
+ // If it's a BR tag, we need to set it's text to the default text.
1474
+ // This way when we see it in plaintext, we can generate formatting that the user wants.
1475
+ // since a br tag never has sub nodes, this works well.
1476
+ if ($node->tag == "br")
1477
+ {
1478
+ $node->_[WG_HDOM_INFO_INNER] = $this->WG_DEFAULT_BR_TEXT;
1479
+ }
1480
+
1481
+ return true;
1482
+ }
1483
+
1484
+ // parse attributes
1485
+ protected function parse_attr($node, $name, &$space)
1486
+ {
1487
+ // Per sourceforge: http://sourceforge.net/tracker/?func=detail&aid=3061408&group_id=218559&atid=1044037
1488
+ // If the attribute is already defined inside a tag, only pay atetntion to the first one as opposed to the last one.
1489
+ if (isset($node->attr[$name]))
1490
+ {
1491
+ return;
1492
+ }
1493
+
1494
+ $space[2] = $this->copy_skip($this->token_blank);
1495
+ switch ($this->char) {
1496
+ case '"':
1497
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_DOUBLE;
1498
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1499
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
1500
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1501
+ break;
1502
+ case '\'':
1503
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_SINGLE;
1504
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1505
+ $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
1506
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1507
+ break;
1508
+ default:
1509
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_NO;
1510
+ $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
1511
+ }
1512
+ // PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
1513
+ $node->attr[$name] = str_replace("\r", "", $node->attr[$name]);
1514
+ $node->attr[$name] = str_replace("\n", "", $node->attr[$name]);
1515
+ // PaperG: If this is a "class" selector, lets get rid of the preceeding and trailing space since some people leave it in the multi class case.
1516
+ if ($name == "class") {
1517
+ $node->attr[$name] = trim($node->attr[$name]);
1518
+ }
1519
+ }
1520
+
1521
+ // link node's parent
1522
+ protected function link_nodes(&$node, $is_child)
1523
+ {
1524
+ $node->parent = $this->parent;
1525
+ $this->parent->nodes[] = $node;
1526
+ if ($is_child)
1527
+ {
1528
+ $this->parent->children[] = $node;
1529
+ }
1530
+ }
1531
+
1532
+ // as a text node
1533
+ protected function as_text_node($tag)
1534
+ {
1535
+ $node = new simple_html_dom_node($this);
1536
+ ++$this->cursor;
1537
+ $node->_[WG_HDOM_INFO_TEXT] = '</' . $tag . '>';
1538
+ $this->link_nodes($node, false);
1539
+ $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1540
+ return true;
1541
+ }
1542
+
1543
+ protected function skip($chars)
1544
+ {
1545
+ $this->pos += strspn($this->doc, $chars, $this->pos);
1546
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1547
+ }
1548
+
1549
+ protected function copy_skip($chars)
1550
+ {
1551
+ $pos = $this->pos;
1552
+ $len = strspn($this->doc, $chars, $pos);
1553
+ $this->pos += $len;
1554
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1555
+ if ($len===0) return '';
1556
+ return substr($this->doc, $pos, $len);
1557
+ }
1558
+
1559
+ protected function copy_until($chars)
1560
+ {
1561
+ $pos = $this->pos;
1562
+ $len = strcspn($this->doc, $chars, $pos);
1563
+ $this->pos += $len;
1564
+ $this->char = ($this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1565
+ return substr($this->doc, $pos, $len);
1566
+ }
1567
+
1568
+ protected function copy_until_char($char)
1569
+ {
1570
+ if ($this->char===null) return '';
1571
+
1572
+ if (($pos = strpos($this->doc, $char, $this->pos))===false) {
1573
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1574
+ $this->char = null;
1575
+ $this->pos = $this->size;
1576
+ return $ret;
1577
+ }
1578
+
1579
+ if ($pos===$this->pos) return '';
1580
+ $pos_old = $this->pos;
1581
+ $this->char = $this->doc[$pos];
1582
+ $this->pos = $pos;
1583
+ return substr($this->doc, $pos_old, $pos-$pos_old);
1584
+ }
1585
+
1586
+ protected function copy_until_char_escape($char)
1587
+ {
1588
+ if ($this->char===null) return '';
1589
+
1590
+ $start = $this->pos;
1591
+ while (1)
1592
+ {
1593
+ if (($pos = strpos($this->doc, $char, $start))===false)
1594
+ {
1595
+ $ret = substr($this->doc, $this->pos, $this->size-$this->pos);
1596
+ $this->char = null;
1597
+ $this->pos = $this->size;
1598
+ return $ret;
1599
+ }
1600
+
1601
+ if ($pos===$this->pos) return '';
1602
+
1603
+ if ($this->doc[$pos-1]==='\\') {
1604
+ $start = $pos+1;
1605
+ continue;
1606
+ }
1607
+
1608
+ $pos_old = $this->pos;
1609
+ $this->char = $this->doc[$pos];
1610
+ $this->pos = $pos;
1611
+ return substr($this->doc, $pos_old, $pos-$pos_old);
1612
+ }
1613
+ }
1614
+
1615
+ // remove noise from html content
1616
+ // save the noise in the $this->noise array.
1617
+ protected function remove_noise($pattern, $remove_tag=false)
1618
+ {
1619
+ global $debugObject;
1620
+ if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
1621
+
1622
+ $count = preg_match_all($pattern, $this->doc, $matches, PREG_SET_ORDER|PREG_OFFSET_CAPTURE);
1623
+
1624
+ for ($i=$count-1; $i>-1; --$i)
1625
+ {
1626
+ $key = '___noise___'.sprintf('% 5d', count($this->noise)+1000);
1627
+ if (is_object($debugObject)) { $debugObject->debugLog(2, 'key is: ' . $key); }
1628
+ $idx = ($remove_tag) ? 0 : 1;
1629
+ $this->noise[$key] = $matches[$i][$idx][0];
1630
+ $this->doc = substr_replace($this->doc, $key, $matches[$i][$idx][1], strlen($matches[$i][$idx][0]));
1631
+ }
1632
+
1633
+ // reset the length of content
1634
+ $this->size = strlen($this->doc);
1635
+ if ($this->size>0)
1636
+ {
1637
+ $this->char = $this->doc[0];
1638
+ }
1639
+ }
1640
+
1641
+ // restore noise to html content
1642
+ function restore_noise($text)
1643
+ {
1644
+ global $debugObject;
1645
+ if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
1646
+
1647
+ while (($pos=strpos($text, '___noise___'))!==false)
1648
+ {
1649
+ // Sometimes there is a broken piece of markup, and we don't GET the pos+11 etc... token which indicates a problem outside of us...
1650
+ if (strlen($text) > $pos+15)
1651
+ {
1652
+ $key = '___noise___'.$text[$pos+11].$text[$pos+12].$text[$pos+13].$text[$pos+14].$text[$pos+15];
1653
+ if (is_object($debugObject)) { $debugObject->debugLog(2, 'located key of: ' . $key); }
1654
+
1655
+ if (isset($this->noise[$key]))
1656
+ {
1657
+ $text = substr($text, 0, $pos).$this->noise[$key].substr($text, $pos+16);
1658
+ }
1659
+ else
1660
+ {
1661
+ // do this to prevent an infinite loop.
1662
+ $text = substr($text, 0, $pos).'UNDEFINED NOISE FOR KEY: '.$key . substr($text, $pos+16);
1663
+ }
1664
+ }
1665
+ else
1666
+ {
1667
+ // There is no valid key being given back to us... We must get rid of the ___noise___ or we will have a problem.
1668
+ $text = substr($text, 0, $pos).'NO NUMERIC NOISE KEY' . substr($text, $pos+11);
1669
+ }
1670
+ }
1671
+ return $text;
1672
+ }
1673
+
1674
+ // Sometimes we NEED one of the noise elements.
1675
+ function search_noise($text)
1676
+ {
1677
+ global $debugObject;
1678
+ if (is_object($debugObject)) { $debugObject->debugLogEntry(1); }
1679
+
1680
+ foreach($this->noise as $noiseElement)
1681
+ {
1682
+ if (strpos($noiseElement, $text)!==false)
1683
+ {
1684
+ return $noiseElement;
1685
+ }
1686
+ }
1687
+ }
1688
+ function __toString()
1689
+ {
1690
+ return $this->root->innertext();
1691
+ }
1692
+
1693
+ function __get($name)
1694
+ {
1695
+ switch ($name)
1696
+ {
1697
+ case 'outertext':
1698
+ return $this->root->innertext();
1699
+ case 'innertext':
1700
+ return $this->root->innertext();
1701
+ case 'plaintext':
1702
+ return $this->root->text();
1703
+ case 'charset':
1704
+ return $this->_charset;
1705
+ case 'target_charset':
1706
+ return $this->_target_charset;
1707
+ }
1708
+ }
1709
+
1710
+ // camel naming conventions
1711
+ function childNodes($idx=-1) {return $this->root->childNodes($idx);}
1712
+ function firstChild() {return $this->root->first_child();}
1713
+ function lastChild() {return $this->root->last_child();}
1714
+ function createElement($name, $value=null) {return @str_get_html("<$name>$value</$name>")->first_child();}
1715
+ function createTextNode($value) {return @end(str_get_html($value)->nodes);}
1716
+ function getElementById($id) {return $this->find("#$id", 0);}
1717
+ function getElementsById($id, $idx=null) {return $this->find("#$id", $idx);}
1718
+ function getElementByTagName($name) {return $this->find($name, 0);}
1719
+ function getElementsByTagName($name, $idx=-1) {return $this->find($name, $idx);}
1720
+ function loadFile() {$args = func_get_args();$this->load_file($args);}
1721
+ }
1722
+ }
1723
+ ?>
weglot.php ADDED
@@ -0,0 +1,758 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Weglot
4
+ * @version 1.4.3
5
+ */
6
+
7
+ /*
8
+ Plugin Name: Weglot Translate
9
+ Plugin URI: http://wordpress.org/plugins/Weglot/
10
+ Description: Translate your website site into multiple languages in minutes without doing any code. Totally SEO compatible.
11
+ Author: Remy B
12
+ Text Domain: weglot
13
+ Domain Path: /languages/
14
+ Version: 1.4.3
15
+ */
16
+
17
+ /* Copyright 2015 Remy Berda (email : remy@weglot.com)
18
+
19
+ This program is free software; you can redistribute it and/or modify
20
+ it under the terms of the GNU General Public License, version 2, as
21
+ published by the Free Software Foundation.
22
+
23
+ This program is distributed in the hope that it will be useful,
24
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+ GNU General Public License for more details.
27
+
28
+ You should have received a copy of the GNU General Public License
29
+ along with this program; if not, write to the Free Software
30
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
+ */
32
+
33
+ /**
34
+ * Exit if absolute path
35
+ */
36
+ if ( ! defined( 'ABSPATH' ) ) exit;
37
+
38
+ //define( 'WP_DEBUG', true );
39
+ //define( 'WP_DEBUG_LOG', true );
40
+
41
+
42
+ define('WEGLOT_VERSION', '1.4.3');
43
+ define('WEGLOT_DIR', dirname(__FILE__));
44
+ define('WEGLOT_BNAME', plugin_basename(__FILE__));
45
+ define('WEGLOT_DIRURL', plugin_dir_url( __FILE__ ));
46
+ define('WEGLOT_INC', WEGLOT_DIR.'/includes');
47
+ define('WEGLOT_RESURL', WEGLOT_DIRURL.'resources/');
48
+
49
+
50
+ /* Load our files. Could do an autoloader here but for now, there is only 4 files so... */
51
+ require WEGLOT_DIR.'/WeglotPHPClient/weglot.php';
52
+ require WEGLOT_DIR.'/simple_html_dom.php';
53
+ require WEGLOT_DIR.'/WGUtils.php';
54
+ require WEGLOT_DIR.'/WeglotWidget.php';
55
+
56
+ /* Singleton class Weglot */
57
+ class Weglot {
58
+
59
+ private $original_l;
60
+ private $destination_l;
61
+
62
+ private $request_uri;
63
+ private $home_dir;
64
+ private $currentlang;
65
+ private $allowed;
66
+ private $userInfo;
67
+ private $translator;
68
+
69
+ /*
70
+ * constructor
71
+ *
72
+ * @since 0.1
73
+ */
74
+ private function __construct() {
75
+
76
+ register_activation_hook( __FILE__, array(&$this, 'plugin_activate') );
77
+ register_deactivation_hook( __FILE__, array(&$this, 'plugin_deactivate') );
78
+ register_uninstall_hook( __FILE__, array('Weglot', 'plugin_uninstall') );
79
+
80
+ if (version_compare(phpversion(), '5.3.0', '<')) {
81
+ add_action( 'admin_notices', array(&$this, 'wg_admin_notice2'),0);
82
+ return;
83
+ }
84
+
85
+ if(function_exists('apache_get_modules') && !in_array('mod_rewrite', apache_get_modules())) {
86
+ add_action( 'admin_notices', array(&$this, 'wg_admin_notice3'),0);
87
+ return;
88
+ }
89
+
90
+
91
+
92
+ add_action('plugins_loaded', array(&$this, 'wg_load_textdomain'));
93
+ add_action('init', array(&$this, 'init_function'),11);
94
+ add_action('wp_head',array(&$this, 'add_alternate'));
95
+ add_action('wp', array(&$this, 'rr_404_my_event') );
96
+ add_shortcode('weglot_switcher', array(&$this, 'wg_switcher_creation'));
97
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this,'wg_plugin_action_links') );
98
+
99
+ $this->original_l = get_option("original_l");
100
+ $this->destination_l = get_option("destination_l");
101
+
102
+ $this->home_dir = $this->getHomeDirectory();
103
+ $this->request_uri = $this->getRequestUri($this->home_dir);
104
+
105
+ $this->noredirect = false;
106
+ if (strpos($this->request_uri, '?no_lredirect=true') !== false) {
107
+ $this->noredirect = true;
108
+ $_SERVER['REQUEST_URI'] = str_replace("?no_lredirect=true","", $_SERVER['REQUEST_URI'] );
109
+ }
110
+ $this->request_uri = str_replace("?no_lredirect=true","",$this->request_uri);
111
+ $curr = $this->getLangFromUrl($this->request_uri);
112
+ $this->currentlang = $curr ? $curr:$this->original_l;
113
+
114
+ if($this->currentlang!=$this->original_l) {
115
+ $_SERVER['REQUEST_URI'] = str_replace('/'.$this->currentlang.'/','/',$_SERVER['REQUEST_URI']);
116
+ }
117
+
118
+ if(WGUtils::isLanguageRTL($this->currentlang)) {
119
+ $GLOBALS['text_direction'] = "rtl";
120
+ }
121
+ else {
122
+ $GLOBALS['text_direction'] = "ltr";
123
+ }
124
+
125
+
126
+ $apikey = get_option("project_key");
127
+ $this->translator = $apikey ? new \Weglot\Client($apikey):null;
128
+ $this->allowed = $apikey ? get_option("wg_allowed"):true;
129
+
130
+ if (is_admin()) {
131
+ if(strpos($this->request_uri, 'page=Weglot') !== false) {
132
+ if($this->translator) {
133
+ try {
134
+ $this->userInfo = $this->translator->getUserInfo();
135
+ if($this->userInfo) {
136
+ $this->allowed = $this->userInfo['allowed'];
137
+ update_option('wg_allowed',$this->allowed?1:0);
138
+ }
139
+ }
140
+ catch(\Exception $e) {
141
+
142
+ }
143
+ }
144
+
145
+ }
146
+ elseif($this->allowed==0) {
147
+ add_action( 'admin_notices', array(&$this, 'wg_admin_notice1'),0);
148
+ }
149
+ }
150
+
151
+ $urlRacine = ($this->currentlang!=$this->original_l) ? substr($this->request_uri,3) :$this->request_uri;
152
+ $isURLOK = $this->isEligibleURL($urlRacine);
153
+ if($isURLOK) {
154
+ add_action('widgets_init', array(&$this, 'addWidget'));
155
+
156
+ if(get_option("is_menu")=='on') {
157
+ add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
158
+ function your_custom_menu_item ( $items, $args ) {
159
+ $button = Weglot::Instance()->returnWidgetCode();
160
+ $items .= $button;
161
+
162
+ return $items;
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ // Get our only instance of Weglot class
169
+ public static function Instance() {
170
+ static $inst = null;
171
+ if($inst == null)
172
+ {
173
+ $inst = new Weglot();
174
+ }
175
+ return $inst;
176
+ }
177
+
178
+ public function plugin_activate() {
179
+ if (version_compare(phpversion(), '5.3.0', '<')) {
180
+ wp_die('<p>Thank you for downloading <strong>Weglot Translate</strong> !</p><p>In order to activate Weglot, you need PHP version <strong>5.3</strong> or greater. Your current version of PHP is '.phpversion().'</p><p>Please upgrade your PHP version, you can ask your host provider to do it by sending them an email.</p>','Plugin Activation Error', array( 'response'=>200, 'back_link'=>TRUE ) );
181
+ }
182
+ //$this->updateRewriteRule();
183
+ add_option('with_flags','on');
184
+ add_option('with_name','on');
185
+ add_option('is_dropdown','on');
186
+ add_option('is_fullname','off');
187
+ add_option('override_css','');
188
+ add_option('is_menu','off');
189
+ update_option('wg_allowed',1);
190
+ if(get_option('permalink_structure')=="") {
191
+ add_option('wg_old_permalink_structure_empty','on');
192
+ update_option('permalink_structure','/%year%/%monthnum%/%day%/%postname%/');
193
+ }
194
+ }
195
+
196
+ public function plugin_deactivate() {
197
+ flush_rewrite_rules();
198
+ if(get_option('wg_old_permalink_structure_empty')=="on") {
199
+ delete_option('wg_old_permalink_structure_empty');
200
+ update_option('permalink_structure','');
201
+ }
202
+ }
203
+
204
+ public function plugin_uninstall() {
205
+ flush_rewrite_rules();
206
+ delete_option('project_key');
207
+ delete_option('original_l');
208
+ delete_option('destination_l');
209
+ delete_option('show_box');
210
+ }
211
+
212
+ public function wg_load_textdomain() {
213
+ load_plugin_textdomain( 'weglot', false, dirname( WEGLOT_BNAME ) . '/languages/' );
214
+ }
215
+
216
+ public function wg_plugin_action_links( $links ) {
217
+ $links[] = '<a href="'. esc_url( get_admin_url(null, 'admin.php?page=Weglot') ) .'">'.__('Settings','weglot').'</a>';
218
+ return $links;
219
+ }
220
+
221
+ public function wg_admin_notice1() {
222
+ ?>
223
+ <div class="updated settings-error notice is-dismissible">
224
+ <p><?php _e( 'Weglot Translate is not active because you exceed the free limit. Please <a target="_blank" href="https://weglot.com/change-plan">upgrade your plan</a> if you want to keep the service running.', 'weglot' ); ?></p>
225
+ </div>
226
+ <?php
227
+ }
228
+
229
+ public function wg_admin_notice2() {
230
+ ?>
231
+ <div class="error settings-error notice is-dismissible">
232
+ <p><?php echo sprintf(__( 'Weglot Translate plugin requires at least PHP 5.3 and you have PHP %s. Please upgrade your PHP Version (you can contact your host and they will do it for you).', 'weglot' ), phpversion() ); ?></p>
233
+ </div>
234
+ <?php
235
+ }
236
+
237
+ public function wg_admin_notice3() {
238
+ ?>
239
+ <div class="error settings-error notice is-dismissible">
240
+ <p><?php _e( 'Weglot Translate: You need to activate the mod_rewrite module. You have more information here : <a target="_blank" href="https://codex.wordpress.org/Using_Permalinks">Using Permalinks</a>. If you need help, just ask us directly <a target="_blank" href="https://tawk.to/remyb">here</a>', 'weglot' ); ?></p>
241
+ </div>
242
+ <?php
243
+ }
244
+
245
+ public function wg_switcher_creation(){
246
+ $button = Weglot::Instance()->returnWidgetCode();
247
+ echo $button;
248
+ }
249
+
250
+ public function init_function() {
251
+
252
+ add_action('admin_menu', array(&$this, 'plugin_menu'));
253
+ add_action('admin_init', array(&$this, 'plugin_settings') );
254
+
255
+ $dest = explode(",",$this->destination_l);
256
+
257
+ if($this->request_uri=="/" && !$this->noredirect && !WGUtils::is_bot()) { //front_page
258
+ if(get_option("wg_auto_switch")=="on") {
259
+ /* Redirects to browser L */
260
+ $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
261
+ //exit(print_r($dest));
262
+ if(in_array($lang,$dest)) {
263
+ wp_redirect( "/$lang/" );
264
+ exit();
265
+ }
266
+ }
267
+ }
268
+
269
+ /* prevent homepage redirect in canonical.php in case of show */
270
+ $request_uri = $this->request_uri;
271
+ foreach($dest as $d) {
272
+ if($request_uri == '/'.$d.'/')
273
+ $thisL = $d;
274
+ }
275
+ $url = (isset($thisL) && $thisL!='') ? substr($request_uri,3) :$request_uri;
276
+
277
+ if($url=="/" && (isset($thisL) && $thisL!='') && 'page' == get_option('show_on_front')) {
278
+ add_action('template_redirect',array(&$this, 'kill_canonical_wg_92103'),1);
279
+ }
280
+
281
+
282
+ if(!is_admin() || (is_admin() && strpos($this->request_uri, 'page=Weglot') !== false)) {
283
+ // Add JS
284
+ wp_register_script('wp-weglot-js', WEGLOT_RESURL.'wp-weglot-js.js', false,WEGLOT_VERSION, false);
285
+ wp_enqueue_script('wp-weglot-js');
286
+
287
+ //Add CSS
288
+ wp_register_style('wp-weglot-css', WEGLOT_RESURL.'wp-weglot-css.css', false,WEGLOT_VERSION, false);
289
+ wp_enqueue_style('wp-weglot-css');
290
+
291
+ wp_add_inline_style( 'wp-weglot-css', $this->getInlineCSS() );
292
+
293
+ if(is_admin()) {
294
+ // Add Admin JS
295
+ wp_register_script('wp-weglot-admin-js', WEGLOT_RESURL.'wp-weglot-admin-js.js', array('jquery'),WEGLOT_VERSION, true);
296
+ wp_enqueue_script('wp-weglot-admin-js');
297
+
298
+ //Add Admin CSS
299
+ wp_register_style('wp-weglot-admin-css', WEGLOT_RESURL.'wp-weglot-admin-css.css', false,WEGLOT_VERSION, false);
300
+ wp_enqueue_style('wp-weglot-admin-css');
301
+
302
+ }
303
+ }
304
+
305
+ /* Putting it in init makes that buffer deeper than caching ob */
306
+ ob_start(array(&$this,'treatPage'));
307
+ }
308
+
309
+ public function add_alternate() {
310
+
311
+ if($this->destination_l!="") {
312
+
313
+ //$thisL = $this->currentlang;
314
+ $dest = explode(",",$this->destination_l);
315
+
316
+ $full_url = ($this->currentlang!=$this->original_l) ? str_replace('/'.$this->currentlang.'/','/',$this->full_url($_SERVER)):$this->full_url($_SERVER);
317
+ $output= '<link rel="alternate" hreflang="'.$this->original_l.'" href="'.$full_url.'" />'."\n";
318
+ foreach($dest as $d) {
319
+ $output.= '<link rel="alternate" hreflang="'.$d.'" href="'.$this->replaceUrl($full_url,$d).'" />'."\n";
320
+ }
321
+ echo $output;
322
+ }
323
+ }
324
+
325
+ public function getCurrentLang() {
326
+ return $this->currentlang;
327
+ }
328
+
329
+ public function rr_404_my_event() {
330
+
331
+ $request_uri = $this->request_uri;
332
+ //$thisL = $this->currentlang;
333
+ $url = ($this->currentlang!=$this->original_l) ? substr($request_uri,3) :$request_uri;
334
+
335
+ //regex logic here
336
+ $isURLOK = $this->isEligibleURL($url);
337
+ if (!$isURLOK && $this->currentlang!=$this->original_l) {
338
+ global $wp_query;
339
+ $wp_query->set_404();
340
+ status_header(404);
341
+ }
342
+ }
343
+
344
+ public function kill_canonical_wg_92103() {
345
+ add_action('redirect_canonical','__return_false');
346
+ }
347
+
348
+ public function plugin_menu() {
349
+ $hook = add_menu_page('Weglot', 'Weglot', 'administrator', 'Weglot', array(&$this, 'plugin_settings_page'), WEGLOT_DIRURL.'/images/weglot_fav_bw.png');
350
+ //add_action('load-'.$hook,array(&$this, 'updateRewriteRule'));
351
+ if(isset($_GET['settings-updated']) && $_GET['settings-updated'] && strpos($this->request_uri, 'page=Weglot') !== false)
352
+ {
353
+ //$this->updateRewriteRule();
354
+ $d = explode(",",preg_replace('/\s+/', '', trim($this->destination_l,',')));
355
+ $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");
356
+ foreach($d as $k=>$l) {
357
+ if(!in_array($l,$accepted) || $l==$this->original_l)
358
+ unset($d[$k]);
359
+ }
360
+ update_option('destination_l',implode (",",$d));
361
+ $this->destination_l = implode(",",$d);
362
+ /* Display Box */
363
+ if( !get_option( 'show_box' ) ) {
364
+ add_option('show_box','on');
365
+ } else {
366
+ //your migrate stuff here
367
+ }
368
+
369
+ if($this->userInfo['plan']<=0 || in_array($this->userInfo['plan'],array(18,19,1001,1002))) {
370
+ $d = explode(",",preg_replace('/\s+/', '', trim($this->destination_l,',')));
371
+ $this->destination_l = $d[0];
372
+ update_option('destination_l',$this->destination_l);
373
+ }
374
+ }
375
+ }
376
+
377
+ public function plugin_settings() {
378
+ register_setting( 'my-plugin-settings-group', 'project_key' );
379
+ register_setting( 'my-plugin-settings-group', 'original_l' );
380
+ register_setting( 'my-plugin-settings-group', 'destination_l' );
381
+ register_setting( 'my-plugin-settings-group', 'wg_auto_switch' );
382
+ register_setting( 'my-plugin-settings-group', 'override_css' );
383
+ register_setting( 'my-plugin-settings-group', 'flag_css' );
384
+ register_setting( 'my-plugin-settings-group', 'with_flags' );
385
+ register_setting( 'my-plugin-settings-group', 'type_flags' );
386
+ register_setting( 'my-plugin-settings-group', 'with_name' );
387
+ register_setting( 'my-plugin-settings-group', 'is_dropdown' );
388
+ register_setting( 'my-plugin-settings-group', 'is_fullname' );
389
+ register_setting( 'my-plugin-settings-group', 'is_menu' );
390
+ register_setting( 'my-plugin-settings-group', 'exclude_url' );
391
+ register_setting( 'my-plugin-settings-group', 'exclude_blocks' );
392
+ register_setting( 'my-plugin-settings-group', 'rtl_ltr_style' );
393
+ }
394
+
395
+ public function plugin_settings_page() {
396
+ include(WEGLOT_DIR.'/includes/wg-settings-page.php');
397
+ }
398
+
399
+ public function addWidget() {
400
+ return register_widget("WeglotWidget");
401
+ }
402
+
403
+ public function treatPage($final) {
404
+
405
+ $request_uri = $this->request_uri;
406
+ if(!is_admin() && strpos($request_uri,'wc-ajax') === false && $this->original_l!="" && $this->destination_l!="") {
407
+
408
+ //$final = file_get_contents(__DIR__.'/content.html'); //Testing purpose.
409
+
410
+ //Get the original request
411
+ $url = ($this->currentlang!=$this->original_l) ? substr($request_uri,3) : $request_uri;
412
+
413
+ if($this->isEligibleURL($url) && WGUtils::is_HTML($final)) {
414
+
415
+ //If a language is set, we translate the page & links.
416
+ if($this->currentlang!=$this->original_l) {
417
+ try {
418
+ $l = $this->currentlang;
419
+ $final = $this->translatePageTo($final,$l);
420
+ }
421
+ catch(\Weglot\WeglotException $e) {
422
+ $final .= "<!--Weglot error : ".$e->getMessage()."-->";
423
+ if(strpos($e->getMessage(), 'NMC') !== false) {
424
+ update_option('wg_allowed',0);
425
+ }
426
+ }
427
+ catch(\Exception $e) {
428
+ $final .= "<!--Weglot error : ".$e->getMessage()."-->";
429
+ }
430
+ }
431
+
432
+ //Place the button if we see short code
433
+ if (strpos($final,'<div id="weglot_here"></div>') !== false) {
434
+
435
+ $button = $this->returnWidgetCode();
436
+ $final = str_replace('<div id="weglot_here"></div>',$button,$final);
437
+ }
438
+ //Place the button if not in the page
439
+ if (strpos($final,'class="wgcurrent') === false) {
440
+
441
+ $button = $this->returnWidgetCode(true);
442
+ $button = WGUtils::str_lreplace('<aside data-wg-notranslate class="','<aside data-wg-notranslate class="wg-default ',$button);
443
+ $final = (strpos($final, '</body>') !== false) ? WGUtils::str_lreplace('</body>',$button.' </body>',$final):WGUtils::str_lreplace('</footer>',$button.' </footer>',$final);
444
+ }
445
+ return $final;
446
+ }
447
+ else {
448
+ return $final;
449
+ }
450
+ }
451
+ elseif((strpos($request_uri,'admin-ajax.php') !== false || strpos($request_uri,'?wc-ajax') !== false) && $this->destination_l!="" && $this->original_l!="" && isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER["HTTP_REFERER"],'admin') === false ) {
452
+
453
+ $thisL = $this->getLangFromUrl($this->URLToRelative($_SERVER["HTTP_REFERER"]));
454
+ if(isset($thisL) && $thisL!='') {
455
+ try {
456
+ if($final[0]=='{' || ($final[0]=='[' && $final[1]=='{')) {
457
+ $json = json_decode($final,true);
458
+ if(json_last_error() == JSON_ERROR_NONE) {
459
+ $jsonT = $this->translateArray($json,$thisL);
460
+ return json_encode($jsonT);
461
+ }
462
+ else {
463
+ return $final;
464
+ }
465
+ }
466
+ elseif(WGUtils::is_AJAX_HTML($final)) {
467
+ return $this->translatePageTo($final,$thisL);
468
+ }
469
+ else {
470
+ return $final;
471
+ }
472
+ }
473
+ catch(\Weglot\WeglotException $e) {
474
+ return $final;
475
+ }
476
+ catch(\Exception $e) {
477
+ return $final;
478
+ }
479
+ }
480
+ else {
481
+ return $final;
482
+ }
483
+ }
484
+ else {
485
+ return $final;
486
+ }
487
+ }
488
+
489
+ /* translation of the page */
490
+ function translateArray($array,$to) {
491
+ foreach($array as $key=>$val) {
492
+ if(is_array($val)) {
493
+ $array[$key] = $this->translateArray($val,$to);
494
+ }
495
+ else {
496
+ if(WGUtils::is_AJAX_HTML($val)) {
497
+ $array[$key] = $this->translatePageTo($val,$to);
498
+ }
499
+ }
500
+ }
501
+ return $array;
502
+ }
503
+
504
+ function translatePageTo($final,$l) {
505
+
506
+ if($this->allowed==0) {
507
+ return $final."<!--Not allowed-->";
508
+ }
509
+ $translatedPage = $this->translator->translateDomFromTo($final,$this->original_l,$l); //$page is your html page
510
+ // to do : condenser, replacer les endwidths par contient 'upload' ?
511
+
512
+ $admin_url = admin_url();
513
+
514
+ preg_match_all('/<a([^\>]+?)?href=(\"|\')([^\s\>]+?)(\"|\')([^\>]+?)?>/',$translatedPage,$out, PREG_PATTERN_ORDER);
515
+ for($i=0;$i<count($out[0]);$i++) {
516
+ $sometags = $out[1][$i];
517
+ $sometags2 = $out[5][$i];
518
+ $current_url = $out[3][$i];
519
+ $parsed_url = parse_url($current_url);
520
+ if((($current_url[0] == 'h' && $parsed_url['host']==$_SERVER['HTTP_HOST']) || ($current_url[0] =='/' && $current_url[1] !='/'))
521
+ && strpos($current_url,$admin_url) === false && strpos($current_url,'wp-login') === false && !WGUtils::endsWith($current_url,'.jpg') && !WGUtils::endsWith($current_url,'.jpeg') && !WGUtils::endsWith($current_url,'.png') && !WGUtils::endsWith($current_url,'.pdf')
522
+ && $this->isEligibleURL($current_url) && strpos($sometags,'data-wg-notranslate') === false && strpos($sometags2,'data-wg-notranslate') === false)
523
+ {
524
+ $translatedPage = preg_replace('/<a'.preg_quote($sometags,'/').'href='.preg_quote($out[2][$i].$current_url.$out[4][$i],'/').'/','<a'.$sometags.'href='.$out[2][$i].$this->replaceUrl($current_url,$l).$out[4][$i],$translatedPage);
525
+ }
526
+ }
527
+ preg_match_all('/<form([^\>]+?)?action=(\"|\')([^\s\>]+?)(\"|\')/',$translatedPage,$out, PREG_PATTERN_ORDER);
528
+ for($i=0;$i<count($out[0]);$i++) {
529
+ $sometags = $out[1][$i];
530
+ $current_url = $out[3][$i];
531
+ $parsed_url = parse_url($current_url);
532
+ if((($current_url[0] == 'h' && $parsed_url['host']==$_SERVER['HTTP_HOST']) || ($current_url[0] =='/' && $current_url[1] !='/'))
533
+ && strpos($current_url,$admin_url) === false && strpos($current_url,'wp-login') === false && !WGUtils::endsWith($current_url,'.jpg') && !WGUtils::endsWith($current_url,'.jpeg') && !WGUtils::endsWith($current_url,'.png') && !WGUtils::endsWith($current_url,'.pdf')
534
+ && $this->isEligibleURL($current_url) && strpos($sometags,'data-wg-notranslate') === false)
535
+ {
536
+ $translatedPage = preg_replace('/<form'.preg_quote($sometags,'/').'action='.preg_quote($out[2][$i].$current_url.$out[4][$i],'/').'/','<form '.$sometags.'action='.$out[2][$i].$this->replaceUrl($current_url,$l).$out[4][$i],$translatedPage);
537
+ }
538
+ }
539
+ preg_match_all('/<option (.*?)?(\"|\')((https?:\/\/|\/)[^\s\>]*?)(\"|\')(.*?)?>/',$translatedPage,$out, PREG_PATTERN_ORDER);
540
+ for($i=0;$i<count($out[0]);$i++) {
541
+ $sometags = $out[1][$i];
542
+ $current_url = $out[3][$i];
543
+ $parsed_url = parse_url($current_url);
544
+ if((($current_url[0] == 'h' && $parsed_url['host']==$_SERVER['HTTP_HOST']) || $current_url[0] =='/')
545
+ && strpos($current_url,$admin_url) === false && strpos($current_url,'wp-login') === false && !WGUtils::endsWith($current_url,'.jpg') && !WGUtils::endsWith($current_url,'.jpeg') && !WGUtils::endsWith($current_url,'.png') && !WGUtils::endsWith($current_url,'.pdf')
546
+ && $this->isEligibleURL($current_url) && strpos($sometags,'data-wg-notranslate') === false)
547
+ {
548
+ $translatedPage = preg_replace('/<option '.preg_quote($sometags,'/').preg_quote($out[2][$i].$current_url.$out[5][$i],'/').'(.*?)?>/','<option '.$sometags.$out[2][$i].$this->replaceUrl($current_url,$l).$out[5][$i].'$2>',$translatedPage);
549
+ }
550
+ }
551
+ preg_match_all('/<link rel="canonical"(.*?)?href=(\"|\')([^\s\>]+?)(\"|\')/',$translatedPage,$out, PREG_PATTERN_ORDER);
552
+ for($i=0;$i<count($out[0]);$i++) {
553
+ $sometags = $out[1][$i];
554
+ $current_url = $out[3][$i];
555
+ $parsed_url = parse_url($current_url);
556
+ if((($current_url[0] == 'h' && $parsed_url['host']==$_SERVER['HTTP_HOST']) || $current_url[0] =='/')
557
+ && strpos($current_url,$admin_url) === false && strpos($current_url,'wp-login') === false && !WGUtils::endsWith($current_url,'.jpg') && !WGUtils::endsWith($current_url,'.jpeg') && !WGUtils::endsWith($current_url,'.png') && !WGUtils::endsWith($current_url,'.pdf')
558
+ && $this->isEligibleURL($current_url) && strpos($sometags,'data-wg-notranslate') === false)
559
+ {
560
+ $translatedPage = preg_replace('/<link rel="canonical"'.preg_quote($sometags,'/').'href='.preg_quote($out[2][$i].$current_url.$out[4][$i],'/').'/','<link rel="canonical"'.$sometags.'href='.$out[2][$i].$this->replaceUrl($current_url,$l).$out[4][$i],$translatedPage);
561
+ }
562
+ }
563
+
564
+ preg_match_all('/<meta property="og:url"(.*?)?content=(\"|\')([^\s\>]+?)(\"|\')/',$translatedPage,$out, PREG_PATTERN_ORDER);
565
+ for($i=0;$i<count($out[0]);$i++) {
566
+ $sometags = $out[1][$i];
567
+ $current_url = $out[3][$i];
568
+ $parsed_url = parse_url($current_url);
569
+ if((($current_url[0] == 'h' && $parsed_url['host']==$_SERVER['HTTP_HOST']) || $current_url[0] =='/')
570
+ && strpos($current_url,$admin_url) === false && strpos($current_url,'wp-login') === false && !WGUtils::endsWith($current_url,'.jpg') && !WGUtils::endsWith($current_url,'.jpeg') && !WGUtils::endsWith($current_url,'.png') && !WGUtils::endsWith($current_url,'.pdf')
571
+ && $this->isEligibleURL($current_url) && strpos($sometags,'wg-notranslate') === false)
572
+ {
573
+ $translatedPage = preg_replace('/<meta property="og:url"'.preg_quote($sometags,'/').'content='.preg_quote($out[2][$i].$current_url.$out[4][$i],'/').'/','<meta property="og:url"'.$sometags.'content='.$out[2][$i].$this->replaceUrl($current_url,$l).$out[4][$i],$translatedPage);
574
+ }
575
+ }
576
+
577
+ $translatedPage = preg_replace('/<html (.*?)?lang=(\"|\')(\S*)(\"|\')/','<html $1lang=$2'.$l.'$4',$translatedPage);
578
+ $translatedPage = preg_replace('/property="og:locale" content=(\"|\')(\S*)(\"|\')/','property="og:locale" content=$1'.$l.'$3',$translatedPage);
579
+ return $translatedPage;
580
+ }
581
+
582
+ /* Urls functions */
583
+ public function replaceUrl($url,$l) {
584
+ $home_dir = $this->home_dir;
585
+ if($home_dir) {
586
+ $parsed_url = parse_url($url);
587
+ $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
588
+ $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
589
+ $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
590
+ $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
591
+ $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
592
+ $pass = ($user || $pass) ? "$pass@" : '';
593
+ $path = isset($parsed_url['path']) ? $parsed_url['path'] : '/';
594
+ $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
595
+ $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
596
+
597
+ if($l=='') {
598
+ return trim($home_dir, '/')."$l".$this->URLToRelative($url);
599
+ }
600
+ else {
601
+ return trim($home_dir, '/')."/$l".$this->URLToRelative($url);
602
+ }
603
+
604
+ }
605
+ else {
606
+ $parsed_url = parse_url($url);
607
+ $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : '';
608
+ $host = isset($parsed_url['host']) ? $parsed_url['host'] : '';
609
+ $port = isset($parsed_url['port']) ? ':' . $parsed_url['port'] : '';
610
+ $user = isset($parsed_url['user']) ? $parsed_url['user'] : '';
611
+ $pass = isset($parsed_url['pass']) ? ':' . $parsed_url['pass'] : '';
612
+ $pass = ($user || $pass) ? "$pass@" : '';
613
+ $path = isset($parsed_url['path']) ? $parsed_url['path'] : '/';
614
+ $query = isset($parsed_url['query']) ? '?' . $parsed_url['query'] : '';
615
+ $fragment = isset($parsed_url['fragment']) ? '#' . $parsed_url['fragment'] : '';
616
+ if($l=='') {
617
+ return $url;
618
+ }
619
+ else {
620
+ return (strlen($path)>2 && substr($path,0,4)=="/$l/") ? "$scheme$user$pass$host$port$path$query$fragment":"$scheme$user$pass$host$port/$l$path$query$fragment";
621
+ }
622
+ }
623
+ }
624
+ public function url_origin($s, $use_forwarded_host=false) {
625
+ $ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false;
626
+ $sp = strtolower($s['SERVER_PROTOCOL']);
627
+ $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
628
+ $port = $s['SERVER_PORT'];
629
+ $port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port;
630
+ $host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null);
631
+ $host = isset($host) ? $host : $s['SERVER_NAME'] . $port;
632
+ return $protocol . '://' . $host;
633
+ }
634
+ public function full_url($s, $use_forwarded_host=false) {
635
+ return $this->url_origin($s, $use_forwarded_host) . $s['REQUEST_URI'];
636
+ }
637
+ public function isEligibleURL($url) {
638
+ $url = $this->URLToRelative($url);
639
+
640
+ $exclusions = preg_replace('#\s+#',',',get_option("exclude_url"));
641
+ $exclusions = $exclusions=="" ? "/amp(/)?$":$exclusions.",/amp(/)?$";
642
+ $regex = explode(",",$exclusions);
643
+
644
+ if($exclusions!="") {
645
+ foreach($regex as $ex) {
646
+ if(preg_match('/'.str_replace('/', '\/',$ex).'/',$url)==1)
647
+ return false;
648
+ }
649
+ return true;
650
+ }
651
+ else
652
+ return true;
653
+ }
654
+ public function URLToRelative($url) {
655
+
656
+ if ((substr($url, 0, 7) == 'http://') || (substr($url, 0, 8) == 'https://')) {
657
+ // the current link is an "absolute" URL - parse it to get just the path
658
+ $parsed = parse_url($url);
659
+ $path = isset($parsed['path']) ? $parsed['path'] : '';
660
+ $query = isset($parsed['query']) ? '?' . $parsed['query'] : '';
661
+ $fragment = isset($parsed['fragment']) ? '#' . $parsed['fragment'] : '';
662
+
663
+ $home_dir = $this->home_dir;
664
+ if($home_dir) {
665
+ $relative = str_replace(trim($home_dir ,'/'),'',$url);
666
+ return ($relative=="") ? '/':$relative;
667
+ }
668
+ else {
669
+ return $path.$query.$fragment;
670
+ }
671
+ }
672
+ return $url;
673
+ }
674
+ public function getRequestUri($home_dir) {
675
+ if($home_dir) {
676
+ return str_replace(trim($home_dir,'/'),'',$this->full_url($_SERVER));
677
+ }
678
+ else {
679
+ return $_SERVER['REQUEST_URI'];
680
+ }
681
+ }
682
+ public function getLangFromUrl($request_uri) {
683
+ $l= null;
684
+ $dest = explode(",",$this->destination_l);
685
+ foreach($dest as $d) {
686
+ if(substr($request_uri,0,4) == '/'.$d.'/')
687
+ $l = $d;
688
+ }
689
+ return $l;
690
+ }
691
+
692
+ public function getHomeDirectory() {
693
+ $opt_siteurl = trim(get_option("siteurl"),'/');
694
+ $opt_home = trim(get_option("home"),'/');
695
+ if($opt_siteurl!="" && $opt_home!="" /*&& $opt_siteurl==$opt_home*/) {
696
+ if( (substr($opt_home,0,7) == "http://" && strpos(substr($opt_home,7),'/') !== false) || (substr($opt_home,0,8) == "https://" && strpos(substr($opt_home,8),'/') !== false) ) {
697
+ return $opt_home;
698
+ }
699
+ }
700
+ return null;
701
+ }
702
+
703
+ /* button function (code and CSS) */
704
+ public function getInlineCSS() {
705
+ $css= get_option("override_css");
706
+ if( (WGUtils::isLanguageRTL($this->original_l) && !WGUtils::isLanguageRTL($this->currentlang)) ||
707
+ (!WGUtils::isLanguageRTL($this->original_l) && WGUtils::isLanguageRTL($this->currentlang))) {
708
+ $css.= get_option("rtl_ltr_style");
709
+ }
710
+ if(!is_admin()) {
711
+ $css.= get_option("flag_css");
712
+ }
713
+ return $css;
714
+ }
715
+
716
+ public function returnWidgetCode($forceNoMenu = false) {
717
+ $original = $this->original_l;
718
+ $request_uri = $this->request_uri;
719
+
720
+ $url = ($this->currentlang!=$this->original_l) ? substr($request_uri,3) : $request_uri;
721
+
722
+ $full = get_option("is_fullname")=='on';
723
+ $withname = get_option("with_name")=='on';
724
+ $is_dropdown = get_option("is_dropdown")=='on';
725
+ $is_menu = $forceNoMenu ? false:get_option("is_menu")=='on';
726
+ $flag_class = (get_option("with_flags")=='on') ? 'wg-flags ':'';
727
+
728
+ $type_flags = get_option("type_flags") ? get_option("type_flags"):0;
729
+ $flag_class .= $type_flags==0 ? '':'flag-'.$type_flags.' ';
730
+
731
+ $current = $this->currentlang;
732
+ $list = $is_dropdown ? "<ul>":"";
733
+ $destEx = explode(",",$this->destination_l);
734
+ array_unshift($destEx,$original);
735
+ foreach($destEx as $d) {
736
+ if($d!=$current) {
737
+ $link = (($d!=$original) ? $this->replaceUrl($url,$d):$this->replaceUrl($url,''));
738
+ if($link=="/" && get_option("wg_auto_switch")=="on")
739
+ $link = $link."?no_lredirect=true";
740
+ $list .= '<li class="wg-li '.$flag_class.$d.'"><a data-wg-notranslate href="'.$link.'">'.($withname ? ($full? WGUtils::getLangNameFromCode($d,false):strtoupper($d)):"").'</a></li>';
741
+ }
742
+ }
743
+ $list .= $is_dropdown ? "</ul>":"";
744
+ $tag = $is_dropdown ? "div":"li";
745
+
746
+ $moreclass = (get_option("is_dropdown")=='on') ? 'wg-drop ':'wg-list ';
747
+
748
+ $aside1 = ($is_menu && !$is_dropdown) ? '':'<aside data-wg-notranslate class="'.$moreclass.'country-selector closed" onclick="openClose(this);" >';
749
+ $aside2 = ($is_menu && !$is_dropdown) ? '':'</aside>';
750
+
751
+ $button = '<!--Weglot '.WEGLOT_VERSION.'-->'.$aside1.'<'.$tag.' data-wg-notranslate class="wgcurrent wg-li '.$flag_class.$current.'"><a href="javascript:void(0);" >'.($withname ? ($full? WGUtils::getLangNameFromCode($current,false):strtoupper($current)):"").'</a></'.$tag.'>'.$list.$aside2;
752
+
753
+ return $button;
754
+ }
755
+ }
756
+
757
+ add_action( 'plugins_loaded', array ( 'Weglot', 'Instance' ), 10 );
758
+ //Weglot::Instance();