qTranslate X - Version 2.8

Version Description

  • added option "Show displayed language prefix when content is not available for the selected language".
  • compatibility with "BuddyPress" plugin and various improvements.
  • custom CSS for "qTranslate Language Chooser" widget configurable via its properties.
  • now always redirects to a canonical URL, as defined by options, before displaying a page.
  • use of cookies to carry the language chosen from session to session.
Download this release

Release Info

Developer johnclause
Plugin Icon wp plugin qTranslate X
Version 2.8
Comparing to
See all releases

Code changes from version 2.9.2 to 2.8

admin/xhaleera_addons.php DELETED
@@ -1,356 +0,0 @@
1
- <?php // encoding: utf-8
2
- /*
3
- Copyright 2014 qTranslate Team (email : qTranslateTeam@gmail.com )
4
-
5
- This program is free software; you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation; either version 2 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License
16
- along with this program; if not, write to the Free Software
17
- Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
- */
19
-
20
- function mqtrans_import_settings_from_qtrans() {
21
- global $wpdb;
22
-
23
- $option_names = $wpdb->get_col("SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE 'qtranslate\_%'");
24
- foreach ($option_names as $name)
25
- {
26
- $opt = get_option($name);
27
-
28
- $nn = "m{$name}";
29
- if ( false !== get_option($nn) )
30
- update_option($nn, $opt);
31
- else
32
- add_option($nn, $opt);
33
- }
34
- }
35
-
36
- function mqtrans_export_setting_to_qtrans($updateOnly = false) {
37
- global $wpdb;
38
-
39
- $option_names = $wpdb->get_col("SELECT `option_name` FROM {$wpdb->options} WHERE `option_name` LIKE 'mqtranslate\_%'");
40
- foreach ($option_names as $name)
41
- {
42
- $opt = get_option($name);
43
-
44
- $nn = substr($name, 1);
45
- if ( false !== get_option($nn) )
46
- update_option($nn, $opt);
47
- else if (!$updateOnly)
48
- add_option($nn, $opt);
49
- }
50
- }
51
-
52
- function mqtrans_currentUserCanEdit($lang) {
53
- global $q_config;
54
-
55
- $cu = wp_get_current_user();
56
- if ($cu->has_cap('edit_users') || empty($q_config['ul_lang_protection']))
57
- return true;
58
- else
59
- {
60
- $user_meta = get_user_meta($cu->ID);
61
- if (empty($user_meta) || !is_array($user_meta) || !array_key_exists('mqtranslate_language_access', $user_meta))
62
- $user_langs = $q_config['enabled_languages'];
63
- else
64
- $user_langs = explode(',', get_user_meta($cu->ID, 'mqtranslate_language_access', true));
65
- return in_array($lang, $user_langs);
66
- }
67
- }
68
-
69
- function mqtrans_currentUserCanView($lang) {
70
- global $q_config;
71
-
72
- $cu = wp_get_current_user();
73
- if ($cu->has_cap('edit_users') || empty($q_config['ul_lang_protection']))
74
- return true;
75
- else
76
- {
77
- $master_lang = get_user_meta($cu->ID, 'mqtranslate_master_language', true);
78
- if (empty($master_lang))
79
- return ($lang === $q_config['default_language']);
80
- else
81
- return ($lang === $master_lang || $lang === $q_config['default_language']);
82
- }
83
- }
84
-
85
- function mqtrans_userProfile($user) {
86
- global $q_config;
87
-
88
- if (empty($q_config['ul_lang_protection']))
89
- return;
90
-
91
- $cu = wp_get_current_user();
92
- $langs = qtrans_getSortedLanguages();
93
-
94
- echo '<h3>'.__('mqTranslate User Language Settings', 'mqtranslate') . "</h3>\n";
95
- echo "<table class=\"form-table\">\n<tbody>\n";
96
-
97
- // Editable languages
98
- $user_meta = get_user_meta($user->ID);
99
- if (empty($user_meta) || !is_array($user_meta) || !array_key_exists('mqtranslate_language_access', $user_meta))
100
- $user_langs = $q_config['enabled_languages'];
101
- else
102
- $user_langs = explode(',', get_user_meta($user->ID, 'mqtranslate_language_access', true));
103
- echo "<tr>\n";
104
- if ($cu->ID == $user->ID)
105
- echo '<th>'.__('You can edit posts in', 'mqtranslate') . "</th>\n";
106
- else
107
- echo '<th>'.__('This user can edit posts in', 'mqtranslate') . "</th>\n";
108
- echo "<td>";
109
- if ($user->has_cap('edit_users'))
110
- {
111
- if (empty($langs))
112
- _e('No language available', 'mqtranslate');
113
- else if ($cu->ID == $user->ID)
114
- _e('As an Administrator, you can edit posts in all languages.', 'mqtranslate');
115
- else
116
- _e('As an Administrator, this user can edit posts in all languages.', 'mqtranslate');
117
- }
118
- else if ($cu->has_cap('edit_users'))
119
- {
120
- if (empty($langs))
121
- _e('No language available', 'mqtranslate')."\n";
122
- else
123
- {
124
- $checkboxes = array();
125
- foreach ($langs as $l) {
126
- $name = "mqtrans_user_lang_{$l}";
127
- $checked = (in_array($l, $user_langs)) ? 'checked' : '';
128
- $checkboxes[] = "<label for=\"{$name}\"><input type=\"checkbox\" name=\"mqtrans_user_lang[]\" id=\"{$name}\" value=\"{$l}\" {$checked} /> {$q_config['language_name'][$l]}</label>\n";
129
- }
130
- echo implode("<br />\n", $checkboxes);
131
- }
132
- }
133
- else
134
- {
135
- $intersect = array_intersect($langs, $user_langs);
136
- if (empty($intersect))
137
- _e('No language selected', 'mqtranslate')."\n";
138
- else
139
- {
140
- $languages = array();
141
- foreach ($intersect as $l)
142
- $languages[] = $q_config['language_name'][$l];
143
- echo implode(', ', $languages);
144
- }
145
- }
146
- echo "</td>\n";
147
- echo "</tr>\n";
148
-
149
- // Master language
150
- $user_master_lang = get_user_meta($user->ID, 'mqtranslate_master_language', true);
151
- echo "<tr>\n";
152
- echo '<th>' . __('Master language', 'mqtranslate') . "</th>\n";
153
- echo "<td>\n";
154
- if ($user->has_cap('edit_users'))
155
- _e('Not applicable to Administrators', 'mqtranslate');
156
- else if ($cu->has_cap('edit_users'))
157
- {
158
- echo "<select name=\"mqtrans_master_lang\">\n";
159
- echo '<option value="">' . __('Default Language', 'mqtranslate') . "</option>\n";
160
- foreach ($langs as $l)
161
- {
162
- if ($l == $q_config['default_language'])
163
- continue;
164
- $selected = ($user_master_lang == $l) ? ' selected' : '';
165
- echo "<option value=\"{$l}\"{$selected}>{$q_config['language_name'][$l]}</option>\n";
166
- }
167
- echo "</select>\n";
168
- echo '<span class="description">' . __('Language from which texts should be translated by this user', 'mqtranslate') . "</span>\n";
169
- }
170
- else
171
- {
172
- if (empty($langs) || empty($user_master_lang) || !in_array($user_master_lang, $langs))
173
- _e('Default Language', 'mqtranslate');
174
- else
175
- echo $q_config['language_name'][$user_master_lang];
176
- }
177
- echo "</td>\n";
178
- echo "</tr>\n";
179
-
180
- echo "</tbody>\n</table>\n";
181
- }
182
-
183
- function mqtrans_userProfileUpdate($user_id) {
184
- global $q_config;
185
- $cu = wp_get_current_user();
186
- if ($cu->has_cap('edit_users') && !empty($q_config['ul_lang_protection'])) {
187
- // Editable languages
188
- $langs = (empty($_POST['mqtrans_user_lang'])) ? array() : $_POST['mqtrans_user_lang'];
189
- if (!is_array($langs))
190
- $langs = array();
191
- update_user_meta($user_id, 'mqtranslate_language_access', implode(',', $langs));
192
-
193
- // Master language
194
- if (empty($_POST['mqtrans_master_lang']))
195
- delete_user_meta($user_id, 'mqtranslate_master_language');
196
- else
197
- update_user_meta($user_id, 'mqtranslate_master_language', $_POST['mqtrans_master_lang']);
198
- }
199
- }
200
-
201
- function qtrans_isEmptyContent($value) {
202
- $str = trim(strip_tags($value, '<img>,<embed>,<object>'));
203
- return empty($str);
204
- }
205
-
206
- function mqtrans_postUpdated($post_ID, $after, $before) {
207
- global $wpdb, $q_config;
208
-
209
- // Don't handle custom post types
210
- if (!in_array($after->post_type, array( 'post', 'page' )) && !in_array($after->post_type, $q_config['allowed_custom_post_types']))
211
- return;
212
-
213
- $titleMap = array();
214
- $contentMap = array();
215
-
216
- $cu = wp_get_current_user();
217
- if ($cu->has_cap('edit_users') || empty($q_config['ul_lang_protection']))
218
- {
219
- $title = qtrans_split($after->post_title, true, $titleMap);
220
- foreach ($title as $k => $v) {
221
- if (qtrans_isEmptyContent($v))
222
- unset($title[$k]);
223
- }
224
- $content = qtrans_split($after->post_content, true, $contentMap);
225
- foreach ($content as $k => $v) {
226
- if (qtrans_isEmptyContent($v))
227
- unset($content[$k]);
228
- }
229
- }
230
- else
231
- {
232
- $titleBeforeMap = array();
233
- $titleBefore = qtrans_split($before->post_title, true, $titleBeforeMap);
234
- $titleAfter = qtrans_split($after->post_title, true, $titleMap);
235
- foreach ($titleAfter as $k => $v) {
236
- if (!mqtrans_currentUserCanEdit($k))
237
- unset($titleAfter[$k], $titleMap[$k]);
238
- }
239
- $title = array_merge($titleBefore, $titleAfter);
240
- $titleMap = array_merge($titleBeforeMap, $titleMap);
241
-
242
- $contentBeforeMap = array();
243
- $contentBefore = qtrans_split($before->post_content, true, $contentBeforeMap);
244
- $contentAfter = qtrans_split($after->post_content, true, $contentMap);
245
- foreach ($contentAfter as $k => $v) {
246
- if (qtrans_isEmptyContent($v) || !mqtrans_currentUserCanEdit($k))
247
- unset($contentAfter[$k], $contentMap[$k]);
248
- }
249
- $content = array_merge($contentBefore, $contentAfter);
250
- $contentMap = array_merge($contentBeforeMap, $contentMap);
251
- }
252
-
253
- $data = array('post_title' => qtrans_join($title, $titleMap), 'post_content' => qtrans_join($content, $contentMap));
254
- if (get_magic_quotes_gpc())
255
- $data = stripslashes_deep($data);
256
- $where = array('ID' => $post_ID);
257
-
258
- $wpdb->update($wpdb->posts, $data, $where);
259
- }
260
-
261
- function mqtrans_filterHomeURL($url, $path, $orig_scheme, $blog_id) {
262
- global $q_config;
263
- return ((empty($path) && $q_config['url_mode'] == QT_URL_PATH) || $path == '/' || !empty($q_config['url_info']['explicit_default_language'])) ? qtrans_convertURL($url, '', false, $q_config['url_info']['explicit_default_language']) : $url;
264
- }
265
-
266
- function mqtrans_filterPostMetaData($original_value, $object_id, $meta_key, $single) {
267
- if ($meta_key == '_menu_item_url')
268
- {
269
- $meta = wp_cache_get($object_id, 'post_meta');
270
- if (!empty($meta) && array_key_exists($meta_key, $meta) && !empty($meta[$meta_key]))
271
- {
272
- if ($single === false)
273
- {
274
- if (is_array($meta[$meta_key]))
275
- $meta = $meta[$meta_key];
276
- else
277
- $meta = array($meta[$meta_key]);
278
- $meta = array_map('qtrans_convertURL', $meta);
279
- }
280
- else
281
- {
282
- if (is_array($meta[$meta_key]))
283
- $meta = $meta[$meta_key][0];
284
- else
285
- $meta = $meta[$meta_key];
286
- $meta = qtrans_convertURL($meta);
287
- }
288
- return $meta;
289
- }
290
- }
291
- return null;
292
- }
293
-
294
- function mqtrans_team_options() {
295
- global $q_config;
296
- ?>
297
- <h3><?php _e('mqTranslate Team Settings', 'mqtranslate') ?><span id="mqtranslate-show-team"> (<a name="mqtranslate_team_settings" href="#" onclick="return showTeamSettings();"><?php _e('Show / Hide', 'mqtranslate'); ?></a>)</span></h3>
298
- <table class="form-table" id="mqtranslate-team" style="display: none">
299
- <tr>
300
- <th scope="row"><?php _e('User-level Language Protection', 'mqtranslate') ?></th>
301
- <td>
302
- <label for="ul_lang_protection"><input type="checkbox" name="ul_lang_protection" id="ul_lang_protection" value="1"<?php echo ($q_config['ul_lang_protection'])?' checked="checked"':''; ?>/> <?php _e('Enable user-level language protection', 'mqtranslate'); ?></label>
303
- <br />
304
- <small><?php _e('When enabled, this option allows you to select which language is editable on a user-level account basis.', 'mqtranslate') ?></small>
305
- </td>
306
- </tr>
307
- </table>
308
- <script type="text/javascript">
309
- // <![CDATA[
310
- function showTeamSettings() {
311
- var el = document.getElementById('mqtranslate-team');
312
- if (el.style.display == 'block')
313
- el.style.display = 'none';
314
- else
315
- el.style.display='block';
316
- return false;
317
- }
318
- // ]]>
319
- </script>
320
- <?php
321
- }
322
-
323
- function mqtrans_load_team_options() {
324
- global $q_config;
325
- $opt = get_option('mqtranslate_ul_lang_protection');
326
- if ($opt === false)
327
- $q_config['ul_lang_protection'] = true;
328
- else
329
- $q_config['ul_lang_protection'] = ($opt == '1');
330
- }
331
-
332
- function mqtrans_save_team_options() {
333
- qtrans_checkSetting('ul_lang_protection', true, QT_BOOLEAN);
334
- }
335
-
336
- function mqtrans_editorExpand() {
337
- return false;
338
- }
339
-
340
- if (!defined('WP_ADMIN'))
341
- {
342
- add_filter('home_url', 'mqtrans_filterHomeURL', 10, 4);
343
- add_filter('get_post_metadata', 'mqtrans_filterPostMetaData', 10, 4);
344
- }
345
- else
346
- add_filter('wp_editor_expand', 'mqtrans_editorExpand');
347
-
348
- add_action('edit_user_profile', 'mqtrans_userProfile');
349
- add_action('show_user_profile', 'mqtrans_userProfile');
350
- add_action('profile_update', 'mqtrans_userProfileUpdate');
351
- add_action('post_updated', 'mqtrans_postUpdated', 10, 3);
352
-
353
- add_action('mqtranslate_configuration', 'mqtrans_team_options', 9);
354
- add_action('mqtranslate_loadConfig', 'mqtrans_load_team_options');
355
- add_action('mqtranslate_saveConfig', 'mqtrans_save_team_options');
356
- ?>
lang/qtranslate-sr_RS.mo DELETED
Binary file
qtranslate.js CHANGED
@@ -1,4 +1,4 @@
1
- /* this is the developer version of qtranslate.min.js before it is minimized */
2
/*
3
//debuging tools, do not check in
4
var cc=0;
@@ -9,67 +9,7 @@ function ct(v){ c(v); console.trace(); }
9
qtranxj_split = function(text)
10
{
11
var result = new Object;
12
- for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
13
- {
14
- var lang=qTranslateConfig.enabled_languages[i];
15
- result[lang] = '';
16
- }
17
- var split_regex_c = /<!--:-->/gi;
18
- var blocks = text.xsplit(split_regex_c);
19
- //c('qtranxj_split: blocks='+blocks);
20
- //c('qtranxj_split: blocks.length='+blocks.length);
21
- if(!qtranxj_isArray(blocks))
22
- return result;
23
- var matches, lang_regex, lang;
24
- if(blocks.length>1){//there are matches
25
- lang_regex = /<!--:([a-z]{2})-->/gi;
26
- for(var i = 0;i<blocks.length;++i){
27
- var b=blocks[i];
28
- //c('blocks['+i+']='+b);
29
- if(!b.length) continue;
30
- matches = lang_regex.exec(b); lang_regex.lastIndex=0;
31
- //c('matches='+matches);
32
- if(matches==null) continue;
33
- lang = matches[1];
34
- result[lang] += b.substring(10);
35
- //c('text='+result[lang]);
36
- }
37
- }else{
38
- var split_regex_b = /(\[:[a-z]{2}\])/gi;
39
- blocks = text.xsplit(split_regex_b);
40
- if(!qtranxj_isArray(blocks))
41
- return result;
42
- if(blocks.length==1){//no language separator found, enter it to all languages
43
- var b=blocks[0];
44
- for(var j=0; j<qTranslateConfig.enabled_languages.length; ++j){
45
- var lang=qTranslateConfig.enabled_languages[j];
46
- result[lang] += b;
47
- }
48
- }else{
49
- lang_regex = /\[:([a-z]{2})\]/gi;
50
- lang = false;
51
- for(var i = 0;i<blocks.length;++i){
52
- var b=blocks[i];
53
- //c('blocks['+i+']='+b+'; lang='+lang);
54
- if(lang){
55
- result[lang] += b;
56
- lang = false;
57
- }else{
58
- matches = lang_regex.exec(b); lang_regex.lastIndex=0;
59
- if(matches==null) continue;
60
- lang = matches[1];
61
- }
62
- }
63
- }
64
- }
65
- return result;
66
- }
67
-
68
- /*
69
- qtranxj_split = function(text)
70
- {
71
- var result = new Object;
72
- for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
73
{
74
var lang=qTranslateConfig.enabled_languages[i];
75
result[lang] = '';
@@ -100,7 +40,7 @@ qtranxj_split = function(text)
100
}else{
101
var matches;
102
var lang = false;
103
- for(var i = 0;i<blocks.length;++i){
104
var b=blocks[i];
105
//c('blocks['+i+']='+b);
106
if(!b.length) continue;
@@ -115,17 +55,17 @@ qtranxj_split = function(text)
115
}
116
}
117
var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+#x2F;gi;
118
- for(var i = 0;i<result.length;++i){
119
result[i] = result[i].replace(morenextpage_regex,'');
120
}
121
return result;
122
}
123
- */
124
//"_c" stands for "comment"
125
qtranxj_join_c = function(texts)
126
{
127
var text = '';
128
- for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
129
{
130
var lang=qTranslateConfig.enabled_languages[i];
131
var t = texts[lang];
@@ -141,7 +81,7 @@ qtranxj_join_c = function(texts)
141
qtranxj_join_b = function(texts)
142
{
143
var text = '';
144
- for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
145
{
146
var lang=qTranslateConfig.enabled_languages[i];
147
var t = texts[lang];
@@ -156,8 +96,7 @@ function qtranxj_get_cookie(cname)
156
{
157
var nm = cname + "=";
158
var ca = document.cookie.split(';');
159
- //c('ca='+ca);
160
- for(var i=0; i<ca.length; ++i){
161
var s = ca[i];
162
var sa = s.split('=');
163
if(sa[0].trim()!=cname) continue;
@@ -225,7 +164,7 @@ var qTranslateX=function()
225
{
226
function ge(id){ return document.getElementById(id); }
227
228
- var activeLanguage=qtranxj_get_cookie('wp_qtrans_edit_language');
229
if(!activeLanguage)
230
activeLanguage=qTranslateConfig.language;
231
@@ -234,9 +173,8 @@ var qTranslateX=function()
234
{
235
var h=contentHooks[id];
236
var lang=languageSwitch.getActiveLanguage();
237
- //var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+#x2F;gi;
238
- //h.contents[lang]=value.replace(morenextpage_regex,'');
239
- h.contents[lang]=value;
240
if(h.separator==='<'){
241
h.mlContentField.value = qtranxj_join_c(h.contents);
242
}else{
@@ -293,6 +231,8 @@ var qTranslateX=function()
293
return false;
294
}
295
296
var adminLanguage=qTranslateConfig.language;
297
298
build_translator=function(langF,langT)
@@ -323,7 +263,7 @@ var qTranslateX=function()
323
var tr=rows[r];
324
var td=tr.getElementsByTagName('TD')[0];
325
var items=td.getElementsByClassName('inline');
326
- for(var i=0; i<items.length; ++i)
327
{
328
var e=items[i];
329
e.style.display='none';
@@ -358,7 +298,7 @@ var qTranslateX=function()
358
var nmF = nms[langF]||'';
359
var nmT = nms[langT]||'';
360
var items=td.getElementsByClassName('row-title');
361
- for(var i=0; i<items.length; ++i)
362
{
363
var e=items[i];
364
if(nmF)
@@ -376,7 +316,7 @@ var qTranslateX=function()
376
var items=tagCloud.getElementsByTagName('A');
377
if(!items.length) return;
378
var translator=build_translator(langF,langT);
379
- for(var i=0; i<items.length; ++i)
380
{
381
var e=items[i];
382
var nmF=e.innerHTML;
@@ -412,7 +352,7 @@ var qTranslateX=function()
412
413
var editinlines=document.getElementsByClassName('editinline');
414
//c('editinlines.length='+editinlines.length);
415
- for(var i=0; i<editinlines.length; ++i)
416
{
417
var e=editinlines[i];
418
if(e.tagName!=='A') continue;
@@ -429,7 +369,7 @@ var qTranslateX=function()
429
430
var langs=qTranslateConfig.enabled_languages;
431
var newNameFields={};
432
- for(var i=0; i<langs.length; ++i)
433
{
434
var lang=langs[i];
435
newNameFields[lang]=qtranxj_ce('input', {name: 'qtranx_term_'+lang, className: 'hidden', value: name[lang] || ''}, form, true);
@@ -477,20 +417,6 @@ var qTranslateX=function()
477
addContentHook(f,form,sep);
478
}
479
480
- for(var i=0; i<qTranslateConfig.custom_field_classes.length; ++i){
481
- var nm=qTranslateConfig.custom_field_classes[i];
482
- var sep;
483
- if(nm.indexOf('<')==0 || nm.indexOf('[')==0){
484
- sep=nm.substring(0,1);
485
- nm=nm.substring(1);
486
- }
487
- var fields=form.getElementsByClassName(nm);
488
- for(var j=0; j<fields.length; ++j){
489
- f=fields[j];
490
- addContentHook(f,form,sep);
491
- }
492
- }
493
-
494
var alttextField=ge('attachment_alt');
495
if(alttextField) addContentHookB(alttextField,form);
496
@@ -638,7 +564,7 @@ var qTranslateX=function()
638
639
setLangCookie=function()
640
{
641
- document.cookie='wp_qtrans_edit_language='+this.lang;
642
}
643
644
var matches = location.pathname.match(/(\/wp-admin\/([^\/]*))#x2F;);
@@ -692,13 +618,13 @@ function LanguageSwitch(target,initial_language)
692
}
693
activeLanguage=tabSwitch.lang;
694
tabSwitch.classList.add('active');
695
- for(var i=0; i<onTabSwitch.length; ++i)
696
{
697
onTabSwitch[i].call(this);
698
}
699
}
700
location.pathname.indexOf();
701
- for(var i=0; i<langs.length; ++i)
702
{
703
//var flags_location=qTranslateConfig.WP_CONTENT_URL+qTranslateConfig.flag_location;
704
var flag_location=qTranslateConfig.flag_location;
1
+ /* this is a developer version of qtranslate.min.js before it is minimized */
2
/*
3
//debuging tools, do not check in
4
var cc=0;
9
qtranxj_split = function(text)
10
{
11
var result = new Object;
12
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; i++)
13
{
14
var lang=qTranslateConfig.enabled_languages[i];
15
result[lang] = '';
40
}else{
41
var matches;
42
var lang = false;
43
+ for(var i = 0;i<blocks.length;i++){
44
var b=blocks[i];
45
//c('blocks['+i+']='+b);
46
if(!b.length) continue;
55
}
56
}
57
var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+#x2F;gi;
58
+ for(var i = 0;i<result.length;i++){
59
result[i] = result[i].replace(morenextpage_regex,'');
60
}
61
return result;
62
}
63
+
64
//"_c" stands for "comment"
65
qtranxj_join_c = function(texts)
66
{
67
var text = '';
68
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; i++)
69
{
70
var lang=qTranslateConfig.enabled_languages[i];
71
var t = texts[lang];
81
qtranxj_join_b = function(texts)
82
{
83
var text = '';
84
+ for(var i=0; i<qTranslateConfig.enabled_languages.length; i++)
85
{
86
var lang=qTranslateConfig.enabled_languages[i];
87
var t = texts[lang];
96
{
97
var nm = cname + "=";
98
var ca = document.cookie.split(';');
99
+ for(var i=0; i<ca.length; i++){
100
var s = ca[i];
101
var sa = s.split('=');
102
if(sa[0].trim()!=cname) continue;
164
{
165
function ge(id){ return document.getElementById(id); }
166
167
+ var activeLanguage=qtranxj_get_cookie('qtrans_edit_language');
168
if(!activeLanguage)
169
activeLanguage=qTranslateConfig.language;
170
173
{
174
var h=contentHooks[id];
175
var lang=languageSwitch.getActiveLanguage();
176
+ var morenextpage_regex = /(<!--more-->|<!--nextpage-->)+#x2F;gi;
177
+ h.contents[lang]=value.replace(morenextpage_regex,'');;
178
if(h.separator==='<'){
179
h.mlContentField.value = qtranxj_join_c(h.contents);
180
}else{
231
return false;
232
}
233
234
+ //var adminLanguage=qtranxj_get_cookie('qtrans_admin_language');
235
+ //if(!adminLanguage)
236
var adminLanguage=qTranslateConfig.language;
237
238
build_translator=function(langF,langT)
263
var tr=rows[r];
264
var td=tr.getElementsByTagName('TD')[0];
265
var items=td.getElementsByClassName('inline');
266
+ for(var i=0; i<items.length; i++)
267
{
268
var e=items[i];
269
e.style.display='none';
298
var nmF = nms[langF]||'';
299
var nmT = nms[langT]||'';
300
var items=td.getElementsByClassName('row-title');
301
+ for(var i=0; i<items.length; i++)
302
{
303
var e=items[i];
304
if(nmF)
316
var items=tagCloud.getElementsByTagName('A');
317
if(!items.length) return;
318
var translator=build_translator(langF,langT);
319
+ for(var i=0; i<items.length; i++)
320
{
321
var e=items[i];
322
var nmF=e.innerHTML;
352
353
var editinlines=document.getElementsByClassName('editinline');
354
//c('editinlines.length='+editinlines.length);
355
+ for(var i=0; i<editinlines.length; i++)
356
{
357
var e=editinlines[i];
358
if(e.tagName!=='A') continue;
369
370
var langs=qTranslateConfig.enabled_languages;
371
var newNameFields={};
372
+ for(var i=0; i<langs.length; i++)
373
{
374
var lang=langs[i];
375
newNameFields[lang]=qtranxj_ce('input', {name: 'qtranx_term_'+lang, className: 'hidden', value: name[lang] || ''}, form, true);
417
addContentHook(f,form,sep);
418
}
419
420
var alttextField=ge('attachment_alt');
421
if(alttextField) addContentHookB(alttextField,form);
422
564
565
setLangCookie=function()
566
{
567
+ document.cookie='qtrans_edit_language='+this.lang;
568
}
569
570
var matches = location.pathname.match(/(\/wp-admin\/([^\/]*))#x2F;);
618
}
619
activeLanguage=tabSwitch.lang;
620
tabSwitch.classList.add('active');
621
+ for(var i=0; i<onTabSwitch.length; i++)
622
{
623
onTabSwitch[i].call(this);
624
}
625
}
626
location.pathname.indexOf();
627
+ for(var i=0; i<langs.length; i++)
628
{
629
//var flags_location=qTranslateConfig.WP_CONTENT_URL+qTranslateConfig.flag_location;
630
var flag_location=qTranslateConfig.flag_location;
qtranslate.min.js CHANGED
@@ -1 +1 @@
1
- function qtranxj_get_cookie(e){for(var n=document.cookie.split(";"),a=0;a<n.length;++a){var t=n[a],r=t.split("=");if(r[0].trim()==e&&!(n.length<2))return r[1].trim()}return""}function qtranxj_isArray(e){return e.constructor.toString().indexOf("Array")>=0}function qtranxj_ce(e,n,a,t){var r=document.createElement(e);if(n)for(prop in n)r[prop]=n[prop];return a&&(t&&a.firstChild?a.insertBefore(r,a.firstChild):a.appendChild(r)),r}function LanguageSwitch(e,n){function a(){var e=this;if(!e.lang)return void alert("qTranslate-X: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang");if(i!==e.lang){i&&l[i].classList.remove("active"),i=e.lang,e.classList.add("active");for(var n=0;n<s.length;++n)s[n].call(this)}}var t=qTranslateConfig.enabled_languages,r=qTranslateConfig.language_name,i=n,l={},s=[];location.pathname.indexOf();for(var o=0;o<t.length;++o){var g=qTranslateConfig.flag_location,u=t[o],c=qtranxj_ce("li",{lang:u,className:"qtranxs-lang-switch",onclick:a},e);qtranxj_ce("img",{src:g+qTranslateConfig.flag[u]},c),qtranxj_ce("span",{innerHTML:r[u]},c),l[u]=c,i==u&&c.classList.add("active")}this.getActiveLanguage=function(){return i},this.onSwitch=function(e){"function"==typeof e&&s.push(e)}}qtranxj_split=function(e){for(var n=new Object,a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a];n[t]=""}var r=/<!--:-->/gi,i=e.xsplit(r);if(!qtranxj_isArray(i))return n;var l,s,t;if(i.length>1){s=/<!--:([a-z]{2})-->/gi;for(var a=0;a<i.length;++a){var o=i[a];o.length&&(l=s.exec(o),s.lastIndex=0,null!=l&&(t=l[1],n[t]+=o.substring(10)))}}else{var g=/(\[:[a-z]{2}\])/gi;if(i=e.xsplit(g),!qtranxj_isArray(i))return n;if(1==i.length)for(var o=i[0],u=0;u<qTranslateConfig.enabled_languages.length;++u){var t=qTranslateConfig.enabled_languages[u];n[t]+=o}else{s=/\[:([a-z]{2})\]/gi,t=!1;for(var a=0;a<i.length;++a){var o=i[a];if(t)n[t]+=o,t=!1;else{if(l=s.exec(o),s.lastIndex=0,null==l)continue;t=l[1]}}}}return n},qtranxj_join_c=function(e){for(var n="",a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],r=e[t];r&&""!=r&&(n+="<!--:"+t+"-->",n+=r,n+="<!--:-->")}return n},qtranxj_join_b=function(e){for(var n="",a=0;a<qTranslateConfig.enabled_languages.length;++a){var t=qTranslateConfig.enabled_languages[a],r=e[t];r&&""!=r&&(n+="[:"+t+"]",n+=r)}return n},String.prototype.xsplit=function(e){if(3==="a~b".split(/(~)/).length)return this.split(e);e.global||(e=new RegExp(e.source,"g"+(e.ignoreCase?"i":"")));for(var n,a=0,t=[];null!=(n=e.exec(this));)t.push(this.slice(a,n.index)),n.length>1&&t.push(n[1]),a=e.lastIndex;return a<this.length&&t.push(this.slice(a)),a==this.length&&t.push(""),t};var qTranslateX=function(){function e(e){return document.getElementById(e)}function n(e,n){var a=g[e],t=languageSwitch.getActiveLanguage();a.contents[t]=n,a.mlContentField.value="<"===a.separator?qtranxj_join_c(a.contents):qtranxj_join_b(a.contents)}function a(e,a,t){if(e){var r=g[e.id]={};r.contentField=e,r.contents=qtranxj_split(e.value),r.mlContentField=qtranxj_ce(e.tagName,{name:e.name,className:"hidden",value:e.value},a,!0),t||(t="TEXTAREA"===e.tagName?"<":"["),r.separator=t,e.name+="_edit",e.value=r.contents[o],e.onblur=function(){n(this.id,this.value)}}}function t(e,n){a(e,n,"<")}function r(e,n){a(e,n,"[")}function i(){var n,a,t=!!e("tag-name");t?(n="tag-",a="addtag"):(n="",a="edittag");var r=e(n+"name"),i=e(a);if(!i||!r)return!1;var l=qTranslateConfig.language;build_translator=function(e,n){var a={};for(var t in qTranslateConfig.term_name){var r=qTranslateConfig.term_name[t],i=r[e],l=r[n];if(!i||!l){var s=r[qTranslateConfig.default_language];if(!s)continue;i||(i=s+"("+qTranslateConfig.default_language+")"),l||(l=s+"("+qTranslateConfig.default_language+")")}a[i]=l}return a};var s=e("the-list");hideQuickEdit=function(){if(s)for(var e=s.getElementsByTagName("TR"),n=0;n<e.length;n++)for(var a=e[n],t=a.getElementsByTagName("TD")[0],r=t.getElementsByClassName("inline"),i=0;i<r.length;++i){var l=r[i];l.style.display="none"}},hideQuickEdit(),updateNames=function(e,n){if(s)for(var a=s.getElementsByTagName("TR"),t=0;t<a.length;t++){for(var r,i=a[t],o=i.getElementsByTagName("TD")[0],g=o.getElementsByTagName("DIV"),u=0;u<g.length;u++){var c=g[u];if("name"===c.className){r=c.innerHTML;break}}if(l!=qTranslateConfig.default_language){var f=build_translator(l,qTranslateConfig.default_language);r=f[r]}for(var d=qTranslateConfig.term_name[r]||{},h=d[e]||"",v=d[n]||"",m=o.getElementsByClassName("row-title"),p=0;p<m.length;++p){var c=m[p];h?c.innerHTML=c.innerHTML.replace(h,v):c.innerHTML+=v}}};var g=document.getElementsByClassName("tagcloud")[0];updateTagCloud=function(e,n){if(g){var a=g.getElementsByTagName("A");if(a.length)for(var t=build_translator(e,n),r=0;r<a.length;++r){var i=a[r],l=i.innerHTML,s=t[l];s&&(i.innerHTML=s)}}},updateNamesAndTagCloud=function(e,n){updateNames(e,n),updateTagCloud(e,n)},l!==o&&updateNamesAndTagCloud(l,o);var u=qtranxj_ce("input",{name:r.name,className:"hidden",value:r.value},i,!0);r.name="";var c=qTranslateConfig.term_name[r.value]||{};o!==qTranslateConfig.default_language&&(r.value=c[o]||""),editinline_activated=function(){return!0};for(var f=document.getElementsByClassName("editinline"),d=0;d<f.length;++d){var h=f[d];"A"===h.tagName&&h.addEventListener("click",editinline_activated)}onTabSwitch=function(){o!==this.lang&&(r.value=c[this.lang]||"",updateNamesAndTagCloud(o,this.lang),o=this.lang)};for(var v=qTranslateConfig.enabled_languages,m={},d=0;d<v.length;++d){var p=v[d];m[p]=qtranxj_ce("input",{name:"qtranx_term_"+p,className:"hidden",value:name[p]||""},i,!0)}return r.onblur=function(){var e=languageSwitch.getActiveLanguage();m[e].value=this.value,c[e]=this.value,e===qTranslateConfig.default_language&&(u.value=this.value)},!0}function l(){function i(e,n){switch(qTranslateConfig.url_mode.toString()){case"1":e.search?e.search+="&lang="+n:e.search="?lang="+n;break;case"2":var a=qTranslateConfig.url_info_home,t=e.pathname.indexOf(a);e.pathname=a+n+e.pathname.substring(t+a.length-1);break;case"3":e.host=n+"."+e.host}}function l(n){if(!x){var a=e("view-post-btn");if(!a||!a.children.length)return;if(x=a.children[0],"A"!=x.tagName)return;b=x.href,E=qtranxj_ce("a",{})}E.href=b,i(E,n),x.href=E.href;var t=e("preview-action");if(t&&t.children.length&&(t.children[0].href=E.href),1!=qTranslateConfig.url_mode){if(!N){var r=e("sample-permalink");r&&r.childNodes.length&&(N=r.childNodes[0],y=N.nodeValue)}N&&(E.href=y,i(E,n),N.nodeValue=E.href)}}function s(e){var a=e.id;if(a){var t=g[a];t.mce||(t.mce=e,e.getBody().addEventListener("blur",function(){n(e.id,e.getContent())}))}}var u=e("post");if(!u)return!1;var c=e("title");c&&t(c,u);for(var f=u.getElementsByClassName("wp-editor-area"),d=0;d<f.length;++d){var h=f[d];t(h,u)}var v=e("attachment_caption");v&&t(v,u);for(var d=0;d<qTranslateConfig.custom_fields.length;++d){var m,p=qTranslateConfig.custom_fields[d];(0==p.indexOf("<")||0==p.indexOf("["))&&(m=p.substring(0,1),p=p.substring(1));var _=e(p);a(_,u,m)}for(var d=0;d<qTranslateConfig.custom_field_classes.length;++d){var m,T=qTranslateConfig.custom_field_classes[d];(0==T.indexOf("<")||0==T.indexOf("["))&&(m=T.substring(0,1),T=T.substring(1));for(var C=u.getElementsByClassName(T),q=0;q<C.length;++q)_=C[q],a(_,u,m)}var w=e("attachment_alt");w&&r(w,u);var x,b,E,N,y;return l(o),onTabSwitch=function(){for(var e in g){var n=g[e];n.contentField.value=n.contents[this.lang]}if(w&&(w.value=alttexts[this.lang]),l(this.lang),window.tinyMCE)for(var a=0;a<tinyMCE.editors.length;++a){var t=tinyMCE.editors[a],n=g[t.id];n&&t.setContent(n.contentField.value)}},window.addEventListener("load",function(){if(window.tinyMCE){for(var e=0;e<tinyMCE.editors.length;++e){var n=tinyMCE.editors[e];s(n)}for(var a in g){var t=g[a];t.mce||"TEXTAREA"===t.contentField.tagName&&(tinyMCEPreInit.mceInit[a].init_instance_callback=function(e){s(e)})}}}),!0}function s(){var n=document.getElementsByTagName("FORM");if(!n.length)return!1;var a=n[0];return r(e("blogname"),a),r(e("blogdescription"),a),onTabSwitch=function(){for(var e in g){var n=g[e];n.contentField.value=n.contents[this.lang]}},!0}var o=qtranxj_get_cookie("wp_qtrans_edit_language");o||(o=qTranslateConfig.language);var g={};setLangCookie=function(){document.cookie="wp_qtrans_edit_language="+this.lang};var u=location.pathname.match(/(\/wp-admin\/([^\/]*))#x2F;);switch(u&&u[1]){case"/wp-admin/post.php":case"/wp-admin/post-new.php":if(!l())return;break;case"/wp-admin/edit-tags.php":if(!i())return;break;case"/wp-admin/options-general.php":if(location.search.indexOf("page=")>=0)return;if(!s())return;break;default:return}var c=qtranxj_ce("ul",{className:"qtranxs-lang-switch-wrap"}),f=document.getElementsByClassName("wrap")[0],d=f.getElementsByTagName("form")[0];d.parentNode.insertBefore(c,d),languageSwitch=new LanguageSwitch(c,o),languageSwitch.onSwitch(onTabSwitch),languageSwitch.onSwitch(setLangCookie)};new qTranslateX;
1
+ function qtranxj_get_cookie(e){for(var a=document.cookie.split(";"),n=0;n<a.length;n++){var t=a[n],r=t.split("=");if(r[0].trim()==e&&!(a.length<2))return r[1].trim()}return""}function qtranxj_isArray(e){return e.constructor.toString().indexOf("Array")>=0}function qtranxj_ce(e,a,n,t){var r=document.createElement(e);if(a)for(prop in a)r[prop]=a[prop];return n&&(t&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r)),r}function LanguageSwitch(e,a){function n(){var e=this;if(!e.lang)return void alert("qTranslate-X: This should not have happened: Please, report this incident to the developers: !tabSwitch.lang");if(i!==e.lang){i&&l[i].classList.remove("active"),i=e.lang,e.classList.add("active");for(var a=0;a<o.length;a++)o[a].call(this)}}var t=qTranslateConfig.enabled_languages,r=qTranslateConfig.language_name,i=a,l={},o=[];location.pathname.indexOf();for(var s=0;s<t.length;s++){var g=qTranslateConfig.flag_location,u=t[s],c=qtranxj_ce("li",{lang:u,className:"qtranxs-lang-switch",onclick:n},e);qtranxj_ce("img",{src:g+qTranslateConfig.flag[u]},c),qtranxj_ce("span",{innerHTML:r[u]},c),l[u]=c,i==u&&c.classList.add("active")}this.getActiveLanguage=function(){return i},this.onSwitch=function(e){"function"==typeof e&&o.push(e)}}qtranxj_split=function(e){for(var a=new Object,n=0;n<qTranslateConfig.enabled_languages.length;n++){var t=qTranslateConfig.enabled_languages[n];a[t]=""}var r=/(<!--.*?-->)/gi,i=e.xsplit(r);if(!qtranxj_isArray(i))return a;var l,o;if(i.length>1)l=/<!--:([a-z]{2})-->/gi,o=/<!--:-->/gi;else{var s=/(\[:[a-z]{2}\])/gi;if(i=e.xsplit(s),!qtranxj_isArray(i))return a;l=/\[:([a-z]{2})\]/gi}if(!i.length)return a;if(1==i.length)for(var g=i[0],u=0;u<qTranslateConfig.enabled_languages.length;u++){var t=qTranslateConfig.enabled_languages[u];a[t]+=g}else for(var c,t=!1,n=0;n<i.length;n++){var g=i[n];g.length&&(null!=(c=l.exec(g))?t=c[1]:o&&o.test(g)?t=!1:t&&(a[t]+=g,t=!1))}for(var f=/(<!--more-->|<!--nextpage-->)+#x2F;gi,n=0;n<a.length;n++)a[n]=a[n].replace(f,"");return a},qtranxj_join_c=function(e){for(var a="",n=0;n<qTranslateConfig.enabled_languages.length;n++){var t=qTranslateConfig.enabled_languages[n],r=e[t];r&&""!=r&&(a+="<!--:"+t+"-->",a+=r,a+="<!--:-->")}return a},qtranxj_join_b=function(e){for(var a="",n=0;n<qTranslateConfig.enabled_languages.length;n++){var t=qTranslateConfig.enabled_languages[n],r=e[t];r&&""!=r&&(a+="[:"+t+"]",a+=r)}return a},String.prototype.xsplit=function(e){if(3==="a~b".split(/(~)/).length)return this.split(e);e.global||(e=new RegExp(e.source,"g"+(e.ignoreCase?"i":"")));for(var a,n=0,t=[];null!=(a=e.exec(this));)t.push(this.slice(n,a.index)),a.length>1&&t.push(a[1]),n=e.lastIndex;return n<this.length&&t.push(this.slice(n)),n==this.length&&t.push(""),t};var qTranslateX=function(){function e(e){return document.getElementById(e)}function a(e,a){var n=g[e],t=languageSwitch.getActiveLanguage(),r=/(<!--more-->|<!--nextpage-->)+#x2F;gi;n.contents[t]=a.replace(r,""),n.mlContentField.value="<"===n.separator?qtranxj_join_c(n.contents):qtranxj_join_b(n.contents)}function n(e,n,t){if(e){var r=g[e.id]={};r.contentField=e,r.contents=qtranxj_split(e.value),r.mlContentField=qtranxj_ce(e.tagName,{name:e.name,className:"hidden",value:e.value},n,!0),t||(t="TEXTAREA"===e.tagName?"<":"["),r.separator=t,e.name+="_edit",e.value=r.contents[s],e.onblur=function(){a(this.id,this.value)}}}function t(e,a){n(e,a,"<")}function r(e,a){n(e,a,"[")}function i(){var a,n,t=!!e("tag-name");t?(a="tag-",n="addtag"):(a="",n="edittag");var r=e(a+"name"),i=e(n);if(!i||!r)return!1;var l=qTranslateConfig.language;build_translator=function(e,a){var n={};for(var t in qTranslateConfig.term_name){var r=qTranslateConfig.term_name[t],i=r[e],l=r[a];if(!i||!l){var o=r[qTranslateConfig.default_language];if(!o)continue;i||(i=o+"("+qTranslateConfig.default_language+")"),l||(l=o+"("+qTranslateConfig.default_language+")")}n[i]=l}return n};var o=e("the-list");hideQuickEdit=function(){if(o)for(var e=o.getElementsByTagName("TR"),a=0;a<e.length;a++)for(var n=e[a],t=n.getElementsByTagName("TD")[0],r=t.getElementsByClassName("inline"),i=0;i<r.length;i++){var l=r[i];l.style.display="none"}},hideQuickEdit(),updateNames=function(e,a){if(o)for(var n=o.getElementsByTagName("TR"),t=0;t<n.length;t++){for(var r,i=n[t],s=i.getElementsByTagName("TD")[0],g=s.getElementsByTagName("DIV"),u=0;u<g.length;u++){var c=g[u];if("name"===c.className){r=c.innerHTML;break}}if(l!=qTranslateConfig.default_language){var f=build_translator(l,qTranslateConfig.default_language);r=f[r]}for(var d=qTranslateConfig.term_name[r]||{},h=d[e]||"",v=d[a]||"",m=s.getElementsByClassName("row-title"),p=0;p<m.length;p++){var c=m[p];h?c.innerHTML=c.innerHTML.replace(h,v):c.innerHTML+=v}}};var g=document.getElementsByClassName("tagcloud")[0];updateTagCloud=function(e,a){if(g){var n=g.getElementsByTagName("A");if(n.length)for(var t=build_translator(e,a),r=0;r<n.length;r++){var i=n[r],l=i.innerHTML,o=t[l];o&&(i.innerHTML=o)}}},updateNamesAndTagCloud=function(e,a){updateNames(e,a),updateTagCloud(e,a)},l!==s&&updateNamesAndTagCloud(l,s);var u=qtranxj_ce("input",{name:r.name,className:"hidden",value:r.value},i,!0);r.name="";var c=qTranslateConfig.term_name[r.value]||{};s!==qTranslateConfig.default_language&&(r.value=c[s]||""),editinline_activated=function(){return!0};for(var f=document.getElementsByClassName("editinline"),d=0;d<f.length;d++){var h=f[d];"A"===h.tagName&&h.addEventListener("click",editinline_activated)}onTabSwitch=function(){s!==this.lang&&(r.value=c[this.lang]||"",updateNamesAndTagCloud(s,this.lang),s=this.lang)};for(var v=qTranslateConfig.enabled_languages,m={},d=0;d<v.length;d++){var p=v[d];m[p]=qtranxj_ce("input",{name:"qtranx_term_"+p,className:"hidden",value:name[p]||""},i,!0)}return r.onblur=function(){var e=languageSwitch.getActiveLanguage();m[e].value=this.value,c[e]=this.value,e===qTranslateConfig.default_language&&(u.value=this.value)},!0}function l(){function i(e,a){switch(qTranslateConfig.url_mode.toString()){case"1":e.search?e.search+="&lang="+a:e.search="?lang="+a;break;case"2":var n=qTranslateConfig.url_info_home,t=e.pathname.indexOf(n);e.pathname=n+a+e.pathname.substring(t+n.length-1);break;case"3":e.host=a+"."+e.host}}function l(a){if(!q){var n=e("view-post-btn");if(!n||!n.children.length)return;if(q=n.children[0],"A"!=q.tagName)return;C=q.href,w=qtranxj_ce("a",{})}w.href=C,i(w,a),q.href=w.href;var t=e("preview-action");if(t&&t.children.length&&(t.children[0].href=w.href),1!=qTranslateConfig.url_mode){if(!x){var r=e("sample-permalink");r&&r.childNodes.length&&(x=r.childNodes[0],b=x.nodeValue)}x&&(w.href=b,i(w,a),x.nodeValue=w.href)}}function o(e){var n=e.id;if(n){var t=g[n];t.mce||(t.mce=e,e.getBody().addEventListener("blur",function(){a(e.id,e.getContent())}))}}var u=e("post");if(!u)return!1;var c=e("title");c&&t(c,u);for(var f=u.getElementsByClassName("wp-editor-area"),d=0;d<f.length;++d){var h=f[d];t(h,u)}var v=e("attachment_caption");v&&t(v,u);for(var d=0;d<qTranslateConfig.custom_fields.length;++d){var m,p=qTranslateConfig.custom_fields[d];(0==p.indexOf("<")||0==p.indexOf("["))&&(m=p.substring(0,1),p=p.substring(1));var _=e(p);n(_,u,m)}var T=e("attachment_alt");T&&r(T,u);var q,C,w,x,b;return l(s),onTabSwitch=function(){for(var e in g){var a=g[e];a.contentField.value=a.contents[this.lang]}if(T&&(T.value=alttexts[this.lang]),l(this.lang),window.tinyMCE)for(var n=0;n<tinyMCE.editors.length;++n){var t=tinyMCE.editors[n],a=g[t.id];a&&t.setContent(a.contentField.value)}},window.addEventListener("load",function(){if(window.tinyMCE){for(var e=0;e<tinyMCE.editors.length;++e){var a=tinyMCE.editors[e];o(a)}for(var n in g){var t=g[n];t.mce||"TEXTAREA"===t.contentField.tagName&&(tinyMCEPreInit.mceInit[n].init_instance_callback=function(e){o(e)})}}}),!0}function o(){var a=document.getElementsByTagName("FORM");if(!a.length)return!1;var n=a[0];return r(e("blogname"),n),r(e("blogdescription"),n),onTabSwitch=function(){for(var e in g){var a=g[e];a.contentField.value=a.contents[this.lang]}},!0}var s=qtranxj_get_cookie("qtrans_edit_language");s||(s=qTranslateConfig.language);var g={};setLangCookie=function(){document.cookie="qtrans_edit_language="+this.lang};var u=location.pathname.match(/(\/wp-admin\/([^\/]*))#x2F;);switch(u&&u[1]){case"/wp-admin/post.php":case"/wp-admin/post-new.php":if(!l())return;break;case"/wp-admin/edit-tags.php":if(!i())return;break;case"/wp-admin/options-general.php":if(location.search.indexOf("page=")>=0)return;if(!o())return;break;default:return}var c=qtranxj_ce("ul",{className:"qtranxs-lang-switch-wrap"}),f=document.getElementsByClassName("wrap")[0],d=f.getElementsByTagName("form")[0];d.parentNode.insertBefore(c,d),languageSwitch=new LanguageSwitch(c,s),languageSwitch.onSwitch(onTabSwitch),languageSwitch.onSwitch(setLangCookie)};new qTranslateX;
qtranslate.php CHANGED
@@ -1,9 +1,9 @@
1
<?php // encoding: utf-8
2
/**
3
- Plugin Name: qTranslate X
4
Plugin URI: http://wordpress.org/plugins/qtranslate-x/
5
Description: Adds user-friendly and database-friendly multilingual content support into WordPress.
6
- Version: 2.9.2
7
Author: John Clause based on original code by Qian Qin
8
Author URI: http://qtranslatexteam.wordpress.com/about
9
Tags: multilingual, multi, language, admin, tinymce, Polyglot, bilingual, widget, switcher, professional, human, translation, service, qTranslate, zTranslate, mqTranslate, qTranslate Plus, WPML
@@ -122,8 +122,7 @@ define('QTX_DATE_OVERRIDE', 2);
122
define('QTX_DATE', 3);
123
define('QTX_STRFTIME', 4);
124
125
- define('QTX_COOKIE_NAME_FRONT','wp_qtrans_front_language');
126
- define('QTX_COOKIE_NAME_ADMIN','wp_qtrans_admin_language');
127
128
define('QTX_IGNORE_FILE_TYPES','gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js');
129
@@ -153,9 +152,6 @@ $q_config['auto_update_mo'] = true;
153
// hide language tag for default language
154
$q_config['hide_default_language'] = true;
155
156
- //enables compatibility with former qtrans_* functions
157
- $q_config['qtrans_compatibility'] = false;
158
-
159
// sets default url mode
160
// QTX_URL_QUERY(1) - query (questionmark)
161
// QTX_URL_PATH(2) - pre-path
@@ -322,9 +318,6 @@ $q_config['flag_location'] = 'plugins/qtranslate-x/flags/';
322
323
// Don't convert URLs to this file types
324
//$q_config['ignore_file_types'] = explode(',',QTX_IGNORE_FILE_TYPES);
325
- $q_config['custom_fields'] = array();
326
- $q_config['custom_field_classes'] = array();
327
- $q_config['text_field_filters'] = array();
328
329
/* DEFAULT CONFIGURATION PART ENDS HERE */
330
1
<?php // encoding: utf-8
2
/**
3
+ Plugin Name: qTranslate-X
4
Plugin URI: http://wordpress.org/plugins/qtranslate-x/
5
Description: Adds user-friendly and database-friendly multilingual content support into WordPress.
6
+ Version: 2.8
7
Author: John Clause based on original code by Qian Qin
8
Author URI: http://qtranslatexteam.wordpress.com/about
9
Tags: multilingual, multi, language, admin, tinymce, Polyglot, bilingual, widget, switcher, professional, human, translation, service, qTranslate, zTranslate, mqTranslate, qTranslate Plus, WPML
122
define('QTX_DATE', 3);
123
define('QTX_STRFTIME', 4);
124
125
+ define('QTX_COOKIE_NAME','language');
126
127
define('QTX_IGNORE_FILE_TYPES','gif,jpg,jpeg,png,pdf,swf,tif,rar,zip,7z,mpg,divx,mpeg,avi,css,js');
128
152
// hide language tag for default language
153
$q_config['hide_default_language'] = true;
154
155
// sets default url mode
156
// QTX_URL_QUERY(1) - query (questionmark)
157
// QTX_URL_PATH(2) - pre-path
318
319
// Don't convert URLs to this file types
320
//$q_config['ignore_file_types'] = explode(',',QTX_IGNORE_FILE_TYPES);
321
322
/* DEFAULT CONFIGURATION PART ENDS HERE */
323
qtranslate_compatibility.php CHANGED
@@ -19,10 +19,8 @@ if (!function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')){
19
return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($content);
20
}
21
}
22
- if(!function_exists('qtrans_useTermLib')){
23
- function qtrans_useTermLib($obj){ return qtranxf_useTermLib($obj); }
24
- }
25
- if(!function_exists('qtrans_getSortedLanguages')){
26
- function qtrans_getSortedLanguages($reverse = false){ return qtranxf_getSortedLanguages($reverse); }
27
- }
28
?>
19
return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($content);
20
}
21
}
22
+
23
+ //if(!function_exists('qtrans_useTermLib')){//is not available any more
24
+ // function qtrans_useTermLib($obj){ return qtranxf_useTermLib($obj);
25
+ //}
26
?>
qtranslate_configuration.php CHANGED
@@ -47,7 +47,6 @@ function qtranxf_update_config()
47
delete_option('qtranslate_auto_update_mo');
48
delete_option('qtranslate_next_update_mo');
49
delete_option('qtranslate_hide_default_language');
50
- delete_option('qtranslate_qtrans_compatibility');
51
delete_option('qtranslate_custom_fields');
52
if(isset($_POST['qtranslate_reset3'])) {
53
delete_option('qtranslate_term_name');
@@ -67,7 +66,7 @@ function qtranxf_add_admin_js () {
67
wp_deregister_script( 'autosave' );//autosave script saves the active language only and messes it up later in a hard way
68
69
//echo '<script>var qTranslateConfig='.json_encode($q_config).';</script>';
70
- $keys=array('enabled_languages','default_language','language','term_name','custom_fields','custom_field_classes','url_mode');
71
foreach($keys as $key){
72
$config[$key]=$q_config[$key];
73
}
@@ -256,7 +255,7 @@ function qtranxf_language_form($lang = '', $language_code = '', $language_name =
256
<label for="language_locale"><?php _e('Locale', 'qtranslate') ?></label>
257
<input name="language_locale" id="language_locale" type="text" value="<?php echo $language_locale; ?>" size="5" maxlength="5"/>
258
<p>
259
- <?php _e('PHP and Wordpress Locale for the language. (Example: en_US)', 'qtranslate'); ?><br/>
260
<?php _e('You will need to install the .mo file for this language.', 'qtranslate'); ?>
261
</p>
262
</div>
@@ -274,8 +273,8 @@ function qtranxf_language_form($lang = '', $language_code = '', $language_name =
274
<label for="language_na_message"><?php _e('Not Available Message', 'qtranslate') ?></label>
275
<input name="language_na_message" id="language_na_message" type="text" value="<?php echo $language_na_message; ?>"/>
276
<p>
277
- <?php _e('Message to display if post is not available in the requested language. (Example: Sorry, this entry is only available in %LANG:, : and %.)', 'qtranslate'); ?><br/>
278
- <?php _e('%LANG:&lt;normal_seperator&gt;:&lt;last_seperator&gt;% generates a list of languages seperated by &lt;normal_seperator&gt; except for the last one, where &lt;last_seperator&gt; will be used instead.', 'qtranslate'); ?><br/>
279
</p>
280
</div>
281
<?php
@@ -436,10 +435,7 @@ function qtranxf_conf() {
436
qtranxf_updateSetting('url_mode', QTX_INTEGER);
437
qtranxf_updateSetting('auto_update_mo', QTX_BOOLEAN);
438
qtranxf_updateSetting('hide_default_language', QTX_BOOLEAN);
439
- qtranxf_updateSetting('qtrans_compatibility', QTX_BOOLEAN);
440
qtranxf_updateSetting('custom_fields', QTX_ARRAY);
441
- qtranxf_updateSetting('custom_field_classes', QTX_ARRAY);
442
- qtranxf_updateSetting('text_field_filters', QTX_ARRAY);
443
if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtranxf_updateGettextDatabases(true))
444
$message = __('Gettext databases updated.', 'qtranslate');
445
}
@@ -670,7 +666,7 @@ function qtranxf_conf() {
670
echo ' <a href="'.add_query_arg('moveup', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/qtranslate-x/arrowup.png" alt="up" /></a>';
671
echo ' <a href="'.add_query_arg('movedown', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/qtranslate-x/arrowdown.png" alt="down" /></a>';
672
echo ' <img src="' . trailingslashit(WP_CONTENT_URL) .$q_config['flag_location'].$q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
673
- echo ' '.$q_config['language_name'][$language] . "</label><br/>\n";
674
}
675
?>
676
<small><?php printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), get_bloginfo('url')); ?></small>
@@ -704,9 +700,9 @@ function qtranxf_conf() {
704
<th scope="row"><?php _e('URL Modification Mode', 'qtranslate') ?></th>
705
<td>
706
<fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate') ?></legend>
707
- <label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_PATH; ?>" <?php echo ($q_config['url_mode']==QTX_URL_PATH)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate').'. SEO '.__('friendly', 'qtranslate').'.'; ?></label><br/>
708
- <label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAIN; ?>" <?php echo ($q_config['url_mode']==QTX_URL_DOMAIN)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate').'. '.__('You will need to configure DNS sub-domains on your site.', 'qtranslate'); ?></label><br/>
709
- <label title="Query Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_QUERY; ?>" <?php echo ($q_config['url_mode']==QTX_URL_QUERY)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Query Mode (?lang=en)', 'qtranslate').'. '.__('Most SEO unfriendly, not recommended.', 'qtranslate'); ?></label><br/>
710
</fieldset>
711
<small><?php _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!', 'qtranslate'); ?></small>
712
<br/><br/>
@@ -742,45 +738,18 @@ function qtranxf_conf() {
742
<tr valign="top">
743
<th scope="row"><?php _e('Date / Time Conversion', 'qtranslate');?></th>
744
<td>
745
- <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE; ?>" <?php echo ($q_config['use_strftime']==QTX_DATE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function.', 'qtranslate'); ?></label><br/>
746
- <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QTX_DATE_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br/>
747
- <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME; ?>" <?php echo ($q_config['use_strftime']==QTX_STRFTIME)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date.', 'qtranslate'); ?></label><br/>
748
- <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QTX_STRFTIME_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br/>
749
<small><?php _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate'); ?></small>
750
</td>
751
</tr>
752
<tr valign="top">
753
- <th scope="row"><?php echo __('Custom Fields', 'qtranslate');?></th>
754
<td>
755
- <?php printf(__('Enter "id" or "class" attribute of text fields from your theme, which you wish to translate. This applies to post, page and media editors (/wp-admin/post*). To lookup "id" or "class", right-click on the field in the post or the page editor and choose "Inspect Element". Look for an attribute of the field named "id" or "class". Enter it below, as many as you need, space- or comma-separated. After saving configuration, these fields will start responding to the language switching buttons, and you can enter different text for each language. The input fields of type %s will be parsed using %s syntax, while single line text fields will use %s syntax. If you need to override this behaviour, prepend prefix %s or %s to the name of the field to specify which syntax to use. For more information, read %sFAQ%s.', 'qtranslate'),'\'textarea\'',esc_html('<!--:-->'),'[:]','\'<\'','\'[\'','<a href="https://wordpress.org/plugins/qtranslate-x/faq/">','</a>'); ?>
756
- </td>
757
- </tr>
758
- <tr valign="top">
759
- <th scope="row" style="text-align: right">id:</th>
760
- <td>
761
- <input type="text" name="custom_fields" id="qtranxs_custom_fields" value="<?php echo implode(' ',$q_config['custom_fields']); ?>" style="width:100%"><br/>
762
- <small><?php _e('The value of "id" attribute is normally unique within one page, otherwise the first field found, having an id specified, is picked up.', 'qtranslate'); ?></small>
763
- </td>
764
- </tr>
765
- <tr valign="top">
766
- <th scope="row" style="text-align: right">class:</th>
767
- <td>
768
- <input type="text" name="custom_field_classes" id="qtranxs_custom_field_classes" value="<?php echo implode(' ',$q_config['custom_field_classes']); ?>" style="width:100%"><br>
769
- <small><?php printf(__('All the fields of specified classes will respond to Language Switching Buttons. Be careful not to include a class, which would affect language-neutral fields. If you cannot uniquely identify a field needed neither by %s, nor by %s attribute, report the issue on %sSupport Forum%s', 'qtranslate'),'"id"', '"class"', '<a href="https://wordpress.org/support/plugin/qtranslate-x">','</a>'); ?></small>
770
- </td>
771
- </tr>
772
- <tr valign="top">
773
- <th scope="row"><?php echo __('Custom Filters', 'qtranslate');?></th>
774
- <td>
775
- <input type="text" name="text_field_filters" id="qtranxs_text_field_filters" value="<?php echo implode(' ',$q_config['text_field_filters']); ?>" style="width:100%"><br>
776
- <small><?php printf(__('Names of filters (which are enabled on theme or other plugins via %s function) to add translation to. For more information, read %sFAQ%s.', 'qtranslate'),'apply_filters()','<a href="https://wordpress.org/plugins/qtranslate-x/faq/">','</a>'); ?></small>
777
- </td>
778
- </tr>
779
- <tr valign="top">
780
- <th scope="row"><?php _e('Compatibility Functions', 'qtranslate');?></th>
781
- <td>
782
- <label for="qtrans_compatibility"><input type="checkbox" name="qtrans_compatibility" id="qtrans_compatibility" value="1"<?php echo ($q_config['qtrans_compatibility'])?' checked="checked"':''; ?>/>&nbsp;<?php printf(__('Enable function names compatibility for %s.', 'qtranslate'), 'qtrans_getLanguage, qtrans_convertURL, qtrans_use, qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage, qtranxf_useTermLib and qtrans_getSortedLanguages'); ?></label><br/>
783
- <small><?php printf(__('Some plugins and themes use direct calls to the functions listed, which are defined in former %s plugin and some of its forks. Turning this flag on will enable those function to exists, which will make the dependent plugins and themes to work. WordPress policy prohibits to define functions with the same names as in other plugins, since it generates user-unfriendly fatal errors, when two conflicting plugins are activated simultaneously. Before turning this option on, you have to make sure that there are no other plugins active, which define those functions.', 'qtranslate'), '<a href="https://wordpress.org/plugins/qtranslate/" target="_blank">qTranslate</a>'); ?></small>
784
</td>
785
</tr>
786
<?php /*
@@ -918,7 +887,7 @@ function qtranxf_nav_menu_metabox( $object )
918
</div>
919
<span class="list-controls hide-if-no-js">
920
<a href="javascript:void(0);" class="help" onclick="jQuery( '#help-login-links' ).toggle();"><?php _e( 'Help' ); ?></a>
921
- <span class="hide-if-js" id="help-login-links"><br/><a name="help-login-links"></a>
922
Menu item added is replaced with a sub-menu of available languages when menu is rendered. Depending on how your theme renders menu you may need to override and customize css entries .qtranxs-lang-menu and .qtranxs-lang-menu-item, originally defined in qtranslate.css.
923
</span>
924
</span>
47
delete_option('qtranslate_auto_update_mo');
48
delete_option('qtranslate_next_update_mo');
49
delete_option('qtranslate_hide_default_language');
50
delete_option('qtranslate_custom_fields');
51
if(isset($_POST['qtranslate_reset3'])) {
52
delete_option('qtranslate_term_name');
66
wp_deregister_script( 'autosave' );//autosave script saves the active language only and messes it up later in a hard way
67
68
//echo '<script>var qTranslateConfig='.json_encode($q_config).';</script>';
69
+ $keys=array('enabled_languages','default_language','language','term_name','custom_fields','url_mode');
70
foreach($keys as $key){
71
$config[$key]=$q_config[$key];
72
}
255
<label for="language_locale"><?php _e('Locale', 'qtranslate') ?></label>
256
<input name="language_locale" id="language_locale" type="text" value="<?php echo $language_locale; ?>" size="5" maxlength="5"/>
257
<p>
258
+ <?php _e('PHP and Wordpress Locale for the language. (Example: en_US)', 'qtranslate'); ?><br />
259
<?php _e('You will need to install the .mo file for this language.', 'qtranslate'); ?>
260
</p>
261
</div>
273
<label for="language_na_message"><?php _e('Not Available Message', 'qtranslate') ?></label>
274
<input name="language_na_message" id="language_na_message" type="text" value="<?php echo $language_na_message; ?>"/>
275
<p>
276
+ <?php _e('Message to display if post is not available in the requested language. (Example: Sorry, this entry is only available in %LANG:, : and %.)', 'qtranslate'); ?><br />
277
+ <?php _e('%LANG:&lt;normal_seperator&gt;:&lt;last_seperator&gt;% generates a list of languages seperated by &lt;normal_seperator&gt; except for the last one, where &lt;last_seperator&gt; will be used instead.', 'qtranslate'); ?><br />
278
</p>
279
</div>
280
<?php
435
qtranxf_updateSetting('url_mode', QTX_INTEGER);
436
qtranxf_updateSetting('auto_update_mo', QTX_BOOLEAN);
437
qtranxf_updateSetting('hide_default_language', QTX_BOOLEAN);
438
qtranxf_updateSetting('custom_fields', QTX_ARRAY);
439
if(isset($_POST['update_mo_now']) && $_POST['update_mo_now']=='1' && qtranxf_updateGettextDatabases(true))
440
$message = __('Gettext databases updated.', 'qtranslate');
441
}
666
echo ' <a href="'.add_query_arg('moveup', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/qtranslate-x/arrowup.png" alt="up" /></a>';
667
echo ' <a href="'.add_query_arg('movedown', $language, $clean_uri).'"><img src="'.WP_PLUGIN_URL.'/qtranslate-x/arrowdown.png" alt="down" /></a>';
668
echo ' <img src="' . trailingslashit(WP_CONTENT_URL) .$q_config['flag_location'].$q_config['flag'][$language] . '" alt="' . $q_config['language_name'][$language] . '" /> ';
669
+ echo ' '.$q_config['language_name'][$language] . "</label><br />\n";
670
}
671
?>
672
<small><?php printf(__('Choose the default language of your blog. This is the language which will be shown on %s. You can also change the order the languages by clicking on the arrows above.', 'qtranslate'), get_bloginfo('url')); ?></small>
700
<th scope="row"><?php _e('URL Modification Mode', 'qtranslate') ?></th>
701
<td>
702
<fieldset><legend class="hidden"><?php _e('URL Modification Mode', 'qtranslate') ?></legend>
703
+ <label title="Pre-Path Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_PATH; ?>" <?php echo ($q_config['url_mode']==QTX_URL_PATH)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Pre-Path Mode (Default, puts /en/ in front of URL)', 'qtranslate').'. SEO '.__('friendly', 'qtranslate').'.'; ?></label><br />
704
+ <label title="Pre-Domain Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_DOMAIN; ?>" <?php echo ($q_config['url_mode']==QTX_URL_DOMAIN)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Pre-Domain Mode (uses http://en.yoursite.com)', 'qtranslate').'. '.__('You will need to configure DNS sub-domains on your site.', 'qtranslate'); ?></label><br />
705
+ <label title="Query Mode"><input type="radio" name="url_mode" value="<?php echo QTX_URL_QUERY; ?>" <?php echo ($q_config['url_mode']==QTX_URL_QUERY)?"checked=\"checked\"":""; ?> /> <?php echo __('Use Query Mode (?lang=en)', 'qtranslate').'. '.__('Most SEO unfriendly, not recommended.', 'qtranslate'); ?></label><br />
706
</fieldset>
707
<small><?php _e('Pre-Path and Pre-Domain mode will only work with mod_rewrite/pretty permalinks. Additional Configuration is needed for Pre-Domain mode!', 'qtranslate'); ?></small>
708
<br/><br/>
738
<tr valign="top">
739
<th scope="row"><?php _e('Date / Time Conversion', 'qtranslate');?></th>
740
<td>
741
+ <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE; ?>" <?php echo ($q_config['use_strftime']==QTX_DATE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function.', 'qtranslate'); ?></label><br />
742
+ <label><input type="radio" name="use_strftime" value="<?php echo QTX_DATE_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QTX_DATE_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use emulated date function and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br />
743
+ <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME; ?>" <?php echo ($q_config['use_strftime']==QTX_STRFTIME)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date.', 'qtranslate'); ?></label><br />
744
+ <label><input type="radio" name="use_strftime" value="<?php echo QTX_STRFTIME_OVERRIDE; ?>" <?php echo ($q_config['use_strftime']==QTX_STRFTIME_OVERRIDE)?' checked="checked"':''; ?>/> <?php _e('Use strftime instead of date and replace formats with the predefined formats for each language.', 'qtranslate'); ?></label><br />
745
<small><?php _e('Depending on the mode selected, additional customizations of the theme may be needed.', 'qtranslate'); ?></small>
746
</td>
747
</tr>
748
<tr valign="top">
749
+ <th scope="row"><?php _e('Custom Fields', 'qtranslate');?></th>
750
<td>
751
+ <input type="text" name="custom_fields" id="qtranxs_custom_fields" value="<?php echo implode(' ',$q_config['custom_fields']); ?>" style="width:100%">
752
+ <p><small><?php printf(__('Enter "id" attribute of text fields from your theme, which you wish to translate. This applies to post, page and media editors (/wp-admin/post*). To lookup "id", right-click on the field in the post or the page editor and choose "Inspect Element". Look for an attribute of the field named "id". Enter it here, as many as you need, space-separated. After saving configuration, these fields will start responding to the language switching buttons, and you can enter different text for each language. For more information, read %sFAQ%s.', 'qtranslate'),'<a href="https://wordpress.org/plugins/qtranslate-x/faq/">','</a>'); ?></small></p>
753
</td>
754
</tr>
755
<?php /*
887
</div>
888
<span class="list-controls hide-if-no-js">
889
<a href="javascript:void(0);" class="help" onclick="jQuery( '#help-login-links' ).toggle();"><?php _e( 'Help' ); ?></a>
890
+ <span class="hide-if-js" id="help-login-links"><br /><a name="help-login-links"></a>
891
Menu item added is replaced with a sub-menu of available languages when menu is rendered. Depending on how your theme renders menu you may need to override and customize css entries .qtranxs-lang-menu and .qtranxs-lang-menu-item, originally defined in qtranslate.css.
892
</span>
893
</span>
qtranslate_core.php CHANGED
@@ -37,13 +37,14 @@ function qtranxf_init() {
37
if($q_config['auto_update_mo']) qtranxf_updateGettextDatabases();
38
// update definitions if neccesary
39
if(current_user_can('manage_categories')) qtranxf_updateTermLibrary();
40
- $q_config['cookie_enabled']=isset($_COOKIE[QTX_COOKIE_NAME_ADMIN]);
41
- }else{
42
- $q_config['cookie_enabled']=isset($_COOKIE[QTX_COOKIE_NAME_FRONT]);
43
}
44
45
$host=$_SERVER['HTTP_HOST'];
46
- //on different port, it will not work for now
47
//if(isset($_SERVER['SERVER_PORT']) && !empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']!='80'){
48
// $host.=':'.$_SERVER['SERVER_PORT'];
49
//}
@@ -52,6 +53,61 @@ function qtranxf_init() {
52
//qtranxf_dbg_log('qtranxf_init: POST: ',$_POST);
53
$q_config['url_info'] = qtranxf_detect_language($_SERVER['REQUEST_URI'], $host, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
54
//qtranxf_dbg_log('qtranxf_init: url_info: ',$q_config['url_info']);
55
56
$q_config['language'] = $q_config['url_info']['language'];
57
$q_config['language'] = apply_filters('qtranslate_language', $q_config['language']);
@@ -86,10 +142,6 @@ function qtranxf_init() {
86
// fix url to prevent xss
87
$q_config['url_info']['url'] = qtranxf_convertURL(add_query_arg('lang',$q_config['default_language'],$q_config['url_info']['url']));
88
89
- if($q_config['qtrans_compatibility']){
90
- require_once(dirname(__FILE__)."/qtranslate_compatibility.php");
91
- }
92
-
93
//allow other plugins to initialize whatever they need
94
do_action('qtranxf_init');
95
@@ -121,28 +173,16 @@ function qtranxf_resolveLangCase($lang,&$caseredirect)
121
return FALSE;
122
}
123
124
- function qtranxf_get_language_cookie()
125
- {
126
- if(defined('WP_ADMIN')){
127
- if(isset($_COOKIE[QTX_COOKIE_NAME_ADMIN])) return $_COOKIE[QTX_COOKIE_NAME_ADMIN];
128
- }else{
129
- if(isset($_COOKIE[QTX_COOKIE_NAME_FRONT])) return $_COOKIE[QTX_COOKIE_NAME_FRONT];
130
- }
131
- return false;
132
- }
133
-
134
function qtranxf_set_language_cookie($lang,$cookie_path)
135
{
136
if(defined('WP_ADMIN')){
137
- $cookie_name = QTX_COOKIE_NAME_ADMIN;
138
$cookie_path = trailingslashit($cookie_path).'wp-admin';
139
}else{
140
- $cookie_name = QTX_COOKIE_NAME_FRONT;
141
if(strlen($cookie_path)>1)
142
$cookie_path=untrailingslashit($cookie_path);
143
}
144
//qtranxf_dbg_log('qtranxf_set_language_cookie: COOKIEPATH='.COOKIEPATH.'; cookie_path='.$cookie_path.'; lang='.$lang);
145
- setcookie($cookie_name, $lang, time()+31536000, $cookie_path);//one year
146
//two weeks 1209600
147
}
148
@@ -239,10 +279,10 @@ function qtranxf_detect_language($url, $host, $referer) {
239
if($q_config['hide_default_language'] && $lang_url == $q_config['default_language'])
240
$doredirect=true;
241
}else{
242
- $lang=qtranxf_get_language_cookie();
243
- if($lang){
244
$cs=false;
245
- $lang=qtranxf_resolveLangCase($lang,$cs);
246
//qtranxf_dbg_log('qtranxf_detect_language: cookie: lang='.$lang);
247
}
248
@@ -348,27 +388,6 @@ function qtranxf_validateBool($var, $default) {
348
if($var==='0') return false; elseif($var==='1') return true; else return $default;
349
}
350
351
- function qtranxf_load_option($nm) {
352
- global $q_config;
353
- $val = get_option('qtranslate_'.$nm);
354
- if(empty($val)) return;
355
- $q_config[$nm]=$val;
356
- }
357
-
358
- function qtranxf_load_option_array($nm) {
359
- global $q_config;
360
- $val = get_option('qtranslate_'.$nm);
361
- if(!is_array($val)) return;
362
- $q_config[$nm]=$val;
363
- }
364
-
365
- function qtranxf_load_option_bool($nm) {
366
- global $q_config;
367
- $val = get_option('qtranslate_'.$nm);
368
- if($val==='0') $q_config[$nm] = false;
369
- elseif($val==='1') $q_config[$nm] = true;
370
- }
371
-
372
// loads config via get_option and defaults to values set on top
373
function qtranxf_loadConfig() {
374
global $q_config;
@@ -389,11 +408,13 @@ function qtranxf_loadConfig() {
389
$use_strftime = get_option('qtranslate_use_strftime');
390
$ignore_file_types = get_option('qtranslate_ignore_file_types');
391
$url_mode = get_option('qtranslate_url_mode');
392
$term_name = get_option('qtranslate_term_name');
393
-
394
- qtranxf_load_option_array('custom_fields');
395
- qtranxf_load_option_array('custom_field_classes');
396
- qtranxf_load_option_array('text_field_filters');
397
398
// default if not set
399
if(!is_array($date_formats)) $date_formats = $q_config['date_format'];
@@ -404,36 +425,18 @@ function qtranxf_loadConfig() {
404
if(!is_array($language_names)) $language_names = $q_config['language_name'];
405
if(!is_array($enabled_languages)) $enabled_languages = $q_config['enabled_languages'];
406
if(!is_array($term_name)) $term_name = $q_config['term_name'];
407
if(empty($default_language)) $default_language = $q_config['default_language'];
408
if(empty($use_strftime)) $use_strftime = $q_config['use_strftime'];
409
if(empty($url_mode)) $url_mode = $q_config['url_mode'];
410
if(!is_string($flag_location) || $flag_location==='') $flag_location = $q_config['flag_location'];
411
-
412
- qtranxf_load_option_bool('detect_browser_language');
413
- qtranxf_load_option_bool('hide_untranslated');
414
- qtranxf_load_option_bool('show_displayed_language_prefix');
415
- qtranxf_load_option_bool('auto_update_mo');
416
- qtranxf_load_option_bool('hide_default_language');
417
- qtranxf_load_option_bool('qtrans_compatibility');
418
- /*
419
- $detect_browser_language = get_option('qtranslate_detect_browser_language');
420
- $hide_untranslated = get_option('qtranslate_hide_untranslated');
421
- $show_displayed_language_prefix = get_option('qtranslate_show_displayed_language_prefix');
422
- $auto_update_mo = get_option('qtranslate_auto_update_mo');
423
- $hide_default_language = get_option('qtranslate_hide_default_language');
424
-
425
$detect_browser_language = qtranxf_validateBool($detect_browser_language, $q_config['detect_browser_language']);
426
$hide_untranslated = qtranxf_validateBool($hide_untranslated, $q_config['hide_untranslated']);
427
$show_displayed_language_prefix = qtranxf_validateBool($show_displayed_language_prefix, $q_config['show_displayed_language_prefix']);
428
$auto_update_mo = qtranxf_validateBool($auto_update_mo, $q_config['auto_update_mo']);
429
$hide_default_language = qtranxf_validateBool($hide_default_language, $q_config['hide_default_language']);
430
-
431
- $q_config['detect_browser_language'] = $detect_browser_language;
432
- $q_config['hide_untranslated'] = $hide_untranslated;
433
- $q_config['show_displayed_language_prefix'] = $show_displayed_language_prefix;
434
- $q_config['auto_update_mo'] = $auto_update_mo;
435
- $q_config['hide_default_language'] = $hide_default_language;
436
- */
437
// url fix for upgrading users
438
$flag_location = trailingslashit(preg_replace('#^wp-content/#','',$flag_location));
439
@@ -466,19 +469,17 @@ function qtranxf_loadConfig() {
466
$q_config['ignore_file_types'] = $val;
467
468
$q_config['url_mode'] = $url_mode;
469
$q_config['term_name'] = $term_name;
470
471
- foreach($q_config['text_field_filters'] as $nm){
472
- add_filter($nm, 'qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage',0);
473
- }
474
do_action('qtranslate_loadConfig');
475
}
476
477
- function qtranxf_update_option($nm) {
478
- global $q_config;
479
- update_option('qtranslate_'.$nm, $q_config[$nm]);
480
- }
481
-
482
function qtranxf_update_option_bool($nm) {
483
global $q_config;
484
if($q_config[$nm])
@@ -487,7 +488,7 @@ function qtranxf_update_option_bool($nm) {
487
update_option('qtranslate_'.$nm, '0');
488
}
489
490
- // saves entire configuration - it should be in admin only?
491
function qtranxf_saveConfig() {
492
global $q_config;
493
@@ -504,10 +505,7 @@ function qtranxf_saveConfig() {
504
update_option('qtranslate_url_mode', $q_config['url_mode']);
505
update_option('qtranslate_term_name', $q_config['term_name']);
506
update_option('qtranslate_use_strftime', $q_config['use_strftime']);
507
-
508
- qtranxf_update_option('custom_fields');
509
- qtranxf_update_option('custom_field_classes');
510
- qtranxf_update_option('text_field_filters');
511
512
qtranxf_update_option_bool('detect_browser_language');
513
qtranxf_update_option_bool('hide_untranslated');
37
if($q_config['auto_update_mo']) qtranxf_updateGettextDatabases();
38
// update definitions if neccesary
39
if(current_user_can('manage_categories')) qtranxf_updateTermLibrary();
40
+ // $cookie_name = 'qtrans_admin_language';
41
+ //}else{
42
+ // $cookie_name = 'language';
43
}
44
+ $q_config['cookie_enabled']=isset($_COOKIE[QTX_COOKIE_NAME]);
45
46
$host=$_SERVER['HTTP_HOST'];
47
+ //on different port it will not work for now
48
//if(isset($_SERVER['SERVER_PORT']) && !empty($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT']!='80'){
49
// $host.=':'.$_SERVER['SERVER_PORT'];
50
//}
53
//qtranxf_dbg_log('qtranxf_init: POST: ',$_POST);
54
$q_config['url_info'] = qtranxf_detect_language($_SERVER['REQUEST_URI'], $host, isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '');
55
//qtranxf_dbg_log('qtranxf_init: url_info: ',$q_config['url_info']);
56
+ /*
57
+ // set test cookie
58
+ //setcookie('qtrans_cookie_test', 'qTranslateookie Test', 0, $q_config['url_info']['home'], $q_config['url_info']['host']);
59
+ // check cookies for admin
60
+ if(defined('WP_ADMIN')) {
61
+ if(isset($_GET['lang']) && qtranxf_isEnabled($_GET['lang'])) {
62
+ $q_config['language'] = $q_config['url_info']['language'];
63
+ setcookie('qtrans_admin_language', $q_config['language'], time()+60*60*24*30);
64
+ } elseif(isset($_COOKIE['qtrans_admin_language']) && qtranxf_isEnabled($_COOKIE['qtrans_admin_language'])) {
65
+ $q_config['language'] = $_COOKIE['qtrans_admin_language'];
66
+ } else {
67
+ $q_config['language'] = $q_config['default_language'];
68
+ }
69
+ } else {
70
+ $q_config['language'] = $q_config['url_info']['language'];
71
+ }
72
+
73
+ //qtranxf_dbg_log('qtranxf_init: url_info:',$q_config['url_info']);
74
+ //http_negotiate_language
75
+ if(!$q_config['url_info']['language']){
76
+ // detect language and forward if needed
77
+ if($q_config['detect_browser_language'] && $q_config['url_info']['redirect'] && !isset($_COOKIE['qtrans_cookie_test']) && $q_config['url_info']['language'] == $q_config['default_language']) {
78
+ $target = false;
79
+ $prefered_languages = array();
80
+ if(isset($_SERVER["HTTP_ACCEPT_LANGUAGE"]) && preg_match_all("#([^;,]+)(;[^,0-9]*([0-9\.]+)[^,]*)?#i",$_SERVER["HTTP_ACCEPT_LANGUAGE"], $matches, PREG_SET_ORDER)) {
81
+ $priority = 1.0;
82
+ foreach($matches as $match) {
83
+ if(!isset($match[3])) {
84
+ $pr = $priority;
85
+ $priority -= 0.001;
86
+ } else {
87
+ $pr = floatval($match[3]);
88
+ }
89
+ $prefered_languages[$match[1]] = $pr;
90
+ }
91
+ arsort($prefered_languages, SORT_NUMERIC);
92
+ foreach($prefered_languages as $language => $priority) {
93
+ if(strlen($language)>2) $language = substr($language,0,2);
94
+ if(qtranxf_isEnabled($language)) {
95
+ if($q_config['hide_default_language'] && $language == $q_config['default_language']) break;
96
+ $target = qtranxf_convertURL(get_option('home'),$language);
97
+ break;
98
+ }
99
+ }
100
+ }
101
+ $target = apply_filters('qtranslate_language_detect_redirect', $target);
102
+ if($target !== false) {
103
+ //qtranxf_dbg_log('qtranxf_init:detect_redirect: target='.$target);
104
+ wp_redirect($target);
105
+ exit();
106
+ }
107
+ }
108
+ $q_config['url_info']['language']=$q_config['default_language'];
109
+ }
110
+ */
111
112
$q_config['language'] = $q_config['url_info']['language'];
113
$q_config['language'] = apply_filters('qtranslate_language', $q_config['language']);
142
// fix url to prevent xss
143
$q_config['url_info']['url'] = qtranxf_convertURL(add_query_arg('lang',$q_config['default_language'],$q_config['url_info']['url']));
144
145
//allow other plugins to initialize whatever they need
146
do_action('qtranxf_init');
147
173
return FALSE;
174
}
175
176
function qtranxf_set_language_cookie($lang,$cookie_path)
177
{
178
if(defined('WP_ADMIN')){
179
$cookie_path = trailingslashit($cookie_path).'wp-admin';
180
}else{
181
if(strlen($cookie_path)>1)
182
$cookie_path=untrailingslashit($cookie_path);
183
}
184
//qtranxf_dbg_log('qtranxf_set_language_cookie: COOKIEPATH='.COOKIEPATH.'; cookie_path='.$cookie_path.'; lang='.$lang);
185
+ setcookie(QTX_COOKIE_NAME, $lang, time()+31536000, $cookie_path);//one year
186
//two weeks 1209600
187
}
188
279
if($q_config['hide_default_language'] && $lang_url == $q_config['default_language'])
280
$doredirect=true;
281
}else{
282
+
283
+ if(isset($_COOKIE[QTX_COOKIE_NAME])){
284
$cs=false;
285
+ $lang=qtranxf_resolveLangCase($_COOKIE[QTX_COOKIE_NAME],$cs);
286
//qtranxf_dbg_log('qtranxf_detect_language: cookie: lang='.$lang);
287
}
288
388
if($var==='0') return false; elseif($var==='1') return true; else return $default;
389
}
390
391
// loads config via get_option and defaults to values set on top
392
function qtranxf_loadConfig() {
393
global $q_config;
408
$use_strftime = get_option('qtranslate_use_strftime');
409
$ignore_file_types = get_option('qtranslate_ignore_file_types');
410
$url_mode = get_option('qtranslate_url_mode');
411
+ $detect_browser_language = get_option('qtranslate_detect_browser_language');
412
+ $hide_untranslated = get_option('qtranslate_hide_untranslated');
413
+ $show_displayed_language_prefix = get_option('qtranslate_show_displayed_language_prefix');
414
+ $auto_update_mo = get_option('qtranslate_auto_update_mo');
415
$term_name = get_option('qtranslate_term_name');
416
+ $hide_default_language = get_option('qtranslate_hide_default_language');
417
+ $custom_fields = get_option('qtranslate_custom_fields');
418
419
// default if not set
420
if(!is_array($date_formats)) $date_formats = $q_config['date_format'];
425
if(!is_array($language_names)) $language_names = $q_config['language_name'];
426
if(!is_array($enabled_languages)) $enabled_languages = $q_config['enabled_languages'];
427
if(!is_array($term_name)) $term_name = $q_config['term_name'];
428
+ if(!is_array($custom_fields)) $custom_fields = array();
429
+ //if(empty($ignore_file_types)) $ignore_file_types = $q_config['ignore_file_types'];
430
if(empty($default_language)) $default_language = $q_config['default_language'];
431
if(empty($use_strftime)) $use_strftime = $q_config['use_strftime'];
432
if(empty($url_mode)) $url_mode = $q_config['url_mode'];
433
if(!is_string($flag_location) || $flag_location==='') $flag_location = $q_config['flag_location'];
434
$detect_browser_language = qtranxf_validateBool($detect_browser_language, $q_config['detect_browser_language']);
435
$hide_untranslated = qtranxf_validateBool($hide_untranslated, $q_config['hide_untranslated']);
436
$show_displayed_language_prefix = qtranxf_validateBool($show_displayed_language_prefix, $q_config['show_displayed_language_prefix']);
437
$auto_update_mo = qtranxf_validateBool($auto_update_mo, $q_config['auto_update_mo']);
438
$hide_default_language = qtranxf_validateBool($hide_default_language, $q_config['hide_default_language']);
439
+
440
// url fix for upgrading users
441
$flag_location = trailingslashit(preg_replace('#^wp-content/#','',$flag_location));
442
469
$q_config['ignore_file_types'] = $val;
470
471
$q_config['url_mode'] = $url_mode;
472
+ $q_config['detect_browser_language'] = $detect_browser_language;
473
+ $q_config['hide_untranslated'] = $hide_untranslated;
474
+ $q_config['show_displayed_language_prefix'] = $show_displayed_language_prefix;
475
+ $q_config['auto_update_mo'] = $auto_update_mo;
476
+ $q_config['hide_default_language'] = $hide_default_language;
477
$q_config['term_name'] = $term_name;
478
+ $q_config['custom_fields'] = $custom_fields;
479
480
do_action('qtranslate_loadConfig');
481
}
482
483
function qtranxf_update_option_bool($nm) {
484
global $q_config;
485
if($q_config[$nm])
488
update_option('qtranslate_'.$nm, '0');
489
}
490
491
+ // saves entire configuration
492
function qtranxf_saveConfig() {
493
global $q_config;
494
505
update_option('qtranslate_url_mode', $q_config['url_mode']);
506
update_option('qtranslate_term_name', $q_config['term_name']);
507
update_option('qtranslate_use_strftime', $q_config['use_strftime']);
508
+ update_option('qtranslate_custom_fields', $q_config['custom_fields']);
509
510
qtranxf_update_option_bool('detect_browser_language');
511
qtranxf_update_option_bool('hide_untranslated');
qtranslate_frontend.php CHANGED
@@ -71,54 +71,21 @@ function qtranxf_get_nav_menu_items( $items, $menu, $args )
71
$itemid=0;
72
$menu_order=0;
73
$qtransmenu=null;
74
- $altlang=null;
75
- $url='';//it will keep the same page
76
- $tp='LM';
77
- $flags=true;
78
foreach($items as $item)
79
{
80
if($itemid<$item->ID) $itemid=$item->ID;
81
if($menu_order<$item->menu_order) $menu_order=$item->menu_order;
82
if( !isset( $item->url ) || strstr( $item->url, '#qtransLangSw' ) === FALSE ) continue;
83
- $qs=explode('?',$item->url);
84
- if(count($qs)>1){
85
- $pars=explode('&',$qs[1]);
86
- foreach($pars as $par){
87
- $ps=explode('=',$par);
88
- switch($ps[0]){
89
- case 'flags': $flags=($ps[1]!='no'); break;
90
- case 'type': $tp=$ps[1]; break;
91
- }
92
- }
93
- }
94
- if($tp=='AL'){
95
- foreach($q_config['enabled_languages'] as $lang){
96
- if($lang==$language) continue;
97
- $toplang=$lang;
98
- $altlang=$lang;
99
- break;
100
- }
101
- $item->title=$q_config['language_name'][$toplang];
102
- $item->url=qtranxf_convertURL($url, $altlang, false, true);
103
- }else{
104
- $toplang=$language;
105
- $item->title=__('Language','qtranslate');
106
- $item->url=null;
107
- }
108
- if($flags){
109
- $item->title.=':&nbsp;<img src="'.$flag_location.$q_config['flag'][$toplang].'">';
110
- }
111
//$item->classes[] = 'qtranxs_flag_'.$language;
112
$item->classes[] = 'qtranxs-lang-menu';
113
$qtransmenu = $item;
114
}
115
if(!$qtransmenu) return $items;
116
foreach($q_config['enabled_languages'] as $lang)
117
{
118
- if($tp=='AL'){
119
- if($lang==$language) continue;
120
- if($lang==$altlang ) continue;
121
- }
122
$item=new WP_Post((object)array('ID' => ++$itemid));
123
//$item->db_id=$item->ID;
124
$item->menu_item_parent=$qtransmenu->ID;
@@ -128,10 +95,7 @@ function qtranxf_get_nav_menu_items( $items, $menu, $args )
128
//$item->object_id=0;
129
$item->type='custom';
130
$item->type_label='Custom';
131
- $item->title=$q_config['language_name'][$lang];
132
- if($flags){
133
- $item->title='<img src="'.$flag_location.$q_config['flag'][$lang].'">&nbsp;'.$item->title;
134
- }
135
$item->post_title=$item->title;
136
$item->post_name='language-menuitem-'.$lang;
137
if($lang!=$language)
71
$itemid=0;
72
$menu_order=0;
73
$qtransmenu=null;
74
foreach($items as $item)
75
{
76
if($itemid<$item->ID) $itemid=$item->ID;
77
if($menu_order<$item->menu_order) $menu_order=$item->menu_order;
78
if( !isset( $item->url ) || strstr( $item->url, '#qtransLangSw' ) === FALSE ) continue;
79
+ $item->title=__('Language','qtranslate').':'.'&nbsp;<img src="'.$flag_location.$q_config['flag'][$language].'">';
80
+ $item->url=null;
81
//$item->classes[] = 'qtranxs_flag_'.$language;
82
$item->classes[] = 'qtranxs-lang-menu';
83
$qtransmenu = $item;
84
}
85
if(!$qtransmenu) return $items;
86
+ $url='';//it will keep the same page
87
foreach($q_config['enabled_languages'] as $lang)
88
{
89
$item=new WP_Post((object)array('ID' => ++$itemid));
90
//$item->db_id=$item->ID;
91
$item->menu_item_parent=$qtransmenu->ID;
95
//$item->object_id=0;
96
$item->type='custom';
97
$item->type_label='Custom';
98
+ $item->title='<img src="'.$flag_location.$q_config['flag'][$lang].'">&nbsp;'.$q_config['language_name'][$lang];
99
$item->post_title=$item->title;
100
$item->post_name='language-menuitem-'.$lang;
101
if($lang!=$language)
qtranslate_services.php CHANGED
@@ -630,7 +630,7 @@ function qts_service() {
630
if(isset($answer['error'])) {
631
$error = sprintf(__('An error occured: %s', 'qtranslate'), $qts_error_messages[$answer['error']]);
632
if($answer['message']!='') {
633
- $error.='<br/>'.sprintf(__('Additional information: %s', 'qtranslate'), qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($answer['message']));
634
}
635
}
636
if(isset($answer['order_id'])) {
630
if(isset($answer['error'])) {
631
$error = sprintf(__('An error occured: %s', 'qtranslate'), $qts_error_messages[$answer['error']]);
632
if($answer['message']!='') {
633
+ $error.='<br />'.sprintf(__('Additional information: %s', 'qtranslate'), qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($answer['message']));
634
}
635
}
636
if(isset($answer['order_id'])) {
readme.txt CHANGED
@@ -1,10 +1,10 @@
1
- === qTranslate X ===
2
Developed by: qTranslate Team based on original code by Qian Qin
3
Contributors: johnclause, chineseleper, Vavooon
4
Tags: multilingual, language, admin, tinymce, bilingual, widget, switcher, i18n, l10n, multilanguage, translation
5
Requires at least: 3.9
6
Tested up to: 4.1
7
- Stable tag: 2.9.2
8
License: GPLv3 or later
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QEXEK3HX8AR6U
10
License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -36,8 +36,6 @@ You may still find a lot of useful information through reading [qTranslate](http
36
37
We suggest all mentioned authors to get together and to continue supporting one single qTranslate-ish plugin in a joint effort.
38
39
- GitHub repository is available: https://github.com/qTranslate-Team/qtranslate-x.git
40
-
41
== Installation ==
42
43
Installation of this plugin is no different from any other plugin:
@@ -57,11 +55,11 @@ Installation of this plugin is no different from any other plugin:
57
58
= Is it possible to translate theme custom fields? =
59
60
- Yes, some themes put additional text fields per page or per post. By default, those fields have no way to respond to language switching buttons in editors. However, you may enter "id" or "class" name attribute of those fields into "Custom Fields" section of "Languages" configuration page in "Settings", and they will then respond to the language switching buttons allowing you to enter different text for each language. To lookup "id" or "class", right-click on the field in the post or the page editor, choose "Inspect Element", and look for which attributes are defined for that field. If you cannot uniquely distinct the field neither by if nor by class, report on the forum threads.
61
62
- The theme must pass those values through [translation](http://codex.wordpress.org/Function_Reference/_2) function '__()' before displaying on the front-end output. If this is not done, you will see the text of all languages displayed one after another. Most themes use '__()' translation by default, otherwise you may ask theme author to make this little modification for each field you need to be translatable. However, sometimes, they pass a value through 'apply_filters()' function before displaying the value, and then you may put that filter name into configuration filed "Custom Filters" to get the value translated properly.
63
64
- The following fields are pre-configured to be translatable by default:
65
66
- all input fields of class "wp-editor-area", which normally include all TinyMCE visual editors.
67
- fields with the following id: "title", "attachment_caption", "attachment_alt".
@@ -115,19 +113,6 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt
115
116
== Changelog ==
117
118
- = 2.9.2 =
119
- * Option "Compatibility Functions" to enable former qTranslate function names: qtrans_getLanguage, qtrans_convertURL, qtrans_use, qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage, qtranxf_useTermLib and qtrans_getSortedLanguages
120
- * "Language Switcher" menu options: flags=[yes|no], type=[LM|AL]. They can be used in a query string in URL field of Language Menu.
121
-
122
- = 2.9.1 =
123
- * JS bug fixed, which would not show any field value if no languages are yet configured for that field.
124
-
125
- = 2.9 =
126
- * ability to enable "Custom Fields" by either "id" or "class" attribute.
127
- * ability to specify filters, which other theme or plugins define, to pass relevant data through the translation.
128
- * support for <!--more--> and <!--nextpage--> tags.
129
- * language cookie are renamed to minimize possible interference with other sites.
130
-
131
= 2.8 =
132
* added option "Show displayed language prefix when content is not available for the selected language".
133
* compatibility with "BuddyPress" plugin and various improvements.
@@ -184,13 +169,6 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt
184
* added 'post_title' filter to translate all titles fetched for display purpose
185
* fixed problem with comment date display in some themes
186
187
- == Known Bugs ==
188
-
189
- * Incompatibility with plugin [WP Editor](https://wordpress.org/support/plugin/wp-editor). Language switching buttons do not change the content of main editor in pages and posts. For now, you would need to deactivate "WP Editor".
190
- * Sometimes after a new plugin update is released, the language switching buttons disappear on the first editor page load. Refresh the page to bring them back. Apparently, it has something to do with browse caching mechanism.
191
- * Message "The backup of this post in your browser is different from the version below" appears sometimes in the post editor. Clicking on "Restore the backup" may produce unexpected result, since backup has one language only,
192
- the one which was active at the time of the last pressing of button "Update". The code which causes this is in /wp-includes/js/autosave.js.
193
-
194
== Credentials ==
195
196
* The code of this plugin mostly originally based on [qTranslate](https://wordpress.org/plugins/qtranslate/ "qTranslate original plugin") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate fork").
@@ -198,7 +176,11 @@ the one which was active at the time of the last pressing of button "Update". Th
198
199
== Desirable Unimplemented Features ==
200
201
- * Add ability to put Language Switching buttons on other editors besides, post, pages and taxonomies.
202
* "Quick Edit" action in category or tag list pages will update the default language only.
203
- * If a language was switched on a page or post, but no edits were done, browser sometimes still complains about page changes, when leaving page.
204
- * Full screen editor mode does not have language switch buttons (not applicable in WP 4.1 any more).
1
+ === qTranslate-X ===
2
Developed by: qTranslate Team based on original code by Qian Qin
3
Contributors: johnclause, chineseleper, Vavooon
4
Tags: multilingual, language, admin, tinymce, bilingual, widget, switcher, i18n, l10n, multilanguage, translation
5
Requires at least: 3.9
6
Tested up to: 4.1
7
+ Stable tag: 2.8
8
License: GPLv3 or later
9
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QEXEK3HX8AR6U
10
License URI: http://www.gnu.org/licenses/gpl-3.0.html
36
37
We suggest all mentioned authors to get together and to continue supporting one single qTranslate-ish plugin in a joint effort.
38
39
== Installation ==
40
41
Installation of this plugin is no different from any other plugin:
55
56
= Is it possible to translate theme custom fields? =
57
58
+ Yes, some themes put additional text fields per page or per post. By default, those fields have no way to respond to language switching buttons in editors. However, you may enter "id" attribute of those fields into "Custom Fields" section of "Languages" configuration page in "Settings", and they will then respond to the language switching buttons allowing you to enter different text for each language. To lookup "id", right-click on the field in the post or the page editor, choose "Inspect Element", and look for an attribute of the field named "id".
59
60
+ The theme must pass those values through [translation](http://codex.wordpress.org/Function_Reference/_2) function '__()' before displaying on the output. Most themes do this by default, otherwise you may ask theme author to make this little modification for each field you need to be translatable.
61
62
+ Translatable fields, pre-configured by default:
63
64
- all input fields of class "wp-editor-area", which normally include all TinyMCE visual editors.
65
- fields with the following id: "title", "attachment_caption", "attachment_alt".
113
114
== Changelog ==
115
116
= 2.8 =
117
* added option "Show displayed language prefix when content is not available for the selected language".
118
* compatibility with "BuddyPress" plugin and various improvements.
169
* added 'post_title' filter to translate all titles fetched for display purpose
170
* fixed problem with comment date display in some themes
171
172
== Credentials ==
173
174
* The code of this plugin mostly originally based on [qTranslate](https://wordpress.org/plugins/qtranslate/ "qTranslate original plugin") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate fork").
176
177
== Desirable Unimplemented Features ==
178
179
* "Quick Edit" action in category or tag list pages will update the default language only.
180
+ * Full screen editor mode does not have language switch buttons
181
+ * If a language was switched on a page or post, but no edits were done, browser still complains about page changes, when leaving page.
182
+
183
+ == Known Bugs ==
184
+
185
+ * Message "The backup of this post in your browser is different from the version below" appears sometimes in the post editor. Clicking on "Restore the backup" may produce unexpected result, since backup has one language only,
186
+ the one which was active at the time of the last pressing of button "Update". The code which causes this is in /wp-includes/js/autosave.js.