diff --git a/trunk/localizejs.js b/trunk/localizejs.js index 2f459b8..ee3e8e5 100644 --- a/trunk/localizejs.js +++ b/trunk/localizejs.js @@ -147,7 +147,7 @@ function addLanguageToLinks() { const EXCLUDED_PATHS = ['wp-content', 'wp-admin']; // only use if subdirectories seo is set and plain permalinks aren't set, i.e. /es/my-page/ and not ?p=4&lang=es if (URL_OPTIONS == '1' && localize_conf.permalink_plain != '1') { - const links = document.querySelectorAll('a'); + const links = document.querySelectorAll('a:not([data-localize-ignore])'); links.forEach((link) => { if (link.href) { let url = new URL(link.href); @@ -159,8 +159,10 @@ function addLanguageToLinks() { // so, we go ahead and remove the language if it exists. const lang = findLanguageInPath(url.pathname); if (lang) { + link.setAttribute('data-localize-original-url', link.href ); url.pathname = removeLanguageFromPath(url.pathname); link.href = url.href; + } return; } @@ -171,6 +173,7 @@ function addLanguageToLinks() { const docUrl = new URL(document.URL); const docLang = findLanguageInPath(docUrl.pathname); if (docLang) { + link.setAttribute('data-localize-original-url', link.href ); url.pathname = `/${docLang}${url.pathname}`; link.href = url.href; }