Weglot Translate – Translate your WP website - Version 2.5.0

Version Description

(07/02/2019) = * Add : Compatibility with Ninja Forms * Add : DOM Checker on input type reset * Bugfix : have the same menu switcher on the same page several times * Bugfix : Remove no redirect on hreflang * Improve DOM Checker meta content image

Download this release

Release Info

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

Code changes from version 2.3.1 to 2.5.0

Files changed (67) hide show
  1. app/javascripts/nav.js +61 -0
  2. bootstrap.php +6 -0
  3. composer.json +1 -1
  4. dist/admin-css.js +1 -1
  5. dist/admin-js.js +1 -1
  6. dist/front-amp-css.js +1 -1
  7. dist/front-css.js +1 -1
  8. dist/metaboxes-js.js +1 -1
  9. dist/nav-js.js +1 -0
  10. readme.txt +26 -6
  11. src/actions/admin/class-customize-menu-weglot.php +41 -81
  12. src/actions/admin/class-metabox-url-translate-weglot.php +1 -0
  13. src/actions/admin/class-options-weglot.php +10 -2
  14. src/actions/admin/class-pages-weglot.php +1 -0
  15. src/actions/admin/class-permalink-weglot.php +0 -1
  16. src/actions/front/class-front-menu-weglot.php +186 -0
  17. src/actions/front/class-search-weglot.php +86 -0
  18. src/actions/front/class-translate-page-weglot.php +4 -2
  19. src/class-bootstrap-weglot.php +1 -2
  20. src/domcheckers/class-input-reset.php +27 -0
  21. src/domcheckers/class-meta-facebook-image.php +27 -0
  22. src/domcheckers/class-meta-twitter-image.php +27 -0
  23. src/domcheckers/class-meta-twitter.php +1 -1
  24. src/helpers/class-helper-filter-url-weglot.php +17 -0
  25. src/helpers/class-helper-json-inline-weglot.php +14 -0
  26. src/helpers/class-helper-keys-json-weglot.php +51 -0
  27. src/helpers/class-helper-menu-options-weglot.php +53 -0
  28. src/helpers/class-helper-tabs-admin-weglot.php +8 -1
  29. src/services/class-button-service-weglot.php +2 -16
  30. src/services/class-custom-url-service-weglot.php +13 -6
  31. src/services/class-generate-switcher-service-weglot.php +13 -6
  32. src/services/class-href-lang-service-weglot.php +5 -1
  33. src/services/class-menu-options-service-weglot.php +43 -0
  34. src/services/class-option-service-weglot.php +15 -2
  35. src/services/class-private-language-service-weglot.php +27 -0
  36. src/services/class-replace-link-service-weglot.php +8 -3
  37. src/services/class-replace-url-service-weglot.php +4 -2
  38. src/services/class-request-url-service-weglot.php +29 -3
  39. src/services/class-translate-service-weglot.php +18 -2
  40. src/third/ninjaforms/class-ninja-active-weglot.php +40 -0
  41. src/third/ninjaforms/class-ninja-translate-json-weglot.php +198 -0
  42. src/third/woocommerce/class-wc-cart-reload-weglot.php +109 -0
  43. src/third/woocommerce/class-wc-filter-urls-weglot.php +3 -2
  44. templates/admin/pages/settings.php +3 -0
  45. templates/admin/pages/tabs/advanced.php +35 -5
  46. templates/admin/pages/tabs/support.php +42 -0
  47. vendor/autoload.php +1 -1
  48. vendor/composer/autoload_namespaces.php +1 -1
  49. vendor/composer/autoload_real.php +7 -7
  50. vendor/composer/autoload_static.php +6 -6
  51. vendor/composer/installed.json +14 -14
  52. vendor/weglot/simplehtmldom/README.md +8 -0
  53. vendor/weglot/simplehtmldom/composer.json +1 -1
  54. vendor/weglot/simplehtmldom/src/simple_html_dom.php +118 -118
  55. vendor/weglot/weglot-php/composer.json +1 -1
  56. vendor/weglot/weglot-php/src/Parser/Check/AbstractChecker.php +1 -1
  57. vendor/weglot/weglot-php/src/Parser/Check/Dom/AbstractDomChecker.php +1 -1
  58. vendor/weglot/weglot-php/src/Parser/Check/Dom/IframeSrc.php +1 -1
  59. vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php +2 -2
  60. vendor/weglot/weglot-php/src/Parser/Formatter/ExcludeBlocksFormatter.php +1 -1
  61. vendor/weglot/weglot-php/src/Parser/Parser.php +49 -5
  62. vendor/weglot/weglot-php/src/Util/Server.php +19 -2
  63. vendor/weglot/weglot-php/tests/unit/Parser/Check/Dom/MetaContentTest.php +4 -4
  64. webpack.config.js +2 -1
  65. weglot-compatibility.php +27 -0
  66. weglot-functions.php +11 -0
  67. weglot.php +4 -6
app/javascripts/nav.js ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function ($) {
2
+ $('#update-nav-menu').bind('click', function (e) {
3
+ if (e.target && e.target.className && -1 != e.target.className.indexOf('item-edit')) {
4
+
5
+ $("input[value='#weglot_switcher'][type=text]").parents('.menu-item-settings').each(function () {
6
+ const id = $(this).attr('id').substring(19);
7
+ $(this).children('p:not( .field-move )').remove(); // remove default fields we don't need
8
+
9
+ $(this).append($('<input>').attr({
10
+ type: 'hidden',
11
+ id: 'edit-menu-item-title-' + id,
12
+ name: 'menu-item-title[' + id + ']',
13
+ value: weglot_data.title
14
+ }));
15
+
16
+ $(this).append($("<input>").attr({
17
+ type: "hidden",
18
+ id: "edit-menu-item-url-" + id,
19
+ name: "menu-item-url[" + id + "]",
20
+ value: "#weglot_switcher"
21
+ }));
22
+
23
+ $(this).append($('<input>').attr({
24
+ type: 'hidden',
25
+ id: 'edit-menu-item-pll-detect-' + id,
26
+ name: 'menu-item-pll-detect[' + id + ']',
27
+ value: 1
28
+ }));
29
+
30
+
31
+ $.each(weglot_data.list_options, (key, option) => {
32
+ const paragraph = $("<p>").attr("class", "description");
33
+ const label = $("<label>")
34
+ .attr("for", `edit-menu-item-${option.key}-${id}`)
35
+ .text(` ${option.title}`);
36
+
37
+ $(this).prepend(paragraph);
38
+ paragraph.append(label);
39
+
40
+ const checkbox = $("<input>").attr({
41
+ type: "checkbox",
42
+ id: `edit-menu-item-${
43
+ option.key
44
+ }-${id}`,
45
+ name: `menu-item-${
46
+ option.key
47
+ }[${id}]`,
48
+ value: 1
49
+ });
50
+
51
+ if( weglot_data.options[ option.key ] === 1 ){
52
+ checkbox.prop("checked", true);
53
+ }
54
+
55
+ label.prepend(checkbox);
56
+ })
57
+ });
58
+
59
+ }
60
+ });
61
+ });
bootstrap.php CHANGED
@@ -48,6 +48,8 @@ abstract class Context_Weglot {
48
  '\WeglotWP\Services\Parser_Service_Weglot',
49
  '\WeglotWP\Third\Woocommerce\WC_Translate_Weglot',
50
  '\WeglotWP\Third\Woocommerce\WC_Active_Weglot',
 
 
51
  '\WeglotWP\Third\Amp\Amp_Service_Weglot',
52
  '\WeglotWP\Services\User_Api_Service_Weglot',
53
  '\WeglotWP\Services\Other_Translate_Service_Weglot',
@@ -58,6 +60,7 @@ abstract class Context_Weglot {
58
  '\WeglotWP\Services\Translate_Service_Weglot',
59
  '\WeglotWP\Services\Private_Language_Service_Weglot',
60
  '\WeglotWP\Services\Href_Lang_Service_Weglot',
 
61
  ];
62
 
63
  self::$context->set_services( $services );
@@ -77,8 +80,11 @@ abstract class Context_Weglot {
77
  '\WeglotWP\Actions\Front\Redirect_Log_User_Weglot',
78
  '\WeglotWP\Actions\Migration_Weglot',
79
  '\WeglotWP\Third\Woocommerce\WC_Filter_Urls_Weglot',
 
80
  '\WeglotWP\Third\Amp\Amp_Enqueue_Weglot',
81
  '\WeglotWP\Actions\Admin\Metabox_Url_Translate_Weglot',
 
 
82
  ];
83
 
84
  self::$context->set_actions( $actions );
48
  '\WeglotWP\Services\Parser_Service_Weglot',
49
  '\WeglotWP\Third\Woocommerce\WC_Translate_Weglot',
50
  '\WeglotWP\Third\Woocommerce\WC_Active_Weglot',
51
+ '\WeglotWP\Third\NinjaForms\Ninja_Active_Weglot',
52
+ '\WeglotWP\Third\NinjaForms\Ninja_Translate_Json_Weglot',
53
  '\WeglotWP\Third\Amp\Amp_Service_Weglot',
54
  '\WeglotWP\Services\User_Api_Service_Weglot',
55
  '\WeglotWP\Services\Other_Translate_Service_Weglot',
60
  '\WeglotWP\Services\Translate_Service_Weglot',
61
  '\WeglotWP\Services\Private_Language_Service_Weglot',
62
  '\WeglotWP\Services\Href_Lang_Service_Weglot',
63
+ '\WeglotWP\Services\Menu_Options_Service_Weglot',
64
  ];
65
 
66
  self::$context->set_services( $services );
80
  '\WeglotWP\Actions\Front\Redirect_Log_User_Weglot',
81
  '\WeglotWP\Actions\Migration_Weglot',
82
  '\WeglotWP\Third\Woocommerce\WC_Filter_Urls_Weglot',
83
+ '\WeglotWP\Third\Woocommerce\WC_Cart_Reload_Weglot',
84
  '\WeglotWP\Third\Amp\Amp_Enqueue_Weglot',
85
  '\WeglotWP\Actions\Admin\Metabox_Url_Translate_Weglot',
86
+ '\WeglotWP\Actions\Front\Front_Menu_Weglot',
87
+ '\WeglotWP\Actions\Front\Search_Weglot',
88
  ];
89
 
90
  self::$context->set_actions( $actions );
composer.json CHANGED
@@ -18,7 +18,7 @@
18
  "require-dev": {
19
  "squizlabs/php_codesniffer": "*",
20
  "wp-coding-standards/wpcs": "^0.13.1",
21
- "phpunit/phpunit": "^4"
22
  },
23
  "scripts": {
24
  "post-install-cmd": [
18
  "require-dev": {
19
  "squizlabs/php_codesniffer": "*",
20
  "wp-coding-standards/wpcs": "^0.13.1",
21
+ "phpunit/phpunit": "^4 || ^6"
22
  },
23
  "scripts": {
24
  "post-install-cmd": [
dist/admin-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=11)}({11:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=12)}({12:function(e,t){}});
dist/admin-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function o(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(n,a,function(t){return e[t]}.bind(null,a));return n},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=4)}([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 n=arguments[1],a=0;a<o;){var l=t[a];if(e.call(n,l,a,t))return l;a++}},configurable:!0,writable:!0})},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,n=new Array(o),a=this,l=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(n[l++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(n[l++]=a[r]);return n.length=l,n})},,,function(e,t,o){"use strict";o.r(t);var n=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 n=t[0].selectize.getValue(),a=e("#li-button-tpl");if(0===a.length)return;const l=e("#is_fullname").is(":checked"),r=e("#with_name").is(":checked");let s="";e("#with_flags").is(":checked")&&(s="weglot-flags");let c="";n.forEach(e=>{const t=weglot_languages.available.find(t=>t.code===e);let o="";r&&(o=l?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",()=>{(()=>{let n=e("#original_language").val();e("#original_language").on("change",function(o){const a=n,l=n;n=o.target.value,t[0].selectize.removeOption(n);const r=weglot_languages.available.find(e=>e.code===l),s=weglot_languages.available.find(e=>e.code===n);t[0].selectize.addOption(r);const c=e("#is_fullname").is(":checked");let i="";e("#with_name").is(":checked")&&(i=c?s.local:s.code.toUpperCase()),e(".wgcurrent.wg-li").removeClass(a).addClass(n).attr("data-code-language",n).find("span").html(i)}),o(),window.addEventListener("weglotCheckApi",e=>{let o=1e3;const n=e.detail.answer.plan;n<=0||weglot_languages.plans.starter_free.ids.indexOf(n)>=0?o=weglot_languages.plans.starter_free.limit_language:weglot_languages.plans.business.ids.indexOf(n)>=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 l=function(){jQuery;const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),n=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(),n.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,n)=>{o.push(e(n).data("code-language"))});const n=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 n=o.target.value;e(".country-selector label, .country-selector li").addClass(`flag-${n}`),t=n});const a=()=>{const t=n.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 l=n.find(t=>t.code===e(a).data("code-language")),r=o?l.local:l.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=n.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=n.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,n=new Array,a=new Array,l=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],n[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],l[1]=[1830,129,3096,5664],l[2]=[5100,2177,3840,2904],l[3]=[4890,3425,3648,2136],l[4]=[1320,3681,1896,4080],l[5]=[1260,3841,1824,1200],l[6]=[1020,3969,1608,312],l[7]=[4800,4065,3600,72],l[8]=[4710,4865,3504,480],l[9]=[6720,5984,5112,3792],l[10]=[4500,7233,3288,1800],l[11]=[720,7522,384,3936],l[12]=[690,7745,336,1104],l[13]=[600,8225,120,1272],l[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 !important; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0 !important; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0 !important; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0 !important; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0 !important; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0 !important; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0 !important; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0 !important; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+n[c][0]+"px 0 !important; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+n[c][1]+"px 0 !important; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+n[c][2]+"px 0 !important; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+n[c][3]+"px 0 !important; } ",p=i<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[i][0]+"px 0 !important; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[i][1]+"px 0 !important; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[i][2]+"px 0 !important; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[i][3]+"px 0 !important; } ",w=g<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+l[g][0]+"px 0 !important; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+l[g][1]+"px 0 !important; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+l[g][2]+"px 0 !important; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+l[g][3]+"px 0 !important; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+w)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var i=function(){};var g=function(){jQuery;document.addEventListener("DOMContentLoaded",()=>{0!=document.querySelector("#private_mode").length&&(document.querySelector("#private_mode").addEventListener("change",function(e){document.querySelectorAll(".private-mode-lang--input").forEach(t=>{t.checked=e.target.checked})}),document.querySelectorAll(".private-mode-lang--input").forEach(e=>{e.addEventListener("change",function(e){0===document.querySelectorAll(".private-mode-lang--input:checked").length&&(document.querySelector("#private_mode").checked=!1)})}))})};o(0),o(1);n(),l(),a(),r(),s(),c(),i(),g()}]);
1
+ !function(e){var t={};function o(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,o),a.l=!0,a.exports}o.m=e,o.c=t,o.d=function(e,t,n){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)o.d(n,a,function(t){return e[t]}.bind(null,a));return n},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=5)}([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 n=arguments[1],a=0;a<o;){var l=t[a];if(e.call(n,l,a,t))return l;a++}},configurable:!0,writable:!0})},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,n=new Array(o),a=this,l=0,r=-1;if(void 0===t)for(;++r!==o;)r in this&&e(a[r],r,a)&&(n[l++]=a[r]);else for(;++r!==o;)r in this&&e.call(t,a[r],r,a)&&(n[l++]=a[r]);return n.length=l,n})},,,,function(e,t,o){"use strict";o.r(t);var n=function(){const e=jQuery,t=()=>weglot_languages.available.filter(e=>e.code!==weglot_languages.original);let o;const n=()=>{let n=e("#original_language").val();e("#original_language").on("change",function(t){const a=n,l=n;n=t.target.value,o[0].selectize.removeOption(n);const r=weglot_languages.available.find(e=>e.code===l),s=weglot_languages.available.find(e=>e.code===n);o[0].selectize.addOption(r);const c=e("#is_fullname").is(":checked");let i="";e("#with_name").is(":checked")&&(i=c?s.local:s.code.toUpperCase()),e(".wgcurrent.wg-li").removeClass(a).addClass(n).attr("data-code-language",n).find("span").html(i)}),o=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:t(),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",t=>{const n=o[0].selectize.getValue(),a=e("#li-button-tpl");if(0===a.length)return;const l=e("#is_fullname").is(":checked"),r=e("#with_name").is(":checked"),s=e("#with_flags").is(":checked");let c="";s&&(c="weglot-flags");let i="";n.forEach(e=>{const t=weglot_languages.available.find(t=>t.code===e);let o="";r&&(o=l?t.local:e.toUpperCase()),i+=a.html().replace("{LABEL_LANGUAGE}",o).replace(new RegExp("{CODE_LANGUAGE}","g"),e).replace("{CLASSES}",c)}),e(".country-selector ul").html(i)}),window.addEventListener("weglotCheckApi",e=>{let t=1e3;const n=e.detail.answer.plan;n<=0||weglot_languages.plans.starter_free.ids.indexOf(n)>=0?t=weglot_languages.plans.starter_free.limit_language:weglot_languages.plans.business.ids.indexOf(n)>=0&&(t=weglot_languages.plans.business.limit_language),o[0].selectize.settings.maxItems=t})};document.addEventListener("DOMContentLoaded",()=>{n()})};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 l=function(){jQuery;const e=()=>{const e=document.querySelector("#tpl-exclusion-url"),t=document.querySelector("#tpl-exclusion-block"),o=document.querySelector("#container-exclude_urls"),n=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(),n.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,n)=>{o.push(e(n).data("code-language"))});const n=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 n=o.target.value;e(".country-selector label, .country-selector li").addClass(`flag-${n}`),t=n});const a=()=>{const t=n.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 l=n.find(t=>t.code===e(a).data("code-language")),r=o?l.local:l.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=n.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=n.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,n=new Array,a=new Array,l=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],n[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],l[1]=[1830,129,3096,5664],l[2]=[5100,2177,3840,2904],l[3]=[4890,3425,3648,2136],l[4]=[1320,3681,1896,4080],l[5]=[1260,3841,1824,1200],l[6]=[1020,3969,1608,312],l[7]=[4800,4065,3600,72],l[8]=[4710,4865,3504,480],l[9]=[6720,5984,5112,3792],l[10]=[4500,7233,3288,1800],l[11]=[720,7522,384,3936],l[12]=[690,7745,336,1104],l[13]=[600,8225,120,1272],l[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 !important; } .weglot-flags.flag-1.en > a:before, .weglot-flags.flag-1.en > span:before { background-position: -"+t[r][1]+"px 0 !important; } .weglot-flags.flag-2.en > a:before, .weglot-flags.flag-2.en > span:before { background-position: -"+t[r][2]+"px 0 !important; } .weglot-flags.flag-3.en > a:before, .weglot-flags.flag-3.en > span:before { background-position: -"+t[r][3]+"px 0 !important; } ",u=s<=0?"":".weglot-flags.es > a:before, .weglot-flags.es > span:before { background-position: -"+o[s][0]+"px 0 !important; } .weglot-flags.flag-1.es > a:before, .weglot-flags.flag-1.es > span:before { background-position: -"+o[s][1]+"px 0 !important; } .weglot-flags.flag-2.es > a:before, .weglot-flags.flag-2.es > span:before { background-position: -"+o[s][2]+"px 0 !important; } .weglot-flags.flag-3.es > a:before, .weglot-flags.flag-3.es > span:before { background-position: -"+o[s][3]+"px 0 !important; } ",d=c<=0?"":".weglot-flags.pt > a:before, .weglot-flags.pt > span:before { background-position: -"+n[c][0]+"px 0 !important; } .weglot-flags.flag-1.pt > a:before, .weglot-flags.flag-1.pt > span:before { background-position: -"+n[c][1]+"px 0 !important; } .weglot-flags.flag-2.pt > a:before, .weglot-flags.flag-2.pt > span:before { background-position: -"+n[c][2]+"px 0 !important; } .weglot-flags.flag-3.pt > a:before, .weglot-flags.flag-3.pt > span:before { background-position: -"+n[c][3]+"px 0 !important; } ",p=i<=0?"":".weglot-flags.fr > a:before, .weglot-flags.fr > span:before { background-position: -"+a[i][0]+"px 0 !important; } .weglot-flags.flag-1.fr > a:before, .weglot-flags.flag-1.fr > span:before { background-position: -"+a[i][1]+"px 0 !important; } .weglot-flags.flag-2.fr > a:before, .weglot-flags.flag-2.fr > span:before { background-position: -"+a[i][2]+"px 0 !important; } .weglot-flags.flag-3.fr > a:before, .weglot-flags.flag-3.fr > span:before { background-position: -"+a[i][3]+"px 0 !important; } ",w=g<=0?"":".weglot-flags.ar > a:before, .weglot-flags.ar > span:before { background-position: -"+l[g][0]+"px 0 !important; } .weglot-flags.flag-1.ar > a:before, .weglot-flags.flag-1.ar > span:before { background-position: -"+l[g][1]+"px 0 !important; } .weglot-flags.flag-2.ar > a:before, .weglot-flags.flag-2.ar > span:before { background-position: -"+l[g][2]+"px 0 !important; } .weglot-flags.flag-3.ar > a:before, .weglot-flags.flag-3.ar > span:before { background-position: -"+l[g][3]+"px 0 !important; } ";e("#flag_css, #weglot-css-flag-css").text(f+u+d+p+w)}()})};document.addEventListener("DOMContentLoaded",()=>{t()})};var i=function(){};var g=function(){jQuery;document.addEventListener("DOMContentLoaded",()=>{0!=document.querySelector("#private_mode").length&&(document.querySelector("#private_mode").addEventListener("change",function(e){document.querySelectorAll(".private-mode-lang--input").forEach(t=>{t.checked=e.target.checked})}),document.querySelectorAll(".private-mode-lang--input").forEach(e=>{e.addEventListener("change",function(e){0===document.querySelectorAll(".private-mode-lang--input:checked").length&&(document.querySelector("#private_mode").checked=!1)})}))})};o(0),o(1);n(),l(),a(),r(),s(),c(),i(),g()}]);
dist/front-amp-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=14)}({14:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=15)}({15:function(e,t){}});
dist/front-css.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=6)}({6:function(e,t){}});
1
+ !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="/dist/",r(r.s=7)}({7:function(e,t){}});
dist/metaboxes-js.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=5)}([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),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var a=arguments[1],o=0;o<n;){var r=t[o];if(e.call(a,r,o,t))return r;o++}},configurable:!0,writable:!0})},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 n=this.length>>>0,a=new Array(n),o=this,r=0,i=-1;if(void 0===t)for(;++i!==n;)i in this&&e(o[i],i,o)&&(a[r++]=o[i]);else for(;++i!==n;)i in this&&e.call(t,o[i],i,o)&&(a[r++]=o[i]);return a.length=r,a})},function(e,t,n){!function(t,n,a){e.exports=a(),e.exports.default=a()}(0,0,function(){var e=JSON.parse('{"$":"dollar","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","џ":"dz","Ґ":"G","ґ":"g","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","‘":"\'","’":"\'","“":"\\"","”":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₹":"indian rupee","₽":"russian ruble","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial"}');function t(t,n){if("string"!=typeof t)throw new Error("slugify: string argument expected");n="string"==typeof n?{replacement:n}:n||{};var a=t.split("").reduce(function(t,a){return t+(e[a]||a).replace(n.remove||/[^\w\s$*_+~.()'"!\-:@]/g,"")},"").trim().replace(/[-\s]+/g,n.replacement||"-").replace("#{replacement}$","");return n.lower?a.toLowerCase():a}return t.extend=function(t){for(var n in t)e[n]=t[n]},t})},,,function(e,t,n){"use strict";n.r(t);n(0),n(1);var a=n(2),o=n.n(a);(()=>{const e=jQuery,t=()=>{let t={};const n=function(n){const a=e(this).data("lang"),r=o()(e(`#lang-${a}`).val(),{lower:!0,replacement:"-"});e(`#text-edit-${a}`).text(r),e(`#lang-${a}`).hide(),e(this).hide(),e(`.button-weglot-lang[data-lang=${a}]`).show(),e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_post_name",lang:a,id:e("#weglot_post_id").data("id"),post_name:r},success:function(n){if(n.data&&n.data.code&&"same_post_name"===n.data.code)return e(`#text-edit-${a}`).text(t[a]),void e(`#lang-${a}`).val("");n.data&&n.data.code&&"not_available"===n.data.code&&(e(`#weglot_permalink_not_available_${a}`).show(),e(`#lang-${a}`).val(""),setTimeout(()=>{e(`#weglot_permalink_not_available_${a}`).hide()},5e3)),e(`#text-edit-${a}`).text(n.data.result.slug)}})};e(".button-weglot-lang").each((a,o)=>{e(o).on("click",function(n){n.preventDefault();const a=e(this).data("lang"),o=e(`#text-edit-${a}`).text();t[a]=o,e(`#text-edit-${a}`).text(" "),e(`#lang-${a}`).val(o).show(),e(`.button-weglot-lang-submit[data-lang=${a}]`).show(),e(this).hide()});const r=e(o).data("lang");e(`.button-weglot-lang-submit[data-lang=${r}]`).on("click",n)}),e(".weglot_reset").each((t,n)=>{e(n).on("click",function(t){t.preventDefault();const n=e(this).data("lang"),a=e(this).attr("href"),o=e(this).data("id");e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_reset_custom_url",code_lang:n,id:o,custom_url:a},success:function(t){e(`#text-edit-${n}`).text(t.data.result.slug)}})})})};document.addEventListener("DOMContentLoaded",()=>{t()})})()}]);
1
+ !function(e){var t={};function n(a){if(t[a])return t[a].exports;var o=t[a]={i:a,l:!1,exports:{}};return e[a].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,a){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:a})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var a=Object.create(null);if(n.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(a,o,function(t){return e[t]}.bind(null,o));return a},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=6)}([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),n=t.length>>>0;if("function"!=typeof e)throw new TypeError("predicate must be a function");for(var a=arguments[1],o=0;o<n;){var r=t[o];if(e.call(a,r,o,t))return r;o++}},configurable:!0,writable:!0})},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 n=this.length>>>0,a=new Array(n),o=this,r=0,i=-1;if(void 0===t)for(;++i!==n;)i in this&&e(o[i],i,o)&&(a[r++]=o[i]);else for(;++i!==n;)i in this&&e.call(t,o[i],i,o)&&(a[r++]=o[i]);return a.length=r,a})},function(e,t,n){var a;a=function(){var e=JSON.parse('{"$":"dollar","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","џ":"dz","Ґ":"G","ґ":"g","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","‘":"\'","’":"\'","“":"\\"","”":"\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₹":"indian rupee","₽":"russian ruble","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial"}');function t(t,n){if("string"!=typeof t)throw new Error("slugify: string argument expected");n="string"==typeof n?{replacement:n}:n||{};var a=t.split("").reduce(function(t,a){return t+(e[a]||a).replace(n.remove||/[^\w\s$*_+~.()'"!\-:@]/g,"")},"").trim().replace(/[-\s]+/g,n.replacement||"-").replace("#{replacement}$","");return n.lower?a.toLowerCase():a}return t.extend=function(t){for(var n in t)e[n]=t[n]},t},e.exports=a(),e.exports.default=a()},,,,function(e,t,n){"use strict";n.r(t);n(0),n(1);var a=n(2),o=n.n(a);(()=>{const e=jQuery,t=()=>{let t={};const n=function(n){const a=e(this).data("lang"),r=o()(e(`#lang-${a}`).val(),{lower:!0,replacement:"-"});e(`#text-edit-${a}`).text(r),e(`#lang-${a}`).hide(),e(this).hide(),e(`.button-weglot-lang[data-lang=${a}]`).show(),e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_post_name",lang:a,id:e("#weglot_post_id").data("id"),post_name:r},success:function(n){if(n.data&&n.data.code&&"same_post_name"===n.data.code)return e(`#text-edit-${a}`).text(t[a]),void e(`#lang-${a}`).val("");n.data&&n.data.code&&"not_available"===n.data.code&&(e(`#weglot_permalink_not_available_${a}`).show(),e(`#lang-${a}`).val(""),setTimeout(()=>{e(`#weglot_permalink_not_available_${a}`).hide()},5e3)),e(`#text-edit-${a}`).text(n.data.result.slug)}})};e(".button-weglot-lang").each((a,o)=>{e(o).on("click",function(n){n.preventDefault();const a=e(this).data("lang"),o=e(`#text-edit-${a}`).text();t[a]=o,e(`#text-edit-${a}`).text(" "),e(`#lang-${a}`).val(o).show(),e(`.button-weglot-lang-submit[data-lang=${a}]`).show(),e(this).hide()});const r=e(o).data("lang");e(`.button-weglot-lang-submit[data-lang=${r}]`).on("click",n)}),e(".weglot_reset").each((t,n)=>{e(n).on("click",function(t){t.preventDefault();const n=e(this).data("lang"),a=e(this).attr("href"),o=e(this).data("id");e.ajax({url:ajaxurl,method:"POST",data:{action:"weglot_reset_custom_url",code_lang:n,id:o,custom_url:a},success:function(t){e(`#text-edit-${n}`).text(t.data.result.slug)}})})})};document.addEventListener("DOMContentLoaded",()=>{t()})})()}]);
dist/nav-js.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/dist/",n(n.s=4)}({4:function(e,t){jQuery(document).ready(function(e){e("#update-nav-menu").bind("click",function(t){t.target&&t.target.className&&-1!=t.target.className.indexOf("item-edit")&&e("input[value='#weglot_switcher'][type=text]").parents(".menu-item-settings").each(function(){const t=e(this).attr("id").substring(19);e(this).children("p:not( .field-move )").remove(),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-title-"+t,name:"menu-item-title["+t+"]",value:weglot_data.title})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-url-"+t,name:"menu-item-url["+t+"]",value:"#weglot_switcher"})),e(this).append(e("<input>").attr({type:"hidden",id:"edit-menu-item-pll-detect-"+t,name:"menu-item-pll-detect["+t+"]",value:1})),e.each(weglot_data.list_options,(n,i)=>{const r=e("<p>").attr("class","description"),u=e("<label>").attr("for",`edit-menu-item-${i.key}-${t}`).text(` ${i.title}`);e(this).prepend(r),r.append(u);const o=e("<input>").attr({type:"checkbox",id:`edit-menu-item-${i.key}-${t}`,name:`menu-item-${i.key}[${t}]`,value:1});1===weglot_data.options[i.key]&&o.prop("checked",!0),u.prepend(o)})})})})}});
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: 5.0
6
  Requires PHP: 5.4
7
- Stable tag: 2.3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -22,7 +22,7 @@ Weglot Translate, a WP multi language plugin, is trusted by companies in e-comme
22
 
23
  Check Weglot Translate in video:
24
 
25
- [youtube http://www.youtube.com/watch?v=cdoBED8p3HQ]
26
 
27
  Weglot Translate benefits:
28
 
@@ -129,6 +129,8 @@ If you have any questions about Weglot Translate, please post a topic on the [su
129
  == Instructions ==
130
  Weglot Translate is easy to set up:
131
 
 
 
132
  1. Go to [https://weglot.com/register-wordpress](https://weglot.com/register-wordpress) to set up an account
133
  2. Grab your api_key from your dashboard, it looks like "wg_XXXXXXX"
134
  3. Find the Weglot Translate settings page on the bottom left of your WordPress admin dashboard.
@@ -142,16 +144,34 @@ Weglot Translate is easy to set up:
142
  == Screenshots ==
143
 
144
  1. Example on front end: language switch button on page
145
- 2. Weglot Translate dashboard, translation edition
146
- 3. Weglot Translate settings page
147
- 4. Weglot Translate switch button
148
- 4. Weglot Translate button: a lot of designs are possible
149
 
150
  == Upgrade Notice ==
151
  See changelog for upgrade changes.
152
 
153
  == Changelog ==
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  = 2.3.1 (05/12/2018) =
156
  * Bugfix : Button preview fail on migration for private mode
157
 
4
  Requires at least: 4.5
5
  Tested up to: 5.0
6
  Requires PHP: 5.4
7
+ Stable tag: 2.5.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
22
 
23
  Check Weglot Translate in video:
24
 
25
+ [youtube https://www.youtube.com/watch?v=wmZLvhWX29k]
26
 
27
  Weglot Translate benefits:
28
 
129
  == Instructions ==
130
  Weglot Translate is easy to set up:
131
 
132
+ [youtube http://www.youtube.com/watch?v=cdoBED8p3HQ]
133
+
134
  1. Go to [https://weglot.com/register-wordpress](https://weglot.com/register-wordpress) to set up an account
135
  2. Grab your api_key from your dashboard, it looks like "wg_XXXXXXX"
136
  3. Find the Weglot Translate settings page on the bottom left of your WordPress admin dashboard.
144
  == Screenshots ==
145
 
146
  1. Example on front end: language switch button on page
147
+ 2. Weglot Translate settings page
148
+ 3. Weglot Translate dashboard, translation edition
149
+ 4. Weglot Translate visual editor
 
150
 
151
  == Upgrade Notice ==
152
  See changelog for upgrade changes.
153
 
154
  == Changelog ==
155
 
156
+ = 2.5.0 (07/02/2019) =
157
+ * Add : Compatibility with Ninja Forms
158
+ * Add : DOM Checker on input type reset
159
+ * Bugfix : have the same menu switcher on the same page several times
160
+ * Bugfix : Remove no redirect on hreflang
161
+ * Improve DOM Checker meta content image
162
+
163
+ = 2.4.1 (09/01/2019) =
164
+ * Bugfix: undefined function if there is no antislash before the function ( \is_rest )
165
+
166
+ = 2.4.0 (09/01/2019) =
167
+ * Compatibility PHP 7.3
168
+ * Changed : the language selector for menus
169
+ * Add : Compatibility with the REST API of Contact Form 7
170
+ * Add [BETA] : Be able to translate the keywords of a search
171
+ * Bugfix : translation of the empty cart on WooCommerce
172
+ * Bugfix: correction of options on a multisite
173
+
174
+
175
  = 2.3.1 (05/12/2018) =
176
  * Bugfix : Button preview fail on migration for private mode
177
 
src/actions/admin/class-customize-menu-weglot.php CHANGED
@@ -25,6 +25,7 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
25
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
26
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
27
  $this->private_language_services = weglot_get_service( 'Private_Language_Service_Weglot' );
 
28
  return $this;
29
  }
30
 
@@ -32,6 +33,7 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
32
  * @see Hooks_Interface_Weglot
33
  *
34
  * @since 2.0
 
35
  * @return void
36
  */
37
  public function hooks() {
@@ -40,87 +42,57 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
40
  }
41
 
42
  add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
43
- add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
44
- add_filter( 'nav_menu_css_class', [ $this, 'add_nav_menu_css_class' ], 10, 2 );
45
-
46
- add_filter( 'megamenu_nav_menu_css_class', [ $this, 'add_nav_menu_css_class' ], 10, 2 );
47
-
48
- if ( $this->option_services->get_option( 'is_menu' ) ) {
49
- add_filter( 'wp_nav_menu_items', [ $this, 'weglot_fallback_menu' ] );
50
- }
51
  }
52
 
53
- /**
54
- * @since 2.0
55
- * @param string $items
56
- * @return string
57
- */
58
- public function weglot_fallback_menu( $items ) {
59
- $button = $this->button_services->get_html();
60
- $items .= $button;
61
 
62
- return $items;
63
- }
64
 
65
  /**
66
- * @since 2.0
67
- * @version 2.0.2
68
- * @see nav_menu_link_attributes
69
- * @param array $classes
70
- * @param object $item
71
  * @return void
72
  */
73
- public function add_nav_menu_css_class( $classes, $item ) {
74
- $str = 'weglot_menu_title-';
75
- if ( strpos( $item->post_name, $str ) !== false ) {
76
- $lang = explode( '-', substr( $item->post_name, strlen( $str ) ) );
77
-
78
- if ( ! $this->request_url_services->is_translatable_url() || ! weglot_current_url_is_eligible() || $this->private_language_services->is_active_private_mode_for_lang( $lang[0] ) ) {
79
- $classes[] = apply_filters( 'weglot_nav_menu_link_class', 'weglot-hide' );
80
- return $classes;
81
- }
82
 
83
- $options = $this->option_services->get_options();
84
- $with_flags = $options['with_flags'];
85
- $type_flags = $options['type_flags'];
86
 
87
- $flag_class = $with_flags ? 'weglot-flags ' : '';
88
- $flag_class .= '0' === $type_flags ? '' : 'flag-' . $type_flags . ' ';
89
 
90
- $classes[] = apply_filters( 'weglot_nav_menu_link_class', $flag_class . $lang[0] );
 
 
91
  }
92
 
93
- return $classes;
94
  }
95
 
96
  /**
97
  * @since 2.0
98
- * @see nav_menu_link_attributes
99
- * @param array $attrs
100
- * @param object $item
101
  * @return void
102
  */
103
- public function add_nav_menu_link_attributes( $attrs, $item ) {
104
- $str = 'weglot_menu_title-';
105
- if ( strpos( $item->post_name, $str ) !== false ) {
106
- $current_language = $this->request_url_services->get_current_language();
 
107
 
108
- if ( ! $this->request_url_services->is_translatable_url() || ! weglot_current_url_is_eligible() ) {
109
- $attrs['style'] = 'display:none';
110
- return $attrs;
111
- }
112
 
113
- if ( ! isset( $attrs['class'] ) ) {
114
- $attrs['class'] = '';
115
- }
116
 
117
- $attrs['class'] .= ' weglot-lang';
 
118
 
119
- $attrs['data-wg-notranslate'] = 'true';
120
- }
121
 
122
- return $attrs;
123
- }
124
 
125
  /**
126
  * @since 2.0
@@ -137,36 +109,24 @@ class Customize_Menu_Weglot implements Hooks_Interface_Weglot {
137
  * @see add_meta_box weglot_nav_link
138
  */
139
  public function nav_menu_links() {
140
- $languages_configured = $this->language_services->get_languages_configured();
141
-
142
- $languages_configured = apply_filters( 'weglot_custom_nav_menu_items', $languages_configured ); ?>
143
  <div id="posttype-weglot-languages" class="posttypediv">
144
  <div id="tabs-panel-weglot-endpoints" class="tabs-panel tabs-panel-active">
145
  <ul id="weglot-endpoints-checklist" class="categorychecklist form-no-clear">
146
- <?php
147
- $i = 1;
148
- foreach ( $languages_configured as $key => $language ) : //phpcs:ignore
149
- ?>
150
- <li>
151
- <label class="menu-item-title">
152
- <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $i ); ?>" /> <?php echo esc_html( $language->getEnglishName() ); ?>
153
- </label>
154
- <input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-type]" value="custom" />
155
- <input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-title]" value="[weglot_menu_title-<?php echo esc_attr( $language->getIso639() ); ?>]" />
156
- <input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-url]" value="[weglot_menu_current_url-<?php echo esc_attr( $language->getIso639() ); ?>]" />
157
- <input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $i ); ?>][menu-item-classes]" />
158
- </li>
159
- <?php
160
- $i++;
161
- endforeach; //phpcs:ignore ?>
162
  </ul>
163
  </div>
164
  <p class="button-controls">
165
- <span class="list-controls">
166
- <a href="<?php echo esc_url( admin_url( 'nav-menus.php?page-tab=all&selectall=1#posttype-weglot-languages' ) ); ?>" class="select-all"><?php esc_html_e( 'Select all', 'weglot' ); ?></a>
167
- </span>
168
  <span class="add-to-menu">
169
- <button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'weglot' ); ?>" name="add-post-type-menu-item" id="submit-posttype-weglot-languages"><?php esc_html_e( 'Add to menu', 'weglot' ); ?></button>
170
  <span class="spinner"></span>
171
  </span>
172
  </p>
25
  $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
26
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
27
  $this->private_language_services = weglot_get_service( 'Private_Language_Service_Weglot' );
28
+ $this->menu_options_services = weglot_get_service( 'Menu_Options_Service_Weglot' );
29
  return $this;
30
  }
31
 
33
  * @see Hooks_Interface_Weglot
34
  *
35
  * @since 2.0
36
+ * @version 2.4.0
37
  * @return void
38
  */
39
  public function hooks() {
42
  }
43
 
44
  add_action( 'admin_head-nav-menus.php', [ $this, 'add_nav_menu_meta_boxes' ] );
45
+ add_action( 'admin_enqueue_scripts', [ $this, 'nav_admin_enqueue_scripts' ] );
46
+ add_action( 'wp_update_nav_menu_item', [ $this, 'custom_wp_update_nav_menu_item' ], 10, 2 );
 
 
 
 
 
 
47
  }
48
 
 
 
 
 
 
 
 
 
49
 
 
 
50
 
51
  /**
52
+ * @since 2.4.0
53
+ * @param int $menu_id
54
+ * @param int $menu_item_db_id
 
 
55
  * @return void
56
  */
57
+ public function custom_wp_update_nav_menu_item( $menu_id = 0, $menu_item_db_id = 0 ) {
58
+ if ( empty( $_POST['menu-item-url'][ $menu_item_db_id ] ) || '#weglot_switcher' !== $_POST[ 'menu-item-url' ][ $menu_item_db_id ] ) { //phpcs:ignore
59
+ return;
60
+ }
 
 
 
 
 
61
 
62
+ if ( ! current_user_can( 'edit_theme_options' ) ) {
63
+ return;
64
+ }
65
 
66
+ check_admin_referer( 'update-nav_menu', 'update-nav-menu-nonce' );
 
67
 
68
+ $options = $this->option_services->get_option( 'menu_switcher' );
69
+ foreach ( $options as $key => $value ) {
70
+ $options[ $key ] = empty( $_POST[ 'menu-item-' . $key ][ $menu_item_db_id ] ) ? 0 : 1;
71
  }
72
 
73
+ $this->option_services->set_option_by_key( 'menu_switcher', $options );
74
  }
75
 
76
  /**
77
  * @since 2.0
 
 
 
78
  * @return void
79
  */
80
+ public function nav_admin_enqueue_scripts() {
81
+ $screen = get_current_screen();
82
+ if ( 'nav-menus' !== $screen->base ) {
83
+ return;
84
+ }
85
 
86
+ wp_enqueue_script( 'weglot_nav_menu', WEGLOT_URL_DIST . '/nav-js.js', [ 'jquery' ], WEGLOT_VERSION );
 
 
 
87
 
88
+ $data['title'] = __( 'Weglot switcher', 'weglot' );
89
+ $data['options'] = $this->option_services->get_option( 'menu_switcher' );
90
+ $data['list_options'] = $this->menu_options_services->get_list_options_menu_switcher();
91
 
92
+ wp_localize_script( 'weglot_nav_menu', 'weglot_data', $data );
93
+ }
94
 
 
 
95
 
 
 
96
 
97
  /**
98
  * @since 2.0
109
  * @see add_meta_box weglot_nav_link
110
  */
111
  public function nav_menu_links() {
112
+ global $_nav_menu_placeholder, $nav_menu_selected_id; ?>
 
 
113
  <div id="posttype-weglot-languages" class="posttypediv">
114
  <div id="tabs-panel-weglot-endpoints" class="tabs-panel tabs-panel-active">
115
  <ul id="weglot-endpoints-checklist" class="categorychecklist form-no-clear">
116
+ <li>
117
+ <label class="menu-item-title">
118
+ <input type="checkbox" class="menu-item-checkbox" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-object-id]" value="<?php echo esc_attr( $_nav_menu_placeholder ); ?>" /> <?php esc_html_e( 'Weglot Switcher', 'weglot' ); ?>
119
+ </label>
120
+ <input type="hidden" class="menu-item-type" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-type]" value="custom" />
121
+ <input type="hidden" class="menu-item-title" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-title]" value="<?php esc_html_e( 'Weglot Switcher', 'weglot' ); ?>" />
122
+ <input type="hidden" class="menu-item-url" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-url]" value="#weglot_switcher" />
123
+ <input type="hidden" class="menu-item-classes" name="menu-item[<?php echo esc_attr( $_nav_menu_placeholder ); ?>][menu-item-classes]" />
124
+ </li>
 
 
 
 
 
 
 
125
  </ul>
126
  </div>
127
  <p class="button-controls">
 
 
 
128
  <span class="add-to-menu">
129
+ <button type="submit" class="button-secondary submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'weglot' ); ?>" name="add-post-type-menu-item" id="submit-posttype-weglot-languages"><?php esc_attr_e( 'Add to Menu' ); ?></button>
130
  <span class="spinner"></span>
131
  </span>
132
  </p>
src/actions/admin/class-metabox-url-translate-weglot.php CHANGED
@@ -212,6 +212,7 @@ class Metabox_Url_Translate_Weglot implements Hooks_Interface_Weglot {
212
  $exclude_post_type_metabox = apply_filters( 'weglot_url_translate_metabox_post_type_exclude', [
213
  'attachment',
214
  'seopress_404',
 
215
  ] );
216
 
217
  if ( in_array( $post_type, $exclude_post_type_metabox ) ) { //phpcs:ignore
212
  $exclude_post_type_metabox = apply_filters( 'weglot_url_translate_metabox_post_type_exclude', [
213
  'attachment',
214
  'seopress_404',
215
+ 'product',
216
  ] );
217
 
218
  if ( in_array( $post_type, $exclude_post_type_metabox ) ) { //phpcs:ignore
src/actions/admin/class-options-weglot.php CHANGED
@@ -90,8 +90,11 @@ class Options_Weglot implements Hooks_Interface_Weglot {
90
  $new_options = $this->sanitize_options_advanced( $new_options, $options );
91
  }
92
  break;
 
 
 
93
  case Helper_Tabs_Admin_Weglot::CUSTOM_URLS:
94
- if (null === $options) {
95
  $new_options['custom_urls'] = [];
96
  }
97
  break;
@@ -157,6 +160,7 @@ class Options_Weglot implements Hooks_Interface_Weglot {
157
 
158
  /**
159
  * @since 2.0
 
160
  * @param array $new_options
161
  * @param array $options
162
  * @return array
@@ -165,11 +169,15 @@ class Options_Weglot implements Hooks_Interface_Weglot {
165
  $new_options['auto_redirect'] = isset( $options['auto_redirect'] ) ? 1 : 0;
166
  $new_options['email_translate'] = isset( $options['email_translate'] ) ? 1 : 0;
167
  $new_options['translate_amp'] = isset( $options['translate_amp'] ) ? 1 : 0;
 
168
  $new_options['private_mode']['active'] = isset( $options['private_mode']['active'] ) ? 1 : 0;
169
 
170
  $languages = weglot_get_languages_configured();
171
 
172
- foreach ( $languages as $key => $lang) {
 
 
 
173
  $new_options['private_mode'][ $lang->getIso639() ] = isset( $options['private_mode'][ $lang->getIso639() ] ) ? 1 : 0;
174
  }
175
 
90
  $new_options = $this->sanitize_options_advanced( $new_options, $options );
91
  }
92
  break;
93
+ case Helper_Tabs_Admin_Weglot::SUPPORT:
94
+ $new_options['active_wc_reload'] = isset( $options['active_wc_reload'] ) ? 1 : 0;
95
+ break;
96
  case Helper_Tabs_Admin_Weglot::CUSTOM_URLS:
97
+ if ( null === $options ) {
98
  $new_options['custom_urls'] = [];
99
  }
100
  break;
160
 
161
  /**
162
  * @since 2.0
163
+ * @version 2.4.0
164
  * @param array $new_options
165
  * @param array $options
166
  * @return array
169
  $new_options['auto_redirect'] = isset( $options['auto_redirect'] ) ? 1 : 0;
170
  $new_options['email_translate'] = isset( $options['email_translate'] ) ? 1 : 0;
171
  $new_options['translate_amp'] = isset( $options['translate_amp'] ) ? 1 : 0;
172
+ $new_options['active_search'] = isset( $options['active_search'] ) ? 1 : 0;
173
  $new_options['private_mode']['active'] = isset( $options['private_mode']['active'] ) ? 1 : 0;
174
 
175
  $languages = weglot_get_languages_configured();
176
 
177
+ foreach ( $languages as $key => $lang ) {
178
+ if ( ! $lang ) {
179
+ continue;
180
+ }
181
  $new_options['private_mode'][ $lang->getIso639() ] = isset( $options['private_mode'][ $lang->getIso639() ] ) ? 1 : 0;
182
  }
183
 
src/actions/admin/class-pages-weglot.php CHANGED
@@ -27,6 +27,7 @@ class Pages_Weglot implements Hooks_Interface_Weglot {
27
  $this->language_services = weglot_get_service( 'Language_Service_Weglot' );
28
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
29
  $this->user_api_services = weglot_get_service( 'User_Api_Service_Weglot' );
 
30
  return $this;
31
  }
32
 
27
  $this->language_services = weglot_get_service( 'Language_Service_Weglot' );
28
  $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
29
  $this->user_api_services = weglot_get_service( 'User_Api_Service_Weglot' );
30
+ $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
31
  return $this;
32
  }
33
 
src/actions/admin/class-permalink-weglot.php CHANGED
@@ -15,7 +15,6 @@ if ( ! defined( 'ABSPATH' ) ) {
15
  class Permalink_Weglot {
16
 
17
  /**
18
- *
19
  * @since 2.0
20
  * @return void
21
  */
15
  class Permalink_Weglot {
16
 
17
  /**
 
18
  * @since 2.0
19
  * @return void
20
  */
src/actions/front/class-front-menu-weglot.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Actions\Front;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use WeglotWP\Models\Hooks_Interface_Weglot;
10
+ use WeglotWP\Helpers\Helper_Pages_Weglot;
11
+
12
+ /**
13
+ *
14
+ * @since 2.0
15
+ *
16
+ */
17
+ class Front_Menu_Weglot implements Hooks_Interface_Weglot {
18
+
19
+ /**
20
+ * @since 2.4.0
21
+ */
22
+ public function __construct() {
23
+ $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
24
+ $this->button_services = weglot_get_service( 'Button_Service_Weglot' );
25
+ $this->custom_url_services = weglot_get_service( 'Custom_Url_Service_Weglot' );
26
+ $this->request_url_services = weglot_get_service( 'Request_Url_Service_Weglot' );
27
+ $this->private_language_services = weglot_get_service( 'Private_Language_Service_Weglot' );
28
+ }
29
+
30
+ /**
31
+ * @see Hooks_Interface_Weglot
32
+ *
33
+ * @since 2.4.0
34
+ * @return void
35
+ */
36
+ public function hooks() {
37
+ if ( is_admin() ) {
38
+ return;
39
+ }
40
+
41
+ if ( ! $this->option_services->get_option( 'allowed' ) ) {
42
+ return;
43
+ }
44
+
45
+ add_filter( 'wp_get_nav_menu_items', [ $this, 'weglot_wp_get_nav_menu_items' ], 20 );
46
+ add_filter( 'nav_menu_link_attributes', [ $this, 'add_nav_menu_link_attributes' ], 10, 2 );
47
+
48
+ if ( $this->option_services->get_option( 'is_menu' ) ) {
49
+ add_filter( 'wp_nav_menu_items', [ $this, 'weglot_fallback_menu' ] );
50
+ }
51
+ }
52
+
53
+ /**
54
+ * @since 2.4.0
55
+ * @param string $items
56
+ * @return string
57
+ */
58
+ public function weglot_fallback_menu( $items ) {
59
+ $button = $this->button_services->get_html();
60
+ $items .= $button;
61
+
62
+ return $items;
63
+ }
64
+
65
+ /**
66
+ * @since 2.4.0
67
+ * @param array $items
68
+ * @return array
69
+ */
70
+ public function weglot_wp_get_nav_menu_items( $items ) {
71
+ if ( ! $this->request_url_services->is_translatable_url() || ! weglot_current_url_is_eligible() || $this->private_language_services->private_mode_for_all_languages() ) {
72
+ foreach ( $items as $key => $item ) {
73
+ if ( 'weglot-switcher' !== $item->post_name ) {
74
+ continue;
75
+ }
76
+ unset( $items[ $key ] );
77
+ }
78
+
79
+ return $items;
80
+ }
81
+
82
+ // Prevent customizer
83
+ if ( doing_action( 'customize_register' ) ) {
84
+ return $items;
85
+ }
86
+
87
+ $new_items = [];
88
+ $offset = 0;
89
+
90
+ foreach ( $items as $key => $item ) {
91
+ if ( strpos( $item->post_name, 'weglot-switcher' ) === false ) {
92
+ $item->menu_order += $offset;
93
+ $new_items[] = $item;
94
+ continue;
95
+ }
96
+
97
+ $i = 0;
98
+
99
+ $classes = [ 'weglot-lang', 'menu-item-weglot' ];
100
+ $with_flags = $this->option_services->get_option( 'with_flags' );
101
+ $options = $this->option_services->get_option( 'menu_switcher' );
102
+
103
+ if ( ! $options['hide_current'] && $with_flags ) {
104
+ $classes = array_merge( $classes, explode( ' ', $this->button_services->get_flag_class() ) );
105
+ }
106
+
107
+ $languages = weglot_get_languages_configured();
108
+ $current_language = $this->request_url_services->get_current_language_entry();
109
+
110
+ if ( $options['dropdown'] ) {
111
+ $title = __( 'Choose your language', 'weglot' );
112
+ if ( ! $options['hide_current'] ) {
113
+ $title = $this->button_services->get_name_with_language_entry( $current_language );
114
+ }
115
+ $item->title = apply_filters( 'weglot_menu_parent_menu_item_title', $title );
116
+ $item->attr_title = $current_language->getLocalName();
117
+ $item->classes = array_merge( [ 'weglot-parent-menu-item' ], $classes, [ $current_language->getIso639() ] );
118
+ $new_items[] = $item;
119
+ $offset++;
120
+ }
121
+
122
+ foreach ( $languages as $language ) {
123
+ if ( $this->private_language_services->is_active_private_mode_for_lang( $language->getIso639() ) ) {
124
+ continue;
125
+ }
126
+
127
+ if (
128
+ ( $options['dropdown'] && $current_language->getIso639() === $language->getIso639() ) ||
129
+ ( $options['hide_current'] && $current_language->getIso639() === $language->getIso639() ) ) {
130
+ continue;
131
+ }
132
+
133
+ $add_classes = [];
134
+ if ( $options['hide_current'] && $with_flags ) { // Just for children without flag classes
135
+ $classes = array_merge( $classes, explode( ' ', $this->button_services->get_flag_class() ) );
136
+ }
137
+
138
+ if ( $with_flags ) {
139
+ $add_classes[] = $language->getIso639();
140
+ }
141
+
142
+ $language_item = clone $item;
143
+ $language_item->ID = 'weglot-' . $item->ID . '-' . $language->getIso639();
144
+ $language_item->title = $this->button_services->get_name_with_language_entry( $language );
145
+ $language_item->attr_title = $language->getLocalName();
146
+ $language_item->url = $this->custom_url_services->get_link_button_with_key_code( $language->getIso639() );
147
+ ;
148
+ $language_item->lang = $language->getIso639();
149
+ $language_item->classes = array_merge( $classes, $add_classes );
150
+ $language_item->menu_order += $offset + $i++;
151
+ if ( $options['dropdown'] ) {
152
+ $language_item->menu_item_parent = $item->db_id;
153
+ $language_item->db_id = 0;
154
+ }
155
+
156
+ $new_items[] = $language_item;
157
+ }
158
+ $offset += $i - 1;
159
+ }
160
+ return $new_items;
161
+ }
162
+
163
+ /**
164
+ * @since 2.0
165
+ * @version 2.4.0
166
+ * @see nav_menu_link_attributes
167
+ * @param array $attrs
168
+ * @param object $item
169
+ * @return array
170
+ */
171
+ public function add_nav_menu_link_attributes( $attrs, $item ) {
172
+ $str = 'weglot-switcher';
173
+ if ( strpos( $item->post_name, $str ) !== false ) {
174
+ $current_language = $this->request_url_services->get_current_language();
175
+ if ( ! $this->request_url_services->is_translatable_url() || ! weglot_current_url_is_eligible() ) {
176
+ $attrs['style'] = 'display:none';
177
+ return $attrs;
178
+ }
179
+
180
+ $attrs['data-wg-notranslate'] = 'true';
181
+ }
182
+
183
+ return $attrs;
184
+ }
185
+ }
186
+
src/actions/front/class-search-weglot.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Actions\Front;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use WeglotWP\Models\Hooks_Interface_Weglot;
10
+
11
+ /**
12
+ * @since 2.4.0
13
+ */
14
+ class Search_Weglot implements Hooks_Interface_Weglot {
15
+ protected $old_search = null;
16
+
17
+ protected $new_search = null;
18
+
19
+ /**
20
+ * @since 2.4.0
21
+ */
22
+ public function __construct() {
23
+ $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
24
+ $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
25
+ }
26
+
27
+ /**
28
+ * @see Hooks_Interface_Weglot
29
+ *
30
+ * @since 2.4.0
31
+ * @return void
32
+ */
33
+ public function hooks() {
34
+ $search_active = $this->option_services->get_option( 'active_search' );
35
+
36
+ if ( $search_active ) {
37
+ add_action( 'pre_get_posts', [ $this, 'pre_get_posts_translate' ] );
38
+ add_filter( 'get_search_query', [ $this, 'get_search_query_translate' ] );
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @since 2.4.0
44
+ * @param WP_Query $query
45
+ * @return void
46
+ */
47
+ public function pre_get_posts_translate( $query ) {
48
+ if ( ! $query->is_search() || ! $query->is_main_query() ) {
49
+ return;
50
+ }
51
+
52
+ $query_vars_check = apply_filters( 'weglot_query_vars_check', 's' );
53
+ if ( empty( $query->query_vars[ $query_vars_check ] ) ) {
54
+ return;
55
+ }
56
+ $original_language = weglot_get_original_language();
57
+ $current_language = weglot_get_current_language();
58
+
59
+ if ( $original_language === $current_language ) {
60
+ return;
61
+ }
62
+
63
+ try {
64
+ $parser = $this->parser_services->get_parser();
65
+ $this->old_search = $query->query_vars[ 's' ];
66
+ $this->new_search = $parser->translate( $query->query_vars[ 's' ], $current_language, $original_language ); //phpcs:ignore
67
+
68
+ if ( empty( $this->new_search ) ) {
69
+ return;
70
+ }
71
+
72
+ set_query_var( $query_vars_check, $this->new_search );
73
+ } catch ( \Exception $th ) {
74
+ return;
75
+ }
76
+ }
77
+
78
+ /**
79
+ * @since 2.4.0
80
+ * @param string $string
81
+ * @return string
82
+ */
83
+ public function get_search_query_translate( $string ) {
84
+ return ($this->old_search) ? $this->old_search : $string;
85
+ }
86
+ }
src/actions/front/class-translate-page-weglot.php CHANGED
@@ -83,7 +83,9 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
83
  'avia_ajax_switch_menu_walker', // Enfold theme
84
  'query-themes', // WP Core
85
  'wpestate_ajax_check_booking_valability_internal', // WP Estate theme
86
- 'mailster_get_template', // Mailster Pro
 
 
87
  ] );
88
 
89
  if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
@@ -125,6 +127,7 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
125
  }
126
 
127
  $active_translation = apply_filters( 'weglot_active_translation_before_process', true );
 
128
  // Default : yes
129
  if ( ! $active_translation ) {
130
  return;
@@ -151,7 +154,6 @@ class Translate_Page_Weglot implements Hooks_Interface_Weglot {
151
  $this->translate_services->set_original_language( weglot_get_original_language() );
152
  $this->translate_services->set_current_language( $this->request_url_services->get_current_language() );
153
  echo $this->translate_services->weglot_treat_page( file_get_contents( $file ) ); //phpcs:ignore
154
- die;
155
  } else {
156
  $this->translate_services->weglot_translate();
157
  }
83
  'avia_ajax_switch_menu_walker', // Enfold theme
84
  'query-themes', // WP Core
85
  'wpestate_ajax_check_booking_valability_internal', // WP Estate theme
86
+ 'wpestate_ajax_add_booking', // WP Estate theme
87
+ 'wpestate_ajax_check_booking_valability', // WP Estate theme
88
+ 'mailster_get_template', // Mailster Pro,
89
  ] );
90
 
91
  if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['action'] ) && in_array( $_POST['action'], $action_ajax_no_translate ) ) { //phpcs:ignore
127
  }
128
 
129
  $active_translation = apply_filters( 'weglot_active_translation_before_process', true );
130
+
131
  // Default : yes
132
  if ( ! $active_translation ) {
133
  return;
154
  $this->translate_services->set_original_language( weglot_get_original_language() );
155
  $this->translate_services->set_current_language( $this->request_url_services->get_current_language() );
156
  echo $this->translate_services->weglot_treat_page( file_get_contents( $file ) ); //phpcs:ignore
 
157
  } else {
158
  $this->translate_services->weglot_translate();
159
  }
src/class-bootstrap-weglot.php CHANGED
@@ -94,8 +94,7 @@ class Bootstrap_Weglot {
94
  */
95
  public function get_service( $name ) {
96
  if ( ! array_key_exists( $name, $this->services ) ) {
97
- return null;
98
- // @TODO : Throw exception
99
  }
100
 
101
  if ( is_string( $this->services[ $name ] ) ) {
94
  */
95
  public function get_service( $name ) {
96
  if ( ! array_key_exists( $name, $this->services ) ) {
97
+ throw new \Exception( 'Service : ' . $name . ' not exist' );
 
98
  }
99
 
100
  if ( is_string( $this->services[ $name ] ) ) {
src/domcheckers/class-input-reset.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @since 2.5.0
13
+ */
14
+ class Input_Reset extends AbstractDomChecker {
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ const DOM = "input[type='reset']";
19
+ /**
20
+ * {@inheritdoc}
21
+ */
22
+ const PROPERTY = 'value';
23
+ /**
24
+ * {@inheritdoc}
25
+ */
26
+ const WORD_TYPE = WordType::TEXT;
27
+ }
src/domcheckers/class-meta-facebook-image.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @since 2.5.0
13
+ */
14
+ class Meta_Facebook_Image extends AbstractDomChecker {
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ const DOM = "meta[name='og:image'], meta[name='og:image:secure_url']";
19
+ /**
20
+ * {@inheritdoc}
21
+ */
22
+ const PROPERTY = 'content';
23
+ /**
24
+ * {@inheritdoc}
25
+ */
26
+ const WORD_TYPE = WordType::IMG_SRC;
27
+ }
src/domcheckers/class-meta-twitter-image.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @since 2.5.0
13
+ */
14
+ class Meta_Twitter_Image extends AbstractDomChecker {
15
+ /**
16
+ * {@inheritdoc}
17
+ */
18
+ const DOM = "meta[name='twitter:image'], meta[name='twitter:image:src']";
19
+ /**
20
+ * {@inheritdoc}
21
+ */
22
+ const PROPERTY = 'content';
23
+ /**
24
+ * {@inheritdoc}
25
+ */
26
+ const WORD_TYPE = WordType::IMG_SRC;
27
+ }
src/domcheckers/class-meta-twitter.php CHANGED
@@ -15,7 +15,7 @@ class Meta_Twitter extends AbstractDomChecker {
15
  /**
16
  * {@inheritdoc}
17
  */
18
- const DOM = "meta[name='twitter:image'],meta[name='twitter:card'],meta[name='twitter:site'],meta[name='twitter:creator']";
19
  /**
20
  * {@inheritdoc}
21
  */
15
  /**
16
  * {@inheritdoc}
17
  */
18
+ const DOM = "meta[name='twitter:card'],meta[name='twitter:site'],meta[name='twitter:creator']";
19
  /**
20
  * {@inheritdoc}
21
  */
src/helpers/class-helper-filter-url-weglot.php CHANGED
@@ -26,6 +26,23 @@ abstract class Helper_Filter_Url_Weglot {
26
  return apply_filters( 'weglot_get_clean_base_url', $url );
27
  }
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  /**
30
  * Filter URL log redirection
31
  * @since 2.0
26
  return apply_filters( 'weglot_get_clean_base_url', $url );
27
  }
28
 
29
+ /**
30
+ * @since 2.4.0
31
+ * @param string $url
32
+ * @return string
33
+ */
34
+ public static function filter_url_lambda( $url ) {
35
+ $current_and_original_language = weglot_get_current_and_original_language();
36
+ $request_url_service = weglot_get_request_url_service();
37
+ if ( $current_and_original_language['current'] === $current_and_original_language['original'] ) {
38
+ return $url;
39
+ }
40
+
41
+ $url = $request_url_service->create_url_object( $url );
42
+
43
+ return $url->getForLanguage( $current_and_original_language['current'] );
44
+ }
45
+
46
  /**
47
  * Filter URL log redirection
48
  * @since 2.0
src/helpers/class-helper-json-inline-weglot.php CHANGED
@@ -32,6 +32,20 @@ abstract class Helper_Json_Inline_Weglot {
32
  return $string;
33
  }
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  /**
36
  * @since 2.3.0
37
  *
32
  return $string;
33
  }
34
 
35
+ /**
36
+ * @since 2.5.0
37
+ * @param string $string
38
+ * @return string
39
+ */
40
+ public static function need_json_encode_api( $string ) {
41
+ if ( strip_tags( $string ) !== $string ) { // Is HTML
42
+ $str = \json_encode( $string ); //phpcs:ignore
43
+ return trim( $str, '"' );
44
+ }
45
+
46
+ return str_replace( '"', '', \json_encode( $string ) ); //phpcs:ignore
47
+ }
48
+
49
  /**
50
  * @since 2.3.0
51
  *
src/helpers/class-helper-keys-json-weglot.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Helpers;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ /**
10
+ * @since 2.4.0
11
+ */
12
+ abstract class Helper_Keys_Json_Weglot {
13
+ /**
14
+ * @var array
15
+ */
16
+ protected static $keys = [
17
+ 'contact-form-7' => [
18
+ 'message'
19
+ ],
20
+ ];
21
+
22
+ /**
23
+ * @since 2.4.0
24
+ * @return array
25
+ */
26
+ public static function get_keys() {
27
+ return apply_filters( 'weglot_keys_translate_json', self::$keys );
28
+ }
29
+
30
+ /**
31
+ * @since 2.4.0
32
+ * @param string $key
33
+ * @return bool
34
+ */
35
+ public static function translate_key_for_path( $key ) {
36
+ $keys_translate = self::get_keys();
37
+ $path = weglot_get_rest_current_url_path();
38
+
39
+ foreach ( $keys_translate as $key_translate => $value) {
40
+ if ( empty( $key_translate ) || strpos( $path, $key_translate ) === false) {
41
+ continue;
42
+ }
43
+
44
+ if ( in_array( $key, $keys_translate[ $key_translate ], true ) ) {
45
+ return true;
46
+ }
47
+ }
48
+
49
+ return false;
50
+ }
51
+ }
src/helpers/class-helper-menu-options-weglot.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Helpers;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ /**
10
+ * @since 2.4.0
11
+ */
12
+ abstract class Helper_Menu_Options_Weglot {
13
+
14
+ /**
15
+ * @var string
16
+ */
17
+ const HIDE_CURRENT = 'hide_current';
18
+
19
+ /**
20
+ * @var string
21
+ */
22
+ const DROPDOWN = 'dropdown';
23
+
24
+ /**
25
+ * @since 2.4.0
26
+ * @static
27
+ * @return array
28
+ */
29
+ public static function get_menu_switcher_list_options() {
30
+ return apply_filters( 'weglot_menu_switcher_options', [
31
+ [
32
+ 'key' => self::HIDE_CURRENT,
33
+ 'title' => __( 'Hide the current language', 'weglot' ),
34
+ ],
35
+ [
36
+ 'key' => self::DROPDOWN,
37
+ 'title' => __( "Show as dropdown (By default it's a list)", 'weglot' ),
38
+ ],
39
+ ]);
40
+ }
41
+
42
+ /**
43
+ * @since 2.4.0
44
+ * @static
45
+ * @return array
46
+ */
47
+ public static function get_keys() {
48
+ return apply_filters( 'weglot_menu_switcher_options_keys', [
49
+ self::HIDE_CURRENT,
50
+ self::DROPDOWN,
51
+ ]);
52
+ }
53
+ }
src/helpers/class-helper-tabs-admin-weglot.php CHANGED
@@ -28,6 +28,12 @@ abstract class Helper_Tabs_Admin_Weglot {
28
  */
29
  const CUSTOM_URLS = 'custom-urls';
30
 
 
 
 
 
 
 
31
  /**
32
  * Get tabs constant
33
  *
@@ -39,7 +45,8 @@ abstract class Helper_Tabs_Admin_Weglot {
39
  return [
40
  self::SETTINGS,
41
  self::STATUS,
42
- self::CUSTOM_URLS
 
43
  ];
44
  }
45
 
28
  */
29
  const CUSTOM_URLS = 'custom-urls';
30
 
31
+ /**
32
+ * @var string
33
+ */
34
+ const SUPPORT = 'support';
35
+
36
+
37
  /**
38
  * Get tabs constant
39
  *
45
  return [
46
  self::SETTINGS,
47
  self::STATUS,
48
+ self::CUSTOM_URLS,
49
+ self::SUPPORT
50
  ];
51
  }
52
 
src/services/class-button-service-weglot.php CHANGED
@@ -86,22 +86,8 @@ class Button_Service_Weglot {
86
  $private_mode = $this->option_services->get_option( 'private_mode' );
87
  $original_language = weglot_get_original_language();
88
 
89
- $view_button = false;
90
- if ( $private_mode['active'] && ! is_admin() ) {
91
- foreach ($private_mode as $key_code => $value) {
92
- if ( $key_code === $original_language || $key_code === 'active' ) {
93
- continue;
94
- }
95
-
96
- if ( ! $this->private_language_services->is_active_private_mode_for_lang( $key_code ) ) {
97
- $view_button = true;
98
- }
99
- }
100
- } else {
101
- $view_button = true;
102
- }
103
-
104
- if ( ! apply_filters( 'weglot_view_button_html', $view_button ) ) {
105
  return '';
106
  }
107
 
86
  $private_mode = $this->option_services->get_option( 'private_mode' );
87
  $original_language = weglot_get_original_language();
88
 
89
+ $private_all_languages = $this->private_language_services->private_mode_for_all_languages();
90
+ if ( apply_filters( 'weglot_view_button_html', $private_all_languages ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  return '';
92
  }
93
 
src/services/class-custom-url-service-weglot.php CHANGED
@@ -24,9 +24,10 @@ class Custom_Url_Service_Weglot {
24
  /**
25
  * @since 2.3.0
26
  * @param string $key_code
 
27
  * @return string
28
  */
29
- public function get_link( $key_code ) {
30
  global $post;
31
  $weglot_url = $this->request_url_services->get_weglot_url();
32
  $request_without_language = array_filter( explode( '/', $weglot_url->getPath() ), 'strlen' );
@@ -56,7 +57,17 @@ class Custom_Url_Service_Weglot {
56
 
57
  $link_button = apply_filters( 'weglot_link_language', $url_lang, $key_code );
58
 
59
- $link_button = preg_replace( '#\?no_lredirect=true$#', '', $link_button ); // Remove ending "?no_lredirect=true"
 
 
 
 
 
 
 
 
 
 
60
 
61
  return apply_filters( 'weglot_get_link_with_key_code', $link_button );
62
  }
@@ -70,10 +81,6 @@ class Custom_Url_Service_Weglot {
70
  public function get_link_button_with_key_code( $key_code ) {
71
  $link_button = $this->get_link( $key_code );
72
 
73
- if ( weglot_has_auto_redirect() && strpos( $link_button, 'no_lredirect' ) === false && ( is_home() || is_front_page() ) && $key_code === $original_language ) {
74
- $link_button .= '?no_lredirect=true';
75
- }
76
-
77
  return apply_filters( 'weglot_get_link_button_with_key_code', $link_button );
78
  }
79
  }
24
  /**
25
  * @since 2.3.0
26
  * @param string $key_code
27
+ * @param boolean $add_no_redirect
28
  * @return string
29
  */
30
+ public function get_link( $key_code, $add_no_redirect = true ) {
31
  global $post;
32
  $weglot_url = $this->request_url_services->get_weglot_url();
33
  $request_without_language = array_filter( explode( '/', $weglot_url->getPath() ), 'strlen' );
57
 
58
  $link_button = apply_filters( 'weglot_link_language', $url_lang, $key_code );
59
 
60
+ if (
61
+ weglot_has_auto_redirect() &&
62
+ strpos( $link_button, 'no_lredirect' ) === false && // If not exist
63
+ ( is_home() || is_front_page() ) && // Only for homepage
64
+ $key_code === $original_language && // Only for original language
65
+ $add_no_redirect // Example : for hreflang service
66
+ ) {
67
+ $link_button .= '?no_lredirect=true';
68
+ } else {
69
+ $link_button = preg_replace( '#\?no_lredirect=true$#', '', $link_button ); // Remove ending "?no_lredirect=true"
70
+ }
71
 
72
  return apply_filters( 'weglot_get_link_with_key_code', $link_button );
73
  }
81
  public function get_link_button_with_key_code( $key_code ) {
82
  $link_button = $this->get_link( $key_code );
83
 
 
 
 
 
84
  return apply_filters( 'weglot_get_link_button_with_key_code', $link_button );
85
  }
86
  }
src/services/class-generate-switcher-service-weglot.php CHANGED
@@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
11
  * @since 2.3.0
12
  */
13
  class Generate_Switcher_Service_Weglot {
14
-
15
  /**
16
  * @since 2.3.0
17
  */
@@ -42,15 +42,22 @@ class Generate_Switcher_Service_Weglot {
42
 
43
  /**
44
  * @since 2.3.0
45
- *
46
  * @param string $dom
47
  * @return string
48
  */
49
- public function replace_weglot_menu( $dom ) {
 
 
 
 
 
50
  if ( strpos( $dom, '[weglot_menu' ) === false ) {
51
  return $dom;
52
  }
53
 
 
 
54
  $languages_configured = $this->language_services->get_languages_configured();
55
  $options = $this->option_services->get_options();
56
  $is_fullname = $options['is_fullname'];
@@ -90,7 +97,7 @@ class Generate_Switcher_Service_Weglot {
90
  $dom = preg_replace( '#' . $shortcode_url_html . '#i', $link_menu, $dom );
91
  }
92
 
93
- $dom .= sprintf( '<!--Weglot %s-->', WEGLOT_VERSION );
94
 
95
  return apply_filters( 'weglot_replace_weglot_menu', $dom );
96
  }
@@ -102,7 +109,7 @@ class Generate_Switcher_Service_Weglot {
102
  * @return string
103
  */
104
  public function render_default_button( $dom ) {
105
- if ( strpos( $dom, sprintf( '<!--Weglot %s-->', WEGLOT_VERSION ) ) !== false ) {
106
  return $dom;
107
  }
108
 
@@ -120,7 +127,7 @@ class Generate_Switcher_Service_Weglot {
120
  */
121
  public function generate_switcher_from_dom( $dom ) {
122
  $dom = $this->replace_div_id( $dom );
123
- $dom = $this->replace_weglot_menu( $dom );
124
  $dom = $this->render_default_button( $dom );
125
 
126
  return apply_filters( 'weglot_generate_switcher_from_dom', $dom );
11
  * @since 2.3.0
12
  */
13
  class Generate_Switcher_Service_Weglot {
14
+ protected $string_version = '<!--Weglot %s-->';
15
  /**
16
  * @since 2.3.0
17
  */
42
 
43
  /**
44
  * @since 2.3.0
45
+ * @version 2.4.0
46
  * @param string $dom
47
  * @return string
48
  */
49
+ public function check_weglot_menu( $dom ) {
50
+ if ( strpos( $dom, 'menu-item-weglot' ) !== false ) {
51
+ $dom .= sprintf( $this->string_version, WEGLOT_VERSION );
52
+ return $dom;
53
+ }
54
+
55
  if ( strpos( $dom, '[weglot_menu' ) === false ) {
56
  return $dom;
57
  }
58
 
59
+
60
+
61
  $languages_configured = $this->language_services->get_languages_configured();
62
  $options = $this->option_services->get_options();
63
  $is_fullname = $options['is_fullname'];
97
  $dom = preg_replace( '#' . $shortcode_url_html . '#i', $link_menu, $dom );
98
  }
99
 
100
+ $dom .= sprintf( $this->string_version, WEGLOT_VERSION );
101
 
102
  return apply_filters( 'weglot_replace_weglot_menu', $dom );
103
  }
109
  * @return string
110
  */
111
  public function render_default_button( $dom ) {
112
+ if ( strpos( $dom, sprintf( $this->string_version, WEGLOT_VERSION ) ) !== false ) {
113
  return $dom;
114
  }
115
 
127
  */
128
  public function generate_switcher_from_dom( $dom ) {
129
  $dom = $this->replace_div_id( $dom );
130
+ $dom = $this->check_weglot_menu( $dom );
131
  $dom = $this->render_default_button( $dom );
132
 
133
  return apply_filters( 'weglot_generate_switcher_from_dom', $dom );
src/services/class-href-lang-service-weglot.php CHANGED
@@ -27,13 +27,17 @@ class Href_Lang_Service_Weglot {
27
  public function generate_href_lang_tags() {
28
  $destination_languages = weglot_get_all_languages_configured();
29
  $render = '';
 
 
 
 
30
  try {
31
  foreach ( $destination_languages as $language ) {
32
  if ( $this->private_language_service->is_active_private_mode_for_lang( $language ) ) {
33
  continue;
34
  }
35
 
36
- $url = $this->custom_url_services->get_link( $language );
37
  $render .= '<link rel="alternate" href="' . $url . '" hreflang="' . $language . '"/>' . "\n";
38
  }
39
  } catch ( \Exception $e ) {
27
  public function generate_href_lang_tags() {
28
  $destination_languages = weglot_get_all_languages_configured();
29
  $render = '';
30
+ if ( $this->private_language_service->private_mode_for_all_languages() ) {
31
+ return apply_filters( 'weglot_href_lang', $render );
32
+ }
33
+
34
  try {
35
  foreach ( $destination_languages as $language ) {
36
  if ( $this->private_language_service->is_active_private_mode_for_lang( $language ) ) {
37
  continue;
38
  }
39
 
40
+ $url = $this->custom_url_services->get_link( $language, false );
41
  $render .= '<link rel="alternate" href="' . $url . '" hreflang="' . $language . '"/>' . "\n";
42
  }
43
  } catch ( \Exception $e ) {
src/services/class-menu-options-service-weglot.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Services;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+
10
+ use WeglotWP\Helpers\Helper_Menu_Options_Weglot;
11
+
12
+ /**
13
+ * @since 2.4.0
14
+ */
15
+ class Menu_Options_Service_Weglot {
16
+
17
+ /**
18
+ * @since 2.4.0
19
+ */
20
+ public function __construct() {
21
+ $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
22
+ }
23
+
24
+ /**
25
+ * @since 2.4.0
26
+ * @return array
27
+ */
28
+ public function get_options_default() {
29
+ $keys = Helper_Menu_Options_Weglot::get_keys();
30
+
31
+ return apply_filters( 'weglot_menu_switcher_options_default', array_map( function() {
32
+ return false;
33
+ }, array_flip( $keys ) ) );
34
+ }
35
+
36
+ /**
37
+ * @since 2.4.0
38
+ * @return array
39
+ */
40
+ public function get_list_options_menu_switcher() {
41
+ return Helper_Menu_Options_Weglot::get_menu_switcher_list_options();
42
+ }
43
+ }
src/services/class-option-service-weglot.php CHANGED
@@ -35,13 +35,17 @@ class Option_Service_Weglot {
35
  'show_box_first_settings' => false,
36
  'rtl_ltr_style' => '',
37
  'allowed' => true,
 
38
  'custom_urls' => [],
39
  'flag_css' => '',
 
 
40
  'private_mode' => [
41
  'active' => false,
42
  ],
43
  ];
44
 
 
45
  /**
46
  * Get options default
47
  *
@@ -54,11 +58,18 @@ class Option_Service_Weglot {
54
 
55
  /**
56
  * @since 2.0
57
- * @version 2.2.2
58
  * @return array
59
  */
60
  public function get_options() {
61
- return apply_filters( 'weglot_get_options', wp_parse_args( get_option( WEGLOT_SLUG ), $this->get_options_default() ) );
 
 
 
 
 
 
 
62
  }
63
 
64
  /**
@@ -68,6 +79,7 @@ class Option_Service_Weglot {
68
  */
69
  public function get_option( $name ) {
70
  $options = $this->get_options();
 
71
  if ( ! array_key_exists( $name, $options ) ) {
72
  return null; // @TODO : throw exception
73
  }
@@ -83,6 +95,7 @@ class Option_Service_Weglot {
83
  $exclude_blocks = $this->get_option( 'exclude_blocks' );
84
  $exclude_blocks[] = '#wpadminbar';
85
  $exclude_blocks[] = '#query-monitor';
 
86
 
87
  return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
88
  }
35
  'show_box_first_settings' => false,
36
  'rtl_ltr_style' => '',
37
  'allowed' => true,
38
+ 'active_wc_reload' => false,
39
  'custom_urls' => [],
40
  'flag_css' => '',
41
+ 'menu_switcher' => [],
42
+ 'active_search' => false,
43
  'private_mode' => [
44
  'active' => false,
45
  ],
46
  ];
47
 
48
+
49
  /**
50
  * Get options default
51
  *
58
 
59
  /**
60
  * @since 2.0
61
+ * @version 2.4.0
62
  * @return array
63
  */
64
  public function get_options() {
65
+ $options = wp_parse_args( get_option( WEGLOT_SLUG ), $this->get_options_default() );
66
+
67
+ if ( empty( $options['menu_switcher'] ) ) {
68
+ $menu_options_services = weglot_get_service( 'Menu_Options_Service_Weglot' );
69
+ $options['menu_switcher'] = $menu_options_services->get_options_default();
70
+ }
71
+
72
+ return apply_filters( 'weglot_get_options', $options );
73
  }
74
 
75
  /**
79
  */
80
  public function get_option( $name ) {
81
  $options = $this->get_options();
82
+
83
  if ( ! array_key_exists( $name, $options ) ) {
84
  return null; // @TODO : throw exception
85
  }
95
  $exclude_blocks = $this->get_option( 'exclude_blocks' );
96
  $exclude_blocks[] = '#wpadminbar';
97
  $exclude_blocks[] = '#query-monitor';
98
+ $exclude_blocks[] = '.menu-item-weglot';
99
 
100
  return apply_filters( 'weglot_exclude_blocks', $exclude_blocks );
101
  }
src/services/class-private-language-service-weglot.php CHANGED
@@ -46,6 +46,33 @@ class Private_Language_Service_Weglot {
46
 
47
  return false;
48
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  }
50
 
51
 
46
 
47
  return false;
48
  }
49
+
50
+ /**
51
+ * @since 2.4.0
52
+ * @return bool
53
+ */
54
+ public function private_mode_for_all_languages() {
55
+ $private_mode_languages = $this->option_services->get_option( 'private_mode' );
56
+ if ( current_user_can( $this->role_private_mode ) ) { // No check if admin
57
+ return false;
58
+ }
59
+
60
+ if ( ! $private_mode_languages['active'] ) {
61
+ return false;
62
+ }
63
+
64
+ $original_language = weglot_get_original_language();
65
+ unset( $private_mode_languages['active'] );
66
+ unset( $private_mode_languages[ $original_language ] );
67
+
68
+ foreach ( $private_mode_languages as $lang => $lang_active ) {
69
+ if ( ! $lang_active ) {
70
+ return false;
71
+ }
72
+ }
73
+
74
+ return true;
75
+ }
76
  }
77
 
78
 
src/services/class-replace-link-service-weglot.php CHANGED
@@ -26,8 +26,14 @@ class Replace_Link_Service_Weglot {
26
  * @return string
27
  */
28
  public function replace_url( $url ) {
29
- $current_and_original = weglot_get_current_and_original_language();
30
- $custom_urls = $this->option_service->get_option( 'custom_urls' );
 
 
 
 
 
 
31
 
32
  $parsed_url = wp_parse_url( $url );
33
  $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
@@ -48,7 +54,6 @@ class Replace_Link_Service_Weglot {
48
  $request_without_language = array_filter( explode( '/', $path ), 'strlen' );
49
  $index_entries = count( $request_without_language );
50
 
51
-
52
  if ( isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && isset( $custom_urls[ $current_language ] ) ) {
53
  $slug_in_work = $request_without_language[ $index_entries ];
54
  $key_slug = array_search( $slug_in_work, $custom_urls[ $current_language ] ); //phpcs:ignore
26
  * @return string
27
  */
28
  public function replace_url( $url ) {
29
+ $no_replace_condition = apply_filters( 'weglot_no_replace_url_condition', 'wp-content/uploads' );
30
+
31
+ if ( strpos( $url, $no_replace_condition ) !== false ) {
32
+ return $url;
33
+ }
34
+
35
+ $current_and_original = weglot_get_current_and_original_language();
36
+ $custom_urls = $this->option_service->get_option( 'custom_urls' );
37
 
38
  $parsed_url = wp_parse_url( $url );
39
  $scheme = isset( $parsed_url['scheme'] ) ? $parsed_url['scheme'] . '://' : '';
54
  $request_without_language = array_filter( explode( '/', $path ), 'strlen' );
55
  $index_entries = count( $request_without_language );
56
 
 
57
  if ( isset( $request_without_language[ $index_entries ] ) && ! is_admin() && ! empty( $custom_urls ) && isset( $custom_urls[ $current_language ] ) ) {
58
  $slug_in_work = $request_without_language[ $index_entries ];
59
  $key_slug = array_search( $slug_in_work, $custom_urls[ $current_language ] ); //phpcs:ignore
src/services/class-replace-url-service-weglot.php CHANGED
@@ -103,6 +103,7 @@ class Replace_Url_Service_Weglot {
103
  $admin_url = admin_url();
104
  $parsed_url = wp_parse_url( $current_url );
105
  $server_host = apply_filters( 'weglot_check_link_server_host', $_SERVER['HTTP_HOST'] ); //phpcs:ignore
 
106
  return (
107
  (
108
  ( 'h' === $current_url[0] && $parsed_url['host'] === $server_host ) ||
@@ -157,11 +158,12 @@ class Replace_Url_Service_Weglot {
157
  * @return boolean
158
  */
159
  public function ends_with( $haystack, $needle ) {
160
- $temp = strlen( $haystack );
 
161
 
162
  return '' === $needle ||
163
  (
164
- ( $temp - strlen( $needle ) ) >= 0 && strpos( $haystack, $needle, $temp ) !== false
165
  );
166
  }
167
  }
103
  $admin_url = admin_url();
104
  $parsed_url = wp_parse_url( $current_url );
105
  $server_host = apply_filters( 'weglot_check_link_server_host', $_SERVER['HTTP_HOST'] ); //phpcs:ignore
106
+
107
  return (
108
  (
109
  ( 'h' === $current_url[0] && $parsed_url['host'] === $server_host ) ||
158
  * @return boolean
159
  */
160
  public function ends_with( $haystack, $needle ) {
161
+ $temp = strlen( $haystack );
162
+ $len_needle = strlen( $needle );
163
 
164
  return '' === $needle ||
165
  (
166
+ ( $temp - $len_needle ) >= 0 && strpos( $haystack, $needle, $temp - $len_needle ) !== false
167
  );
168
  }
169
  }
src/services/class-request-url-service-weglot.php CHANGED
@@ -27,8 +27,9 @@ class Request_Url_Service_Weglot {
27
  * @since 2.0
28
  */
29
  public function __construct() {
30
- $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
31
- $this->amp_services = weglot_get_service( 'Amp_Service_Weglot' );
 
32
  }
33
 
34
  /**
@@ -86,14 +87,31 @@ class Request_Url_Service_Weglot {
86
  return $this->weglot_url;
87
  }
88
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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();
@@ -106,6 +124,14 @@ class Request_Url_Service_Weglot {
106
  return $current_language;
107
  }
108
 
 
 
 
 
 
 
 
 
109
  /**
110
  * Abstraction of \Weglot\Util\Url
111
  * @since 2.0
27
  * @since 2.0
28
  */
29
  public function __construct() {
30
+ $this->option_services = weglot_get_service( 'Option_Service_Weglot' );
31
+ $this->amp_services = weglot_get_service( 'Amp_Service_Weglot' );
32
+ $this->language_services = weglot_get_service( 'Language_Service_Weglot' );
33
  }
34
 
35
  /**
87
  return $this->weglot_url;
88
  }
89
 
90
+ /**
91
+ * @since 2.4.1
92
+ * @return boolean
93
+ */
94
+ public function is_rest() {
95
+ $prefix = rest_get_url_prefix();
96
+ if (
97
+ defined( 'REST_REQUEST' ) && REST_REQUEST || isset( $_GET['rest_route'] ) && // phpcs:ignore
98
+ strpos( trim( $_GET['rest_route'], '\\/' ), $prefix, 0 ) === 0 ) { // phpcs:ignore
99
+ return true;
100
+ }
101
+ $rest_url = wp_parse_url( site_url( $prefix ) );
102
+ $current_url = wp_parse_url( add_query_arg( array() ) );
103
+ return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0;
104
+ }
105
+
106
  /**
107
  * Abstraction of \Weglot\Util\Url
108
  * @since 2.0
109
+ * @version 2.4.0
110
  * @param boolean $with_filter
111
  * @return string
112
  */
113
  public function get_current_language( $with_filter = true ) {
114
+ if ( ( wp_doing_ajax() || $this->is_rest() ) && isset( $_SERVER['HTTP_REFERER'] ) ) { //phpcs:ignore
115
  $current_language = $this->create_url_object( $_SERVER['HTTP_REFERER'] )->detectCurrentLanguage(); //phpcs:ignore
116
  } else {
117
  $current_language = $this->get_weglot_url()->detectCurrentLanguage();
124
  return $current_language;
125
  }
126
 
127
+ /**
128
+ * @since 2.4.0
129
+ * @return LanguageEntry
130
+ */
131
+ public function get_current_language_entry() {
132
+ return $this->language_services->get_current_language_entry_from_key( $this->get_current_language() );
133
+ }
134
+
135
  /**
136
  * Abstraction of \Weglot\Util\Url
137
  * @since 2.0
src/services/class-translate-service-weglot.php CHANGED
@@ -7,6 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) {
7
  }
8
 
9
  use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
 
10
 
11
 
12
  /**
@@ -14,6 +15,7 @@ use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
14
  */
15
  class Translate_Service_Weglot {
16
 
 
17
  /**
18
  * @since 2.3.0
19
  */
@@ -24,6 +26,7 @@ class Translate_Service_Weglot {
24
  $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
25
  $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
26
  $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
 
27
  $this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
28
  $this->generate_switcher_service = weglot_get_service( 'Generate_Switcher_Service_Weglot' );
29
  }
@@ -106,6 +109,10 @@ class Translate_Service_Weglot {
106
  // Improve this with multiple service
107
  $translated_content = weglot_get_service( 'WC_Translate_Weglot' )->translate_words( $translated_content );
108
  }
 
 
 
 
109
 
110
  $translated_content = $this->other_translate_services->translate_words( $translated_content );
111
 
@@ -135,7 +142,7 @@ class Translate_Service_Weglot {
135
 
136
  /**
137
  * @since 2.3.0
138
- *
139
  * @param array $array
140
  * @return array
141
  */
@@ -152,8 +159,17 @@ class Translate_Service_Weglot {
152
  } catch ( \Exception $e ) {
153
  continue;
154
  }
155
- } elseif ( in_array( $key, $array_not_ajax_html ) ) { //phpcs:ignore
156
  $array[$key] = $this->replace_link_services->replace_url( $val ); //phpcs:ignore
 
 
 
 
 
 
 
 
 
157
  }
158
  }
159
  }
7
  }
8
 
9
  use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
10
+ use WeglotWP\Helpers\Helper_Keys_Json_Weglot;
11
 
12
 
13
  /**
15
  */
16
  class Translate_Service_Weglot {
17
 
18
+
19
  /**
20
  * @since 2.3.0
21
  */
26
  $this->replace_link_services = weglot_get_service( 'Replace_Link_Service_Weglot' );
27
  $this->parser_services = weglot_get_service( 'Parser_Service_Weglot' );
28
  $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
29
+ $this->ninja_active_services = weglot_get_service( 'Ninja_Active_Weglot' );
30
  $this->other_translate_services = weglot_get_service( 'Other_Translate_Service_Weglot' );
31
  $this->generate_switcher_service = weglot_get_service( 'Generate_Switcher_Service_Weglot' );
32
  }
109
  // Improve this with multiple service
110
  $translated_content = weglot_get_service( 'WC_Translate_Weglot' )->translate_words( $translated_content );
111
  }
112
+ if ( $this->ninja_active_services->is_active() ) {
113
+ // Improve this with multiple service
114
+ $translated_content = weglot_get_service( 'Ninja_Translate_Json_Weglot' )->translate_words( $translated_content );
115
+ }
116
 
117
  $translated_content = $this->other_translate_services->translate_words( $translated_content );
118
 
142
 
143
  /**
144
  * @since 2.3.0
145
+ * @version 2.4.0
146
  * @param array $array
147
  * @return array
148
  */
159
  } catch ( \Exception $e ) {
160
  continue;
161
  }
162
+ } elseif ( in_array( $key, $array_not_ajax_html, true ) ) {
163
  $array[$key] = $this->replace_link_services->replace_url( $val ); //phpcs:ignore
164
+ } else {
165
+ if ( Helper_Keys_Json_Weglot::translate_key_for_path( $key ) ) {
166
+ try {
167
+ $parser = $this->parser_services->get_parser();
168
+ $array[ $key ] = $parser->translate( $val, $this->original_language, $this->current_language ); //phpcs:ignore
169
+ } catch ( \Exception $e ) {
170
+ continue;
171
+ }
172
+ }
173
  }
174
  }
175
  }
src/third/ninjaforms/class-ninja-active-weglot.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\NinjaForms;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+
10
+ use WeglotWP\Models\Third_Active_Interface_Weglot;
11
+
12
+
13
+
14
+ /**
15
+ * Ninja_Active_Weglot
16
+ *
17
+ * @since 2.5.0
18
+ */
19
+ class Ninja_Active_Weglot implements Third_Active_Interface_Weglot {
20
+
21
+ /**
22
+ * Ninja forms is active ?
23
+ * @since 2.5.0
24
+ *
25
+ * @return boolean
26
+ */
27
+ public function is_active() {
28
+ if ( ! function_exists( 'is_plugin_active' ) ) {
29
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
30
+ }
31
+
32
+ $active = true;
33
+
34
+ if ( ! is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
35
+ $active = false;
36
+ }
37
+
38
+ return apply_filters( 'weglot_ninja_forms_is_active', $active );
39
+ }
40
+ }
src/third/ninjaforms/class-ninja-translate-json-weglot.php ADDED
@@ -0,0 +1,198 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\NinjaForms;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use Weglot\Client\Api\WordCollection;
10
+ use Weglot\Client\Api\WordEntry;
11
+ use Weglot\Client\Api\Enum\WordType;
12
+ use Weglot\Client\Client;
13
+ use Weglot\Client\Endpoint\Translate;
14
+ use Weglot\Client\Api\TranslateEntry;
15
+ use Weglot\Client\Api\Enum\BotType;
16
+
17
+ use WeglotWP\Helpers\Helper_Json_Inline_Weglot;
18
+
19
+
20
+
21
+ /**
22
+ * Ninja_Translate_Json_Weglot
23
+ *
24
+ * @since 2.5.0
25
+ */
26
+ class Ninja_Translate_Json_Weglot {
27
+ protected function translate_entries( $all_words ) {
28
+ // TranslateEntry
29
+ $params = [
30
+ 'language_from' => weglot_get_original_language(),
31
+ 'language_to' => weglot_get_current_language(),
32
+ 'request_url' => weglot_get_current_full_url(),
33
+ 'bot' => BotType::HUMAN,
34
+ ];
35
+
36
+ $translate = new TranslateEntry( $params );
37
+
38
+ $word_collection = $translate->getInputWords();
39
+ foreach ( $all_words as $value ) {
40
+ $value = Helper_Json_Inline_Weglot::format_for_api( $value );
41
+ $word_collection->addOne( new WordEntry( $value, WordType::TEXT ) );
42
+ }
43
+
44
+ $client = new Client( weglot_get_option( 'api_key' ) );
45
+ $translate = new Translate( $translate, $client );
46
+
47
+ return $translate->handle();
48
+ }
49
+
50
+ /**
51
+ * @since 2.5.0
52
+ *
53
+ * @param string $content
54
+ * @return array
55
+ */
56
+ protected function translate_i18n( $content ) {
57
+ if ( ! apply_filters( 'weglot_ninja_forms_translate_i18n', false ) ) {
58
+ return $content;
59
+ }
60
+
61
+ preg_match( '#nfi18n(.*?);#', $content, $match );
62
+
63
+ if ( ! isset( $match[1] ) ) {
64
+ return $content;
65
+ }
66
+
67
+ $regex = apply_filters( 'weglot_ninja_forms_translate_i18n', '#(title|changeEmailErrorMsg|changeDateErrorMsg|confirmFieldErrorMsg|fieldNumberNumMinError|fieldNumberNumMaxError|fieldNumberIncrementBy|fieldTextareaRTEInsertLink|fieldTextareaRTEInsertMedia|fieldTextareaRTESelectAFile|formErrorsCorrectErrors|validateRequiredField|honeypotHoneypotError|fileUploadOldCodeFileUploadInProgress|previousMonth|nextMonth|fieldsMarkedRequired|fileUploadOldCodeFileUpload)":"(.*?)",#' );
68
+ preg_match_all( $regex, $match[1], $all );
69
+
70
+ if ( empty( $all[2] ) ) {
71
+ return $content;
72
+ }
73
+
74
+ $object = $this->translate_entries( $all[2] );
75
+
76
+ foreach ( $object->getInputWords() as $key => $input_word ) {
77
+ $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
78
+ $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
79
+ $from_input = $input_word->getWord();
80
+ $to_output = $object->getOutputWords()[ $key ]->getWord();
81
+
82
+ if ( '' === $from_input ) {
83
+ continue;
84
+ }
85
+
86
+ if ( $from_input_encoding ) {
87
+ $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
88
+ }
89
+ if ( $to_output_encoding ) {
90
+ $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
91
+ }
92
+
93
+ $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
94
+ }
95
+
96
+ return $content;
97
+ }
98
+
99
+ /**
100
+ * @since 2.5.0
101
+ * @param string $content
102
+ * @return array
103
+ */
104
+ protected function translate_form_settings( $content ) {
105
+ $regex = apply_filters( 'weglot_ninja_forms_match_form_settings', '#form\.settings=(.*?);#' );
106
+ preg_match( $regex, $content, $match );
107
+ if ( ! isset( $match[1] ) ) {
108
+ return $content;
109
+ }
110
+
111
+ $regex = apply_filters( 'weglot_ninja_forms_translate_form_settings', '#(title|changeEmailErrorMsg|changeDateErrorMsg|confirmFieldErrorMsg|fieldNumberNumMinError|fieldNumberNumMaxError|fieldNumberIncrementBy|fieldTextareaRTEInsertLink|fieldTextareaRTEInsertMedia|fieldTextareaRTESelectAFile|formErrorsCorrectErrors|validateRequiredField|honeypotHoneypotError|fileUploadOldCodeFileUploadInProgress|previousMonth|nextMonth|fieldsMarkedRequired)":"(.*?)",#' );
112
+ preg_match_all( $regex, $match[1], $all );
113
+
114
+ if ( empty( $all[2] ) ) {
115
+ return $content;
116
+ }
117
+
118
+ $object = $this->translate_entries( $all[2] );
119
+
120
+ foreach ( $object->getInputWords() as $key => $input_word ) {
121
+ $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
122
+ $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
123
+ $from_input = $input_word->getWord();
124
+ $to_output = $object->getOutputWords()[ $key ]->getWord();
125
+ if ( '' === $from_input ) {
126
+ continue;
127
+ }
128
+
129
+ if ( $from_input_encoding ) {
130
+ $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
131
+ }
132
+ if ( $to_output_encoding ) {
133
+ $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
134
+ }
135
+
136
+ $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
137
+ }
138
+
139
+ return $content;
140
+ }
141
+
142
+
143
+ /**
144
+ * @since 2.5.0
145
+ * @param string $content
146
+ * @return array
147
+ */
148
+ protected function translate_form_fields( $content ) {
149
+ $regex = apply_filters( 'weglot_ninja_forms_match_form_fields', '#form\.fields=(.*?);#' );
150
+ preg_match( $regex, $content, $match );
151
+
152
+ if ( ! isset( $match[1] ) ) {
153
+ return $content;
154
+ }
155
+
156
+ $regex = apply_filters( 'weglot_ninja_forms_translate_form_fields', '#(label|help_text|value)":"(.*?)",#' );
157
+ preg_match_all( $regex, $match[1], $all );
158
+ if ( empty( $all[1] ) ) {
159
+ return $content;
160
+ }
161
+
162
+ $object = $this->translate_entries( $all[2] );
163
+
164
+ foreach ( $object->getInputWords() as $key => $input_word ) {
165
+ $from_input_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
166
+ $to_output_encoding = apply_filters( 'weglot_ninja_translate_need_json_encode', true );
167
+ $from_input = $input_word->getWord();
168
+ $to_output = $object->getOutputWords()[ $key ]->getWord();
169
+ if ( '' === $from_input ) {
170
+ continue;
171
+ }
172
+
173
+ if ( $from_input_encoding ) {
174
+ $from_input = Helper_Json_Inline_Weglot::need_json_encode_api( $from_input );
175
+ }
176
+ if ( $to_output_encoding ) {
177
+ $to_output = Helper_Json_Inline_Weglot::need_json_encode_api( $to_output );
178
+ }
179
+
180
+ $content = str_replace( '"' . $from_input . '"', '"' . $to_output . '"', $content );
181
+ }
182
+
183
+ return $content;
184
+ }
185
+
186
+ /**
187
+ * @since 2.5.0
188
+ * @param string $content
189
+ * @return string
190
+ */
191
+ public function translate_words( $content ) {
192
+ $content = $this->translate_form_settings( $content );
193
+ $content = $this->translate_form_fields( $content );
194
+ $content = $this->translate_i18n( $content );
195
+
196
+ return $content;
197
+ }
198
+ }
src/third/woocommerce/class-wc-cart-reload-weglot.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WeglotWP\Third\Woocommerce;
4
+
5
+ if ( ! defined( 'ABSPATH' ) ) {
6
+ exit;
7
+ }
8
+
9
+ use WeglotWP\Models\Hooks_Interface_Weglot;
10
+
11
+ /**
12
+ * WC_Cart_Reload_Weglot
13
+ *
14
+ * @since 2.4.0
15
+ */
16
+ class WC_Cart_Reload_Weglot implements Hooks_Interface_Weglot {
17
+ protected $name_transient = 'weglot_wc_clean_cart';
18
+
19
+ /**
20
+ * @since 2.4.0
21
+ * @return void
22
+ */
23
+ public function __construct() {
24
+ $this->wc_active_services = weglot_get_service( 'WC_Active_Weglot' );
25
+ }
26
+
27
+ /**
28
+ * @since 2.4.0
29
+ * @see Hooks_Interface_Weglot
30
+ * @return void
31
+ */
32
+ public function hooks() {
33
+ if ( ! $this->wc_active_services->is_active() ) {
34
+ return;
35
+ }
36
+
37
+ $active_wc_reload = weglot_get_option( 'active_wc_reload' );
38
+
39
+ if ( ! $active_wc_reload ) {
40
+ return;
41
+ }
42
+
43
+ add_action( 'wp_ajax_weglot_wc_reload_cart', [ $this, 'weglot_wc_reload_cart' ] );
44
+ add_action( 'wp_ajax_nopriv_weglot_wc_reload_cart', [ $this, 'weglot_wc_reload_cart' ] );
45
+
46
+ add_action( 'wp_enqueue_scripts', [ $this, 'weglot_wc_wp_enqueue_scripts' ] );
47
+ add_action( 'wp_footer', [ $this, 'weglot_wc_footer' ] );
48
+ }
49
+
50
+ /**
51
+ * @since 2.4.0
52
+ * @return void
53
+ */
54
+ public function weglot_wc_reload_cart() {
55
+ set_transient( $this->name_transient, 'true', 12 * HOUR_IN_SECONDS );
56
+ wp_send_json_success();
57
+ }
58
+
59
+ /**
60
+ * @since 2.4.0
61
+ * @return void
62
+ */
63
+ public function weglot_wc_wp_enqueue_scripts() {
64
+ wp_enqueue_script( 'jquery' );
65
+ }
66
+
67
+ /**
68
+ * @since 2.4.0
69
+ * @return void
70
+ */
71
+ public function weglot_wc_footer() {
72
+ $click_selector = apply_filters( 'weglot_wc_reload_selector', '.weglot-flags a' );
73
+ $ajaxurl = admin_url( 'admin-ajax.php' );
74
+ $load = apply_filters( 'weglot_load_script_reload_selector', true );
75
+ if ( ! $load ) {
76
+ return;
77
+ } ?>
78
+ <script>
79
+ document.addEventListener('DOMContentLoaded', function(){
80
+
81
+ jQuery( '<?php echo esc_attr( $click_selector ); ?>' ).on('click', function(e) {
82
+ e.preventDefault();
83
+ var href = jQuery(this).attr('href')
84
+ jQuery.ajax({
85
+ url: '<?php echo esc_url( $ajaxurl ); ?>',
86
+ data:{
87
+ action :'weglot_wc_reload_cart'
88
+ }
89
+ })
90
+
91
+ window.location.href = href
92
+
93
+ })
94
+ })
95
+ </script>
96
+ <?php
97
+ $transient = get_transient( $this->name_transient );
98
+
99
+ if ( false !== $transient ) {
100
+ delete_transient( $this->name_transient ); //phpcs:ignore ?>
101
+ <script>
102
+ document.addEventListener('DOMContentLoaded', function(){
103
+ jQuery(document.body).trigger('wc_fragment_refresh');
104
+ })
105
+ </script>
106
+ <?php
107
+ }
108
+ }
109
+ }
src/third/woocommerce/class-wc-filter-urls-weglot.php CHANGED
@@ -47,6 +47,7 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
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' ] );
 
50
  }
51
 
52
  /**
@@ -103,8 +104,8 @@ class WC_Filter_Urls_Weglot implements Hooks_Interface_Weglot {
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
  }
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' ] );
50
+ add_filter( 'woocommerce_cart_item_permalink', [ '\WeglotWP\Helpers\Helper_Filter_Url_Weglot', 'filter_url_lambda' ] );
51
  }
52
 
53
  /**
104
  $url = $this->request_url_services->create_url_object( $result['redirect'] );
105
  }
106
  }
107
+ if ( $this->replace_url_services->check_link( $result['redirect'] ) ) { // We must not add language code if external link
108
+ $result['redirect'] = $url->getForLanguage( $choose_current_language );
109
  }
110
  return $result;
111
  }
templates/admin/pages/settings.php CHANGED
@@ -28,6 +28,9 @@ use WeglotWP\Helpers\Helper_Tabs_Admin_Weglot;
28
  case Helper_Tabs_Admin_Weglot::STATUS:
29
  include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/status.php';
30
  break;
 
 
 
31
  case Helper_Tabs_Admin_Weglot::CUSTOM_URLS:
32
  include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/custom-urls.php';
33
  break;
28
  case Helper_Tabs_Admin_Weglot::STATUS:
29
  include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/status.php';
30
  break;
31
+ case Helper_Tabs_Admin_Weglot::SUPPORT:
32
+ include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/support.php';
33
+ break;
34
  case Helper_Tabs_Admin_Weglot::CUSTOM_URLS:
35
  include_once WEGLOT_TEMPLATES_ADMIN_PAGES . '/tabs/custom-urls.php';
36
  break;
templates/admin/pages/tabs/advanced.php CHANGED
@@ -34,17 +34,27 @@ $options_available = [
34
  'label' => __( 'Translate AMP', 'weglot' ),
35
  'description' => __( 'Translate AMP page', 'weglot' ),
36
  ],
 
 
 
 
 
37
  'private_mode' => [
38
  'key' => 'private_mode',
39
  'label' => __( 'Private mode', 'weglot' ),
40
- 'description' => __( 'Only admin users can be view translation', 'weglot' ),
 
 
 
 
 
41
  ],
42
  ];
43
 
44
  $languages = weglot_get_languages_configured();
45
- foreach ($languages as $key => $value) {
46
- if ($value->getIso639() === weglot_get_original_language() ) {
47
- unset( $languages[$key] );
48
  }
49
  }
50
 
@@ -172,6 +182,22 @@ foreach ($languages as $key => $value) {
172
  <p class="description"><?php echo esc_html( $options_available['translate_amp']['description'] ); ?></p>
173
  </td>
174
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
175
  <tr valign="top">
176
  <th scope="row" class="titledesc">
177
  <label for="<?php echo esc_attr( $options_available['private_mode']['key'] ); ?>">
@@ -188,6 +214,10 @@ foreach ($languages as $key => $value) {
188
  <p class="description"><?php echo esc_html( $options_available['private_mode']['description'] ); ?></p>
189
  <div id="private-mode-detail">
190
  <?php foreach ( $languages as $key => $lang):
 
 
 
 
191
  $checked_value = isset( $this->options[ $options_available['private_mode']['key'] ][ $lang->getIso639() ] ) ? $this->options[ $options_available['private_mode']['key'] ][ $lang->getIso639() ] : null;
192
  ?>
193
  <div class="private-mode-detail-lang">
@@ -201,7 +231,7 @@ foreach ($languages as $key => $value) {
201
  <label for="<?php echo esc_attr( sprintf( '%s[%s][%s]', WEGLOT_SLUG, $options_available['private_mode']['key'], $lang->getIso639() ) ); ?>">
202
  <?php
203
  // translators: 1 Local name language
204
- esc_html_e( sprintf( "Make '%s' a private langauge", $lang->getLocalName() ), 'weglot' ); ?>
205
  </label>
206
  </div>
207
  <?php endforeach; ?>
34
  'label' => __( 'Translate AMP', 'weglot' ),
35
  'description' => __( 'Translate AMP page', 'weglot' ),
36
  ],
37
+ 'active_search' => [
38
+ 'key' => 'active_search',
39
+ 'label' => __( 'Search WordPress', 'weglot' ),
40
+ 'description' => __( ' [BETA] : Allow your users to search in the language they use.', 'weglot' ),
41
+ ],
42
  'private_mode' => [
43
  'key' => 'private_mode',
44
  'label' => __( 'Private mode', 'weglot' ),
45
+ 'description' => __( 'Check if your only want admin users to see the translations', 'weglot' ),
46
+ ],
47
+ 'active_wc_reload' => [
48
+ 'key' => 'active_wc_reload',
49
+ 'label' => __( '[WooCommerce] : Prevent reload cart', 'weglot' ),
50
+ 'description' => __( 'You should only enable this option if you have translation errors on your cart widget.', 'weglot' ),
51
  ],
52
  ];
53
 
54
  $languages = weglot_get_languages_configured();
55
+ foreach ( $languages as $key => $value ) {
56
+ if ( $value && $value->getIso639() === weglot_get_original_language() ) {
57
+ unset( $languages[ $key ] );
58
  }
59
  }
60
 
182
  <p class="description"><?php echo esc_html( $options_available['translate_amp']['description'] ); ?></p>
183
  </td>
184
  </tr>
185
+ <tr valign="top">
186
+ <th scope="row" class="titledesc">
187
+ <label for="<?php echo esc_attr( $options_available['active_search']['key'] ); ?>">
188
+ <?php echo esc_html( $options_available['active_search']['label'] ); ?>
189
+ </label>
190
+ </th>
191
+ <td class="forminp forminp-text">
192
+ <input
193
+ name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['active_search']['key'] ) ); ?>"
194
+ id="<?php echo esc_attr( $options_available['active_search']['key'] ); ?>"
195
+ type="checkbox"
196
+ <?php checked( $this->options[ $options_available['active_search']['key'] ], 1 ); ?>
197
+ >
198
+ <p class="description"><?php echo esc_html( $options_available['active_search']['description'] ); ?></p>
199
+ </td>
200
+ </tr>
201
  <tr valign="top">
202
  <th scope="row" class="titledesc">
203
  <label for="<?php echo esc_attr( $options_available['private_mode']['key'] ); ?>">
214
  <p class="description"><?php echo esc_html( $options_available['private_mode']['description'] ); ?></p>
215
  <div id="private-mode-detail">
216
  <?php foreach ( $languages as $key => $lang):
217
+ if ( ! $lang ) {
218
+ continue;
219
+ }
220
+
221
  $checked_value = isset( $this->options[ $options_available['private_mode']['key'] ][ $lang->getIso639() ] ) ? $this->options[ $options_available['private_mode']['key'] ][ $lang->getIso639() ] : null;
222
  ?>
223
  <div class="private-mode-detail-lang">
231
  <label for="<?php echo esc_attr( sprintf( '%s[%s][%s]', WEGLOT_SLUG, $options_available['private_mode']['key'], $lang->getIso639() ) ); ?>">
232
  <?php
233
  // translators: 1 Local name language
234
+ esc_html_e( sprintf( "Make '%s' a private language", $lang->getLocalName() ), 'weglot' ); ?>
235
  </label>
236
  </div>
237
  <?php endforeach; ?>
templates/admin/pages/tabs/support.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ }
6
+
7
+ $options_available = [
8
+ 'active_wc_reload' => [
9
+ 'key' => 'active_wc_reload',
10
+ 'label' => __( '[WooCommerce] : Prevent reload cart', 'weglot' ),
11
+ 'description' => __( 'You should only enable this option if you have translation errors on your cart widget.', 'weglot' ),
12
+ ],
13
+ ];
14
+
15
+
16
+ ?>
17
+
18
+ <h3><?php esc_html_e( 'Options for support', 'weglot' ); ?> </h3>
19
+ <hr>
20
+
21
+ <table class="form-table">
22
+ <tbody>
23
+ <?php if ($this->wc_active_services->is_active()): ?>
24
+ <tr valign="top">
25
+ <th scope="row" class="titledesc">
26
+ <label for="<?php echo esc_attr( $options_available['active_wc_reload']['key'] ); ?>">
27
+ <?php echo esc_html( $options_available['active_wc_reload']['label'] ); ?>
28
+ </label>
29
+ </th>
30
+ <td class="forminp forminp-text">
31
+ <input
32
+ name="<?php echo esc_attr( sprintf( '%s[%s]', WEGLOT_SLUG, $options_available['active_wc_reload']['key'] ) ); ?>"
33
+ id="<?php echo esc_attr( $options_available['active_wc_reload']['key'] ); ?>"
34
+ type="checkbox"
35
+ <?php checked( $this->options[ $options_available['active_wc_reload']['key'] ], 1 ); ?>
36
+ >
37
+ <p class="description"><?php echo esc_html( $options_available['active_wc_reload']['description'] ); ?></p>
38
+ </td>
39
+ </tr>
40
+ <?php endif; ?>
41
+ </tbody>
42
+ </table>
vendor/autoload.php CHANGED
@@ -4,4 +4,4 @@
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
- return ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc::getLoader();
4
 
5
  require_once __DIR__ . '/composer/autoload_real.php';
6
 
7
+ return ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79::getLoader();
vendor/composer/autoload_namespaces.php CHANGED
@@ -6,5 +6,5 @@ $vendorDir = dirname(dirname(__FILE__));
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
- 'SimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
10
  );
6
  $baseDir = dirname($vendorDir);
7
 
8
  return array(
9
+ 'WGSimpleHtmlDom' => array($vendorDir . '/weglot/simplehtmldom/src'),
10
  );
vendor/composer/autoload_real.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
- class ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc
6
  {
7
  private static $loader;
8
 
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc
19
  return self::$loader;
20
  }
21
 
22
- spl_autoload_register(array('ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
- spl_autoload_unregister(array('ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc', '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\ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc::getInitializer($loader));
31
  } else {
32
  $map = require __DIR__ . '/autoload_namespaces.php';
33
  foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInit083a0087f89e1a005689d29cd9f22dcc
48
  $loader->register(true);
49
 
50
  if ($useStaticLoader) {
51
- $includeFiles = Composer\Autoload\ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
- composerRequire083a0087f89e1a005689d29cd9f22dcc($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
- function composerRequire083a0087f89e1a005689d29cd9f22dcc($fileIdentifier, $file)
64
  {
65
  if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
  require $file;
2
 
3
  // autoload_real.php @generated by Composer
4
 
5
+ class ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79
6
  {
7
  private static $loader;
8
 
19
  return self::$loader;
20
  }
21
 
22
+ spl_autoload_register(array('ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79', 'loadClassLoader'), true, true);
23
  self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit2f68d23dd97857b5db6a3ca15c219d79', '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\ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79::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\ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79::$files;
52
  } else {
53
  $includeFiles = require __DIR__ . '/autoload_files.php';
54
  }
55
  foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire2f68d23dd97857b5db6a3ca15c219d79($fileIdentifier, $file);
57
  }
58
 
59
  return $loader;
60
  }
61
  }
62
 
63
+ function composerRequire2f68d23dd97857b5db6a3ca15c219d79($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 ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
@@ -33,9 +33,9 @@ class ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc
33
  );
34
 
35
  public static $prefixesPsr0 = array (
36
- 'S' =>
37
  array (
38
- 'SimpleHtmlDom' =>
39
  array (
40
  0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
41
  ),
@@ -45,9 +45,9 @@ class ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
- $loader->prefixLengthsPsr4 = ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc::$prefixLengthsPsr4;
49
- $loader->prefixDirsPsr4 = ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc::$prefixDirsPsr4;
50
- $loader->prefixesPsr0 = ComposerStaticInit083a0087f89e1a005689d29cd9f22dcc::$prefixesPsr0;
51
 
52
  }, null, ClassLoader::class);
53
  }
4
 
5
  namespace Composer\Autoload;
6
 
7
+ class ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79
8
  {
9
  public static $files = array (
10
  '6c200413eed8aeea54dbaf934a31b127' => __DIR__ . '/..' . '/weglot/simplehtmldom/src/simple_html_dom.php',
33
  );
34
 
35
  public static $prefixesPsr0 = array (
36
+ 'W' =>
37
  array (
38
+ 'WGSimpleHtmlDom' =>
39
  array (
40
  0 => __DIR__ . '/..' . '/weglot/simplehtmldom/src',
41
  ),
45
  public static function getInitializer(ClassLoader $loader)
46
  {
47
  return \Closure::bind(function () use ($loader) {
48
+ $loader->prefixLengthsPsr4 = ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79::$prefixLengthsPsr4;
49
+ $loader->prefixDirsPsr4 = ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79::$prefixDirsPsr4;
50
+ $loader->prefixesPsr0 = ComposerStaticInit2f68d23dd97857b5db6a3ca15c219d79::$prefixesPsr0;
51
 
52
  }, null, ClassLoader::class);
53
  }
vendor/composer/installed.json CHANGED
@@ -49,28 +49,28 @@
49
  },
50
  {
51
  "name": "weglot/simplehtmldom",
52
- "version": "0.3",
53
- "version_normalized": "0.3.0.0",
54
  "source": {
55
  "type": "git",
56
  "url": "https://github.com/weglot/simple_html_dom.git",
57
- "reference": "e760e7f2dd3c1f0ec9df8e16b900a0fe920bf9fe"
58
  },
59
  "dist": {
60
  "type": "zip",
61
- "url": "https://api.github.com/repos/weglot/simple_html_dom/zipball/e760e7f2dd3c1f0ec9df8e16b900a0fe920bf9fe",
62
- "reference": "e760e7f2dd3c1f0ec9df8e16b900a0fe920bf9fe",
63
  "shasum": ""
64
  },
65
  "require": {
66
  "php": ">=5.3.0"
67
  },
68
- "time": "2018-07-23T15:42:35+00:00",
69
  "type": "library",
70
  "installation-source": "dist",
71
  "autoload": {
72
  "psr-0": {
73
- "SimpleHtmlDom": "src/"
74
  },
75
  "files": [
76
  "src/simple_html_dom.php"
@@ -96,29 +96,29 @@
96
  },
97
  {
98
  "name": "weglot/weglot-php",
99
- "version": "0.5.15",
100
- "version_normalized": "0.5.15.0",
101
  "source": {
102
  "type": "git",
103
  "url": "https://github.com/weglot/weglot-php.git",
104
- "reference": "291cd6cba7290df7e6e92cd429c7b00bfcc7136d"
105
  },
106
  "dist": {
107
  "type": "zip",
108
- "url": "https://api.github.com/repos/weglot/weglot-php/zipball/291cd6cba7290df7e6e92cd429c7b00bfcc7136d",
109
- "reference": "291cd6cba7290df7e6e92cd429c7b00bfcc7136d",
110
  "shasum": ""
111
  },
112
  "require": {
113
  "php": ">=5.4",
114
  "psr/cache": "^1.0",
115
- "weglot/simplehtmldom": "^0.3"
116
  },
117
  "require-dev": {
118
  "codeception/codeception": "^2.4",
119
  "vlucas/phpdotenv": "^2.4"
120
  },
121
- "time": "2018-12-03T16:31:42+00:00",
122
  "type": "library",
123
  "installation-source": "dist",
124
  "autoload": {
49
  },
50
  {
51
  "name": "weglot/simplehtmldom",
52
+ "version": "0.5",
53
+ "version_normalized": "0.5.0.0",
54
  "source": {
55
  "type": "git",
56
  "url": "https://github.com/weglot/simple_html_dom.git",
57
+ "reference": "ae2c353a18aa421703824838e5d921b3de5388fd"
58
  },
59
  "dist": {
60
  "type": "zip",
61
+ "url": "https://api.github.com/repos/weglot/simple_html_dom/zipball/ae2c353a18aa421703824838e5d921b3de5388fd",
62
+ "reference": "ae2c353a18aa421703824838e5d921b3de5388fd",
63
  "shasum": ""
64
  },
65
  "require": {
66
  "php": ">=5.3.0"
67
  },
68
+ "time": "2019-01-03T10:18:36+00:00",
69
  "type": "library",
70
  "installation-source": "dist",
71
  "autoload": {
72
  "psr-0": {
73
+ "WGSimpleHtmlDom": "src/"
74
  },
75
  "files": [
76
  "src/simple_html_dom.php"
96
  },
97
  {
98
  "name": "weglot/weglot-php",
99
+ "version": "0.5.20",
100
+ "version_normalized": "0.5.20.0",
101
  "source": {
102
  "type": "git",
103
  "url": "https://github.com/weglot/weglot-php.git",
104
+ "reference": "6728f001f1bc393d95b1042e75af7fb0ff7434c1"
105
  },
106
  "dist": {
107
  "type": "zip",
108
+ "url": "https://api.github.com/repos/weglot/weglot-php/zipball/6728f001f1bc393d95b1042e75af7fb0ff7434c1",
109
+ "reference": "6728f001f1bc393d95b1042e75af7fb0ff7434c1",
110
  "shasum": ""
111
  },
112
  "require": {
113
  "php": ">=5.4",
114
  "psr/cache": "^1.0",
115
+ "weglot/simplehtmldom": "^0.5"
116
  },
117
  "require-dev": {
118
  "codeception/codeception": "^2.4",
119
  "vlucas/phpdotenv": "^2.4"
120
  },
121
+ "time": "2019-01-16T13:05:58+00:00",
122
  "type": "library",
123
  "installation-source": "dist",
124
  "autoload": {
vendor/weglot/simplehtmldom/README.md CHANGED
@@ -10,6 +10,14 @@ Simple fork of [simple_html_dom](http://simplehtmldom.sourceforge.net/) PHP libr
10
 
11
  ## Changelog
12
 
 
 
 
 
 
 
 
 
13
  ## [0.3] - 2018-07-23
14
  ### Added
15
  - redo modifications previsouly done like max size for exemple
10
 
11
  ## Changelog
12
 
13
+ ## [0.5] - 2019-01-03
14
+ ### Changed
15
+ - Update compatibility PHP 7.3
16
+
17
+ ## [0.4] - 2018-10-05
18
+ ### Changed
19
+ - Change namespace for resolve conflict with other library Simple HTML DOM
20
+
21
  ## [0.3] - 2018-07-23
22
  ### Added
23
  - redo modifications previsouly done like max size for exemple
vendor/weglot/simplehtmldom/composer.json CHANGED
@@ -16,7 +16,7 @@
16
  },
17
  "autoload": {
18
  "psr-0": {
19
- "SimpleHtmlDom": "src/"
20
  },
21
  "files": [
22
  "src/simple_html_dom.php"
16
  },
17
  "autoload": {
18
  "psr-0": {
19
+ "WGSimpleHtmlDom": "src/"
20
  },
21
  "files": [
22
  "src/simple_html_dom.php"
vendor/weglot/simplehtmldom/src/simple_html_dom.php CHANGED
@@ -1,6 +1,6 @@
1
  <?php
2
 
3
- namespace SimpleHtmlDom;
4
 
5
  /**
6
  * Website: http://sourceforge.net/projects/simplehtmldom/
@@ -45,32 +45,32 @@ namespace SimpleHtmlDom;
45
  * All of the Defines for the classes below.
46
  * @author S.C. Chen <me578022@gmail.com>
47
  */
48
- define('HDOM_TYPE_ELEMENT', 1);
49
- define('HDOM_TYPE_COMMENT', 2);
50
- define('HDOM_TYPE_TEXT', 3);
51
- define('HDOM_TYPE_ENDTAG', 4);
52
- define('HDOM_TYPE_ROOT', 5);
53
- define('HDOM_TYPE_UNKNOWN', 6);
54
- define('HDOM_QUOTE_DOUBLE', 0);
55
- define('HDOM_QUOTE_SINGLE', 1);
56
- define('HDOM_QUOTE_NO', 3);
57
- define('HDOM_INFO_BEGIN', 0);
58
- define('HDOM_INFO_END', 1);
59
- define('HDOM_INFO_QUOTE', 2);
60
- define('HDOM_INFO_SPACE', 3);
61
- define('HDOM_INFO_TEXT', 4);
62
- define('HDOM_INFO_INNER', 5);
63
- define('HDOM_INFO_OUTER', 6);
64
- define('HDOM_INFO_ENDSPACE', 7);
65
- define('DEFAULT_TARGET_CHARSET', 'UTF-8');
66
- define('DEFAULT_BR_TEXT', "\r\n");
67
- define('DEFAULT_SPAN_TEXT', " ");
68
- define('MAX_FILE_SIZE', 100000000);
69
  // helper functions
70
  // -----------------------------------------------------------------------------
71
  // get html dom from file
72
  // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
73
- function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
74
  {
75
  // We DO force the tags to be terminated.
76
  $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
@@ -78,7 +78,7 @@ function file_get_html($url, $use_include_path = false, $context=null, $offset =
78
  $contents = file_get_contents($url, $use_include_path, $context, $offset);
79
  // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
80
  //$contents = retrieve_url_contents($url);
81
- if (empty($contents) || strlen($contents) > MAX_FILE_SIZE) {
82
  return false;
83
  }
84
  // The second parameter can force the selectors to all be lowercase.
@@ -87,10 +87,10 @@ function file_get_html($url, $use_include_path = false, $context=null, $offset =
87
  }
88
 
89
  // get html dom from string
90
- function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
91
  {
92
  $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
93
- if (empty($str) || strlen($str) > MAX_FILE_SIZE) {
94
  $dom->clear();
95
  return false;
96
  }
@@ -114,7 +114,7 @@ function dump_html_tree($node, $show_attr=true, $deep=0)
114
  */
115
  class simple_html_dom_node
116
  {
117
- public $nodetype = HDOM_TYPE_TEXT;
118
  public $tag = 'text';
119
  public $attr = array();
120
  public $children = array();
@@ -205,8 +205,8 @@ class simple_html_dom_node
205
  }
206
 
207
  $string .= " HDOM_INNER_INFO: '";
208
- if (isset($node->_[HDOM_INFO_INNER])) {
209
- $string .= $node->_[HDOM_INFO_INNER] . "'";
210
  } else {
211
  $string .= ' NULL ';
212
  }
@@ -337,11 +337,11 @@ class simple_html_dom_node
337
  // get dom node's inner html
338
  public function innertext()
339
  {
340
- if (isset($this->_[HDOM_INFO_INNER])) {
341
- return $this->_[HDOM_INFO_INNER];
342
  }
343
- if (isset($this->_[HDOM_INFO_TEXT])) {
344
- return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
345
  }
346
 
347
  $ret = '';
@@ -374,25 +374,25 @@ class simple_html_dom_node
374
  call_user_func_array($this->dom->callback, array($this));
375
  }
376
 
377
- if (isset($this->_[HDOM_INFO_OUTER])) {
378
- return $this->_[HDOM_INFO_OUTER];
379
  }
380
- if (isset($this->_[HDOM_INFO_TEXT])) {
381
- return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
382
  }
383
 
384
  // render begin tag
385
- if ($this->dom && $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]) {
386
- $ret = $this->dom->nodes[$this->_[HDOM_INFO_BEGIN]]->makeup();
387
  } else {
388
  $ret = "";
389
  }
390
 
391
  // render inner text
392
- if (isset($this->_[HDOM_INFO_INNER])) {
393
  // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
394
  if ($this->tag != "br") {
395
- $ret .= $this->_[HDOM_INFO_INNER];
396
  }
397
  } else {
398
  if ($this->nodes) {
@@ -403,7 +403,7 @@ class simple_html_dom_node
403
  }
404
 
405
  // render end tag
406
- if (isset($this->_[HDOM_INFO_END]) && $this->_[HDOM_INFO_END]!=0) {
407
  $ret .= '</'.$this->tag.'>';
408
  }
409
  return $ret;
@@ -412,13 +412,13 @@ class simple_html_dom_node
412
  // get dom node's plain text
413
  public function text()
414
  {
415
- if (isset($this->_[HDOM_INFO_INNER])) {
416
- return $this->_[HDOM_INFO_INNER];
417
  }
418
  switch ($this->nodetype) {
419
- case HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
420
- case HDOM_TYPE_COMMENT: return '';
421
- case HDOM_TYPE_UNKNOWN: return '';
422
  }
423
  if (strcasecmp($this->tag, 'script')===0) {
424
  return '';
@@ -428,7 +428,7 @@ class simple_html_dom_node
428
  }
429
 
430
  $ret = '';
431
- // In rare cases, (always node type 1 or HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
432
  // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
433
  // WHY is this happening?
434
  if (!is_null($this->nodes)) {
@@ -438,7 +438,7 @@ class simple_html_dom_node
438
 
439
  // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
440
  if ($this->tag == "span") {
441
- $ret .= $this->dom->DEFAULT_SPAN_TEXT;
442
  }
443
  }
444
  return $ret;
@@ -456,8 +456,8 @@ class simple_html_dom_node
456
  public function makeup()
457
  {
458
  // text, comment, unknown
459
- if (isset($this->_[HDOM_INFO_TEXT])) {
460
- return $this->dom->restore_noise($this->_[HDOM_INFO_TEXT]);
461
  }
462
 
463
  $ret = '<'.$this->tag;
@@ -471,21 +471,21 @@ class simple_html_dom_node
471
  continue;
472
  }
473
 
474
- $ret .= $this->_[HDOM_INFO_SPACE][$i][0];
475
  //no value attr: nowrap, checked selected...
476
  if ($val===true) {
477
  $ret .= $key;
478
  } else {
479
- switch ($this->_[HDOM_INFO_QUOTE][$i]) {
480
- case HDOM_QUOTE_DOUBLE: $quote = '"'; break;
481
- case HDOM_QUOTE_SINGLE: $quote = '\''; break;
482
  default: $quote = '';
483
  }
484
- $ret .= $key.$this->_[HDOM_INFO_SPACE][$i][1].'='.$this->_[HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
485
  }
486
  }
487
  $ret = $this->dom->restore_noise($ret);
488
- return $ret . $this->_[HDOM_INFO_ENDSPACE] . '>';
489
  }
490
 
491
  // find elements by css selector
@@ -505,11 +505,11 @@ class simple_html_dom_node
505
  if (($levle=count($selectors[$c]))===0) {
506
  return array();
507
  }
508
- if (!isset($this->_[HDOM_INFO_BEGIN])) {
509
  return array();
510
  }
511
 
512
- $head = array($this->_[HDOM_INFO_BEGIN]=>1);
513
 
514
  // handle descendant selectors, no recursive!
515
  for ($l=0; $l<$levle; ++$l) {
@@ -563,7 +563,7 @@ class simple_html_dom_node
563
  foreach ($this->children as $c) {
564
  if ($tag==='*' || $tag===$c->tag) {
565
  if (++$count==$key) {
566
- $ret[$c->_[HDOM_INFO_BEGIN]] = 1;
567
  return;
568
  }
569
  }
@@ -571,17 +571,17 @@ class simple_html_dom_node
571
  return;
572
  }
573
 
574
- $end = (!empty($this->_[HDOM_INFO_END])) ? $this->_[HDOM_INFO_END] : 0;
575
  if ($end==0) {
576
  $parent = $this->parent;
577
- while (!isset($parent->_[HDOM_INFO_END]) && $parent!==null) {
578
  $end -= 1;
579
  $parent = $parent->parent;
580
  }
581
- $end += $parent->_[HDOM_INFO_END];
582
  }
583
 
584
- for ($i=$this->_[HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
585
  $node = $this->dom->nodes[$i];
586
 
587
  $pass = true;
@@ -702,8 +702,8 @@ class simple_html_dom_node
702
  // Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
703
  // This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
704
  // farther study is required to determine of this should be documented or removed.
705
- // $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
706
- $pattern = "/([\w-:\*]*)(?:\#([\w-]+)|\.([\w-]+))?(?:\[@?(!?[\w-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
707
  preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
708
  if (is_object($debugObject)) {
709
  $debugObject->debugLog(2, "Matches Array: ", $matches);
@@ -782,16 +782,16 @@ class simple_html_dom_node
782
  public function __set($name, $value)
783
  {
784
  switch ($name) {
785
- case 'outertext': return $this->_[HDOM_INFO_OUTER] = $value;
786
  case 'innertext':
787
- if (isset($this->_[HDOM_INFO_TEXT])) {
788
- return $this->_[HDOM_INFO_TEXT] = $value;
789
  }
790
- return $this->_[HDOM_INFO_INNER] = $value;
791
  }
792
  if (!isset($this->attr[$name])) {
793
- $this->_[HDOM_INFO_SPACE][] = array(' ', '', '');
794
- $this->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
795
  }
796
  $this->attr[$name] = $value;
797
  }
@@ -942,7 +942,7 @@ class simple_html_dom_node
942
  if (isset($this->attr['style'])) {
943
  // Thanks to user gnarf from stackoverflow for this regular expression.
944
  $attributes = array();
945
- preg_match_all("/([\w-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
946
  foreach ($matches as $match) {
947
  $attributes[$match[1]] = $match[2];
948
  }
@@ -1110,8 +1110,8 @@ class simple_html_dom
1110
  // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
1111
  public $_charset = '';
1112
  public $_target_charset = '';
1113
- protected $DEFAULT_BR_TEXT = "";
1114
- public $DEFAULT_SPAN_TEXT = "";
1115
 
1116
  // use isset instead of in_array, performance boost about 30%...
1117
  protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
@@ -1133,7 +1133,7 @@ class simple_html_dom
1133
  'source'=>array('source'=>1)
1134
  );
1135
 
1136
- public function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1137
  {
1138
  if ($str) {
1139
  if (preg_match("/^http:\/\//i", $str) || is_file($str)) {
@@ -1155,7 +1155,7 @@ class simple_html_dom
1155
  }
1156
 
1157
  // load html from string
1158
- public function load($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1159
  {
1160
  global $debugObject;
1161
 
@@ -1184,7 +1184,7 @@ class simple_html_dom
1184
  // parsing
1185
  while ($this->parse());
1186
  // end
1187
- $this->root->_[HDOM_INFO_END] = $this->cursor;
1188
  $this->parse_charset();
1189
 
1190
  // make load function chainable
@@ -1264,7 +1264,7 @@ class simple_html_dom
1264
  }
1265
 
1266
  // prepare HTML data and init everything
1267
- protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=DEFAULT_BR_TEXT, $defaultSpanText=DEFAULT_SPAN_TEXT)
1268
  {
1269
  $this->clear();
1270
 
@@ -1288,12 +1288,12 @@ class simple_html_dom
1288
  $this->noise = array();
1289
  $this->nodes = array();
1290
  $this->lowercase = $lowercase;
1291
- $this->DEFAULT_BR_TEXT = $defaultBRText;
1292
- $this->DEFAULT_SPAN_TEXT = $defaultSpanText;
1293
  $this->root = new simple_html_dom_node($this);
1294
  $this->root->tag = 'root';
1295
- $this->root->_[HDOM_INFO_BEGIN] = -1;
1296
- $this->root->nodetype = HDOM_TYPE_ROOT;
1297
  $this->parent = $this->root;
1298
  if ($this->size>0) {
1299
  $this->char = $this->doc[0];
@@ -1310,7 +1310,7 @@ class simple_html_dom
1310
  // text
1311
  $node = new simple_html_dom_node($this);
1312
  ++$this->cursor;
1313
- $node->_[HDOM_INFO_TEXT] = $s;
1314
  $this->link_nodes($node, false);
1315
  return true;
1316
  }
@@ -1396,7 +1396,7 @@ class simple_html_dom
1396
  protected function read_tag()
1397
  {
1398
  if ($this->char!=='<') {
1399
- $this->root->_[HDOM_INFO_END] = $this->cursor;
1400
  return false;
1401
  }
1402
  $begin_tag_pos = $this->pos;
@@ -1420,7 +1420,7 @@ class simple_html_dom
1420
 
1421
  if ($parent_lower!==$tag_lower) {
1422
  if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) {
1423
- $this->parent->_[HDOM_INFO_END] = 0;
1424
  $org_parent = $this->parent;
1425
 
1426
  while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
@@ -1432,11 +1432,11 @@ class simple_html_dom
1432
  if ($this->parent->parent) {
1433
  $this->parent = $this->parent->parent;
1434
  }
1435
- $this->parent->_[HDOM_INFO_END] = $this->cursor;
1436
  return $this->as_text_node($tag);
1437
  }
1438
  } elseif (($this->parent->parent) && isset($this->block_tags[$tag_lower])) {
1439
- $this->parent->_[HDOM_INFO_END] = 0;
1440
  $org_parent = $this->parent;
1441
 
1442
  while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
@@ -1445,18 +1445,18 @@ class simple_html_dom
1445
 
1446
  if (strtolower($this->parent->tag)!==$tag_lower) {
1447
  $this->parent = $org_parent; // restore origonal parent
1448
- $this->parent->_[HDOM_INFO_END] = $this->cursor;
1449
  return $this->as_text_node($tag);
1450
  }
1451
  } elseif (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) {
1452
- $this->parent->_[HDOM_INFO_END] = 0;
1453
  $this->parent = $this->parent->parent;
1454
  } else {
1455
  return $this->as_text_node($tag);
1456
  }
1457
  }
1458
 
1459
- $this->parent->_[HDOM_INFO_END] = $this->cursor;
1460
  if ($this->parent->parent) {
1461
  $this->parent = $this->parent->parent;
1462
  }
@@ -1466,24 +1466,24 @@ class simple_html_dom
1466
  }
1467
 
1468
  $node = new simple_html_dom_node($this);
1469
- $node->_[HDOM_INFO_BEGIN] = $this->cursor;
1470
  ++$this->cursor;
1471
  $tag = $this->copy_until($this->token_slash);
1472
  $node->tag_start = $begin_tag_pos;
1473
 
1474
  // doctype, cdata & comments...
1475
  if (isset($tag[0]) && $tag[0]==='!') {
1476
- $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1477
 
1478
  if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
1479
- $node->nodetype = HDOM_TYPE_COMMENT;
1480
  $node->tag = 'comment';
1481
  } else {
1482
- $node->nodetype = HDOM_TYPE_UNKNOWN;
1483
  $node->tag = 'unknown';
1484
  }
1485
  if ($this->char==='>') {
1486
- $node->_[HDOM_INFO_TEXT].='>';
1487
  }
1488
  $this->link_nodes($node, true);
1489
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
@@ -1493,21 +1493,21 @@ class simple_html_dom
1493
  // text
1494
  if ($pos=strpos($tag, '<')!==false) {
1495
  $tag = '<' . substr($tag, 0, -1);
1496
- $node->_[HDOM_INFO_TEXT] = $tag;
1497
  $this->link_nodes($node, false);
1498
  $this->char = $this->doc[--$this->pos]; // prev
1499
  return true;
1500
  }
1501
 
1502
- if (!preg_match("/^[\w-:]+$/", $tag)) {
1503
- $node->_[HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1504
  if ($this->char==='<') {
1505
  $this->link_nodes($node, false);
1506
  return true;
1507
  }
1508
 
1509
  if ($this->char==='>') {
1510
- $node->_[HDOM_INFO_TEXT].='>';
1511
  }
1512
  $this->link_nodes($node, false);
1513
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
@@ -1515,14 +1515,14 @@ class simple_html_dom
1515
  }
1516
 
1517
  // begin tag
1518
- $node->nodetype = HDOM_TYPE_ELEMENT;
1519
  $tag_lower = strtolower($tag);
1520
  $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1521
 
1522
  // handle optional closing tags
1523
  if (isset($this->optional_closing_tags[$tag_lower])) {
1524
  while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
1525
- $this->parent->_[HDOM_INFO_END] = 0;
1526
  $this->parent = $this->parent->parent;
1527
  }
1528
  $node->parent = $this->parent;
@@ -1545,9 +1545,9 @@ class simple_html_dom
1545
 
1546
  // handle endless '<'
1547
  if ($this->pos>=$this->size-1 && $this->char!=='>') {
1548
- $node->nodetype = HDOM_TYPE_TEXT;
1549
- $node->_[HDOM_INFO_END] = 0;
1550
- $node->_[HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1551
  $node->tag = 'text';
1552
  $this->link_nodes($node, false);
1553
  return true;
@@ -1555,11 +1555,11 @@ class simple_html_dom
1555
 
1556
  // handle mismatch '<'
1557
  if ($this->doc[$this->pos-1]=='<') {
1558
- $node->nodetype = HDOM_TYPE_TEXT;
1559
  $node->tag = 'text';
1560
  $node->attr = array();
1561
- $node->_[HDOM_INFO_END] = 0;
1562
- $node->_[HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
1563
  $this->pos -= 2;
1564
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1565
  $this->link_nodes($node, false);
@@ -1577,13 +1577,13 @@ class simple_html_dom
1577
  $this->parse_attr($node, $name, $space);
1578
  } else {
1579
  //no value attr: nowrap, checked selected...
1580
- $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1581
  $node->attr[$name] = true;
1582
  if ($this->char!='>') {
1583
  $this->char = $this->doc[--$this->pos];
1584
  } // prev
1585
  }
1586
- $node->_[HDOM_INFO_SPACE][] = $space;
1587
  $space = array($this->copy_skip($this->token_blank), '', '');
1588
  } else {
1589
  break;
@@ -1591,12 +1591,12 @@ class simple_html_dom
1591
  } while ($this->char!=='>' && $this->char!=='/');
1592
 
1593
  $this->link_nodes($node, true);
1594
- $node->_[HDOM_INFO_ENDSPACE] = $space[0];
1595
 
1596
  // check self closing
1597
  if ($this->copy_until_char_escape('>')==='/') {
1598
- $node->_[HDOM_INFO_ENDSPACE] .= '/';
1599
- $node->_[HDOM_INFO_END] = 0;
1600
  } else {
1601
  // reset parent
1602
  if (!isset($this->self_closing_tags[strtolower($node->tag)])) {
@@ -1609,7 +1609,7 @@ class simple_html_dom
1609
  // This way when we see it in plaintext, we can generate formatting that the user wants.
1610
  // since a br tag never has sub nodes, this works well.
1611
  if ($node->tag == "br") {
1612
- $node->_[HDOM_INFO_INNER] = $this->DEFAULT_BR_TEXT;
1613
  }
1614
 
1615
  return true;
@@ -1627,19 +1627,19 @@ class simple_html_dom
1627
  $space[2] = $this->copy_skip($this->token_blank);
1628
  switch ($this->char) {
1629
  case '"':
1630
- $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_DOUBLE;
1631
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1632
  $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
1633
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1634
  break;
1635
  case '\'':
1636
- $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_SINGLE;
1637
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1638
  $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
1639
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1640
  break;
1641
  default:
1642
- $node->_[HDOM_INFO_QUOTE][] = HDOM_QUOTE_NO;
1643
  $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
1644
  }
1645
  // PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
@@ -1666,7 +1666,7 @@ class simple_html_dom
1666
  {
1667
  $node = new simple_html_dom_node($this);
1668
  ++$this->cursor;
1669
- $node->_[HDOM_INFO_TEXT] = '</' . $tag . '>';
1670
  $this->link_nodes($node, false);
1671
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1672
  return true;
1
  <?php
2
 
3
+ namespace WGSimpleHtmlDom;
4
 
5
  /**
6
  * Website: http://sourceforge.net/projects/simplehtmldom/
45
  * All of the Defines for the classes below.
46
  * @author S.C. Chen <me578022@gmail.com>
47
  */
48
+ define('WG_HDOM_TYPE_ELEMENT', 1);
49
+ define('WG_HDOM_TYPE_COMMENT', 2);
50
+ define('WG_HDOM_TYPE_TEXT', 3);
51
+ define('WG_HDOM_TYPE_ENDTAG', 4);
52
+ define('WG_HDOM_TYPE_ROOT', 5);
53
+ define('WG_HDOM_TYPE_UNKNOWN', 6);
54
+ define('WG_HDOM_QUOTE_DOUBLE', 0);
55
+ define('WG_HDOM_QUOTE_SINGLE', 1);
56
+ define('WG_HDOM_QUOTE_NO', 3);
57
+ define('WG_HDOM_INFO_BEGIN', 0);
58
+ define('WG_HDOM_INFO_END', 1);
59
+ define('WG_HDOM_INFO_QUOTE', 2);
60
+ define('WG_HDOM_INFO_SPACE', 3);
61
+ define('WG_HDOM_INFO_TEXT', 4);
62
+ define('WG_HDOM_INFO_INNER', 5);
63
+ define('WG_HDOM_INFO_OUTER', 6);
64
+ define('WG_HDOM_INFO_ENDSPACE', 7);
65
+ define('WG_DEFAULT_TARGET_CHARSET', 'UTF-8');
66
+ define('WG_DEFAULT_BR_TEXT', "\r\n");
67
+ define('WG_DEFAULT_SPAN_TEXT', " ");
68
+ define('WG_MAX_FILE_SIZE', 100000000);
69
  // helper functions
70
  // -----------------------------------------------------------------------------
71
  // get html dom from file
72
  // $maxlen is defined in the code as PHP_STREAM_COPY_ALL which is defined as -1.
73
+ function file_get_html($url, $use_include_path = false, $context=null, $offset = -1, $maxLen=-1, $lowercase = true, $forceTagsClosed=true, $target_charset = WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
74
  {
75
  // We DO force the tags to be terminated.
76
  $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
78
  $contents = file_get_contents($url, $use_include_path, $context, $offset);
79
  // Paperg - use our own mechanism for getting the contents as we want to control the timeout.
80
  //$contents = retrieve_url_contents($url);
81
+ if (empty($contents) || strlen($contents) > WG_MAX_FILE_SIZE) {
82
  return false;
83
  }
84
  // The second parameter can force the selectors to all be lowercase.
87
  }
88
 
89
  // get html dom from string
90
+ function str_get_html($str, $lowercase=true, $forceTagsClosed=true, $target_charset = WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
91
  {
92
  $dom = new simple_html_dom(null, $lowercase, $forceTagsClosed, $target_charset, $stripRN, $defaultBRText, $defaultSpanText);
93
+ if (empty($str) || strlen($str) > WG_MAX_FILE_SIZE) {
94
  $dom->clear();
95
  return false;
96
  }
114
  */
115
  class simple_html_dom_node
116
  {
117
+ public $nodetype = WG_HDOM_TYPE_TEXT;
118
  public $tag = 'text';
119
  public $attr = array();
120
  public $children = array();
205
  }
206
 
207
  $string .= " HDOM_INNER_INFO: '";
208
+ if (isset($node->_[WG_HDOM_INFO_INNER])) {
209
+ $string .= $node->_[WG_HDOM_INFO_INNER] . "'";
210
  } else {
211
  $string .= ' NULL ';
212
  }
337
  // get dom node's inner html
338
  public function innertext()
339
  {
340
+ if (isset($this->_[WG_HDOM_INFO_INNER])) {
341
+ return $this->_[WG_HDOM_INFO_INNER];
342
  }
343
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) {
344
+ return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
345
  }
346
 
347
  $ret = '';
374
  call_user_func_array($this->dom->callback, array($this));
375
  }
376
 
377
+ if (isset($this->_[WG_HDOM_INFO_OUTER])) {
378
+ return $this->_[WG_HDOM_INFO_OUTER];
379
  }
380
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) {
381
+ return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
382
  }
383
 
384
  // render begin tag
385
+ if ($this->dom && $this->dom->nodes[$this->_[WG_HDOM_INFO_BEGIN]]) {
386
+ $ret = $this->dom->nodes[$this->_[WG_HDOM_INFO_BEGIN]]->makeup();
387
  } else {
388
  $ret = "";
389
  }
390
 
391
  // render inner text
392
+ if (isset($this->_[WG_HDOM_INFO_INNER])) {
393
  // If it's a br tag... don't return the HDOM_INNER_INFO that we may or may not have added.
394
  if ($this->tag != "br") {
395
+ $ret .= $this->_[WG_HDOM_INFO_INNER];
396
  }
397
  } else {
398
  if ($this->nodes) {
403
  }
404
 
405
  // render end tag
406
+ if (isset($this->_[WG_HDOM_INFO_END]) && $this->_[WG_HDOM_INFO_END]!=0) {
407
  $ret .= '</'.$this->tag.'>';
408
  }
409
  return $ret;
412
  // get dom node's plain text
413
  public function text()
414
  {
415
+ if (isset($this->_[WG_HDOM_INFO_INNER])) {
416
+ return $this->_[WG_HDOM_INFO_INNER];
417
  }
418
  switch ($this->nodetype) {
419
+ case WG_HDOM_TYPE_TEXT: return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
420
+ case WG_HDOM_TYPE_COMMENT: return '';
421
+ case WG_HDOM_TYPE_UNKNOWN: return '';
422
  }
423
  if (strcasecmp($this->tag, 'script')===0) {
424
  return '';
428
  }
429
 
430
  $ret = '';
431
+ // In rare cases, (always node type 1 or WG_HDOM_TYPE_ELEMENT - observed for some span tags, and some p tags) $this->nodes is set to NULL.
432
  // NOTE: This indicates that there is a problem where it's set to NULL without a clear happening.
433
  // WHY is this happening?
434
  if (!is_null($this->nodes)) {
438
 
439
  // If this node is a span... add a space at the end of it so multiple spans don't run into each other. This is plaintext after all.
440
  if ($this->tag == "span") {
441
+ $ret .= $this->dom->WG_DEFAULT_SPAN_TEXT;
442
  }
443
  }
444
  return $ret;
456
  public function makeup()
457
  {
458
  // text, comment, unknown
459
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) {
460
+ return $this->dom->restore_noise($this->_[WG_HDOM_INFO_TEXT]);
461
  }
462
 
463
  $ret = '<'.$this->tag;
471
  continue;
472
  }
473
 
474
+ $ret .= $this->_[WG_HDOM_INFO_SPACE][$i][0];
475
  //no value attr: nowrap, checked selected...
476
  if ($val===true) {
477
  $ret .= $key;
478
  } else {
479
+ switch ($this->_[WG_HDOM_INFO_QUOTE][$i]) {
480
+ case WG_HDOM_QUOTE_DOUBLE: $quote = '"'; break;
481
+ case WG_HDOM_QUOTE_SINGLE: $quote = '\''; break;
482
  default: $quote = '';
483
  }
484
+ $ret .= $key.$this->_[WG_HDOM_INFO_SPACE][$i][1].'='.$this->_[WG_HDOM_INFO_SPACE][$i][2].$quote.$val.$quote;
485
  }
486
  }
487
  $ret = $this->dom->restore_noise($ret);
488
+ return $ret . $this->_[WG_HDOM_INFO_ENDSPACE] . '>';
489
  }
490
 
491
  // find elements by css selector
505
  if (($levle=count($selectors[$c]))===0) {
506
  return array();
507
  }
508
+ if (!isset($this->_[WG_HDOM_INFO_BEGIN])) {
509
  return array();
510
  }
511
 
512
+ $head = array($this->_[WG_HDOM_INFO_BEGIN]=>1);
513
 
514
  // handle descendant selectors, no recursive!
515
  for ($l=0; $l<$levle; ++$l) {
563
  foreach ($this->children as $c) {
564
  if ($tag==='*' || $tag===$c->tag) {
565
  if (++$count==$key) {
566
+ $ret[$c->_[WG_HDOM_INFO_BEGIN]] = 1;
567
  return;
568
  }
569
  }
571
  return;
572
  }
573
 
574
+ $end = (!empty($this->_[WG_HDOM_INFO_END])) ? $this->_[WG_HDOM_INFO_END] : 0;
575
  if ($end==0) {
576
  $parent = $this->parent;
577
+ while (!isset($parent->_[WG_HDOM_INFO_END]) && $parent!==null) {
578
  $end -= 1;
579
  $parent = $parent->parent;
580
  }
581
+ $end += $parent->_[WG_HDOM_INFO_END];
582
  }
583
 
584
+ for ($i=$this->_[WG_HDOM_INFO_BEGIN]+1; $i<$end; ++$i) {
585
  $node = $this->dom->nodes[$i];
586
 
587
  $pass = true;
702
  // Notice the \[ starting the attbute? and the @? following? This implies that an attribute can begin with an @ sign that is not captured.
703
  // This implies that an html attribute specifier may start with an @ sign that is NOT captured by the expression.
704
  // farther study is required to determine of this should be documented or removed.
705
+ // $pattern = "/([a-zA-Z0-9_\-:\*]*)(?:\#([a-zA-Z0-9_\-]+)|\.([a-zA-Z0-9_\-]+))?(?:\[@?(!?[a-zA-Z0-9_\-]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
706
+ $pattern = "/([a-zA-Z0-9_\-:\*]*)(?:\#([a-zA-Z0-9_\-]+)|\.([a-zA-Z0-9_\-]+))?(?:\[@?(!?[a-zA-Z0-9_\-:]+)(?:([!*^$]?=)[\"']?(.*?)[\"']?)?\])?([\/, ]+)/is";
707
  preg_match_all($pattern, trim($selector_string).' ', $matches, PREG_SET_ORDER);
708
  if (is_object($debugObject)) {
709
  $debugObject->debugLog(2, "Matches Array: ", $matches);
782
  public function __set($name, $value)
783
  {
784
  switch ($name) {
785
+ case 'outertext': return $this->_[WG_HDOM_INFO_OUTER] = $value;
786
  case 'innertext':
787
+ if (isset($this->_[WG_HDOM_INFO_TEXT])) {
788
+ return $this->_[WG_HDOM_INFO_TEXT] = $value;
789
  }
790
+ return $this->_[WG_HDOM_INFO_INNER] = $value;
791
  }
792
  if (!isset($this->attr[$name])) {
793
+ $this->_[WG_HDOM_INFO_SPACE][] = array(' ', '', '');
794
+ $this->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_DOUBLE;
795
  }
796
  $this->attr[$name] = $value;
797
  }
942
  if (isset($this->attr['style'])) {
943
  // Thanks to user gnarf from stackoverflow for this regular expression.
944
  $attributes = array();
945
+ preg_match_all("/([a-zA-Z0-9_\-]+)\s*:\s*([^;]+)\s*;?/", $this->attr['style'], $matches, PREG_SET_ORDER);
946
  foreach ($matches as $match) {
947
  $attributes[$match[1]] = $match[2];
948
  }
1110
  // Note that this is referenced by a child node, and so it needs to be public for that node to see this information.
1111
  public $_charset = '';
1112
  public $_target_charset = '';
1113
+ protected $WG_DEFAULT_BR_TEXT = "";
1114
+ public $WG_DEFAULT_SPAN_TEXT = "";
1115
 
1116
  // use isset instead of in_array, performance boost about 30%...
1117
  protected $self_closing_tags = array('img'=>1, 'br'=>1, 'input'=>1, 'meta'=>1, 'link'=>1, 'hr'=>1, 'base'=>1, 'embed'=>1, 'spacer'=>1);
1133
  'source'=>array('source'=>1)
1134
  );
1135
 
1136
+ public function __construct($str=null, $lowercase=true, $forceTagsClosed=true, $target_charset=WG_DEFAULT_TARGET_CHARSET, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1137
  {
1138
  if ($str) {
1139
  if (preg_match("/^http:\/\//i", $str) || is_file($str)) {
1155
  }
1156
 
1157
  // load html from string
1158
+ public function load($str, $lowercase=true, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1159
  {
1160
  global $debugObject;
1161
 
1184
  // parsing
1185
  while ($this->parse());
1186
  // end
1187
+ $this->root->_[WG_HDOM_INFO_END] = $this->cursor;
1188
  $this->parse_charset();
1189
 
1190
  // make load function chainable
1264
  }
1265
 
1266
  // prepare HTML data and init everything
1267
+ protected function prepare($str, $lowercase=true, $stripRN=true, $defaultBRText=WG_DEFAULT_BR_TEXT, $defaultSpanText=WG_DEFAULT_SPAN_TEXT)
1268
  {
1269
  $this->clear();
1270
 
1288
  $this->noise = array();
1289
  $this->nodes = array();
1290
  $this->lowercase = $lowercase;
1291
+ $this->WG_DEFAULT_BR_TEXT = $defaultBRText;
1292
+ $this->WG_DEFAULT_SPAN_TEXT = $defaultSpanText;
1293
  $this->root = new simple_html_dom_node($this);
1294
  $this->root->tag = 'root';
1295
+ $this->root->_[WG_HDOM_INFO_BEGIN] = -1;
1296
+ $this->root->nodetype = WG_HDOM_TYPE_ROOT;
1297
  $this->parent = $this->root;
1298
  if ($this->size>0) {
1299
  $this->char = $this->doc[0];
1310
  // text
1311
  $node = new simple_html_dom_node($this);
1312
  ++$this->cursor;
1313
+ $node->_[WG_HDOM_INFO_TEXT] = $s;
1314
  $this->link_nodes($node, false);
1315
  return true;
1316
  }
1396
  protected function read_tag()
1397
  {
1398
  if ($this->char!=='<') {
1399
+ $this->root->_[WG_HDOM_INFO_END] = $this->cursor;
1400
  return false;
1401
  }
1402
  $begin_tag_pos = $this->pos;
1420
 
1421
  if ($parent_lower!==$tag_lower) {
1422
  if (isset($this->optional_closing_tags[$parent_lower]) && isset($this->block_tags[$tag_lower])) {
1423
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1424
  $org_parent = $this->parent;
1425
 
1426
  while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
1432
  if ($this->parent->parent) {
1433
  $this->parent = $this->parent->parent;
1434
  }
1435
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1436
  return $this->as_text_node($tag);
1437
  }
1438
  } elseif (($this->parent->parent) && isset($this->block_tags[$tag_lower])) {
1439
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1440
  $org_parent = $this->parent;
1441
 
1442
  while (($this->parent->parent) && strtolower($this->parent->tag)!==$tag_lower) {
1445
 
1446
  if (strtolower($this->parent->tag)!==$tag_lower) {
1447
  $this->parent = $org_parent; // restore origonal parent
1448
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1449
  return $this->as_text_node($tag);
1450
  }
1451
  } elseif (($this->parent->parent) && strtolower($this->parent->parent->tag)===$tag_lower) {
1452
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1453
  $this->parent = $this->parent->parent;
1454
  } else {
1455
  return $this->as_text_node($tag);
1456
  }
1457
  }
1458
 
1459
+ $this->parent->_[WG_HDOM_INFO_END] = $this->cursor;
1460
  if ($this->parent->parent) {
1461
  $this->parent = $this->parent->parent;
1462
  }
1466
  }
1467
 
1468
  $node = new simple_html_dom_node($this);
1469
+ $node->_[WG_HDOM_INFO_BEGIN] = $this->cursor;
1470
  ++$this->cursor;
1471
  $tag = $this->copy_until($this->token_slash);
1472
  $node->tag_start = $begin_tag_pos;
1473
 
1474
  // doctype, cdata & comments...
1475
  if (isset($tag[0]) && $tag[0]==='!') {
1476
+ $node->_[WG_HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until_char('>');
1477
 
1478
  if (isset($tag[2]) && $tag[1]==='-' && $tag[2]==='-') {
1479
+ $node->nodetype = WG_HDOM_TYPE_COMMENT;
1480
  $node->tag = 'comment';
1481
  } else {
1482
+ $node->nodetype = WG_HDOM_TYPE_UNKNOWN;
1483
  $node->tag = 'unknown';
1484
  }
1485
  if ($this->char==='>') {
1486
+ $node->_[WG_HDOM_INFO_TEXT].='>';
1487
  }
1488
  $this->link_nodes($node, true);
1489
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1493
  // text
1494
  if ($pos=strpos($tag, '<')!==false) {
1495
  $tag = '<' . substr($tag, 0, -1);
1496
+ $node->_[WG_HDOM_INFO_TEXT] = $tag;
1497
  $this->link_nodes($node, false);
1498
  $this->char = $this->doc[--$this->pos]; // prev
1499
  return true;
1500
  }
1501
 
1502
+ if (!preg_match("/^[a-zA-Z0-9_\-:]+$/", $tag)) {
1503
+ $node->_[WG_HDOM_INFO_TEXT] = '<' . $tag . $this->copy_until('<>');
1504
  if ($this->char==='<') {
1505
  $this->link_nodes($node, false);
1506
  return true;
1507
  }
1508
 
1509
  if ($this->char==='>') {
1510
+ $node->_[WG_HDOM_INFO_TEXT].='>';
1511
  }
1512
  $this->link_nodes($node, false);
1513
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1515
  }
1516
 
1517
  // begin tag
1518
+ $node->nodetype = WG_HDOM_TYPE_ELEMENT;
1519
  $tag_lower = strtolower($tag);
1520
  $node->tag = ($this->lowercase) ? $tag_lower : $tag;
1521
 
1522
  // handle optional closing tags
1523
  if (isset($this->optional_closing_tags[$tag_lower])) {
1524
  while (isset($this->optional_closing_tags[$tag_lower][strtolower($this->parent->tag)])) {
1525
+ $this->parent->_[WG_HDOM_INFO_END] = 0;
1526
  $this->parent = $this->parent->parent;
1527
  }
1528
  $node->parent = $this->parent;
1545
 
1546
  // handle endless '<'
1547
  if ($this->pos>=$this->size-1 && $this->char!=='>') {
1548
+ $node->nodetype = WG_HDOM_TYPE_TEXT;
1549
+ $node->_[WG_HDOM_INFO_END] = 0;
1550
+ $node->_[WG_HDOM_INFO_TEXT] = '<'.$tag . $space[0] . $name;
1551
  $node->tag = 'text';
1552
  $this->link_nodes($node, false);
1553
  return true;
1555
 
1556
  // handle mismatch '<'
1557
  if ($this->doc[$this->pos-1]=='<') {
1558
+ $node->nodetype = WG_HDOM_TYPE_TEXT;
1559
  $node->tag = 'text';
1560
  $node->attr = array();
1561
+ $node->_[WG_HDOM_INFO_END] = 0;
1562
+ $node->_[WG_HDOM_INFO_TEXT] = substr($this->doc, $begin_tag_pos, $this->pos-$begin_tag_pos-1);
1563
  $this->pos -= 2;
1564
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1565
  $this->link_nodes($node, false);
1577
  $this->parse_attr($node, $name, $space);
1578
  } else {
1579
  //no value attr: nowrap, checked selected...
1580
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_NO;
1581
  $node->attr[$name] = true;
1582
  if ($this->char!='>') {
1583
  $this->char = $this->doc[--$this->pos];
1584
  } // prev
1585
  }
1586
+ $node->_[WG_HDOM_INFO_SPACE][] = $space;
1587
  $space = array($this->copy_skip($this->token_blank), '', '');
1588
  } else {
1589
  break;
1591
  } while ($this->char!=='>' && $this->char!=='/');
1592
 
1593
  $this->link_nodes($node, true);
1594
+ $node->_[WG_HDOM_INFO_ENDSPACE] = $space[0];
1595
 
1596
  // check self closing
1597
  if ($this->copy_until_char_escape('>')==='/') {
1598
+ $node->_[WG_HDOM_INFO_ENDSPACE] .= '/';
1599
+ $node->_[WG_HDOM_INFO_END] = 0;
1600
  } else {
1601
  // reset parent
1602
  if (!isset($this->self_closing_tags[strtolower($node->tag)])) {
1609
  // This way when we see it in plaintext, we can generate formatting that the user wants.
1610
  // since a br tag never has sub nodes, this works well.
1611
  if ($node->tag == "br") {
1612
+ $node->_[WG_HDOM_INFO_INNER] = $this->WG_DEFAULT_BR_TEXT;
1613
  }
1614
 
1615
  return true;
1627
  $space[2] = $this->copy_skip($this->token_blank);
1628
  switch ($this->char) {
1629
  case '"':
1630
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_DOUBLE;
1631
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1632
  $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('"'));
1633
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1634
  break;
1635
  case '\'':
1636
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_SINGLE;
1637
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1638
  $node->attr[$name] = $this->restore_noise($this->copy_until_char_escape('\''));
1639
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1640
  break;
1641
  default:
1642
+ $node->_[WG_HDOM_INFO_QUOTE][] = WG_HDOM_QUOTE_NO;
1643
  $node->attr[$name] = $this->restore_noise($this->copy_until($this->token_attr));
1644
  }
1645
  // PaperG: Attributes should not have \r or \n in them, that counts as html whitespace.
1666
  {
1667
  $node = new simple_html_dom_node($this);
1668
  ++$this->cursor;
1669
+ $node->_[WG_HDOM_INFO_TEXT] = '</' . $tag . '>';
1670
  $this->link_nodes($node, false);
1671
  $this->char = (++$this->pos<$this->size) ? $this->doc[$this->pos] : null; // next
1672
  return true;
vendor/weglot/weglot-php/composer.json CHANGED
@@ -35,7 +35,7 @@
35
  ],
36
  "require": {
37
  "php": ">=5.4",
38
- "weglot/simplehtmldom": "^0.3",
39
  "psr/cache": "^1.0"
40
  },
41
  "autoload": {
35
  ],
36
  "require": {
37
  "php": ">=5.4",
38
+ "weglot/simplehtmldom": "^0.5",
39
  "psr/cache": "^1.0"
40
  },
41
  "autoload": {
vendor/weglot/weglot-php/src/Parser/Check/AbstractChecker.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace Weglot\Parser\Check;
4
 
5
- use SimpleHtmlDom\simple_html_dom;
6
  use Weglot\Parser\Parser;
7
 
8
  /**
2
 
3
  namespace Weglot\Parser\Check;
4
 
5
+ use WGSimpleHtmlDom\simple_html_dom;
6
  use Weglot\Parser\Parser;
7
 
8
  /**
vendor/weglot/weglot-php/src/Parser/Check/Dom/AbstractDomChecker.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace Weglot\Parser\Check\Dom;
4
 
5
- use SimpleHtmlDom\simple_html_dom_node;
6
  use Weglot\Client\Api\Enum\WordType;
7
  use Weglot\Parser\Parser;
8
  use Weglot\Util\Text;
2
 
3
  namespace Weglot\Parser\Check\Dom;
4
 
5
+ use WGSimpleHtmlDom\simple_html_dom_node;
6
  use Weglot\Client\Api\Enum\WordType;
7
  use Weglot\Parser\Parser;
8
  use Weglot\Util\Text;
vendor/weglot/weglot-php/src/Parser/Check/Dom/IframeSrc.php CHANGED
@@ -31,6 +31,6 @@ class IframeSrc extends AbstractDomChecker
31
  */
32
  protected function check()
33
  {
34
- return TextUtil::contains(TextUtil::fullTrim($this->node->src), '.youtube.');
35
  }
36
  }
31
  */
32
  protected function check()
33
  {
34
+ return TextUtil::contains(TextUtil::fullTrim($this->node->src), '.youtube.') || TextUtil::contains(TextUtil::fullTrim($this->node->src), '.vimeo.') || TextUtil::contains(TextUtil::fullTrim($this->node->src), '.dailymotion.');
35
  }
36
  }
vendor/weglot/weglot-php/src/Parser/Check/DomCheckerProvider.php CHANGED
@@ -2,8 +2,8 @@
2
 
3
  namespace Weglot\Parser\Check;
4
 
5
- use SimpleHtmlDom\simple_html_dom;
6
- use SimpleHtmlDom\simple_html_dom_node;
7
  use Weglot\Client\Api\Exception\InvalidWordTypeException;
8
  use Weglot\Client\Api\WordEntry;
9
  use Weglot\Parser\Check\Dom\AbstractDomChecker;
2
 
3
  namespace Weglot\Parser\Check;
4
 
5
+ use WGSimpleHtmlDom\simple_html_dom;
6
+ use WGSimpleHtmlDom\simple_html_dom_node;
7
  use Weglot\Client\Api\Exception\InvalidWordTypeException;
8
  use Weglot\Client\Api\WordEntry;
9
  use Weglot\Parser\Check\Dom\AbstractDomChecker;
vendor/weglot/weglot-php/src/Parser/Formatter/ExcludeBlocksFormatter.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace Weglot\Parser\Formatter;
4
 
5
- use SimpleHtmlDom\simple_html_dom;
6
  use Weglot\Parser\Parser;
7
 
8
  class ExcludeBlocksFormatter
2
 
3
  namespace Weglot\Parser\Formatter;
4
 
5
+ use WGSimpleHtmlDom\simple_html_dom;
6
  use Weglot\Parser\Parser;
7
 
8
  class ExcludeBlocksFormatter
vendor/weglot/weglot-php/src/Parser/Parser.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  namespace Weglot\Parser;
4
 
5
- use SimpleHtmlDom\simple_html_dom;
6
  use Weglot\Client\Api\Exception\ApiError;
7
  use Weglot\Client\Api\Exception\InputAndOutputCountMatchException;
8
  use Weglot\Client\Api\Exception\InvalidWordTypeException;
@@ -235,7 +235,8 @@ class Parser
235
  /**
236
  * @return IgnoredNodes
237
  */
238
- public function getIgnoredNodesFormatter(){
 
239
  return $this->ignoredNodesFormatter;
240
  }
241
 
@@ -261,17 +262,17 @@ class Parser
261
  $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
262
 
263
  $ignoredNodesFormatter->setSource($source)
264
- ->handle();
265
 
266
  $source = $ignoredNodesFormatter->getSource();
267
  }
268
 
269
  // simple_html_dom
270
- $dom = \SimpleHtmlDom\str_get_html(
271
  $source,
272
  true,
273
  true,
274
- DEFAULT_TARGET_CHARSET,
275
  false
276
  );
277
 
@@ -300,6 +301,49 @@ class Parser
300
  return $source;
301
  }
302
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  /**
304
  * @param simple_html_dom $dom
305
  * @return TranslateEntry
2
 
3
  namespace Weglot\Parser;
4
 
5
+ use WGSimpleHtmlDom\simple_html_dom;
6
  use Weglot\Client\Api\Exception\ApiError;
7
  use Weglot\Client\Api\Exception\InputAndOutputCountMatchException;
8
  use Weglot\Client\Api\Exception\InvalidWordTypeException;
235
  /**
236
  * @return IgnoredNodes
237
  */
238
+ public function getIgnoredNodesFormatter()
239
+ {
240
  return $this->ignoredNodesFormatter;
241
  }
242
 
262
  $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
263
 
264
  $ignoredNodesFormatter->setSource($source)
265
+ ->handle();
266
 
267
  $source = $ignoredNodesFormatter->getSource();
268
  }
269
 
270
  // simple_html_dom
271
+ $dom = \WGSimpleHtmlDom\str_get_html(
272
  $source,
273
  true,
274
  true,
275
+ WG_DEFAULT_TARGET_CHARSET,
276
  false
277
  );
278
 
301
  return $source;
302
  }
303
 
304
+ /**
305
+ * @param $source
306
+ * @return string|WordCollection
307
+ * @throws InvalidWordTypeException
308
+ */
309
+ public function parse($source)
310
+ {
311
+ if ($this->client->getProfile()->getIgnoredNodes()) {
312
+ $ignoredNodesFormatter = $this->getIgnoredNodesFormatter();
313
+
314
+ $ignoredNodesFormatter->setSource($source)
315
+ ->handle();
316
+
317
+ $source = $ignoredNodesFormatter->getSource();
318
+ }
319
+
320
+ // simple_html_dom
321
+ $dom = \WGSimpleHtmlDom\str_get_html(
322
+ $source,
323
+ true,
324
+ true,
325
+ WG_DEFAULT_TARGET_CHARSET,
326
+ false
327
+ );
328
+
329
+ // if simple_html_dom can't parse the $source, it returns false
330
+ // so we just return raw $source
331
+ if ($dom === false) {
332
+ return $source;
333
+ }
334
+
335
+ // exclude blocks
336
+ if (!empty($this->excludeBlocks)) {
337
+ $excludeBlocks = new ExcludeBlocksFormatter($dom, $this->excludeBlocks);
338
+ $dom = $excludeBlocks->getDom();
339
+ }
340
+
341
+ // checkers
342
+ $this->checkers($dom);
343
+
344
+ return $this->getWords();
345
+ }
346
+
347
  /**
348
  * @param simple_html_dom $dom
349
  * @return TranslateEntry
vendor/weglot/weglot-php/src/Util/Server.php CHANGED
@@ -42,7 +42,7 @@ class Server
42
  Text::contains($userAgent, 'facebook') ||
43
  Text::contains($userAgent, 'wprocketbot') ||
44
  Text::contains($userAgent, 'SemrushBot'));
45
-
46
  if ($userAgent !== null && !$checkBotAgent) {
47
  return BotType::HUMAN;
48
  }
@@ -77,7 +77,24 @@ class Server
77
  */
78
  private static function isSsl(array $server)
79
  {
80
- return !empty($server['HTTPS']) && $server['HTTPS'] === 'on';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  }
82
 
83
  /**
42
  Text::contains($userAgent, 'facebook') ||
43
  Text::contains($userAgent, 'wprocketbot') ||
44
  Text::contains($userAgent, 'SemrushBot'));
45
+
46
  if ($userAgent !== null && !$checkBotAgent) {
47
  return BotType::HUMAN;
48
  }
77
  */
78
  private static function isSsl(array $server)
79
  {
80
+ if ( isset($server['HTTPS']) ) {
81
+ if ( 'on' == strtolower($server['HTTPS']) ) {
82
+ return true;
83
+ }
84
+
85
+ if ( '1' == $server['HTTPS'] ){
86
+ return true;
87
+ }
88
+ elseif ( isset($server['SERVER_PORT']) && ( '443' == $server['SERVER_PORT'] ) ) {
89
+ return true;
90
+ }
91
+ }
92
+
93
+ if( isset( $server['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $server['HTTP_X_FORWARDED_PROTO'] ){
94
+ return true;
95
+ }
96
+
97
+ return false;
98
  }
99
 
100
  /**
vendor/weglot/weglot-php/tests/unit/Parser/Check/Dom/MetaContentTest.php CHANGED
@@ -70,14 +70,14 @@ class MetaContentTest extends \Codeception\Test\Unit
70
 
71
  private function _getSimpleDom($source)
72
  {
73
- return \SimpleHtmlDom\str_get_html(
74
  $source,
75
  true,
76
  true,
77
- DEFAULT_TARGET_CHARSET,
78
  false,
79
- DEFAULT_BR_TEXT,
80
- DEFAULT_SPAN_TEXT
81
  );
82
  }
83
  }
70
 
71
  private function _getSimpleDom($source)
72
  {
73
+ return \WGSimpleHtmlDom\str_get_html(
74
  $source,
75
  true,
76
  true,
77
+ WG_DEFAULT_TARGET_CHARSET,
78
  false,
79
+ WG_DEFAULT_BR_TEXT,
80
+ WG_DEFAULT_SPAN_TEXT
81
  );
82
  }
83
  }
webpack.config.js CHANGED
@@ -11,7 +11,8 @@ module.exports = {
11
  "metaboxes-js": "./app/javascripts/metaboxes.js",
12
  "front-css": "./app/styles/index.scss",
13
  "admin-css": "./app/styles/admin.scss",
14
- "front-amp-css": "./app/styles/amp.scss"
 
15
  },
16
  output: {
17
  path: __dirname + "/dist",
11
  "metaboxes-js": "./app/javascripts/metaboxes.js",
12
  "front-css": "./app/styles/index.scss",
13
  "admin-css": "./app/styles/admin.scss",
14
+ "front-amp-css": "./app/styles/amp.scss",
15
+ "nav-js" : "./app/javascripts/nav.js"
16
  },
17
  output: {
18
  path: __dirname + "/dist",
weglot-compatibility.php CHANGED
@@ -19,3 +19,30 @@ if ( ! function_exists( 'wp_doing_ajax' ) ) {
19
  return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
20
  }
21
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  return apply_filters( 'wp_doing_ajax', defined( 'DOING_AJAX' ) && DOING_AJAX );
20
  }
21
  }
22
+
23
+
24
+ if ( ! function_exists('is_rest')) {
25
+ /**
26
+ * Checks if the current request is a WP REST API request.
27
+ *
28
+ * Case #1: After WP_REST_Request initialisation
29
+ * Case #2: Support "plain" permalink settings
30
+ * Case #3: URL Path begins with wp-json/ (your REST prefix)
31
+ * Also supports WP installations in subfolders
32
+ *
33
+ * @returns boolean
34
+ * @author matzeeable
35
+ */
36
+ function is_rest() {
37
+ $prefix = rest_get_url_prefix( );
38
+ if (defined('REST_REQUEST') && REST_REQUEST // (#1)
39
+ || isset($_GET['rest_route']) // (#2)
40
+ && strpos( trim( $_GET['rest_route'], '\\/' ), $prefix, 0 ) === 0) {
41
+ return true;
42
+ }
43
+ // (#3)
44
+ $rest_url = wp_parse_url( site_url( $prefix ) );
45
+ $current_url = wp_parse_url( add_query_arg( array( ) ) );
46
+ return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0;
47
+ }
48
+ }
weglot-functions.php CHANGED
@@ -232,3 +232,14 @@ function weglot_get_destination_language() {
232
  function weglot_get_private_languages() {
233
  return weglot_get_option( 'private_mode' );
234
  }
 
 
 
 
 
 
 
 
 
 
 
232
  function weglot_get_private_languages() {
233
  return weglot_get_option( 'private_mode' );
234
  }
235
+
236
+
237
+ /**
238
+ * @since 2.4.0
239
+ * @return string
240
+ */
241
+ function weglot_get_rest_current_url_path() {
242
+ $prefix = rest_get_url_prefix();
243
+ $current_url = wp_parse_url( add_query_arg( [] ) );
244
+ return $current_url['path'];
245
+ }
weglot.php CHANGED
@@ -1,8 +1,4 @@
1
  <?php
2
- /**
3
- * @version 2.3.0
4
- */
5
-
6
  /*
7
  Plugin Name: Weglot Translate
8
  Plugin URI: http://wordpress.org/plugins/weglot/
@@ -11,7 +7,7 @@ Author: Weglot Translate team
11
  Author URI: https://weglot.com/
12
  Text Domain: weglot
13
  Domain Path: /languages/
14
- Version: 2.3.1
15
  */
16
 
17
  /**
@@ -26,7 +22,7 @@ if ( ! defined('ABSPATH')) {
26
  define('WEGLOT_NAME', 'Weglot');
27
  define('WEGLOT_SLUG', 'weglot-translate');
28
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
29
- define('WEGLOT_VERSION', '2.3.1');
30
  define('WEGLOT_PHP_MIN', '5.4');
31
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
32
  define('WEGLOT_DIR', __DIR__ );
@@ -115,6 +111,7 @@ function weglot_plugin_activate() {
115
 
116
  require_once __DIR__ . '/weglot-autoload.php';
117
  require_once __DIR__ . '/vendor/autoload.php';
 
118
  require_once __DIR__ . '/weglot-functions.php';
119
  require_once __DIR__ . '/bootstrap.php';
120
 
@@ -131,6 +128,7 @@ function weglot_plugin_deactivate() {
131
 
132
  require_once __DIR__ . '/weglot-autoload.php';
133
  require_once __DIR__ . '/vendor/autoload.php';
 
134
  require_once __DIR__ . '/weglot-functions.php';
135
  require_once __DIR__ . '/bootstrap.php';
136
 
1
  <?php
 
 
 
 
2
  /*
3
  Plugin Name: Weglot Translate
4
  Plugin URI: http://wordpress.org/plugins/weglot/
7
  Author URI: https://weglot.com/
8
  Text Domain: weglot
9
  Domain Path: /languages/
10
+ Version: 2.5.0
11
  */
12
 
13
  /**
22
  define('WEGLOT_NAME', 'Weglot');
23
  define('WEGLOT_SLUG', 'weglot-translate');
24
  define('WEGLOT_OPTION_GROUP', 'group-weglot-translate');
25
+ define('WEGLOT_VERSION', '2.5.0');
26
  define('WEGLOT_PHP_MIN', '5.4');
27
  define('WEGLOT_BNAME', plugin_basename(__FILE__));
28
  define('WEGLOT_DIR', __DIR__ );
111
 
112
  require_once __DIR__ . '/weglot-autoload.php';
113
  require_once __DIR__ . '/vendor/autoload.php';
114
+ require_once __DIR__ . '/weglot-compatibility.php';
115
  require_once __DIR__ . '/weglot-functions.php';
116
  require_once __DIR__ . '/bootstrap.php';
117
 
128
 
129
  require_once __DIR__ . '/weglot-autoload.php';
130
  require_once __DIR__ . '/vendor/autoload.php';
131
+ require_once __DIR__ . '/weglot-compatibility.php';
132
  require_once __DIR__ . '/weglot-functions.php';
133
  require_once __DIR__ . '/bootstrap.php';
134