Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
subversal
/
wp-content-20250317205720
/
plugins
/
post-views-counter
/
js
:
frontend.min.js
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
var initPostViewsCounter=function(){(PostViewsCounter={promise:null,args:{},init:function(e){this.args=e;let t={},a="pvc_visits"+(!1!==e.multisite?"_"+parseInt(e.multisite):"");"cookieless"===e.dataStorage&&this.isLocalStorageAvailable()?(t.storage_type="cookieless",t.storage_data=this.readStorageData(a)):(t.storage_type="cookies",t.storage_data=this.readCookieData(a)),"rest_api"===e.mode?this.promise=this.request(e.requestURL,t,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8","X-WP-Nonce":e.nonce},a):(t.action="pvc-check-post",t.pvc_nonce=e.nonce,t.id=e.postID,this.promise=this.request(e.requestURL,t,"POST",{"Content-Type":"application/x-www-form-urlencoded; charset=utf-8"},a))},request:function(e,t,a,o,r=""){let n={method:a,mode:"cors",cache:"no-cache",credentials:"same-origin",headers:o,body:this.prepareRequestData(t)},i=this;return fetch(e,n).then(function(e){if(!e.ok)throw Error(e.statusText);return e.json()}).then(function(e){try{"object"==typeof e&&null!==e?"success"in e&&!1===e.success?(console.log("Request error"),console.log(e.data)):("cookieless"===i.args.dataStorage?i.saveStorageData.call(i,r,e.storage,e.type):i.saveCookieData(r,e.storage),i.triggerEvent("pvcCheckPost",e)):(console.log("Invalid object"),console.log(e))}catch(t){console.log("Invalid JSON data"),console.log(t)}}).catch(function(e){console.log("Invalid response"),console.log(e)})},prepareRequestData:function(e){return Object.keys(e).map(function(t){return encodeURIComponent(t)+"="+encodeURIComponent(e[t])}).join("&").replace(/%20/g,"+")},triggerEvent:function(e,t){let a=new CustomEvent(e,{bubbles:!0,detail:t});document.dispatchEvent(a)},saveStorageData:function(e,t,a){window.localStorage.setItem(e,JSON.stringify(t[a]))},readStorageData:function(e){let t=null;return null===(t=window.localStorage.getItem(e))&&(t=""),t},saveCookieData:function(e,t){var a="";if("https:"===document.location.protocol&&(a=";secure"),!1===t.hasOwnProperty("name")){console.log("Error saveCookieData");return}for(let o=0;o<t.name.length;o++){var r=new Date,n=parseInt(t.expiry[o]);n?n*=1e3:n=r.getTime()+864e5,r.setTime(n),document.cookie=t.name[o]+"="+t.value[o]+";expires="+r.toUTCString()+";path=/"+("/"===this.args.path?"":this.args.path)+";domain="+this.args.domain+a+";SameSite=Lax"}},readCookieData:function(e){var t=[];return document.cookie.split(";").forEach(function(a){var[o,r]=a.split("="),n=o.trim();RegExp(e+"\\[\\d+\\]").test(n)&&t.push(r)}),t.join("a")},isLocalStorageAvailable:function(){var e;try{return(e=window.localStorage).setItem("__pvcStorageTest",0),e.removeItem("__pvcStorageTest"),!0}catch(t){return t instanceof DOMException&&(22===t.code||1014===t.code||"QuotaExceededError"===t.name||"NS_ERROR_DOM_QUOTA_REACHED"===t.name)&&e&&0!==e.length}}}).init(pvcArgsFrontend)};document.addEventListener("DOMContentLoaded",initPostViewsCounter);