Converter for Media – Optimize images | Convert WebP & AVIF - Version 4.1.2

Version Description

(2022-01-29) = * [Fixed] Validation of authorization token when images regeneration * [Fixed] Validation of loaded images using Pass Thru method

Download this release

Release Info

Developer mateuszgbiorczyk
Plugin Icon 128x128 Converter for Media – Optimize images | Convert WebP & AVIF
Version 4.1.2
Comparing to
See all releases

Code changes from version 4.1.1 to 4.1.2

assets/build/js/scripts.js CHANGED
@@ -1 +1 @@
1
- !function(){var e,t={669:function(e,t,r){e.exports=r(609)},448:function(e,t,r){"use strict";var n=r(867),o=r(26),i=r(372),s=r(327),a=r(97),u=r(109),c=r(985),f=r(61);e.exports=function(e){return new Promise((function(t,r){var l=e.data,d=e.headers,h=e.responseType;n.isFormData(l)&&delete d["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",v=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+v)}var g=a(e.baseURL,e.url);function b(){if(p){var n="getAllResponseHeaders"in p?u(p.getAllResponseHeaders()):null,i={data:h&&"text"!==h&&"json"!==h?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:n,config:e,request:p};o(t,r,i),p=null}}if(p.open(e.method.toUpperCase(),s(g,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,"onloadend"in p?p.onloadend=b:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(b)},p.onabort=function(){p&&(r(f("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(f("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var _=(e.withCredentials||c(g))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;_&&(d[e.xsrfHeaderName]=_)}"setRequestHeader"in p&&n.forEach(d,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),h&&"json"!==h&&(p.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),r(e),p=null)})),l||(l=null),p.send(l)}))}},609:function(e,t,r){"use strict";var n=r(867),o=r(849),i=r(321),s=r(185);function a(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var u=a(r(655));u.Axios=i,u.create=function(e){return a(s(u.defaults,e))},u.Cancel=r(263),u.CancelToken=r(972),u.isCancel=r(502),u.all=function(e){return Promise.all(e)},u.spread=r(713),u.isAxiosError=r(268),e.exports=u,e.exports.default=u},263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:function(e,t,r){"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:function(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:function(e,t,r){"use strict";var n=r(867),o=r(327),i=r(782),s=r(572),a=r(185),u=r(875),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!n){var f=[s,void 0];for(Array.prototype.unshift.apply(f,r),f=f.concat(i),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var l=e;r.length;){var d=r.shift(),h=r.shift();try{l=d(l)}catch(e){h(e);break}}try{o=s(l)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=f},782:function(e,t,r){"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:function(e,t,r){"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:function(e,t,r){"use strict";var n=r(481);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},572:function(e,t,r){"use strict";var n=r(867),o=r(527),i=r(502),s=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:function(e){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function u(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=u(void 0,t[e]))})),n.forEach(i,c),n.forEach(s,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=u(e[n],t[n]):n in e&&(r[n]=u(void 0,e[n]))}));var f=o.concat(i).concat(s).concat(a),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return n.forEach(l,c),r}},26:function(e,t,r){"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:function(e,t,r){"use strict";var n=r(867),o=r(655);e.exports=function(e,t,r){var i=this||o;return n.forEach(r,(function(r){e=r.call(i,e,t)})),e}},655:function(e,t,r){"use strict";var n=r(155),o=r(867),i=r(16),s=r(481),a={"Content-Type":"application/x-www-form-urlencoded"};function u(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,f={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==n&&"[object process]"===Object.prototype.toString.call(n))&&(c=r(448)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(u(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)||t&&"application/json"===t["Content-Type"]?(u(t,"application/json"),function(e,t,r){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw s(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};f.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],(function(e){f.headers[e]={}})),o.forEach(["post","put","patch"],(function(e){f.headers[e]=o.merge(a)})),e.exports=f},849:function(e){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},327:function(e,t,r){"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},303:function(e){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:function(e){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:function(e){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:function(e,t,r){"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:function(e,t,r){"use strict";var n=r(593),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={},s=n.version.split(".");function a(e,t){for(var r=t?t.split("."):s,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}o.transitional=function(e,t,r){var o=t&&a(t);return function(s,a,u){if(!1===e)throw new Error(function(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}(a," has been removed in "+t));return o&&!i[a]&&(i[a]=!0),!e||e(s,a,u)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:o}},867:function(e,t,r){"use strict";var n=r(849),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function r(r,n){u(t[n])&&u(r)?t[n]=e(t[n],r):u(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)f(arguments[n],r);return t},extend:function(e,t,r){return f(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},712:function(e,t,r){"use strict";var n=r(669),o=r.n(n);function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.section=document.querySelector("[data-calculate-widget]"),this.section)return this.button=this.section.querySelector("[data-calculate-widget-button]"),this.loading=this.section.querySelector("[data-calculate-widget-loading]"),this.output=this.section.querySelector("[data-calculate-widget-output]"),this.settings={ajax:{url_calculation:this.section.getAttribute("data-calculate-widget-api")}},!0}},{key:"set_events",value:function(){this.button.addEventListener("click",this.init_calculation.bind(this))}},{key:"init_calculation",value:function(e){e.preventDefault(),this.button.setAttribute("hidden","hidden"),this.loading.removeAttribute("hidden"),this.send_request_for_calculation()}},{key:"send_request_for_calculation",value:function(){var e=this,t=this.settings.ajax.url_calculation;o()({method:"POST",url:t}).then((function(t){e.loading.setAttribute("hidden","hidden"),e.output.innerText=t.data.value_output,e.output.removeAttribute("hidden","hidden")})).catch((function(t){e.button.removeAttribute("hidden"),e.loading.setAttribute("hidden","hidden")}))}}])&&i(t.prototype,r),n&&i(t,n),e}();function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.notice=document.querySelector('.notice[data-notice="webp-converter-for-media"]'),this.notice)return this.settings={ajax_url:this.notice.getAttribute("data-url"),ajax_action:"webpc_notice",button_close_class:".notice-dismiss",button_hide_class:"[data-permanently]"},this.events={click_on_close:this.click_on_close.bind(this)},!0}},{key:"set_events",value:function(){this.notice.addEventListener("click",this.events.click_on_close)}},{key:"click_on_close",value:function(e){var t=this.settings,r=t.button_close_class,n=t.button_hide_class;this.notice.removeEventListener("click",this.events.click_on_close),e.target.matches(r)?this.hide_notice(!1):e.target.matches(n)&&this.hide_notice(!0)}},{key:"hide_notice",value:function(e){var t=this.settings.button_close_class;this.send_request(e),e&&this.notice.querySelector(t).click()}},{key:"send_request",value:function(e){var t=this.settings.ajax_url;o()({method:"POST",url:t,data:this.get_data_for_request(e)})}},{key:"get_data_for_request",value:function(e){var t=this.settings.ajax_action,r=new FormData;return r.append("action",t),r.append("is_permanently",e?1:0),r}}])&&a(t.prototype,r),n&&a(t,n),e}();function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.section=document.querySelector(".webpLoader"),this.section)return this.wrapper=this.section.querySelector(".webpLoader__status"),this.progress=this.wrapper.querySelector(".webpLoader__barProgress"),this.progress_size=this.section.querySelector(".webpLoader__sizeProgress"),this.errors=this.section.querySelector(".webpLoader__errors"),this.errors_inner=this.errors.querySelector(".webpLoader__errorsContent"),this.success=this.section.querySelector(".webpLoader__success"),this.success_popup=this.section.querySelector(".webpLoader__popup"),this.option_force=this.section.querySelector('input[name="regenerate_force"]'),this.button=this.section.querySelector(".webpLoader__button"),this.data={count:0,max:0,items:[],size:{before:0,after:0},errors:[]},this.settings={is_disabled:!1,ajax:{url_paths:this.section.getAttribute("data-api-paths"),url_regenerate:this.section.getAttribute("data-api-regenerate"),error_message:this.section.getAttribute("data-api-error-message")},units:["kB","MB","GB"]},this.atts={progress:"data-percent"},this.classes={progress_error:"webpLoader__barProgress--error",button_disabled:"webpLoader__button--disabled",error_message:"webpLoader__errorsContentError"},!0}},{key:"set_events",value:function(){this.button.addEventListener("click",this.init_regeneration.bind(this))}},{key:"init_regeneration",value:function(e){e.preventDefault(),this.settings.is_disabled||(this.settings.is_disabled=!0,this.button.classList.add(this.classes.button_disabled),this.option_force.setAttribute("disabled","disabled"),this.wrapper.removeAttribute("hidden"),this.send_request_for_paths())}},{key:"send_request_for_paths",value:function(){var e=this,t=this.settings.ajax.url_paths;o()({method:"POST",url:t,data:{regenerate_force:this.option_force.checked?1:0}}).then((function(t){e.data.items=t.data,e.data.max=t.data.length,e.regenerate_next_images()})).catch((function(t){e.catch_request_error(t,!0)}))}},{key:"regenerate_next_images",value:function(){if(0===this.data.max&&this.update_progress(),!(this.data.count>=this.data.max)){var e=this.data.items[this.data.count];this.data.count++,this.send_request_for_regeneration(e)}}},{key:"send_request_for_regeneration",value:function(e){var t=this,r=this.settings.ajax.url_regenerate;o()({method:"POST",url:r,data:{regenerate_force:this.option_force.checked?1:0,paths:e}}).then((function(e){var r=e.data.is_fatal_error;t.update_errors(e.data.errors,r),r||(t.update_size(e.data.size.before,e.data.size.after),t.update_progress(),t.regenerate_next_images())})).catch((function(r){t.catch_request_error(r,!1,e),t.regenerate_next_images()}))}},{key:"update_errors",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=0;r<e.length;r++)this.print_error_message(e[r],t);t&&this.set_fatal_error()}},{key:"set_fatal_error",value:function(){this.progress.classList.add(this.classes.progress_error)}},{key:"catch_request_error",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t&&(this.print_error_message([this.settings.ajax.error_message],!0),this.set_fatal_error());var n=null!==r?'["'.concat(r.join('", "'),'"]'):"";this.print_error_message("".concat(e.response.status," - ").concat(e.response.statusText," (").concat(e.response.config.url,") ").concat(n),!0,!0)}},{key:"print_error_message",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=document.createElement("p");if(r){var o=document.createElement("pre");o.innerText=e,n.appendChild(o)}else n.innerHTML=e;t&&n.classList.add(this.classes.error_message),this.errors.removeAttribute("hidden"),this.errors_inner.appendChild(n)}},{key:"update_size",value:function(e,t){var r=this.data.size;r.before+=e,r.after+=t;var n=r.before-r.after;if(n<0&&(n=0),0!==n){var o=Math.round(100*(1-r.after/r.before));o<0&&(o=0);var i=-1;do{i++,n/=1024}while(n>1024);var s=n.toFixed(2),a=this.settings.units[i];this.progress_size.innerHTML="".concat(s," ").concat(a," (").concat(o,"%)")}}},{key:"update_progress",value:function(){var e=this.data.max>0?Math.floor(this.data.count/this.data.max*100):100;e>100&&(e=100),100===e&&(this.success.removeAttribute("hidden"),this.success_popup&&this.success_popup.removeAttribute("hidden")),this.progress.setAttribute(this.atts.progress,e.toString())}}])&&c(t.prototype,r),n&&c(t,n),e}();new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new u,new f,new s}},694:function(){},155:function(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,u=[],c=!1,f=-1;function l(){c&&a&&(c=!1,a.length?u=a.concat(u):f=-1,u.length&&d())}function d(){if(!c){var e=s(l);c=!0;for(var t=u.length;t;){for(a=u,u=[];++f<t;)a&&a[f].run();f=-1,t=u.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||c||s(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},593:function(e){"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=function(t,r,o,i){if(!r){var s=1/0;for(f=0;f<e.length;f++){r=e[f][0],o=e[f][1],i=e[f][2];for(var a=!0,u=0;u<r.length;u++)(!1&i||s>=i)&&Object.keys(n.O).every((function(e){return n.O[e](r[u])}))?r.splice(u--,1):(a=!1,i<s&&(s=i));if(a){e.splice(f--,1);var c=o();void 0!==c&&(t=c)}}return t}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[r,o,i]},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={794:0,505:0};n.O.j=function(t){return 0===e[t]};var t=function(t,r){var o,i,s=r[0],a=r[1],u=r[2],c=0;if(s.some((function(t){return 0!==e[t]}))){for(o in a)n.o(a,o)&&(n.m[o]=a[o]);if(u)var f=u(n)}for(t&&t(r);c<s.length;c++)i=s[c],n.o(e,i)&&e[i]&&e[i][0](),e[s[c]]=0;return n.O(f)},r=self.webpackChunkwebp_converter_for_media=self.webpackChunkwebp_converter_for_media||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}(),n.O(void 0,[505],(function(){return n(712)}));var o=n.O(void 0,[505],(function(){return n(694)}));o=n.O(o)}();
1
+ !function(){var e,t={669:function(e,t,r){e.exports=r(609)},448:function(e,t,r){"use strict";var n=r(867),o=r(26),i=r(372),s=r(327),a=r(97),u=r(109),c=r(985),f=r(61);e.exports=function(e){return new Promise((function(t,r){var l=e.data,d=e.headers,h=e.responseType;n.isFormData(l)&&delete d["Content-Type"];var p=new XMLHttpRequest;if(e.auth){var m=e.auth.username||"",v=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";d.Authorization="Basic "+btoa(m+":"+v)}var g=a(e.baseURL,e.url);function b(){if(p){var n="getAllResponseHeaders"in p?u(p.getAllResponseHeaders()):null,i={data:h&&"text"!==h&&"json"!==h?p.response:p.responseText,status:p.status,statusText:p.statusText,headers:n,config:e,request:p};o(t,r,i),p=null}}if(p.open(e.method.toUpperCase(),s(g,e.params,e.paramsSerializer),!0),p.timeout=e.timeout,"onloadend"in p?p.onloadend=b:p.onreadystatechange=function(){p&&4===p.readyState&&(0!==p.status||p.responseURL&&0===p.responseURL.indexOf("file:"))&&setTimeout(b)},p.onabort=function(){p&&(r(f("Request aborted",e,"ECONNABORTED",p)),p=null)},p.onerror=function(){r(f("Network Error",e,null,p)),p=null},p.ontimeout=function(){var t="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(f(t,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",p)),p=null},n.isStandardBrowserEnv()){var _=(e.withCredentials||c(g))&&e.xsrfCookieName?i.read(e.xsrfCookieName):void 0;_&&(d[e.xsrfHeaderName]=_)}"setRequestHeader"in p&&n.forEach(d,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete d[t]:p.setRequestHeader(t,e)})),n.isUndefined(e.withCredentials)||(p.withCredentials=!!e.withCredentials),h&&"json"!==h&&(p.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&p.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&p.upload&&p.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){p&&(p.abort(),r(e),p=null)})),l||(l=null),p.send(l)}))}},609:function(e,t,r){"use strict";var n=r(867),o=r(849),i=r(321),s=r(185);function a(e){var t=new i(e),r=o(i.prototype.request,t);return n.extend(r,i.prototype,t),n.extend(r,t),r}var u=a(r(655));u.Axios=i,u.create=function(e){return a(s(u.defaults,e))},u.Cancel=r(263),u.CancelToken=r(972),u.isCancel=r(502),u.all=function(e){return Promise.all(e)},u.spread=r(713),u.isAxiosError=r(268),e.exports=u,e.exports.default=u},263:function(e){"use strict";function t(e){this.message=e}t.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},t.prototype.__CANCEL__=!0,e.exports=t},972:function(e,t,r){"use strict";var n=r(263);function o(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}o.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},o.source=function(){var e;return{token:new o((function(t){e=t})),cancel:e}},e.exports=o},502:function(e){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},321:function(e,t,r){"use strict";var n=r(867),o=r(327),i=r(782),s=r(572),a=r(185),u=r(875),c=u.validators;function f(e){this.defaults=e,this.interceptors={request:new i,response:new i}}f.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=a(this.defaults,e)).method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var t=e.transitional;void 0!==t&&u.assertOptions(t,{silentJSONParsing:c.transitional(c.boolean,"1.0.0"),forcedJSONParsing:c.transitional(c.boolean,"1.0.0"),clarifyTimeoutError:c.transitional(c.boolean,"1.0.0")},!1);var r=[],n=!0;this.interceptors.request.forEach((function(t){"function"==typeof t.runWhen&&!1===t.runWhen(e)||(n=n&&t.synchronous,r.unshift(t.fulfilled,t.rejected))}));var o,i=[];if(this.interceptors.response.forEach((function(e){i.push(e.fulfilled,e.rejected)})),!n){var f=[s,void 0];for(Array.prototype.unshift.apply(f,r),f=f.concat(i),o=Promise.resolve(e);f.length;)o=o.then(f.shift(),f.shift());return o}for(var l=e;r.length;){var d=r.shift(),h=r.shift();try{l=d(l)}catch(e){h(e);break}}try{o=s(l)}catch(e){return Promise.reject(e)}for(;i.length;)o=o.then(i.shift(),i.shift());return o},f.prototype.getUri=function(e){return e=a(this.defaults,e),o(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){f.prototype[e]=function(t,r){return this.request(a(r||{},{method:e,url:t,data:(r||{}).data}))}})),n.forEach(["post","put","patch"],(function(e){f.prototype[e]=function(t,r,n){return this.request(a(n||{},{method:e,url:t,data:r}))}})),e.exports=f},782:function(e,t,r){"use strict";var n=r(867);function o(){this.handlers=[]}o.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},o.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},o.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=o},97:function(e,t,r){"use strict";var n=r(793),o=r(303);e.exports=function(e,t){return e&&!n(t)?o(e,t):t}},61:function(e,t,r){"use strict";var n=r(481);e.exports=function(e,t,r,o,i){var s=new Error(e);return n(s,t,r,o,i)}},572:function(e,t,r){"use strict";var n=r(867),o=r(527),i=r(502),s=r(655);function a(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return a(e),e.headers=e.headers||{},e.data=o.call(e,e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||s.adapter)(e).then((function(t){return a(e),t.data=o.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return i(t)||(a(e),t&&t.response&&(t.response.data=o.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},481:function(e){"use strict";e.exports=function(e,t,r,n,o){return e.config=t,r&&(e.code=r),e.request=n,e.response=o,e.isAxiosError=!0,e.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},e}},185:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){t=t||{};var r={},o=["url","method","data"],i=["headers","auth","proxy","params"],s=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function u(e,t){return n.isPlainObject(e)&&n.isPlainObject(t)?n.merge(e,t):n.isPlainObject(t)?n.merge({},t):n.isArray(t)?t.slice():t}function c(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(e[o],t[o])}n.forEach(o,(function(e){n.isUndefined(t[e])||(r[e]=u(void 0,t[e]))})),n.forEach(i,c),n.forEach(s,(function(o){n.isUndefined(t[o])?n.isUndefined(e[o])||(r[o]=u(void 0,e[o])):r[o]=u(void 0,t[o])})),n.forEach(a,(function(n){n in t?r[n]=u(e[n],t[n]):n in e&&(r[n]=u(void 0,e[n]))}));var f=o.concat(i).concat(s).concat(a),l=Object.keys(e).concat(Object.keys(t)).filter((function(e){return-1===f.indexOf(e)}));return n.forEach(l,c),r}},26:function(e,t,r){"use strict";var n=r(61);e.exports=function(e,t,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?t(n("Request failed with status code "+r.status,r.config,null,r.request,r)):e(r)}},527:function(e,t,r){"use strict";var n=r(867),o=r(655);e.exports=function(e,t,r){var i=this||o;return n.forEach(r,(function(r){e=r.call(i,e,t)})),e}},655:function(e,t,r){"use strict";var n=r(155),o=r(867),i=r(16),s=r(481),a={"Content-Type":"application/x-www-form-urlencoded"};function u(e,t){!o.isUndefined(e)&&o.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var c,f={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:(("undefined"!=typeof XMLHttpRequest||void 0!==n&&"[object process]"===Object.prototype.toString.call(n))&&(c=r(448)),c),transformRequest:[function(e,t){return i(t,"Accept"),i(t,"Content-Type"),o.isFormData(e)||o.isArrayBuffer(e)||o.isBuffer(e)||o.isStream(e)||o.isFile(e)||o.isBlob(e)?e:o.isArrayBufferView(e)?e.buffer:o.isURLSearchParams(e)?(u(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):o.isObject(e)||t&&"application/json"===t["Content-Type"]?(u(t,"application/json"),function(e,t,r){if(o.isString(e))try{return(t||JSON.parse)(e),o.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,i=!r&&"json"===this.responseType;if(i||n&&o.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(i){if("SyntaxError"===e.name)throw s(e,this,"E_JSON_PARSE");throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};f.headers={common:{Accept:"application/json, text/plain, */*"}},o.forEach(["delete","get","head"],(function(e){f.headers[e]={}})),o.forEach(["post","put","patch"],(function(e){f.headers[e]=o.merge(a)})),e.exports=f},849:function(e){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},327:function(e,t,r){"use strict";var n=r(867);function o(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var i;if(r)i=r(t);else if(n.isURLSearchParams(t))i=t.toString();else{var s=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),s.push(o(t)+"="+o(e))})))})),i=s.join("&")}if(i){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}},303:function(e){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},372:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,o,i,s){var a=[];a.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),n.isString(o)&&a.push("path="+o),n.isString(i)&&a.push("domain="+i),!0===s&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},793:function(e){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},268:function(e){"use strict";e.exports=function(e){return"object"==typeof e&&!0===e.isAxiosError}},985:function(e,t,r){"use strict";var n=r(867);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=o(window.location.href),function(t){var r=n.isString(t)?o(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},16:function(e,t,r){"use strict";var n=r(867);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},109:function(e,t,r){"use strict";var n=r(867),o=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];e.exports=function(e){var t,r,i,s={};return e?(n.forEach(e.split("\n"),(function(e){if(i=e.indexOf(":"),t=n.trim(e.substr(0,i)).toLowerCase(),r=n.trim(e.substr(i+1)),t){if(s[t]&&o.indexOf(t)>=0)return;s[t]="set-cookie"===t?(s[t]?s[t]:[]).concat([r]):s[t]?s[t]+", "+r:r}})),s):s}},713:function(e){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},875:function(e,t,r){"use strict";var n=r(593),o={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){o[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var i={},s=n.version.split(".");function a(e,t){for(var r=t?t.split("."):s,n=e.split("."),o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}o.transitional=function(e,t,r){var o=t&&a(t);return function(s,a,u){if(!1===e)throw new Error(function(e,t){return"[Axios v"+n.version+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}(a," has been removed in "+t));return o&&!i[a]&&(i[a]=!0),!e||e(s,a,u)}},e.exports={isOlderVersion:a,assertOptions:function(e,t,r){if("object"!=typeof e)throw new TypeError("options must be an object");for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new TypeError("option "+i+" must be "+u)}else if(!0!==r)throw Error("Unknown option "+i)}},validators:o}},867:function(e,t,r){"use strict";var n=r(849),o=Object.prototype.toString;function i(e){return"[object Array]"===o.call(e)}function s(e){return void 0===e}function a(e){return null!==e&&"object"==typeof e}function u(e){if("[object Object]"!==o.call(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}function c(e){return"[object Function]"===o.call(e)}function f(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===o.call(e)},isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:a,isPlainObject:u,isUndefined:s,isDate:function(e){return"[object Date]"===o.call(e)},isFile:function(e){return"[object File]"===o.call(e)},isBlob:function(e){return"[object Blob]"===o.call(e)},isFunction:c,isStream:function(e){return a(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:f,merge:function e(){var t={};function r(r,n){u(t[n])&&u(r)?t[n]=e(t[n],r):u(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)f(arguments[n],r);return t},extend:function(e,t,r){return f(t,(function(t,o){e[o]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e}}},712:function(e,t,r){"use strict";var n=r(669),o=r.n(n);function i(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var s=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.section=document.querySelector("[data-calculate-widget]"),this.section)return this.button=this.section.querySelector("[data-calculate-widget-button]"),this.loading=this.section.querySelector("[data-calculate-widget-loading]"),this.output=this.section.querySelector("[data-calculate-widget-output]"),this.settings={ajax:{url_calculation:this.section.getAttribute("data-calculate-widget-api")}},!0}},{key:"set_events",value:function(){this.button.addEventListener("click",this.init_calculation.bind(this))}},{key:"init_calculation",value:function(e){e.preventDefault(),this.button.setAttribute("hidden","hidden"),this.loading.removeAttribute("hidden"),this.send_request_for_calculation()}},{key:"send_request_for_calculation",value:function(){var e=this,t=this.settings.ajax.url_calculation;o()({method:"POST",url:t}).then((function(t){e.loading.setAttribute("hidden","hidden"),e.output.innerText=t.data.value_output,e.output.removeAttribute("hidden","hidden")})).catch((function(t){e.button.removeAttribute("hidden"),e.loading.setAttribute("hidden","hidden")}))}}])&&i(t.prototype,r),n&&i(t,n),e}();function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var u=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.notice=document.querySelector('.notice[data-notice="webp-converter-for-media"]'),this.notice)return this.settings={ajax_url:this.notice.getAttribute("data-url"),ajax_action:"webpc_notice",button_close_class:".notice-dismiss",button_hide_class:"[data-permanently]"},this.events={click_on_close:this.click_on_close.bind(this)},!0}},{key:"set_events",value:function(){this.notice.addEventListener("click",this.events.click_on_close)}},{key:"click_on_close",value:function(e){var t=this.settings,r=t.button_close_class,n=t.button_hide_class;this.notice.removeEventListener("click",this.events.click_on_close),e.target.matches(r)?this.hide_notice(!1):e.target.matches(n)&&this.hide_notice(!0)}},{key:"hide_notice",value:function(e){var t=this.settings.button_close_class;this.send_request(e),e&&this.notice.querySelector(t).click()}},{key:"send_request",value:function(e){var t=this.settings.ajax_url;o()({method:"POST",url:t,data:this.get_data_for_request(e)})}},{key:"get_data_for_request",value:function(e){var t=this.settings.ajax_action,r=new FormData;return r.append("action",t),r.append("is_permanently",e?1:0),r}}])&&a(t.prototype,r),n&&a(t,n),e}();function c(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}var f=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.set_vars()&&this.set_events()}var t,r,n;return t=e,(r=[{key:"set_vars",value:function(){if(this.section=document.querySelector(".webpLoader"),this.section)return this.wrapper=this.section.querySelector(".webpLoader__status"),this.progress=this.wrapper.querySelector(".webpLoader__barProgress"),this.progress_size=this.section.querySelector(".webpLoader__sizeProgress"),this.errors=this.section.querySelector(".webpLoader__errors"),this.errors_inner=this.errors.querySelector(".webpLoader__errorsContent"),this.success=this.section.querySelector(".webpLoader__success"),this.success_popup=this.section.querySelector(".webpLoader__popup"),this.option_force=this.section.querySelector('input[name="regenerate_force"]'),this.button=this.section.querySelector(".webpLoader__button"),this.data={count:0,max:0,items:[],size:{before:0,after:0},errors:[]},this.settings={is_disabled:!1,ajax:{url_paths:this.section.getAttribute("data-api-paths"),url_regenerate:this.section.getAttribute("data-api-regenerate"),error_message:this.section.getAttribute("data-api-error-message")},units:["kB","MB","GB"]},this.atts={progress:"data-percent"},this.classes={progress_error:"webpLoader__barProgress--error",button_disabled:"webpLoader__button--disabled",error_message:"webpLoader__errorsContentError"},!0}},{key:"set_events",value:function(){this.button.addEventListener("click",this.init_regeneration.bind(this))}},{key:"init_regeneration",value:function(e){e.preventDefault(),this.settings.is_disabled||(this.settings.is_disabled=!0,this.button.classList.add(this.classes.button_disabled),this.option_force.setAttribute("disabled","disabled"),this.wrapper.removeAttribute("hidden"),this.send_request_for_paths())}},{key:"send_request_for_paths",value:function(){var e=this,t=this.settings.ajax.url_paths;o()({method:"POST",url:t,data:{regenerate_force:this.option_force.checked?1:0}}).then((function(t){e.data.items=t.data,e.data.max=t.data.length,e.regenerate_next_images()})).catch((function(t){e.catch_request_error(t,!0)}))}},{key:"regenerate_next_images",value:function(){if(0===this.data.max&&this.update_progress(),!(this.data.count>=this.data.max)){var e=this.data.items[this.data.count];this.data.count++,this.send_request_for_regeneration(e)}}},{key:"send_request_for_regeneration",value:function(e){var t=this,r=this.settings.ajax.url_regenerate;o()({method:"POST",url:r,data:{regenerate_force:this.option_force.checked?1:0,paths:e}}).then((function(e){var r=e.data.is_fatal_error;t.update_errors(e.data.errors,r),r||(t.update_size(e.data.size.before,e.data.size.after),t.update_progress(),t.regenerate_next_images())})).catch((function(r){t.catch_request_error(r,!1,e),setTimeout(t.regenerate_next_images.bind(t),1e3)}))}},{key:"update_errors",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=0;r<e.length;r++)this.print_error_message(e[r],t);t&&this.set_fatal_error()}},{key:"set_fatal_error",value:function(){this.progress.classList.add(this.classes.progress_error)}},{key:"catch_request_error",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;t&&(this.print_error_message([this.settings.ajax.error_message],!0),this.set_fatal_error());var n=null!==r?'["'.concat(r.join('", "'),'"]'):"";this.print_error_message("".concat(e.response.status," - ").concat(e.response.statusText," (").concat(e.response.config.url,") ").concat(n),!0,!0)}},{key:"print_error_message",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=document.createElement("p");if(r){var o=document.createElement("pre");o.innerText=e,n.appendChild(o)}else n.innerHTML=e;t&&n.classList.add(this.classes.error_message),this.errors.removeAttribute("hidden"),this.errors_inner.appendChild(n)}},{key:"update_size",value:function(e,t){var r=this.data.size;r.before+=e,r.after+=t;var n=r.before-r.after;if(n<0&&(n=0),0!==n){var o=Math.round(100*(1-r.after/r.before));o<0&&(o=0);var i=-1;do{i++,n/=1024}while(n>1024);var s=n.toFixed(2),a=this.settings.units[i];this.progress_size.innerHTML="".concat(s," ").concat(a," (").concat(o,"%)")}}},{key:"update_progress",value:function(){var e=this.data.max>0?Math.floor(this.data.count/this.data.max*100):100;e>100&&(e=100),100===e&&(this.success.removeAttribute("hidden"),this.success_popup&&this.success_popup.removeAttribute("hidden")),this.progress.setAttribute(this.atts.progress,e.toString())}}])&&c(t.prototype,r),n&&c(t,n),e}();new function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),new u,new f,new s}},694:function(){},155:function(e){var t,r,n=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===o||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:o}catch(e){t=o}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var a,u=[],c=!1,f=-1;function l(){c&&a&&(c=!1,a.length?u=a.concat(u):f=-1,u.length&&d())}function d(){if(!c){var e=s(l);c=!0;for(var t=u.length;t;){for(a=u,u=[];++f<t;)a&&a[f].run();f=-1,t=u.length}a=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function h(e,t){this.fun=e,this.array=t}function p(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new h(e,t)),1!==u.length||c||s(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=p,n.addListener=p,n.once=p,n.off=p,n.removeListener=p,n.removeAllListeners=p,n.emit=p,n.prependListener=p,n.prependOnceListener=p,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},593:function(e){"use strict";e.exports=JSON.parse('{"name":"axios","version":"0.21.4","description":"Promise based HTTP client for the browser and node.js","main":"index.js","scripts":{"test":"grunt test","start":"node ./sandbox/server.js","build":"NODE_ENV=production grunt build","preversion":"npm test","version":"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json","postversion":"git push && git push --tags","examples":"node ./examples/server.js","coveralls":"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js","fix":"eslint --fix lib/**/*.js"},"repository":{"type":"git","url":"https://github.com/axios/axios.git"},"keywords":["xhr","http","ajax","promise","node"],"author":"Matt Zabriskie","license":"MIT","bugs":{"url":"https://github.com/axios/axios/issues"},"homepage":"https://axios-http.com","devDependencies":{"coveralls":"^3.0.0","es6-promise":"^4.2.4","grunt":"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1","karma":"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2","minimist":"^1.2.0","mocha":"^8.2.1","sinon":"^4.5.0","terser-webpack-plugin":"^4.2.3","typescript":"^4.0.5","url-search-params":"^0.10.0","webpack":"^4.44.2","webpack-dev-server":"^3.11.0"},"browser":{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},"jsdelivr":"dist/axios.min.js","unpkg":"dist/axios.min.js","typings":"./index.d.ts","dependencies":{"follow-redirects":"^1.14.0"},"bundlesize":[{"path":"./dist/axios.min.js","threshold":"5kB"}]}')}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.m=t,e=[],n.O=function(t,r,o,i){if(!r){var s=1/0;for(f=0;f<e.length;f++){r=e[f][0],o=e[f][1],i=e[f][2];for(var a=!0,u=0;u<r.length;u++)(!1&i||s>=i)&&Object.keys(n.O).every((function(e){return n.O[e](r[u])}))?r.splice(u--,1):(a=!1,i<s&&(s=i));if(a){e.splice(f--,1);var c=o();void 0!==c&&(t=c)}}return t}i=i||0;for(var f=e.length;f>0&&e[f-1][2]>i;f--)e[f]=e[f-1];e[f]=[r,o,i]},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e={794:0,505:0};n.O.j=function(t){return 0===e[t]};var t=function(t,r){var o,i,s=r[0],a=r[1],u=r[2],c=0;if(s.some((function(t){return 0!==e[t]}))){for(o in a)n.o(a,o)&&(n.m[o]=a[o]);if(u)var f=u(n)}for(t&&t(r);c<s.length;c++)i=s[c],n.o(e,i)&&e[i]&&e[i][0](),e[s[c]]=0;return n.O(f)},r=self.webpackChunkwebp_converter_for_media=self.webpackChunkwebp_converter_for_media||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))}(),n.O(void 0,[505],(function(){return n(712)}));var o=n.O(void 0,[505],(function(){return n(694)}));o=n.O(o)}();
changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  == Changelog ==
2
 
 
 
 
 
3
  = 4.1.1 (2022-01-19) =
4
  * `[Fixed]` Loading images with special character in filename using Pass Thru method
5
  * `[Changed]` Error messages on plugin settings page
1
  == Changelog ==
2
 
3
+ = 4.1.2 (2022-01-29) =
4
+ * `[Fixed]` Validation of authorization token when images regeneration
5
+ * `[Fixed]` Validation of loaded images using Pass Thru method
6
+
7
  = 4.1.1 (2022-01-19) =
8
  * `[Fixed]` Loading images with special character in filename using Pass Thru method
9
  * `[Changed]` Error messages on plugin settings page
includes/passthru.php CHANGED
@@ -18,25 +18,28 @@ class PassthruLoader {
18
  const MIME_TYPES = '';
19
 
20
  public function __construct() {
 
 
 
 
 
21
  $image_url = $_GET['src'] ?? null; // phpcs:ignore WordPress.Security
22
- if ( ! $image_url || ! $this->validate_url( $image_url ) ) {
23
  return;
24
- } elseif ( ! $this->validate_src_param( $image_url ) ) {
25
- $this->load_image_default( $image_url );
26
  }
27
 
28
  $this->load_converted_image( $image_url );
29
  }
30
 
31
- private function validate_url( string $image_url ): bool {
32
  $url_path = parse_url( $image_url, PHP_URL_PATH ) ?: '';
33
  $encoded_path = array_map( 'urlencode', explode( '/', $url_path ) );
34
  $encoded_url = str_replace( $url_path, implode( '/', $encoded_path ), $image_url );
35
 
36
- return ( filter_var( $encoded_url, FILTER_VALIDATE_URL ) !== false );
37
- }
 
38
 
39
- private function validate_src_param( string $image_url ): bool {
40
  $image_host = parse_url( $image_url, PHP_URL_HOST );
41
  if ( $image_host !== ( $_SERVER['HTTP_HOST'] ?? '' ) ) { // phpcs:ignore WordPress.Security
42
  return false;
18
  const MIME_TYPES = '';
19
 
20
  public function __construct() {
21
+ if ( ( self::PATH_UPLOADS === '' ) || ( self::PATH_UPLOADS_WEBP === '' ) || ( self::MIME_TYPES === '' ) ) {
22
+ http_response_code( 404 );
23
+ exit;
24
+ }
25
+
26
  $image_url = $_GET['src'] ?? null; // phpcs:ignore WordPress.Security
27
+ if ( ! $image_url || ! $this->validate_src_param( $image_url ) ) {
28
  return;
 
 
29
  }
30
 
31
  $this->load_converted_image( $image_url );
32
  }
33
 
34
+ private function validate_src_param( string $image_url ): bool {
35
  $url_path = parse_url( $image_url, PHP_URL_PATH ) ?: '';
36
  $encoded_path = array_map( 'urlencode', explode( '/', $url_path ) );
37
  $encoded_url = str_replace( $url_path, implode( '/', $encoded_path ), $image_url );
38
 
39
+ if ( filter_var( $encoded_url, FILTER_VALIDATE_URL ) === false ) {
40
+ return false;
41
+ }
42
 
 
43
  $image_host = parse_url( $image_url, PHP_URL_HOST );
44
  if ( $image_host !== ( $_SERVER['HTTP_HOST'] ?? '' ) ) { // phpcs:ignore WordPress.Security
45
  return false;
readme.txt CHANGED
@@ -392,6 +392,10 @@ This is all very important to us and allows us to do even better things for you!
392
 
393
  == Changelog ==
394
 
 
 
 
 
395
  = 4.1.1 (2022-01-19) =
396
  * `[Fixed]` Loading images with special character in filename using Pass Thru method
397
  * `[Changed]` Error messages on plugin settings page
392
 
393
  == Changelog ==
394
 
395
+ = 4.1.2 (2022-01-29) =
396
+ * `[Fixed]` Validation of authorization token when images regeneration
397
+ * `[Fixed]` Validation of loaded images using Pass Thru method
398
+
399
  = 4.1.1 (2022-01-19) =
400
  * `[Fixed]` Loading images with special character in filename using Pass Thru method
401
  * `[Changed]` Error messages on plugin settings page
src/Conversion/Endpoint/EndpointAbstract.php CHANGED
@@ -2,11 +2,20 @@
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
 
 
5
  /**
6
  * Abstract class for class that supports image conversion method.
7
  */
8
  abstract class EndpointAbstract implements EndpointInterface {
9
 
 
 
 
 
 
 
 
10
  /**
11
  * {@inheritdoc}
12
  */
@@ -18,13 +27,17 @@ abstract class EndpointAbstract implements EndpointInterface {
18
  * {@inheritdoc}
19
  */
20
  public function get_route_url(): string {
 
 
 
21
  return get_rest_url(
22
  null,
23
  sprintf(
24
- '%1$s/%2$s?_wpnonce=%3$s',
25
  EndpointIntegration::ROUTE_NAMESPACE,
26
  $this->get_route_name(),
27
- wp_create_nonce( 'wp_rest' )
 
28
  )
29
  );
30
  }
2
 
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
+ use WebpConverter\Service\NonceManager;
6
+
7
  /**
8
  * Abstract class for class that supports image conversion method.
9
  */
10
  abstract class EndpointAbstract implements EndpointInterface {
11
 
12
+ /**
13
+ * {@inheritdoc}
14
+ */
15
+ public function get_url_lifetime(): int {
16
+ return ( 24 * 60 * 60 );
17
+ }
18
+
19
  /**
20
  * {@inheritdoc}
21
  */
27
  * {@inheritdoc}
28
  */
29
  public function get_route_url(): string {
30
+ $nonce_value = ( new NonceManager( $this->get_url_lifetime(), false ) )
31
+ ->generate_nonce( sprintf( EndpointIntegration::ROUTE_NONCE_ACTION, $this->get_route_name() ) );
32
+
33
  return get_rest_url(
34
  null,
35
  sprintf(
36
+ '%1$s/%2$s?%3$s=%4$s',
37
  EndpointIntegration::ROUTE_NAMESPACE,
38
  $this->get_route_name(),
39
+ EndpointIntegration::ROUTE_NONCE_PARAM,
40
+ $nonce_value
41
  )
42
  );
43
  }
src/Conversion/Endpoint/EndpointIntegration.php CHANGED
@@ -3,13 +3,16 @@
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
  use WebpConverter\HookableInterface;
 
6
 
7
  /**
8
  * Integrates endpoint class by registering REST API route.
9
  */
10
  class EndpointIntegration implements HookableInterface {
11
 
12
- const ROUTE_NAMESPACE = 'webp-converter/v1';
 
 
13
 
14
  /**
15
  * Objects of supported REST API endpoints.
@@ -42,8 +45,11 @@ class EndpointIntegration implements HookableInterface {
42
  [
43
  'methods' => \WP_REST_Server::ALLMETHODS,
44
  'permission_callback' => function () {
45
- return ( wp_verify_nonce( $_REQUEST['_wpnonce'] ?? '', 'wp_rest' ) // phpcs:ignore
46
- && current_user_can( 'manage_options' ) );
 
 
 
47
  },
48
  'callback' => [ $this->endpoint_object, 'get_route_response' ],
49
  'args' => $this->endpoint_object->get_route_args(),
3
  namespace WebpConverter\Conversion\Endpoint;
4
 
5
  use WebpConverter\HookableInterface;
6
+ use WebpConverter\Service\NonceManager;
7
 
8
  /**
9
  * Integrates endpoint class by registering REST API route.
10
  */
11
  class EndpointIntegration implements HookableInterface {
12
 
13
+ const ROUTE_NAMESPACE = 'webp-converter/v1';
14
+ const ROUTE_NONCE_PARAM = 'nonce_token';
15
+ const ROUTE_NONCE_ACTION = 'webpc_rest-%s';
16
 
17
  /**
18
  * Objects of supported REST API endpoints.
45
  [
46
  'methods' => \WP_REST_Server::ALLMETHODS,
47
  'permission_callback' => function () {
48
+ return ( new NonceManager( $this->endpoint_object->get_url_lifetime(), false ) )
49
+ ->verify_nonce(
50
+ $_REQUEST[ self::ROUTE_NONCE_PARAM ] ?? '', // phpcs:ignore WordPress.Security
51
+ sprintf( self::ROUTE_NONCE_ACTION, $this->endpoint_object->get_route_name() )
52
+ );
53
  },
54
  'callback' => [ $this->endpoint_object, 'get_route_response' ],
55
  'args' => $this->endpoint_object->get_route_args(),
src/Conversion/Endpoint/EndpointInterface.php CHANGED
@@ -10,21 +10,28 @@ interface EndpointInterface {
10
  /**
11
  * Returns route of endpoint.
12
  *
13
- * @return string Endpoint route.
14
  */
15
  public function get_route_name(): string;
16
 
 
 
 
 
 
 
 
17
  /**
18
  * Returns list of params for endpoint.
19
  *
20
- * @return mixed[] Params of endpoint.
21
  */
22
  public function get_route_args(): array;
23
 
24
  /**
25
  * Returns URL of endpoint.
26
  *
27
- * @return string Endpoint URL.
28
  */
29
  public function get_route_url(): string;
30
 
@@ -33,7 +40,7 @@ interface EndpointInterface {
33
  *
34
  * @param \WP_REST_Request $request REST request object.
35
  *
36
- * @return \WP_REST_Response|\WP_Error REST response object or WordPress Error object.
37
  * @internal
38
  */
39
  public function get_route_response( \WP_REST_Request $request );
10
  /**
11
  * Returns route of endpoint.
12
  *
13
+ * @return string
14
  */
15
  public function get_route_name(): string;
16
 
17
+ /**
18
+ * Returns expiration time in seconds of endpoint URL.
19
+ *
20
+ * @return int
21
+ */
22
+ public function get_url_lifetime(): int;
23
+
24
  /**
25
  * Returns list of params for endpoint.
26
  *
27
+ * @return mixed[]
28
  */
29
  public function get_route_args(): array;
30
 
31
  /**
32
  * Returns URL of endpoint.
33
  *
34
+ * @return string
35
  */
36
  public function get_route_url(): string;
37
 
40
  *
41
  * @param \WP_REST_Request $request REST request object.
42
  *
43
+ * @return \WP_REST_Response|\WP_Error
44
  * @internal
45
  */
46
  public function get_route_response( \WP_REST_Request $request );
src/Conversion/Endpoint/RegenerateEndpoint.php CHANGED
@@ -26,6 +26,13 @@ class RegenerateEndpoint extends EndpointAbstract {
26
  return 'regenerate';
27
  }
28
 
 
 
 
 
 
 
 
29
  /**
30
  * {@inheritdoc}
31
  */
26
  return 'regenerate';
27
  }
28
 
29
+ /**
30
+ * {@inheritdoc}
31
+ */
32
+ public function get_url_lifetime(): int {
33
+ return ( 7 * 24 * 60 * 60 );
34
+ }
35
+
36
  /**
37
  * {@inheritdoc}
38
  */
src/Service/NonceManager.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace WebpConverter\Service;
4
+
5
+ /**
6
+ * Manages generation and validation of Nonce values.
7
+ */
8
+ class NonceManager {
9
+
10
+ /**
11
+ * @var int
12
+ */
13
+ private $nonce_lifetime = ( 24 * 60 * 60 );
14
+
15
+ /**
16
+ * @var bool
17
+ */
18
+ private $use_user;
19
+
20
+ public function __construct( int $nonce_lifetime = null, bool $use_user = true ) {
21
+ if ( $nonce_lifetime !== null ) {
22
+ $this->nonce_lifetime = $nonce_lifetime;
23
+ }
24
+ $this->use_user = $use_user;
25
+ }
26
+
27
+ public function generate_nonce( string $nonce_action ): string {
28
+ if ( ! $this->use_user ) {
29
+ $user_id = (int) wp_get_current_user()->ID;
30
+ wp_set_current_user( 0 );
31
+ }
32
+
33
+ add_filter( 'nonce_life', [ $this, 'set_nonce_lifetime' ] );
34
+ $nonce_value = wp_create_nonce( $nonce_action );
35
+ remove_filter( 'nonce_life', [ $this, 'set_nonce_lifetime' ] );
36
+
37
+ if ( ! $this->use_user && isset( $user_id ) ) {
38
+ wp_set_current_user( $user_id );
39
+ }
40
+
41
+ return $nonce_value;
42
+ }
43
+
44
+ public function verify_nonce( string $nonce_value, string $nonce_action ): bool {
45
+ if ( ! $this->use_user ) {
46
+ $user_id = (int) wp_get_current_user()->ID;
47
+ wp_set_current_user( 0 );
48
+ }
49
+
50
+ add_filter( 'nonce_life', [ $this, 'set_nonce_lifetime' ] );
51
+ $nonce_status = wp_verify_nonce( $nonce_value, $nonce_action );
52
+ remove_filter( 'nonce_life', [ $this, 'set_nonce_lifetime' ] );
53
+
54
+ if ( ! $this->use_user && isset( $user_id ) ) {
55
+ wp_set_current_user( $user_id );
56
+ }
57
+
58
+ return (bool) $nonce_status;
59
+ }
60
+
61
+ /**
62
+ * @internal
63
+ */
64
+ public function set_nonce_lifetime(): int {
65
+ return $this->nonce_lifetime;
66
+ }
67
+ }
src/Settings/Page/DebugPage.php CHANGED
@@ -10,7 +10,6 @@ use WebpConverter\PluginData;
10
  use WebpConverter\PluginInfo;
11
  use WebpConverter\Service\FileLoader;
12
  use WebpConverter\Service\ViewLoader;
13
- use WebpConverter\Settings\SettingsSave;
14
 
15
  /**
16
  * Supports debug tab in plugin settings page.
@@ -64,16 +63,8 @@ class DebugPage extends PageAbstract {
64
  ( new ViewLoader( $this->plugin_info ) )->load_view(
65
  self::PAGE_VIEW_PATH,
66
  [
67
- 'settings_url' => sprintf(
68
- '%1$s&%2$s=%3$s',
69
- PageIntegration::get_settings_page_url(),
70
- SettingsSave::NONCE_PARAM_KEY,
71
- wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
72
- ),
73
- 'settings_debug_url' => sprintf(
74
- '%s&action=server',
75
- PageIntegration::get_settings_page_url()
76
- ),
77
  'site_root_path' => $this->paths_generator->get_wordpress_root_path(),
78
  'size_png_path' => $this->file_loader->get_file_size_by_path(
79
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG
10
  use WebpConverter\PluginInfo;
11
  use WebpConverter\Service\FileLoader;
12
  use WebpConverter\Service\ViewLoader;
 
13
 
14
  /**
15
  * Supports debug tab in plugin settings page.
63
  ( new ViewLoader( $this->plugin_info ) )->load_view(
64
  self::PAGE_VIEW_PATH,
65
  [
66
+ 'settings_url' => PageIntegration::get_settings_page_url(),
67
+ 'settings_debug_url' => PageIntegration::get_settings_page_url( 'server' ),
 
 
 
 
 
 
 
 
68
  'site_root_path' => $this->paths_generator->get_wordpress_root_path(),
69
  'size_png_path' => $this->file_loader->get_file_size_by_path(
70
  $uploads_path . RewritesErrorsDetector::PATH_OUTPUT_FILE_PNG
src/Settings/Page/PageIntegration.php CHANGED
@@ -55,14 +55,21 @@ class PageIntegration implements HookableInterface {
55
  /**
56
  * Returns URL of plugin settings page.
57
  *
 
 
58
  * @return string
59
  */
60
- public static function get_settings_page_url(): string {
61
  if ( ! is_multisite() ) {
62
- return menu_page_url( self::ADMIN_MENU_PAGE, false );
63
  } else {
64
- return network_admin_url( 'settings.php?page=' . self::ADMIN_MENU_PAGE );
 
 
 
 
65
  }
 
66
  }
67
 
68
  /**
55
  /**
56
  * Returns URL of plugin settings page.
57
  *
58
+ * @param string|null $action .
59
+ *
60
  * @return string
61
  */
62
+ public static function get_settings_page_url( string $action = null ): string {
63
  if ( ! is_multisite() ) {
64
+ $page_url = menu_page_url( self::ADMIN_MENU_PAGE, false );
65
  } else {
66
+ $page_url = network_admin_url( 'settings.php?page=' . self::ADMIN_MENU_PAGE );
67
+ }
68
+
69
+ if ( $action !== null ) {
70
+ $page_url .= 'action=' . $action;
71
  }
72
+ return $page_url;
73
  }
74
 
75
  /**
src/Settings/Page/SettingsPage.php CHANGED
@@ -10,6 +10,7 @@ use WebpConverter\Loader\LoaderAbstract;
10
  use WebpConverter\PluginData;
11
  use WebpConverter\PluginInfo;
12
  use WebpConverter\Repository\TokenRepository;
 
13
  use WebpConverter\Service\ViewLoader;
14
  use WebpConverter\Settings\PluginOptions;
15
  use WebpConverter\Settings\SettingsSave;
@@ -68,17 +69,11 @@ class SettingsPage extends PageAbstract {
68
  'submit_value' => SettingsSave::SUBMIT_VALUE,
69
  'submit_activate_token' => SettingsSave::SUBMIT_TOKEN_ACTIVATE,
70
  'submit_deactivate_token' => SettingsSave::SUBMIT_TOKEN_DEACTIVATE,
 
 
71
  'token_valid_status' => $this->token_repository->get_token()->get_valid_status(),
72
- 'settings_url' => sprintf(
73
- '%1$s&%2$s=%3$s',
74
- PageIntegration::get_settings_page_url(),
75
- SettingsSave::NONCE_PARAM_KEY,
76
- wp_create_nonce( SettingsSave::NONCE_PARAM_VALUE )
77
- ),
78
- 'settings_debug_url' => sprintf(
79
- '%s&action=server',
80
- PageIntegration::get_settings_page_url()
81
- ),
82
  'api_calculate_url' => ( new ImagesCounterEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
83
  'api_paths_url' => ( new PathsEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
84
  'api_regenerate_url' => ( new RegenerateEndpoint( $this->plugin_data ) )->get_route_url(),
10
  use WebpConverter\PluginData;
11
  use WebpConverter\PluginInfo;
12
  use WebpConverter\Repository\TokenRepository;
13
+ use WebpConverter\Service\NonceManager;
14
  use WebpConverter\Service\ViewLoader;
15
  use WebpConverter\Settings\PluginOptions;
16
  use WebpConverter\Settings\SettingsSave;
69
  'submit_value' => SettingsSave::SUBMIT_VALUE,
70
  'submit_activate_token' => SettingsSave::SUBMIT_TOKEN_ACTIVATE,
71
  'submit_deactivate_token' => SettingsSave::SUBMIT_TOKEN_DEACTIVATE,
72
+ 'nonce_input_name' => SettingsSave::NONCE_PARAM_KEY,
73
+ 'nonce_input_value' => ( new NonceManager() )->generate_nonce( SettingsSave::NONCE_PARAM_VALUE ),
74
  'token_valid_status' => $this->token_repository->get_token()->get_valid_status(),
75
+ 'settings_url' => PageIntegration::get_settings_page_url(),
76
+ 'settings_debug_url' => PageIntegration::get_settings_page_url( 'server' ),
 
 
 
 
 
 
 
 
77
  'api_calculate_url' => ( new ImagesCounterEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
78
  'api_paths_url' => ( new PathsEndpoint( $this->plugin_data, $this->token_repository ) )->get_route_url(),
79
  'api_regenerate_url' => ( new RegenerateEndpoint( $this->plugin_data ) )->get_route_url(),
src/Settings/SettingsSave.php CHANGED
@@ -9,6 +9,7 @@ use WebpConverter\Conversion\Format\WebpFormat;
9
  use WebpConverter\Conversion\Method\RemoteMethod;
10
  use WebpConverter\Loader\LoaderAbstract;
11
  use WebpConverter\PluginData;
 
12
  use WebpConverter\Service\OptionsAccessManager;
13
  use WebpConverter\Service\TokenValidator;
14
  use WebpConverter\Settings\Option\AccessTokenOption;
@@ -25,7 +26,7 @@ class SettingsSave {
25
  const SUBMIT_VALUE = 'webpc_save';
26
  const SUBMIT_TOKEN_ACTIVATE = 'webpc_token_activate';
27
  const SUBMIT_TOKEN_DEACTIVATE = 'webpc_token_deactivate';
28
- const NONCE_PARAM_KEY = '_wpnonce';
29
  const NONCE_PARAM_VALUE = 'webpc-save';
30
 
31
  /**
@@ -49,24 +50,25 @@ class SettingsSave {
49
  * @return void
50
  */
51
  public function save_settings() {
52
- if ( ( ! isset( $_POST[ self::SUBMIT_VALUE ] )
53
- && ! isset( $_POST[ self::SUBMIT_TOKEN_ACTIVATE ] )
54
- && ! isset( $_POST[ self::SUBMIT_TOKEN_DEACTIVATE ] ) )
55
- || ! isset( $_REQUEST[ self::NONCE_PARAM_KEY ] )
56
- || ! wp_verify_nonce( $_REQUEST[ self::NONCE_PARAM_KEY ], self::NONCE_PARAM_VALUE ) ) { // phpcs:ignore
 
57
  return;
58
  }
59
 
60
  $saved_settings = $this->plugin_data->get_plugin_settings();
61
- if ( isset( $_POST[ self::SUBMIT_VALUE ] ) ) {
62
- $plugin_settings = ( new PluginOptions() )->get_values( false, $_POST );
63
  } else {
64
  $plugin_settings = $saved_settings;
65
  }
66
 
67
- if ( isset( $_POST[ self::SUBMIT_TOKEN_ACTIVATE ] ) ) {
68
- $plugin_settings[ AccessTokenOption::OPTION_NAME ] = sanitize_text_field( $_POST[ AccessTokenOption::OPTION_NAME ] ?: '' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
69
- } elseif ( isset( $_POST[ self::SUBMIT_TOKEN_DEACTIVATE ] ) ) {
70
  $plugin_settings[ AccessTokenOption::OPTION_NAME ] = '';
71
  } elseif ( substr( $plugin_settings[ AccessTokenOption::OPTION_NAME ], -32 ) === str_repeat( '*', 32 ) ) {
72
  $plugin_settings[ AccessTokenOption::OPTION_NAME ] = $saved_settings[ AccessTokenOption::OPTION_NAME ];
@@ -76,7 +78,7 @@ class SettingsSave {
76
  if ( $token->get_valid_status() ) {
77
  $plugin_settings[ ConversionMethodOption::OPTION_NAME ] = RemoteMethod::METHOD_NAME;
78
 
79
- if ( isset( $_POST[ self::SUBMIT_TOKEN_ACTIVATE ] ) ) {
80
  $plugin_settings[ OutputFormatsOption::OPTION_NAME ] = [
81
  AvifFormat::FORMAT_EXTENSION,
82
  WebpFormat::FORMAT_EXTENSION,
9
  use WebpConverter\Conversion\Method\RemoteMethod;
10
  use WebpConverter\Loader\LoaderAbstract;
11
  use WebpConverter\PluginData;
12
+ use WebpConverter\Service\NonceManager;
13
  use WebpConverter\Service\OptionsAccessManager;
14
  use WebpConverter\Service\TokenValidator;
15
  use WebpConverter\Settings\Option\AccessTokenOption;
26
  const SUBMIT_VALUE = 'webpc_save';
27
  const SUBMIT_TOKEN_ACTIVATE = 'webpc_token_activate';
28
  const SUBMIT_TOKEN_DEACTIVATE = 'webpc_token_deactivate';
29
+ const NONCE_PARAM_KEY = 'webpc_nonce';
30
  const NONCE_PARAM_VALUE = 'webpc-save';
31
 
32
  /**
50
  * @return void
51
  */
52
  public function save_settings() {
53
+ $post_data = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
54
+ if ( ( ! isset( $post_data[ self::SUBMIT_VALUE ] )
55
+ && ! isset( $post_data[ self::SUBMIT_TOKEN_ACTIVATE ] )
56
+ && ! isset( $post_data[ self::SUBMIT_TOKEN_DEACTIVATE ] ) )
57
+ || ! ( new NonceManager() )
58
+ ->verify_nonce( $post_data[ self::NONCE_PARAM_KEY ] ?? '', self::NONCE_PARAM_VALUE ) ) {
59
  return;
60
  }
61
 
62
  $saved_settings = $this->plugin_data->get_plugin_settings();
63
+ if ( isset( $post_data[ self::SUBMIT_VALUE ] ) ) {
64
+ $plugin_settings = ( new PluginOptions() )->get_values( false, $post_data );
65
  } else {
66
  $plugin_settings = $saved_settings;
67
  }
68
 
69
+ if ( isset( $post_data[ self::SUBMIT_TOKEN_ACTIVATE ] ) ) {
70
+ $plugin_settings[ AccessTokenOption::OPTION_NAME ] = sanitize_text_field( $post_data[ AccessTokenOption::OPTION_NAME ] ?: '' );
71
+ } elseif ( isset( $post_data[ self::SUBMIT_TOKEN_DEACTIVATE ] ) ) {
72
  $plugin_settings[ AccessTokenOption::OPTION_NAME ] = '';
73
  } elseif ( substr( $plugin_settings[ AccessTokenOption::OPTION_NAME ], -32 ) === str_repeat( '*', 32 ) ) {
74
  $plugin_settings[ AccessTokenOption::OPTION_NAME ] = $saved_settings[ AccessTokenOption::OPTION_NAME ];
78
  if ( $token->get_valid_status() ) {
79
  $plugin_settings[ ConversionMethodOption::OPTION_NAME ] = RemoteMethod::METHOD_NAME;
80
 
81
+ if ( isset( $post_data[ self::SUBMIT_TOKEN_ACTIVATE ] ) ) {
82
  $plugin_settings[ OutputFormatsOption::OPTION_NAME ] = [
83
  AvifFormat::FORMAT_EXTENSION,
84
  WebpFormat::FORMAT_EXTENSION,
templates/components/widgets/options.php CHANGED
@@ -6,6 +6,8 @@
6
  * @var string $submit_value Value of submit button.
7
  * @var string $submit_activate_token .
8
  * @var string $submit_deactivate_token .
 
 
9
  * @var bool $token_valid_status .
10
  * @var string $settings_debug_url URL of plugin settings page (debug view).
11
  * @var string $api_calculate_url URL of REST API endpoint.
@@ -38,7 +40,12 @@
38
  </div>
39
  <?php endforeach; ?>
40
  <div class="webpPage__widgetRow">
41
- <button type="submit" name="<?php echo esc_attr( $submit_value ); ?>"
 
 
 
 
 
42
  class="webpButton webpButton--green"
43
  >
44
  <?php echo esc_html( __( 'Save Changes', 'webp-converter-for-media' ) ); ?>
6
  * @var string $submit_value Value of submit button.
7
  * @var string $submit_activate_token .
8
  * @var string $submit_deactivate_token .
9
+ * @var string $nonce_input_name .
10
+ * @var string $nonce_input_value .
11
  * @var bool $token_valid_status .
12
  * @var string $settings_debug_url URL of plugin settings page (debug view).
13
  * @var string $api_calculate_url URL of REST API endpoint.
40
  </div>
41
  <?php endforeach; ?>
42
  <div class="webpPage__widgetRow">
43
+ <input type="hidden"
44
+ name="<?php echo esc_attr( $nonce_input_name ); ?>"
45
+ value="<?php echo esc_attr( $nonce_input_value ); ?>"
46
+ >
47
+ <button type="submit"
48
+ name="<?php echo esc_attr( $submit_value ); ?>"
49
  class="webpButton webpButton--green"
50
  >
51
  <?php echo esc_html( __( 'Save Changes', 'webp-converter-for-media' ) ); ?>
templates/components/widgets/regenerate.php CHANGED
@@ -20,7 +20,7 @@
20
  >
21
  <div class="webpPage__widgetRow">
22
  <p>
23
- <?php echo wp_kses_post( __( 'Convert all existing images with just one click! This tool uses the WordPress REST API by downloading addresses of all images and converting all files gradually. This is a process that may take a few or more than ten minutes depending on the number of files. During this process, please do not close your browser window.', 'webp-converter-for-media' ) ); ?>
24
  </p>
25
  <p>
26
  <?php echo wp_kses_post( __( 'This operation should be performed only once after installing the plugin. New images from the Media Library will be converted automatically. For other images, e.g. from the /themes or /uploads directory that are not from the Media Library, you must start manual conversion after adding new images.', 'webp-converter-for-media' ) ); ?>
20
  >
21
  <div class="webpPage__widgetRow">
22
  <p>
23
+ <?php echo wp_kses_post( __( 'Convert all existing images with just one click! This tool uses the WordPress REST API by downloading addresses of all images and converting all files gradually. This is a process that can take anywhere from several minutes to many hours depending on the number of files. During this process, please do not close your browser window.', 'webp-converter-for-media' ) ); ?>
24
  </p>
25
  <p>
26
  <?php echo wp_kses_post( __( 'This operation should be performed only once after installing the plugin. New images from the Media Library will be converted automatically. For other images, e.g. from the /themes or /uploads directory that are not from the Media Library, you must start manual conversion after adding new images.', 'webp-converter-for-media' ) ); ?>
templates/views/settings.php CHANGED
@@ -8,6 +8,8 @@
8
  * @var string $submit_value Value of submit button.
9
  * @var string $submit_activate_token .
10
  * @var string $submit_deactivate_token .
 
 
11
  * @var bool $token_valid_status .
12
  * @var string $settings_url URL of plugin settings page (default view).
13
  * @var string $settings_debug_url URL of plugin settings page (debug view).
8
  * @var string $submit_value Value of submit button.
9
  * @var string $submit_activate_token .
10
  * @var string $submit_deactivate_token .
11
+ * @var string $nonce_input_name .
12
+ * @var string $nonce_input_value .
13
  * @var bool $token_valid_status .
14
  * @var string $settings_url URL of plugin settings page (default view).
15
  * @var string $settings_debug_url URL of plugin settings page (debug view).
vendor/composer/autoload_classmap.php CHANGED
@@ -146,6 +146,7 @@ return array(
146
  'WebpConverter\\Repository\\TokenRepository' => $baseDir . '/src/Repository/TokenRepository.php',
147
  'WebpConverter\\Service\\DeactivationModalGenerator' => $baseDir . '/src/Service/DeactivationModalGenerator.php',
148
  'WebpConverter\\Service\\FileLoader' => $baseDir . '/src/Service/FileLoader.php',
 
149
  'WebpConverter\\Service\\OptionsAccessManager' => $baseDir . '/src/Service/OptionsAccessManager.php',
150
  'WebpConverter\\Service\\ServerConfigurator' => $baseDir . '/src/Service/ServerConfigurator.php',
151
  'WebpConverter\\Service\\TokenValidator' => $baseDir . '/src/Service/TokenValidator.php',
146
  'WebpConverter\\Repository\\TokenRepository' => $baseDir . '/src/Repository/TokenRepository.php',
147
  'WebpConverter\\Service\\DeactivationModalGenerator' => $baseDir . '/src/Service/DeactivationModalGenerator.php',
148
  'WebpConverter\\Service\\FileLoader' => $baseDir . '/src/Service/FileLoader.php',
149
+ 'WebpConverter\\Service\\NonceManager' => $baseDir . '/src/Service/NonceManager.php',
150
  'WebpConverter\\Service\\OptionsAccessManager' => $baseDir . '/src/Service/OptionsAccessManager.php',
151
  'WebpConverter\\Service\\ServerConfigurator' => $baseDir . '/src/Service/ServerConfigurator.php',
152
  'WebpConverter\\Service\\TokenValidator' => $baseDir . '/src/Service/TokenValidator.php',
vendor/composer/autoload_static.php CHANGED
@@ -161,6 +161,7 @@ class ComposerStaticInitebe26683fe2867a2665137fa33b88538
161
  'WebpConverter\\Repository\\TokenRepository' => __DIR__ . '/../..' . '/src/Repository/TokenRepository.php',
162
  'WebpConverter\\Service\\DeactivationModalGenerator' => __DIR__ . '/../..' . '/src/Service/DeactivationModalGenerator.php',
163
  'WebpConverter\\Service\\FileLoader' => __DIR__ . '/../..' . '/src/Service/FileLoader.php',
 
164
  'WebpConverter\\Service\\OptionsAccessManager' => __DIR__ . '/../..' . '/src/Service/OptionsAccessManager.php',
165
  'WebpConverter\\Service\\ServerConfigurator' => __DIR__ . '/../..' . '/src/Service/ServerConfigurator.php',
166
  'WebpConverter\\Service\\TokenValidator' => __DIR__ . '/../..' . '/src/Service/TokenValidator.php',
161
  'WebpConverter\\Repository\\TokenRepository' => __DIR__ . '/../..' . '/src/Repository/TokenRepository.php',
162
  'WebpConverter\\Service\\DeactivationModalGenerator' => __DIR__ . '/../..' . '/src/Service/DeactivationModalGenerator.php',
163
  'WebpConverter\\Service\\FileLoader' => __DIR__ . '/../..' . '/src/Service/FileLoader.php',
164
+ 'WebpConverter\\Service\\NonceManager' => __DIR__ . '/../..' . '/src/Service/NonceManager.php',
165
  'WebpConverter\\Service\\OptionsAccessManager' => __DIR__ . '/../..' . '/src/Service/OptionsAccessManager.php',
166
  'WebpConverter\\Service\\ServerConfigurator' => __DIR__ . '/../..' . '/src/Service/ServerConfigurator.php',
167
  'WebpConverter\\Service\\TokenValidator' => __DIR__ . '/../..' . '/src/Service/TokenValidator.php',
vendor/composer/installed.php CHANGED
@@ -5,7 +5,7 @@
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
- 'reference' => 'fc539b18cc283e9063bdb3b9ec0badab031b4317',
9
  'name' => 'gbiorczyk/webp-converter-for-media',
10
  'dev' => false,
11
  ),
@@ -16,7 +16,7 @@
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
- 'reference' => 'fc539b18cc283e9063bdb3b9ec0badab031b4317',
20
  'dev_requirement' => false,
21
  ),
22
  'matt-plugins/deactivation-modal' => array(
5
  'type' => 'library',
6
  'install_path' => __DIR__ . '/../../',
7
  'aliases' => array(),
8
+ 'reference' => '23e6fbd9765363bebd60579aea1376ff2b15fa88',
9
  'name' => 'gbiorczyk/webp-converter-for-media',
10
  'dev' => false,
11
  ),
16
  'type' => 'library',
17
  'install_path' => __DIR__ . '/../../',
18
  'aliases' => array(),
19
+ 'reference' => '23e6fbd9765363bebd60579aea1376ff2b15fa88',
20
  'dev_requirement' => false,
21
  ),
22
  'matt-plugins/deactivation-modal' => array(
webp-converter-for-media.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP and AVIF images instead of standard formats JPEG, PNG and GIF. Reduce image sizes just now!
6
- * Version: 4.1.1
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://mattplugins.com/
9
  * Text Domain: webp-converter-for-media
@@ -13,5 +13,5 @@
13
  require_once __DIR__ . '/vendor/autoload.php';
14
 
15
  new WebpConverter\WebpConverter(
16
- new WebpConverter\PluginInfo( __FILE__, '4.1.1' )
17
  );
3
  /**
4
  * Plugin Name: WebP Converter for Media
5
  * Description: Speed up your website by serving WebP and AVIF images instead of standard formats JPEG, PNG and GIF. Reduce image sizes just now!
6
+ * Version: 4.1.2
7
  * Author: Mateusz Gbiorczyk
8
  * Author URI: https://mattplugins.com/
9
  * Text Domain: webp-converter-for-media
13
  require_once __DIR__ . '/vendor/autoload.php';
14
 
15
  new WebpConverter\WebpConverter(
16
+ new WebpConverter\PluginInfo( __FILE__, '4.1.2' )
17
  );