From 31675358d58763afb4dcc9fb0738b386a0734aa4 Mon Sep 17 00:00:00 2001 From: Matthew Jackowski Date: Fri, 27 May 2016 10:39:29 -0700 Subject: [PATCH] fix for #160 and #161 --- .../lib/transifex-live-integration-javascript.php | 11 ++++++++++- includes/transifex-live-integration-defaults.php | 2 +- .../transifex-live-integration-settings-page.js | 8 +++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/includes/lib/transifex-live-integration-javascript.php b/includes/lib/transifex-live-integration-javascript.php index e508cc04..ebaa61e7 100644 --- a/includes/lib/transifex-live-integration-javascript.php +++ b/includes/lib/transifex-live-integration-javascript.php @@ -34,6 +34,7 @@ class Transifex_Live_Integration_Javascript { */ private $language_map; private $url_options; + private $subdomain_pattern; /** * Public constructor, sets local settings @@ -47,6 +48,7 @@ public function __construct( $settings, $live_settings ) { $this->source_language = $settings['source_language']; $this->language_map = $settings['language_map']; $this->url_options = $settings['url_options']; + $this->subdomain_pattern = $settings['subdomain_pattern']; } /** @@ -108,7 +110,14 @@ function wp_head_hook() { $language_map .= "case '$value': return '$key'; break; "; } $snippet .= <<function subdomain_detect_lang() {var a = window.location.host.split( '.' )[0]; switch(a) { $language_map case 'www': return true; break;} return a;} + SUBDOMAIN; $detectlang = "subdomain_detect_lang"; diff --git a/includes/transifex-live-integration-defaults.php b/includes/transifex-live-integration-defaults.php index 6843484e..f81b9430 100644 --- a/includes/transifex-live-integration-defaults.php +++ b/includes/transifex-live-integration-defaults.php @@ -97,7 +97,7 @@ static function settings() { 'languages' => '', 'hreflang' => false, 'url_options' => 1, - 'subdomain_pattern' => '', + 'subdomain_pattern' => '/(.*?)\.(?=[^\/]*\..{2,5})/i', 'static_frontpage_support' => false, 'enable_prerender' => 0, 'prerender_url' => '', diff --git a/javascript/transifex-live-integration-settings-page.js b/javascript/transifex-live-integration-settings-page.js index 7dd9f925..afe419c9 100755 --- a/javascript/transifex-live-integration-settings-page.js +++ b/javascript/transifex-live-integration-settings-page.js @@ -16,18 +16,24 @@ function transifex_live_integration_map_update(tl) { } else { var t = transifex_languages; } - var h = []; + //var h = []; var local_lm = []; + var local_hreflm = []; var arr = {}; + var arrr= {}; // loop through transifex languages jQuery.each( t, function (i, s) { var l = jQuery('#transifex-integration-live-' + s).val(); + var h = jQuery('#transifex-integration-live-hreflang-' + s).val(); + arrr[s] = h; arr[s] = l; } ); local_lm.push(arr); + local_hreflm.push(arrr); jQuery('#transifex_live_settings_language_map').val(JSON.stringify(local_lm)); + jQuery('#transifex_live_settings_hreflang_map').val(JSON.stringify(local_hreflm)); return true; }