Version Description
- more fixes for <!--more--> and <!--nextpage--> tags.
Download this release
Release Info
Developer | johnclause |
Plugin | qTranslate X |
Version | 2.9.5 |
Comparing to | |
See all releases |
Code changes from version 2.9.4 to 2.9.5
- admin/import_export.php +1 -1
- qtranslate.js +82 -2
- qtranslate.min.js +1 -1
- qtranslate.php +3 -2
- qtranslate_configuration.php +18 -2
- qtranslate_core.php +55 -10
- qtranslate_hooks.php +0 -14
- qtranslate_utils.php +1 -1
- readme.txt +14 -2
admin/import_export.php
CHANGED
@@ -80,7 +80,7 @@ function qtranxf_add_row_migrate($nm,$plugin) {
|
|
80 |
<td>
|
81 |
<?php
|
82 |
if($plugin=='qtranslate' || $plugin=='ztranslate'){
|
83 |
-
_e('There is no need to migrate any setting, the database schema is compatible with this plugin.');
|
84 |
}else{
|
85 |
?>
|
86 |
<label for="qtranslate_no_migration"><input type="radio" name="<?php echo $plugin; ?>-migration" id="<?php echo $plugin; ?>_no_migration" value="none" checked /> <?php _e('Do not migrate any setting', 'qtranslate'); ?></label>
|
80 |
<td>
|
81 |
<?php
|
82 |
if($plugin=='qtranslate' || $plugin=='ztranslate'){
|
83 |
+
_e('There is no need to migrate any setting, the database schema is compatible with this plugin.', 'qtranslate');
|
84 |
}else{
|
85 |
?>
|
86 |
<label for="qtranslate_no_migration"><input type="radio" name="<?php echo $plugin; ?>-migration" id="<?php echo $plugin; ?>_no_migration" value="none" checked /> <?php _e('Do not migrate any setting', 'qtranslate'); ?></label>
|
qtranslate.js
CHANGED
@@ -6,6 +6,59 @@ function c(v){ ++cc; console.log('== '+cc+': '+v); }
|
|
6 |
function ct(v){ c(v); console.trace(); }
|
7 |
*/
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
qtranxj_split = function(text)
|
10 |
{
|
11 |
var result = new Object;
|
@@ -64,7 +117,7 @@ qtranxj_split = function(text)
|
|
64 |
}
|
65 |
return result;
|
66 |
}
|
67 |
-
|
68 |
/*
|
69 |
qtranxj_split = function(text)
|
70 |
{
|
@@ -121,10 +174,35 @@ qtranxj_split = function(text)
|
|
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];
|
@@ -141,6 +219,8 @@ qtranxj_join_c = function(texts)
|
|
141 |
//"b" stands for "bracket"
|
142 |
qtranxj_join_b = function(texts)
|
143 |
{
|
|
|
|
|
144 |
var text = '';
|
145 |
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
|
146 |
{
|
6 |
function ct(v){ c(v); console.trace(); }
|
7 |
*/
|
8 |
|
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 = /(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])/gi;
|
18 |
+
var blocks = text.xsplit(split_regex);
|
19 |
+
//c('qtranxj_split: blocks='+blocks);
|
20 |
+
//c('qtranxj_split: blocks.length='+blocks.length);
|
21 |
+
if(!qtranxj_isArray(blocks))
|
22 |
+
return result;
|
23 |
+
if(blocks.length==1){//no language separator found, enter it to all languages
|
24 |
+
var b=blocks[0];
|
25 |
+
for(var j=0; j<qTranslateConfig.enabled_languages.length; ++j){
|
26 |
+
var lang=qTranslateConfig.enabled_languages[j];
|
27 |
+
result[lang] += b;
|
28 |
+
}
|
29 |
+
return result;
|
30 |
+
}
|
31 |
+
var clang_regex=/<!--:([a-z]{2})-->/gi;
|
32 |
+
var c_end_regex=/<!--:-->/g;
|
33 |
+
var blang_regex=/\[:([a-z]{2})\]/gi;
|
34 |
+
lang = false;
|
35 |
+
for(var i = 0;i<blocks.length;++i){
|
36 |
+
var b=blocks[i];
|
37 |
+
//c('blocks['+i+']='+b);
|
38 |
+
if(!b.length) continue;
|
39 |
+
matches = clang_regex.exec(b); clang_regex.lastIndex=0;
|
40 |
+
if(matches!=null){
|
41 |
+
lang = matches[1];
|
42 |
+
continue;
|
43 |
+
}
|
44 |
+
matches = c_end_regex.exec(b); c_end_regex.lastIndex=0;
|
45 |
+
if(matches!=null){
|
46 |
+
lang = false;
|
47 |
+
continue;
|
48 |
+
}
|
49 |
+
matches = blang_regex.exec(b); blang_regex.lastIndex=0;
|
50 |
+
if(matches!=null){
|
51 |
+
lang = matches[1];
|
52 |
+
continue;
|
53 |
+
}
|
54 |
+
if(!lang) continue;
|
55 |
+
result[lang] += b;
|
56 |
+
lang = false;
|
57 |
+
}
|
58 |
+
return result;
|
59 |
+
}
|
60 |
+
|
61 |
+
/*
|
62 |
qtranxj_split = function(text)
|
63 |
{
|
64 |
var result = new Object;
|
117 |
}
|
118 |
return result;
|
119 |
}
|
120 |
+
*/
|
121 |
/*
|
122 |
qtranxj_split = function(text)
|
123 |
{
|
174 |
return result;
|
175 |
}
|
176 |
*/
|
177 |
+
qtranxj_allthesame = function(texts)
|
178 |
+
{
|
179 |
+
if(qTranslateConfig.enabled_languages.length==0) return '';
|
180 |
+
var text = '';
|
181 |
+
//take first not empty
|
182 |
+
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
|
183 |
+
{
|
184 |
+
var lang=qTranslateConfig.enabled_languages[i];
|
185 |
+
var t = texts[lang];
|
186 |
+
if ( !t || t=='' ) continue;
|
187 |
+
text = t;
|
188 |
+
break;
|
189 |
+
}
|
190 |
+
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
|
191 |
+
{
|
192 |
+
var lang=qTranslateConfig.enabled_languages[i];
|
193 |
+
var t = texts[lang];
|
194 |
+
if ( !t || t=='' ) continue;
|
195 |
+
if(t!=text) return null;
|
196 |
+
}
|
197 |
+
return text;
|
198 |
+
}
|
199 |
+
|
200 |
//"_c" stands for "comment"
|
201 |
qtranxj_join_c = function(texts)
|
202 |
{
|
203 |
+
var text = qtranxj_allthesame(texts);
|
204 |
+
if(text!=null) return text;
|
205 |
+
text='';
|
206 |
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
|
207 |
{
|
208 |
var lang=qTranslateConfig.enabled_languages[i];
|
219 |
//"b" stands for "bracket"
|
220 |
qtranxj_join_b = function(texts)
|
221 |
{
|
222 |
+
var text = qtranxj_allthesame(texts);
|
223 |
+
if(text!=null) return text;
|
224 |
var text = '';
|
225 |
for(var i=0; i<qTranslateConfig.enabled_languages.length; ++i)
|
226 |
{
|
qtranslate.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function qtranxj_get_cookie(e){for(var
|
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<s.length;++a)s[a].call(this)}}var t=qTranslateConfig.enabled_languages,r=qTranslateConfig.language_name,i=a,l={},s=[];location.pathname.indexOf();for(var g=0;g<t.length;++g){var o=qTranslateConfig.flag_location,u=t[g],c=qtranxj_ce("li",{lang:u,className:"qtranxs-lang-switch",onclick:n},e);qtranxj_ce("img",{src:o+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 a=new Object,n=0;n<qTranslateConfig.enabled_languages.length;++n){var t=qTranslateConfig.enabled_languages[n];a[t]=""}var r=/(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])/gi,i=e.xsplit(r);if(!qtranxj_isArray(i))return a;if(1==i.length){for(var l=i[0],s=0;s<qTranslateConfig.enabled_languages.length;++s){var t=qTranslateConfig.enabled_languages[s];a[t]+=l}return a}var g=/<!--:([a-z]{2})-->/gi,o=/<!--:-->/g,u=/\[:([a-z]{2})\]/gi;t=!1;for(var n=0;n<i.length;++n){var l=i[n];l.length&&(matches=g.exec(l),g.lastIndex=0,null==matches?(matches=o.exec(l),o.lastIndex=0,null==matches?(matches=u.exec(l),u.lastIndex=0,null==matches?t&&(a[t]+=l,t=!1):t=matches[1]):t=!1):t=matches[1])}return a},qtranxj_allthesame=function(e){if(0==qTranslateConfig.enabled_languages.length)return"";for(var a="",n=0;n<qTranslateConfig.enabled_languages.length;++n){var t=qTranslateConfig.enabled_languages[n],r=e[t];if(r&&""!=r){a=r;break}}for(var n=0;n<qTranslateConfig.enabled_languages.length;++n){var t=qTranslateConfig.enabled_languages[n],r=e[t];if(r&&""!=r&&r!=a)return null}return a},qtranxj_join_c=function(e){var a=qtranxj_allthesame(e);if(null!=a)return a;a="";for(var 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){var a=qtranxj_allthesame(e);if(null!=a)return a;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=o[e],t=languageSwitch.getActiveLanguage();n.contents[t]=a,n.mlContentField.value="<"===n.separator?qtranxj_join_c(n.contents):qtranxj_join_b(n.contents)}function n(e,n,t){if(e){var r=o[e.id]={};r.contentField=e,r.contents=qtranxj_split(e.value),r.mlContentField=qtranxj_ce("input",{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[g],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 s=r[qTranslateConfig.default_language];if(!s)continue;i||(i=s+"("+qTranslateConfig.default_language+")"),l||(l=s+"("+qTranslateConfig.default_language+")")}n[i]=l}return n};var s=e("the-list");hideQuickEdit=function(){if(s)for(var e=s.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(s)for(var n=s.getElementsByTagName("TR"),t=0;t<n.length;t++){for(var r,i=n[t],g=i.getElementsByTagName("TD")[0],o=g.getElementsByTagName("DIV"),u=0;u<o.length;u++){var c=o[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=g.getElementsByClassName("row-title"),_=0;_<m.length;++_){var c=m[_];h?c.innerHTML=c.innerHTML.replace(h,v):c.innerHTML+=v}}};var o=document.getElementsByClassName("tagcloud")[0];updateTagCloud=function(e,a){if(o){var n=o.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,s=t[l];s&&(i.innerHTML=s)}}},updateNamesAndTagCloud=function(e,a){updateNames(e,a),updateTagCloud(e,a)},l!==g&&updateNamesAndTagCloud(l,g);var u=qtranxj_ce("input",{name:r.name,className:"hidden",value:r.value},i,!0);r.name="";var c=qTranslateConfig.term_name[r.value]||{};g!==qTranslateConfig.default_language&&(r.value=c[g]||""),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(){g!==this.lang&&(r.value=c[this.lang]||"",updateNamesAndTagCloud(g,this.lang),g=this.lang)};for(var v=qTranslateConfig.enabled_languages,m={},d=0;d<v.length;++d){var _=v[d];m[_]=qtranxj_ce("input",{name:"qtranx_term_"+_,className:"hidden",value:name[_]||""},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(!x){var n=e("view-post-btn");if(!n||!n.children.length)return;if(x=n.children[0],"A"!=x.tagName)return;w=x.href,E=qtranxj_ce("a",{})}E.href=w,i(E,a),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,a),N.nodeValue=E.href)}}function s(e){var n=e.id;if(n){var t=o[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,_=qTranslateConfig.custom_fields[d];(0==_.indexOf("<")||0==_.indexOf("["))&&(m=_.substring(0,1),_=_.substring(1));var p=e(_);n(p,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 q=u.getElementsByClassName(T),C=0;C<q.length;++C)p=q[C],n(p,u,m)}var b=e("attachment_alt");b&&r(b,u);var x,w,E,N,y;return l(g),onTabSwitch=function(){for(var e in o){var a=o[e];a.contentField.value=a.contents[this.lang]}if(b&&(b.value=alttexts[this.lang]),l(this.lang),window.tinyMCE)for(var n=0;n<tinyMCE.editors.length;++n){var t=tinyMCE.editors[n],a=o[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];s(a)}for(var n in o){var t=o[n];t.mce||"TEXTAREA"===t.contentField.tagName&&(tinyMCEPreInit.mceInit[n].init_instance_callback=function(e){s(e)})}}}),!0}function s(){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 o){var a=o[e];a.contentField.value=a.contents[this.lang]}},!0}var g=qtranxj_get_cookie("wp_qtrans_edit_language");g||(g=qTranslateConfig.language);var o={};setLangCookie=function(){document.cookie="wp_qtrans_edit_language="+this.lang};var u=location.pathname.match(/(\/wp-admin\/([^\/]*))$/);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,g),languageSwitch.onSwitch(onTabSwitch),languageSwitch.onSwitch(setLangCookie)};new qTranslateX;
|
qtranslate.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.
|
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
|
@@ -101,10 +101,11 @@ if ( ! defined( 'QTRANSLATE_FILE' ) ) {
|
|
101 |
define( 'QTRANSLATE_FILE', __FILE__ );
|
102 |
}
|
103 |
|
|
|
|
|
104 |
/* DEFAULT CONFIGURATION PART BEGINS HERE */
|
105 |
|
106 |
/* There is no need to edit anything here! */
|
107 |
-
|
108 |
define('QTX_STRING', 1);
|
109 |
define('QTX_BOOLEAN', 2);
|
110 |
define('QTX_INTEGER', 3);
|
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.5
|
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
|
101 |
define( 'QTRANSLATE_FILE', __FILE__ );
|
102 |
}
|
103 |
|
104 |
+
define('QTX_VERSION','2.9.5');
|
105 |
+
|
106 |
/* DEFAULT CONFIGURATION PART BEGINS HERE */
|
107 |
|
108 |
/* There is no need to edit anything here! */
|
|
|
109 |
define('QTX_STRING', 1);
|
110 |
define('QTX_BOOLEAN', 2);
|
111 |
define('QTX_INTEGER', 3);
|
qtranslate_configuration.php
CHANGED
@@ -59,7 +59,7 @@ add_action('qtranxf_init_begin','qtranxf_reset_config');
|
|
59 |
function qtranxf_add_admin_js () {
|
60 |
global $q_config;
|
61 |
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.js', __FILE__ ) );
|
62 |
-
wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.min.js', __FILE__ ) );
|
63 |
wp_enqueue_script( 'qtranslate-script' );
|
64 |
|
65 |
wp_dequeue_script('autosave');
|
@@ -359,15 +359,17 @@ function qtranxf_array_compare($a,$b) {
|
|
359 |
return empty($diff_a) && empty($diff_b);
|
360 |
}
|
361 |
|
|
|
362 |
function qtranxf_language_columns($columns) {
|
363 |
return array(
|
364 |
-
'flag' => 'Flag',
|
365 |
'name' => __('Name', 'qtranslate'),
|
366 |
'status' => __('Action', 'qtranslate'),
|
367 |
'status2' => '',
|
368 |
'status3' => ''
|
369 |
);
|
370 |
}
|
|
|
371 |
|
372 |
function qtranxf_useAdminTermLib($obj) {
|
373 |
if ($_SERVER["SCRIPT_NAME"]==="/wp-admin/edit-tags.php" &&
|
@@ -964,6 +966,20 @@ function qtranxf_add_language_menu( $wp_admin_bar )
|
|
964 |
}
|
965 |
}
|
966 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
967 |
add_filter('get_term', 'qtranxf_useAdminTermLib',0);
|
968 |
add_filter('get_terms', 'qtranxf_useAdminTermLib',0);
|
969 |
|
59 |
function qtranxf_add_admin_js () {
|
60 |
global $q_config;
|
61 |
//wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.js', __FILE__ ) );
|
62 |
+
wp_register_script( 'qtranslate-script', plugins_url( '/qtranslate.min.js', __FILE__ ), array(), QTX_VERSION );
|
63 |
wp_enqueue_script( 'qtranslate-script' );
|
64 |
|
65 |
wp_dequeue_script('autosave');
|
359 |
return empty($diff_a) && empty($diff_b);
|
360 |
}
|
361 |
|
362 |
+
//this is not in use?
|
363 |
function qtranxf_language_columns($columns) {
|
364 |
return array(
|
365 |
+
'flag' => __('Flag', 'qtranslate'),
|
366 |
'name' => __('Name', 'qtranslate'),
|
367 |
'status' => __('Action', 'qtranslate'),
|
368 |
'status2' => '',
|
369 |
'status3' => ''
|
370 |
);
|
371 |
}
|
372 |
+
//add_filter('manage_language_columns', 'qtranxf_language_columns');
|
373 |
|
374 |
function qtranxf_useAdminTermLib($obj) {
|
375 |
if ($_SERVER["SCRIPT_NAME"]==="/wp-admin/edit-tags.php" &&
|
966 |
}
|
967 |
}
|
968 |
|
969 |
+
function qtranxf_links($links, $file){ // copied from Sociable Plugin
|
970 |
+
//Static so we don't call plugin_basename on every plugin row.
|
971 |
+
static $this_plugin;
|
972 |
+
if (!$this_plugin) $this_plugin = plugin_basename(dirname(__FILE__).'/qtranslate.php');
|
973 |
+
|
974 |
+
if ($file == $this_plugin){
|
975 |
+
$settings_link = '<a href="options-general.php?page=qtranslate-x">' . __('Settings', 'qtranslate') . '</a>';
|
976 |
+
array_unshift( $links, $settings_link ); // before other links
|
977 |
+
}
|
978 |
+
return $links;
|
979 |
+
}
|
980 |
+
add_filter('plugin_action_links', 'qtranxf_links', 10, 2);
|
981 |
+
|
982 |
+
|
983 |
add_filter('get_term', 'qtranxf_useAdminTermLib',0);
|
984 |
add_filter('get_terms', 'qtranxf_useAdminTermLib',0);
|
985 |
|
qtranslate_core.php
CHANGED
@@ -913,18 +913,18 @@ function qtranxf_convertURL($url='', $lang='', $forceadmin = false, $showDefault
|
|
913 |
}
|
914 |
}
|
915 |
|
916 |
-
|
917 |
function qtranxf_split($text, $quicktags = true) {
|
918 |
global $q_config;
|
919 |
-
|
920 |
//init vars
|
921 |
$split_regex = "#(<!--[^-]*-->|\[:[a-z]{2}\])#ism";
|
|
|
922 |
$current_language = "";
|
923 |
$result = array();
|
924 |
foreach($q_config['enabled_languages'] as $language) {
|
925 |
$result[$language] = "";
|
926 |
}
|
927 |
-
|
928 |
// split text at all xml comments
|
929 |
$blocks = preg_split($split_regex, $text, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
930 |
foreach($blocks as $block) {
|
@@ -949,11 +949,11 @@ function qtranxf_split($text, $quicktags = true) {
|
|
949 |
$current_language = "";
|
950 |
continue;
|
951 |
// detect defective more tag
|
952 |
-
} elseif(preg_match("#^<!--more-->$#ism", $block, $matches)) {
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
}
|
958 |
// correctly categorize text block
|
959 |
if($current_language == "") {
|
@@ -966,11 +966,56 @@ function qtranxf_split($text, $quicktags = true) {
|
|
966 |
$result[$current_language] .= $block;
|
967 |
}
|
968 |
}
|
969 |
-
foreach($result as $lang => $lang_content) {
|
970 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
971 |
}
|
972 |
return $result;
|
973 |
}
|
|
|
974 |
|
975 |
function qtranxf_join($texts) {
|
976 |
global $q_config;
|
913 |
}
|
914 |
}
|
915 |
|
916 |
+
/*
|
917 |
function qtranxf_split($text, $quicktags = true) {
|
918 |
global $q_config;
|
|
|
919 |
//init vars
|
920 |
$split_regex = "#(<!--[^-]*-->|\[:[a-z]{2}\])#ism";
|
921 |
+
//$split_regex = "#(<!--:[[a-z]{2}]?-->|\[:[a-z]{2}\])#ism";
|
922 |
$current_language = "";
|
923 |
$result = array();
|
924 |
foreach($q_config['enabled_languages'] as $language) {
|
925 |
$result[$language] = "";
|
926 |
}
|
927 |
+
|
928 |
// split text at all xml comments
|
929 |
$blocks = preg_split($split_regex, $text, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
930 |
foreach($blocks as $block) {
|
949 |
$current_language = "";
|
950 |
continue;
|
951 |
// detect defective more tag
|
952 |
+
//} elseif(preg_match("#^<!--more-->$#ism", $block, $matches)) {
|
953 |
+
// foreach($q_config['enabled_languages'] as $language) {
|
954 |
+
// $result[$language] .= $block;
|
955 |
+
// }
|
956 |
+
// continue;
|
957 |
}
|
958 |
// correctly categorize text block
|
959 |
if($current_language == "") {
|
966 |
$result[$current_language] .= $block;
|
967 |
}
|
968 |
}
|
969 |
+
//foreach($result as $lang => $lang_content) {
|
970 |
+
// $result[$lang] = preg_replace("#(<!--more-->|<!--nextpage-->)+$#ism","",$lang_content);
|
971 |
+
//}
|
972 |
+
return $result;
|
973 |
+
}// */
|
974 |
+
|
975 |
+
if (!function_exists('qtranxf_split')){
|
976 |
+
function qtranxf_split($text, $quicktags = true) {
|
977 |
+
global $q_config;
|
978 |
+
//$split_regex = "#(<!--[^-]*-->|\[:[a-z]{2}\])#ism";
|
979 |
+
$split_regex = "#(<!--:[a-z]{2}-->|<!--:-->|\[:[a-z]{2}\])#ism";
|
980 |
+
$result = array();
|
981 |
+
foreach($q_config['enabled_languages'] as $language) {
|
982 |
+
$result[$language] = '';
|
983 |
+
}
|
984 |
+
// split text at all language comments and quick tags
|
985 |
+
$blocks = preg_split($split_regex, $text, -1, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
|
986 |
+
if(count($blocks)==1){
|
987 |
+
$block=$blocks[0];
|
988 |
+
//no languages, put it in all languages then
|
989 |
+
foreach($q_config['enabled_languages'] as $language) {
|
990 |
+
$result[$language] = $block;
|
991 |
+
}
|
992 |
+
}else{
|
993 |
+
$current_language = false;
|
994 |
+
foreach($blocks as $block) {
|
995 |
+
# detect language tags
|
996 |
+
if(preg_match("#^<!--:([a-z]{2})-->$#ism", $block, $matches)) {
|
997 |
+
$current_language = $matches[1];
|
998 |
+
if(!qtranxf_isEnabled($current_language)) $current_language = false;
|
999 |
+
continue;
|
1000 |
+
// detect quicktags
|
1001 |
+
} elseif($quicktags && preg_match("#^\[:([a-z]{2})\]$#ism", $block, $matches)) {
|
1002 |
+
$current_language = $matches[1];
|
1003 |
+
if(!qtranxf_isEnabled($current_language)) $current_language = false;
|
1004 |
+
continue;
|
1005 |
+
// detect ending tags
|
1006 |
+
} elseif(preg_match("#^<!--:-->$#ism", $block, $matches)) {
|
1007 |
+
$current_language = false;
|
1008 |
+
continue;
|
1009 |
+
}
|
1010 |
+
// correctly categorize text block
|
1011 |
+
if(!$current_language) continue;
|
1012 |
+
$result[$current_language] .= $block;
|
1013 |
+
$current_language = false;
|
1014 |
+
}
|
1015 |
}
|
1016 |
return $result;
|
1017 |
}
|
1018 |
+
}
|
1019 |
|
1020 |
function qtranxf_join($texts) {
|
1021 |
global $q_config;
|
qtranslate_hooks.php
CHANGED
@@ -73,18 +73,6 @@ function qtranxf_excludePages($pages) {
|
|
73 |
return array_merge($exclude, $pages);
|
74 |
}
|
75 |
|
76 |
-
function qtranxf_links($links, $file){ // copied from Sociable Plugin
|
77 |
-
//Static so we don't call plugin_basename on every plugin row.
|
78 |
-
static $this_plugin;
|
79 |
-
if (!$this_plugin) $this_plugin = plugin_basename(dirname(__FILE__).'/qtranslate.php');
|
80 |
-
|
81 |
-
if ($file == $this_plugin){
|
82 |
-
$settings_link = '<a href="options-general.php?page=qtranslate-x">' . __('Settings', 'qtranslate') . '</a>';
|
83 |
-
array_unshift( $links, $settings_link ); // before other links
|
84 |
-
}
|
85 |
-
return $links;
|
86 |
-
}
|
87 |
-
|
88 |
function qtranxf_languageColumnHeader($columns){
|
89 |
$new_columns = array();
|
90 |
if(isset($columns['cb'])) $new_columns['cb'] = '';
|
@@ -286,8 +274,6 @@ add_filter('comment_notification_subject', 'qtranxf_useCurrentLanguageIfNotFound
|
|
286 |
// add_filter('the_editor', 'qtranxf_modifyRichEditor');
|
287 |
//add_filter('admin_footer', 'qtranxf_modifyExcerpt');
|
288 |
add_filter('bloginfo_url', 'qtranxf_convertBlogInfoURL',10,2);
|
289 |
-
add_filter('plugin_action_links', 'qtranxf_links', 10, 2);
|
290 |
-
add_filter('manage_language_columns', 'qtranxf_language_columns');
|
291 |
add_filter('core_version_check_locale', 'qtranxf_versionLocale');
|
292 |
add_filter('redirect_canonical', 'qtranxf_checkCanonical', 10, 2);
|
293 |
?>
|
73 |
return array_merge($exclude, $pages);
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
function qtranxf_languageColumnHeader($columns){
|
77 |
$new_columns = array();
|
78 |
if(isset($columns['cb'])) $new_columns['cb'] = '';
|
274 |
// add_filter('the_editor', 'qtranxf_modifyRichEditor');
|
275 |
//add_filter('admin_footer', 'qtranxf_modifyExcerpt');
|
276 |
add_filter('bloginfo_url', 'qtranxf_convertBlogInfoURL',10,2);
|
|
|
|
|
277 |
add_filter('core_version_check_locale', 'qtranxf_versionLocale');
|
278 |
add_filter('redirect_canonical', 'qtranxf_checkCanonical', 10, 2);
|
279 |
?>
|
qtranslate_utils.php
CHANGED
@@ -127,7 +127,7 @@ function qtranxf_startsWith($s, $n) {
|
|
127 |
function qtranxf_getAvailableLanguages($text) {
|
128 |
global $q_config;
|
129 |
$result = array();
|
130 |
-
|
131 |
foreach($content as $language => $lang_text) {
|
132 |
$lang_text = trim($lang_text);
|
133 |
if(!empty($lang_text)) $result[] = $language;
|
127 |
function qtranxf_getAvailableLanguages($text) {
|
128 |
global $q_config;
|
129 |
$result = array();
|
130 |
+
$content = qtranxf_split($text);
|
131 |
foreach($content as $language => $lang_text) {
|
132 |
$lang_text = trim($lang_text);
|
133 |
if(!empty($lang_text)) $result[] = $language;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.
|
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
|
@@ -28,9 +28,10 @@ qTranslate-X makes creation of multilingual content as easy as working with a si
|
|
28 |
- Choose one of 3 Modes to make your URLs look pretty and SEO-friendly. - The simple and beautiful `/en/foo/`, or nice and neat `en.yoursite.com`, and everywhere compatible `?lang=en`.
|
29 |
- One language for each URL - Users and SEO will thank you for not mixing multilingual content.
|
30 |
- qTranslate-X supports unlimited number of languages, which can be easily added/modified/deleted via a comfortable Configuration Page at Settings->Languages.
|
31 |
-
- You may use [Google XML Sitemaps v3 for qTranslate](https://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/) plugin to rebuild your XML sitemap for better SEO support.
|
32 |
- Custom CSS for "qTranslate Language Chooser" widget configurable via its properties.
|
33 |
- Menu item "Language Switcher" to enable language choosing from a menu.
|
|
|
|
|
34 |
|
35 |
You may still find a lot of useful information through reading [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin")'s original documentation, which is not duplicated here in full. There are also other plugins, which offer multilingual support, but it seems that Qian Qin has very good original back-end design, and many people have been pleasantly using his plugin ever since. It stores all translations in the same single post, which makes it easy to maintain and to use it with other plugins. However, the user interface of former qTranslate got out of sync with the recent versions of Wordpress, especially after WP went to TinyMCE 4. There is a number of forks of qTranslate, see for example, [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate plugin"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus plugin") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate plugin"). They all try to fix qTranslate's user interface preserving its original back-end, which is what this plugin does too. This plugin is a hybrid of all of them and fixes a few bugs in each of them. It also has many new features too, like theme custom translatable fields, for example. We hope that this plugin is the most complete working version which combines the best features of [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin"), [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate fork"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus fork") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate fork").
|
36 |
|
@@ -104,6 +105,14 @@ The following query options can be typed in the field "URL" of "Language Menu" c
|
|
104 |
|
105 |
We understand that this is not a very user-friendly way to adjust the options, but it works, and we will provide a better in-editor interface to specify them in the future.
|
106 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
107 |
= How do I customize images for flags? =
|
108 |
|
109 |
If you wish to use different flag images, point option "Flag Image Path" to your own folder, containing custom images outside of "plugins" or "themes" folders. Most people would put it somewhere under "uploads" folder.
|
@@ -141,6 +150,9 @@ One can find the original qTranslate FAQ [here](https://wordpress.org/plugins/qt
|
|
141 |
|
142 |
== Changelog ==
|
143 |
|
|
|
|
|
|
|
144 |
= 2.9.4 =
|
145 |
* fix for https://wordpress.org/support/topic/comment-shows-404-error
|
146 |
|
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.5
|
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
|
28 |
- Choose one of 3 Modes to make your URLs look pretty and SEO-friendly. - The simple and beautiful `/en/foo/`, or nice and neat `en.yoursite.com`, and everywhere compatible `?lang=en`.
|
29 |
- One language for each URL - Users and SEO will thank you for not mixing multilingual content.
|
30 |
- qTranslate-X supports unlimited number of languages, which can be easily added/modified/deleted via a comfortable Configuration Page at Settings->Languages.
|
|
|
31 |
- Custom CSS for "qTranslate Language Chooser" widget configurable via its properties.
|
32 |
- Menu item "Language Switcher" to enable language choosing from a menu.
|
33 |
+
- Use [Google XML Sitemaps v3 for qTranslate](https://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/) plugin to rebuild your XML sitemap for better SEO support.
|
34 |
+
- Use plugin [Qtranslate Slug](https://wordpress.org/plugins/qtranslate-slug/) if you need to translate slugs.
|
35 |
|
36 |
You may still find a lot of useful information through reading [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin")'s original documentation, which is not duplicated here in full. There are also other plugins, which offer multilingual support, but it seems that Qian Qin has very good original back-end design, and many people have been pleasantly using his plugin ever since. It stores all translations in the same single post, which makes it easy to maintain and to use it with other plugins. However, the user interface of former qTranslate got out of sync with the recent versions of Wordpress, especially after WP went to TinyMCE 4. There is a number of forks of qTranslate, see for example, [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate plugin"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus plugin") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate plugin"). They all try to fix qTranslate's user interface preserving its original back-end, which is what this plugin does too. This plugin is a hybrid of all of them and fixes a few bugs in each of them. It also has many new features too, like theme custom translatable fields, for example. We hope that this plugin is the most complete working version which combines the best features of [qTranslate](https://wordpress.org/plugins/qtranslate/ "Original qTranslate plugin"), [mqTranslate](https://wordpress.org/plugins/mqtranslate/ "mqTranslate fork"), [qTranslate Plus](https://wordpress.org/plugins/qtranslate-xp/ "qTranslate Plus fork") and [zTranslate](https://wordpress.org/plugins/ztranslate/ "zTranslate fork").
|
37 |
|
105 |
|
106 |
We understand that this is not a very user-friendly way to adjust the options, but it works, and we will provide a better in-editor interface to specify them in the future.
|
107 |
|
108 |
+
= Can I translate slugs? =
|
109 |
+
|
110 |
+
Use plugin [Qtranslate Slug](https://wordpress.org/plugins/qtranslate-slug/).
|
111 |
+
|
112 |
+
= Can I build Google XML Sitemap, including pages with all different languages? =
|
113 |
+
|
114 |
+
Use plugin [Google XML Sitemaps v3 for qTranslate](https://wordpress.org/plugins/google-xml-sitemaps-v3-for-qtranslate/)
|
115 |
+
|
116 |
= How do I customize images for flags? =
|
117 |
|
118 |
If you wish to use different flag images, point option "Flag Image Path" to your own folder, containing custom images outside of "plugins" or "themes" folders. Most people would put it somewhere under "uploads" folder.
|
150 |
|
151 |
== Changelog ==
|
152 |
|
153 |
+
= 2.9.5 =
|
154 |
+
* more fixes for <!--more--> and <!--nextpage--> tags.
|
155 |
+
|
156 |
= 2.9.4 =
|
157 |
* fix for https://wordpress.org/support/topic/comment-shows-404-error
|
158 |
|