← Back
Editing: wp-accessibility.min.js
(()=>{(()=>{"use strict";let m=document.querySelector("html"),A=document.querySelector("body"),h=[];if(wpa.lang&&(m.getAttribute("lang")||(m.setAttribute("lang",wpa.lang),(wpa.errors||wpa.tracking)&&(h.push("html-lang"),console.log("HTML language set by WP Accessibility")))),wpa.dir&&!m.getAttribute("dir")&&wpa.dir!=="ltr"&&(m.setAttribute("dir",wpa.dir),(wpa.errors||wpa.tracking)&&(h.push("html-lang-direction"),console.log("HTML language direction set by WP Accessibility"))),wpa.continue){let d=document.querySelectorAll(".wp-block-post-excerpt__more-link");d.length!==0&&d.forEach(i=>{if(!i.hasAttribute("aria-describedby")){let o=i.closest(".wp-block-post"),c=o.getAttribute("class");c=c.replaceAll(" ","-");let r=o.querySelector(".wp-block-post-title");r&&(r.hasAttribute("id")?c=r.getAttribute("id"):r.setAttribute("id",c),i.setAttribute("aria-describedby",c),(wpa.errors||wpa.tracking)&&console.log("Continue Reading link description set by WP Accessibility"))}})}let E=d=>d.replace(/(?:,\s*)?maximum-scale=[^,]+(?:,\s*)?/,(i,o,c)=>o===0||o+i.length===c.length?"":", ").trim(),x=document.querySelector('meta[name="viewport"]');if(x&&wpa.viewport){let d=x.getAttribute("content"),i;d.search(/user-scalable=no/g)&&(i=d.replace("user-scalable=no","user-scalable=yes"),x.setAttribute("content",i),(wpa.errors||wpa.tracking)&&i!=d&&(h.push("viewport-scalable"),console.log("Viewport made scalable by WP Accessibility"))),d=x.getAttribute("content"),i=E(d),console.log(i),x.setAttribute("content",i),(wpa.errors||wpa.tracking)&&i!=d&&(h.push("viewport-maxscale"),console.log("Viewport maximum scale set by WP Accessibility"))}if(wpa.skiplinks.enabled&&(A.insertAdjacentHTML("afterbegin",wpa.skiplinks.output),(wpa.errors||wpa.tracking)&&(h.push("skiplinks"),console.log("Skip links added by WP Accessibility"))),wpa.current){let d=document.querySelectorAll(".current-menu-item a, .current_page_item a");d.length!==0&&(d.forEach(i=>{i.setAttribute("aria-current","page")}),(wpa.errors||wpa.tracking)&&(h.push("aria-current"),console.log("ARIA current added by WP Accessibility")))}if(wpa.labels&&["s","author","email","url","comment"].forEach(i=>{let o,c,r,a,e,s,f,t,n,l;i=="comment"?o=document.querySelectorAll("textarea[name="+i+"]"):o=document.querySelectorAll("input[name="+i+"]:not(#adminbar-search)"),o.length!==0&&o.forEach(b=>{b.length!==0&&(c=b.getAttribute("id"),r=b.closest("label"),a=b.getAttribute("aria-label"),e=b.getAttribute("aria-labelledby"),s={},e&&(s=document.getElementById(e)),f=!(a==null||a==""||typeof a>"u"),t=!(e==null||e==""||typeof e>"u"),(!f&&!t||!f&&t&&!s)&&(c?(n=document.querySelector("label[for="+c+"]"),n&&(l=n.innerText,n&&!l&&(n.innerText=wpa.wpalabels[i],(wpa.errors||wpa.tracking)&&(h.push(["empty-label",wpa.wpalabels[i]]),console.log("Empty label on "+wpa.wpalabels[i]+" added by WP Accessibility")))),!n&&!r&&(b.insertAdjacentHTML("beforebegin","<label for='"+c+"' class='wpa-screen-reader-text'>"+wpa.wpalabels[i]+"</label>"),(wpa.errors||wpa.tracking)&&(h.push(["explicit-label",wpa.wpalabels[i]]),console.log("Explicit label on "+wpa.wpalabels[i]+" added by WP Accessibility")))):r||(b.setAttribute("id","wpa_label_"+i),b.insertAdjacentHTML("beforebegin","<label for='wpa_label_"+i+"' class='wpa-screen-reader-text'>"+wpa.wpalabels[i]+"</label>"),(wpa.errors||wpa.tracking)&&(h.push(["implicit-label",wpa.wpalabels[i]]),console.log("Implicit label on "+wpa.wpalabels[i]+" added by WP Accessibility")))))})}),wpa.titles){let d=0,i=0,o=0,c=!1,r=document.querySelectorAll("img, a, input, textarea, select, button");r.length!==0&&(r.forEach(a=>{let e=a.getAttribute("title");if(a.classList.contains("nturl")&&(c=!0),e&&e!=="")switch(a.tagName){case"IMG":let s=a.getAttribute("alt");e=a.getAttribute("title"),!s||s===""?(a.setAttribute("alt",e),a.removeAttribute("title")):e===s&&a.removeAttribute("title"),d++;break;case"A":case"BUTTON":let f=S(a);if(!f||f===""){let v=a.getAttribute("aria-label");(!v||v==="")&&(a.setAttribute("aria-label",e),c||a.removeAttribute("title"))}else a.removeAttribute("title");i++;break;case"INPUT":case"SELECT":case"TEXTAREA":let t=a.getAttribute("aria-label"),n=a.getAttribute("aria-labelledby"),l=n?document.getElementById(n):!1,b=a.getAttribute("id"),g=b?document.querySelector('label[for="'+b+'"]'):!1,w=a.closest("label"),u=!!(t&&t!==""),p=!!(g&&S(g)!==""),y=!!(w&&S(w)!==""),L=!!(l&&S(l)!=="");u||p||y||L||a.setAttribute("aria-label",e),a.removeAttribute("title"),o++;break}}),(wpa.errors||wpa.tracking)&&(d>0&&(h.push(["images-titles",d]),console.log(d+" title attributes removed from images by WP Accessibility")),i>0&&(h.push(["control-titles",i]),console.log(i+" title attributes removed from links and buttons by WP Accessibility")),o>0&&(h.push(["input-titles",o]),console.log(o+" title attributes removed from input fields by WP Accessibility"))))}if(wpa.target){let d=document.querySelectorAll("a:not(.wpa-allow-target)"),i=0;d.length!==0&&(d.forEach(o=>{let c=o.getAttribute("target"),r=o.getAttribute("href");if(c)if(r.startsWith("#"))o.removeAttribute("target");else try{new URL(r).hostname.includes("facebook")||(o.removeAttribute("target"),i++)}catch{console.log("href value is not a URL or a fragment:",r)}}),i>0&&(wpa.errors||wpa.tracking)&&(h.push(["link-targets",i]),console.log(i+" target attributes removed from links by WP Accessibility")))}if(wpa.tabindex){let d=document.querySelectorAll("input:not(.wpa-ignore-tabindex),a[href]:not(.wpa-ignore-tabindex),select:not(.wpa-ignore-tabindex),textarea:not(.wpa-ignore-tabindex),button:not(.wpa-ignore-tabindex)"),i=0;d.length!==0&&(d.forEach(e=>{let s=e.getAttribute("tabindex"),f=!1;if(e.hasAttribute("tabindex")&&s==="-1"){let t=e.getAttribute("aria-hidden"),n=e.hasAttribute("hidden");(t==="true"||n)&&(f=!0)}s&&!f&&(e.removeAttribute("tabindex"),i++)}),i>0&&(wpa.errors||wpa.tracking)&&(h.push(["control-tabindex",i]),console.log(i+" tabindex attributes removed from links, buttons and inputs by WP Accessibility")));let o=document.querySelectorAll('[role="button"]:not([tabindex]):not(a):not(button)'),c=document.querySelectorAll('a[role="button"]:not([tabindex]):not([href])'),r=document.querySelectorAll('[role="link"]:not([tabindex]):not(a)'),a=document.querySelectorAll("a:not([href]):not([tabindex])");o.length!==0&&(o.forEach(e=>{e.setAttribute("tabindex","0"),e.classList.add("wpa-focusable")}),o.length>0&&(wpa.errors||wpa.tracking)&&(h.push(["button-add-tabindex",o.length]),console.log(o.length+" tabindex attributes added to divs with the button role by WP Accessibility"))),c.length!==0&&(c.forEach(e=>{e.setAttribute("tabindex","0"),e.classList.add("wpa-focusable")}),c.length>0&&(wpa.errors||wpa.tracking)&&(h.push(["link-add-tabindex",c.length]),console.log(c.length+" tabindex attributes added to anchor elements with the button role and no href value by WP Accessibility"))),r.length!==0&&(r.forEach(e=>{e.setAttribute("tabindex","0"),e.classList.add("wpa-focusable")}),r.length>0&&(wpa.errors||wpa.tracking)&&(h.push(["fakelink-add-tabindex",r.length]),console.log(r.length+" tabindex attributes added to elements with the link role not using the a element by WP Accessibility"))),a.length!==0&&(a.forEach(e=>{e.setAttribute("tabindex","0"),e.classList.add("wpa-focusable")}),a.length>0&&(wpa.errors||wpa.tracking)&&(h.push(["links-add-tabindex",a.length]),console.log(a.length+" tabindex attributes added to a with no href attribute by WP Accessibility")))}if(wpa.url!=="disabled"){let o=function(e,s,f="event"){e=JSON.stringify(e);let t=new FormData;t.append("action",wpa.action),t.append("security",wpa.security),t.append("stats",e),t.append("post_id",wpa.post_id),t.append("title",s),t.append("type",f),fetch(wpa.ajaxurl,{method:"POST",body:t})};class d{constructor(s){var f=Array.prototype.forEach,t=Array.prototype.map;this.each=function(n,l,b){if(n!=null){if(f&&n.forEach===f)n.forEach(l,b);else if(n.length===+n.length){for(var g=0,w=n.length;g<w;g++)if(JSON.stringify(l.call(b,n[g],g,n))==="{}")return}else for(var u in n)if(n.hasOwnProperty(u)&&JSON.stringify(l.call(b,n[u],u,n))==="{}")return}},this.map=function(n,l,b){var g=[];return n==null?g:t&&n.map===t?n.map(l,b):(this.each(n,function(w,u,p){g[g.length]=l.call(b,w,u,p)}),g)},s&&(this.hasher=s)}get(){let s=[];s.push(navigator.userAgent),s.push([screen.height,screen.width,screen.colorDepth].join("x")),s.push(new Date().getTimezoneOffset()),s.push(!!window.sessionStorage),s.push(!!window.localStorage);var f=this.map(navigator.plugins,function(t){var n=this.map(t,function(l){return[l.type,l.suffixes].join("~")}).join(",");return[t.name,t.description,n].join("::")},this).join(";");return s.push(f),this.hasher?this.hasher(s.join("###"),31):this.murmurhash3_32_gc(s.join("###"),31)}murmurhash3_32_gc(s,f){let t,n,l,b,g,w,u,p;for(t=s.length&3,n=s.length-t,l=f,g=3432918353,w=461845907,p=0;p<n;)u=s.charCodeAt(p)&255|(s.charCodeAt(++p)&255)<<8|(s.charCodeAt(++p)&255)<<16|(s.charCodeAt(++p)&255)<<24,++p,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*w+(((u>>>16)*w&65535)<<16)&4294967295,l^=u,l=l<<13|l>>>19,b=(l&65535)*5+(((l>>>16)*5&65535)<<16)&4294967295,l=(b&65535)+27492+(((b>>>16)+58964&65535)<<16);switch(u=0,t){case 3:u^=(s.charCodeAt(p+2)&255)<<16;case 2:u^=(s.charCodeAt(p+1)&255)<<8;case 1:u^=s.charCodeAt(p)&255,u=(u&65535)*g+(((u>>>16)*g&65535)<<16)&4294967295,u=u<<15|u>>>17,u=(u&65535)*w+(((u>>>16)*w&65535)<<16)&4294967295,l^=u}return l^=s.length,l^=l>>>16,l=(l&65535)*2246822507+(((l>>>16)*2246822507&65535)<<16)&4294967295,l^=l>>>13,l=(l&65535)*3266489909+(((l>>>16)*3266489909&65535)<<16)&4294967295,l^=l>>>16,l>>>0}}let i=new d().get(),c=document.querySelector(".toggle-contrast");c&&c.addEventListener("click",function(){let e;this.getAttribute("data-id")=="is_normal_contrast"?e={contrast:"disabled"}:e={contrast:"enabled"},o(e,i)});let r=document.querySelector(".toggle-fontsize");r&&r.addEventListener("click",function(){let e;this.getAttribute("data-id")=="is_normal_fontsize"?e={fontsize:"disabled"}:e={fontsize:"enabled"},o(e,i)}),T(".wpa-ld button").then(e=>{e.addEventListener("click",function(s){if(e.getAttribute("aria-expanded")==="true"){let l={longdesc:e.closest("div").getAttribute("class").replace("wpa-ld wp-image-","")};o(l,i)}})});let a=document.querySelectorAll(".wpa-alt button");a.length>0&&a.forEach(e=>{e.addEventListener("click",function(s){if(e.getAttribute("aria-expanded")==="true"){let l={alttext:e.closest("div").getAttribute("class").replace("wpa-alt wp-image-","")};o(l,i)}})}),wpa.tracking&&h.length>=1&&o(h,wpa.url,"view")}if(wpa.underline.enabled){let d=document.querySelectorAll(wpa.underline.target+":not(nav "+wpa.underline.target+"):not(#wpadminbar a), .wpa-focusable[role=link]");d.length>0&&d.forEach(i=>{let o=i.style.outlineWidth,c=i.style.outlineOffset,r=i.style.color,a=i.style.outlineColor;i.style.textDecoration="underline",i.addEventListener("mouseenter",function(){this.style.textDecoration="none"}),i.addEventListener("mouseleave",function(){this.style.textDecoration="underline"}),i.addEventListener("focusin",function(){let e="2px";o=="2px"&&(e="4px"),this.style.outlineWidth=e,this.style.outlineColor=r,this.style.outlineOffset="2px"}),i.addEventListener("focusout",function(){this.style.outlineWidth=o,this.style.outlineColor=a,this.style.outlineOffset=c})})}if(wpa.videos){let d=matchMedia("(prefers-reduced-motion)"),i="false",o=document.querySelectorAll("video[autoplay]:not([controls])");o.length>0&&o.forEach(c=>{d.matches&&(c.pause(),i="true");let r=c.parentElement,a=document.createElement("button"),e=document.createElement("span"),s=document.createElement("span");a.setAttribute("type","button"),a.classList.add("wpa-video"),a.setAttribute("aria-pressed",i),e.classList.add("dashicons-controls-pause","dashicons"),e.setAttribute("aria-hidden","true"),s.classList.add("screen-reader-text"),s.innerText=wpa.pause,a.append(e,s),r.append(a),a.addEventListener("click",function(){let f=this.getAttribute("aria-pressed");console.log(f),f==="true"?(c.play(),this.setAttribute("aria-pressed","false")):(c.pause(),this.setAttribute("aria-pressed","true"))})})}if(wpa.alt){let d=wpa.altSelector?wpa.altSelector:'.hentry img[alt]:not([alt=""]), .comment-content img[alt]:not([alt=""]), #content img[alt]:not([alt=""]),.entry-content img[alt]:not([alt=""])',i=document.querySelectorAll(d),o=(c,r)=>{c.parentElement.insertBefore(r,c),r.appendChild(c)};i.forEach(c=>{let r=c,a=r.closest("a"),e=r.closest("button"),s=!!a,f=!!e,t=r.width,n=r.height;if((t||n)&&(t=t||56,n=n||56,n*t<150*300||c.classList.contains("wpa-skip")||c.closest(".wpa-skip")))return;let l=r.getAttribute("alt"),b=[...r.classList];r.setAttribute("class","");let g=document.createElement("div");g.classList.add("wpa-alt"),o(s||f?s?a:e:r,g),b.forEach(p=>{g.classList.add(p)}),g.insertAdjacentHTML("afterbegin",'<button aria-expanded="false" type="button" class="wpa-toggle">alt</button>'),g.insertAdjacentHTML("beforeend",'<div class="wpa-alt-text"></div>');let w=g.querySelector(".wpa-alt-text");w.style.display="none",w.innerText=l,g.querySelector("button").addEventListener("click",function(p){w.checkVisibility()?(this.setAttribute("aria-expanded","false"),w.style.display="none"):(this.setAttribute("aria-expanded","true"),w.style.display="block")})})}if(wpa.ldType){let o=function(r){let a=r.getAttribute("class"),e=r.getAttribute("id"),s;e&&e.includes("longdesc")?s=e.replace("longdesc-return-",""):((a===null||a==="")&&(parent=r.closest(".wpa-alt"),a=parent.getAttribute("class").replace("wpa-alt ","")),s=a.replace("wp-image-",""));let f=wpa.restUrl+"/"+s;fetch(f,{method:"GET",headers:{"X-WP-Nonce":wpa.restNonce}}).then(t=>t.json()).then(t=>{let n=t.description.rendered;if(n=n.replace(/(<([^>]+)>)/gi,"").trim(),n!==""){let l=new URL(wpa.ldHome);l.searchParams.set("longdesc",s),l.toString(),c(r,s,l,n)}}).catch(t=>{console.log(t)})},c=function(r,a,e,s){let f=document.createElement("div");f.classList.add("wpa-ld");let t=r.getAttribute("alt");t===""&&(t="<code>"+r.getAttribute("src").replace(wpa.ldHome,"")+"</code>");let n=document.body.className.split(/\s+/),l="";if(n.forEach(p=>{p.match(/postid-/gi)&&(l=p.replace("postid-","",p)),p.match(/page-id-/gi)&&(l=p.replace("page-id-","",p))}),l===""){let p=r.closest("article").className.split(/\s+/);p.length>0&&p.forEach(y=>{if(y.match(/post-/gi)){let L=y.replace("post-","",y);L.match(/^[0-9]+$/)&&(l=L)}})}let b=new URL(e);b.searchParams.set("referrer",l),b.toString(),[...r.classList].forEach(p=>{f.classList.add(p)}),d(r,f),r.setAttribute("alt",""),r.setAttribute("class","");let w=document.createElement("a");w.setAttribute("href",b),w.classList.add("longdesc-link");let u=document.createElement("span");if(u.classList.add("screen-reader-text"),u.textContent=" of "+t,w.textContent="Description",w.appendChild(u),wpa.ldType==="link")f.insertAdjacentElement("beforeend",w);else{f.insertAdjacentHTML("beforeend",'<button aria-expanded="false" class="wpa-toggle">'+wpa.ldText+"</button>"),f.insertAdjacentHTML("beforeend",'<div class="longdesc"></div>');let p=f.querySelector(".longdesc");p.style.display="none",fetch(e).then(y=>{if(y.ok)return y.text();p.insertAdjacentHTML("beforeend",s)}).then(y=>{let v=new DOMParser().parseFromString(y,"text/html");p.insertAdjacentElement("beforeend",v.querySelector("#desc_"+a))}),f.querySelector("button").addEventListener("click",function(y){p.checkVisibility()?(this.setAttribute("aria-expanded","false"),p.style.display="none"):(this.setAttribute("aria-expanded","true"),p.style.display="block")})}},d=(r,a)=>{r.parentElement.insertBefore(a,r),a.appendChild(r)},i=document.querySelectorAll("img[longdesc]");if(wpa.ldType==="link"){i.length>0&&i.forEach(a=>{let e=document.createElement("div");e.classList.add("wpa-ld");let s=a.getAttribute("longdesc"),f=a.getAttribute("alt"),t=[...a.classList];d(a,e),t.forEach(b=>{e.classList.add(b)}),a.setAttribute("class","");let n=document.createElement("a");n.setAttribute("href",s),n.classList.add("longdesc-link");let l=document.createElement("span");l.classList.add("screen-reader-text"),l.textContent=" of "+f,n.textContent="Description",n.appendChild(l),a.insertAdjacentElement("afterend",n)});let r=document.querySelectorAll("figure.is-style-longdesc");r.length>0&&r.forEach(a=>{let e=a.querySelector("img");o(e)})}else{i.length>0&&i.forEach(a=>{o(a)});let r=document.querySelectorAll("figure.is-style-longdesc");r.length>0&&r.forEach(a=>{let e=a.querySelector("img");o(e)})}}document.addEventListener("wpa_fontsize_changed",function(d){k(d.detail.change,d.detail.factor)});function k(d="increase",i=1.6){let o=document.getElementById("wpadminbar"),c=document.querySelector(".a11y-toolbar"),r=t=>{for(;t;){if(t.hasAttribute("data-wpa-resized"))return!0;t=t.parentElement}return!1},a=t=>{let l=window.getComputedStyle(t).getPropertyValue("font-size").replace("px",""),b="font-size: "+parseFloat(l)*i+"px !important";if(!r(t)&&d==="increase"){let g=t.style.fontSize;g?t.setAttribute("data-wpa-resized",g):t.setAttribute("data-wpa-resized","true"),t.style.cssText+=b}d==="reset"&&(t.style.removeProperty("font-size"),t.hasAttribute("data-wpa-resized")&&t.getAttribute("data-wpa-resized")!=="true"&&(t.style.fontSize=t.getAttribute("data-wpa-resized")),t.removeAttribute("data-wpa-resized"))},e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT,{acceptNode:function(t){let n=t.parentElement?t.parentElement.tagName:"";return["SCRIPT","STYLE","NOSCRIPT","SVG"].includes(n)||o&&o.contains(t)||c&&c.contains(t)?NodeFilter.FILTER_REJECT:t.textContent.trim().length>0||t.nodeType===Node.ELEMENT_NODE?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT}}),s=new Set;for(;e.nextNode();){let n=e.currentNode.parentElement;n&&!s.has(n)&&(s.add(n),a(n))}document.body.querySelectorAll("input, select, textarea").forEach(t=>{o&&o.contains(t)||c&&c.contains(t)||s.has(t)||(s.add(t),a(t))})}})();function S(m){let A="";if(m.nodeType===3||m.nodeType===4)A=m.nodeValue;else if(m.nodeType===1&&(m.tagName.toLowerCase()=="img"||m.tagName.toLowerCase()=="area"||m.tagName.toLowerCase()=="input"&&m.getAttribute("type")&&m.getAttribute("type").toLowerCase()=="image"))A=m.getAttribute("alt")||"";else if(m.nodeType===1&&!m.tagName.match(/^(script|style)$/i)){let h=m.childNodes;for(let E=0,x=h.length;E<x;E++){let k=m.getAttribute("aria-label");A+=k||S(h[E])+" "}}return A}function T(m){return new Promise(A=>{if(document.querySelector(m))return A(document.querySelector(m));let h=new MutationObserver(E=>{document.querySelector(m)&&(h.disconnect(),A(document.querySelector(m)))});h.observe(document.body,{childList:!0,subtree:!0})})}})();
Save File
Cancel