← Back
Editing: settingsDebug.min.js
/*! For license information please see settingsDebug.min.js.LICENSE.txt */ (()=>{"use strict";const e=wp.element,t=wp.i18n,r=(e,t)=>{let r,n,o=e.path;return"string"==typeof e.namespace&&"string"==typeof e.endpoint&&(r=e.namespace.replace(/^\/|\/$/g,""),n=e.endpoint.replace(/^\//,""),o=n?r+"/"+n:r),delete e.namespace,delete e.endpoint,t({...e,path:o})},n=wp.url;function o(e,t){return Promise.resolve(t?e.body:new window.Response(JSON.stringify(e.body),{status:200,statusText:"OK",headers:e.headers}))}const a=({path:e,url:t,...r},o)=>({...r,url:t&&(0,n.addQueryArgs)(t,o),path:e&&(0,n.addQueryArgs)(e,o)}),i=e=>e.json?e.json():Promise.reject(e),c=e=>{const{next:t}=(e=>{if(!e)return{};const t=e.match(/<([^>]+)>; rel="next"/);return t?{next:t[1]}:{}})(e.headers.get("link"));return t},u=async(e,t)=>{if(!1===e.parse)return t(e);if(!(e=>{const t=!!e.path&&-1!==e.path.indexOf("per_page=-1"),r=!!e.url&&-1!==e.url.indexOf("per_page=-1");return t||r})(e))return t(e);const r=await w({...a(e,{per_page:100}),parse:!1}),n=await i(r);if(!Array.isArray(n))return n;let o=c(r);if(!o)return n;let u=[].concat(n);for(;o;){const t=await w({...e,path:void 0,url:o,parse:!1}),r=await i(t);u=u.concat(r),o=c(t)}return u},s=new Set(["PATCH","PUT","DELETE"]),l="GET",h=(e,t=!0)=>Promise.resolve(((e,t=!0)=>t?204===e.status?null:e.json?e.json():Promise.reject(e):e)(e,t)).catch(e=>f(e,t));function f(e,r=!0){if(!r)throw e;return(e=>{const r={code:"invalid_json",message:(0,t.__)("The response is not a valid JSON response.")};if(!e||!e.json)throw r;return e.json().catch(()=>{throw r})})(e).then(e=>{const r={code:"unknown_error",message:(0,t.__)("An unknown error occurred.")};throw e||r})}const p={Accept:"application/json, */*;q=0.1"},d={credentials:"include"},y=[(e,t)=>("string"!=typeof e.url||(0,n.hasQueryArg)(e.url,"_locale")||(e.url=(0,n.addQueryArgs)(e.url,{_locale:"user"})),"string"!=typeof e.path||(0,n.hasQueryArg)(e.path,"_locale")||(e.path=(0,n.addQueryArgs)(e.path,{_locale:"user"})),t(e)),r,(e,t)=>{const{method:r=l}=e;return s.has(r.toUpperCase())&&(e={...e,headers:{...e.headers,"X-HTTP-Method-Override":r,"Content-Type":"application/json"},method:"POST"}),t(e)},u],g=e=>{if(e.status>=200&&e.status<300)return e;throw e};let m=e=>{const{url:r,path:n,data:o,parse:a=!0,...i}=e;let{body:c,headers:u}=e;return u={...p,...u},o&&(c=JSON.stringify(o),u["Content-Type"]="application/json"),window.fetch(r||n||window.location.href,{...d,...i,body:c,headers:u}).then(e=>Promise.resolve(e).then(g).catch(e=>f(e,a)).then(e=>h(e,a)),e=>{if(e&&"AbortError"===e.name)throw e;throw{code:"fetch_error",message:(0,t.__)("You are probably offline.")}})};function v(e){return y.reduceRight((e,t)=>r=>t(r,e),m)(e).catch(t=>"rest_cookie_invalid_nonce"!==t.code?Promise.reject(t):window.fetch(v.nonceEndpoint).then(g).then(e=>e.text()).then(t=>(v.nonceMiddleware.nonce=t,v(e))))}v.use=function(e){y.unshift(e)},v.setFetchHandler=function(e){m=e},v.createNonceMiddleware=function(e){const t=(e,r)=>{const{headers:n={}}=e;for(const o in n)if("x-wp-nonce"===o.toLowerCase()&&n[o]===t.nonce)return r(e);return r({...e,headers:{...n,"X-WP-Nonce":t.nonce}})};return t.nonce=e,t},v.createPreloadingMiddleware=function(e){const t=Object.fromEntries(Object.entries(e).map(([e,t])=>[(0,n.normalizePath)(e),t]));return(e,r)=>{const{parse:a=!0}=e;let i=e.path;if(!i&&e.url){const{rest_route:t,...r}=(0,n.getQueryArgs)(e.url);"string"==typeof t&&(i=(0,n.addQueryArgs)(t,r))}if("string"!=typeof i)return r(e);const c=e.method||"GET",u=(0,n.normalizePath)(i);if("GET"===c&&t[u]){const e=t[u];return delete t[u],o(e,!!a)}if("OPTIONS"===c&&t[c]&&t[c][u]){const e=t[c][u];return delete t[c][u],o(e,!!a)}return r(e)}},v.createRootURLMiddleware=e=>(t,n)=>r(t,t=>{let r,o=t.url,a=t.path;return"string"==typeof a&&(r=e,-1!==e.indexOf("?")&&(a=a.replace("?","&")),a=a.replace(/^\//,""),"string"==typeof r&&-1!==r.indexOf("?")&&(a=a.replace("?","&")),o=r+a),n({...t,url:o})}),v.fetchAllMiddleware=u,v.mediaUploadMiddleware=(e,r)=>{if(!function(e){const t=!!e.method&&"POST"===e.method;return(!!e.path&&-1!==e.path.indexOf("/wp/v2/media")||!!e.url&&-1!==e.url.indexOf("/wp/v2/media"))&&t}(e))return r(e);let n=0;const o=e=>(n++,r({path:`/wp/v2/media/${e}/post-process`,method:"POST",data:{action:"create-image-subsizes"},parse:!1}).catch(()=>n<5?o(e):(r({path:`/wp/v2/media/${e}?force=true`,method:"DELETE"}),Promise.reject())));return r({...e,parse:!1}).catch(r=>{const n=r.headers.get("x-wp-upload-attachment-id");return r.status>=500&&r.status<600&&n?o(n).catch(()=>!1!==e.parse?Promise.reject({code:"post_process",message:(0,t.__)("Media upload failed. If this is a photo or a large image, please scale it down and try again.")}):Promise.reject(r)):f(r,e.parse)}).then(t=>h(t,e.parse))},v.createThemePreviewMiddleware=e=>(t,r)=>{if("string"==typeof t.url){const r=(0,n.getQueryArg)(t.url,"wp_theme_preview");void 0===r?t.url=(0,n.addQueryArgs)(t.url,{wp_theme_preview:e}):""===r&&(t.url=(0,n.removeQueryArgs)(t.url,"wp_theme_preview"))}if("string"==typeof t.path){const r=(0,n.getQueryArg)(t.path,"wp_theme_preview");void 0===r?t.path=(0,n.addQueryArgs)(t.path,{wp_theme_preview:e}):""===r&&(t.path=(0,n.removeQueryArgs)(t.path,"wp_theme_preview"))}return r(t)};const w=v;function b(e){return b="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},b(e)}function _(){_=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(e,t,r){e[t]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",c=a.asyncIterator||"@@asyncIterator",u=a.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function l(e,t,r,n){var a=t&&t.prototype instanceof m?t:m,i=Object.create(a.prototype),c=new k(n||[]);return o(i,"_invoke",{value:A(e,r,c)}),i}function h(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=l;var f="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function m(){}function v(){}function w(){}var E={};s(E,i,function(){return this});var x=Object.getPrototypeOf,L=x&&x(x(N([])));L&&L!==r&&n.call(L,i)&&(E=L);var j=w.prototype=m.prototype=Object.create(E);function O(e){["next","throw","return"].forEach(function(t){s(e,t,function(e){return this._invoke(t,e)})})}function S(e,t){function r(o,a,i,c){var u=h(e[o],e,a);if("throw"!==u.type){var s=u.arg,l=s.value;return l&&"object"==b(l)&&n.call(l,"__await")?t.resolve(l.__await).then(function(e){r("next",e,i,c)},function(e){r("throw",e,i,c)}):t.resolve(l).then(function(e){s.value=e,i(s)},function(e){return r("throw",e,i,c)})}c(u.arg)}var a;o(this,"_invoke",{value:function(e,n){function o(){return new t(function(t,o){r(e,n,t,o)})}return a=a?a.then(o,o):o()}})}function A(t,r,n){var o=f;return function(a,i){if(o===d)throw Error("Generator is already running");if(o===y){if("throw"===a)throw i;return{value:e,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=P(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=d;var s=h(t,r,n);if("normal"===s.type){if(o=n.done?y:p,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=y,n.method="throw",n.arg=s.arg)}}}function P(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,t.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function R(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(R,this),this.reset(!0)}function N(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}throw new TypeError(b(t)+" is not iterable")}return v.prototype=w,o(j,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:v,configurable:!0}),v.displayName=s(w,u,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===v||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,s(e,u,"GeneratorFunction")),e.prototype=Object.create(j),e},t.awrap=function(e){return{__await:e}},O(S.prototype),s(S.prototype,c,function(){return this}),t.AsyncIterator=S,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new S(l(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then(function(e){return e.done?e.value:i.next()})},O(j),s(j,u,"Generator"),s(j,i,function(){return this}),s(j,"toString",function(){return"[object Generator]"}),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=N,k.prototype={constructor:k,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(T),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return c.type="throw",c.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),g},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),g}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;T(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:N(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),g}},t}function E(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function x(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return L(e,t);var r={}.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?L(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function L(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}var j=window.publishpressFutureSettingsDebug||{},O=j.text||{};function S(){var t=x((0,e.useState)(!1),2),r=t[0],n=t[1],o=x((0,e.useState)(10),2),a=o[0],i=o[1],c=x((0,e.useState)(!1),2),u=c[0],s=c[1],l=x((0,e.useState)(""),2),h=l[0],f=l[1],p=x((0,e.useState)(null),2),d=p[0],y=p[1],g=(0,e.useRef)(null),m=(0,e.useRef)(null),v=(0,e.useRef)(null),b=function(){var e,t=(e=_().mark(function e(){var t,r,n,o,a,i,c,u,l,h;return _().wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return n=(null===(t=document.getElementById("log-count"))||void 0===t?void 0:t.value)||500,o=document.querySelector('input[name="group_by_request"]:checked'),a=o?o.value:1,i=null!==(r=document.querySelector('input[name="trigger_activated_only"]'))&&void 0!==r&&r.checked?1:0,s(!0),f(""),e.prev=6,c=j.apiRoot||"",e.next=10,w({url:"".concat(c,"?log_count=").concat(n,"&group_by_request=").concat(a,"&trigger_activated_only=").concat(i),headers:{"X-WP-Nonce":j.nonce||""}});case 10:u=e.sent,(l=document.querySelector(".pp-debug-log textarea"))&&(u.log_text?l.value=u.log_text:0===u.total_logs_unfiltered?l.value=O.emptyLog||"Debugging table is currently empty.":l.value=O.noResults||"No results match the current filter.",l.scrollTop=l.scrollHeight),(h=document.getElementById("debug-log-length"))&&"string"==typeof u.footer_message&&(h.textContent=u.footer_message),m.current=Date.now(),y(0),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(6),f(O.refreshError||"Failed to refresh log data.");case 22:return e.prev=22,s(!1),e.finish(22);case 25:case"end":return e.stop()}},e,null,[[6,19,22,25]])}),function(){var t=this,r=arguments;return new Promise(function(n,o){var a=e.apply(t,r);function i(e){E(a,n,o,i,c,"next",e)}function c(e){E(a,n,o,i,c,"throw",e)}i(void 0)})});return function(){return t.apply(this,arguments)}}();return(0,e.useEffect)(function(){return r?(b(),g.current=window.setInterval(b,1e3*a),v.current=window.setInterval(function(){null!==m.current&&y(Math.floor((Date.now()-m.current)/1e3))},1e3)):(window.clearInterval(g.current),window.clearInterval(v.current),y(null)),function(){window.clearInterval(g.current),window.clearInterval(v.current)}},[r,a]),React.createElement("div",{className:"pp-debug-log-option pp-debug-log-autorefresh"},React.createElement("label",{className:"pp-checkbox-label"},React.createElement("input",{type:"checkbox",checked:r,onChange:function(e){return n(e.target.checked)}})," ",O.autoRefresh||"Auto-refresh"),r&&React.createElement(React.Fragment,null,React.createElement("label",{htmlFor:"pp-autorefresh-interval",style:{marginLeft:"10px"}},O.refreshInterval||"Refresh interval:"),React.createElement("select",{id:"pp-autorefresh-interval",value:a,onChange:function(e){return i(Number(e.target.value))},style:{marginLeft:"5px"}},React.createElement("option",{value:1},"1 ",O.seconds||"seconds"),React.createElement("option",{value:3},"3 ",O.seconds||"seconds"),React.createElement("option",{value:5},"5 ",O.seconds||"seconds"),React.createElement("option",{value:10},"10 ",O.seconds||"seconds"),React.createElement("option",{value:30},"30 ",O.seconds||"seconds"),React.createElement("option",{value:60},"60 ",O.seconds||"seconds")),u&&React.createElement("span",{style:{marginLeft:"10px",fontStyle:"italic"}},O.refreshing||"Refreshing..."),!u&&null!==d&&React.createElement("span",{style:{marginLeft:"10px",color:"#666"}},O.lastRefreshed||"Last refreshed:"," ",d," ",O.secondsAgo||"seconds ago"),h&&React.createElement("span",{style:{marginLeft:"10px",color:"red"}},h)))}var A=document.getElementById("pp-debug-log-autorefresh");A&&(0,e.createRoot)(A).render(React.createElement(S,null))})();
Save File
Cancel