Version Description
(29/08/2018) = * Add DOM checker for button value and data-value attribute * Update setting page * Bugfix : email translation * Bugfix : external link with quickpay * Prevent auto redirect on homepage translate
Download this release
Release Info
Developer | remyb92 |
Plugin | Weglot Translate – Translate your WP website |
Version | 2.0.6 |
Comparing to | |
See all releases |
Code changes from version 2.0.3 to 2.0.6
- app/javascripts/admin-button-preview.js +18 -9
- app/javascripts/admin-check-api-key.js +7 -1
- app/javascripts/admin-prevent-save-form.js +2 -1
- app/javascripts/admin-select.js +78 -52
- app/styles/admin.scss +16 -3
- dist/admin-js.js +1 -1
- dist/css/admin-css.css +14 -4
- readme.txt +18 -1
- src/actions/admin/class-admin-enqueue-weglot.php +10 -9
- src/actions/admin/class-customize-menu-weglot.php +4 -0
- src/actions/admin/class-options-weglot.php +9 -8
- src/actions/class-email-translate-weglot.php +4 -1
- src/actions/front/class-translate-page-weglot.php +41 -16
- src/domcheckers/class-button-data-value.php +28 -0
- src/domcheckers/class-button-value.php +28 -0
- src/helpers/class-helper-tabs-admin-weglot.php +2 -22
- src/services/class-button-service-weglot.php +27 -7
- src/services/class-dom-checkers-service-weglot.php +2 -8
- src/services/class-language-service-weglot.php +37 -7
- src/services/class-option-service-weglot.php +10 -0
- src/services/class-other-translate-service-weglot.php +1 -0
- src/services/class-redirect-service-weglot.php +3 -3
- src/services/class-replace-link-service-weglot.php +9 -3
- src/services/class-request-url-service-weglot.php +26 -7
- src/services/class-user-api-service-weglot.php +34 -6
- src/third/woocommerce/class-wc-filter-urls-weglot.php +11 -5
- templates/admin/pages/settings.php +13 -12
- templates/admin/pages/tabs/advanced.php +108 -0
- templates/admin/pages/tabs/appearance.php +4 -0
- templates/admin/pages/tabs/settings.php +29 -120
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +7 -7
- vendor/composer/autoload_static.php +4 -4
- vendor/composer/installed.json +6 -6
- vendor/weglot/simplehtmldom/README.md +23 -0
- vendor/weglot/weglot-php/CHANGELOG.md +7 -0
- vendor/weglot/weglot-php/src/Client/Client.php +1 -1
- vendor/weglot/weglot-php/src/Client/Endpoint/Translate.php +4 -5
- vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php +4 -6
- weglot-functions.php +39 -3
- weglot.php +3 -3
app/javascripts/admin-button-preview.js
CHANGED
@@ -36,28 +36,34 @@ const init_admin_button_preview = function () {
|
|
36 |
old_type_flags = new_type_flags;
|
37 |
});
|
38 |
|
39 |
-
const
|
40 |
const label_language = weglot_desination_languages.find(
|
41 |
(itm) => itm.code === $(".country-selector label").data("code-language")
|
42 |
);
|
|
|
43 |
|
44 |
-
|
|
|
|
|
45 |
|
46 |
$(".country-selector li").each((key, itm) => {
|
47 |
const li_language = weglot_desination_languages.find(
|
48 |
(lang) => lang.code === $(itm).data("code-language")
|
49 |
);
|
50 |
|
51 |
-
|
|
|
|
|
|
|
|
|
52 |
})
|
53 |
}
|
54 |
|
55 |
// Change with name
|
56 |
$("#with_name").on("change", function(e) {
|
57 |
-
if(e.target.checked){
|
58 |
-
|
59 |
-
}
|
60 |
-
else{
|
61 |
$(".country-selector label a, .country-selector label span").text("");
|
62 |
$(".country-selector li a, .country-selector li span").each(
|
63 |
(key, itm) => {
|
@@ -70,9 +76,12 @@ const init_admin_button_preview = function () {
|
|
70 |
|
71 |
|
72 |
$("#is_fullname").on("change", function(e){
|
73 |
-
if (
|
74 |
-
|
|
|
75 |
|
|
|
|
|
76 |
}
|
77 |
else {
|
78 |
const label_language = weglot_desination_languages.find(itm => itm.code === $(".country-selector label").data("code-language"));
|
36 |
old_type_flags = new_type_flags;
|
37 |
});
|
38 |
|
39 |
+
const set_languages = () => {
|
40 |
const label_language = weglot_desination_languages.find(
|
41 |
(itm) => itm.code === $(".country-selector label").data("code-language")
|
42 |
);
|
43 |
+
const is_fullname = $("#is_fullname").is(":checked");
|
44 |
|
45 |
+
const label = is_fullname ? label_language.local : label_language.code.toUpperCase();
|
46 |
+
|
47 |
+
$(".country-selector label a, .country-selector label span").text(label);
|
48 |
|
49 |
$(".country-selector li").each((key, itm) => {
|
50 |
const li_language = weglot_desination_languages.find(
|
51 |
(lang) => lang.code === $(itm).data("code-language")
|
52 |
);
|
53 |
|
54 |
+
const label = is_fullname ? li_language.local : li_language.code.toUpperCase();
|
55 |
+
|
56 |
+
$(itm)
|
57 |
+
.find("a")
|
58 |
+
.text(label);
|
59 |
})
|
60 |
}
|
61 |
|
62 |
// Change with name
|
63 |
$("#with_name").on("change", function(e) {
|
64 |
+
if (e.target.checked) {
|
65 |
+
set_languages();
|
66 |
+
} else {
|
|
|
67 |
$(".country-selector label a, .country-selector label span").text("");
|
68 |
$(".country-selector li a, .country-selector li span").each(
|
69 |
(key, itm) => {
|
76 |
|
77 |
|
78 |
$("#is_fullname").on("change", function(e){
|
79 |
+
if ( !$("#with_name").is(":checked") ) {
|
80 |
+
return
|
81 |
+
}
|
82 |
|
83 |
+
if (e.target.checked) {
|
84 |
+
set_languages();
|
85 |
}
|
86 |
else {
|
87 |
const label_language = weglot_desination_languages.find(itm => itm.code === $(".country-selector label").data("code-language"));
|
app/javascripts/admin-check-api-key.js
CHANGED
@@ -13,7 +13,7 @@ const init_admin_button_preview = function () {
|
|
13 |
}
|
14 |
$.getJSON(
|
15 |
"https://weglot.com/api/user-info?api_key=" + key,
|
16 |
-
|
17 |
$(".weglot-keyres").remove();
|
18 |
$("#api_key").after(
|
19 |
'<span class="weglot-keyres weglot-okkey"></span>'
|
@@ -22,6 +22,12 @@ const init_admin_button_preview = function () {
|
|
22 |
"disabled",
|
23 |
false
|
24 |
);
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
).fail(function() {
|
27 |
$(".weglot-keyres").remove();
|
13 |
}
|
14 |
$.getJSON(
|
15 |
"https://weglot.com/api/user-info?api_key=" + key,
|
16 |
+
(data) => {
|
17 |
$(".weglot-keyres").remove();
|
18 |
$("#api_key").after(
|
19 |
'<span class="weglot-keyres weglot-okkey"></span>'
|
22 |
"disabled",
|
23 |
false
|
24 |
);
|
25 |
+
|
26 |
+
const evt = new CustomEvent("weglotCheckApi", {
|
27 |
+
detail: data
|
28 |
+
});
|
29 |
+
|
30 |
+
window.dispatchEvent(evt);
|
31 |
}
|
32 |
).fail(function() {
|
33 |
$(".weglot-keyres").remove();
|
app/javascripts/admin-prevent-save-form.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
const init_prevent_save_form = function () {
|
2 |
-
|
3 |
const $ = jQuery
|
4 |
|
5 |
const execute = () => {
|
@@ -25,6 +25,7 @@ const init_prevent_save_form = function () {
|
|
25 |
document.addEventListener('DOMContentLoaded', () => {
|
26 |
execute();
|
27 |
})
|
|
|
28 |
}
|
29 |
|
30 |
export default init_prevent_save_form;
|
1 |
const init_prevent_save_form = function () {
|
2 |
+
/* TODO : remove file
|
3 |
const $ = jQuery
|
4 |
|
5 |
const execute = () => {
|
25 |
document.addEventListener('DOMContentLoaded', () => {
|
26 |
execute();
|
27 |
})
|
28 |
+
*/
|
29 |
}
|
30 |
|
31 |
export default init_prevent_save_form;
|
app/javascripts/admin-select.js
CHANGED
@@ -1,65 +1,35 @@
|
|
1 |
const init_admin_select = function(){
|
2 |
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
let destination_selectize
|
11 |
-
|
12 |
-
const execute = () => {
|
13 |
-
$(".weglot-select-original").selectize({
|
14 |
-
delimiter: "|",
|
15 |
-
persist: false,
|
16 |
-
valueField: "code",
|
17 |
-
labelField: "local",
|
18 |
-
searchField: ["code", "english", "local"],
|
19 |
-
sortField: [
|
20 |
-
{ field: "code", direction: "asc" },
|
21 |
-
{ field: "english", direction: "asc" }
|
22 |
-
],
|
23 |
-
maxItems: 1,
|
24 |
-
plugins: ["remove_button"],
|
25 |
-
options: weglot_languages.available,
|
26 |
-
onChange: value => {
|
27 |
-
if(value.length > 0){
|
28 |
-
destination_selectize.data('selectize').clearOptions()
|
29 |
-
|
30 |
-
destination_selectize
|
31 |
-
.data("selectize")
|
32 |
-
.addOption(weglot_languages.available.filter(itm => {
|
33 |
-
return itm.code !== value
|
34 |
-
}));
|
35 |
-
}
|
36 |
-
}
|
37 |
-
});
|
38 |
|
|
|
39 |
|
40 |
-
|
41 |
-
|
|
|
42 |
delimiter: "|",
|
43 |
persist: false,
|
44 |
valueField: "code",
|
45 |
labelField: "local",
|
46 |
searchField: ["code", "english", "local"],
|
47 |
-
sortField: [
|
48 |
-
{ field: "code", direction: "asc" },
|
49 |
-
{ field: "english", direction: "asc" }
|
50 |
-
],
|
51 |
maxItems: weglot_languages.limit,
|
52 |
-
plugins: ["remove_button"],
|
53 |
options: generate_destination_language(),
|
54 |
render: {
|
55 |
option: function(item, escape) {
|
56 |
return (
|
57 |
'<div class="weglot__choice__language">' +
|
58 |
-
'<span class="weglot__choice__language--local">' +
|
59 |
-
escape(item.local) +
|
60 |
-
"</span>" +
|
61 |
'<span class="weglot__choice__language--english">' +
|
62 |
escape(item.english) +
|
|
|
|
|
|
|
63 |
" [" +
|
64 |
escape(item.code) +
|
65 |
"]</span>" +
|
@@ -67,15 +37,71 @@ const init_admin_select = function(){
|
|
67 |
);
|
68 |
}
|
69 |
}
|
70 |
-
}
|
71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
|
73 |
-
}
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
79 |
|
80 |
export default init_admin_select;
|
81 |
-
|
1 |
const init_admin_select = function(){
|
2 |
|
3 |
+
const $ = jQuery
|
4 |
+
const generate_destination_language = () => {
|
5 |
+
return weglot_languages.available.filter(itm => {
|
6 |
+
return itm.code !== weglot_languages.original
|
7 |
+
});
|
8 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
+
let destination_selectize
|
11 |
|
12 |
+
const load_destination_selectize = () => {
|
13 |
+
destination_selectize = $(".weglot-select-destination")
|
14 |
+
.selectize({
|
15 |
delimiter: "|",
|
16 |
persist: false,
|
17 |
valueField: "code",
|
18 |
labelField: "local",
|
19 |
searchField: ["code", "english", "local"],
|
20 |
+
sortField: [{ field: "english", direction: "asc" }],
|
|
|
|
|
|
|
21 |
maxItems: weglot_languages.limit,
|
22 |
+
plugins: ["remove_button", "drag_drop"],
|
23 |
options: generate_destination_language(),
|
24 |
render: {
|
25 |
option: function(item, escape) {
|
26 |
return (
|
27 |
'<div class="weglot__choice__language">' +
|
|
|
|
|
|
|
28 |
'<span class="weglot__choice__language--english">' +
|
29 |
escape(item.english) +
|
30 |
+
"</span>" +
|
31 |
+
'<span class="weglot__choice__language--local">' +
|
32 |
+
escape(item.local) +
|
33 |
" [" +
|
34 |
escape(item.code) +
|
35 |
"]</span>" +
|
37 |
);
|
38 |
}
|
39 |
}
|
40 |
+
})
|
41 |
+
.on("change", (value) => {
|
42 |
+
const code_languages = destination_selectize[0].selectize.getValue()
|
43 |
+
const template = $("#li-button-tpl");
|
44 |
+
const is_fullname = $("#is_fullname").is(":checked")
|
45 |
+
const with_name = $("#with_name").is(":checked")
|
46 |
+
const with_flags = $("#with_flags").is(":checked")
|
47 |
+
|
48 |
+
let classes = ''
|
49 |
+
if (with_flags) {
|
50 |
+
classes = "weglot-flags";
|
51 |
+
}
|
52 |
+
|
53 |
+
let new_dest_language = ''
|
54 |
+
code_languages.forEach(element => {
|
55 |
+
const language = weglot_languages.available.find(itm => itm.code === element);
|
56 |
+
let label = ''
|
57 |
+
if(with_name){
|
58 |
+
if (is_fullname){
|
59 |
+
label = language.local
|
60 |
+
}
|
61 |
+
else{
|
62 |
+
label = element.toUpperCase()
|
63 |
+
}
|
64 |
+
}
|
65 |
|
|
|
66 |
|
67 |
+
new_dest_language += template
|
68 |
+
.html()
|
69 |
+
.replace("{LABEL_LANGUAGE}", label)
|
70 |
+
.replace(new RegExp("{CODE_LANGUAGE}", "g"), element)
|
71 |
+
.replace("{CLASSES}", classes)
|
72 |
+
|
73 |
+
|
74 |
+
});
|
75 |
+
$(".country-selector ul").html(new_dest_language)
|
76 |
+
});
|
77 |
+
}
|
78 |
+
|
79 |
+
const execute = () => {
|
80 |
+
|
81 |
+
load_destination_selectize();
|
82 |
+
|
83 |
+
window.addEventListener("weglotCheckApi", (data) => {
|
84 |
+
|
85 |
+
let limit = 1000
|
86 |
+
const plan = data.detail.answer.plan
|
87 |
+
|
88 |
+
if (
|
89 |
+
plan <= 0 ||
|
90 |
+
weglot_languages.plans.starter_free.ids.indexOf(plan) >= 0
|
91 |
+
) {
|
92 |
+
limit = weglot_languages.plans.starter_free.limit_language;
|
93 |
+
} else if( weglot_languages.plans.business.ids.indexOf(plan) >= 0 ) {
|
94 |
+
limit = weglot_languages.plans.business.limit_language;
|
95 |
+
}
|
96 |
+
|
97 |
+
destination_selectize[0].selectize.settings.maxItems = limit
|
98 |
+
});
|
99 |
+
|
100 |
+
}
|
101 |
+
|
102 |
+
document.addEventListener('DOMContentLoaded', () => {
|
103 |
+
execute();
|
104 |
+
})
|
105 |
}
|
106 |
|
107 |
export default init_admin_select;
|
|
app/styles/admin.scss
CHANGED
@@ -4,9 +4,9 @@
|
|
4 |
.weglot__choice__language{
|
5 |
border-bottom:1px solid #eee;
|
6 |
margin:5px 0px;
|
7 |
-
&--
|
8 |
border-width:50px;
|
9 |
-
color
|
10 |
display:block;
|
11 |
}
|
12 |
}
|
@@ -87,6 +87,10 @@ input[type='text'],textarea {
|
|
87 |
margin: 2px 0 0;
|
88 |
}
|
89 |
|
|
|
|
|
|
|
|
|
90 |
.original-select,
|
91 |
#type_flags {
|
92 |
padding: 8px;
|
@@ -129,6 +133,7 @@ input[type="text"], .wg-input-textarea {
|
|
129 |
padding:0 10px;
|
130 |
}
|
131 |
display:flex;
|
|
|
132 |
.wrap {
|
133 |
flex: 4;
|
134 |
}
|
@@ -175,7 +180,8 @@ input[type="text"], .wg-input-textarea {
|
|
175 |
|
176 |
.selectize-control,
|
177 |
input[type="text"],
|
178 |
-
.wg-input-textarea
|
|
|
179 |
width : 100%;
|
180 |
max-width: 300px;
|
181 |
}
|
@@ -213,6 +219,13 @@ input[type="text"], .wg-input-textarea {
|
|
213 |
font-size : 17px;
|
214 |
}
|
215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
}
|
217 |
|
218 |
|
4 |
.weglot__choice__language{
|
5 |
border-bottom:1px solid #eee;
|
6 |
margin:5px 0px;
|
7 |
+
&--local{
|
8 |
border-width:50px;
|
9 |
+
color: #a6a6a6;
|
10 |
display:block;
|
11 |
}
|
12 |
}
|
87 |
margin: 2px 0 0;
|
88 |
}
|
89 |
|
90 |
+
.weglot-select-original {
|
91 |
+
height : 36px!important;
|
92 |
+
margin : 0;
|
93 |
+
}
|
94 |
.original-select,
|
95 |
#type_flags {
|
96 |
padding: 8px;
|
133 |
padding:0 10px;
|
134 |
}
|
135 |
display:flex;
|
136 |
+
margin-left: 15px;
|
137 |
.wrap {
|
138 |
flex: 4;
|
139 |
}
|
180 |
|
181 |
.selectize-control,
|
182 |
input[type="text"],
|
183 |
+
.wg-input-textarea,
|
184 |
+
.weglot-select-original{
|
185 |
width : 100%;
|
186 |
max-width: 300px;
|
187 |
}
|
219 |
font-size : 17px;
|
220 |
}
|
221 |
|
222 |
+
.form-table {
|
223 |
+
margin-bottom: 50px;
|
224 |
+
}
|
225 |
+
.country-selector {
|
226 |
+
z-index: 1!important;
|
227 |
+
}
|
228 |
+
|
229 |
}
|
230 |
|
231 |
|
dist/admin-js.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
!function(e){var t={};function o(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,l){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:l})},o.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=0)}([function(e,t,o){"use strict";o.r(t);var l=function(){const e=jQuery;let t;const o=()=>{e(".weglot-select-original").selectize({delimiter:"|",persist:!1,valueField:"code",labelField:"local",searchField:["code","english","local"],sortField:[{field:"code",direction:"asc"},{field:"english",direction:"asc"}],maxItems:1,plugins:["remove_button"],options:weglot_languages.available,onChange:e=>{e.length>0&&(t.data("selectize").clearOptions(),t.data("selectize").addOption(weglot_languages.available.filter(t=>t.code!==e)))}}),t=e(".weglot-select-destination").selectize({delimiter:"|",persist:!1,valueField:"code",labelField:"local",searchField:["code","english","local"],sortField:[{field:"code",direction:"asc"},{field:"english",direction:"asc"}],maxItems:weglot_languages.limit,plugins:["remove_button"],options:(()=>weglot_languages.available.filter(e=>e.code!==weglot_languages.original))(),render:{option:function(e,t){return'<div class="weglot__choice__language"><span class="weglot__choice__language--local">'+t(e.local)+'</span><span class="weglot__choice__language--english">'+t(e.english)+" ["+t(e.code)+"]</span></div>"}}})};document.addEventListener("DOMContentLoaded",()=>{o()})};var a=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{e("#weglot-box-first-settings .weglot-btn-close").on("click",function(t){t.preventDefault(),e("#weglot-box-first-settings").hide()})})};var n=function(){jQuery;const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),l=document.querySelector("#container-exclude_blocks");function a(e){e.preventDefault(),this.parentNode.remove()}document.querySelector("#js-add-exclude-url")&&document.querySelector("#js-add-exclude-url").addEventListener("click",t=>{t.preventDefault(),o.insertAdjacentHTML("beforeend",e.innerHTML),document.querySelector("#container-exclude_urls .item-exclude:last-child .js-btn-remove").addEventListener("click",a)}),document.querySelector("#js-add-exclude-block")&&document.querySelector("#js-add-exclude-block").addEventListener("click",e=>{e.preventDefault(),l.insertAdjacentHTML("beforeend",t.innerHTML),document.querySelector("#container-exclude_blocks .item-exclude:last-child .js-btn-remove-exclude").addEventListener("click",a)}),document.querySelectorAll(".js-btn-remove").forEach(e=>{e.addEventListener("click",a)})};document.addEventListener("DOMContentLoaded",()=>{e()})};var r=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{0!==e(".weglot-preview").length&&(()=>{let t=e("#type_flags").val(),o=[];o.push(e(".country-selector label").data("code-language")),e(".country-selector li").each((t,l)=>{o.push(e(l).data("code-language"))});const l=weglot_languages.available.filter(e=>o.indexOf(e.code)>=0);e("#weglot-css-inline").text(weglot_css.inline),e("#is_dropdown").on("change",function(){e(".country-selector").toggleClass("weglot-inline"),e(".country-selector").toggleClass("weglot-dropdown")}),e("#with_flags").on("change",function(){e(".country-selector label, .country-selector li").toggleClass("weglot-flags")}),e("#type_flags").on("change",function(o){e(".country-selector label, .country-selector li").removeClass(`flag-${t}`);const l=o.target.value;e(".country-selector label, .country-selector li").addClass(`flag-${l}`),t=l});const a=()=>{const t=l.find(t=>t.code===e(".country-selector label").data("code-language"));e(".country-selector label a, .country-selector label span").text(t.local),e(".country-selector li").each((t,o)=>{const a=l.find(t=>t.code===e(o).data("code-language"));e(o).find("a").text(a.local)})};e("#with_name").on("change",function(t){t.target.checked?a():(e(".country-selector label a, .country-selector label span").text(""),e(".country-selector li a, .country-selector li span").each((t,o)=>{e(o).text("")}))}),e("#is_fullname").on("change",function(t){if(t.target.checked)a();else{const t=l.find(t=>t.code===e(".country-selector label").data("code-language"));e(".country-selector label a, .country-selector label span").text(t.code.toUpperCase()),e(".country-selector li").each((t,o)=>{const a=l.find(t=>t.code===e(o).data("code-language"));e(o).find("a").text(a.code.toUpperCase()),e(o).find("span").text(a.code.toUpperCase())})}}),e("#override_css").on("keyup",function(t){e("#weglot-css-inline").text(t.target.value)})})()})};var s=function(){const e=jQuery,t=()=>{e("#api_key").blur(function(){var t=e(this).val();if(0===t.length)return e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-nokkey"></span>'),void e("#wrap-weglot #submit").prop("disabled",!0);e.getJSON("https://weglot.com/api/user-info?api_key="+t,function(t){e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-okkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!1)}).fail(function(){e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-nokkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!0)})})};document.addEventListener("DOMContentLoaded",()=>{t()})};var c=function(){const e=jQuery;"undefined"!=typeof weglot_css&&e("#weglot-css-flag-css").text(weglot_css.flag_css);const t=()=>{e(".flag-style-openclose").on("click",function(){e(".flag-style-wrapper").toggle()}),e("select.flag-en-type, select.flag-es-type, select.flag-pt-type, select.flag-fr-type, select.flag-ar-type").on("change",function(){!function(){var t=new Array,o=new Array,l=new Array,a=new Array,n=new Array;t[1]=[3570,7841,48,2712],t[2]=[3720,449,3048,4440],t[3]=[3840,1281,2712,4224],t[4]=[3240,5217,1224,2112],t[5]=[4050,3585,1944,2496],t[6]=[2340,3457,2016,2016],o[1]=[4320,4641,3144,3552],o[2]=[3750,353,2880,4656],o[3]=[4200,1601,2568,3192],o[4]=[3990,5793,1032,2232],o[5]=[5460,897,4104,3120],o[6]=[3810,7905,216,3888],o[7]=[3630,8065,192,2376],o[8]=[3780,1473,2496,4104],o[9]=[6120,2145,4680,2568],o[10]=[4440,3009,3240,1176],o[11]=[5280,1825,3936,2976],o[12]=[4770,2081,3624,1008],o[13]=[4080,3201,2160,2544],o[14]=[4590,5761,3432,624],o[15]=[4350,2209,3360,2688],o[16]=[5610,5249,3168,528],o[17]=[5070,1729,3792,2952],o[18]=[6870,5953,96,3408],o[19]=[4020,5697,1056,1224],l[1]=[1740,5921,528,3504],a[1]=[2760,736,2856,4416],a[2]=[3840,1280,2712,4224],a[3]=[5700,7201,5016,2400],a[4]=[2220,4160,1632,1944],n[1]=[1830,129,3096,5664],n[2]=[5100,2177,3840,2904],n[3]=[4890,3425,3648,2136],n[4]=[1320,3681,1896,4080],n[5]=[1260,3841,1824,1200],n[6]=[1020,3969,1608,312],n[7]=[4800,4065,3600,72],n[8]=[4710,4865,3504,480],n[9]=[6720,5984,5112,3792],n[10]=[4500,7233,3288,1800],n[11]=[720,7522,384,3936],n[12]=[690,7745,336,1104],n[13]=[600,8225,120,1272],n[14]=[660,5569,840,576];var r=e("select.flag-en-type").val(),s=e("select.flag-es-type").val(),c=e("select.flag-pt-type").val(),i=e("select.flag-fr-type").val(),g=e("select.flag-ar-type").val(),f=r<=0?"":".weglot-flags.en > a:before, .weglot-flags.en > span:before { background-position: -"+t[r][0]+"px 0; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+l[c][0]+"px 0; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+l[c][1]+"px 0; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+l[c][2]+"px 0; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+l[c][3]+"px 0; } ",p=i<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[i][0]+"px 0; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[i][1]+"px 0; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[i][2]+"px 0; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[i][3]+"px 0; } ",b=g<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+n[g][0]+"px 0; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+n[g][1]+"px 0; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+n[g][2]+"px 0; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+n[g][3]+"px 0; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+b)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var i=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{(()=>{let t=!1;e(document).on({change:()=>t=!0,keyup:()=>t=!0},"input[type='text'], select, textarea, input[type='checkbox']"),e("input[type='submit']").on("click",e=>{t=!1}),window.onbeforeunload=function(){if(t)return"You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your unsaved changes"}})()})};o(2),o(1);l(),n(),a(),r(),s(),c(),i()},function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var o=this.length>>>0,l=new Array(o),a=this,n=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(l[n++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(l[n++]=a[r]);return l.length=n,l})},function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var l=arguments[1],a=0;a<o;){var n=t[a];if(e.call(l,n,a,t))return n;a++}},configurable:!0,writable:!0})}]);
|
1 |
+
!function(e){var t={};function o(l){if(t[l])return t[l].exports;var a=t[l]={i:l,l:!1,exports:{}};return e[l].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,l){o.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:l})},o.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="/dist/",o(o.s=0)}([function(e,t,o){"use strict";o.r(t);var l=function(){const e=jQuery;let t;const o=()=>{t=e(".weglot-select-destination").selectize({delimiter:"|",persist:!1,valueField:"code",labelField:"local",searchField:["code","english","local"],sortField:[{field:"english",direction:"asc"}],maxItems:weglot_languages.limit,plugins:["remove_button","drag_drop"],options:(()=>weglot_languages.available.filter(e=>e.code!==weglot_languages.original))(),render:{option:function(e,t){return'<div class="weglot__choice__language"><span class="weglot__choice__language--english">'+t(e.english)+'</span><span class="weglot__choice__language--local">'+t(e.local)+" ["+t(e.code)+"]</span></div>"}}}).on("change",o=>{const l=t[0].selectize.getValue(),a=e("#li-button-tpl"),n=e("#is_fullname").is(":checked"),r=e("#with_name").is(":checked");let s="";e("#with_flags").is(":checked")&&(s="weglot-flags");let c="";l.forEach(e=>{const t=weglot_languages.available.find(t=>t.code===e);let o="";r&&(o=n?t.local:e.toUpperCase()),c+=a.html().replace("{LABEL_LANGUAGE}",o).replace(new RegExp("{CODE_LANGUAGE}","g"),e).replace("{CLASSES}",s)}),e(".country-selector ul").html(c)})};document.addEventListener("DOMContentLoaded",()=>{o(),window.addEventListener("weglotCheckApi",e=>{let o=1e3;const l=e.detail.answer.plan;l<=0||weglot_languages.plans.starter_free.ids.indexOf(l)>=0?o=weglot_languages.plans.starter_free.limit_language:weglot_languages.plans.business.ids.indexOf(l)>=0&&(o=weglot_languages.plans.business.limit_language),t[0].selectize.settings.maxItems=o})})};var a=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{e("#weglot-box-first-settings .weglot-btn-close").on("click",function(t){t.preventDefault(),e("#weglot-box-first-settings").hide()})})};var n=function(){jQuery;const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),l=document.querySelector("#container-exclude_blocks");function a(e){e.preventDefault(),this.parentNode.remove()}document.querySelector("#js-add-exclude-url")&&document.querySelector("#js-add-exclude-url").addEventListener("click",t=>{t.preventDefault(),o.insertAdjacentHTML("beforeend",e.innerHTML),document.querySelector("#container-exclude_urls .item-exclude:last-child .js-btn-remove").addEventListener("click",a)}),document.querySelector("#js-add-exclude-block")&&document.querySelector("#js-add-exclude-block").addEventListener("click",e=>{e.preventDefault(),l.insertAdjacentHTML("beforeend",t.innerHTML),document.querySelector("#container-exclude_blocks .item-exclude:last-child .js-btn-remove-exclude").addEventListener("click",a)}),document.querySelectorAll(".js-btn-remove").forEach(e=>{e.addEventListener("click",a)})};document.addEventListener("DOMContentLoaded",()=>{e()})};var r=function(){const e=jQuery;document.addEventListener("DOMContentLoaded",()=>{0!==e(".weglot-preview").length&&(()=>{let t=e("#type_flags").val(),o=[];o.push(e(".country-selector label").data("code-language")),e(".country-selector li").each((t,l)=>{o.push(e(l).data("code-language"))});const l=weglot_languages.available.filter(e=>o.indexOf(e.code)>=0);e("#weglot-css-inline").text(weglot_css.inline),e("#is_dropdown").on("change",function(){e(".country-selector").toggleClass("weglot-inline"),e(".country-selector").toggleClass("weglot-dropdown")}),e("#with_flags").on("change",function(){e(".country-selector label, .country-selector li").toggleClass("weglot-flags")}),e("#type_flags").on("change",function(o){e(".country-selector label, .country-selector li").removeClass(`flag-${t}`);const l=o.target.value;e(".country-selector label, .country-selector li").addClass(`flag-${l}`),t=l});const a=()=>{const t=l.find(t=>t.code===e(".country-selector label").data("code-language")),o=e("#is_fullname").is(":checked"),a=o?t.local:t.code.toUpperCase();e(".country-selector label a, .country-selector label span").text(a),e(".country-selector li").each((t,a)=>{const n=l.find(t=>t.code===e(a).data("code-language")),r=o?n.local:n.code.toUpperCase();e(a).find("a").text(r)})};e("#with_name").on("change",function(t){t.target.checked?a():(e(".country-selector label a, .country-selector label span").text(""),e(".country-selector li a, .country-selector li span").each((t,o)=>{e(o).text("")}))}),e("#is_fullname").on("change",function(t){if(e("#with_name").is(":checked"))if(t.target.checked)a();else{const t=l.find(t=>t.code===e(".country-selector label").data("code-language"));e(".country-selector label a, .country-selector label span").text(t.code.toUpperCase()),e(".country-selector li").each((t,o)=>{const a=l.find(t=>t.code===e(o).data("code-language"));e(o).find("a").text(a.code.toUpperCase()),e(o).find("span").text(a.code.toUpperCase())})}}),e("#override_css").on("keyup",function(t){e("#weglot-css-inline").text(t.target.value)})})()})};var s=function(){const e=jQuery,t=()=>{e("#api_key").blur(function(){var t=e(this).val();if(0===t.length)return e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-nokkey"></span>'),void e("#wrap-weglot #submit").prop("disabled",!0);e.getJSON("https://weglot.com/api/user-info?api_key="+t,t=>{e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-okkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!1);const o=new CustomEvent("weglotCheckApi",{detail:t});window.dispatchEvent(o)}).fail(function(){e(".weglot-keyres").remove(),e("#api_key").after('<span class="weglot-keyres weglot-nokkey"></span>'),e("#wrap-weglot #submit").prop("disabled",!0)})})};document.addEventListener("DOMContentLoaded",()=>{t()})};var c=function(){const e=jQuery;"undefined"!=typeof weglot_css&&e("#weglot-css-flag-css").text(weglot_css.flag_css);const t=()=>{e(".flag-style-openclose").on("click",function(){e(".flag-style-wrapper").toggle()}),e("select.flag-en-type, select.flag-es-type, select.flag-pt-type, select.flag-fr-type, select.flag-ar-type").on("change",function(){!function(){var t=new Array,o=new Array,l=new Array,a=new Array,n=new Array;t[1]=[3570,7841,48,2712],t[2]=[3720,449,3048,4440],t[3]=[3840,1281,2712,4224],t[4]=[3240,5217,1224,2112],t[5]=[4050,3585,1944,2496],t[6]=[2340,3457,2016,2016],o[1]=[4320,4641,3144,3552],o[2]=[3750,353,2880,4656],o[3]=[4200,1601,2568,3192],o[4]=[3990,5793,1032,2232],o[5]=[5460,897,4104,3120],o[6]=[3810,7905,216,3888],o[7]=[3630,8065,192,2376],o[8]=[3780,1473,2496,4104],o[9]=[6120,2145,4680,2568],o[10]=[4440,3009,3240,1176],o[11]=[5280,1825,3936,2976],o[12]=[4770,2081,3624,1008],o[13]=[4080,3201,2160,2544],o[14]=[4590,5761,3432,624],o[15]=[4350,2209,3360,2688],o[16]=[5610,5249,3168,528],o[17]=[5070,1729,3792,2952],o[18]=[6870,5953,96,3408],o[19]=[4020,5697,1056,1224],l[1]=[1740,5921,528,3504],a[1]=[2760,736,2856,4416],a[2]=[3840,1280,2712,4224],a[3]=[5700,7201,5016,2400],a[4]=[2220,4160,1632,1944],n[1]=[1830,129,3096,5664],n[2]=[5100,2177,3840,2904],n[3]=[4890,3425,3648,2136],n[4]=[1320,3681,1896,4080],n[5]=[1260,3841,1824,1200],n[6]=[1020,3969,1608,312],n[7]=[4800,4065,3600,72],n[8]=[4710,4865,3504,480],n[9]=[6720,5984,5112,3792],n[10]=[4500,7233,3288,1800],n[11]=[720,7522,384,3936],n[12]=[690,7745,336,1104],n[13]=[600,8225,120,1272],n[14]=[660,5569,840,576];var r=e("select.flag-en-type").val(),s=e("select.flag-es-type").val(),c=e("select.flag-pt-type").val(),g=e("select.flag-fr-type").val(),i=e("select.flag-ar-type").val(),f=r<=0?"":".weglot-flags.en > a:before, .weglot-flags.en > span:before { background-position: -"+t[r][0]+"px 0; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+l[c][0]+"px 0; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+l[c][1]+"px 0; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+l[c][2]+"px 0; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+l[c][3]+"px 0; } ",p=g<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[g][0]+"px 0; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[g][1]+"px 0; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[g][2]+"px 0; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[g][3]+"px 0; } ",w=i<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+n[i][0]+"px 0; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+n[i][1]+"px 0; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+n[i][2]+"px 0; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+n[i][3]+"px 0; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+w)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var g=function(){};o(2),o(1);l(),n(),a(),r(),s(),c(),g()},function(e,t){Array.prototype.filter||(Array.prototype.filter=function(e,t){"use strict";if("Function"!=typeof e&&"function"!=typeof e||!this)throw new TypeError;var o=this.length>>>0,l=new Array(o),a=this,n=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(l[n++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(l[n++]=a[r]);return l.length=n,l})},function(e,t){Array.prototype.find||Object.defineProperty(Array.prototype,"find",{value:function(e){if(null==this)throw new TypeError('"this" is null or not defined');var t=Object(this),o=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var l=arguments[1],a=0;a<o;){var n=t[a];if(e.call(l,n,a,t))return n;a++}},configurable:!0,writable:!0})}]);
|
dist/css/admin-css.css
CHANGED
@@ -325,9 +325,9 @@
|
|
325 |
.weglot__choice__language {
|
326 |
border-bottom: 1px solid #eee;
|
327 |
margin: 5px 0px; }
|
328 |
-
.weglot__choice__language--
|
329 |
border-width: 50px;
|
330 |
-
color: #
|
331 |
display: block; }
|
332 |
|
333 |
.btn {
|
@@ -397,6 +397,10 @@ input[type='text']:focus, textarea:focus {
|
|
397 |
font-weight: normal;
|
398 |
margin: 2px 0 0; }
|
399 |
|
|
|
|
|
|
|
|
|
400 |
.original-select,
|
401 |
#type_flags {
|
402 |
padding: 8px;
|
@@ -428,7 +432,8 @@ input[type="text"], .wg-input-textarea {
|
|
428 |
display: -webkit-box;
|
429 |
display: -webkit-flex;
|
430 |
display: -ms-flexbox;
|
431 |
-
display: flex;
|
|
|
432 |
#wrap-weglot .weglot-nokkey:before {
|
433 |
content: '\274C';
|
434 |
display: inline-block;
|
@@ -492,7 +497,8 @@ input[type="text"], .wg-input-textarea {
|
|
492 |
font-size: 15px; }
|
493 |
#wrap-weglot .selectize-control,
|
494 |
#wrap-weglot input[type="text"],
|
495 |
-
#wrap-weglot .wg-input-textarea
|
|
|
496 |
width: 100%;
|
497 |
max-width: 300px; }
|
498 |
#wrap-weglot #submit {
|
@@ -517,6 +523,10 @@ input[type="text"], .wg-input-textarea {
|
|
517 |
left: 36px; }
|
518 |
#wrap-weglot .question-icon {
|
519 |
font-size: 17px; }
|
|
|
|
|
|
|
|
|
520 |
|
521 |
.weglot-info {
|
522 |
position: relative;
|
325 |
.weglot__choice__language {
|
326 |
border-bottom: 1px solid #eee;
|
327 |
margin: 5px 0px; }
|
328 |
+
.weglot__choice__language--local {
|
329 |
border-width: 50px;
|
330 |
+
color: #a6a6a6;
|
331 |
display: block; }
|
332 |
|
333 |
.btn {
|
397 |
font-weight: normal;
|
398 |
margin: 2px 0 0; }
|
399 |
|
400 |
+
.weglot-select-original {
|
401 |
+
height: 36px !important;
|
402 |
+
margin: 0; }
|
403 |
+
|
404 |
.original-select,
|
405 |
#type_flags {
|
406 |
padding: 8px;
|
432 |
display: -webkit-box;
|
433 |
display: -webkit-flex;
|
434 |
display: -ms-flexbox;
|
435 |
+
display: flex;
|
436 |
+
margin-left: 15px; }
|
437 |
#wrap-weglot .weglot-nokkey:before {
|
438 |
content: '\274C';
|
439 |
display: inline-block;
|
497 |
font-size: 15px; }
|
498 |
#wrap-weglot .selectize-control,
|
499 |
#wrap-weglot input[type="text"],
|
500 |
+
#wrap-weglot .wg-input-textarea,
|
501 |
+
#wrap-weglot .weglot-select-original {
|
502 |
width: 100%;
|
503 |
max-width: 300px; }
|
504 |
#wrap-weglot #submit {
|
523 |
left: 36px; }
|
524 |
#wrap-weglot .question-icon {
|
525 |
font-size: 17px; }
|
526 |
+
#wrap-weglot .form-table {
|
527 |
+
margin-bottom: 50px; }
|
528 |
+
#wrap-weglot .country-selector {
|
529 |
+
z-index: 1 !important; }
|
530 |
|
531 |
.weglot-info {
|
532 |
position: relative;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Tags: translate,translation,language,multilingual,bilingual,international,locali
|
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.4
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -152,6 +152,23 @@ See changelog for upgrade changes.
|
|
152 |
|
153 |
== Changelog ==
|
154 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
= 2.0.3 (27/07/2018) =
|
156 |
* Bugfix : Hide shortcode on non translatable URL
|
157 |
* Bugfix : filter nav_menu_css_class
|
4 |
Requires at least: 4.5
|
5 |
Tested up to: 4.9
|
6 |
Requires PHP: 5.4
|
7 |
+
Stable tag: 2.0.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
152 |
|
153 |
== Changelog ==
|
154 |
|
155 |
+
= 2.0.6 (29/08/2018) =
|
156 |
+
* Add DOM checker for button value and data-value attribute
|
157 |
+
* Update setting page
|
158 |
+
* Bugfix : email translation
|
159 |
+
* Bugfix : external link with quickpay
|
160 |
+
* Prevent auto redirect on homepage translate
|
161 |
+
|
162 |
+
= 2.0.5 (09/08/2018) =
|
163 |
+
* Bugfix : Fatal error if use weglot menu custom
|
164 |
+
|
165 |
+
= 2.0.4 (09/08/2018) =
|
166 |
+
* Bugfix : lost password email on WooCommerce
|
167 |
+
* Bugfix : translate custom login page
|
168 |
+
* Bugfix : uniq id on each button selector
|
169 |
+
* Bugfix : no translate image on a href html tag with wp-content/uploads src
|
170 |
+
* Bugfix : admin-ajax url
|
171 |
+
|
172 |
= 2.0.3 (27/07/2018) =
|
173 |
* Bugfix : Hide shortcode on non translatable URL
|
174 |
* Bugfix : filter nav_menu_css_class
|
src/actions/admin/class-admin-enqueue-weglot.php
CHANGED
@@ -51,7 +51,7 @@ class Admin_Enqueue_Weglot implements Hooks_Interface_Weglot {
|
|
51 |
return;
|
52 |
}
|
53 |
|
54 |
-
wp_enqueue_script( 'weglot-admin-selectize-js', WEGLOT_URL_DIST . '/selectize.js', [ 'jquery' ] );
|
55 |
|
56 |
wp_enqueue_script( 'weglot-admin', WEGLOT_URL_DIST . '/admin-js.js', [ 'weglot-admin-selectize-js' ], [], WEGLOT_VERSION );
|
57 |
|
@@ -70,19 +70,20 @@ class Admin_Enqueue_Weglot implements Hooks_Interface_Weglot {
|
|
70 |
}
|
71 |
|
72 |
wp_localize_script( 'weglot-admin', 'weglot_languages', [
|
73 |
-
'available' => $this->language_services->get_languages_available(
|
|
|
|
|
74 |
'limit' => $limit,
|
|
|
75 |
'original' => weglot_get_original_language(),
|
76 |
]);
|
77 |
|
78 |
wp_enqueue_style( 'weglot-admin-css', WEGLOT_URL_DIST . '/css/admin-css.css', [], WEGLOT_VERSION );
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
]);
|
86 |
-
}
|
87 |
}
|
88 |
}
|
51 |
return;
|
52 |
}
|
53 |
|
54 |
+
wp_enqueue_script( 'weglot-admin-selectize-js', WEGLOT_URL_DIST . '/selectize.js', [ 'jquery', 'jquery-ui-sortable' ] );
|
55 |
|
56 |
wp_enqueue_script( 'weglot-admin', WEGLOT_URL_DIST . '/admin-js.js', [ 'weglot-admin-selectize-js' ], [], WEGLOT_VERSION );
|
57 |
|
70 |
}
|
71 |
|
72 |
wp_localize_script( 'weglot-admin', 'weglot_languages', [
|
73 |
+
'available' => $this->language_services->get_languages_available( [
|
74 |
+
'sort' => true,
|
75 |
+
] ),
|
76 |
'limit' => $limit,
|
77 |
+
'plans' => $this->user_api_services->get_plans(),
|
78 |
'original' => weglot_get_original_language(),
|
79 |
]);
|
80 |
|
81 |
wp_enqueue_style( 'weglot-admin-css', WEGLOT_URL_DIST . '/css/admin-css.css', [], WEGLOT_VERSION );
|
82 |
|
83 |
+
wp_enqueue_style( 'weglot-css', WEGLOT_URL_DIST . '/css/front-css.css', [], WEGLOT_VERSION );
|
84 |
+
wp_localize_script( 'weglot-admin', 'weglot_css', [
|
85 |
+
'inline' => $this->option_services->get_css_custom_inline(),
|
86 |
+
'flag_css' => $this->option_services->get_option( 'flag_css' ),
|
87 |
+
]);
|
|
|
|
|
88 |
}
|
89 |
}
|
src/actions/admin/class-customize-menu-weglot.php
CHANGED
@@ -34,6 +34,10 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
|
|
34 |
* @return void
|
35 |
*/
|
36 |
public function hooks() {
|
|
|
|
|
|
|
|
|
37 |
add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
|
38 |
add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
|
39 |
add_filter( 'nav_menu_css_class', [ $this, 'add_nav_menu_css_class' ], 10, 2 );
|
34 |
* @return void
|
35 |
*/
|
36 |
public function hooks() {
|
37 |
+
if ( ! $this->option_services->get_option( 'allowed' ) ) {
|
38 |
+
return;
|
39 |
+
}
|
40 |
+
|
41 |
add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
|
42 |
add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
|
43 |
add_filter( 'nav_menu_css_class', [ $this, 'add_nav_menu_css_class' ], 10, 2 );
|
src/actions/admin/class-options-weglot.php
CHANGED
@@ -34,7 +34,8 @@ class Options_Weglot implements Hooks_Interface_Weglot {
|
|
34 |
public function hooks() {
|
35 |
add_action( 'admin_init', [ $this, 'weglot_options_init' ] );
|
36 |
$api_key = $this->option_services->get_option( 'api_key' );
|
37 |
-
if ( empty( $api_key ) ) {
|
|
|
38 |
add_action( 'admin_notices', [ '\WeglotWP\Notices\No_Configuration_Weglot', 'admin_notice' ] );
|
39 |
}
|
40 |
}
|
@@ -80,17 +81,16 @@ class Options_Weglot implements Hooks_Interface_Weglot {
|
|
80 |
switch ( $tab ) {
|
81 |
case Helper_Tabs_Admin_Weglot::SETTINGS:
|
82 |
$new_options = $this->sanitize_options_settings( $new_options, $options );
|
|
|
|
|
83 |
if ( $options_bdd['has_first_settings'] ) {
|
84 |
$new_options['has_first_settings'] = false;
|
85 |
$new_options['show_box_first_settings'] = true;
|
|
|
|
|
|
|
86 |
}
|
87 |
break;
|
88 |
-
case Helper_Tabs_Admin_Weglot::APPEARANCE:
|
89 |
-
$new_options = $this->sanitize_options_appearance( $new_options, $options );
|
90 |
-
break;
|
91 |
-
case Helper_Tabs_Admin_Weglot::ADVANCED:
|
92 |
-
$new_options = $this->sanitize_options_advanced( $new_options, $options );
|
93 |
-
break;
|
94 |
}
|
95 |
|
96 |
return $new_options;
|
@@ -98,12 +98,13 @@ class Options_Weglot implements Hooks_Interface_Weglot {
|
|
98 |
|
99 |
/**
|
100 |
* @since 2.0
|
|
|
101 |
* @param array $new_options
|
102 |
* @param array $options
|
103 |
* @return array
|
104 |
*/
|
105 |
public function sanitize_options_settings( $new_options, $options ) {
|
106 |
-
$user_info = $this->user_api_services->get_user_info();
|
107 |
$plans = $this->user_api_services->get_plans();
|
108 |
$options_bdd = $this->option_services->get_options();
|
109 |
|
34 |
public function hooks() {
|
35 |
add_action( 'admin_init', [ $this, 'weglot_options_init' ] );
|
36 |
$api_key = $this->option_services->get_option( 'api_key' );
|
37 |
+
if ( empty( $api_key ) && ( ! isset( $_GET['page'] ) || strpos( $_GET['page'], 'weglot-settings' ) === false) ) { // phpcs:ignore
|
38 |
+
//We don't show the notice if we are on Weglot configuration
|
39 |
add_action( 'admin_notices', [ '\WeglotWP\Notices\No_Configuration_Weglot', 'admin_notice' ] );
|
40 |
}
|
41 |
}
|
81 |
switch ( $tab ) {
|
82 |
case Helper_Tabs_Admin_Weglot::SETTINGS:
|
83 |
$new_options = $this->sanitize_options_settings( $new_options, $options );
|
84 |
+
|
85 |
+
|
86 |
if ( $options_bdd['has_first_settings'] ) {
|
87 |
$new_options['has_first_settings'] = false;
|
88 |
$new_options['show_box_first_settings'] = true;
|
89 |
+
} else {
|
90 |
+
$new_options = $this->sanitize_options_appearance( $new_options, $options );
|
91 |
+
$new_options = $this->sanitize_options_advanced( $new_options, $options );
|
92 |
}
|
93 |
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
|
96 |
return $new_options;
|
98 |
|
99 |
/**
|
100 |
* @since 2.0
|
101 |
+
* @version 2.0.6
|
102 |
* @param array $new_options
|
103 |
* @param array $options
|
104 |
* @return array
|
105 |
*/
|
106 |
public function sanitize_options_settings( $new_options, $options ) {
|
107 |
+
$user_info = $this->user_api_services->get_user_info( $new_options['api_key'] );
|
108 |
$plans = $this->user_api_services->get_plans();
|
109 |
$options_bdd = $this->option_services->get_options();
|
110 |
|
src/actions/class-email-translate-weglot.php
CHANGED
@@ -110,8 +110,11 @@ class Email_Translate_Weglot implements Hooks_Interface_Weglot {
|
|
110 |
$config = new ServerConfigProvider();
|
111 |
$client = new Client( $api_key );
|
112 |
$parser = new Parser( $client, $config, $exclude_blocks );
|
113 |
-
|
114 |
$translated_subject = $parser->translate( '<p>' . $args['subject'] . '</p>', $current_and_original_language['original'], $current_and_original_language['current'] ); //phpcs:ignore
|
|
|
|
|
|
|
|
|
115 |
$translated_message = $parser->translate( $args['message'], $current_and_original_language['original'], $current_and_original_language['current'] ); //phpcs:ignore
|
116 |
|
117 |
return [
|
110 |
$config = new ServerConfigProvider();
|
111 |
$client = new Client( $api_key );
|
112 |
$parser = new Parser( $client, $config, $exclude_blocks );
|
|
|
113 |
$translated_subject = $parser->translate( '<p>' . $args['subject'] . '</p>', $current_and_original_language['original'], $current_and_original_language['current'] ); //phpcs:ignore
|
114 |
+
|
115 |
+
$config = new ServerConfigProvider();
|
116 |
+
$client = new Client( $api_key );
|
117 |
+
$parser = new Parser( $client, $config, $exclude_blocks );
|
118 |
$translated_message = $parser->translate( $args['message'], $current_and_original_language['original'], $current_and_original_language['current'] ); //phpcs:ignore
|
119 |
|
120 |
return [
|
src/actions/front/class-translate-page-weglot.php
CHANGED
@@ -36,7 +36,6 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
36 |
$this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
|
37 |
}
|
38 |
|
39 |
-
|
40 |
/**
|
41 |
* @see Hooks_Interface_Weglot
|
42 |
*
|
@@ -44,7 +43,12 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
44 |
* @return void
|
45 |
*/
|
46 |
public function hooks() {
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
48 |
return;
|
49 |
}
|
50 |
|
@@ -63,6 +67,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
63 |
|
64 |
$this->current_language = $this->request_url_services->get_current_language();
|
65 |
|
|
|
66 |
$this->prepare_rtl_language();
|
67 |
|
68 |
add_action( 'init', [ $this, 'weglot_init' ] );
|
@@ -72,7 +77,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
72 |
/**
|
73 |
* @see init
|
74 |
* @since 2.0
|
75 |
-
* @version 2.0.
|
76 |
* @return void
|
77 |
*/
|
78 |
public function weglot_init() {
|
@@ -84,13 +89,14 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
84 |
return;
|
85 |
}
|
86 |
|
87 |
-
$
|
|
|
88 |
// URL not eligible
|
89 |
-
if ( ! $this->request_url_services->is_eligible_url( $
|
90 |
return;
|
91 |
}
|
92 |
|
93 |
-
$active_translation = apply_filters( '
|
94 |
// Default : yes
|
95 |
if ( ! $active_translation ) {
|
96 |
return;
|
@@ -98,7 +104,6 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
98 |
|
99 |
$this->redirect_services->verify_no_redirect();
|
100 |
$this->check_need_to_redirect();
|
101 |
-
$this->prepare_request_uri();
|
102 |
|
103 |
do_action( 'weglot_init_before_translate_page' );
|
104 |
|
@@ -106,6 +111,12 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
106 |
return;
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
ob_start( [ $this, 'weglot_treat_page' ] );
|
110 |
}
|
111 |
|
@@ -113,10 +124,9 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
113 |
|
114 |
/**
|
115 |
* @since 2.0
|
|
|
116 |
*
|
117 |
* @param array $array
|
118 |
-
* @param string $to
|
119 |
-
* @param Parser $parser
|
120 |
* @return void
|
121 |
*/
|
122 |
public function translate_array( $array ) {
|
@@ -181,7 +191,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
181 |
public function prepare_request_uri() {
|
182 |
// Use for good process on URL
|
183 |
$_SERVER['REQUEST_URI'] = str_replace(
|
184 |
-
'/' . $this->
|
185 |
'/',
|
186 |
$_SERVER['REQUEST_URI'] //phpcs:ignore
|
187 |
);
|
@@ -216,28 +226,31 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
216 |
/**
|
217 |
* @see weglot_init / ob_start
|
218 |
* @since 2.0
|
219 |
-
* @version 2.0.
|
220 |
* @param string $content
|
221 |
* @return string
|
222 |
*/
|
223 |
public function weglot_treat_page( $content ) {
|
224 |
-
$
|
|
|
225 |
|
226 |
if ( ! $allowed ) {
|
227 |
$content = $this->weglot_render_dom( $content );
|
228 |
return $content . '<!--Not allowed-->';
|
229 |
}
|
230 |
|
|
|
|
|
231 |
// No need to translate but prepare new dom with button
|
232 |
-
if ( $this->current_language === $this->original_language ) {
|
233 |
return $this->weglot_render_dom( $content );
|
234 |
}
|
235 |
|
236 |
$parser = $this->parser_services->get_parser();
|
237 |
|
238 |
// Choose type translate
|
239 |
-
$type
|
240 |
-
$type
|
241 |
|
242 |
try {
|
243 |
switch ( $type ) {
|
@@ -342,10 +355,21 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
342 |
$dom = preg_replace( '#' . $shortcode_title_without_bracket . '#i', $name, $dom );
|
343 |
|
344 |
$link_menu = $url->getForLanguage( $language->getIso639() );
|
345 |
-
if ( weglot_has_auto_redirect() && strpos( $link_menu, 'no_lredirect' ) === false && ( is_home() || is_front_page() ) ) {
|
346 |
$link_menu .= '?no_lredirect=true';
|
347 |
}
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
$dom = preg_replace( '#' . $shortcode_url . '#i', $link_menu, $dom );
|
350 |
$dom = preg_replace( '#' . $shortcode_url_html . '#i', $link_menu, $dom );
|
351 |
}
|
@@ -382,6 +406,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
|
|
382 |
|
383 |
/**
|
384 |
* @since 2.0
|
|
|
385 |
* @param string $dom
|
386 |
* @return string
|
387 |
*/
|
36 |
$this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
|
37 |
}
|
38 |
|
|
|
39 |
/**
|
40 |
* @see Hooks_Interface_Weglot
|
41 |
*
|
43 |
* @return void
|
44 |
*/
|
45 |
public function hooks() {
|
46 |
+
$no_translate = false;
|
47 |
+
if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && 'add-menu-item' === $_POST['action'] ) { //phpcs:ignore
|
48 |
+
$no_translate = true;
|
49 |
+
}
|
50 |
+
|
51 |
+
if ( is_admin() && ( ! wp_doing_ajax() || $no_translate ) ) {
|
52 |
return;
|
53 |
}
|
54 |
|
67 |
|
68 |
$this->current_language = $this->request_url_services->get_current_language();
|
69 |
|
70 |
+
$this->prepare_request_uri();
|
71 |
$this->prepare_rtl_language();
|
72 |
|
73 |
add_action( 'init', [ $this, 'weglot_init' ] );
|
77 |
/**
|
78 |
* @see init
|
79 |
* @since 2.0
|
80 |
+
* @version 2.0.4
|
81 |
* @return void
|
82 |
*/
|
83 |
public function weglot_init() {
|
89 |
return;
|
90 |
}
|
91 |
|
92 |
+
$full_url_no_language = $this->request_url_services->get_full_url_no_language();
|
93 |
+
|
94 |
// URL not eligible
|
95 |
+
if ( ! $this->request_url_services->is_eligible_url( $full_url_no_language ) ) {
|
96 |
return;
|
97 |
}
|
98 |
|
99 |
+
$active_translation = apply_filters( 'weglot_active_translation_before_process', true );
|
100 |
// Default : yes
|
101 |
if ( ! $active_translation ) {
|
102 |
return;
|
104 |
|
105 |
$this->redirect_services->verify_no_redirect();
|
106 |
$this->check_need_to_redirect();
|
|
|
107 |
|
108 |
do_action( 'weglot_init_before_translate_page' );
|
109 |
|
111 |
return;
|
112 |
}
|
113 |
|
114 |
+
$active_translation = apply_filters( 'weglot_active_translation_before_treat_page', true );
|
115 |
+
// Default : yes
|
116 |
+
if ( ! $active_translation ) {
|
117 |
+
return;
|
118 |
+
}
|
119 |
+
|
120 |
ob_start( [ $this, 'weglot_treat_page' ] );
|
121 |
}
|
122 |
|
124 |
|
125 |
/**
|
126 |
* @since 2.0
|
127 |
+
* @version 2.0.4
|
128 |
*
|
129 |
* @param array $array
|
|
|
|
|
130 |
* @return void
|
131 |
*/
|
132 |
public function translate_array( $array ) {
|
191 |
public function prepare_request_uri() {
|
192 |
// Use for good process on URL
|
193 |
$_SERVER['REQUEST_URI'] = str_replace(
|
194 |
+
'/' . $this->request_url_services->get_current_language( false ) . '/',
|
195 |
'/',
|
196 |
$_SERVER['REQUEST_URI'] //phpcs:ignore
|
197 |
);
|
226 |
/**
|
227 |
* @see weglot_init / ob_start
|
228 |
* @since 2.0
|
229 |
+
* @version 2.0.4
|
230 |
* @param string $content
|
231 |
* @return string
|
232 |
*/
|
233 |
public function weglot_treat_page( $content ) {
|
234 |
+
$this->current_language = $this->request_url_services->get_current_language(); // Need to reset
|
235 |
+
$allowed = $this->option_services->get_option( 'allowed' );
|
236 |
|
237 |
if ( ! $allowed ) {
|
238 |
$content = $this->weglot_render_dom( $content );
|
239 |
return $content . '<!--Not allowed-->';
|
240 |
}
|
241 |
|
242 |
+
$active_translation = apply_filters( 'weglot_active_translation', true );
|
243 |
+
|
244 |
// No need to translate but prepare new dom with button
|
245 |
+
if ( $this->current_language === $this->original_language || ! $active_translation ) {
|
246 |
return $this->weglot_render_dom( $content );
|
247 |
}
|
248 |
|
249 |
$parser = $this->parser_services->get_parser();
|
250 |
|
251 |
// Choose type translate
|
252 |
+
$type = ( $this->is_json( $content ) ) ? 'json' : 'html';
|
253 |
+
$type = apply_filters( 'weglot_type_treat_page', $type );
|
254 |
|
255 |
try {
|
256 |
switch ( $type ) {
|
355 |
$dom = preg_replace( '#' . $shortcode_title_without_bracket . '#i', $name, $dom );
|
356 |
|
357 |
$link_menu = $url->getForLanguage( $language->getIso639() );
|
358 |
+
if ( weglot_has_auto_redirect() && strpos( $link_menu, 'no_lredirect' ) === false && ( is_home() || is_front_page() ) && $language->getIso639() === weglot_get_original_language() ) {
|
359 |
$link_menu .= '?no_lredirect=true';
|
360 |
}
|
361 |
|
362 |
+
// Compatibility Menu HTTPS if not work. Since 2.0.6
|
363 |
+
if (
|
364 |
+
(
|
365 |
+
is_ssl() ||
|
366 |
+
isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] // phpcs:ignore
|
367 |
+
) &&
|
368 |
+
strpos( $link_menu, 'https://' ) === false
|
369 |
+
) {
|
370 |
+
$link_menu = str_replace( 'http', 'https', $link_menu );
|
371 |
+
}
|
372 |
+
|
373 |
$dom = preg_replace( '#' . $shortcode_url . '#i', $link_menu, $dom );
|
374 |
$dom = preg_replace( '#' . $shortcode_url_html . '#i', $link_menu, $dom );
|
375 |
}
|
406 |
|
407 |
/**
|
408 |
* @since 2.0
|
409 |
+
* @version 2.0.4
|
410 |
* @param string $dom
|
411 |
* @return string
|
412 |
*/
|
src/domcheckers/class-button-data-value.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WeglotWP\Domcheckers;
|
4 |
+
|
5 |
+
use Weglot\Parser\Check\Dom\AbstractDomChecker;
|
6 |
+
use Weglot\Client\Api\Enum\WordType;
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @since 2.0.6
|
14 |
+
*/
|
15 |
+
class Button_Data_Value extends AbstractDomChecker {
|
16 |
+
/**
|
17 |
+
* {@inheritdoc}
|
18 |
+
*/
|
19 |
+
const DOM = 'button';
|
20 |
+
/**
|
21 |
+
* {@inheritdoc}
|
22 |
+
*/
|
23 |
+
const PROPERTY = 'data-value';
|
24 |
+
/**
|
25 |
+
* {@inheritdoc}
|
26 |
+
*/
|
27 |
+
const WORD_TYPE = WordType::VALUE;
|
28 |
+
}
|
src/domcheckers/class-button-value.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
namespace WeglotWP\Domcheckers;
|
4 |
+
|
5 |
+
use Weglot\Parser\Check\Dom\AbstractDomChecker;
|
6 |
+
use Weglot\Client\Api\Enum\WordType;
|
7 |
+
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
/**
|
13 |
+
* @since 2.0.6
|
14 |
+
*/
|
15 |
+
class Button_Value extends AbstractDomChecker {
|
16 |
+
/**
|
17 |
+
* {@inheritdoc}
|
18 |
+
*/
|
19 |
+
const DOM = 'button';
|
20 |
+
/**
|
21 |
+
* {@inheritdoc}
|
22 |
+
*/
|
23 |
+
const PROPERTY = 'value';
|
24 |
+
/**
|
25 |
+
* {@inheritdoc}
|
26 |
+
*/
|
27 |
+
const WORD_TYPE = WordType::VALUE;
|
28 |
+
}
|
src/helpers/class-helper-tabs-admin-weglot.php
CHANGED
@@ -18,21 +18,11 @@ abstract class Helper_Tabs_Admin_Weglot {
|
|
18 |
*/
|
19 |
const SETTINGS = 'settings';
|
20 |
|
21 |
-
/**
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
const ADVANCED = 'advanced';
|
25 |
-
|
26 |
/**
|
27 |
* @var string
|
28 |
*/
|
29 |
const STATUS = 'status';
|
30 |
|
31 |
-
/**
|
32 |
-
* @var string
|
33 |
-
*/
|
34 |
-
const APPEARANCE = 'appearance';
|
35 |
-
|
36 |
/**
|
37 |
* Get tabs constant
|
38 |
*
|
@@ -43,9 +33,7 @@ abstract class Helper_Tabs_Admin_Weglot {
|
|
43 |
public static function get_tabs() {
|
44 |
return [
|
45 |
self::SETTINGS,
|
46 |
-
self::ADVANCED,
|
47 |
self::STATUS,
|
48 |
-
self::APPEARANCE,
|
49 |
];
|
50 |
}
|
51 |
|
@@ -54,22 +42,14 @@ abstract class Helper_Tabs_Admin_Weglot {
|
|
54 |
* @static
|
55 |
* @since 2.0
|
56 |
*
|
57 |
-
* @return
|
58 |
*/
|
59 |
public static function get_full_tabs() {
|
60 |
return [
|
61 |
self::SETTINGS => [
|
62 |
-
'title' => __( '
|
63 |
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::SETTINGS ) ),
|
64 |
],
|
65 |
-
self::APPEARANCE => [
|
66 |
-
'title' => __( 'Language button', 'weglot' ),
|
67 |
-
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::APPEARANCE ) ),
|
68 |
-
],
|
69 |
-
self::ADVANCED => [
|
70 |
-
'title' => __( 'Advanced', 'weglot' ),
|
71 |
-
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::ADVANCED ) ),
|
72 |
-
],
|
73 |
self::STATUS => [
|
74 |
'title' => __( 'Status', 'weglot' ),
|
75 |
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::STATUS ) ),
|
18 |
*/
|
19 |
const SETTINGS = 'settings';
|
20 |
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* @var string
|
23 |
*/
|
24 |
const STATUS = 'status';
|
25 |
|
|
|
|
|
|
|
|
|
|
|
26 |
/**
|
27 |
* Get tabs constant
|
28 |
*
|
33 |
public static function get_tabs() {
|
34 |
return [
|
35 |
self::SETTINGS,
|
|
|
36 |
self::STATUS,
|
|
|
37 |
];
|
38 |
}
|
39 |
|
42 |
* @static
|
43 |
* @since 2.0
|
44 |
*
|
45 |
+
* @return array
|
46 |
*/
|
47 |
public static function get_full_tabs() {
|
48 |
return [
|
49 |
self::SETTINGS => [
|
50 |
+
'title' => __( 'Settings', 'weglot' ),
|
51 |
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::SETTINGS ) ),
|
52 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
self::STATUS => [
|
54 |
'title' => __( 'Status', 'weglot' ),
|
55 |
'url' => get_admin_url( null, sprintf( 'admin.php?page=%s&tab=%s', Helper_Pages_Weglot::SETTINGS, self::STATUS ) ),
|
src/services/class-button-service-weglot.php
CHANGED
@@ -48,9 +48,9 @@ class Button_Service_Weglot {
|
|
48 |
$add_class .= ' weglot-invert';
|
49 |
}
|
50 |
|
51 |
-
$destination_language =
|
52 |
$original_language = $options['original_language'];
|
53 |
-
$current_language = $this->request_url_services->get_current_language();
|
54 |
|
55 |
$flag_class = $with_flags ? 'weglot-flags ' : '';
|
56 |
$flag_class .= '0' === $type_flags ? '' : 'flag-' . $type_flags . ' ';
|
@@ -64,11 +64,21 @@ class Button_Service_Weglot {
|
|
64 |
|
65 |
if ( ! empty( $original_language ) && ! empty( $destination_language ) ) {
|
66 |
$name = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
if ( $with_name ) {
|
68 |
-
$name = ( $is_fullname ) ? $
|
69 |
}
|
70 |
|
71 |
-
$
|
|
|
72 |
|
73 |
$button_html .= '<ul>';
|
74 |
|
@@ -79,16 +89,26 @@ class Button_Service_Weglot {
|
|
79 |
continue;
|
80 |
}
|
81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
$name = '';
|
83 |
if ( $with_name ) {
|
84 |
-
$name = ( $is_fullname ) ? $
|
85 |
}
|
86 |
|
87 |
$button_html .= sprintf( '<li class="wg-li %s" data-code-language="%s">', $flag_class . $key_code, $key_code );
|
88 |
|
89 |
-
$link_button = $weglot_url->getForLanguage( $key_code );
|
90 |
|
91 |
-
|
|
|
92 |
$link_button .= '?no_lredirect=true';
|
93 |
}
|
94 |
|
48 |
$add_class .= ' weglot-invert';
|
49 |
}
|
50 |
|
51 |
+
$destination_language = weglot_get_destination_languages();
|
52 |
$original_language = $options['original_language'];
|
53 |
+
$current_language = $this->request_url_services->get_current_language( false );
|
54 |
|
55 |
$flag_class = $with_flags ? 'weglot-flags ' : '';
|
56 |
$flag_class .= '0' === $type_flags ? '' : 'flag-' . $type_flags . ' ';
|
64 |
|
65 |
if ( ! empty( $original_language ) && ! empty( $destination_language ) ) {
|
66 |
$name = '';
|
67 |
+
if ( isset( $languages[ $current_language ] ) ) {
|
68 |
+
$current_language_entry = $languages[ $current_language ];
|
69 |
+
} else {
|
70 |
+
$current_language_entry = apply_filters( 'weglot_current_language_entry', $current_language );
|
71 |
+
if ( $current_language_entry === $current_language ) {
|
72 |
+
throw new \Exception( 'You need create a language entry' );
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
if ( $with_name ) {
|
77 |
+
$name = ( $is_fullname ) ? $current_language_entry->getLocalName() : strtoupper( $current_language_entry->getIso639() );
|
78 |
}
|
79 |
|
80 |
+
$uniqId = 'wg' . uniqid( strtotime( 'now' ) ) . rand( 1, 1000 );
|
81 |
+
$button_html .= sprintf( '<input id="%s" class="weglot_choice" type="checkbox" name="menu"/><label for="%s" class="wgcurrent wg-li %s" data-code-language="%s"><span>%s</span></label>', $uniqId, $uniqId, $flag_class . $current_language, $current_language_entry->getIso639(), $name );
|
82 |
|
83 |
$button_html .= '<ul>';
|
84 |
|
89 |
continue;
|
90 |
}
|
91 |
|
92 |
+
if ( isset( $languages[ $key_code ] ) ) {
|
93 |
+
$current_language_entry = $languages[ $key_code ];
|
94 |
+
} else {
|
95 |
+
$current_language_entry = apply_filters( 'weglot_current_language_entry', $key_code );
|
96 |
+
if ( $current_language_entry === $key_code ) {
|
97 |
+
throw new \Exception( 'You need create a language entry' );
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
$name = '';
|
102 |
if ( $with_name ) {
|
103 |
+
$name = ( $is_fullname ) ? $current_language_entry->getLocalName() : strtoupper( $current_language_entry->getIso639() );
|
104 |
}
|
105 |
|
106 |
$button_html .= sprintf( '<li class="wg-li %s" data-code-language="%s">', $flag_class . $key_code, $key_code );
|
107 |
|
108 |
+
$link_button = apply_filters( 'weglot_link_language', $weglot_url->getForLanguage( $key_code ), $key_code );
|
109 |
|
110 |
+
$link_button = preg_replace('#\?no_lredirect=true$#', '', $link_button); // Remove ending "?no_lredirect=true"
|
111 |
+
if ( weglot_has_auto_redirect() && strpos( $link_button, 'no_lredirect' ) === false && ( is_home() || is_front_page() ) && $key_code === $original_language) {
|
112 |
$link_button .= '?no_lredirect=true';
|
113 |
}
|
114 |
|
src/services/class-dom-checkers-service-weglot.php
CHANGED
@@ -12,16 +12,10 @@ use Weglot\Util\Text;
|
|
12 |
* Dom Checkers
|
13 |
*
|
14 |
* @since 2.0
|
|
|
15 |
*/
|
16 |
class Dom_Checkers_Service_Weglot {
|
17 |
-
|
18 |
-
* @since 2.0
|
19 |
-
*/
|
20 |
-
public function __construct() {
|
21 |
-
$this->dom_checkers = [
|
22 |
-
'\WeglotWP\Domcheckers\Meta_Twitter',
|
23 |
-
];
|
24 |
-
}
|
25 |
/**
|
26 |
* @since 2.0
|
27 |
* @return array
|
12 |
* Dom Checkers
|
13 |
*
|
14 |
* @since 2.0
|
15 |
+
* @version 2.0.6
|
16 |
*/
|
17 |
class Dom_Checkers_Service_Weglot {
|
18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
/**
|
20 |
* @since 2.0
|
21 |
* @return array
|
src/services/class-language-service-weglot.php
CHANGED
@@ -9,6 +9,8 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
9 |
|
10 |
use Weglot\Client\Endpoint\Languages;
|
11 |
use Weglot\Client\Client;
|
|
|
|
|
12 |
|
13 |
/**
|
14 |
* Language service
|
@@ -25,18 +27,45 @@ class Language_Service_Weglot {
|
|
25 |
$this->option_services = weglot_get_service( 'Option_Service_Weglot' );
|
26 |
}
|
27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
/**
|
30 |
* Get languages available from API
|
31 |
* @since 2.0
|
32 |
-
*
|
|
|
33 |
* @return array
|
34 |
*/
|
35 |
-
public function get_languages_available() {
|
36 |
-
if ( null
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
return $this->languages;
|
@@ -59,7 +88,8 @@ class Language_Service_Weglot {
|
|
59 |
*/
|
60 |
public function get_languages_configured( $type = null ) {
|
61 |
$languages[] = weglot_get_original_language();
|
62 |
-
$languages = array_merge( $languages,
|
|
|
63 |
$languages_object = [];
|
64 |
|
65 |
foreach ( $languages as $language ) {
|
9 |
|
10 |
use Weglot\Client\Endpoint\Languages;
|
11 |
use Weglot\Client\Client;
|
12 |
+
use Weglot\Client\Api\LanguageCollection;
|
13 |
+
use Weglot\Client\Factory\Languages as LanguagesFactory;
|
14 |
|
15 |
/**
|
16 |
* Language service
|
27 |
$this->option_services = weglot_get_service( 'Option_Service_Weglot' );
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* @since 2.0.6
|
32 |
+
* @param array $a
|
33 |
+
* @param array $b
|
34 |
+
* @return bool
|
35 |
+
*/
|
36 |
+
protected function compare_language( $a, $b ) {
|
37 |
+
return strcmp( $a['english'], $b['english'] );
|
38 |
+
}
|
39 |
|
40 |
/**
|
41 |
* Get languages available from API
|
42 |
* @since 2.0
|
43 |
+
* @version 2.0.6
|
44 |
+
* @param array $params
|
45 |
* @return array
|
46 |
*/
|
47 |
+
public function get_languages_available( $params = [] ) {
|
48 |
+
if ( null !== $this->languages ) {
|
49 |
+
return $this->languages;
|
50 |
+
}
|
51 |
+
|
52 |
+
$client = new Client( $this->option_services->get_option( 'api_key' ) );
|
53 |
+
$languages = new Languages( $client );
|
54 |
+
|
55 |
+
$this->languages = $languages->handle();
|
56 |
+
|
57 |
+
if ( isset( $params['sort'] ) && $params['sort'] ) {
|
58 |
+
$this->languages = $this->languages->jsonSerialize();
|
59 |
+
usort( $this->languages, [ $this, 'compare_language' ] );
|
60 |
+
|
61 |
+
$language_collection = new LanguageCollection();
|
62 |
+
|
63 |
+
foreach ( $this->languages as $language ) {
|
64 |
+
$factory = new LanguagesFactory( $language );
|
65 |
+
$language_collection->addOne( $factory->handle() );
|
66 |
+
}
|
67 |
+
|
68 |
+
$this->languages = $language_collection;
|
69 |
}
|
70 |
|
71 |
return $this->languages;
|
88 |
*/
|
89 |
public function get_languages_configured( $type = null ) {
|
90 |
$languages[] = weglot_get_original_language();
|
91 |
+
$languages = array_merge( $languages, weglot_get_destination_languages() );
|
92 |
+
|
93 |
$languages_object = [];
|
94 |
|
95 |
foreach ( $languages as $language ) {
|
src/services/class-option-service-weglot.php
CHANGED
@@ -81,6 +81,16 @@ class Option_Service_Weglot {
|
|
81 |
return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
|
82 |
}
|
83 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* @since 2.0
|
86 |
* @return array
|
81 |
return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
|
82 |
}
|
83 |
|
84 |
+
/**
|
85 |
+
* @since 2.0.4
|
86 |
+
* @return array
|
87 |
+
*/
|
88 |
+
public function get_destination_languages() {
|
89 |
+
$destination_languages = $this->get_option( 'destination_language' );
|
90 |
+
|
91 |
+
return apply_filters( 'weglot_destination_languages', $destination_languages );
|
92 |
+
}
|
93 |
+
|
94 |
/**
|
95 |
* @since 2.0
|
96 |
* @return array
|
src/services/class-other-translate-service-weglot.php
CHANGED
@@ -68,6 +68,7 @@ class Other_Translate_Service_Weglot {
|
|
68 |
$from_input = Helper_Json_Inline_Weglot::unformat_from_api( $input_word->getWord() );
|
69 |
$to_output = Helper_Json_Inline_Weglot::unformat_from_api( $object->getOutputWords()[ $key ]->getWord() );
|
70 |
|
|
|
71 |
if ( ! preg_match( "#<[^>\"']*" . $from_input . "[^>\"']*>#", $content ) ) {
|
72 |
$content = preg_replace( "#\b$from_input\b#", $to_output, $content );
|
73 |
}
|
68 |
$from_input = Helper_Json_Inline_Weglot::unformat_from_api( $input_word->getWord() );
|
69 |
$to_output = Helper_Json_Inline_Weglot::unformat_from_api( $object->getOutputWords()[ $key ]->getWord() );
|
70 |
|
71 |
+
$from_input = preg_quote($from_input); // To avoid special char like | to be interpreted as regex.
|
72 |
if ( ! preg_match( "#<[^>\"']*" . $from_input . "[^>\"']*>#", $content ) ) {
|
73 |
$content = preg_replace( "#\b$from_input\b#", $to_output, $content );
|
74 |
}
|
src/services/class-redirect-service-weglot.php
CHANGED
@@ -57,11 +57,11 @@ class Redirect_Service_Weglot {
|
|
57 |
}
|
58 |
|
59 |
$server_lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ); //phpcs:ignore
|
60 |
-
$destination_languages =
|
61 |
|
62 |
if (
|
63 |
-
in_array( $server_lang, $destination_languages
|
64 |
-
|
65 |
) {
|
66 |
$url_auto_redirect = apply_filters( 'weglot_url_auto_redirect', $this->request_url_services->get_weglot_url()->getForLanguage( $server_lang ) );
|
67 |
wp_safe_redirect( $url_auto_redirect );
|
57 |
}
|
58 |
|
59 |
$server_lang = substr( $_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2 ); //phpcs:ignore
|
60 |
+
$destination_languages = weglot_get_destination_languages();
|
61 |
|
62 |
if (
|
63 |
+
in_array( $server_lang, $destination_languages ) && // phpcs:ignore
|
64 |
+
weglot_get_original_language() === $this->request_url_services->get_current_language()
|
65 |
) {
|
66 |
$url_auto_redirect = apply_filters( 'weglot_url_auto_redirect', $this->request_url_services->get_weglot_url()->getForLanguage( $server_lang ) );
|
67 |
wp_safe_redirect( $url_auto_redirect );
|
src/services/class-replace-link-service-weglot.php
CHANGED
@@ -49,8 +49,8 @@ class Replace_Link_Service_Weglot {
|
|
49 |
foreach ( array_reverse( $this->multisite_service->get_list_of_network_path() ) as $np ) {
|
50 |
if ( strlen( $np ) > 2 && strpos( $url_translated, $np ) !== false ) {
|
51 |
$url_translated = str_replace(
|
52 |
-
str_replace( '//', '/', '/' . $current_language . $np . '/'),
|
53 |
-
|
54 |
$url_translated
|
55 |
);
|
56 |
}
|
@@ -63,6 +63,7 @@ class Replace_Link_Service_Weglot {
|
|
63 |
/**
|
64 |
* Replace href in <a>
|
65 |
* @since 2.0
|
|
|
66 |
* @param string $translated_page
|
67 |
* @param string $current_url
|
68 |
* @param string $quote1
|
@@ -72,7 +73,12 @@ class Replace_Link_Service_Weglot {
|
|
72 |
* @return string
|
73 |
*/
|
74 |
public function replace_a( $translated_page, $current_url, $quote1, $quote2, $sometags = null, $sometags2 = null ) {
|
75 |
-
$current_language
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
$translated_page = preg_replace( '/<a' . preg_quote( $sometags, '/' ) . 'href=' . preg_quote( $quote1 . $current_url . $quote2, '/' ) . preg_quote( $sometags2, '/' ) . '>/', '<a' . $sometags . 'href=' . $quote1 . $this->replace_url( $current_url, $current_language ) . $quote2 . $sometags2 . '>', $translated_page );
|
78 |
|
49 |
foreach ( array_reverse( $this->multisite_service->get_list_of_network_path() ) as $np ) {
|
50 |
if ( strlen( $np ) > 2 && strpos( $url_translated, $np ) !== false ) {
|
51 |
$url_translated = str_replace(
|
52 |
+
str_replace( '//', '/', '/' . $current_language . $np . '/' ),
|
53 |
+
str_replace( '//', '/', $np . '/' . $current_language . '/' ),
|
54 |
$url_translated
|
55 |
);
|
56 |
}
|
63 |
/**
|
64 |
* Replace href in <a>
|
65 |
* @since 2.0
|
66 |
+
* @version 2.0.4
|
67 |
* @param string $translated_page
|
68 |
* @param string $current_url
|
69 |
* @param string $quote1
|
73 |
* @return string
|
74 |
*/
|
75 |
public function replace_a( $translated_page, $current_url, $quote1, $quote2, $sometags = null, $sometags2 = null ) {
|
76 |
+
$current_language = weglot_get_current_language();
|
77 |
+
$no_replace_condition = apply_filters( 'weglot_no_replace_a_href', 'wp-content/uploads' );
|
78 |
+
|
79 |
+
if ( strpos( $current_url, $no_replace_condition ) !== false ) {
|
80 |
+
return $translated_page;
|
81 |
+
}
|
82 |
|
83 |
$translated_page = preg_replace( '/<a' . preg_quote( $sometags, '/' ) . 'href=' . preg_quote( $quote1 . $current_url . $quote2, '/' ) . preg_quote( $sometags2, '/' ) . '>/', '<a' . $sometags . 'href=' . $quote1 . $this->replace_url( $current_url, $current_language ) . $quote2 . $sometags2 . '>', $translated_page );
|
84 |
|
src/services/class-request-url-service-weglot.php
CHANGED
@@ -41,7 +41,7 @@ class Request_Url_Service_Weglot {
|
|
41 |
return new Url(
|
42 |
$url,
|
43 |
$this->option_services->get_option( 'original_language' ),
|
44 |
-
|
45 |
$this->get_home_wordpress_directory()
|
46 |
);
|
47 |
}
|
@@ -63,7 +63,7 @@ class Request_Url_Service_Weglot {
|
|
63 |
$this->weglot_url = new Url(
|
64 |
$this->get_full_url(),
|
65 |
$this->option_services->get_option( 'original_language' ),
|
66 |
-
|
67 |
$this->get_home_wordpress_directory()
|
68 |
);
|
69 |
|
@@ -75,10 +75,11 @@ class Request_Url_Service_Weglot {
|
|
75 |
/**
|
76 |
* Get request URL in process
|
77 |
* @since 2.0
|
|
|
78 |
* @return \Weglot\Util\Url
|
79 |
*/
|
80 |
-
public function get_weglot_url() {
|
81 |
-
if ( null === $this->weglot_url ) {
|
82 |
$this->init_weglot_url();
|
83 |
}
|
84 |
|
@@ -88,14 +89,21 @@ class Request_Url_Service_Weglot {
|
|
88 |
/**
|
89 |
* Abstraction of \Weglot\Util\Url
|
90 |
* @since 2.0
|
|
|
91 |
* @return string
|
92 |
*/
|
93 |
-
public function get_current_language() {
|
94 |
if ( wp_doing_ajax() && isset( $_SERVER['HTTP_REFERER'] ) ) { //phpcs:ignore
|
95 |
-
|
|
|
|
|
96 |
}
|
97 |
|
98 |
-
|
|
|
|
|
|
|
|
|
99 |
}
|
100 |
|
101 |
/**
|
@@ -119,6 +127,16 @@ class Request_Url_Service_Weglot {
|
|
119 |
return Server::fullUrl($_SERVER, $use_forwarded_host); //phpcs:ignore
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
/**
|
124 |
* @todo : Change this when weglot-php included
|
@@ -197,6 +215,7 @@ class Request_Url_Service_Weglot {
|
|
197 |
foreach ( $list_regex as $regex ) {
|
198 |
$str = $this->escape_slash( $regex );
|
199 |
$prepare_regex = sprintf( '/%s/', $str );
|
|
|
200 |
if ( preg_match( $prepare_regex, $url ) === 1 ) {
|
201 |
return apply_filters( 'weglot_is_eligible_url', false, $url );
|
202 |
}
|
41 |
return new Url(
|
42 |
$url,
|
43 |
$this->option_services->get_option( 'original_language' ),
|
44 |
+
weglot_get_destination_languages(),
|
45 |
$this->get_home_wordpress_directory()
|
46 |
);
|
47 |
}
|
63 |
$this->weglot_url = new Url(
|
64 |
$this->get_full_url(),
|
65 |
$this->option_services->get_option( 'original_language' ),
|
66 |
+
weglot_get_destination_languages(),
|
67 |
$this->get_home_wordpress_directory()
|
68 |
);
|
69 |
|
75 |
/**
|
76 |
* Get request URL in process
|
77 |
* @since 2.0
|
78 |
+
* @param boolean $cache
|
79 |
* @return \Weglot\Util\Url
|
80 |
*/
|
81 |
+
public function get_weglot_url( $cache = true ) {
|
82 |
+
if ( null === $this->weglot_url || ! $cache ) {
|
83 |
$this->init_weglot_url();
|
84 |
}
|
85 |
|
89 |
/**
|
90 |
* Abstraction of \Weglot\Util\Url
|
91 |
* @since 2.0
|
92 |
+
* @param boolean $with_filter
|
93 |
* @return string
|
94 |
*/
|
95 |
+
public function get_current_language( $with_filter = true ) {
|
96 |
if ( wp_doing_ajax() && isset( $_SERVER['HTTP_REFERER'] ) ) { //phpcs:ignore
|
97 |
+
$current_language = $this->create_url_object( $_SERVER['HTTP_REFERER'] )->detectCurrentLanguage(); //phpcs:ignore
|
98 |
+
} else {
|
99 |
+
$current_language = $this->get_weglot_url()->detectCurrentLanguage();
|
100 |
}
|
101 |
|
102 |
+
if ( $with_filter ) {
|
103 |
+
return apply_filters( 'weglot_translate_current_language', $current_language );
|
104 |
+
}
|
105 |
+
|
106 |
+
return $current_language;
|
107 |
}
|
108 |
|
109 |
/**
|
127 |
return Server::fullUrl($_SERVER, $use_forwarded_host); //phpcs:ignore
|
128 |
}
|
129 |
|
130 |
+
/**
|
131 |
+
* @since 2.0.4
|
132 |
+
*
|
133 |
+
* @return string
|
134 |
+
* @param mixed $use_forwarded_host
|
135 |
+
*/
|
136 |
+
public function get_full_url_no_language( $use_forwarded_host = false ) {
|
137 |
+
return $this->create_url_object( $this->get_full_url() )->getForLanguage( weglot_get_original_language() );
|
138 |
+
}
|
139 |
+
|
140 |
|
141 |
/**
|
142 |
* @todo : Change this when weglot-php included
|
215 |
foreach ( $list_regex as $regex ) {
|
216 |
$str = $this->escape_slash( $regex );
|
217 |
$prepare_regex = sprintf( '/%s/', $str );
|
218 |
+
|
219 |
if ( preg_match( $prepare_regex, $url ) === 1 ) {
|
220 |
return apply_filters( 'weglot_is_eligible_url', false, $url );
|
221 |
}
|
src/services/class-user-api-service-weglot.php
CHANGED
@@ -6,8 +6,6 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
6 |
exit;
|
7 |
}
|
8 |
|
9 |
-
|
10 |
-
|
11 |
/**
|
12 |
* @since 2.0
|
13 |
*/
|
@@ -38,14 +36,19 @@ class User_Api_Service_Weglot {
|
|
38 |
* @since 2.0
|
39 |
* @version 2.0.1
|
40 |
* @return array
|
|
|
41 |
*/
|
42 |
-
public function get_user_info() {
|
43 |
if ( null !== $this->user_info ) {
|
44 |
return $this->user_info;
|
45 |
}
|
46 |
|
|
|
|
|
|
|
|
|
47 |
try {
|
48 |
-
$results = $this->do_request( self::API_BASE_OLD . 'user-info?api_key=' .
|
49 |
$json = json_decode( $results, true );
|
50 |
if ( json_last_error() !== JSON_ERROR_NONE ) {
|
51 |
throw new \Exception( 'Unknown error with Weglot Api (0001) : ' . json_last_error() );
|
@@ -67,11 +70,36 @@ class User_Api_Service_Weglot {
|
|
67 |
} else {
|
68 |
throw new \Exception( 'Unknown error with Weglot Api (0002) : ' . $json );
|
69 |
}
|
70 |
-
} catch ( \Exception $e) {
|
71 |
-
return [
|
|
|
|
|
72 |
}
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/**
|
76 |
*
|
77 |
* @param string $url
|
6 |
exit;
|
7 |
}
|
8 |
|
|
|
|
|
9 |
/**
|
10 |
* @since 2.0
|
11 |
*/
|
36 |
* @since 2.0
|
37 |
* @version 2.0.1
|
38 |
* @return array
|
39 |
+
* @param null|string $api_key
|
40 |
*/
|
41 |
+
public function get_user_info( $api_key = null ) {
|
42 |
if ( null !== $this->user_info ) {
|
43 |
return $this->user_info;
|
44 |
}
|
45 |
|
46 |
+
if ( null === $api_key ) {
|
47 |
+
$api_key = weglot_get_api_key();
|
48 |
+
}
|
49 |
+
|
50 |
try {
|
51 |
+
$results = $this->do_request( self::API_BASE_OLD . 'user-info?api_key=' . $api_key, null );
|
52 |
$json = json_decode( $results, true );
|
53 |
if ( json_last_error() !== JSON_ERROR_NONE ) {
|
54 |
throw new \Exception( 'Unknown error with Weglot Api (0001) : ' . json_last_error() );
|
70 |
} else {
|
71 |
throw new \Exception( 'Unknown error with Weglot Api (0002) : ' . $json );
|
72 |
}
|
73 |
+
} catch ( \Exception $e ) {
|
74 |
+
return [
|
75 |
+
'allowed' => true,
|
76 |
+
];
|
77 |
}
|
78 |
}
|
79 |
|
80 |
+
/**
|
81 |
+
* @since 2.0.6
|
82 |
+
*
|
83 |
+
* @return int
|
84 |
+
*/
|
85 |
+
public function get_limit_destination_language() {
|
86 |
+
$user_info = $this->get_user_info();
|
87 |
+
$plans = $this->get_plans();
|
88 |
+
$limit = 1000;
|
89 |
+
if (
|
90 |
+
$user_info['plan'] <= 0 ||
|
91 |
+
in_array( $user_info['plan'], $plans['starter_free']['ids'] ) // phpcs:ignore
|
92 |
+
) {
|
93 |
+
$limit = $plans['starter_free']['limit_language'];
|
94 |
+
} elseif (
|
95 |
+
in_array( $user_info['plan'], $plans['business']['ids'] ) // phpcs:ignore
|
96 |
+
) {
|
97 |
+
$limit = $plans['business']['limit_language'];
|
98 |
+
}
|
99 |
+
|
100 |
+
return $limit;
|
101 |
+
}
|
102 |
+
|
103 |
/**
|
104 |
*
|
105 |
* @param string $url
|
src/third/woocommerce/class-wc-filter-urls-weglot.php
CHANGED
@@ -21,13 +21,15 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
|
|
21 |
* @return void
|
22 |
*/
|
23 |
public function __construct() {
|
24 |
-
$this->request_url_services
|
25 |
-
$this->option_services
|
26 |
-
$this->wc_active_services
|
|
|
27 |
}
|
28 |
|
29 |
/**
|
30 |
* @since 2.0
|
|
|
31 |
* @see Hooks_Interface_Weglot
|
32 |
*
|
33 |
* @return void
|
@@ -41,7 +43,7 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
|
|
41 |
add_filter( 'woocommerce_get_checkout_url', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_without_ajax' ] );
|
42 |
add_filter( 'woocommerce_payment_successful_result', [ $this, 'woocommerce_filter_url_array' ] );
|
43 |
add_filter( 'woocommerce_get_checkout_order_received_url', [ $this, 'woocommerce_filter_order_received_url' ] );
|
44 |
-
add_action( 'woocommerce_reset_password_notification', [ $this, 'woocommerce_filter_reset_password' ] );
|
45 |
|
46 |
add_filter( 'woocommerce_login_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
47 |
add_filter( 'woocommerce_registration_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
@@ -101,13 +103,17 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
|
|
101 |
$url = $this->request_url_services->create_url_object( $result['redirect'] );
|
102 |
}
|
103 |
}
|
104 |
-
$result['redirect']
|
|
|
|
|
105 |
return $result;
|
106 |
}
|
107 |
|
108 |
|
109 |
/**
|
110 |
* Redirect URL Lost password for WooCommerce
|
|
|
|
|
111 |
* @param mixed $url
|
112 |
*/
|
113 |
public function woocommerce_filter_reset_password( $url ) {
|
21 |
* @return void
|
22 |
*/
|
23 |
public function __construct() {
|
24 |
+
$this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
|
25 |
+
$this->option_services = weglot_get_service( 'Option_Service_Weglot' );
|
26 |
+
$this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
|
27 |
+
$this->replace_url_services = weglot_get_service( 'Replace_Url_Service_Weglot' );
|
28 |
}
|
29 |
|
30 |
/**
|
31 |
* @since 2.0
|
32 |
+
* @version 2.0.4
|
33 |
* @see Hooks_Interface_Weglot
|
34 |
*
|
35 |
* @return void
|
43 |
add_filter( 'woocommerce_get_checkout_url', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_without_ajax' ] );
|
44 |
add_filter( 'woocommerce_payment_successful_result', [ $this, 'woocommerce_filter_url_array' ] );
|
45 |
add_filter( 'woocommerce_get_checkout_order_received_url', [ $this, 'woocommerce_filter_order_received_url' ] );
|
46 |
+
add_action( 'woocommerce_reset_password_notification', [ $this, 'woocommerce_filter_reset_password' ], 999 );
|
47 |
|
48 |
add_filter( 'woocommerce_login_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
49 |
add_filter( 'woocommerce_registration_redirect', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_log_redirect' ] );
|
103 |
$url = $this->request_url_services->create_url_object( $result['redirect'] );
|
104 |
}
|
105 |
}
|
106 |
+
if ($this->replace_url_services->check_link($result['redirect'])) { // We must not add language code if external link
|
107 |
+
$result['redirect'] = $url->getForLanguage($choose_current_language);
|
108 |
+
}
|
109 |
return $result;
|
110 |
}
|
111 |
|
112 |
|
113 |
/**
|
114 |
* Redirect URL Lost password for WooCommerce
|
115 |
+
* @since 2.0
|
116 |
+
* @version 2.0.4
|
117 |
* @param mixed $url
|
118 |
*/
|
119 |
public function woocommerce_filter_reset_password( $url ) {
|
templates/admin/pages/settings.php
CHANGED
@@ -11,20 +11,19 @@ use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
|
11 |
|
12 |
<div id="wrap-weglot">
|
13 |
<div class="wrap">
|
14 |
-
<?php include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/nav.php'; ?>
|
15 |
-
|
16 |
<form method="post" id="mainform" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
|
17 |
<?php
|
|
|
|
|
18 |
switch ( $this->tab_active ) {
|
19 |
case Helper_Tabs_Admin_Weglot::SETTINGS:
|
20 |
default:
|
21 |
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/settings.php';
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/advanced.php';
|
28 |
break;
|
29 |
case Helper_Tabs_Admin_Weglot::STATUS:
|
30 |
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/status.php';
|
@@ -38,7 +37,8 @@ use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
|
38 |
?>
|
39 |
<input type="hidden" name="tab" value="<?php echo esc_attr( $this->tab_active ); ?>">
|
40 |
</form>
|
41 |
-
|
|
|
42 |
<hr>
|
43 |
<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/weglot?rate=5#postform">
|
44 |
<?php esc_html_e( 'Love Weglot? Give us 5 stars on WordPress.org :)', 'weglot' ); ?>
|
@@ -50,9 +50,10 @@ use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
|
50 |
echo sprintf( esc_html__( 'If you need any help, you can contact us via email us at support@weglot.com.', 'weglot' ), '<a href="https://weglot.com/" target="_blank">', '</a>' );
|
51 |
echo '<br>';
|
52 |
// translators: 1 HTML Tag, 2 HTML Tag
|
53 |
-
echo sprintf( esc_html__( 'You can also check our %1$sFAQ%2$s', 'weglot' ), '<a href="http://support.weglot.com/" target="_blank">', '</a>' );
|
54 |
-
?>
|
55 |
</p>
|
|
|
|
|
56 |
</div>
|
57 |
<?php
|
58 |
if ( ! $this->options['has_first_settings'] ) :
|
@@ -66,7 +67,7 @@ use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
|
66 |
</a>
|
67 |
</div>
|
68 |
</div>
|
69 |
-
<?php
|
70 |
endif;
|
71 |
?>
|
72 |
</div>
|
11 |
|
12 |
<div id="wrap-weglot">
|
13 |
<div class="wrap">
|
|
|
|
|
14 |
<form method="post" id="mainform" action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>">
|
15 |
<?php
|
16 |
+
|
17 |
+
|
18 |
switch ( $this->tab_active ) {
|
19 |
case Helper_Tabs_Admin_Weglot::SETTINGS:
|
20 |
default:
|
21 |
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/settings.php';
|
22 |
+
if ( ! $this->options['has_first_settings'] ) {
|
23 |
+
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/appearance.php';
|
24 |
+
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/advanced.php';
|
25 |
+
}
|
26 |
+
|
|
|
27 |
break;
|
28 |
case Helper_Tabs_Admin_Weglot::STATUS:
|
29 |
include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/status.php';
|
37 |
?>
|
38 |
<input type="hidden" name="tab" value="<?php echo esc_attr( $this->tab_active ); ?>">
|
39 |
</form>
|
40 |
+
<?php if ( ! $this->options['has_first_settings'] ) {
|
41 |
+
?>
|
42 |
<hr>
|
43 |
<a target="_blank" href="http://wordpress.org/support/view/plugin-reviews/weglot?rate=5#postform">
|
44 |
<?php esc_html_e( 'Love Weglot? Give us 5 stars on WordPress.org :)', 'weglot' ); ?>
|
50 |
echo sprintf( esc_html__( 'If you need any help, you can contact us via email us at support@weglot.com.', 'weglot' ), '<a href="https://weglot.com/" target="_blank">', '</a>' );
|
51 |
echo '<br>';
|
52 |
// translators: 1 HTML Tag, 2 HTML Tag
|
53 |
+
echo sprintf( esc_html__( 'You can also check our %1$sFAQ%2$s', 'weglot' ), '<a href="http://support.weglot.com/" target="_blank">', '</a>' ); ?>
|
|
|
54 |
</p>
|
55 |
+
<?php
|
56 |
+
} ?>
|
57 |
</div>
|
58 |
<?php
|
59 |
if ( ! $this->options['has_first_settings'] ) :
|
67 |
</a>
|
68 |
</div>
|
69 |
</div>
|
70 |
+
<?php
|
71 |
endif;
|
72 |
?>
|
73 |
</div>
|
templates/admin/pages/tabs/advanced.php
CHANGED
@@ -9,6 +9,16 @@ use Weglot\Client\Client;
|
|
9 |
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
10 |
|
11 |
$options_available = [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
'auto_redirect' => [
|
13 |
'key' => 'auto_redirect',
|
14 |
'label' => __( 'Auto redirection', 'weglot' ),
|
@@ -28,7 +38,78 @@ $options_available = [
|
|
28 |
|
29 |
?>
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
|
|
|
|
32 |
<table class="form-table">
|
33 |
<tbody>
|
34 |
<tr valign="top">
|
@@ -99,3 +180,30 @@ $options_available = [
|
|
99 |
</p>
|
100 |
</div>
|
101 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
|
10 |
|
11 |
$options_available = [
|
12 |
+
'exclude_urls' => [
|
13 |
+
'key' => 'exclude_urls',
|
14 |
+
'label' => __( 'Exclusion URL', 'weglot' ),
|
15 |
+
'description' => __( 'Add URL that you want to exclude from translations. You can use regular expression to match multiple URLs. ', 'weglot' ),
|
16 |
+
],
|
17 |
+
'exclude_blocks' => [
|
18 |
+
'key' => 'exclude_blocks',
|
19 |
+
'label' => __( 'Exclusion Blocks', 'weglot' ),
|
20 |
+
'description' => __( 'Enter the CSS selector of blocks you don\'t want to translate (like a sidebar, a menu, a paragraph etc...', 'weglot' ),
|
21 |
+
],
|
22 |
'auto_redirect' => [
|
23 |
'key' => 'auto_redirect',
|
24 |
'label' => __( 'Auto redirection', 'weglot' ),
|
38 |
|
39 |
?>
|
40 |
|
41 |
+
<h3><?php esc_html_e( 'Translation Exclusion (Optional)', 'weglot' ); ?> </h3>
|
42 |
+
<hr>
|
43 |
+
<p><?php esc_html_e( 'By default, every page is translated. You can exclude parts of a page or a full page here.', 'weglot' ); ?></p>
|
44 |
+
<table class="form-table">
|
45 |
+
<tbody>
|
46 |
+
<tr valign="top">
|
47 |
+
<th scope="row" class="titledesc">
|
48 |
+
<label for="<?php echo esc_attr( $options_available['exclude_urls']['key'] ); ?>">
|
49 |
+
<?php echo esc_html( $options_available['exclude_urls']['label'] ); ?>
|
50 |
+
</label>
|
51 |
+
<p class="sub-label"><?php echo esc_html( $options_available['exclude_urls']['description'] ); ?></p>
|
52 |
+
</th>
|
53 |
+
<td class="forminp forminp-text">
|
54 |
+
<div id="container-<?php echo esc_attr( $options_available['exclude_urls']['key'] ); ?>">
|
55 |
+
<?php
|
56 |
+
if ( ! empty( $this->options[ $options_available['exclude_urls']['key'] ] ) ) :
|
57 |
+
foreach ( $this->options[ $options_available['exclude_urls']['key'] ] as $option ) :
|
58 |
+
?>
|
59 |
+
<div class="item-exclude">
|
60 |
+
<input
|
61 |
+
type="text"
|
62 |
+
placeholder="/my-awesome-url"
|
63 |
+
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_urls']['key'] ) ); ?>[]"
|
64 |
+
value="<?php echo esc_attr( $option ); ?>"
|
65 |
+
>
|
66 |
+
<button class="js-btn-remove js-btn-remove-exclude-url">
|
67 |
+
<span class="dashicons dashicons-minus"></span>
|
68 |
+
</button>
|
69 |
+
</div>
|
70 |
+
<?php
|
71 |
+
endforeach;
|
72 |
+
endif; ?>
|
73 |
+
</div>
|
74 |
+
<button id="js-add-exclude-url" class="btn btn-soft"><?php esc_html_e( 'Add an URL to exclude', 'weglot' ); ?></button>
|
75 |
+
</td>
|
76 |
+
</tr>
|
77 |
+
<tr valign="top">
|
78 |
+
<th scope="row" class="titledesc">
|
79 |
+
<label for="<?php echo esc_attr( $options_available['exclude_blocks']['key'] ); ?>">
|
80 |
+
<?php echo esc_html( $options_available['exclude_blocks']['label'] ); ?>
|
81 |
+
</label>
|
82 |
+
<p class="sub-label"><?php echo esc_html( $options_available['exclude_blocks']['description'] ); ?></p>
|
83 |
+
</th>
|
84 |
+
<td class="forminp forminp-text">
|
85 |
+
<div id="container-<?php echo esc_attr( $options_available['exclude_blocks']['key'] ); ?>">
|
86 |
+
<?php
|
87 |
+
if ( ! empty( $this->options[ $options_available['exclude_blocks']['key'] ] ) ) :
|
88 |
+
foreach ( $this->options[ $options_available['exclude_blocks']['key'] ] as $option ) :
|
89 |
+
?>
|
90 |
+
<div class="item-exclude">
|
91 |
+
<input
|
92 |
+
type="text"
|
93 |
+
placeholder=".my-class"
|
94 |
+
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_blocks']['key'] ) ); ?>[]"
|
95 |
+
value="<?php echo esc_attr( $option ); ?>"
|
96 |
+
>
|
97 |
+
<button class="js-btn-remove js-btn-remove-exclude">
|
98 |
+
<span class="dashicons dashicons-minus"></span>
|
99 |
+
</button>
|
100 |
+
</div>
|
101 |
+
<?php
|
102 |
+
endforeach;
|
103 |
+
endif; ?>
|
104 |
+
</div>
|
105 |
+
<button id="js-add-exclude-block" class="btn btn-soft"><?php esc_html_e( 'Add a block to exclude', 'weglot' ); ?></button>
|
106 |
+
</td>
|
107 |
+
</tr>
|
108 |
+
</tbody>
|
109 |
+
</table>
|
110 |
|
111 |
+
<h3><?php esc_html_e( 'Other options (Optional)', 'weglot' ); ?></h3>
|
112 |
+
<hr>
|
113 |
<table class="form-table">
|
114 |
<tbody>
|
115 |
<tr valign="top">
|
180 |
</p>
|
181 |
</div>
|
182 |
|
183 |
+
<template id="tpl-exclusion-url">
|
184 |
+
<div class="item-exclude">
|
185 |
+
<input
|
186 |
+
type="text"
|
187 |
+
placeholder="/my-awesome-url"
|
188 |
+
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_urls']['key'] ) ); ?>[]"
|
189 |
+
value=""
|
190 |
+
>
|
191 |
+
<button class="js-btn-remove js-btn-remove-exclude">
|
192 |
+
<span class="dashicons dashicons-minus"></span>
|
193 |
+
</button>
|
194 |
+
</div>
|
195 |
+
</template>
|
196 |
+
|
197 |
+
<template id="tpl-exclusion-block">
|
198 |
+
<div class="item-exclude">
|
199 |
+
<input
|
200 |
+
type="text"
|
201 |
+
placeholder=".my-class"
|
202 |
+
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_blocks']['key'] ) ); ?>[]"
|
203 |
+
value=""
|
204 |
+
>
|
205 |
+
<button class="js-btn-remove js-btn-remove-exclude">
|
206 |
+
<span class="dashicons dashicons-minus"></span>
|
207 |
+
</button>
|
208 |
+
</div>
|
209 |
+
</template>
|
templates/admin/pages/tabs/appearance.php
CHANGED
@@ -303,3 +303,7 @@ $options_available = [
|
|
303 |
</tr>
|
304 |
</table>
|
305 |
|
|
|
|
|
|
|
|
303 |
</tr>
|
304 |
</table>
|
305 |
|
306 |
+
<template id="li-button-tpl">
|
307 |
+
<li class="wg-li {CLASSES} {CODE_LANGUAGE}" data-code-language="{CODE_LANGUAGE}">
|
308 |
+
<a href="#">{LABEL_LANGUAGE}</a></li>
|
309 |
+
</template>
|
templates/admin/pages/tabs/settings.php
CHANGED
@@ -9,7 +9,7 @@ $options_available = [
|
|
9 |
'api_key' => [
|
10 |
'key' => 'api_key',
|
11 |
'label' => __( 'API Key', 'weglot' ),
|
12 |
-
'description' => __( 'Log in to <a target="_blank" href="https://weglot.com/register-wordpress">Weglot</a> to get your API key.
|
13 |
],
|
14 |
'original_language' => [
|
15 |
'key' => 'original_language',
|
@@ -18,23 +18,15 @@ $options_available = [
|
|
18 |
],
|
19 |
'destination_language' => [
|
20 |
'key' => 'destination_language',
|
21 |
-
'label' => __( 'Destination
|
22 |
'description' => 'Choose languages you want to translate into. Supported languages can be found <a target="_blank" href="https://weglot.com/translation-api#languages_code">here</a>.',
|
23 |
],
|
24 |
-
'exclude_urls' => [
|
25 |
-
'key' => 'exclude_urls',
|
26 |
-
'label' => __( 'Exclusion URL', 'weglot' ),
|
27 |
-
'description' => __( 'Add URL that you want to exclude from translations. You can use regular expression to match multiple URLs. ', 'weglot' ),
|
28 |
-
],
|
29 |
-
'exclude_blocks' => [
|
30 |
-
'key' => 'exclude_blocks',
|
31 |
-
'label' => __( 'Exclusion Blocks', 'weglot' ),
|
32 |
-
'description' => __( 'Enter the CSS selector of blocks you don\'t want to translate (like a sidebar, a menu, a paragraph etc...', 'weglot' ),
|
33 |
-
],
|
34 |
];
|
35 |
|
36 |
|
37 |
-
$languages = $this->language_services->get_languages_available(
|
|
|
|
|
38 |
$user_info = $this->user_api_services->get_user_info();
|
39 |
$plans = $this->user_api_services->get_plans();
|
40 |
|
@@ -56,9 +48,16 @@ $plans = $this->user_api_services->get_plans();
|
|
56 |
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['api_key']['key'] ) ); ?>"
|
57 |
id="<?php echo esc_attr( $options_available['api_key']['key'] ); ?>"
|
58 |
type="text"
|
|
|
59 |
placeholder="wg_XXXXXXXXXXXX"
|
60 |
value="<?php echo esc_attr( $this->options[ $options_available['api_key']['key'] ] ); ?>"
|
61 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
</td>
|
63 |
</tr>
|
64 |
<tr valign="top">
|
@@ -71,7 +70,6 @@ $plans = $this->user_api_services->get_plans();
|
|
71 |
<td class="forminp forminp-text">
|
72 |
<select
|
73 |
class="weglot-select weglot-select-original"
|
74 |
-
style="display:none"
|
75 |
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['original_language']['key'] ) ); ?>"
|
76 |
id="<?php echo esc_attr( $options_available['original_language']['key'] ); ?>"
|
77 |
>
|
@@ -80,7 +78,7 @@ $plans = $this->user_api_services->get_plans();
|
|
80 |
value="<?php echo esc_attr( $language->getIso639() ); ?>"
|
81 |
<?php selected( $language->getIso639(), $this->options[ $options_available['original_language']['key'] ] ); ?>
|
82 |
>
|
83 |
-
<?php
|
84 |
</option>
|
85 |
<?php endforeach; ?>
|
86 |
</select>
|
@@ -93,6 +91,7 @@ $plans = $this->user_api_services->get_plans();
|
|
93 |
</label>
|
94 |
<p class="sub-label"><?php echo $options_available['destination_language']['description']; //phpcs:ignore ?></p>
|
95 |
</th>
|
|
|
96 |
<td class="forminp forminp-text">
|
97 |
<select
|
98 |
class="weglot-select weglot-select-destination"
|
@@ -102,6 +101,16 @@ $plans = $this->user_api_services->get_plans();
|
|
102 |
multiple="true"
|
103 |
required
|
104 |
>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
<?php foreach ( $languages as $language ) : ?>
|
106 |
<option
|
107 |
value="<?php echo esc_attr( $language->getIso639() ); ?>"
|
@@ -117,21 +126,21 @@ $plans = $this->user_api_services->get_plans();
|
|
117 |
?>
|
118 |
<p class="description">
|
119 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
120 |
-
<?php echo sprintf( esc_html__( 'On the free plan, you can
|
121 |
</p>
|
122 |
<?php
|
123 |
} elseif ( in_array( $user_info['plan'], $plans['starter_free']['ids'] ) ) { //phpcs:ignore
|
124 |
?>
|
125 |
<p class="description">
|
126 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
127 |
-
<?php echo sprintf( esc_html__( 'On the Starter plan, you can choose one language. If you
|
128 |
</p>
|
129 |
<?php
|
130 |
} elseif ( in_array( $user_info['plan'], $plans['business']['ids'] ) ) { //phpcs:ignore
|
131 |
?>
|
132 |
<p class="description">
|
133 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
134 |
-
<?php echo sprintf( esc_html__( 'On the Business plan, you can choose five languages. If you
|
135 |
</p>
|
136 |
<?php
|
137 |
}
|
@@ -141,78 +150,6 @@ $plans = $this->user_api_services->get_plans();
|
|
141 |
</tbody>
|
142 |
</table>
|
143 |
|
144 |
-
<h3><?php esc_html_e( 'Translation Exclusion (Optional)', 'weglot' ); ?> </h3>
|
145 |
-
<hr>
|
146 |
-
<p><?php esc_html__( 'By default, every page is translated. You can exclude parts of a page or a full page here.', 'weglot' ); ?></p>
|
147 |
-
<table class="form-table">
|
148 |
-
<tbody>
|
149 |
-
<tr valign="top">
|
150 |
-
<th scope="row" class="titledesc">
|
151 |
-
<label for="<?php echo esc_attr( $options_available['exclude_urls']['key'] ); ?>">
|
152 |
-
<?php echo esc_html( $options_available['exclude_urls']['label'] ); ?>
|
153 |
-
</label>
|
154 |
-
<p class="sub-label"><?php echo esc_html( $options_available['exclude_urls']['description'] ); ?></p>
|
155 |
-
</th>
|
156 |
-
<td class="forminp forminp-text">
|
157 |
-
<div id="container-<?php echo esc_attr( $options_available['exclude_urls']['key'] ); ?>">
|
158 |
-
<?php
|
159 |
-
if ( ! empty( $this->options[ $options_available['exclude_urls']['key'] ] ) ) :
|
160 |
-
foreach ( $this->options[ $options_available['exclude_urls']['key'] ] as $option ) :
|
161 |
-
?>
|
162 |
-
<div class="item-exclude">
|
163 |
-
<input
|
164 |
-
type="text"
|
165 |
-
placeholder="/my-awesome-url"
|
166 |
-
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_urls']['key'] ) ); ?>[]"
|
167 |
-
value="<?php echo esc_attr( $option ); ?>"
|
168 |
-
>
|
169 |
-
<button class="js-btn-remove js-btn-remove-exclude-url">
|
170 |
-
<span class="dashicons dashicons-minus"></span>
|
171 |
-
</button>
|
172 |
-
</div>
|
173 |
-
<?php
|
174 |
-
endforeach;
|
175 |
-
endif;
|
176 |
-
?>
|
177 |
-
</div>
|
178 |
-
<button id="js-add-exclude-url" class="btn btn-soft"><?php esc_html_e( 'Add an URL to exclude', 'weglot' ); ?></button>
|
179 |
-
</td>
|
180 |
-
</tr>
|
181 |
-
<tr valign="top">
|
182 |
-
<th scope="row" class="titledesc">
|
183 |
-
<label for="<?php echo esc_attr( $options_available['exclude_blocks']['key'] ); ?>">
|
184 |
-
<?php echo esc_html( $options_available['exclude_blocks']['label'] ); ?>
|
185 |
-
</label>
|
186 |
-
<p class="sub-label"><?php echo esc_html( $options_available['exclude_blocks']['description'] ); ?></p>
|
187 |
-
</th>
|
188 |
-
<td class="forminp forminp-text">
|
189 |
-
<div id="container-<?php echo esc_attr( $options_available['exclude_blocks']['key'] ); ?>">
|
190 |
-
<?php
|
191 |
-
if ( ! empty( $this->options[ $options_available['exclude_blocks']['key'] ] ) ) :
|
192 |
-
foreach ( $this->options[ $options_available['exclude_blocks']['key'] ] as $option ) :
|
193 |
-
?>
|
194 |
-
<div class="item-exclude">
|
195 |
-
<input
|
196 |
-
type="text"
|
197 |
-
placeholder=".my-class"
|
198 |
-
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_blocks']['key'] ) ); ?>[]"
|
199 |
-
value="<?php echo esc_attr( $option ); ?>"
|
200 |
-
>
|
201 |
-
<button class="js-btn-remove js-btn-remove-exclude">
|
202 |
-
<span class="dashicons dashicons-minus"></span>
|
203 |
-
</button>
|
204 |
-
</div>
|
205 |
-
<?php
|
206 |
-
endforeach;
|
207 |
-
endif;
|
208 |
-
?>
|
209 |
-
</div>
|
210 |
-
<button id="js-add-exclude-block" class="btn btn-soft"><?php esc_html_e( 'Add a block to exclude', 'weglot' ); ?></button>
|
211 |
-
</td>
|
212 |
-
</tr>
|
213 |
-
</tbody>
|
214 |
-
</table>
|
215 |
-
|
216 |
|
217 |
<?php if ( ! $this->options['has_first_settings'] && $this->options['show_box_first_settings'] ) : ?>
|
218 |
<?php $this->option_services->set_option_by_key( 'show_box_first_settings', false ); // remove showbox ?>
|
@@ -220,11 +157,11 @@ $plans = $this->user_api_services->get_plans();
|
|
220 |
<div class="weglot-box">
|
221 |
<a class="weglot-btn-close"><?php esc_html_e( 'Close', 'weglot' ); ?></a>
|
222 |
<h3 class="weglot-box--title"><?php esc_html_e( 'Well done! Your website is now multilingual.', 'weglot' ); ?></h3>
|
223 |
-
<p class="weglot-box--text"><?php esc_html_e( 'Go on your website, there is a language switcher. Try it :)', 'weglot' ); ?></p>
|
224 |
<a class="button button-primary" href="<?php echo esc_attr( home_url() ); ?>" target="_blank">
|
225 |
<?php esc_html_e( 'Go on my front page.', 'weglot' ); ?>
|
226 |
</a>
|
227 |
-
<p class="weglot-box--subtext"><?php esc_html_e( 'Next step, edit your translations directly in your Weglot account.', 'weglot' ); ?></p>
|
228 |
</div>
|
229 |
</div>
|
230 |
<?php
|
@@ -236,31 +173,3 @@ $plans = $this->user_api_services->get_plans();
|
|
236 |
</iframe>
|
237 |
<?php endif; ?>
|
238 |
<?php endif; ?>
|
239 |
-
|
240 |
-
<template id="tpl-exclusion-url">
|
241 |
-
<div class="item-exclude">
|
242 |
-
<input
|
243 |
-
type="text"
|
244 |
-
placeholder="/my-awesome-url"
|
245 |
-
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_urls']['key'] ) ); ?>[]"
|
246 |
-
value=""
|
247 |
-
>
|
248 |
-
<button class="js-btn-remove js-btn-remove-exclude">
|
249 |
-
<span class="dashicons dashicons-minus"></span>
|
250 |
-
</button>
|
251 |
-
</div>
|
252 |
-
</template>
|
253 |
-
|
254 |
-
<template id="tpl-exclusion-block">
|
255 |
-
<div class="item-exclude">
|
256 |
-
<input
|
257 |
-
type="text"
|
258 |
-
placeholder=".my-class"
|
259 |
-
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['exclude_blocks']['key'] ) ); ?>[]"
|
260 |
-
value=""
|
261 |
-
>
|
262 |
-
<button class="js-btn-remove js-btn-remove-exclude">
|
263 |
-
<span class="dashicons dashicons-minus"></span>
|
264 |
-
</button>
|
265 |
-
</div>
|
266 |
-
</template>
|
9 |
'api_key' => [
|
10 |
'key' => 'api_key',
|
11 |
'label' => __( 'API Key', 'weglot' ),
|
12 |
+
'description' => __( 'Log in to <a target="_blank" href="https://weglot.com/register-wordpress">Weglot</a> to get your API key.', 'weglot' ),
|
13 |
],
|
14 |
'original_language' => [
|
15 |
'key' => 'original_language',
|
18 |
],
|
19 |
'destination_language' => [
|
20 |
'key' => 'destination_language',
|
21 |
+
'label' => __( 'Destination languages', 'weglot' ),
|
22 |
'description' => 'Choose languages you want to translate into. Supported languages can be found <a target="_blank" href="https://weglot.com/translation-api#languages_code">here</a>.',
|
23 |
],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
];
|
25 |
|
26 |
|
27 |
+
$languages = $this->language_services->get_languages_available( [
|
28 |
+
'sort' => true,
|
29 |
+
] );
|
30 |
$user_info = $this->user_api_services->get_user_info();
|
31 |
$plans = $this->user_api_services->get_plans();
|
32 |
|
48 |
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['api_key']['key'] ) ); ?>"
|
49 |
id="<?php echo esc_attr( $options_available['api_key']['key'] ); ?>"
|
50 |
type="text"
|
51 |
+
required
|
52 |
placeholder="wg_XXXXXXXXXXXX"
|
53 |
value="<?php echo esc_attr( $this->options[ $options_available['api_key']['key'] ] ); ?>"
|
54 |
>
|
55 |
+
<br>
|
56 |
+
<?php if ( $this->options['has_first_settings'] ) {
|
57 |
+
?>
|
58 |
+
<p class="description"><?php echo esc_html_e( 'If you don\'t have an account, you can create one in 20 seconds !', 'weglot' ); ?></p>
|
59 |
+
<?php
|
60 |
+
} ?>
|
61 |
</td>
|
62 |
</tr>
|
63 |
<tr valign="top">
|
70 |
<td class="forminp forminp-text">
|
71 |
<select
|
72 |
class="weglot-select weglot-select-original"
|
|
|
73 |
name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['original_language']['key'] ) ); ?>"
|
74 |
id="<?php echo esc_attr( $options_available['original_language']['key'] ); ?>"
|
75 |
>
|
78 |
value="<?php echo esc_attr( $language->getIso639() ); ?>"
|
79 |
<?php selected( $language->getIso639(), $this->options[ $options_available['original_language']['key'] ] ); ?>
|
80 |
>
|
81 |
+
<?php esc_html_e( $language->getEnglishName(), 'weglot'); //phpcs:ignore ?>
|
82 |
</option>
|
83 |
<?php endforeach; ?>
|
84 |
</select>
|
91 |
</label>
|
92 |
<p class="sub-label"><?php echo $options_available['destination_language']['description']; //phpcs:ignore ?></p>
|
93 |
</th>
|
94 |
+
|
95 |
<td class="forminp forminp-text">
|
96 |
<select
|
97 |
class="weglot-select weglot-select-destination"
|
101 |
multiple="true"
|
102 |
required
|
103 |
>
|
104 |
+
<?php foreach ( $this->options[ $options_available['destination_language']['key'] ] as $language ) :
|
105 |
+
$languages[ $language ]; ?>
|
106 |
+
<option
|
107 |
+
value="<?php echo esc_attr( $language ); ?>"
|
108 |
+
selected="selected"
|
109 |
+
>
|
110 |
+
<?php echo esc_html( $language ); ?>
|
111 |
+
</option>
|
112 |
+
<?php endforeach; ?>
|
113 |
+
|
114 |
<?php foreach ( $languages as $language ) : ?>
|
115 |
<option
|
116 |
value="<?php echo esc_attr( $language->getIso639() ); ?>"
|
126 |
?>
|
127 |
<p class="description">
|
128 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
129 |
+
<?php echo sprintf( esc_html__( 'On the free plan, you can choose one language and use a maximum of 2000 words. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
|
130 |
</p>
|
131 |
<?php
|
132 |
} elseif ( in_array( $user_info['plan'], $plans['starter_free']['ids'] ) ) { //phpcs:ignore
|
133 |
?>
|
134 |
<p class="description">
|
135 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
136 |
+
<?php echo sprintf( esc_html__( 'On the Starter plan, you can choose one language. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
|
137 |
</p>
|
138 |
<?php
|
139 |
} elseif ( in_array( $user_info['plan'], $plans['business']['ids'] ) ) { //phpcs:ignore
|
140 |
?>
|
141 |
<p class="description">
|
142 |
<?php // translators: 1 HTML Tag, 2 HTML Tag ?>
|
143 |
+
<?php echo sprintf( esc_html__( 'On the Business plan, you can choose five languages. If you need more, please %1$supgrade your plan%2$s.', 'weglot' ), '<a target="_blank" href="https://dashboard.weglot.com/billing/upgrade">', '</a>' ); ?>
|
144 |
</p>
|
145 |
<?php
|
146 |
}
|
150 |
</tbody>
|
151 |
</table>
|
152 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
<?php if ( ! $this->options['has_first_settings'] && $this->options['show_box_first_settings'] ) : ?>
|
155 |
<?php $this->option_services->set_option_by_key( 'show_box_first_settings', false ); // remove showbox ?>
|
157 |
<div class="weglot-box">
|
158 |
<a class="weglot-btn-close"><?php esc_html_e( 'Close', 'weglot' ); ?></a>
|
159 |
<h3 class="weglot-box--title"><?php esc_html_e( 'Well done! Your website is now multilingual.', 'weglot' ); ?></h3>
|
160 |
+
<p class="weglot-box--text"><?php esc_html_e( 'Go on your website, there is a language switcher bottom right. Try it :)', 'weglot' ); ?></p>
|
161 |
<a class="button button-primary" href="<?php echo esc_attr( home_url() ); ?>" target="_blank">
|
162 |
<?php esc_html_e( 'Go on my front page.', 'weglot' ); ?>
|
163 |
</a>
|
164 |
+
<p class="weglot-box--subtext"><?php esc_html_e( 'Next step, customize the language button as you want and manually edit your translations directly in your Weglot account.', 'weglot' ); ?></p>
|
165 |
</div>
|
166 |
</div>
|
167 |
<?php
|
173 |
</iframe>
|
174 |
<?php endif; ?>
|
175 |
<?php endif; ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitec5eb040bcf6bc06d6afc63577f1384f::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInite807ffc58eb349a6e9e74a3e430e31e5
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
@@ -48,19 +48,19 @@ class ComposerAutoloaderInite807ffc58eb349a6e9e74a3e430e31e5
|
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
-
$includeFiles = Composer\Autoload\
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
-
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
-
function
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitec5eb040bcf6bc06d6afc63577f1384f
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitec5eb040bcf6bc06d6afc63577f1384f', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitec5eb040bcf6bc06d6afc63577f1384f', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
48 |
$loader->register(true);
|
49 |
|
50 |
if ($useStaticLoader) {
|
51 |
+
$includeFiles = Composer\Autoload\ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f::$files;
|
52 |
} else {
|
53 |
$includeFiles = require __DIR__ . '/autoload_files.php';
|
54 |
}
|
55 |
foreach ($includeFiles as $fileIdentifier => $file) {
|
56 |
+
composerRequireec5eb040bcf6bc06d6afc63577f1384f($fileIdentifier, $file);
|
57 |
}
|
58 |
|
59 |
return $loader;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
function composerRequireec5eb040bcf6bc06d6afc63577f1384f($fileIdentifier, $file)
|
64 |
{
|
65 |
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
|
66 |
require $file;
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
@@ -45,9 +45,9 @@ class ComposerStaticInite807ffc58eb349a6e9e74a3e430e31e5
|
|
45 |
public static function getInitializer(ClassLoader $loader)
|
46 |
{
|
47 |
return \Closure::bind(function () use ($loader) {
|
48 |
-
$loader->prefixLengthsPsr4 =
|
49 |
-
$loader->prefixDirsPsr4 =
|
50 |
-
$loader->prefixesPsr0 =
|
51 |
|
52 |
}, null, ClassLoader::class);
|
53 |
}
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f
|
8 |
{
|
9 |
public static $files = array (
|
10 |
'6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
|
45 |
public static function getInitializer(ClassLoader $loader)
|
46 |
{
|
47 |
return \Closure::bind(function () use ($loader) {
|
48 |
+
$loader->prefixLengthsPsr4 = ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f::$prefixLengthsPsr4;
|
49 |
+
$loader->prefixDirsPsr4 = ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f::$prefixDirsPsr4;
|
50 |
+
$loader->prefixesPsr0 = ComposerStaticInitec5eb040bcf6bc06d6afc63577f1384f::$prefixesPsr0;
|
51 |
|
52 |
}, null, ClassLoader::class);
|
53 |
}
|
vendor/composer/installed.json
CHANGED
@@ -96,17 +96,17 @@
|
|
96 |
},
|
97 |
{
|
98 |
"name": "weglot/weglot-php",
|
99 |
-
"version": "0.5.
|
100 |
-
"version_normalized": "0.5.
|
101 |
"source": {
|
102 |
"type": "git",
|
103 |
"url": "https://github.com/weglot/weglot-php.git",
|
104 |
-
"reference": "
|
105 |
},
|
106 |
"dist": {
|
107 |
"type": "zip",
|
108 |
-
"url": "https://api.github.com/repos/weglot/weglot-php/zipball/
|
109 |
-
"reference": "
|
110 |
"shasum": ""
|
111 |
},
|
112 |
"require": {
|
@@ -118,7 +118,7 @@
|
|
118 |
"codeception/codeception": "^2.4",
|
119 |
"vlucas/phpdotenv": "^2.4"
|
120 |
},
|
121 |
-
"time": "2018-07-
|
122 |
"type": "library",
|
123 |
"installation-source": "dist",
|
124 |
"autoload": {
|
96 |
},
|
97 |
{
|
98 |
"name": "weglot/weglot-php",
|
99 |
+
"version": "0.5.11",
|
100 |
+
"version_normalized": "0.5.11.0",
|
101 |
"source": {
|
102 |
"type": "git",
|
103 |
"url": "https://github.com/weglot/weglot-php.git",
|
104 |
+
"reference": "7f2df77f2eb195f8554606555732bb8836f04407"
|
105 |
},
|
106 |
"dist": {
|
107 |
"type": "zip",
|
108 |
+
"url": "https://api.github.com/repos/weglot/weglot-php/zipball/7f2df77f2eb195f8554606555732bb8836f04407",
|
109 |
+
"reference": "7f2df77f2eb195f8554606555732bb8836f04407",
|
110 |
"shasum": ""
|
111 |
},
|
112 |
"require": {
|
118 |
"codeception/codeception": "^2.4",
|
119 |
"vlucas/phpdotenv": "^2.4"
|
120 |
},
|
121 |
+
"time": "2018-07-31T15:23:07+00:00",
|
122 |
"type": "library",
|
123 |
"installation-source": "dist",
|
124 |
"autoload": {
|
vendor/weglot/simplehtmldom/README.md
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!-- logo -->
|
2 |
+
<img src="https://cdn.weglot.com/logo/logo-hor.png" height="40" />
|
3 |
+
|
4 |
+
# simple_html_dom
|
5 |
+
[![Latest Stable Version](https://poser.pugx.org/weglot/simplehtmldom/v/stable)](https://packagist.org/packages/weglot/simplehtmldom)
|
6 |
+
[![License](https://poser.pugx.org/weglot/simplehtmldom/license)](https://packagist.org/packages/weglot/simplehtmldom)
|
7 |
+
|
8 |
+
## Overview
|
9 |
+
Simple fork of [simple_html_dom](http://simplehtmldom.sourceforge.net/) PHP library with some tweaks.
|
10 |
+
|
11 |
+
## Changelog
|
12 |
+
|
13 |
+
## [0.3] - 2018-07-23
|
14 |
+
### Added
|
15 |
+
- redo modifications previsouly done like max size for exemple
|
16 |
+
|
17 |
+
## [0.2] - 2018-04-12
|
18 |
+
### Added
|
19 |
+
- hasAncestorAttribute function to check if a node has given attribute in his ancestors
|
20 |
+
|
21 |
+
## [0.1] - 2018-04-04
|
22 |
+
### Changed
|
23 |
+
- Weglot modifications to make `simple_html_dom` working onto WordPress
|
vendor/weglot/weglot-php/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
6 |
|
7 |
## [Unreleased]
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
## [0.5.9] - 2018-07-19
|
10 |
### Changed
|
11 |
- Cleaning tags html entities before rendering
|
6 |
|
7 |
## [Unreleased]
|
8 |
|
9 |
+
## [0.5.11] - 2018-07-31
|
10 |
+
### Changed
|
11 |
+
Better API errors management
|
12 |
+
|
13 |
+
## [0.5.10] - ????-??-??
|
14 |
+
???
|
15 |
+
|
16 |
## [0.5.9] - 2018-07-19
|
17 |
### Changed
|
18 |
- Cleaning tags html entities before rendering
|
vendor/weglot/weglot-php/src/Client/Client.php
CHANGED
@@ -22,7 +22,7 @@ class Client
|
|
22 |
*
|
23 |
* @var string
|
24 |
*/
|
25 |
-
const VERSION = '0.5.
|
26 |
|
27 |
/**
|
28 |
* Weglot API Key
|
22 |
*
|
23 |
* @var string
|
24 |
*/
|
25 |
+
const VERSION = '0.5.11';
|
26 |
|
27 |
/**
|
28 |
* Weglot API Key
|
vendor/weglot/weglot-php/src/Client/Endpoint/Translate.php
CHANGED
@@ -176,12 +176,11 @@ class Translate extends Endpoint
|
|
176 |
}
|
177 |
|
178 |
list($rawBody, $httpStatusCode, $httpHeader) = $this->request($asArray, false);
|
179 |
-
|
180 |
-
$response = json_decode($rawBody, true);
|
181 |
-
if ($response === null && $httpStatusCode != 200) {
|
182 |
throw new ApiError($rawBody, $asArray);
|
183 |
}
|
184 |
-
|
|
|
185 |
if ($this->getCache()->enabled()) {
|
186 |
$response = $this->afterRequest($response, $beforeRequest);
|
187 |
}
|
@@ -189,4 +188,4 @@ class Translate extends Endpoint
|
|
189 |
$factory = new TranslateFactory($response);
|
190 |
return $factory->handle();
|
191 |
}
|
192 |
-
}
|
176 |
}
|
177 |
|
178 |
list($rawBody, $httpStatusCode, $httpHeader) = $this->request($asArray, false);
|
179 |
+
if ($httpStatusCode !== 200) {
|
|
|
|
|
180 |
throw new ApiError($rawBody, $asArray);
|
181 |
}
|
182 |
+
|
183 |
+
$response = json_decode($rawBody, true);
|
184 |
if ($this->getCache()->enabled()) {
|
185 |
$response = $this->afterRequest($response, $beforeRequest);
|
186 |
}
|
188 |
$factory = new TranslateFactory($response);
|
189 |
return $factory->handle();
|
190 |
}
|
191 |
+
}
|
vendor/weglot/weglot-php/src/Parser/Formatter/DomFormatter.php
CHANGED
@@ -34,22 +34,20 @@ class DomFormatter extends AbstractFormatter
|
|
34 |
* @param array $details
|
35 |
* @param string $translated
|
36 |
*/
|
37 |
-
protected function metaContent(array $details, $translated)
|
38 |
-
{
|
39 |
$property = $details['property'];
|
40 |
|
41 |
-
if ($details['class']
|
42 |
$details['node']->$property = htmlspecialchars($translated);
|
43 |
} else {
|
44 |
$details['node']->$property = $translated;
|
45 |
}
|
46 |
}
|
47 |
|
48 |
-
protected function imageSource(array $details, $translated, $index)
|
49 |
-
{
|
50 |
$words = $this->getTranslated()->getInputWords();
|
51 |
|
52 |
-
if ($details['class']
|
53 |
$details['node']->src = $translated;
|
54 |
if ($details['node']->hasAttribute('srcset') &&
|
55 |
$details['node']->srcset != '' &&
|
34 |
* @param array $details
|
35 |
* @param string $translated
|
36 |
*/
|
37 |
+
protected function metaContent(array $details, $translated) {
|
|
|
38 |
$property = $details['property'];
|
39 |
|
40 |
+
if ($details['class'] === '\Weglot\Parser\Check\Dom\MetaContent') {
|
41 |
$details['node']->$property = htmlspecialchars($translated);
|
42 |
} else {
|
43 |
$details['node']->$property = $translated;
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
protected function imageSource(array $details, $translated, $index) {
|
|
|
48 |
$words = $this->getTranslated()->getInputWords();
|
49 |
|
50 |
+
if ($details['class'] === '\Weglot\Parser\Check\Dom\ImageSource') {
|
51 |
$details['node']->src = $translated;
|
52 |
if ($details['node']->hasAttribute('srcset') &&
|
53 |
$details['node']->srcset != '' &&
|
weglot-functions.php
CHANGED
@@ -54,12 +54,12 @@ function weglot_get_current_language() {
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
-
* Get destination language
|
58 |
* @since 2.0
|
59 |
* @return string
|
60 |
*/
|
61 |
-
function
|
62 |
-
return
|
63 |
}
|
64 |
|
65 |
/**
|
@@ -176,3 +176,39 @@ function weglot_current_url_is_eligible() {
|
|
176 |
$full_url = weglot_get_current_full_url();
|
177 |
return weglot_is_eligible_url( $full_url );
|
178 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
|
56 |
/**
|
57 |
+
* Get destination language with filters
|
58 |
* @since 2.0
|
59 |
* @return string
|
60 |
*/
|
61 |
+
function weglot_get_destination_languages() {
|
62 |
+
return Context_Weglot::weglot_get_context()->get_service( 'Option_Service_Weglot' )->get_destination_languages();
|
63 |
}
|
64 |
|
65 |
/**
|
176 |
$full_url = weglot_get_current_full_url();
|
177 |
return weglot_is_eligible_url( $full_url );
|
178 |
}
|
179 |
+
|
180 |
+
|
181 |
+
/**
|
182 |
+
* @since 2.0.4
|
183 |
+
* @return string
|
184 |
+
*/
|
185 |
+
function weglot_get_full_url_no_language() {
|
186 |
+
return weglot_get_request_url_service()->get_full_url_no_language();
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* @since 2.0.4
|
191 |
+
* @param string $url
|
192 |
+
* @return Weglot\Util\Url
|
193 |
+
*/
|
194 |
+
function weglot_create_url_object( $url ) {
|
195 |
+
return weglot_get_request_url_service()->create_url_object( $url );
|
196 |
+
}
|
197 |
+
|
198 |
+
/**
|
199 |
+
* @since 2.0.4
|
200 |
+
* @return int
|
201 |
+
*/
|
202 |
+
function weglot_get_postid_from_url() {
|
203 |
+
return url_to_postid( weglot_get_full_url_no_language() );
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Get option destination language
|
208 |
+
* @since 2.0
|
209 |
+
* @version 2.0.4
|
210 |
+
* @return array
|
211 |
+
*/
|
212 |
+
function weglot_get_destination_language() {
|
213 |
+
return weglot_get_option( 'destination_language' );
|
214 |
+
}
|
weglot.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* @version 2.0.
|
4 |
*/
|
5 |
|
6 |
/*
|
@@ -11,7 +11,7 @@ Author: Weglot Translate team
|
|
11 |
Author URI: https://weglot.com/
|
12 |
Text Domain: weglot
|
13 |
Domain Path: /languages/
|
14 |
-
Version: 2.0.
|
15 |
*/
|
16 |
|
17 |
/**
|
@@ -27,7 +27,7 @@ if ( ! defined('ABSPATH')) {
|
|
27 |
define('WEGLOT_NAME', 'Weglot');
|
28 |
define('WEGLOT_SLUG', 'weglot-translate');
|
29 |
define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
|
30 |
-
define('WEGLOT_VERSION', '2.0.
|
31 |
define('WEGLOT_PHP_MIN', '5.4');
|
32 |
define('WEGLOT_BNAME', plugin_basename(__FILE__));
|
33 |
define('WEGLOT_DIR', __DIR__ );
|
1 |
<?php
|
2 |
/**
|
3 |
+
* @version 2.0.6
|
4 |
*/
|
5 |
|
6 |
/*
|
11 |
Author URI: https://weglot.com/
|
12 |
Text Domain: weglot
|
13 |
Domain Path: /languages/
|
14 |
+
Version: 2.0.6
|
15 |
*/
|
16 |
|
17 |
/**
|
27 |
define('WEGLOT_NAME', 'Weglot');
|
28 |
define('WEGLOT_SLUG', 'weglot-translate');
|
29 |
define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
|
30 |
+
define('WEGLOT_VERSION', '2.0.6');
|
31 |
define('WEGLOT_PHP_MIN', '5.4');
|
32 |
define('WEGLOT_BNAME', plugin_basename(__FILE__));
|
33 |
define('WEGLOT_DIR', __DIR__ );
|