Version Description
- Info: Brand new UI! Made everything much clearer.
- Fix: Issues related to WebP and PDF thumbnails.
- Fix: Issues related to breaking characters in the Media or Attached Post Title.
Download this release
Release Info
Developer | TigrouMeow |
Plugin | Media File Renamer |
Version | 5.0.0 |
Comparing to | |
See all releases |
Code changes from version 4.7.0 to 5.0.0
- app/index.js +2 -0
- app/vendor.js +27 -0
- classes/admin.php +88 -0
- api.php → classes/api.php +1 -1
- core.php → classes/core.php +230 -177
- classes/init.php +44 -0
- {plugins → classes/plugins}/beaverbuilder.php +0 -0
- {plugins → classes/plugins}/custom.php +0 -0
- plugins/woocommerce.php → classes/plugins/unused_woocommerce.php +0 -0
- {plugins → classes/plugins}/wpml.php +0 -0
- classes/rest.php +440 -0
- classes/ui.php +59 -0
- updates.php → classes/updates.php +5 -8
- common/admin.css +0 -404
- common/admin.php +99 -507
- common/classes/ratings.php +114 -0
- common/classes/rest.php +82 -0
- common/classes/rest_license.php +40 -0
- common/classes/updater.php +591 -0
- common/helpers.php +47 -0
- common/licenser.php +125 -0
- helpers.php +0 -39
- languages/media-file-renamer-fr_FR.mo +0 -0
- media-file-renamer.php +13 -35
- mfrh_admin.php +0 -575
- readme.txt +40 -29
- scripts/media-library.js +0 -280
- style.css +0 -94
- ui.php +0 -459
- views/admin-head.php +0 -92
- views/column.php +0 -95
- views/menu-screen.php +0 -145
app/index.js
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
!function(e){function n(n){for(var r,i,l=n[0],c=n[1],u=n[2],f=0,d=[];f<l.length;f++)i=l[f],Object.prototype.hasOwnProperty.call(a,i)&&a[i]&&d.push(a[i][0]),a[i]=0;for(r in c)Object.prototype.hasOwnProperty.call(c,r)&&(e[r]=c[r]);for(s&&s(n);d.length;)d.shift()();return o.push.apply(o,u||[]),t()}function t(){for(var e,n=0;n<o.length;n++){for(var t=o[n],r=!0,l=1;l<t.length;l++){var c=t[l];0!==a[c]&&(r=!1)}r&&(o.splice(n--,1),e=i(i.s=t[0]))}return e}var r={},a={0:0},o=[];function i(n){if(r[n])return r[n].exports;var t=r[n]={i:n,l:!1,exports:{}};return e[n].call(t.exports,t,t.exports,i),t.l=!0,t.exports}i.m=e,i.c=r,i.d=function(e,n,t){i.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,n){if(1&n&&(e=i(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(i.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var r in e)i.d(t,r,function(n){return e[n]}.bind(null,r));return t},i.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(n,"a",n),n},i.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},i.p="";var l=window.wpJsonMfrh=window.wpJsonMfrh||[],c=l.push.bind(l);l.push=n,l=l.slice();for(var u=0;u<l.length;u++)n(l[u]);var s=c;o.push([78,1]),t()}({0:function(e,n){e.exports=React},69:function(e,n){e.exports=ReactDOM},78:function(e,n,t){"use strict";t.r(n);var r=wp.i18n.__,a={};a.RENAME=r("Rename","media-file-renamer"),a.DASHBOARD=r("Dashboard","media-file-renamer"),a.PENDING=r("Pending","media-file-renamer"),a.RENAMED=r("Renamed","media-file-renamer"),a.ALL=r("All","media-file-renamer"),a.THUMB=r("Thumb","media-file-renamer"),a.TITLE=r("Title","media-file-renamer"),a.ATTACHED_TO=r("Attached To","media-file-renamer"),a.FILENAME=r("Filename","media-file-renamer");var o=a,i=mfrh_media_file_renamer.prefix,l=mfrh_media_file_renamer.domain,c=mfrh_media_file_renamer.rest_url.replace(/\/+$/,""),u=mfrh_media_file_renamer.api_url.replace(/\/+$/,""),s=mfrh_media_file_renamer.plugin_url.replace(/\/+$/,""),f="1"===mfrh_media_file_renamer.is_pro,d=f&&"1"===mfrh_media_file_renamer.is_registered,m="1"===mfrh_media_file_renamer.mfrh_undo,p="1"===mfrh_media_file_renamer.mfrh_manual_rename,h=t(0),b=t.n(h),g=t(1),y=t.n(g);function v(){return(v=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function E(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function w(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?E(Object(t),!0).forEach((function(n){k(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):E(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function k(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function R(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return O(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return O(e,n)}(e,n)||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 O(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var j=function(e){var n=e.spinner,t=void 0===n||n,r=e.busy,a=void 0!==r&&r,o=e.overlayStyle,i=R(Object(h.useState)(!0),2),l=i[0],c=i[1];Object(h.useEffect)((function(){var e;return a?c(!0):e=setTimeout((function(){c(!1),e=null}),250),function(){e&&clearTimeout(e)}}),[a]);var u=l?b.a.createElement(b.a.Fragment,null,b.a.createElement("div",{className:"overlay "+(a?"":"overlayHidden"),style:o},Boolean(t)&&b.a.createElement("div",{className:"lds-ellipsis "+(a?"":"spinnerHidden")},b.a.createElement("div",null),b.a.createElement("div",null),b.a.createElement("div",null),b.a.createElement("div",null))),b.a.createElement("style",{jsx:!0},"\n .overlay {\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n width: 100%;\n height: 100%;\n background: rgb(30 124 186 / 85%);\n transition: opacity 1s ease-out;\n z-index: 10;\n display: flex;\n align-items: center;\n flex-direction: column;\n justify-content: center;\n overflow: hidden;\n }\n\n .overlayHidden {\n opacity: 0;\n transition: opacity 0.25s ease-out;\n }\n .spinnerHidden {\n opacity: 0;\n transition: opacity 0.25s ease-out;\n }\n .lds-ellipsis {\n position: relative;\n width: 80px;\n height: 80px;\n display: flex;\n justify-items: center;\n align-items: center;\n }\n .lds-ellipsis div {\n position: absolute;\n width: 13px;\n height: 13px;\n border-radius: 50%;\n background: white;\n animation-timing-function: cubic-bezier(0, 1, 1, 0);\n }\n .lds-ellipsis div:nth-child(1) {\n left: 8px;\n animation: lds-ellipsis1 0.6s infinite;\n }\n .lds-ellipsis div:nth-child(2) {\n left: 8px;\n animation: lds-ellipsis2 0.6s infinite;\n }\n .lds-ellipsis div:nth-child(3) {\n left: 32px;\n animation: lds-ellipsis2 0.6s infinite;\n }\n .lds-ellipsis div:nth-child(4) {\n left: 56px;\n animation: lds-ellipsis3 0.6s infinite;\n }\n @keyframes lds-ellipsis1 {\n 0% {\n transform: scale(0);\n }\n 100% {\n transform: scale(1);\n }\n }\n @keyframes lds-ellipsis3 {\n 0% {\n transform: scale(1);\n }\n 100% {\n transform: scale(0);\n }\n }\n @keyframes lds-ellipsis2 {\n 0% {\n transform: translate(0, 0);\n }\n 100% {\n transform: translate(24px, 0);\n }\n } \n ")):null,s=w(w({},e),{},{busy:void 0,spinner:void 0});return b.a.createElement("div",v({style:{position:"relative"}},s),u,e.children)};j.propTypes={busy:y.a.bool.isRequired,spinner:y.a.bool,children:y.a.oneOfType([y.a.arrayOf(y.a.node),y.a.node]).isRequired};var S,P=j,C=t(2),_=t(5),A={black:"black",blackRGB:"0, 0, 0",blue:"#007cba",blueRGB:"0, 124, 186",deepBlue:"#134575",finderBorder:"#DEDEDE",lightBlue:"#EBF3FF",lightGray:"#F1F1F1",gray:"#E8E8E8",green:"#0EA480",darkGray:"#A0A0A0",disabledForm:"#828282",orange:"#daa827",overlay:"rgba(16, 16, 16, 0.92)",red:"#ba4300",header:"#134675",proGray:"#7F8EA0",progress:"#8414a8",tableGray:"#FAFAFA",yellow:"#e4b42b",yellowRGB:"224, 156, 54",white:"white",fontFamily:"Lato",fontSizeH1:"24px",fontSizeH2:"18px",fontSizeText:"13px",fontSizeSmall:"12px",lightShadow:"0px 0px 10px rgba(0,0,0,0.1)"},T=t(3),N=t(27),z=t.n(N),I=t(28),M=t.n(I),F=t(29),B=t.n(F),L=t(9),q=t.n(L),U=t(10),D=t.n(U),H=t(11),G=t.n(H),W=t(6),$=t.n(W),Y=t(4),J=t.n(Y),V=t(8),K=t.n(V),Z=t(12),Q=t.n(Z),X=t(13),ee=t.n(X),ne=t(30),te=t.n(ne),re=t(31),ae=t.n(re),oe=t(14),ie=t.n(oe),le=t(32),ce=t.n(le),ue=t(33),se=t.n(ue),fe=t(34),de=t.n(fe),me=t(35),pe=t.n(me),he=t(36),be=t.n(he),ge=t(37),ye=t.n(ge),ve=t(38),Ee=t.n(ve),xe=t(39),we=t.n(xe),ke=t(40),Re=t.n(ke),Oe=t(41),je=t.n(Oe),Se=t(42),Pe=t.n(Se),Ce=t(43),_e=t.n(Ce),Ae=t(44),Te=t.n(Ae),Ne=t(45),ze=t.n(Ne);function Ie(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Me=(Ie(S={lock:z.a,"lock-open":M.a,"file-undo":B.a,"chevron-double-left":q.a,"chevron-double-right":D.a,"chevron-left":G.a,"chevron-right":$.a,"chevron-down":J.a,"chevron-up":K.a,pause:Q.a,play:ee.a,replay:te.a,check:ae.a,stop:ie.a,delete:ce.a,undo:se.a,alert:de.a,database:pe.a,pencil:be.a,tools:ye.a,cog:Ee.a,close:we.a,cat:Re.a,upload:je.a,trash:Pe.a},"pencil",_e.a),Ie(S,"dashboard",Te.a),Ie(S,"search",ze.a),S);function Fe(){return(Fe=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function Be(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function Le(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n display: inline-block;\n box-sizing: border-box;\n height: 30px;\n min-width: 6em;\n border: none;\n border-radius: 4px;\n text-align: center;\n font-family: ",";\n font-size: ",";\n padding: 0 15px;\n\n background-color: ",";\n color: white;\n transition: background-color .10s, opacity .25s;\n\n :not([disabled]):hover {\n cursor: pointer;\n background-color: ",";\n }\n\n :disabled {\n opacity: 0.35;\n }\n\n :focus {\n outline: none;\n }\n\n &.has-icon {\n align-items: center;\n display: inline-flex;\n padding: 2.5px 6px 2.5px 4px;\n }\n\n &.secondary {\n background-color: ",";\n border: 1px solid ",";\n color: ",";\n\n &:hover {\n background-color: ",";\n }\n }\n\n &.danger {\n background-color: ",";\n border-color: ",";\n\n\t &:hover {\n\t\t background-color: ",";\n\t }\n }\n\n &.success {\n background-color: ",";\n border-color: ",";\n\n\t &:hover {\n\t\t background-color: ",";\n\t }\n }\n\n & + button {\n margin-left: .25rem;\n }\n\n ","\n"]);return Le=function(){return e},e}var qe=Object(C.a)((function(e){var n=e.className,t=e.icon,r=void 0===t?null:t,a=e.onClick,o=e.disabled,i=void 0!==o&&o,l=e.color,c=void 0===l?null:l,u=e.children,s=Be(e,["className","icon","onClick","disabled","color","children"]),f=!!r,d="".concat(n||"").concat(f?" has-icon":""," ").concat(c?"custom-color":"");return b.a.createElement("button",Fe({type:"button",className:d,onClick:a,disabled:i},s),f&&b.a.createElement(T.Icon,{icon:"string"==typeof r?Me[r]||null:r,width:"24",height:"24",style:{marginRight:"4px"}}),b.a.createElement("span",null,u))}))(Le(),A.fontFamily,A.fontSizeText,A.blue,Object(_.a)(.1,A.blue),A.lightBlue,A.blue,A.blue,Object(_.a)(.1,A.lightBlue),A.red,A.red,Object(_.a)(.1,A.red),A.green,A.green,Object(_.a)(.1,A.green),(function(e){return Ue(e.color)})),Ue=function(e){if(e)return"\n &.custom-color {\n background-color: ".concat(e,";\n border: 1px solid ").concat(e,";\n\n &:hover {\n background-color: ").concat(Object(_.a)(.1,e),";\n }\n }\n ")},De=function(e){return b.a.createElement(qe,e)};function He(){return(He=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function Ge(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function We(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n background-color: ",";\n position: relative;\n border-radius: 10px;\n color: ",";\n font-family: ",";\n font-size: 9px;\n line-height: 10px;\n padding: 5px 8px;\n text-transform: uppercase;\n\n &.inline {\n display: inline;\n margin-left: 5px;\n vertical-align: middle;\n }\n"]);return We=function(){return e},e}De.propTypes={className:y.a.oneOf(["primary","secondary","danger","success"]),disabled:y.a.bool,icon:y.a.oneOfType([y.a.instanceOf(T.IconifyIcon),y.a.oneOf(["setting","edit","trash"])]),color:y.a.string,onClick:y.a.func.isRequired},De.defaultProps={className:"primary",disabled:!1,icon:null,color:null,onClick:function(){}};var $e=C.a.div(We(),A.yellow,A.white,A.fontFamily),Ye=function(e){var n=e.show,t=void 0===n||n,r=e.className,a=Ge(e,["show","className"]);return t?b.a.createElement($e,He({className:"".concat(r||"")},a),"Pro Only"):null},Je=function(e){return b.a.createElement(Ye,e)};Je.propTypes={show:y.a.bool,className:y.a.string},Je.defaultProps={show:!0,className:void 0};var Ve=t(49);function Ke(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=en(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(l)throw o}}}}function Ze(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function Qe(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Ze(o,r,a,i,l,"next",e)}function l(e){Ze(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Xe(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||en(e,n)||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 en(e,n){if(e){if("string"==typeof e)return nn(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?nn(e,n):void 0}}function nn(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var tn=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,t=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=Object(h.useState)(n),a=Xe(r,2),o=a[0],i=a[1],l=Object(h.useState)(t),c=Xe(l,2),u=c[0],s=c[1],f=Object(h.useState)(0),d=Xe(f,2),m=d[0],p=d[1];return Object(h.useEffect)((function(){void 0!==e&&(i(e.data),p(e.total?e.total:0)),s(void 0===e)}),[e]),{busy:u,data:o,total:m}},rn=function(){var e=Object(h.useRef)(),n=Xe(Object(h.useState)({}),2),t=n[0],r=n[1];return Object(h.useEffect)((function(){if(e&&e.current){var n=new ResizeObserver((function(e){var n=e[0];n.contentRect&&r({width:n.contentRect.left+n.contentRect.right,height:n.contentRect.top+n.contentRect.bottom})}));return n.observe(e.current),function(){n.unobserve(e.current)}}}),[]),{ref:e,width:t.width?t.width:0,height:t.height?t.height:0}},an=function(e){var n=Object(h.useRef)(),t=function(t){e&&!n.current.contains(t.target)&&e()};return Object(h.useEffect)((function(){return document.addEventListener("mousedown",t),function(){document.removeEventListener("mousedown",t)}})),n},on=new(t.n(Ve).a)({concurrency:1,autoStart:!1});function ln(){var e=mn(["\n align-items: center;\n background-color: ",";\n border: none;\n box-sizing: border-box;\n color: white;\n display: flex;\n font-family: ",";\n font-size: ",";\n width: 100%;\n padding: 8px 15px 8px 15px;\n text-align: center;\n transition: background-color .10s, opacity .25s;\n\n :not([disabled]):hover {\n cursor: pointer;\n background-color: ",";\n }\n\n :disabled:not(.is-pro) {\n opacity: 0.35;\n }\n\n :focus {\n outline: none;\n }\n\n &.is-pro {\n background-color: ",";\n justify-content: space-between;\n }\n"]);return ln=function(){return e},e}function cn(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return un(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return un(e,n)}(e,n)||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 un(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function sn(){var e=mn(["\n position: relative;\n display: block;\n margin-top: 18px;\n background-color: ",";\n position: absolute;\n z-index: 10;\n box-shadow: ",';\n\n &:before {\n content: "";\n position: absolute;\n top: -18px;\n left: 50%;\n margin-left: -8px;\n border: 8px solid transparent;\n border-bottom: 10px solid ',";\n }\n"]);return sn=function(){return e},e}function fn(){var e=mn(["\n align-items: center;\n background-color: ",";\n border: none;\n border-radius: 4px;\n box-sizing: border-box;\n color: white;\n display: inline-flex;\n font-family: ",";\n font-size: ",";\n height: 30px;\n min-width: 6em;\n padding: 0px 10px;\n text-align: center;\n transition: background-color .10s, opacity .25s;\n\n :not([disabled]):hover {\n cursor: pointer;\n background-color: ",";\n }\n\n :disabled {\n opacity: 0.35;\n }\n\n :focus {\n outline: none;\n }\n\n & + button {\n margin-left: .25rem;\n }\n"]);return fn=function(){return e},e}function dn(){var e=mn(["\n display: inline-block;\n"]);return dn=function(){return e},e}function mn(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var pn=C.a.div(dn()),hn=C.a.button(fn(),A.blue,A.fontFamily,A.fontSizeText,Object(_.a)(.1,A.blue)),bn=C.a.div(sn(),A.blue,A.lightShadow,A.blue),gn=function(e){var n=e.title,t=e.disabled,r=void 0!==t&&t,a=e.isPro,o=void 0!==a&&a,i=cn(b.a.useState(!1),2),l=i[0],c=i[1],u=an((function(){c(!1)})),s=rn(),f=s.ref,d=s.width,m=function(){c(!l)},p=b.a.Children.map(e.children,(function(e){return b.a.cloneElement(e,{isPro:o,disabled:e.props.disabled||r,onClick:function(){e.props.onClick&&e.props.onClick(),m()}})}));return b.a.createElement(pn,{ref:u},b.a.createElement(hn,{ref:f,type:"button",disabled:r,onClick:m},b.a.createElement("span",null,n),b.a.createElement(T.Icon,{icon:J.a,width:"24",height:"24",style:{marginLeft:"4px"}})),l&&b.a.createElement(bn,{style:{transform:"translateX(calc(-50% + ".concat(d/2,"px))")}},p))},yn=C.a.button(ln(),A.blue,A.fontFamily,A.fontSizeText,Object(_.a)(.1,A.blue),A.proGray),vn=function(e){var n=e.onClick,t=e.children,r=e.isPro,a=e.requirePro,o=void 0!==a&&a,i=e.disabled,l=o&&!r;return b.a.createElement(yn,{type:"button",className:l?"is-pro":"",onClick:n,disabled:i||l},b.a.createElement("span",null,t),l&&!r&&b.a.createElement(Je,null))},En=function(e){return b.a.createElement(gn,e)},xn=function(e){return b.a.createElement(vn,e)};function wn(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||kn(e,n)||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 kn(e,n){if(e){if("string"==typeof e)return Rn(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Rn(e,n):void 0}}function Rn(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function On(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n position: relative;\n background: #f1f1f1;\n margin-left: -20px;\n background-color: rgb(30 124 186 / 10%);\n padding-bottom: 50px;\n margin-bottom: -26px;\n\n .neko-rest-error {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: #1e232deb;\n z-index: 100;\n\n .container {\n color: white;\n padding: 5px 20px 15px 20px;\n min-width: 480px;\n max-width: 600px;\n border-radius: 20px;\n background: #883131;\n margin-left: 50%;\n transform: translateX(-50%);\n margin-top: 100px;\n\n h3 {\n color: white;\n }\n\n .neko-debug {\n padding: 5px 10px;\n background: #692426;\n border-radius: 10px;\n\n * {\n margin: 0px;\n padding: 0px;\n } \n }\n }\n }\n"]);return On=function(){return e},e}En.propTypes={title:y.a.string,disabled:y.a.bool,isPro:y.a.bool},En.defaultProps={title:void 0,disabled:!1,isPro:!1},xn.propTypes={onClick:y.a.func.isRequired,requirePro:y.a.bool},xn.defaultProps={onClick:function(){},requirePro:!1};var jn=C.a.div(On()),Sn=function(e){var n=e.className,t=e.children,r=e.nekoErrors,a=e.style,o=void 0===a?{}:a,i=wn(Object(h.useState)(!1),2),l=i[0],c=i[1],u=wn(Object(h.useState)(!1),2),s=u[0],f=u[1];if(r&&!l){var d,m=function(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=kn(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(l)throw o}}}}(r);try{for(m.s();!(d=m.n()).done;){var p=d.value;if(p){c(p);break}}}catch(e){m.e(e)}finally{m.f()}}return b.a.createElement(jn,{className:n||"",style:o},l&&b.a.createElement("div",{className:"neko-rest-error"},b.a.createElement("div",{className:"container"},!s&&b.a.createElement(b.a.Fragment,null,b.a.createElement("h3",null,"The Rest API is disabled or broken 😢"),b.a.createElement("p",null,"The Rest API is required for this plugin to work. It is enabled in WordPress by default since December 2016 and used by the Gutenberg Editor since 2019. In short, it allows more robustness and a much cleaner infrastructure. Soon, Wordpress will entirely depends on it, so it is important to keep it enabled."),b.a.createElement("p",null,b.a.createElement("i",null,"Last but not least: check your PHP Error Logs and your Debugging Console.")),b.a.createElement("p",{className:"neko-debug"},b.a.createElement("small",null,"URL: ",l.url,b.a.createElement("br",null),"CODE: ",l.code,b.a.createElement("br",null),"MESSAGE: ",l.message,b.a.createElement("br",null)))),l.body&&s&&b.a.createElement("p",{className:"neko-debug"},b.a.createElement("div",{dangerouslySetInnerHTML:{__html:l.body}})),l.body&&b.a.createElement(De,{color:"#a94242",onClick:function(){return f(!s)}},s?"Hide":"Display"," response from server"),b.a.createElement(De,{color:"#a94242",onClick:function(){window.open("https://meowapps.com/debugging-wordpress/","_blank")}},"Learn about WordPress Debugging"))),t)},Pn=function(e){return b.a.createElement(Sn,e)};function Cn(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function _n(){var e=zn(["\n font-family: ",";\n font-size: ",";\n line-height: normal;\n margin: 0;\n padding: 0;\n"]);return _n=function(){return e},e}function An(){var e=zn(["\n font-family: ",";\n font-size: ",";\n line-height: normal;\n margin: 16px 0 24px;\n padding: 0;\n"]);return An=function(){return e},e}function Tn(){var e=zn(["\n font-family: ",";\n font-size: ",";\n font-weight: normal;\n line-height: normal;\n margin-top: 0;\n margin-bottom: 16px;\n padding: 0;\n"]);return Tn=function(){return e},e}function Nn(){var e=zn(["\n font-family: ",";\n font-weight: normal;\n font-size: ",";\n line-height: normal;\n margin-top: 0;\n margin-bottom: 16px;\n padding: 0;\n"]);return Nn=function(){return e},e}function zn(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Pn.propTypes={className:y.a.string,style:y.a.object,nekoErrors:y.a.bool},Pn.defaultProps={className:void 0,style:{},nekoErrors:!1};var In=C.a.h1(Nn(),A.fontFamily,A.fontSizeH1),Mn=C.a.h2(Tn(),A.fontFamily,A.fontSizeH2),Fn=C.a.p(An(),A.fontFamily,A.fontSizeText),Bn=C.a.span(_n(),A.fontFamily,A.fontSizeText),Ln=function(e){var n=e.children,t=Cn(e,["children"]);return e.h1?b.a.createElement(In,t,n):e.h2?b.a.createElement(Mn,t,n):e.p?b.a.createElement(Fn,t,n):b.a.createElement(Bn,t,n)},qn=function(e){return b.a.createElement(Ln,e)};function Un(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n font-size: ",";\n margin-bottom: 15px;\n \n .nui-block-title {\n color: ",";\n padding: 5px 10px;\n margin-bottom: 5px;\n }\n\n .nui-block-content {\n background-color: #f1f1f1;\n padding: 26px;\n box-shadow: 0px 2px 5px 0px #0000004a;\n border-radius: 10px;\n\n p:first-child {\n margin-top: 0;\n }\n\n p:last-child {\n margin-bottom: 0;\n }\n }\n\n &.primary {\n padding: 8px;\n background-color: ",";\n\n .nui-block-title {\n color: ",";\n }\n\n .nui-block-content {\n background-color: ",";\n }\n }\n"]);return Un=function(){return e},e}qn.propTypes={h1:y.a.any,h2:y.a.any,p:y.a.any},qn.defaultProps={h1:void 0,h2:void 0,p:void 0};var Dn=C.a.div(Un(),A.fontSizeText,A.blue,A.blue,A.white,A.white),Hn=function(e){var n=e.title,t=e.children,r=e.className,a=e.busy,o=void 0!==a&&a,i=e.style,l=void 0===i?{}:i;return b.a.createElement(Dn,{className:"nui-block "+(r||""),style:l},b.a.createElement(P,{busy:o},b.a.createElement(qn,{h2:!0,className:"nui-block-title"},n),b.a.createElement("div",{className:"nui-block-content"},t)))},Gn=function(e){return b.a.createElement(Hn,e)};function Wn(){var e=Yn(["\n justify-content: flex-start;\n background-color: ",";\n display: flex;\n align-items: center;\n padding: 8px 10px;\n\n &.align-right {\n justify-content: flex-end;\n }\n"]);return Wn=function(){return e},e}function $n(){var e=Yn(["\n font-size: ",";\n font-family: ",";\n background-color: ",";\n box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.25);\n margin-bottom: 25px;\n\n &.primary {\n background-color: ",";\n }\n\n p:first-child {\n margin-top: 0px;\n }\n\n p:last-child {\n margin-bottom: 0px;\n }\n\n .content {\n padding: 20px 20px;\n }\n"]);return $n=function(){return e},e}function Yn(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Gn.propTypes={title:y.a.string,className:y.a.oneOf(["","primary"]),style:y.a.object},Gn.defaultProps={title:void 0,className:"",style:{}};var Jn=C.a.div($n(),A.fontSizeText,A.fontFamily,A.white,A.blue),Vn=C.a.div(Wn(),A.lightGray),Kn=function(e){var n=e.children,t=e.header,r=e.headerAlign,a=void 0===r?"left":r,o=e.footer,i=e.footerAlign,l=void 0===i?"right":i,c=e.className,u=e.style,s=void 0===u?{}:u;return b.a.createElement(Jn,{className:c||"",style:s},t&&b.a.createElement(Vn,{className:"align-".concat(a)},t),b.a.createElement("div",{className:"content"},n),o&&b.a.createElement(Vn,{className:"align-".concat(l)},o))},Zn=function(e){return b.a.createElement(Kn,e)};function Qn(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n display: flex;\n font-family: ",";\n\n > .nui-settings-head {\n font-family: ",";\n font-size: 14px;\n line-height: 17px;\n width: 120px;\n margin-right: 16px;\n }\n\n /* Select, Checkbox, Input need to be a bit higher to be in front of the settings title */\n\n .nui-settings-content > .nui-select:first-child {\n position: relative;\n margin-top: -5px;\n }\n \n .nui-settings-content > .nui-checkbox:first-child {\n position: relative;\n margin-top: -5px;\n }\n\n .nui-settings-content > div:first-child > .neko-input {\n position: relative;\n margin-top: -5px;\n }\n\n > .nui-settings-content {\n flex: 1;\n\n &.nui-settings-content-align-right {\n flex: none;\n margin-left: auto;\n }\n\n input[type=text] {\n width: 100%;\n }\n\n\n }\n\n & + div {\n margin-top: 15px;\n }\n"]);return Qn=function(){return e},e}Zn.propTypes={header:y.a.element,headerAlign:y.a.oneOf(["left","right"]),footer:y.a.element,footerAlign:y.a.oneOf(["left","right"]),className:y.a.string,style:y.a.object},Zn.defaultProps={header:void 0,headerAlign:"left",footer:void 0,footerAlign:"right",className:void 0,style:{}};var Xn=Object(C.a)((function(e){var n=e.title,t=void 0===n?"":n,r=e.contentAlign,a=void 0===r?"left":r;return b.a.createElement("div",{className:e.className||""},t?b.a.createElement("div",{className:"nui-settings-head"},t):null,b.a.createElement("div",{className:"nui-settings-content nui-settings-content-align-".concat(a)},e.children))}))(Qn(),A.fontFamily,A.fontFamily),et=function(e){return b.a.createElement(Xn,e)};function nt(){var e=rt(["\n background-color: ",";\n color: white;\n"]);return nt=function(){return e},e}function tt(){var e=rt(["\n margin: 20px;\n padding: 14px;\n background-color: white;\n box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25);\n\n > * + * {\n /* Base margin between child elements */\n margin-top: 14px;\n }\n"]);return tt=function(){return e},e}function rt(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}et.propTypes={title:y.a.string,className:y.a.string,contentAlign:y.a.string},et.defaultProps={title:"",className:void 0,contentAlign:"left"};var at=C.a.div(tt()),ot=Object(C.a)((function(e){return e.children?b.a.createElement("div",{className:e.className},e.children):null}))(nt(),A.blue),it=function(e){return b.a.createElement(at,{className:"window"},b.a.createElement(ot,null,e.title),e.children)},lt=function(e){return b.a.createElement(it,e)};function ct(){return(ct=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function ut(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function st(){var e=dt(["\n flex: 1;\n padding: 32px 30px;\n\n .nui-block:not(:first-child) {\n margin-top: -20px;\n }\n\n .nui-block:last-child {\n margin-bottom: 0px;\n }\n\n &.minimal {\n padding: 0;\n }\n\n &.full {\n flex-basis: 100%;\n padding-bottom: 0;\n }\n\n & + .full {\n padding-bottom: 32px;\n padding-top: 0;\n }\n\n &:not(.full) + div:not(.full) {\n padding-left: 0;\n }\n"]);return st=function(){return e},e}function ft(){var e=dt(["\n display: flex;\n flex-wrap: wrap;\n"]);return ft=function(){return e},e}function dt(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}lt.propTypes={title:y.a.string},lt.defaultProps={title:void 0};var mt=C.a.div(ft()),pt=C.a.div(st()),ht=function(e){return b.a.createElement(mt,null,e.children)},bt=function(e){var n=e.full,t=e.minimal,r=ut(e,["full","minimal"]),a=n?"full":"";return a+=t?" minimal":"",b.a.createElement(pt,ct({className:a},r),e.children)},gt=function(e){return b.a.createElement(ht,e)},yt=function(e){return b.a.createElement(bt,e)};gt.propTypes={},gt.defaultProps={},yt.propTypes={full:y.a.any},yt.defaultProps={full:void 0};var vt=t(16),Et=t.n(vt),xt=t(17),wt=t.n(xt);function kt(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n font-family: ",";\n\n &.disabled {\n color: ",";\n\n label {\n cursor: default;\n }\n }\n\n input {\n display: none;\n }\n\n label {\n cursor: pointer;\n display: flex;\n }\n .nui-checkbox-check-container {\n flex-basis: 30px;\n }\n .nui-checkbox-inner-container {\n margin-top: 1.5px;\n margin-left: 4px;\n\n .label {\n display: block;\n font-size: 14px;\n line-height: 17px;\n padding-top: 4.5px;\n padding-bottom: 4px;\n }\n \n .description {\n display: block;\n font-size: 13px;\n line-height: 14px;\n color: #8a8a8a;\n\n * {\n font-size: 13px;\n line-height: inherit;\n margin: 0;\n }\n }\n }\n"]);return kt=function(){return e},e}var Rt=Object(C.a)((function(e){var n=e.id,t=e.name,r=e.checked,a=void 0!==r&&r,o=e.onChange,i=e.label,l=e.description,c=e.isPro,u=e.requirePro,s=void 0!==u&&u&&!c,f=s?"disabled":"";return b.a.createElement("div",{className:["nui-checkbox",e.className,f].join(" ")},b.a.createElement("input",{id:n,name:t,type:"checkbox",defaultChecked:!1,onClick:function(){o?o(!a,n):console.log("The onChange handler it not set for this checkbox.",e)},disabled:s}),b.a.createElement("label",{htmlFor:n},b.a.createElement("div",{className:"nui-checkbox-check-container"},b.a.createElement(T.Icon,{icon:a?wt.a:Et.a,width:"30px",height:"30px",color:s?A.disabledForm:A.blue})),b.a.createElement("div",{className:"nui-checkbox-inner-container"},b.a.createElement("span",{className:"label"},i,b.a.createElement(Je,{className:"inline",show:s})),l?b.a.createElement("small",{className:"description"},l):null)))}))(kt(),A.fontFamily,A.disabledForm),Ot=function(e){return b.a.createElement(Rt,e)};function jt(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n"]);return jt=function(){return e},e}Ot.propTypes={id:y.a.string,name:y.a.string,checked:y.a.bool,label:y.a.string,description:y.a.string,isPro:y.a.bool,requirePro:y.a.bool},Ot.defaultProps={id:void 0,name:void 0,checked:!1,label:void 0,description:void 0,isPro:!1,requirePro:!1};var St=Object(C.a)((function(e){var n=e.name,t=(e.max,e.isPro),r=void 0!==t&&t;return b.a.Children.map(e.children,(function(e){return e.props.name?e:b.a.cloneElement(e,{name:n,isPro:r})}))}))(jt()),Pt=function(e){return b.a.createElement(St,e)};function Ct(){return(Ct=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function _t(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return At(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return At(e,n)}(e,n)||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 At(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Tt(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function Nt(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n .neko-input {\n font-family: ",";\n font-size: ",";\n border: 2px solid ",";\n box-sizing: border-box;\n height: 30px;\n background: rgb(0 124 186 / 10%);\n padding: 0 10px;\n width: 100%;\n\n &::placeholder {\n color: rgba(0, 0, 0, 0.25);\n }\n\n :focus {\n background-color: white;\n }\n\n :read-only {\n background-color: ",";\n }\n }\n\n .neko-input-description {\n font-family: ",";\n font-size: ",";\n line-height: 14px;\n margin-top: 8px;\n margin-bottom: 0;\n }\n"]);return Nt=function(){return e},e}Pt.propTypes={name:y.a.string,mas:y.a.number,isPro:y.a.bool},Pt.defaultProps={name:void 0,mas:-1,isPro:!1};var zt=Object(C.a)((function(e){var n=e.id,t=e.name,r=e.value,a=void 0===r?"":r,o=e.description,i=e.placeholder,l=void 0===i?"":i,c=e.onEnter,u=void 0===c?null:c,s=e.readOnly,f=void 0!==s&&s,d=e.type,m=void 0===d?"text":d,p=e.step,g=void 0===p?1:p,y=e.min,v=void 0===y?1:y,E=e.max,x=void 0===E?999:E,w=e.maxLength,k=void 0===w?3:w,R=e.className,O=e.style,j=Tt(e,["id","name","value","description","placeholder","onEnter","readOnly","type","step","min","max","maxLength","className","style"]),S=_t(Object(h.useState)(a),2),P=S[0],C=S[1],_=!!e.onChange;Object(h.useEffect)((function(){_||C(a)}),[a]);var A=function(t){_?e.onChange(t.target.value,n):C(t.target.value,n)},T=function(t){u&&"Enter"===event.key&&(t.preventDefault(),e.onEnter(t.target.value,n))},N=function(t){e.onBlur&&a!==t.target.value&&e.onBlur(t.target.value,n)};return b.a.createElement("div",{className:[R].join(" "),style:O},"number"===m?b.a.createElement("input",Ct({className:"neko-input"},j,{id:n,name:t,value:_?a:P,type:m,step:g,min:v,max:x,maxlength:k,placeholder:l,onChange:A,onKeyPress:T,onBlur:N,readOnly:f})):b.a.createElement("input",Ct({className:"neko-input"},j,{id:n,name:t,value:_?a:P,type:m,spellcheck:"false",placeholder:l,onChange:A,onKeyPress:T,onBlur:N,readOnly:f})),o&&b.a.createElement("p",{className:"neko-input-description"},o))}))(Nt(),A.fontFamily,A.fontSizeText,A.blue,A.gray,A.fontFamily,A.fontSizeSmall),It=function(e){return b.a.createElement(zt,e)};It.propTypes={id:y.a.string,type:y.a.oneOf(["number","text"]),name:y.a.string,value:y.a.string,description:y.a.string,placeholder:y.a.string,onChange:y.a.func,onEnter:y.a.func,onBlur:y.a.func,readOnly:y.a.bool,step:y.a.number,min:y.a.number,max:y.a.number,maxLength:y.a.number},It.defaultProps={id:void 0,type:"text",name:void 0,value:"",description:void 0,placeholder:"",onChange:void 0,onEnter:void 0,onBlur:void 0,readOnly:!1,step:1,min:1,max:999,maxLength:3};var Mt=t(50),Ft=t.n(Mt),Bt=t(51),Lt=t.n(Bt);function qt(){var e=Zt(["\n background-color: ",";\n cursor: pointer;\n font-family: ",";\n padding: 8px 12px;\n\n &:hover {\n filter: brightness(80%);\n }\n\n input {\n display: none;\n }\n\n .option {\n align-items: center;\n color: ",";\n display: flex;\n justify-content: space-between;\n font-family: ",";\n font-size: 14px;\n line-height: 17px;\n }\n\n &.disabled {\n background-color: rgb(224 156 54);\n pointer-events: none;\n\n .option {\n color: rgb(255 255 255 / 35%);\n }\n }\n"]);return qt=function(){return e},e}function Ut(){var e=Zt(["\n font-family: ",";\n margin-bottom: 6px;\n\n input {\n display: none;\n }\n\n label {\n cursor: pointer;\n display: flex;\n }\n\n .inner-container {\n margin-left: 4px;\n\n .label {\n display: block;\n font-size: 14px;\n line-height: 17px;\n padding-top: 4.5px;\n padding-bottom: 4px;\n }\n .description {\n display: block;\n font-size: 12px;\n }\n }\n\n &.disabled {\n color: ",";\n\n label {\n cursor: default;\n }\n }\n"]);return Ut=function(){return e},e}function Dt(){return(Dt=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function Ht(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return Gt(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Gt(e,n)}(e,n)||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 Gt(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Wt(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function $t(){var e=Zt(["\n background-color: ",";\n"]);return $t=function(){return e},e}function Yt(){var e=Zt(["\n border-radius: 8px;\n overflow: hidden;\n padding-top: 28px;\n position: absolute;\n top: 0;\n z-index: 10;\n width: 100%;\n transition: all 0.2s ease-in;\n\n &.hidden {\n opacity: 0;\n }\n"]);return Yt=function(){return e},e}function Jt(){var e=Zt(["\n display: block;\n margin-top: 5px;\n font-size: 13px;\n line-height: 14px;\n color: #8a8a8a;\n\n * {\n font-size: 13px;\n line-height: inherit;\n margin: 0;\n }\n"]);return Jt=function(){return e},e}function Vt(){var e=Zt(["\n align-items: center;\n background-color: ",";\n border: 2px solid ",";\n border-radius: 8px;\n display: flex;\n font-family: ",";\n font-size: 14px;\n padding: 0 5px 0 10px;\n box-sizing: border-box;\n height: 30px;\n\n .rightContent {\n align-items: center;\n display: flex;\n margin-left: auto;\n }\n"]);return Vt=function(){return e},e}function Kt(){var e=Zt(["\n border-radius: 8px;\n position: relative;\n user-select: none;\n cursor: pointer;\n\n &.show-options {\n background-color: ",";\n border-radius: 8px 8px 0 0;\n }\n"]);return Kt=function(){return e},e}function Zt(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var Qt=C.a.div(Kt(),A.blue),Xt=C.a.div(Vt(),A.white,A.blue,A.fontFamily),er=C.a.div(Jt()),nr=C.a.div(Yt()),tr=C.a.div($t(),A.white),rr=function(e){var n,t=e.name,r=e.value,a=e.scrolldown,o=void 0!==a&&a,i=e.isPro,l=void 0!==i&&i,c=e.onChange,u=Wt(e,["name","value","scrolldown","isPro","onChange"]),s=null===(n=b.a.Children.toArray(e.children).find((function(e){return e.props.value===r})))||void 0===n?void 0:n.props,f=(null==s?void 0:s.label)||"Select",d=(null==s?void 0:s.description)||e.description,m=(null==s?void 0:s.requirePro)||!1,p=o?e.id:null==s?void 0:s.id,g=Ht(Object(h.useState)(!1),2),y=g[0],v=g[1],E=an((function(){v(!1)})),x=m&&!l,w=function(n){if(n!==r){if(!c)return void console.log("The onChange handler it not set for this checkbox.",e);c(n,p)}o&&v(!1)},k=b.a.Children.map(e.children,(function(e){return b.a.cloneElement(e,{name:e.props.name||t,checked:e.props.value===r,onClick:w,scrolldown:o,isPro:l})}));return o?b.a.createElement(Qt,Dt({id:p,ref:E},u,{onClick:function(){return v(!y)},className:["nui-select",y?"show-options":""],childrenLength:k.length}),b.a.createElement(Xt,null,f,b.a.createElement("div",{className:"rightContent"},x&&b.a.createElement(Je,null),b.a.createElement(T.Icon,{icon:y?K.a:J.a,width:"24"}))),d&&b.a.createElement(er,null,d),y&&b.a.createElement(nr,{className:y?"":"hidden"},b.a.createElement(tr,null,[k]))):k},ar=C.a.div(Ut(),A.fontFamily,A.disabledForm),or=C.a.div(qt(),A.blue,A.fontFamily,A.white,A.fontFamily),ir=function(e){var n=e.id,t=e.name,r=e.value,a=e.checked,o=e.label,i=e.description,l=e.onClick,c=e.scrolldown,u=e.isPro,s=void 0!==u&&u,f=e.requirePro,d=void 0!==f&&f&&!s,m=d?"disabled":"",p=b.a.createElement(ar,{className:"nui-select ".concat(e.className||""," ").concat(m)},b.a.createElement("input",{id:n,name:t,type:"radio",value:r,defaultChecked:a,onClick:function(e){return l(e.target.value)},disabled:d}),b.a.createElement("label",{htmlFor:n},b.a.createElement(T.Icon,{icon:a?Lt.a:Ft.a,width:"24px",color:d?A.disabledForm:A.blue}),b.a.createElement("div",{className:"inner-container"},b.a.createElement("span",{className:"label"},o,b.a.createElement(Je,{className:"inline",style:{top:-1},show:d})),i?b.a.createElement("small",{className:"description"},i):null))),h=b.a.createElement(or,{className:"nui-select ".concat(e.className||""," ").concat(m)},b.a.createElement("input",{id:n,name:t,type:"radio",value:r,defaultChecked:a,disabled:d}),b.a.createElement("div",{className:"option",onClick:function(){return l(r)}},o,b.a.createElement(Je,{show:d})));return c?h:p},lr=function(e){return b.a.createElement(rr,e)};lr.propTypes={id:y.a.string,name:y.a.string,description:y.a.string,scrolldown:y.a.bool,isPro:y.a.bool,onChange:y.a.func},lr.propTypes={id:void 0,name:void 0,description:void 0,scrolldown:!1,isPro:!1,onChange:void 0};var cr=function(e){return b.a.createElement(ir,e)};cr.propTypes={id:y.a.string,name:y.a.string,value:y.a.string,checked:y.a.bool,label:y.a.string,description:y.a.string,onClick:y.a.func,scrolldown:y.a.bool,isPro:y.a.bool,requirePro:y.a.bool},cr.defaultProps={id:void 0,name:void 0,value:void 0,checked:!1,label:void 0,description:void 0,onClick:void 0,scrolldown:!1,isPro:!1,requirePro:!1};var ur=t(18),sr=t.n(ur),fr=t(52),dr=t.n(fr),mr=t(53),pr=t.n(mr);function hr(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return br(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return br(e,n)}(e,n)||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 br(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function gr(){var e=Er(["\n border-left: 1px solid ",";\n margin-left: 12px;\n padding-left: 6px;\n\n &.no-line {\n border-left: 0;\n padding-left: 12px;\n }\n\n &.no-chevron {\n border-left: 0;\n margin-left: 0;\n padding-left: 0;\n }\n"]);return gr=function(){return e},e}function yr(){var e=Er(["\n height: 24px;\n width: 24px;\n"]);return yr=function(){return e},e}function vr(){var e=Er(["\n align-items: center;\n display: flex;\n margin-bottom: 8px;\n\n &.can-expand {\n cursor: pointer;\n }\n\n p {\n margin: 0 0 0 8px;\n }\n"]);return vr=function(){return e},e}function Er(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var xr=function(e){var n=e.chevron,t=void 0===n||n;return b.a.Children.map(e.children,(function(e){return b.a.cloneElement(e,{chevron:t})}))},wr=C.a.div(vr()),kr=C.a.div(yr()),Rr=C.a.div(gr(),A.finderBorder),Or=function(e){var n={gallery:pr.a},t=e.title,r=e.chevron,a=!e.icon,o=!!e.icon,i=!!e.children,l=hr(b.a.useState(!1),2),c=l[0],u=l[1],s=hr(b.a.useState((function(){return"string"==typeof e.icon&&Object.keys(n).includes(e.icon)?n[e.icon]:e.icon?e.icon:sr.a})),2),f=s[0],d=s[1],m=b.a.Children.map(e.children,(function(e){return b.a.cloneElement(e,{chevron:r})}));return b.a.createElement("div",null,b.a.createElement(wr,{onClick:function(){(a||i)&&(o||d(c?sr.a:dr.a),u(!c))},className:"".concat(a||m?"can-expand":"")},r?a||m?b.a.createElement(T.Icon,{icon:c?J.a:$.a,width:"1.5rem",height:"1.5rem"}):b.a.createElement(kr,null):null,b.a.createElement(T.Icon,{icon:f,color:A.blue,width:"1.5rem",height:"1.5rem"}),b.a.createElement("p",null,t)),c&&b.a.createElement(Rr,{className:"".concat(a?"":"no-line"," ").concat(r?"":"no-chevron")},m))},jr=function(e){return b.a.createElement(xr,e)};jr.propTypes={chevron:y.a.bool},jr.defaultProps={chevron:!0};var Sr=function(e){return b.a.createElement(Or,e)};function Pr(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n display: flex;\n width: 100%;\n height: 100%;\n max-width: 128px;\n max-height: 128px;\n\n & > * {\n width: 100%;\n height: auto;\n object-fit: contain;\n }\n"]);return Pr=function(){return e},e}Sr.propTypes={icon:y.a.oneOfType([y.a.instanceOf(T.IconifyIcon),y.a.oneOf(["gallery"])]),title:y.a.string},Sr.defaultProps={icon:sr.a,title:void 0};var Cr=C.a.div(Pr()),_r=function(){return b.a.createElement(Cr,null,b.a.createElement("svg",{width:"54",height:"38",viewBox:"0 0 54 38",fill:"none",xmlns:"http://www.w3.org/2000/svg"},b.a.createElement("path",{d:"M11.3663 9.40518C9.2981 -3.25522 -0.310763 2.76769 2.5163 9.40518C2.5163 9.40518 8.29338 29.9322 22.3059 26.3677C36.3184 22.8031 23.9038 19.1156 23.9038 19.1156C23.9038 19.1156 13.4345 22.0656 11.3663 9.40518Z",fill:"#724024",stroke:"black",strokeWidth:"2.1869"}),b.a.createElement("path",{d:"M10.7517 8.0531C10.0142 10.7573 6.32673 12.1093 3.99131 11.2489C1.65589 10.3885 2.63923 13.8302 5.09756 14.9364C7.55589 16.0427 11.2434 14.1989 12.1038 12.4781C12.9642 10.7573 11.4892 5.34893 10.7517 8.0531Z",fill:"#B7782E"}),b.a.createElement("path",{d:"M14.0705 17.2718C13.8246 19.2385 9.64547 19.976 7.55589 19.8531C5.46631 19.7302 9.76839 23.5406 11.3663 23.5406C12.9642 23.5406 17.3892 21.2052 17.1434 19.2385C16.8976 17.2718 14.3163 15.3052 14.0705 17.2718Z",fill:"#B7782E"}),b.a.createElement("path",{d:"M17.5121 26.2448C18.6184 25.3843 20.9538 21.8198 19.8476 19.8531C18.7413 17.8864 22.4288 20.9593 22.4288 20.9593L21.6913 26.2448C21.6913 26.2448 16.4059 27.1052 17.5121 26.2448Z",fill:"#B7782E"}),b.a.createElement("path",{d:"M10.7517 8.0531C10.0142 10.7573 6.32673 12.1093 3.99131 11.2489C1.65589 10.3885 2.63923 13.8302 5.09756 14.9364C7.55589 16.0427 11.2434 14.1989 12.1038 12.4781C12.9642 10.7573 11.4892 5.34893 10.7517 8.0531Z",stroke:"black"}),b.a.createElement("path",{d:"M14.0705 17.2718C13.8246 19.2385 9.64547 19.976 7.55589 19.8531C5.46631 19.7302 9.76839 23.5406 11.3663 23.5406C12.9642 23.5406 17.3892 21.2052 17.1434 19.2385C16.8976 17.2718 14.3163 15.3052 14.0705 17.2718Z",stroke:"black"}),b.a.createElement("path",{d:"M17.5121 26.2448C18.6184 25.3843 20.9538 21.8198 19.8476 19.8531C18.7413 17.8864 22.4288 20.9593 22.4288 20.9593L21.6913 26.2448C21.6913 26.2448 16.4059 27.1052 17.5121 26.2448Z",stroke:"black"}),b.a.createElement("path",{d:"M11.3663 9.40518C9.2981 -3.25522 -0.310763 2.76769 2.5163 9.40518C2.5163 9.40518 8.29338 29.9322 22.3059 26.3677C36.3184 22.8031 23.658 19.4843 23.658 19.4843C23.658 19.4843 13.4345 22.0656 11.3663 9.40518Z",stroke:"black",strokeWidth:"2.1869"}),b.a.createElement("path",{d:"M25.3788 9.89685C25.3788 9.89685 21.3225 35.0947 21.9371 35.7093C22.5517 36.3239 27.4684 36.3239 28.083 35.7093C28.6975 35.0947 29.6523 22.5858 30.2955 21.9427C30.9386 21.2995 35.7226 33.1281 36.81 33.1281C37.8975 33.1281 43.2303 21.3567 43.8163 21.9427C44.4023 22.5287 45.2913 35.0947 45.9059 35.7093C46.5204 36.3239 51.3142 36.3239 51.9288 35.7093C52.5434 35.0947 48.9788 9.89685 48.9788 9.89685H42.9559C42.9559 9.89685 37.7934 21.9427 36.81 21.9427C35.8267 21.9427 31.4017 9.89685 31.4017 9.89685H25.3788Z",fill:"white",stroke:"black",strokeWidth:"2.1869"})))},Ar=function(e){return b.a.createElement(_r,e)};function Tr(e){return(Tr="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})(e)}function Nr(){var e=Ir(["\n position: absolute;\n overflow: hidden;\n top: 0; left: 0;\n height: 100%;\n background-color: ",";\n border-radius: 12px;\n text-align: center;\n padding: 0 10px;\n vertical-align: middle;\n color: white;\n font-family: ",";\n font-size: 13px;\n display: flex;\n justify-content: center;\n align-items: center;\n transition: min-width .2s ease-out;\n\n background-size: 30px 30px;\n background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%,\n transparent 25%,\n transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,\n transparent 75%, transparent);\n animation: ",";\n\n @keyframes animate-stripes {\n 0% { background-position: 0 0; }\n 100% { background-position: 60px 0; }\n }\n"]);return Nr=function(){return e},e}function zr(){var e=Ir(["\n position: relative;\n box-sizing: border-box;\n height: 30px;\n background: linear-gradient(\n 180deg,\n rgba(0, 0, 0, 0.06) 0%,\n rgba(0, 0, 0, 0.02) 50%,\n rgba(0, 0, 0, 0.10) 100%\n );\n border-radius: 12px;\n\n .nui-progress-buttons {\n position: absolute;\n height: 100%;\n right: 0px;\n display: flex;\n align-items: center;\n padding-right: 5px;\n\n .nui-progress-button {\n border: none;\n display: flex;\n justify-content: center;\n align-items: center;\n margin-left: 2px;\n border-radius: 100%;\n color: white;\n padding: 2px;\n width: 18px;\n height: 18px;\n background-color: ",";\n\n &:hover {\n background-color: ",";\n }\n\n &.stop {\n background: ",";\n\n &:hover {\n background-color: ",";\n }\n }\n }\n }\n"]);return zr=function(){return e},e}function Ir(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Ar.propTypes={},Ar.defaultProps={};var Mr=Object(C.a)((function(e){var n=e.value,t=void 0===n?0:n,r=e.max,a=void 0===r?100:r,o=e.busy,i=void 0!==o&&o,l=e.status;t=Math.min(t,a);var c=parseFloat(t)/parseFloat(a);return b.a.createElement("div",{className:e.className},b.a.createElement(Fr,{ratio:c,busy:e.busy,status:l}),b.a.createElement("div",{className:"nui-progress-buttons"},i&&e.onPauseClick&&b.a.createElement("div",{className:"nui-progress-button pause",onClick:e.onPauseClick},e.paused?b.a.createElement(T.InlineIcon,{icon:ee.a}):b.a.createElement(T.InlineIcon,{icon:Q.a})),i&&e.onStopClick&&b.a.createElement("div",{className:"nui-progress-button stop",onClick:e.onStopClick},b.a.createElement(T.InlineIcon,{icon:ie.a}))))}))(zr(),A.blue,Object(_.a)(.1,A.blue),A.red,Object(_.a)(.1,A.red)),Fr=Object(C.a)((function(e){var n,t,r,a=isNaN(e.ratio)?0:parseInt(Math.round(100*e.ratio)),o=Tr(e.status),i="undefined"!==o?"string"===o?e.status:e.status(a):"".concat(a,"%");return b.a.createElement("div",{className:e.className,style:(n={minWidth:28},t="minWidth",r=a+"%",t in n?Object.defineProperty(n,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):n[t]=r,n)},b.a.createElement("div",null,i))}))(Nr(),A.progress,A.fontFamily,(function(e){return e.busy?"animate-stripes 1.6s linear infinite":"none"})),Br=function(e){return b.a.createElement(Mr,e)};function Lr(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return qr(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return qr(e,n)}(e,n)||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 qr(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Ur(){var e=Hr(["\n\tbackground-color: rgba(",", 0.8);\n\tborder-radius: 4px;\n\tcolor: ",";\n\tfont-family: ",";\n\tfont-weight: normal;\n\tmin-width: 180px;\n\tmax-width: 280px;\n\tfont-size: ",";\n\tpadding: 8px 12px;\n\tposition: absolute;\n \tmax-width: 280px;\n\tdisplay: ",';\n\tz-index: 100;\n\n\t&:before {\n\t\tcontent: "";\n\t\tposition: absolute;\n\t\tborder: 4px solid transparent;\n\t}\n\n\t&.top {\n\t\t&:before {\n\t\t\tmargin-left: -4px;\n\t\t\ttop: 100%;\n\t\t\tleft: 50%;\n\t\t\tborder-top: 4px solid rgba(',", 0.8);\n\t\t}\n\t}\n\n\t&.left {\n\t\t&:before {\n\t\t\tmargin-top: -4px;\n\t\t\ttop: 50%;\n\t\t\tright: -8px;\n\t\t\tborder-left: 4px solid rgba(",", 0.8);\n\t\t}\n\t}\n\n\t&.right {\n\t\t&:before {\n\t\t\tmargin-top: -4px;\n\t\t\ttop: 50%;\n\t\t\tleft: -8px;\n\t\t\tborder-right: 4px solid rgba(",", 0.8);\n\t\t}\n\t}\n\n\t&.bottom {\n\t\t&:before {\n\t\t\tmargin-left: -4px;\n\t\t\ttop: -8px;\n\t\t\tleft: 50%;\n\t\t\tborder-bottom: 4px solid rgba(",", 0.8);\n\t\t}\n\t}\n\n\t","\n"]);return Ur=function(){return e},e}function Dr(){var e=Hr(["\n\tdisplay: flex;\n"]);return Dr=function(){return e},e}function Hr(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Br.propTypes={value:y.a.number,max:y.a.number,busy:y.a.bool,paused:y.a.bool,onPauseClick:y.a.func,onStopClick:y.a.func,status:y.a.oneOf([y.a.string,y.a.func])},Br.defaultProps={value:0,max:100,busy:!1,paused:!1,onPauseClick:void 0,onStopClick:void 0,status:void 0};var Gr=C.a.div(Dr()),Wr=C.a.div(Ur(),A.blackRGB,A.white,A.fontFamily,A.fontSizeText,(function(e){return e.visible?"inline-block":"none"}),A.blackRGB,A.blackRGB,A.blackRGB,A.blackRGB,(function(e){return e.style})),$r=function(e){var n=e.text,t=void 0===n?"Hello world!":n,r=e.position,a=void 0===r?"top":r,o=Lr(Object(h.useState)(!1),2),i=o[0],l=o[1],c=rn(),u=c.ref,s=c.width,f=c.height,d=rn(),m=d.ref,p=d.width,g=d.height,y=Object(h.useMemo)((function(){var e=0,n=0;if("top"===a)e=-1*f-5,n=s/2*-1+p/2;else if("bottom"===a)e=g+5,n=s/2*-1+p/2;else if("left"===a){e=(f-g)/2*-1,n=-1*s-5}else if("right"===a){e=(f-g)/2*-1,n=p+5}return{transform:"translateX(".concat(n,"px) translateY(").concat(e,"px)")}}),[a,s,f,p,g]);return b.a.createElement(Gr,null,b.a.createElement(Wr,{ref:u,visible:i,className:a,style:y},t),b.a.createElement("div",{ref:m,onMouseEnter:function(){return l(!0)},onMouseLeave:function(){return l(!1)}},e.children))},Yr=function(e){return b.a.createElement($r,e)};function Jr(){return(Jr=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function Vr(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function Kr(){var e=Qr(["\n\n &.nui-clickable {\n cursor: pointer;\n }\n\n &.spin {\n animation-name: spin;\n animation-duration: 700ms;\n animation-iteration-count: infinite;\n animation-timing-function: linear;\n\n @keyframes spin {\n 0% {\n transform: rotate(360deg);\n }\n 100% {\n transform: rotate(0deg);\n }\n }\n }\n"]);return Kr=function(){return e},e}function Zr(){var e=Qr(["\n display: flex;\n align-items: center;\n"]);return Zr=function(){return e},e}function Qr(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Yr.propTypes={text:y.a.string,position:y.a.oneOf(["top","right","bottom","left"])},Yr.defaultProps={text:"Hello world!",position:"top"};var Xr=C.a.div(Zr()),ea=Object(C.a)(T.Icon)(Kr()),na=function(e){var n=e.icon,t=e.spinning,r=void 0!==t&&t,a=e.className,o=void 0===a?"":a,i=e.tooltip,l=e.containerStyle,c=Vr(e,["icon","spinning","className","tooltip","containerStyle"]);c.width||c.height||(c.width=c.height=30);var u=function(){return"string"==typeof n?Me[n]||null:n},s="nui-icon ".concat(o).concat(c.onClick?" nui-clickable":"").concat(r?" spin":"");return i?b.a.createElement(Yr,{text:i.text,position:i.position||"top"},b.a.createElement(Xr,{style:l},b.a.createElement(ea,Jr({icon:u(),className:s},c)))):b.a.createElement(Xr,{style:l},b.a.createElement(ea,Jr({icon:u(),className:s},c)),i?b.a.createElement(Yr,null,i):null)},ta=function(e){return b.a.createElement(na,e)};ta.propTypes={icon:y.a.oneOfType([y.a.instanceOf(T.IconifyIcon),y.a.oneOf(["lock","lock-open","file-undo","chevron-double-left","chevron-double-right","chevron-left","chevron-right","chevron-down","chevron-up","pause","play","replay","check","stop","delete","undo","alert","database","pencil","tools","cog","close","cat","upload"])]),spinning:y.a.bool,className:y.a.string,tooltip:y.a.string},ta.defaultProps={icon:void 0,spinning:!1,className:"",tooltip:void 0};var ra=t(54),aa=t.n(ra);function oa(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n position: relative;\n color: white;\n font-family: ",";\n font-size: ",";\n display: flex;\n align-items: center;\n padding: 15px 20px;\n background-color: ",";\n border-bottom: 5px #2981b5 solid;\n display: flex;\n\n .nui-header-logo-container {\n width: 55px;\n height: 55px;\n padding: 10px;\n margin-right: 20px;\n background: #3D5D8D;\n border-radius: 100%;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n\n .nui-header-title-container {\n flex-direction: column;\n display: flex;\n\n .nui-header-title {\n color: white;\n font-family: ",";\n font-size: 23px;\n line-height: normal;\n margin: 0;\n }\n\n .nui-header-subtitle {\n color: white;\n font-family: ",";\n line-height: normal;\n font-size: ",";\n }\n }\n\n .nui-header-extra-content {\n flex: 1;\n margin: 0 20px;\n }\n"]);return oa=function(){return e},e}var ia=C.a.div(oa(),A.fontFamily,A.fontSizeText,A.header,A.fontFamily,A.fontFamily,A.fontSizeText),la=function(e){var n=e.title,t=void 0===n?"NekoUI":n,r=e.subtitle,a=void 0===r?"By Jordy Meow":r,o=e.children,i=e.saving,l=void 0!==i&&i;return b.a.createElement(ia,null,b.a.createElement("div",{className:"nui-header-logo-container"},b.a.createElement(Ar,null)),b.a.createElement("div",{className:"nui-header-title-container"},b.a.createElement("h1",{className:"nui-header-title"},t),b.a.createElement("small",{className:"nui-header-subtitle"},b.a.createElement("a",{target:"_blank",href:"https://meowapps.com",style:{color:"white",textDecoration:"none"}},a))),b.a.createElement("div",{className:"nui-header-extra-content"},o),l&&b.a.createElement(ta,{icon:aa.a,width:"36",height:"36"}))},ca=function(e){return b.a.createElement(la,e)};function ua(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n align-items: center;\n display: flex;\n\n .neko-paging-text {\n font-family: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 15px;\n line-height: 14px;\n }\n\n .neko-paging-controller {\n box-sizing: border-box;\n height: 30px;\n align-items: center;\n background-color: rgba(",", 0.8);\n border-radius: 15px;\n display: flex;\n margin-left: 15px;\n padding: 3px 5px;\n\n .nako-paging-controller-icon {\n background-color: ",";\n border-radius: 100%;\n cursor: pointer;\n margin-right: 2px;\n height: 22px;\n width: 22px;\n box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.25);\n transition: transform 0.1s ease-in;\n box-sizing: border-box;\n\n :last-child {\n margin-right: 0;\n }\n\n &.disabled {\n color: ",";\n cursor: default;\n pointer-events: none;\n }\n\n &:hover {\n transform: scale(1.2) !important;\n z-index: 10;\n position: relative;\n }\n }\n\n .nako-paging-controller-text {\n color: ",";\n font-family: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 13px;\n margin: 0 40px;\n user-select: none;\n }\n }\n"]);return ua=function(){return e},e}ca.propTypes={title:y.a.string,subtitle:y.a.string,saving:y.a.bool},ca.defaultProps={title:"NekoUI",subtitle:"By Jordy Meow",saving:!1};var sa=C.a.div(ua(),A.fontFamily,A.blueRGB,A.white,A.darkGray,A.white,A.fontFamily),fa=function(e){var n=e.currentPage,t=e.limit,r=e.onClick,a=e.total,o=Math.ceil(0===a?1:t>0?a/t:1),i="nako-paging-controller-icon ".concat(1===n?"disabled":""),l="nako-paging-controller-icon ".concat(n===o?"disabled":""),c=function(e){r(e)};return b.a.createElement(sa,null,b.a.createElement("span",{className:"neko-paging-text"},a," result",a>0?"s":""),b.a.createElement("div",{className:"neko-paging-controller"},b.a.createElement(T.Icon,{icon:q.a,className:i,onClick:function(){return c(1)}}),b.a.createElement(T.Icon,{icon:G.a,className:i,onClick:function(){return c(n-1)}}),b.a.createElement("p",{className:"nako-paging-controller-text"},"Page ",n," of ",o),b.a.createElement(T.Icon,{icon:$.a,className:l,onClick:function(){return c(n+1)}}),b.a.createElement(T.Icon,{icon:D.a,className:l,onClick:function(){return c(o)}})))},da=function(e){return b.a.createElement(fa,e)};function ma(){var e=ha(["\n color: ",";\n cursor: pointer;\n font-family: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 14px;\n line-height: 17px;\n\n &.is-active {\n cursor: default;\n color: ",';\n font-weight: bold;\n }\n\n &::after {\n content: "|";\n color: ',";\n padding: 0 4px;\n }\n\n &:last-child::after {\n content: none;\n }\n\n span {\n color: ",";\n font-weight: normal;\n margin-left: 4px;\n }\n"]);return ma=function(){return e},e}function pa(){var e=ha(["\n display: flex;\n align-items: center;\n"]);return pa=function(){return e},e}function ha(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}da.propTypes={currentPage:y.a.number,limit:y.a.number,total:y.a.number,onClick:y.a.func},da.defaultProps={currentPage:void 0,limit:void 0,total:void 0,onClick:void 0};var ba=C.a.div(pa()),ga=C.a.span(ma(),A.blue,A.fontFamily,A.black,A.darkGray,A.darkGray),ya=function(e){var n=e.id,t=e.value,r=e.onChange,a=e.busy,o=void 0!==a&&a,i=b.a.Children.map(e.children,(function(e,a){return b.a.cloneElement(e,{busy:o,isActive:e.props.value===t,onClick:function(e){e!==t&&r(e,n)}})}));return b.a.createElement(ba,null,i)},va=function(e){var n=e.title,t=e.value,r=void 0===t?0:t,a=e.count,o=e.onClick,i=e.busy,l=e.isActive;return b.a.createElement(ga,{onClick:function(){return o(r)},className:"".concat(l?"is-active":"")},n,b.a.createElement("span",null,"(",i?b.a.createElement(ta,{icon:"replay",spinning:!0,width:12,containerStyle:{display:"inline"}}):a,")"))},Ea=function(e){return b.a.createElement(ya,e)};Ea.propTypes={id:y.a.string,value:y.a.string,onChange:y.a.func},Ea.defaultProps={id:void 0,value:void 0,onChange:void 0};var xa=function(e){return b.a.createElement(va,e)};function wa(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n .mask {\n position: absolute;\n overflow: hidden;\n display: block;\n width: ","px;\n height: ","px;\n }\n\n .semi-circle {\n position: relative;\n display: block;\n width: ","px;\n height: ",'px;\n background: linear-gradient(to right, #27b775 0%, #f3f32c 50%, #f71b1b 100%);\n border-radius: 50% 50% 50% 50% / 100% 100% 0% 0% ;\n\n &::before {\n content: "";\n position: absolute;\n bottom: 0;\n left: 50%;\n z-index: 2;\n display: block;\n width: 140px;\n height: 70px;\n margin-left: -70px;\n background: ',";\n border-radius: 50% 50% 50% 50% / 100% 100% 0% 0% ;\n } \n }\n\n .semi-circle--mask {\n position: absolute;\n top: 0;\n left: 0;\n width: ","px;\n height: ",'px;\n background: transparent;\n transform-origin: center center;\n backface-visibility: hidden;\n transition: all .3s ease-in-out;\n\n &::before {\n content: "";\n position: absolute;\n top: 0;\n left: 0%;\n z-index: 2;\n display: block;\n width: ',"px;\n height: ","px;\n margin-top: -1px;\n margin-left: -1px;\n background: #5396c1d6;\n border-radius: 50% 50% 50% 50% / 100% 100% 0% 0% ;\n } \n }\n\n .gauge { \n width: ","px;\n height: ","px;\n \n .semi-circle--mask {\n transform: rotate(","deg) translate3d(0,0,0);\n }\n }\n\n .child-container {\n position: absolute;\n font-size: 16px;\n display: flex;\n width: ","px;\n height: ","px;\n z-index: 10;\n\n .spacing {\n flex: auto;\n }\n\n .child {\n color: white;\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n }\n"]);return wa=function(){return e},e}xa.propTypes={title:y.a.string,value:y.a.string,count:y.a.number,onClick:y.a.func,isActive:y.a.bool},xa.defaultProps={title:void 0,value:"default",count:0,onClick:void 0,isActive:!1};var ka=C.a.section(wa(),(function(e){return e.width}),(function(e){return e.width/2}),(function(e){return e.width}),(function(e){return e.width/2}),(function(e){return e.backgroundColor}),(function(e){return e.width}),(function(e){return e.width}),(function(e){return e.width+2}),(function(e){return e.width/2+2}),(function(e){return e.width}),(function(e){return e.width/2}),(function(e){return e.degrees}),(function(e){return e.width+2}),(function(e){return e.width/2})),Ra=function(e){var n=e.value,t=void 0===n?1e3:n,r=(e.min,e.max),a=void 0===r?2500:r,o=e.width,i=void 0===o?200:o,l=e.background,c=void 0===l?"#007cba":l,u=e.children,s=180*(t<=a?t:a)/a;return b.a.createElement(ka,{backgroundColor:c,degrees:s,width:i},b.a.createElement("div",{class:"gauge"},b.a.createElement("div",{class:"mask"},b.a.createElement("div",{class:"semi-circle"}),b.a.createElement("div",{class:"semi-circle--mask"})),b.a.createElement("div",{class:"child-container"},b.a.createElement("div",{class:"child"},b.a.createElement("div",{class:"spacing"}),u))))};function Oa(){var e=Sa(["\n background: #1eba96;\n padding: 20px;\n color: white;\n border-radius: 10px;\n font-size: 15px;\n text-align: center;\n\n a {\n color: white;\n font-weight: bold;\n }\n"]);return Oa=function(){return e},e}function ja(){var e=Sa(["\n background: #ba341e;\n padding: 20px;\n color: white;\n border-radius: 10px;\n font-size: 15px;\n\n a {\n color: white;\n font-weight: bold;\n }\n"]);return ja=function(){return e},e}function Sa(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var Pa=C.a.p(ja()),Ca=C.a.p(Oa()),_a=t(55),Aa=t.n(_a);function Ta(){return(Ta=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function Na(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function za(){var e=Ma(["\n width: 518px;\n\n p {\n margin: 0;\n }\n .title {\n font-family: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 18px;\n line-height: 22px;\n }\n .content {\n font-family: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 13px;\n line-height: 14px;\n margin-top: 15px;\n margin-bottom: 30px;\n }\n .button-group {\n align-items: center;\n display: flex;\n justify-content: flex-end;\n margin-top: 15px;\n }\n"]);return za=function(){return e},e}function Ia(){var e=Ma(["\n\n .ReactModal__Overlay {\n z-index: 100;\n display: flex;\n justify-content: center;\n flex-direction: column;\n align-items: center;\n background: "," !important;\n }\n .ReactModal__Overlay {\n opacity: 0;\n transition: opacity 200ms ease-in-out;\n }\n .ReactModal__Overlay--after-open {\n opacity: 1;\n }\n .ReactModal__Overlay--before-close {\n opacity: 0;\n }\n .ReactModal__Overlay .neko-modal {\n opacity: 0;\n transform: scale(0.85);\n transition: all 200ms ease-in-out;\n }\n .ReactModal__Overlay--after-open .neko-modal {\n transform: scale(1);\n opacity: 1;\n }\n .ReactModal__Overlay--before-close .neko-modal {\n transform: scale(0.85);\n opacity: 0;\n }\n .neko-modal {\n background: ",";\n position: relative;\n box-shadow: 2px 2px 15px 2px rgba(0, 0, 0, 0.8);\n outline: none;\n padding: 15px;\n max-width: 820px;\n }\n"]);return Ia=function(){return e},e}function Ma(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var Fa=C.a.div(Ia(),A.overlay,A.white),Ba=C.a.div(za(),A.fontFamily,A.fontFamily),La=function(e){var n=e.children,t=e.className,r=e.style,a=e.ok,o=void 0===a?"OK":a,i=e.cancel,l=void 0===i?"Cancel":i,c=e.customButtons,u=void 0===c?null:c,s=e.title,f=void 0===s?"":s,d=e.content,m=void 0===d?"":d,p=e.onOkClick,h=e.onCancelClick,g=Na(e,["children","className","style","ok","cancel","customButtons","title","content","onOkClick","onCancelClick"]),y=r?"custom-modal":"",v=n||b.a.createElement(Ba,null,f&&b.a.createElement("p",{className:"title"},f),m&&b.a.createElement("p",{className:"content"},m),b.a.createElement("div",{className:"button-group"},h&&b.a.createElement(De,{className:"danger",onClick:h},l),p&&b.a.createElement(De,{onClick:p},o),u));return b.a.createElement(b.a.Fragment,null,b.a.createElement(Fa,{id:"neko-modal-parent"}),b.a.createElement(Aa.a,Ta({ariaHideApp:!1,parentSelector:function(){return document.getElementById("neko-modal-parent")},closeTimeoutMS:200,className:"neko-modal ".concat(t||""," ").concat(y)},g),v))},qa=function(e){return b.a.createElement(La,e)};qa.propTypes={className:y.a.string,style:y.a.object,ok:y.a.string,cancel:y.a.string,title:y.a.string,content:y.a.string,onOkClick:y.a.func,onCancelClick:y.a.func,customButtons:y.a.object},qa.defaultProps={className:void 0,style:void 0,ok:"OK",cancel:"Cancel",title:"",content:"",onOkClick:void 0,onCancelClick:void 0,customButtons:null};var Ua=t(56),Da=t.n(Ua);function Ha(e,n){if(null==e)return{};var t,r,a=function(e,n){if(null==e)return{};var t,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(a[t]=e[t]);return a}(e,n);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(a[t]=e[t])}return a}function Ga(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n background-color: ",";\n font-family: ",";\n border-spacing: 0;\n width: 100%;\n\n th, td {\n margin: 0;\n padding: 5px;\n border-bottom: 1px solid rgba(",", 0.1);\n border-right: 1px solid rgba(",", 0.1);\n\n a {\n text-decoration: none;\n }\n\n :last-child {\n border-right: 0;\n }\n }\n\n th, tfoot td {\n height: 30px;\n background-color: ",";\n color: ",";\n font-style: normal;\n font-weight: normal;\n font-size: 13px;\n line-height: 16px;\n text-align: left;\n\n div {\n display: flex;\n align-items: center;\n justify-content: space-between;\n\n &.sortable {\n cursor: pointer;\n }\n }\n }\n\n tbody {\n tr {\n :nth-child(even) {\n background-color: ",";\n }\n &.selected {\n background-color: rgba(",", 0.8);\n color: ",";\n\n a {\n color: #81e8ff;\n }\n }\n }\n img {\n vertical-align: bottom;\n }\n }\n\n tfoot tr:last-child {\n td {\n border-bottom: 0;\n }\n }\n\n .table-checkbox-cell {\n width: 35px;\n text-align: center;\n\n svg {\n padding: 5px;\n cursor: pointer;\n }\n }\n"]);return Ga=function(){return e},e}var Wa=C.a.table(Ga(),A.white,A.fontFamily,A.blackRGB,A.blackRGB,A.blue,A.white,A.tableGray,A.blueRGB,A.white),$a=function(e){var n=e.checked,t=e.intermediate,r=void 0!==t&&t,a=e.onSelect,o=void 0===a?function(){}:a,i=e.onUnselect,l=void 0===i?function(){}:i;Ha(e,["checked","intermediate","onSelect","onUnselect"]);return b.a.createElement(T.Icon,{icon:r?Da.a:n?wt.a:Et.a,width:"24px",height:"24px",onClick:function(){n?l():o()}})},Ya=function(e){var n=e.columns,t=e.data,r=e.busy,a=void 0!==r&&r,o=e.onSelect,i=e.onUnselect,l=e.selectedItems,c=e.sort,u=e.onSortChange,s=n.length+(o?1:0),f=t.map((function(e){var t=n.map((function(n){return{value:e[n.accessor],style:n.style||{}}}));return{id:e.id,cells:t}})),d=f.map((function(e){return e.id})),m=d.filter((function(e){return l.includes(e)})).length===d.length,p=!m&&l.length>0,h=b.a.createElement("tr",null,o&&b.a.createElement("th",{className:"table-checkbox-cell"},b.a.createElement($a,{checked:m,intermediate:p,onSelect:function(){return o(d)},onUnselect:function(){i(p?l:d)}})),n.map((function(e){var n=c&&c.accessor===e.accessor,t=c&&"asc"===c.by,r=e.style||{};return b.a.createElement("th",{style:r,key:e.accessor},b.a.createElement("div",{className:e.sortable?"sortable":"",onClick:e.sortable?function(){u(e.accessor,n&&t?"desc":"asc")}:void 0},b.a.createElement("div",null,e.title),b.a.createElement("div",null,e.sortable&&b.a.createElement(T.Icon,{icon:n?t?J.a:K.a:J.a,color:n?A.white:"rgba(".concat(A.blackRGB,", 0.1)"),width:"1.6rem",height:"1.6rem"}))))})));return b.a.createElement(P,{busy:a,overlayStyle:{top:"36px",height:"calc(100% - 76px)"}},b.a.createElement(Wa,null,b.a.createElement("thead",null,h),b.a.createElement("tbody",null,!f.length&&b.a.createElement("tr",null,b.a.createElement("td",{colspan:s,style:{textAlign:"center",height:40,color:"gray"}},"Empty.")),f.map((function(e){return b.a.createElement("tr",{className:l.includes(e.id)?"selected":""},o&&b.a.createElement("td",{className:"table-checkbox-cell"},b.a.createElement($a,{checked:l.includes(e.id),onSelect:function(){return o([e.id])},onUnselect:function(){return i([e.id])}})),e.cells.map((function(e){return b.a.createElement("td",{style:e.style},e.value)})))}))),b.a.createElement("tfoot",null,h)))},Ja=function(e){return b.a.createElement(Ya,e)};function Va(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return Ka(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Ka(e,n)}(e,n)||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 Ka(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Za(){var e=no(["\n background-color: ",";\n display: none;\n padding: 10px;\n\n &.active {\n display: block;\n }\n"]);return Za=function(){return e},e}function Qa(){var e=no(["\n font-family: ",";\n font-size: ",";\n border-radius: 8px 8px 0px 0px;\n border: 0;\n background-color: #459ad2;\n color: rgb(255 255 255 / 35%);\n\n cursor: pointer;\n line-height: 17px;\n margin-right: 5px;\n text-align: left;\n padding: 10px 15px 10px 15px;\n\n &:focus {\n outline: none;\n }\n\n &.active {\n background-color: ",";\n color: ",";\n }\n\n &.disabled {\n background-color: rgb(224 156 54);\n cursor: default;\n display: inline-flex;\n padding-bottom: 7px;\n }\n"]);return Qa=function(){return e},e}function Xa(){var e=no(["\n"]);return Xa=function(){return e},e}function eo(){var e=no(["\n"]);return eo=function(){return e},e}function no(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}Ja.propTypes={columns:y.a.arrayOf(y.a.any),data:y.a.arrayOf(y.a.any),busy:y.a.arrayOf(y.a.bool),onSelect:y.a.func,onUnselect:y.a.func,selectedItems:y.a.arrayOf(y.a.object),onSortChange:y.a.func},Ja.defaultProps={columns:void 0,data:void 0,busy:!1,onSelect:void 0,onUnselect:void 0,selectedItems:void 0,onSortChange:void 0};var to=C.a.div(eo()),ro=C.a.div(Xa()),ao=C.a.button(Qa(),A.fontFamily,A.fontSizeText,A.blue,A.white),oo=C.a.div(Za(),A.blue),io=function(e){var n=Va(b.a.useState(0),2),t=n[0],r=n[1],a=b.a.Children.map(e.children,(function(n,t){var r=n.props.title||"Untitled Tab "+(t+1);return{key:n.props.key||"neko-tab-"+r.toLowerCase(),title:r,onClick:n.props.onClick?n.props.onClick:null,requirePro:!e.isPro&&(n.props.requirePro||!1)}})),o=b.a.Children.map(e.children,(function(e,n){return b.a.cloneElement(e,{isActive:n===t})}));return b.a.createElement(to,null,b.a.createElement(ro,null,a.map((function(n,a){return b.a.createElement(ao,{key:n.key,className:"neko-tab-title ".concat(a===t?"active":""," ").concat(n.requirePro?"disabled":""),onClick:function(t){!function(n,t,a){t.requirePro||(r(n),e.onChange&&e.onChange(n,t,a))}(a,n,t)}},n.title,b.a.createElement(Je,{className:"inline",style:{marginLeft:10,marginRight:-5,top:-1},show:n.requirePro}))}))),o)},lo=function(e){var n=e.children,t=e.isActive;return b.a.createElement(oo,{className:"".concat(t?"active":"")},n)},co=function(e){return b.a.createElement(io,e)};co.propTypes={isPro:y.a.bool,onChange:y.a.func},co.defaultProps={isPro:!1,onChange:void 0};var uo=function(e){return b.a.createElement(lo,e)};function so(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return fo(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return fo(e,n)}(e,n)||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 fo(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function mo(){var e=bo(["\n background-color: ",";\n display: none;\n\n &.active {\n display: block;\n }\n"]);return mo=function(){return e},e}function po(){var e=bo(["\n align-items: center;\n background-color: ",";\n border: 0;\n cursor: pointer;\n display: flex;\n padding: 2px 3px 2px 19px;\n\n &.disabled {\n background-color: rgba(",", 0.25);\n cursor: default;\n }\n\n p {\n color: ",";\n font-family: ",";\n font-size: 14px;\n line-height: 17px;\n margin: 0;\n }\n\n .neko-side-tab-icon {\n color: ",";\n margin-left: auto;\n height: 36px;\n width: 36px;\n }\n"]);return po=function(){return e},e}function ho(){var e=bo(["\n"]);return ho=function(){return e},e}function bo(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}uo.propTypes={isActive:y.a.bool,requirePro:y.a.bool,title:y.a.string},uo.defaultProps={isActive:!1,requirePro:!1,title:void 0};var go=C.a.div(ho()),yo=C.a.div(po(),A.blue,A.yellowRGB,A.white,A.fontFamily,A.white),vo=C.a.div(mo(),A.white),Eo=function(e){var n=so(b.a.useState(),2),t=n[0],r=n[1],a=b.a.Children.map(e.children,(function(n,t){var r=n.props.title||"Untitled Tab "+(t+1);return{key:n.props.key||"neko-tab-"+r.toLowerCase(),title:r,onClick:n.props.onClick?n.props.onClick:null,requirePro:!e.isPro&&(n.props.requirePro||!1)}})),o=b.a.Children.map(e.children,(function(e,n){return b.a.cloneElement(e,{isActive:n===t})}));return b.a.createElement(go,null,a.map((function(n,a){return b.a.createElement(b.a.Fragment,null,b.a.createElement(yo,{key:n.key,className:"".concat(a===t?"active":""," ").concat(n.requirePro?"disabled":""),onClick:function(o){!function(n,a,o){if(!a.requirePro){var i=n===t?null:n;r(i),e.onChange&&e.onChange(i,a,o)}}(a,n,o)}},b.a.createElement("p",null,n.title,b.a.createElement(Je,{className:"inline",show:n.requirePro})),b.a.createElement(T.Icon,{icon:a===t?J.a:$.a,className:"neko-side-tab-icon"})),o[a])})))},xo=function(e){var n=e.children,t=e.isActive;return b.a.createElement(vo,{className:"".concat(t?"active":"")},n)},wo=function(e){return b.a.createElement(Eo,e)};wo.propTypes={isPro:y.a.bool,onChange:y.a.func},wo.defaultProps={isPro:!1,onChange:void 0};var ko=function(e){return b.a.createElement(xo,e)};function Ro(){var e=function(e,n){n||(n=e.slice(0));return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}(["\n box-sizing: border-box;\n display: flex;\n width: 100%;\n padding: 10px 10px;\n background: ",";\n border-radius: 10px;\n box-shadow: 0px 0px 10px rgba(",", 0.1);\n\n &.left {\n justify-content: flex-start;\n }\n\n &.right {\n justify-content: flex-end;\n }\n\n > *:not(:last-child) {\n margin-right: 5px;\n }\n"]);return Ro=function(){return e},e}ko.propTypes={isActive:y.a.bool,requirePro:y.a.bool,title:y.a.string},ko.defaultProps={isActive:!1,requirePro:!1,title:void 0};var Oo=C.a.div(Ro(),A.white,A.blackRGB),jo=function(e){var n=e.align,t=void 0===n?"left":n;return b.a.createElement(Oo,{className:t},e.children)},So=function(e){return b.a.createElement(jo,e)};So.propTypes={align:y.a.oneOf(["left","right"])},So.defaultProps={align:"left"};t(21);function Po(e){return(Po="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})(e)}function Co(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}function _o(e,n){return!n||"object"!==Po(n)&&"function"!=typeof n?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):n}function Ao(e){var n="function"==typeof Map?new Map:void 0;return(Ao=function(e){if(null===e||(t=e,-1===Function.toString.call(t).indexOf("[native code]")))return e;var t;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==n){if(n.has(e))return n.get(e);n.set(e,r)}function r(){return To(e,arguments,Io(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),zo(r,e)})(e)}function To(e,n,t){return(To=No()?Reflect.construct:function(e,n,t){var r=[null];r.push.apply(r,n);var a=new(Function.bind.apply(e,r));return t&&zo(a,t.prototype),a}).apply(null,arguments)}function No(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function zo(e,n){return(zo=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e})(e,n)}function Io(e){return(Io=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var Mo=function(e){!function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&zo(e,n)}(a,e);var n,t,r=(n=a,t=No(),function(){var e,r=Io(n);if(t){var a=Io(this).constructor;e=Reflect.construct(r,arguments,a)}else e=r.apply(this,arguments);return _o(this,e)});function a(e){var n,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,l=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};return Co(this,a),(n=r.call(this,e)).name="NekoError",n.url=o,n.code=t,n.body=i,n.debug=l,n.toString=function(){return n.url},n}return a}(Ao(Error));function Fo(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function Bo(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Fo(o,r,a,i,l,"next",e)}function l(e){Fo(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Lo(e,n){var t;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(t=function(e,n){if(!e)return;if("string"==typeof e)return qo(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return qo(e,n)}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0,a=function(){};return{s:a,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:a}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,l=!1;return{s:function(){t=e[Symbol.iterator]()},n:function(){var e=t.next();return i=e.done,e},e:function(e){l=!0,o=e},f:function(){try{i||null==t.return||t.return()}finally{if(l)throw o}}}}function qo(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Uo(e,n){for(var t=[],r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}var Do=function(e){if(!e.data)return e;if(e.data.length>0&&e.data[0].meta){var n,t=Lo(e.data);try{for(t.s();!(n=t.n()).done;){var r=n.value;try{r.meta=JSON.parse(r.meta)}catch(e){console.error("[JsonFetcher]","Could not decode meta.",r.meta)}}}catch(e){t.e(e)}finally{t.f()}}else if(e.data.meta)try{e.data.meta=JSON.parse(e.data.meta)}catch(e){console.error("[JsonFetcher]","Could not decode meta.",x.meta)}return e},Ho=function(){var e=Bo(regeneratorRuntime.mark((function e(n){var t,r,a,o,i,l,c=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=c.length>1&&void 0!==c[1]?c[1]:{},e.next=3,fetch("".concat(n),t);case 3:return r=e.sent,a=null,o=null,i=null,e.prev=7,e.next=10,r.text();case 10:a=e.sent,(o=JSON.parse(a)).success||(l="rest_no_route"===o.code?"NO-ROUTE":"NOT-SUCCESS",i=new Mo(o.message,l,n)),e.next=19;break;case 15:e.prev=15,e.t0=e.catch(7),"BROKEN",i=new Mo("The reply sent by the server is broken.","BROKEN",n,a,e.t0);case 19:if(!i){e.next=22;break}throw console.error("[NekoError] JsonFetcher",i.url,{code:i.code,error:i.error,body:i.body}),i;case 22:return e.abrupt("return",Do(o));case 23:case"end":return e.stop()}}),e,null,[[7,15]])})));return function(n){return e.apply(this,arguments)}}(),Go=function(){var e=Bo(regeneratorRuntime.mark((function e(n,t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Ho(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),signal:r}));case 1:case"end":return e.stop()}}),e)})));return function(n,t,r){return e.apply(this,arguments)}}();function Wo(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function $o(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Wo(o,r,a,i,l,"next",e)}function l(e){Wo(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Yo(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return Jo(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Jo(e,n)}(e,n)||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 Jo(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var Vo=wp.element,Ko=Vo.useState,Zo=Vo.useEffect,Qo=function(e){var n=e.mutate,t=Yo(Ko(e.entry),2),r=t[0],a=t[1],i=Yo(Ko(!1),2),l=i[0],c=i[1],s=Yo(Ko(""),2),f=s[0],d=s[1],h=Yo(Ko(null),2),b=h[0],g=h[1];Zo((function(){d(""),e.entry?a(e.entry):e.mediaId&&y(e.mediaId)}),[e.entry]);var y=function(){var e=$o(regeneratorRuntime.mark((function e(n){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c((function(e){return e+1})),e.next=3,Go("".concat(u,"/analyze"),{mediaId:n});case 3:t=e.sent,a(t.data),c((function(e){return e-1}));case 6:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),v=function(){var e=$o(regeneratorRuntime.mark((function e(n){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:d(n);case 1:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),E=function(){var e=$o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a(t),n&&n();case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),x=function(){var e=$o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c((function(e){return e+1})),e.next=3,Go("".concat(u,"/rename"),{mediaId:r.ID});case 3:n=e.sent,E(n.data),g(null),c((function(e){return e-1}));case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),w=function(){var e=$o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c((function(e){return e+1})),e.next=3,Go("".concat(u,"/rename"),{mediaId:r.ID,filename:f});case 3:n=e.sent,E(n.data),g(null),d(""),c((function(e){return e-1}));case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),k=function(){var e=$o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c((function(e){return e+1})),e.next=3,Go("".concat(u,"/undo"),{mediaId:r.ID});case 3:n=e.sent,E(n.data,r.current_filename),c((function(e){return e-1}));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),R=function(){var e=$o(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c((function(e){return e+1})),e.next=3,Go("".concat(u,"/set_lock"),{mediaId:r.ID,lock:!r.locked});case 3:n=e.sent,E(n.data),c((function(e){return e-1}));case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),O=!!f,j=O?f:b||(null==r?void 0:r.current_filename);return React.createElement(P,{busy:l},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(It,{readOnly:!p||l,value:j,onChange:v,onEnter:w,style:{marginRight:5,flex:"auto"}}),!O&&React.createElement(ta,{icon:(null==r?void 0:r.locked)?"lock":"lock-open",width:24,style:{position:"relative",left:-34,marginRight:-22},color:(null==r?void 0:r.locked)?A.blue:"#5a5a5a82",onClick:R}),O&&React.createElement(ta,{icon:"close",width:24,style:{position:"relative",left:-34,marginRight:-22},color:(null==r?void 0:r.locked)?A.blue:"#5a5a5a82",onClick:function(){d("")}}),!O&&(null==r?void 0:r.proposed_filename)&&!(null==r?void 0:r.proposed_filename_exists)&&React.createElement(De,{style:{marginRight:5},onMouseEnter:function(){return g(null==r?void 0:r.proposed_filename)},onMouseLeave:function(){return g(null)},onClick:x},"Auto"),p&&O&&React.createElement(De,{style:{marginRight:5},onClick:w},o.RENAME),(null==r?void 0:r.proposed_filename_exists)&&React.createElement(ta,{icon:"alert",color:"orange",tooltip:{text:"The ideal filename already exists.",position:"left"}}),m&&!O&&(null==r?void 0:r.original_filename)&&React.createElement(ta,{icon:"file-undo",color:A.red,onClick:k,onMouseEnter:function(){return g(null==r?void 0:r.original_filename)},onMouseLeave:function(){return g(null)}})))},Xo=t(7);function ei(){var e=oi(["\n color: white;\n margin: 0px 15px 15px 15px;\n\n .fatal {\n padding: 8px 12px;\n border-radius: 10px;\n background: #ab3014;\n margin: 0 0 10px 0;\n border: 0;\n }\n\n .warning {\n padding: 8px 12px;\n border-radius: 10px;\n background: #b98c0e;\n margin: 0 0 10px 0;\n border: 0;\n }\n\n .notice {\n padding: 8px 12px;\n border-radius: 10px;\n background: #23ad74;\n margin: 0 0 10px 0;\n border: 0;\n }\n"]);return ei=function(){return e},e}function ni(){var e=oi(["\n\n margin: 15px;\n\n .center {\n background: white;\n border-radius: 10px;\n padding: 10px;\n font-family: Lato;\n max-width: 100%\n overflow: none;\n\n h2 {\n font-size: 26px;\n }\n\n table {\n width: 100%;\n\n tr td:first-child {\n width: 220px;\n font-weight: bold;\n color: #1e7cba;\n }\n\n * {\n overflow-wrap: anywhere;\n }\n }\n }\n\n hr {\n border-color: #1e7cba;\n }\n"]);return ni=function(){return e},e}function ti(){var e=oi(["\n width: 85px;\n height: 85px;\n padding-right: 10px;\n"]);return ti=function(){return e},e}function ri(){var e=oi(["\n\n .nui-block-title {\n display: none;\n }\n\n .nui-block-content {\n display: flex;\n padding: 10px;\n\n h2 {\n color: #055082;\n font-size: 16px;\n margin: 5px 0 5px 0;\n\n a {\n text-decoration: none;\n }\n }\n\n p {\n margin: 0px;\n line-height: 18px;\n }\n }\n"]);return ri=function(){return e},e}function ai(){var e=oi(["\n color: white;\n padding: 15px;\n margin-bottom: -15px;\n\n a {\n color: #7dedff;\n text-decoration: none;\n }\n\n p {\n font-size: 15px;\n }\n"]);return ai=function(){return e},e}function oi(e,n){return n||(n=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(n)}}))}var ii=C.a.div(ai()),li=Object(C.a)(Gn)(ri()),ci=C.a.img(ti()),ui=C.a.div(ni()),si=C.a.div(ei());function fi(e){return function(e){if(Array.isArray(e))return bi(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||hi(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function di(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function mi(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){di(o,r,a,i,l,"next",e)}function l(e){di(o,r,a,i,l,"throw",e)}i(void 0)}))}}function pi(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||hi(e,n)||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 hi(e,n){if(e){if("string"==typeof e)return bi(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?bi(e,n):void 0}}function bi(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var gi=wp.element,yi=gi.useState,vi=gi.useEffect,Ei="".concat(c,"/meow-common/v1"),xi=function(e){var n=e.request,t=e.title,r=e.max,a=pi(yi(!1),2),o=a[0],i=a[1],l=pi(yi([]),2),c=l[0],u=l[1],s=c.length>0?c.reduce((function(e,n){return e+n})):0,f=c.length>0?Math.ceil(s/c.length):0,d=!c.length&&o;vi((function(){o&&setTimeout(mi(regeneratorRuntime.mark((function e(){var t,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=(new Date).getTime(),e.next=3,Go("".concat(Ei,"/").concat(n));case 3:r=(new Date).getTime(),a=r-t,u((function(e){return[].concat(fi(e),[a])}));case 6:case"end":return e.stop()}}),e)}))),1e3)}),[c]);return React.createElement(ii,{style:{width:200,textAlign:"center"}},React.createElement(qn,{h2:!0,style:{color:"white"}},t),React.createElement(Ra,{size:200,value:d?r:f,max:r},React.createElement("span",{style:{fontSize:20}},d?"START":f+" ms"),React.createElement("span",{style:{fontSize:12}},d?"YOUR ENGINE":c.length+" requests")),React.createElement(De,{style:{width:"100%",marginTop:10},color:o?"#cc3627":"#ccb027",onClick:function(){o||u([]),i(!o)}},o?"Stop":"Start"))};function wi(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function ki(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?wi(Object(t),!0).forEach((function(n){Ri(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):wi(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Ri(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Oi(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function ji(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return Si(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Si(e,n)}(e,n)||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 Si(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var Pi=wp.element,Ci=Pi.useState,_i=Pi.useEffect;u&&c&&s||console.error("[@common/dashboard] apiUrl, restUrl and pluginUrl are mandatory.");var Ai="".concat(c,"/meow-common/v1"),Ti=React.createElement(ii,null,React.createElement(qn,{p:!0},"Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking ",React.createElement("a",{target:"_blank",href:"https://offbeatjapan.org"},"a lot of photos"),"). Meow Apps proposes a suite of plugins focusing on photography, imaging, optimization and SEO. The ultimate goal is to make your website better, faster, while making it easy. Meow Apps also teams up with the best players in the community. For more information, please check ",React.createElement("a",{href:"http://meowapps.com",target:"_blank"},"Meow Apps"),".")),Ni=React.createElement(ii,null,React.createElement(qn,{p:!0},"The ",React.createElement("b",null,"Empty Request Time")," helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins (or change their options) then Start this again to see how it influences the results. An excellent install would have an Empty Request Time of less than 500 ms. Keep it absolutely under 2,000 ms! For more information, ",React.createElement("a",{href:"https://meowapps.com/clean-optimize-wordpress/#Optimize_your_Empty_Request_Time",target:"_blank"},"click here"),"."),React.createElement(qn,{p:!0},React.createElement("b",null,"File Operation Time")," creates a temporary size of 10MB every time. ",React.createElement("b",null,"SQL Request Time")," counts the number of posts. Those two should be very fast, and almost the same as the ",React.createElement("b",null,"Empty Request Time"),".")),zi=React.createElement(ii,null,React.createElement(qn,{p:!0},"Too many WordPress installs are blown-up with useless and/or heavy plugins, and not aware of best practices. That's not the fault of the users; WordPress pretends to be simple but it is in fact very complex, and the immensity and diversity of the community around it makes it a real jungle where everything is possible."),React.createElement(qn,{p:!0},"A rule of thumb is to keep your WordPress install as simple as possible, with the least number of plugins installed (run away from the heavy ones) and an excellent hosting service. Avoid VPS or self-hosted solutions; you must be a professional to actually set them up so that they are actually performant."),React.createElement(qn,{p:!0},"On the Meow Apps website, you will find articles which are always updated with the latest recommendations.",React.createElement("ul",null,React.createElement("li",null,"☘️ ",React.createElement("a",{href:"https://meowapps.com/debugging-wordpress/",target:"_blank"},"How To Debug")),React.createElement("li",null,"☘️ ",React.createElement("a",{href:"https://meowapps.com/seo-optimization/",target:"_blank"},"SEO Checklist & Optimization")),React.createElement("li",null,"☘️ ",React.createElement("a",{href:"https://meowapps.com/clean-optimize-wordpress/",target:"_blank"},"Clean Up and Optimize")),React.createElement("li",null,"☘️ ",React.createElement("a",{href:"https://meowapps.com/optimize-images-cdn/",target:"_blank"},"Optimize Images")),React.createElement("li",null,"☘️ ",React.createElement("a",{href:"https://meowapps.com/best-hosting-services-wordpress/",target:"_blank"},"Best Hosting Services"))))),Ii=React.createElement(ii,null,React.createElement(qn,{p:!0},"A summarized version of your PHP Error Logs will be displayed here, with the latest errors at the top. After it, you will find information about your PHP, so make sure your scroll down.")),Mi=function(){var e=ji(Ci(!1),2),n=e[0],t=e[1],r=Object(Xo.a)("".concat(Ai,"/all_settings/"),Ho),a=r.data,o=r.mutate,i=r.error,l=null==a?void 0:a.data,c=null==l?void 0:l.meowapps_hide_meowapps,u=null==l?void 0:l.force_sslverify,f=ji(Ci(!1),2),d=f[0],m=f[1],p=ji(Ci(""),2),h=p[0],b=p[1],g=ji(Ci(""),2),y=g[0],v=g[1];_i((function(){i&&!n&&(t(!0),console.error("Error from UseSWR",i.message))}),[i]),_i((function(){var e=document.getElementById("meow-common-phperrorlogs"),n=document.getElementById("meow-common-phpinfo");b(e.innerHTML),v(n.innerHTML)}),[]);var E=function(){var e,n=(e=regeneratorRuntime.mark((function e(n,t){var r,i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=ki({},a.data))[t]=n,o(ki(ki({},a),{},{data:r}),!1),m(!0),e.next=6,Go("".concat(Ai,"/update_option"),{name:t,value:n});case 6:i=e.sent,m(!1),i.success||alert(i.message),o();case 10:case"end":return e.stop()}}),e)})),function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Oi(o,r,a,i,l,"next",e)}function l(e){Oi(o,r,a,i,l,"throw",e)}i(void 0)}))});return function(e,t){return n.apply(this,arguments)}}(),x=React.createElement(et,{title:"Main Menu"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"meowapps_hide_meowapps",label:"Hide (Not Recommended)",description:React.createElement(qn,{p:!0},"This will hide the Meow Apps Menu (on the left side) and everything it contains. You can re-enable it through though an option that will be added in Settings → General."),value:"1",disabled:d,checked:c,onChange:E}))),w=React.createElement(et,{title:"SSL Verify"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"force_sslverify",label:"Force (Not Recommended)",description:React.createElement(qn,{p:!0},"This will enforce the usage of SSL when checking the license or updating the plugin."),value:"1",disabled:d,checked:u,onChange:E})));return React.createElement(Pn,{showRestError:n},React.createElement(ca,{title:"The Dashboard"}),React.createElement(gt,null,React.createElement(yt,{full:!0},React.createElement(co,null,React.createElement(uo,{title:"Meow Apps"},Ti,React.createElement(gt,null,React.createElement(yt,{minimal:!0},React.createElement(li,{title:"Media Cleaner",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/media-cleaner.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-cleaner/"},"Media Cleaner")),React.createElement("p",null,"The Cleaner analyzes your WordPress entirely to find out which files are not used. You can trash them, before deleting them permanently. Your WordPress will breath again :)"))),React.createElement(li,{title:"Media File Renamer",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/media-file-renamer.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/media-file-renamer/"},"Media File Renamer")),React.createElement("p",null,"The Renamer will help you in getting nicer filenames for an improved SEO and a tidier filesystem. It's mostly automatic and very fun to use."))),React.createElement(li,{title:"Contact Form Block",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/default.png")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/contact-form-block/"},"Contact Form Block")),React.createElement("p",null,"A simple, pretty and superlight contact form. If you simply want your visitors to get in touch with you, this contact form will be perfect for you and your WordPress."))),React.createElement(li,{title:"Meow Analytics",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/default.png")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-analytics/"},"Meow Analytics")),React.createElement("p",null,"Are you tired of those heavy plugins, accessing your Google Analytics deliberately? Switch to Meow Analytics!")))),React.createElement(yt,{minimal:!0},React.createElement(li,{title:"Meow Gallery",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/meow-gallery.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-gallery/"},"Meow Gallery")),React.createElement("p",null,"This is the fastest gallery system... and it is pretty as well! It is 100% compatible with the native WordPress galleries and therefore, works right away."))),React.createElement(li,{title:"Meow Lightbox",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/meow-lightbox.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/meow-lightbox/"},"Meow Lightbox")),React.createElement("p",null,"A very sleek and performant Lightbox which will also display your EXIF data (camera, lens, aperture...). Photographers love it."))),React.createElement(li,{title:"WP/LR Sync",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/wplr-sync.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wplr-sync/"},"WP/LR Sync")),React.createElement("p",null,"Are you using Lightroom? So you know WP/LR Sync already. Wait, you don't? You must try it! This plugin will be your favorite very soon."))),React.createElement(li,{title:"WP Retina 2x",className:"primary"},React.createElement(ci,{src:"".concat(s,"/common/img/wp-retina-2x.jpg")}),React.createElement("div",null,React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/wp-retina-2x/"},"WP Retina 2x")),React.createElement("p",null,"The first and best High-DPI plugin! It enforces high-quality image support and best-practices.")))))),React.createElement(uo,{title:"Performance"},Ni,React.createElement("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:25}},React.createElement(xi,{title:"Empty Request Time",request:"empty_request",max:2500}),React.createElement(xi,{title:"File Operation Time",request:"file_operation",max:2600}),React.createElement(xi,{title:"SQL Request Time",request:"sql_request",max:2800}))),React.createElement(uo,{title:"Recommendations"},zi),React.createElement(uo,{title:"PHP Errors & Info"},Ii,React.createElement(si,{dangerouslySetInnerHTML:{__html:h}}),React.createElement(ui,{dangerouslySetInnerHTML:{__html:y}})),React.createElement(uo,{title:"Settings"},React.createElement(Gn,{title:"Settings",className:"primary"},x,w))))))};function Fi(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function Bi(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Fi(o,r,a,i,l,"next",e)}function l(e){Fi(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Li(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return qi(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return qi(e,n)}(e,n)||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 qi(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var Ui=wp.element,Di=Ui.useState,Hi=Ui.useEffect,Gi="".concat(c,"/meow-licenser/").concat(i,"/v1"),Wi=function(){var e=Li(Di(!1),2),n=e[0],t=e[1],r=Li(Di(null),2),a=r[0],o=r[1],i=Li(Di(null),2),c=i[0],u=i[1],s=Li(Di(""),2),m=s[0],p=s[1],h=d&&(!c||"valid"!==c.license),b=function(){var e=Bi(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(f){e.next=2;break}return e.abrupt("return");case 2:return t(!0),e.next=5,Go("".concat(Gi,"/get_license"));case 5:n=e.sent,u(n.data),n.data.key&&p(n.data.key),t(!1);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g=function(){var e=Bi(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t(!0),e.next=3,Go("".concat(Gi,"/set_license"),{serialKey:null});case 3:e.sent.success&&(p(""),u(null),o("licenseRemoved")),t(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),y=function(){var e=Bi(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t(!0),e.next=3,Go("".concat(Gi,"/set_license"),{serialKey:m});case 3:(n=e.sent).success&&(u(n.data),o("licenseAdded")),t(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();Hi((function(){b()}),[]);var v=h?"Forced License":d?"Enabled":"Disabled",E=c&&"valid"===c.license,x="Your license is active. Thanks a lot for your support :)";E||(c?"no_activations_left"===c.issue?x=React.createElement("span",null,"There are no activations left for this license. You can visit your account at the ",React.createElement("a",{target:"_blank",href:"https://store.meowapps.com"},"Meow Apps Store"),", unregister a site, and click on ",React.createElement("i",null,"Retry to validate"),"."):"expired"===c.issue?x=React.createElement("span",null,"Your license has expired. You can get another license or renew the current one by visiting your account at the ",React.createElement("a",{target:"_blank",href:"https://store.meowapps.com"},"Meow Apps Store"),"."):"missing"===c.issue?x="This license does not exist.":"disabled"===c.issue?x="This license has been disabled.":"item_name_mismatch"===c.issue?x="This license seems to be for a different plugin... isn't it? :)":(x=React.createElement("span",null,"There is an unknown error related to this serial key. Really sorry about this! Please ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/contact/"},"contact us"),"."),console.log({license:c})):x="Unknown error :(");var w=React.createElement(Gn,{title:"Pro Version (Not Installed)",className:"primary"},"You will find more information about the Pro Version ",React.createElement("a",{target:"_blank",href:"https://meowapps.com/plugin/".concat(l,"/")},"here"),". If you actually bought the Pro Version already, please remove the current plugin and download the Pro Version from your account at the ",React.createElement("a",{target:"_blank",href:"https://store.meowapps.com/"},"Meow Apps Store"),"."),k=React.createElement(Gn,{title:"Pro Version (".concat(v,")"),busy:n,className:"primary"},React.createElement(et,{title:"Serial Key",style:{fontWeight:"bold"}},React.createElement(It,{id:"mfrh_pro_serial",name:"mfrh_pro_serial",disabled:n,value:m,onChange:function(e){return p(e)},placeholder:""})),c&&!E&&React.createElement(Pa,null,x),c&&E&&React.createElement(Ca,null,x),!c&&React.createElement(qn,{p:!0},"Insert your serial key above. If you don't have one yet, you can get one ",React.createElement("a",{href:"/plugin/media-file-renamer/"},"here"),". If there was an error during the validation, try the ",React.createElement("i",null,"Retry")," to ",React.createElement("i",null,"validate")," button."),React.createElement(et,{contentAlign:"right"},c&&!E&&React.createElement(De,{className:"secondary",disabled:n||!m,onClick:y},"Retry to validate"),c&&c.key===m&&React.createElement(De,{className:"secondary",disabled:n||!m,onClick:g},"Remove License"),React.createElement(De,{disabled:n||!m||c&&c.key===m,onClick:y},"Validate License")),React.createElement(qa,{isOpen:"licenseAdded"===a,title:"Thank you :)",content:"The Pro features have been enabled. This page should be now reloaded.",ok:"Reload",onOkClick:function(){return location.reload()}}),React.createElement(qa,{isOpen:"licenseRemoved"===a,title:"Goodbye :(",content:"The Pro features have been disabled. This page should be now reloaded.",ok:"Reload",onOkClick:function(){return location.reload()}}));return f?k:w},$i=wp.element.render;function Yi(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function Ji(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{};n%2?Yi(Object(t),!0).forEach((function(n){Vi(e,n,t[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):Yi(Object(t)).forEach((function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}))}return e}function Vi(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Ki(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function Zi(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){Ki(o,r,a,i,l,"next",e)}function l(e){Ki(o,r,a,i,l,"throw",e)}i(void 0)}))}}function Qi(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||function(e,n){if(!e)return;if("string"==typeof e)return Xi(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(e);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Xi(e,n)}(e,n)||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 Xi(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}document.addEventListener("DOMContentLoaded",(function(e){var n=document.getElementById("meow-common-dashboard");n&&$i(React.createElement(Mi,null),n)}));var el=wp.element,nl=el.useState,tl=(el.useEffect,{marginTop:10,background:"rgb(0, 72, 88)",padding:10,color:"rgb(58, 212, 58)",maxHeight:600,minHeight:200,display:"block",fontFamily:"monospace",fontSize:12,whiteSpace:"pre",overflowX:"auto",width:"calc(100vw - 276px)"}),rl=function(){var e=Object(Xo.a)("".concat(u,"/all_settings/"),Ho),n=e.data,t=e.mutate,r=e.error,a=tn(n,{},!0),o=a.busy,c=a.data,s=Qi(nl(""),2),m=s[0],p=s[1],h=Qi(nl(!1),2),b=h[0],g=h[1],y=o||b,v=null==c?void 0:c.mfrh_auto_rename,E=null==c?void 0:c.mfrh_on_upload,x=null==c?void 0:c.mfrh_rename_slug,w=null==c?void 0:c.mfrh_convert_to_ascii,k=null==c?void 0:c.mfrh_update_posts,R=null==c?void 0:c.mfrh_update_postmeta,O=null==c?void 0:c.mfrh_undo,j=null==c?void 0:c.mfrh_manual_rename,S=null==c?void 0:c.mfrh_numbered_files,P=null==c?void 0:c.mfrh_sync_alt,C=null==c?void 0:c.mfrh_sync_media_title,_=null==c?void 0:c.mfrh_force_rename,A=null==c?void 0:c.mfrh_log,T=null==c?void 0:c.mfrh_logsql,N=null==c?void 0:c.mfrh_rename_guid,z=null==c?void 0:c.mfrh_case_sensitive_check,I=null==c?void 0:c.mfrh_rename_on_save,M=[{id:"media_title",value:"media_title",label:React.createElement("span",null,"Based on Media Title"),requirePro:!1},{id:"post_title",value:"post_title",label:React.createElement("span",null,"Based on Attached Post Title"),requirePro:!d},{id:"alt_text",value:"alt_text",label:React.createElement("span",null,"Based on Alternative Text"),requirePro:!d},{id:"anonymize_md5",value:"anonymize_md5",label:React.createElement("span",null,"Anonymize with MD5"),requirePro:!d},{id:"none",value:"none",label:React.createElement("span",null,"Disable Automatic Rename"),requirePro:!1}],F=function(){var e=Zi(regeneratorRuntime.mark((function e(r,a){var o;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(o=Ji({},n.data))[a]=r,t(Ji(Ji({},n),{},{data:o}),!1),g(!0),e.prev=4,e.next=7,Go("".concat(u,"/update_option"),{name:a,value:r});case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(4),alert(e.t0.message);case 12:return e.prev=12,g(!1),t(),e.finish(12);case 16:case"end":return e.stop()}}),e,null,[[4,9,12,16]])})));return function(n,t){return e.apply(this,arguments)}}(),B=function(){var e=Zi(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return g(!0),e.next=3,Go("".concat(u,"/refresh_logs"));case 3:(n=e.sent).success&&p(n.data),g(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),L=function(){var e=Zi(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return g(!0),e.next=3,Go("".concat(u,"/clear_logs"));case 3:(n=e.sent).success&&p(n.data),g(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),q=React.createElement(Gn,{busy:y,title:"Side Updates",className:"primary"},React.createElement(qn,{p:!0,style:{marginTop:0}},"When the files are renamed, many links to them on your WordPress might be broken. Those options are updating the references to those files. ",React.createElement("strong",null,"Give it a try, every install is different and it might not work for certain kind of references.")),React.createElement(et,{title:"Posts"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_update_posts",disabled:y,label:"Enable",description:React.createElement(qn,{p:!0},"Update the references to the renamed files in the ",React.createElement("strong",null,"content")," content and ",React.createElement("strong",null,"excerpt")," of the posts (pages and custom types included)."),value:"1",checked:k,onChange:F}))),React.createElement(et,{title:"Post Meta"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_update_postmeta",disabled:y,label:"Enable",description:React.createElement(qn,{p:!0},"Update the references in the ",React.createElement("strong",null,"custom fields")," of the posts (including pages and custom types metadata)."),value:"1",checked:R,onChange:F})))),U=React.createElement(et,{title:"Method"},React.createElement(lr,{id:"mfrh_auto_rename",disabled:y,value:v,scrolldown:!0,name:"mfrh_auto_rename",description:"Attached Post includes all kinds of posts, such as pages, products, etc.",onChange:F},M.map((function(e){return React.createElement(cr,{key:e.id,id:e.id,value:e.value,label:e.label,requirePro:e.requirePro})})))),D=React.createElement(et,{title:"On Upload"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_on_upload",disabled:y,label:"Enable",description:"If your image has an EXIF title, it will be used to decide the filename.",value:"1",checked:E,onChange:F}))),H=React.createElement(et,{title:"Slug/Permalink"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_rename_slug",disabled:y,label:"Sync with filename",description:"Better to keep this un-checked as the link might have been referenced somewhere else.",value:"1",checked:x,onChange:F}))),G=React.createElement(et,{title:"Transliteration"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_convert_to_ascii",disabled:y,label:"Enable",description:React.createElement(qn,{p:!0},"Replace accents, umlauts, cyrillic, diacritics, by their ASCII equivalent.",React.createElement("br",null)," ",React.createElement("i",null,"Examples: tête → tete, schön → schon, Добро → dobro, etc.")),value:"1",requirePro:!d,checked:w,onChange:F}))),W=React.createElement(et,{title:"Undo"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_undo",disabled:y,label:"Enable",description:"An undo icon will be added to the UI. This allows to rollback to the original filename.",value:"1",checked:O,onChange:F}))),$=React.createElement(et,{title:"Manual Rename"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_manual_rename",disabled:y,label:"Enable",description:"An editable field will be added everywhere your files appear in the UI.",value:"1",checked:j,onChange:F}))),Y=React.createElement(et,{title:"Force Rename"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_force_rename",disabled:y,label:"Enable",description:"Update the references to the file even if the file renaming itself was not successful. You might want to use that option if your install is broken and you are trying to link your Media to files for which the filenames has been altered (after a migration for exemple)",value:"1",requirePro:!d,checked:_,onChange:F}))),J=React.createElement(et,{title:"Numbered Files"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_numbered_files",disabled:y,label:"Enable Numbering",description:"Identical filenames will be allowed by the plugin and a number will be appended automatically (myfile.jpg, myfile-2.jpg, myfile-3.jpg, etc).",requirePro:!d,value:"1",checked:S,onChange:F}))),V=React.createElement(et,{title:"ALT Text"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_sync_alt",disabled:y||"media-title"!==v||"post-title"!==v,label:React.createElement(qn,null,"Sync with Title"),description:"The ALT Text will be synchronized with the title.",requirePro:!d,value:"1",checked:P,onChange:F}))),K=React.createElement(et,{title:"Media Title"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_sync_media_title",disabled:y||"post-title"!==v,label:React.createElement(qn,null,"Sync with Title"),description:"The Media Title will be synchronized with the title.",requirePro:!d,value:"1",checked:C,onChange:F}))),Z=React.createElement(et,{title:"Logs"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_log",label:"Enable",description:React.createElement(qn,{p:!0},"Simple logging that explains which actions has been run."),value:"1",checked:A,onChange:F}),React.createElement("div",{style:{marginTop:20}},React.createElement(De,{onClick:B},"Refresh Logs"),React.createElement(De,{className:"danger",onClick:L},"Clear Logs")))),Q=React.createElement(et,{title:"SQL Logs"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_logsql",disabled:y,label:"Enable",description:React.createElement(qn,{p:!0},"The files mfrh_sql.log and mfrh_sql_revert.log will be created in the /logs directory and will include the raw SQL queries which were run by the plugin. If there is an issue, the revert SQL file can help you."),requirePro:!d,value:"1",checked:T,onChange:F}))),X=React.createElement(et,{title:"GUID"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_rename_guid",disabled:y,label:"Sync with filename",description:"The GUID will be renamed like the new filename. Better to keep this un-checked.",value:"1",checked:N,onChange:F}))),ee=React.createElement(et,{title:"Case Sensitive"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_case_sensitive_check",label:"Enable",description:'This will check and detect as different such files as "abc.jpg" and "ABC.jpg". PHP itself recognize it as a same file, but probably not your system.',value:"1",checked:z,onChange:F}))),ne=React.createElement(et,{title:"Rename on Post Save"},React.createElement(Pt,{max:"1"},React.createElement(Ot,{id:"mfrh_rename_on_save",disabled:y,label:"Enable (Unsafe)",description:"You can modify the titles of your media while editing a post but, of course, the plugin can't update the HTML at this stage. With this option, the plugin will update the filenames and HTML after that you saved the post.",value:"1",checked:I,onChange:F})));return React.createElement(Pn,{nekoError:[r]},React.createElement(ca,{title:"Media File Renamer | Settings",subtitle:"By Jordy Meow"},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},React.createElement(De,{className:"primary",onClick:function(){return window.open("https://meowapps.com/media-file-renamer-tutorial/","_blank")}},"Tutorial"),React.createElement(De,{className:"primary",icon:"dashboard",color:"#8554bb",onClick:function(){return location.href="upload.php?page=mfrh_dashboard"}},"Dashboard"))),React.createElement(gt,null,React.createElement(yt,{full:!0},React.createElement(Zn,null,React.createElement(qn,{p:!0},"It works out of the box, the default settings are good for most installs. However, you should really have a look at the ",React.createElement("a",{href:"https://meowapps.com/plugin/media-file-renamer/"},"tutorial"),".")),React.createElement(co,null,React.createElement(uo,{title:"Basic"},React.createElement(gt,null,React.createElement(yt,{minimal:!0},React.createElement(Gn,{busy:y,title:"Settings",className:"primary"},React.createElement(qn,{h2:!0},"Automatic"),React.createElement(qn,{p:!0},"This plugin's main goal is to make the process of optimizing your filenames entirely automatic. By default, your files will be named after the title of your media entry."),U,D,React.createElement(qn,{h2:!0},"Manual"),$,React.createElement(qn,{p:!0},"If you are a SEO guru or someone who loves having a perfectly neat filesystem, it is recommended to use automatic renaming first, then to tweak specific files with manual renaming. The ",React.createElement("a",{href:"/wp-admin/upload.php?page=mfrh_dashboard"},"Renamer Dashboard")," makes it very easy."))),React.createElement(yt,{minimal:!0},q,React.createElement(Gn,{busy:y,title:"UI (Extra Features)",className:"primary"},W)))),React.createElement(uo,{title:"Advanced"},React.createElement(gt,null,React.createElement(yt,{minimal:!0},React.createElement(Gn,{busy:y,title:"Advanced Settings",className:"primary"},G,J),React.createElement(Gn,{busy:y,title:"Fields Syncing",className:"primary"},H,X,V,K,React.createElement(qn,{p:!0},"The fields in the database will be synchronized, but the data already written in your HTML will not be overwritten."))),React.createElement(yt,{minimal:!0},React.createElement(Gn,{busy:y,title:"Developer Settings",className:"primary"},ee,Y,Q,ne)))),React.createElement(uo,{title:"Pro Version"},React.createElement(Wi,{domain:l,prefix:i,isPro:f,isRegistered:d})),React.createElement(uo,{title:"Logs & Debug"},React.createElement(Gn,{busy:y,className:"primary"},Z),React.createElement("div",{style:tl},m))))))};function al(e){return function(e){if(Array.isArray(e))return ul(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||cl(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ol(e,n,t,r,a,o,i){try{var l=e[o](i),c=l.value}catch(e){return void t(e)}l.done?n(c):Promise.resolve(c).then(r,a)}function il(e){return function(){var n=this,t=arguments;return new Promise((function(r,a){var o=e.apply(n,t);function i(e){ol(o,r,a,i,l,"next",e)}function l(e){ol(o,r,a,i,l,"throw",e)}i(void 0)}))}}function ll(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){if("undefined"==typeof Symbol||!(Symbol.iterator in Object(e)))return;var t=[],r=!0,a=!1,o=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(t.push(i.value),!n||t.length!==n);r=!0);}catch(e){a=!0,o=e}finally{try{r||null==l.return||l.return()}finally{if(a)throw o}}return t}(e,n)||cl(e,n)||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 cl(e,n){if(e){if("string"==typeof e)return ul(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ul(e,n):void 0}}function ul(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}var sl=wp.element,fl=sl.useState,dl=sl.useEffect,ml=sl.useMemo,pl={width:40,height:40,objectFit:"cover"},hl=[{accessor:"thumbnail_url",title:o.THUMB,style:{width:16}},{accessor:"post_title",title:o.TITLE,sortable:!0,style:{width:"25%"}},{accessor:"post_parent",title:o.ATTACHED_TO,sortable:!0,style:{width:"25%"}},{accessor:"current_filename",title:o.FILENAME,sortable:!0}],bl={accessor:"id",by:"asc"},gl=function(){var e=ll(fl("pending"),2),n=e[0],t=e[1],r=ll(fl(),2),a=r[0],i=r[1],l=ll(fl([]),2),c=l[0],s=l[1],f=ll(fl(!1),2),p=f[0],b=f[1],g=ll(fl(""),2),y=g[0],v=g[1],E=ll(fl(""),2),x=E[0],w=E[1],k=ll(fl(bl),2),R=k[0],O=k[1],j=ll(fl(1),2),S=j[0],P=j[1],C=ll(fl(10),2),_=C[0],A=C[1],T=function(){var e=Xe(Object(h.useState)(new AbortController),2),n=e[0],t=e[1],r=Object(h.useRef)(!1),a=Xe(Object(h.useState)(null),2),o=a[0],i=a[1],l=Xe(Object(h.useState)(!1),2),c=l[0],u=l[1],s=Xe(Object(h.useState)(0),2),f=s[0],d=s[1],m=Xe(Object(h.useState)(0),2),p=m[0],b=m[1],g=Xe(Object(h.useState)(!1),2),y=g[0],v=g[1],E=Xe(Object(h.useState)(!1),2),x=E[0],w=E[1],k=Xe(Object(h.useState)(0),2),R=k[0],O=k[1],j=function(){var e=Qe(regeneratorRuntime.mark((function e(){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=new AbortController,t(n),v(!1),b(0),r.current=!1,u(!1),w(!1),O(0),d(0);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),S=function(){var e=Qe(regeneratorRuntime.mark((function e(n){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=new Promise((function(e,t){v(!1),b(0),r.current=!1,u(!1),w(!1),N(n),i(!0),on.start(),on.onIdle().then((function(){A(),e()}))})),e.abrupt("return",t);case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),P=function(){var e=Qe(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:0,on.pause(),u(!0);case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),C=function(){var e=Qe(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:0,v(!1),u(!1),on.start();case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_=function(){var e=Qe(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:0,on.pause(),n.abort(),i(!1),v(!1),w(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),A=function(){var e=Qe(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:0,w(!0),i(!1);case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),T=function(){var e=Qe(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:on.add(Qe(regeneratorRuntime.mark((function e(){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t(n.signal);case 3:(a=e.sent).success||(b((function(e){return e+1})),console.log("Error in UploadQueue",a),r.current||(v(a.error),P())),e.next=17;break;case 7:if(e.prev=7,e.t0=e.catch(0),"AbortError"!==e.t0.name){e.next=14;break}return console.log("Aborted"),e.abrupt("return");case 14:b((function(e){return e+1})),console.log("Error in UploadQueue",e.t0),r.current||(v("An error was caught (more information in the console)."),P());case 17:return e.prev=17,O((function(e){return e+1})),e.finish(17);case 20:case"end":return e.stop()}}),e,null,[[0,7,17,20]])})))),d((function(e){return e+1}));case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),N=function(){var e=Qe(regeneratorRuntime.mark((function e(n){var t,r,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:on.clear(),t=Ke(n);try{for(t.s();!(r=t.n()).done;)a=r.value,T(a)}catch(e){t.e(e)}finally{t.f()}O(0);case 4:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),z=Object(h.useCallback)((function(){r.current=!0}),[]);return{start:S,stop:_,pause:P,resume:C,reset:j,error:y,success:x,busy:o,paused:c,value:R,max:f,addTask:T,setAlwaysSkip:z,getErrorCount:function(){return p}}}(),N=(S-1)*_,z=Object(Xo.a)("".concat(u,"/stats"),Ho),I=z.data,M=z.mutate,F=z.error,B=Object(Xo.a)("".concat(u,"/media?limit=").concat(_,"&skip=").concat(N,"&filterBy=").concat(n,"&orderBy=").concat(R.accessor,"&order=").concat(R.by),Ho),L=B.data,q=B.mutate,U=B.error,D=tn(I,{pending:"-",renamed:"-",all:"-"},!0),H=D.busy,G=D.data,W=tn(L,[],!0),$=W.busy,Y=W.data,J=W.total,V=$||H||p,K=ml((function(){return Y.map((function(e){return{id:e.ID,thumbnail_url:React.createElement("img",{src:e.thumbnail_url,style:pl}),post_title:React.createElement("a",{href:"post.php?post=".concat(e.ID,"&action=edit")},e.post_title),post_parent:React.createElement("div",{style:{maxHeight:35,overflow:"hidden"}},e.post_parent_title?e.post_parent_title:React.createElement("i",{style:{color:"#c1c1c1"}},"None")),current_filename:React.createElement(Qo,{entry:e,mutate:function(){q(),M()}})}}))}),[Y]);dl((function(){s([]),O(bl),P(1)}),[n]),dl((function(){if(null!==T.busy&&(b(T.busy),!T.busy)){var e=T.getErrorCount();e>0&&w("The process has finished, but ".concat(e," error(s) occurred (check your console).")),T.reset(),s([]),q(),M()}}),[T.busy]);var Z=function(){var e=il(regeneratorRuntime.mark((function e(n){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Go("".concat(u,"/get_all_ids"),{unlockedOnly:n});case 2:if((t=e.sent).success){e.next=6;break}return alert(t.message),e.abrupt("return",[]);case 6:return e.abrupt("return",t.data);case 7:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),Q=function(){var e=il(regeneratorRuntime.mark((function e(){var n,t,r,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:null,v("Preparing..."),b(!0),!n){e.next=7;break}e.t0=n,e.next=10;break;case 7:return e.next=9,Z(!0);case 9:e.t0=e.sent;case 10:if(!(t=e.t0)){e.next=16;break}return v("Undoing..."),r=t.map((function(e){return function(){var n=il(regeneratorRuntime.mark((function n(t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return v("Undo Media ".concat(e)),n.next=3,Go("".concat(u,"/undo"),{mediaId:e},t);case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()})),T.start(r),e.abrupt("return");case 16:b(!1);case 17:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=function(){var e=il(regeneratorRuntime.mark((function e(){var n,t,r,a,o=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=o.length>0&&void 0!==o[0]?o[0]:null,v("Preparing..."),b(!0),!n){e.next=7;break}e.t0=n,e.next=10;break;case 7:return e.next=9,Z(!0);case 9:e.t0=e.sent;case 10:if(!(t=e.t0)){e.next=17;break}return v("Analyzing..."),r=Uo(t,20),a=r.map((function(e){return function(){var n=il(regeneratorRuntime.mark((function n(t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return n.next=2,Go("".concat(u,"/analyze"),{mediaIds:e},t);case 2:return n.abrupt("return",n.sent);case 3:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()})),T.start(a),e.abrupt("return");case 17:b(!1);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ee=function(){var e=il(regeneratorRuntime.mark((function e(){var n,t,r,a,o,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=!(i.length>0&&void 0!==i[0])||i[0],t=i.length>1&&void 0!==i[1]?i[1]:null,v("Preparing..."),b(!0),!t){e.next=8;break}e.t0=t,e.next=11;break;case 8:return e.next=10,Z(n);case 10:e.t0=e.sent;case 11:if(!(r=e.t0)){e.next=18;break}return v("".concat(n?"Locking..":"Unlocking...")),a=Uo(r,50),o=a.map((function(e){return function(){var e=il(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,Go("".concat(u,"/set_lock"),{mediaIds:r,lock:n},t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}()})),T.start(o),e.abrupt("return");case 18:b(!1);case 19:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ne=function(){var e=il(regeneratorRuntime.mark((function e(){var n,t,r,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=a.length>0&&void 0!==a[0]?a[0]:null,v("Preparing..."),b(!0),!n){e.next=7;break}e.t0=n,e.next=10;break;case 7:return e.next=9,Z(!0);case 9:e.t0=e.sent;case 10:if(!(t=e.t0)){e.next=15;break}return r=t.map((function(e){return function(){var n=il(regeneratorRuntime.mark((function n(t){return regeneratorRuntime.wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return v("Renaming #".concat(e)),n.next=3,Go("".concat(u,"/rename"),{mediaId:e},t);case 3:return n.abrupt("return",n.sent);case 4:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()})),T.start(r),e.abrupt("return");case 15:b(!1);case 16:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),te=React.createElement(React.Fragment,null,React.createElement(De,{className:"secondary",onClick:function(){return window.open("https://meowapps.com/plugin/media-file-renamer/","_blank")}},"Get the Pro Version"),React.createElement(De,{className:"primary",onClick:function(){return window.open("https://meowapps.com/media-file-renamer-tutorial/","_blank")}},"Read the tutorial"));return React.createElement(Pn,{nekoErrors:[F,U]},React.createElement(ca,{title:"Media File Renamer | Dashboard",subtitle:"By Jordy Meow"},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},React.createElement(De,{className:"primary",onClick:function(){return window.open("https://meowapps.com/media-file-renamer-tutorial/","_blank")}},"Tutorial"),React.createElement(De,{icon:"cog",color:"#8554bb",onClick:function(){return location.href="admin.php?page=mfrh_settings"}},"Settings"))),React.createElement(gt,null,React.createElement(yt,{full:!0},!d&&React.createElement(Zn,{footer:te},React.createElement(qn,{p:!0},"You must ",React.createElement("b",null,"backup the uploads folder and DB")," before using the Renamer. If you don't know how, give a try to ",React.createElement("a",{target:"_blank",href:"https://meow.click/blogvault"},"BlogVault"),". It is also highly recommanded to read the tutorial. Last but not least, check the ",React.createElement("b",null,"Pro Version"),", as it adds many features and also supports the development. This message is only displayed in the free version. Thank you!")),React.createElement(So,null,React.createElement(De,{onClick:function(){return X()}},"Analyze Library"),React.createElement(En,{title:"Actions"},React.createElement(xn,{requiredPro:!0,onClick:function(){i("autoAttach")}},"Auto-Attach")),"pending"===n&&c.length>0&&React.createElement(React.Fragment,null,React.createElement(De,{className:"secondary",onClick:function(){return ne(c)}},"Rename ",React.createElement("strong",null,c.length)," entries"),React.createElement(De,{className:"secondary",onClick:function(){return ee(!0,c)}},"Lock ",React.createElement("strong",null,c.length)," entries")),m&&"renamed"===n&&c.length>0&&React.createElement(React.Fragment,null,React.createElement(De,{className:"secondary",onClick:function(){return Q(c)}},"Undo ",React.createElement("strong",null,c.length)," entries")),React.createElement("div",{style:{flex:1}},p&&React.createElement(Br,{status:function(e){return"".concat(y," (").concat(e,"%)")},busy:p,value:T.value,max:T.max,onStopClick:T.stop})),"all"===n&&React.createElement(React.Fragment,null,React.createElement(De,{className:"secondary",onClick:function(){return ee(!0)}},"Lock ",React.createElement("strong",null,"All")),React.createElement(De,{className:"secondary",onClick:function(){return ee(!1)}},"Unlock ",React.createElement("strong",null,"All"))),("all"===n||"pending"===n)&&React.createElement(React.Fragment,null,React.createElement(De,{className:"primary",onClick:function(){return i("renameAll")}},"Rename ",React.createElement("strong",null,"All"))),m&&("all"===n||"renamed"===n)&&React.createElement(React.Fragment,null,React.createElement(De,{className:"danger",onClick:function(){return i("undoAll")}},"Undo ",React.createElement("strong",null,"All")))),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10,marginBottom:10}},React.createElement(Ea,{value:n,busy:H,onChange:function(e){t(e),P(1)}},React.createElement(xa,{title:o.PENDING,value:"pending",count:G.pending}),React.createElement(xa,{title:"Renamed",value:"renamed",count:G.renamed}),React.createElement(xa,{title:"All",value:"all",count:G.all})),React.createElement(da,{currentPage:S,limit:_,total:J,onClick:function(e){return P(e)}})),React.createElement(Ja,{busy:V,data:K,columns:hl,sort:R,onSortChange:function(e,n){O({accessor:e,by:n})},onSelect:function(e){s([].concat(al(c),al(e)))},onUnselect:function(e){s(al(c.filter((function(n){return!e.includes(n)}))))},selectedItems:c}),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10}},React.createElement(lr,{scrolldown:!0,value:_,onChange:function(e){A(e),P(1)}},React.createElement(cr,{value:5,label:"5 items per page"}),React.createElement(cr,{value:10,label:"10 items per page"}),React.createElement(cr,{value:25,label:"25 items per page"}),React.createElement(cr,{value:50,label:"50 items per page"})),React.createElement(da,{currentPage:S,limit:_,total:J,onClick:function(e){return P(e)}}))),React.createElement(qa,{isOpen:"renameAll"===a,onRequestClose:function(){return i(null)},title:"You are about to rename all your (unlocked) files",content:"Renaming files is a dangerous operation. Please make sure you made a backup or your entire WordPress install. Should we start?",onOkClick:function(){i(null),ne()},onCancelClick:function(){i(null)}}),React.createElement(qa,{isOpen:"undoAll"===a,onRequestClose:function(){return i(null)},title:"You are about to undo the renaming for all your files",content:"Are you sure you would like to proceed?",onOkClick:function(){i(null),Q()},onCancelClick:function(){i(null)}}),React.createElement(qa,{isOpen:"autoAttach"===a,onRequestClose:function(){return i(null)},title:"Coming soon!",content:"This feature, for Pro users, will scan your WordPress install to attach your unattached files to what they belong to (for example, an image to a product). That will also allow to rename those images automatically.",onOkClick:function(){i(null)}}),React.createElement(qa,{isOpen:x,title:"Success",ok:"Close",content:x,onOkClick:function(){w(""),T.reset()}})))},yl=wp.element.render;document.addEventListener("DOMContentLoaded",(function(e){Array.from(document.getElementsByClassName("mfrh-renamer-field")).forEach((function(e){var n=e.getAttribute("data-id");yl(React.createElement(Qo,{mediaId:n}),e)}));var n=document.getElementById("mfrh-admin-settings");n&&yl(React.createElement(rl,null),n);var t=document.getElementById("mfrh-media-rename");t&&yl(React.createElement(gl,null),t)}))}});
|
2 |
+
//# sourceMappingURL=index.js.map
|
app/vendor.js
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(window.wpJsonMfrh=window.wpJsonMfrh||[]).push([[1],[,function(e,t,n){e.exports=n(59)()},function(e,t,n){"use strict";(function(e){var r=n(15),o=n(0),i=n.n(o),a=(n(46),n(47)),u=n(48),s=n(22),l=n(20),c=n.n(l);function f(){return(f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var d=function(e,t){for(var n=[e[0]],r=0,o=t.length;r<o;r+=1)n.push(t[r],e[r+1]);return n},p=function(e){return null!==e&&"object"==typeof e&&"[object Object]"===(e.toString?e.toString():Object.prototype.toString.call(e))&&!Object(r.typeOf)(e)},h=Object.freeze([]),v=Object.freeze({});function y(e){return"function"==typeof e}function b(e){return e.displayName||e.name||"Component"}function m(e){return e&&"string"==typeof e.styledComponentId}var g=void 0!==e&&(e.env.REACT_APP_SC_ATTR||e.env.SC_ATTR)||"data-styled",w="undefined"!=typeof window&&"HTMLElement"in window,_="boolean"==typeof SC_DISABLE_SPEEDY&&SC_DISABLE_SPEEDY||void 0!==e&&(e.env.REACT_APP_SC_DISABLE_SPEEDY||e.env.SC_DISABLE_SPEEDY)||!1,C=function(){return n.nc};function O(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];throw new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/master/packages/styled-components/src/utils/errors.md#"+e+" for more information."+(n.length>0?" Additional arguments: "+n.join(", "):""))}var k=function(e){var t=document.head,n=e||t,r=document.createElement("style"),o=function(e){for(var t=e.childNodes,n=t.length;n>=0;n--){var r=t[n];if(r&&1===r.nodeType&&r.hasAttribute(g))return r}}(n),i=void 0!==o?o.nextSibling:null;r.setAttribute(g,"active"),r.setAttribute("data-styled-version","5.1.1");var a=C();return a&&r.setAttribute("nonce",a),n.insertBefore(r,i),r},S=function(){function e(e){var t=this.element=k(e);t.appendChild(document.createTextNode("")),this.sheet=function(e){if(e.sheet)return e.sheet;for(var t=document.styleSheets,n=0,r=t.length;n<r;n++){var o=t[n];if(o.ownerNode===e)return o}O(17)}(t),this.length=0}var t=e.prototype;return t.insertRule=function(e,t){try{return this.sheet.insertRule(t,e),this.length++,!0}catch(e){return!1}},t.deleteRule=function(e){this.sheet.deleteRule(e),this.length--},t.getRule=function(e){var t=this.sheet.cssRules[e];return void 0!==t&&"string"==typeof t.cssText?t.cssText:""},e}(),x=function(){function e(e){var t=this.element=k(e);this.nodes=t.childNodes,this.length=0}var t=e.prototype;return t.insertRule=function(e,t){if(e<=this.length&&e>=0){var n=document.createTextNode(t),r=this.nodes[e];return this.element.insertBefore(n,r||null),this.length++,!0}return!1},t.deleteRule=function(e){this.element.removeChild(this.nodes[e]),this.length--},t.getRule=function(e){return e<this.length?this.nodes[e].textContent:""},e}(),A=function(){function e(e){this.rules=[],this.length=0}var t=e.prototype;return t.insertRule=function(e,t){return e<=this.length&&(this.rules.splice(e,0,t),this.length++,!0)},t.deleteRule=function(e){this.rules.splice(e,1),this.length--},t.getRule=function(e){return e<this.length?this.rules[e]:""},e}(),M=function(){function e(e){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=e}var t=e.prototype;return t.indexOfGroup=function(e){for(var t=0,n=0;n<e;n++)t+=this.groupSizes[n];return t},t.insertRules=function(e,t){if(e>=this.groupSizes.length){for(var n=this.groupSizes,r=n.length,o=r;e>=o;)(o<<=1)<0&&O(16,""+e);this.groupSizes=new Uint32Array(o),this.groupSizes.set(n),this.length=o;for(var i=r;i<o;i++)this.groupSizes[i]=0}for(var a=this.indexOfGroup(e+1),u=0,s=t.length;u<s;u++)this.tag.insertRule(a,t[u])&&(this.groupSizes[e]++,a++)},t.clearGroup=function(e){if(e<this.length){var t=this.groupSizes[e],n=this.indexOfGroup(e),r=n+t;this.groupSizes[e]=0;for(var o=n;o<r;o++)this.tag.deleteRule(n)}},t.getGroup=function(e){var t="";if(e>=this.length||0===this.groupSizes[e])return t;for(var n=this.groupSizes[e],r=this.indexOfGroup(e),o=r+n,i=r;i<o;i++)t+=this.tag.getRule(i)+"/*!sc*/\n";return t},e}(),j=new Map,E=new Map,P=1,I=function(e){if(j.has(e))return j.get(e);var t=P++;return j.set(e,t),E.set(t,e),t},R=function(e){return E.get(e)},T=function(e,t){t>=P&&(P=t+1),j.set(e,t),E.set(t,e)},L="style["+g+'][data-styled-version="5.1.1"]',F=new RegExp("^"+g+'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)'),z=function(e,t,n){for(var r,o=n.split(","),i=0,a=o.length;i<a;i++)(r=o[i])&&e.registerName(t,r)},N=function(e,t){for(var n=t.innerHTML.split("/*!sc*/\n"),r=[],o=0,i=n.length;o<i;o++){var a=n[o].trim();if(a){var u=a.match(F);if(u){var s=0|parseInt(u[1],10),l=u[2];0!==s&&(T(l,s),z(e,l,u[3]),e.getTag().insertRules(s,r)),r.length=0}else r.push(a)}}},D=w,H={isServer:!w,useCSSOMInjection:!_},q=function(){function e(e,t,n){void 0===e&&(e=H),void 0===t&&(t={}),this.options=f({},H,{},e),this.gs=t,this.names=new Map(n),!this.options.isServer&&w&&D&&(D=!1,function(e){for(var t=document.querySelectorAll(L),n=0,r=t.length;n<r;n++){var o=t[n];o&&"active"!==o.getAttribute(g)&&(N(e,o),o.parentNode&&o.parentNode.removeChild(o))}}(this))}e.registerId=function(e){return I(e)};var t=e.prototype;return t.reconstructWithOptions=function(t){return new e(f({},this.options,{},t),this.gs,this.names)},t.allocateGSInstance=function(e){return this.gs[e]=(this.gs[e]||0)+1},t.getTag=function(){return this.tag||(this.tag=(t=this.options,n=t.isServer,r=t.useCSSOMInjection,o=t.target,e=n?new A(o):r?new S(o):new x(o),new M(e)));var e,t,n,r,o},t.hasNameForId=function(e,t){return this.names.has(e)&&this.names.get(e).has(t)},t.registerName=function(e,t){if(I(e),this.names.has(e))this.names.get(e).add(t);else{var n=new Set;n.add(t),this.names.set(e,n)}},t.insertRules=function(e,t,n){this.registerName(e,t),this.getTag().insertRules(I(e),n)},t.clearNames=function(e){this.names.has(e)&&this.names.get(e).clear()},t.clearRules=function(e){this.getTag().clearGroup(I(e)),this.clearNames(e)},t.clearTag=function(){this.tag=void 0},t.toString=function(){return function(e){for(var t=e.getTag(),n=t.length,r="",o=0;o<n;o++){var i=R(o);if(void 0!==i){var a=e.names.get(i),u=t.getGroup(o);if(void 0!==a&&0!==u.length){var s=g+".g"+o+'[id="'+i+'"]',l="";void 0!==a&&a.forEach((function(e){e.length>0&&(l+=e+",")})),r+=""+u+s+'{content:"'+l+'"}/*!sc*/\n'}}}return r}(this)},e}(),$=function(e,t){for(var n=t.length;n;)e=33*e^t.charCodeAt(--n);return e},V=function(e){return $(5381,e)};var U=/^\s*\/\/.*$/gm;function W(e){var t,n,r,o=void 0===e?v:e,i=o.options,u=void 0===i?v:i,s=o.plugins,l=void 0===s?h:s,c=new a.a(u),f=[],d=function(e){function t(t){if(t)try{e(t+"}")}catch(e){}}return function(n,r,o,i,a,u,s,l,c,f){switch(n){case 1:if(0===c&&64===r.charCodeAt(0))return e(r+";"),"";break;case 2:if(0===l)return r+"/*|*/";break;case 3:switch(l){case 102:case 112:return e(o[0]+r),"";default:return r+(0===f?"/*|*/":"")}case-2:r.split("/*|*/}").forEach(t)}}}((function(e){f.push(e)})),p=function(e,r,o){return r>0&&-1!==o.slice(0,r).indexOf(n)&&o.slice(r-n.length,r)!==n?"."+t:e};function y(e,o,i,a){void 0===a&&(a="&");var u=e.replace(U,""),s=o&&i?i+" "+o+" { "+u+" }":u;return t=a,n=o,r=new RegExp("\\"+n+"\\b","g"),c(i||!o?"":o,s)}return c.use([].concat(l,[function(e,t,o){2===e&&o.length&&o[0].lastIndexOf(n)>0&&(o[0]=o[0].replace(r,p))},d,function(e){if(-2===e){var t=f;return f=[],t}}])),y.hash=l.length?l.reduce((function(e,t){return t.name||O(15),$(e,t.name)}),5381).toString():"",y}var B=i.a.createContext(),G=(B.Consumer,i.a.createContext()),K=(G.Consumer,new q),Y=W();function X(){return Object(o.useContext)(B)||K}function Q(){return Object(o.useContext)(G)||Y}var J=function(){function e(e,t){var n=this;this.inject=function(e){e.hasNameForId(n.id,n.name)||e.insertRules(n.id,n.name,Y.apply(void 0,n.stringifyArgs))},this.toString=function(){return O(12,String(n.name))},this.name=e,this.id="sc-keyframes-"+e,this.stringifyArgs=t}return e.prototype.getName=function(){return this.name},e}(),Z=/([A-Z])/g,ee=/^ms-/;function te(e){return e.replace(Z,"-$1").toLowerCase().replace(ee,"-ms-")}var ne=function(e){return null==e||!1===e||""===e},re=function e(t,n){var r=[];return Object.keys(t).forEach((function(n){if(!ne(t[n])){if(p(t[n]))return r.push.apply(r,e(t[n],n)),r;if(y(t[n]))return r.push(te(n)+":",t[n],";"),r;r.push(te(n)+": "+(o=n,(null==(i=t[n])||"boolean"==typeof i||""===i?"":"number"!=typeof i||0===i||o in u.a?String(i).trim():i+"px")+";"))}var o,i;return r})),n?[n+" {"].concat(r,["}"]):r};function oe(e,t,n){if(Array.isArray(e)){for(var r,o=[],i=0,a=e.length;i<a;i+=1)""!==(r=oe(e[i],t,n))&&(Array.isArray(r)?o.push.apply(o,r):o.push(r));return o}return ne(e)?"":m(e)?"."+e.styledComponentId:y(e)?"function"!=typeof(u=e)||u.prototype&&u.prototype.isReactComponent||!t?e:oe(e(t),t,n):e instanceof J?n?(e.inject(n),e.getName()):e:p(e)?re(e):e.toString();var u}function ie(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return y(e)||p(e)?oe(d(h,[e].concat(n))):0===n.length&&1===e.length&&"string"==typeof e[0]?e:oe(d(e,n))}var ae=function(e){return"function"==typeof e||"object"==typeof e&&null!==e&&!Array.isArray(e)},ue=function(e){return"__proto__"!==e&&"constructor"!==e&&"prototype"!==e};function se(e,t,n){var r=e[n];ae(t)&&ae(r)?le(r,t):e[n]=t}function le(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];for(var o=0,i=n;o<i.length;o++){var a=i[o];if(ae(a))for(var u in a)ue(u)&&se(e,a[u],u)}return e}var ce=/(a)(d)/gi,fe=function(e){return String.fromCharCode(e+(e>25?39:97))};function de(e){var t,n="";for(t=Math.abs(e);t>52;t=t/52|0)n=fe(t%52)+n;return(fe(t%52)+n).replace(ce,"$1-$2")}function pe(e){for(var t=0;t<e.length;t+=1){var n=e[t];if(y(n)&&!m(n))return!1}return!0}var he=function(){function e(e,t){this.rules=e,this.staticRulesId="",this.isStatic=pe(e),this.componentId=t,this.baseHash=V(t),q.registerId(t)}return e.prototype.generateAndInjectStyles=function(e,t,n){var r=this.componentId;if(this.isStatic&&!n.hash){if(this.staticRulesId&&t.hasNameForId(r,this.staticRulesId))return this.staticRulesId;var o=oe(this.rules,e,t).join(""),i=de($(this.baseHash,o.length)>>>0);if(!t.hasNameForId(r,i)){var a=n(o,"."+i,void 0,r);t.insertRules(r,i,a)}return this.staticRulesId=i,i}for(var u=this.rules.length,s=$(this.baseHash,n.hash),l="",c=0;c<u;c++){var f=this.rules[c];if("string"==typeof f)l+=f;else{var d=oe(f,e,t),p=Array.isArray(d)?d.join(""):d;s=$(s,p+c),l+=p}}var h=de(s>>>0);if(!t.hasNameForId(r,h)){var v=n(l,"."+h,void 0,r);t.insertRules(r,h,v)}return h},e}(),ve=(new Set,function(e,t,n){return void 0===n&&(n=v),e.theme!==n.theme&&e.theme||t||n.theme}),ye=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,be=/(^-|-$)/g;function me(e){return e.replace(ye,"-").replace(be,"")}function ge(e){return"string"==typeof e&&!0}var we=function(e){return de(V(e)>>>0)};var _e=i.a.createContext();_e.Consumer;var Ce={};function Oe(e,t,n){var r=e.attrs,i=e.componentStyle,a=e.defaultProps,u=e.foldedComponentIds,l=e.shouldForwardProp,c=e.styledComponentId,d=e.target;Object(o.useDebugValue)(c);var p=function(e,t,n){void 0===e&&(e=v);var r=f({},t,{theme:e}),o={};return n.forEach((function(e){var t,n,i,a=e;for(t in y(a)&&(a=a(r)),a)r[t]=o[t]="className"===t?(n=o[t],i=a[t],n&&i?n+" "+i:n||i):a[t]})),[r,o]}(ve(t,Object(o.useContext)(_e),a)||v,t,r),h=p[0],b=p[1],m=function(e,t,n,r){var i=X(),a=Q(),u=e.isStatic&&!t?e.generateAndInjectStyles(v,i,a):e.generateAndInjectStyles(n,i,a);return Object(o.useDebugValue)(u),u}(i,r.length>0,h),g=n,w=b.$as||t.$as||b.as||t.as||d,_=ge(w),C=b!==t?f({},t,{},b):t,O=l||_&&s.a,k={};for(var S in C)"$"!==S[0]&&"as"!==S&&("forwardedAs"===S?k.as=C[S]:O&&!O(S,s.a)||(k[S]=C[S]));return t.style&&b.style!==t.style&&(k.style=f({},t.style,{},b.style)),k.className=Array.prototype.concat(u,c,m!==c?m:null,t.className,b.className).filter(Boolean).join(" "),k.ref=g,Object(o.createElement)(w,k)}function ke(e,t,n){var r=m(e),o=!ge(e),a=t.displayName,u=void 0===a?function(e){return ge(e)?"styled."+e:"Styled("+b(e)+")"}(e):a,s=t.componentId,l=void 0===s?function(e,t){var n="string"!=typeof e?"sc":me(e);Ce[n]=(Ce[n]||0)+1;var r=n+"-"+we(n+Ce[n]);return t?t+"-"+r:r}(t.displayName,t.parentComponentId):s,d=t.attrs,p=void 0===d?h:d,v=t.displayName&&t.componentId?me(t.displayName)+"-"+t.componentId:t.componentId||l,y=r&&e.attrs?Array.prototype.concat(e.attrs,p).filter(Boolean):p,g=t.shouldForwardProp;r&&e.shouldForwardProp&&(g=g?function(n,r){return e.shouldForwardProp(n,r)&&t.shouldForwardProp(n,r)}:e.shouldForwardProp);var w,_=new he(r?e.componentStyle.rules.concat(n):n,v),C=function(e,t){return Oe(w,e,t)};return C.displayName=u,(w=i.a.forwardRef(C)).attrs=y,w.componentStyle=_,w.displayName=u,w.shouldForwardProp=g,w.foldedComponentIds=r?Array.prototype.concat(e.foldedComponentIds,e.styledComponentId):h,w.styledComponentId=v,w.target=r?e.target:e,w.withComponent=function(e){var r=t.componentId,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(t,["componentId"]),i=r&&r+"-"+(ge(e)?e:me(b(e)));return ke(e,f({},o,{attrs:y,componentId:i}),n)},Object.defineProperty(w,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(t){this._foldedDefaultProps=r?le({},e.defaultProps,t):t}}),w.toString=function(){return"."+w.styledComponentId},o&&c()(w,e,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,self:!0,styledComponentId:!0,target:!0,withComponent:!0}),w}var Se=function(e){return function e(t,n,o){if(void 0===o&&(o=v),!Object(r.isValidElementType)(n))return O(1,String(n));var i=function(){return t(n,o,ie.apply(void 0,arguments))};return i.withConfig=function(r){return e(t,n,f({},o,{},r))},i.attrs=function(r){return e(t,n,f({},o,{attrs:Array.prototype.concat(o.attrs,r).filter(Boolean)}))},i}(ke,e)};["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"].forEach((function(e){Se[e]=Se(e)}));t.a=Se}).call(this,n(61))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=t.InlineIcon=t.Icon=void 0;var r,o=(r=n(0))&&r.__esModule?r:{default:r};function i(e){return(i="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})(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}var u=0,s=/(-?[0-9.]*[0-9]+[0-9.]*)/g,l=/^-?[0-9.]*[0-9]+[0-9.]*$/g,c=["width","height","inline","hFlip","vFlip","flip","rotate","align","color","box"],f={left:0,top:0,width:16,height:16,rotate:0,hFlip:!1,vFlip:!1};var d=function(){function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._item=t}var t,n,r;return t=e,r=[{key:"splitAttributes",value:function(e){var t={icon:Object.create(null),node:Object.create(null)};return Object.keys(e).forEach((function(n){t[-1===c.indexOf(n)?"node":"icon"][n]=e[n]})),t}},{key:"calculateDimension",value:function(e,t,n){if(1===t)return e;if(n=void 0===n?100:n,"number"==typeof e)return Math.ceil(e*t*n)/n;var r=e.split(s);if(null===r||!r.length)return null;for(var o,i=[],a=r.shift(),u=l.test(a);;){if(u?(o=parseFloat(a),isNaN(o)?i.push(a):i.push(Math.ceil(o*t*n)/n)):i.push(a),void 0===(a=r.shift()))return i.join("");u=!u}}},{key:"replaceIDs",value:function(e){var t,n,r=/\sid="(\S+)"/g,o=[];function i(e,t,n){for(var r=0;-1!==(r=n.indexOf(e,r));)n=n.slice(0,r)+t+n.slice(r+e.length),r+=t.length;return n}for(;t=r.exec(e);)o.push(t[1]);return o.length?(n="IconifyId-"+Date.now().toString(16)+"-"+(16777216*Math.random()|0).toString(16)+"-",o.forEach((function(t){var r=n+u;u++,e=i('="'+t+'"','="'+r+'"',e),e=i('="#'+t+'"','="#'+r+'"',e),e=i("(#"+t+")","(#"+r+")",e)})),e):e}}],(n=[{key:"getAttributes",value:function(t){var n=this._item;"object"!==i(t)&&(t=Object.create(null));var r={horizontal:"center",vertical:"middle",slice:!1},o={rotate:n.rotate,hFlip:n.hFlip,vFlip:n.vFlip},a=Object.create(null),u=Object.create(null),s=!0===t.inline||"true"===t.inline||"1"===t.inline,l={left:n.left,top:s?n.inlineTop:n.top,width:n.width,height:s?n.inlineHeight:n.height};if(["hFlip","vFlip"].forEach((function(e){void 0===t[e]||!0!==t[e]&&"true"!==t[e]&&"1"!==t[e]||(o[e]=!o[e])})),void 0!==t.flip&&t.flip.toLowerCase().split(/[\s,]+/).forEach((function(e){switch(e){case"horizontal":o.hFlip=!o.hFlip;break;case"vertical":o.vFlip=!o.vFlip}})),void 0!==t.rotate){var c=t.rotate;if("number"==typeof c)o.rotate+=c;else if("string"==typeof c){var f=c.replace(/^-?[0-9.]*/,"");if(""===f)c=parseInt(c),isNaN(c)||(o.rotate+=c);else if(f!==c){var d=!1;switch(f){case"%":d=25;break;case"deg":d=90}d&&(c=parseInt(c.slice(0,c.length-f.length)),isNaN(c)||(o.rotate+=Math.round(c/d)))}}}var p,h=[];switch(o.hFlip?o.vFlip?o.rotate+=2:(h.push("translate("+(l.width+l.left)+" "+(0-l.top)+")"),h.push("scale(-1 1)"),l.top=l.left=0):o.vFlip&&(h.push("translate("+(0-l.left)+" "+(l.height+l.top)+")"),h.push("scale(1 -1)"),l.top=l.left=0),o.rotate%4){case 1:p=l.height/2+l.top,h.unshift("rotate(90 "+p+" "+p+")"),0===l.left&&0===l.top||(p=l.left,l.left=l.top,l.top=p),l.width!==l.height&&(p=l.width,l.width=l.height,l.height=p);break;case 2:h.unshift("rotate(180 "+(l.width/2+l.left)+" "+(l.height/2+l.top)+")");break;case 3:p=l.width/2+l.left,h.unshift("rotate(-90 "+p+" "+p+")"),0===l.left&&0===l.top||(p=l.left,l.left=l.top,l.top=p),l.width!==l.height&&(p=l.width,l.width=l.height,l.height=p)}var v,y,b=t.width?t.width:null,m=t.height?t.height:null;null===b&&null===m&&(m="1em"),null!==b&&null!==m?(v=b,y=m):null!==b?(v=b,y=e.calculateDimension(v,l.height/l.width)):(y=m,v=e.calculateDimension(y,l.width/l.height)),!1!==v&&(u.width="auto"===v?l.width:v),!1!==y&&(u.height="auto"===y?l.height:y),s&&0!==n.verticalAlign&&(a["vertical-align"]=n.verticalAlign+"em"),void 0!==t.align&&t.align.toLowerCase().split(/[\s,]+/).forEach((function(e){switch(e){case"left":case"right":case"center":r.horizontal=e;break;case"top":case"bottom":case"middle":r.vertical=e;break;case"crop":r.slice=!0;break;case"meet":r.slice=!1}})),u.preserveAspectRatio=function(e){var t;switch(e.horizontal){case"left":t="xMin";break;case"right":t="xMax";break;default:t="xMid"}switch(e.vertical){case"top":t+="YMin";break;case"bottom":t+="YMax";break;default:t+="YMid"}return t+=e.slice?" slice":" meet"}(r),u.viewBox=l.left+" "+l.top+" "+l.width+" "+l.height;var g=e.replaceIDs(n.body);return void 0!==t.color&&(g=g.replace(/currentColor/g,t.color)),h.length&&(g='<g transform="'+h.join(" ")+'">'+g+"</g>"),!0!==t.box&&"true"!==t.box&&"1"!==t.box||(g+='<rect x="'+l.left+'" y="'+l.top+'" width="'+l.width+'" height="'+l.height+'" fill="rgba(0, 0, 0, 0)" />'),{attributes:u,body:g,style:a}}},{key:"getSVG",value:function(t,n){var r=e.splitAttributes(t),o=this.getAttributes(r.icon),i='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"';return n&&Object.keys(r.node).forEach((function(e){i+=" "+e+'="'+r.node[e]+'"'})),Object.keys(o.attributes).forEach((function(e){i+=" "+e+'="'+o.attributes[e]+'"'})),i+=' style="-ms-transform: rotate(360deg); -webkit-transform: rotate(360deg); transform: rotate(360deg);',Object.keys(o.style).forEach((function(e){i+=" "+e+": "+o.style[e]+";"})),t&&void 0!==t.style&&(i+=t.style),i+='">',i+=o.body+"</svg>"}}])&&a(t.prototype,n),r&&a(t,r),e}();function p(e,t){if("object"!==i(e.icon))return null;var n=d.splitAttributes(e),r=n.icon,a=n.node;delete a.icon,void 0===r.inline&&(r.inline=t);var u=new d(function(e){var t,n=Object.create(null);for(t in f)n[t]=f[t];for(t in e)n[t]=e[t];return void 0===n.inlineTop&&(n.inlineTop=n.top),void 0===n.inlineHeight&&(n.inlineHeight=n.height),void 0===n.verticalAlign&&(n.verticalAlign=n.height%7==0&&n.height%8!=0?-.143:-.125),n}(e.icon)).getAttributes(r),s={transform:"rotate(360deg)"};if(void 0!==u.style["vertical-align"]&&(s.verticalAlign=u.style["vertical-align"]),void 0!==e.style)for(var l in e.style)s[l]=e.style[l];var c,p={xmlns:"http://www.w3.org/2000/svg",focusable:!1,style:s};for(c in a)p[c]=a[c];for(c in u.attributes)p[c]=u.attributes[c];return p.dangerouslySetInnerHTML={__html:u.body},o.default.createElement("svg",p,null)}var h=function(e){return p(e,!1)};t.Icon=h;t.InlineIcon=function(e){return p(e,!0)};var v=h;t.default=v},function(e,t){t.__esModule=!0,t.default={body:'<path d="M7.41 8.58L12 13.17l4.59-4.59L18 10l-6 6l-6-6l1.41-1.42z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function o(e){return(o=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function a(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function u(e,t,n){return(u=a()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&i(o,n.prototype),o}).apply(null,arguments)}function s(e){var t="function"==typeof Map?new Map:void 0;return(s=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return u(e,arguments,o(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),i(r,e)})(e)}function l(e){return(l="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})(e)}n.d(t,"a",(function(){return N}));var c=function(e){var t,n;function r(t){return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e.call(this,"An error occurred. See https://github.com/styled-components/polished/blob/master/src/internalHelpers/errors.md#"+t+" for more information.")||this)}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n,r}(s(Error));function f(e){return Math.round(255*e)}function d(e,t,n){return f(e)+","+f(t)+","+f(n)}function p(e,t,n,r){if(void 0===r&&(r=d),0===t)return r(n,n,n);var o=(e%360+360)%360/60,i=(1-Math.abs(2*n-1))*t,a=i*(1-Math.abs(o%2-1)),u=0,s=0,l=0;o>=0&&o<1?(u=i,s=a):o>=1&&o<2?(u=a,s=i):o>=2&&o<3?(s=i,l=a):o>=3&&o<4?(s=a,l=i):o>=4&&o<5?(u=a,l=i):o>=5&&o<6&&(u=i,l=a);var c=n-i/2;return r(u+c,s+c,l+c)}var h={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"00ffff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"0000ff",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",cornsilk:"fff8dc",crimson:"dc143c",cyan:"00ffff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"ff00ff",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",rebeccapurple:"639",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"};var v=/^#[a-fA-F0-9]{6}$/,y=/^#[a-fA-F0-9]{8}$/,b=/^#[a-fA-F0-9]{3}$/,m=/^#[a-fA-F0-9]{4}$/,g=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i,w=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i,_=/^hsl\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*\)$/i,C=/^hsla\(\s*(\d{0,3}[.]?[0-9]+)\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*(\d{1,3}[.]?[0-9]?)%\s*,\s*([-+]?[0-9]*[.]?[0-9]+)\s*\)$/i;function O(e){if("string"!=typeof e)throw new c(3);var t=function(e){if("string"!=typeof e)return e;var t=e.toLowerCase();return h[t]?"#"+h[t]:e}(e);if(t.match(v))return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16)};if(t.match(y)){var n=parseFloat((parseInt(""+t[7]+t[8],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[2],16),green:parseInt(""+t[3]+t[4],16),blue:parseInt(""+t[5]+t[6],16),alpha:n}}if(t.match(b))return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16)};if(t.match(m)){var r=parseFloat((parseInt(""+t[4]+t[4],16)/255).toFixed(2));return{red:parseInt(""+t[1]+t[1],16),green:parseInt(""+t[2]+t[2],16),blue:parseInt(""+t[3]+t[3],16),alpha:r}}var o=g.exec(t);if(o)return{red:parseInt(""+o[1],10),green:parseInt(""+o[2],10),blue:parseInt(""+o[3],10)};var i=w.exec(t);if(i)return{red:parseInt(""+i[1],10),green:parseInt(""+i[2],10),blue:parseInt(""+i[3],10),alpha:parseFloat(""+i[4])};var a=_.exec(t);if(a){var u="rgb("+p(parseInt(""+a[1],10),parseInt(""+a[2],10)/100,parseInt(""+a[3],10)/100)+")",s=g.exec(u);if(!s)throw new c(4,t,u);return{red:parseInt(""+s[1],10),green:parseInt(""+s[2],10),blue:parseInt(""+s[3],10)}}var l=C.exec(t);if(l){var f="rgb("+p(parseInt(""+l[1],10),parseInt(""+l[2],10)/100,parseInt(""+l[3],10)/100)+")",d=g.exec(f);if(!d)throw new c(4,t,f);return{red:parseInt(""+d[1],10),green:parseInt(""+d[2],10),blue:parseInt(""+d[3],10),alpha:parseFloat(""+l[4])}}throw new c(5)}function k(e){return function(e){var t,n=e.red/255,r=e.green/255,o=e.blue/255,i=Math.max(n,r,o),a=Math.min(n,r,o),u=(i+a)/2;if(i===a)return void 0!==e.alpha?{hue:0,saturation:0,lightness:u,alpha:e.alpha}:{hue:0,saturation:0,lightness:u};var s=i-a,l=u>.5?s/(2-i-a):s/(i+a);switch(i){case n:t=(r-o)/s+(r<o?6:0);break;case r:t=(o-n)/s+2;break;default:t=(n-r)/s+4}return t*=60,void 0!==e.alpha?{hue:t,saturation:l,lightness:u,alpha:e.alpha}:{hue:t,saturation:l,lightness:u}}(O(e))}var S=function(e){return 7===e.length&&e[1]===e[2]&&e[3]===e[4]&&e[5]===e[6]?"#"+e[1]+e[3]+e[5]:e};function x(e){var t=e.toString(16);return 1===t.length?"0"+t:t}function A(e){return x(Math.round(255*e))}function M(e,t,n){return S("#"+A(e)+A(t)+A(n))}function j(e,t,n){return p(e,t,n,M)}function E(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return j(e,t,n);if("object"===l(e)&&void 0===t&&void 0===n)return j(e.hue,e.saturation,e.lightness);throw new c(1)}function P(e,t,n,r){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return r>=1?j(e,t,n):"rgba("+p(e,t,n)+","+r+")";if("object"===l(e)&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?j(e.hue,e.saturation,e.lightness):"rgba("+p(e.hue,e.saturation,e.lightness)+","+e.alpha+")";throw new c(2)}function I(e,t,n){if("number"==typeof e&&"number"==typeof t&&"number"==typeof n)return S("#"+x(e)+x(t)+x(n));if("object"===l(e)&&void 0===t&&void 0===n)return S("#"+x(e.red)+x(e.green)+x(e.blue));throw new c(6)}function R(e,t,n,r){if("string"==typeof e&&"number"==typeof t){var o=O(e);return"rgba("+o.red+","+o.green+","+o.blue+","+t+")"}if("number"==typeof e&&"number"==typeof t&&"number"==typeof n&&"number"==typeof r)return r>=1?I(e,t,n):"rgba("+e+","+t+","+n+","+r+")";if("object"===l(e)&&void 0===t&&void 0===n&&void 0===r)return e.alpha>=1?I(e.red,e.green,e.blue):"rgba("+e.red+","+e.green+","+e.blue+","+e.alpha+")";throw new c(7)}function T(e){if("object"!==l(e))throw new c(8);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&"number"==typeof e.alpha}(e))return R(e);if(function(e){return"number"==typeof e.red&&"number"==typeof e.green&&"number"==typeof e.blue&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return I(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&"number"==typeof e.alpha}(e))return P(e);if(function(e){return"number"==typeof e.hue&&"number"==typeof e.saturation&&"number"==typeof e.lightness&&("number"!=typeof e.alpha||void 0===e.alpha)}(e))return E(e);throw new c(8)}function L(e){return function e(t,n,r){return function(){var o=r.concat(Array.prototype.slice.call(arguments));return o.length>=n?t.apply(this,o):e(t,n,o)}}(e,e.length,[])}function F(e,t,n){return Math.max(e,Math.min(t,n))}function z(e,t){if("transparent"===t)return t;var n=k(t);return T(r({},n,{lightness:F(0,1,n.lightness+parseFloat(e))}))}var N=L(z)},function(e,t){t.__esModule=!0,t.default={body:'<path d="M8.59 16.58L13.17 12L8.59 7.41L10 6l6 6l-6 6l-1.41-1.42z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";var r=n(0),o=n(58),i=n.n(o);function a(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}function u(){return void 0===navigator.onLine||navigator.onLine}var s=new WeakMap,l=0;var c=new(function(){function e(e){void 0===e&&(e={}),this.__cache=new Map(Object.entries(e)),this.__listeners=[]}return e.prototype.get=function(e){var t=this.serializeKey(e)[0];return this.__cache.get(t)},e.prototype.set=function(e,t,n){void 0===n&&(n=!0);var r=this.serializeKey(e)[0];this.__cache.set(r,t),n&&E(e,t,!1),this.notify()},e.prototype.keys=function(){return Array.from(this.__cache.keys())},e.prototype.has=function(e){var t=this.serializeKey(e)[0];return this.__cache.has(t)},e.prototype.clear=function(e){void 0===e&&(e=!0),e&&this.__cache.forEach((function(e){return E(e,null,!1)})),this.__cache.clear(),this.notify()},e.prototype.delete=function(e,t){void 0===t&&(t=!0);var n=this.serializeKey(e)[0];t&&E(e,null,!1),this.__cache.delete(n),this.notify()},e.prototype.serializeKey=function(e){var t=null;if("function"==typeof e)try{e=e()}catch(t){e=""}return Array.isArray(e)?(t=e,e=function(e){if(!e.length)return"";for(var t="arg",n=0;n<e.length;++n){var r=void 0;null===e[n]||"object"!=typeof e[n]?r="string"==typeof e[n]?'"'+e[n]+'"':String(e[n]):s.has(e[n])?r=s.get(e[n]):(r=l,s.set(e[n],l++)),t+="@"+r}return t}(e)):e=String(e||""),[e,t,e?"err@"+e:""]},e.prototype.subscribe=function(e){var t=this;if("function"!=typeof e)throw new Error("Expected the listener to be a function.");var n=!0;return this.__listeners.push(e),function(){if(n){n=!1;var r=t.__listeners.indexOf(e);r>-1&&(t.__listeners[r]=t.__listeners[t.__listeners.length-1],t.__listeners.length--)}}},e.prototype.notify=function(){for(var e=0,t=this.__listeners;e<t.length;e++){(0,t[e])()}},e}()),f={},d={},p={},h={},v={};var y="undefined"!=typeof window&&navigator.connection&&-1!==["slow-2g","2g"].indexOf(navigator.connection.effectiveType),b={onLoadingSlow:function(){},onSuccess:function(){},onError:function(){},onErrorRetry:function(e,t,n,r,o){if(a()&&!(n.errorRetryCount&&o.retryCount>n.errorRetryCount)){var i=Math.min(o.retryCount||0,8),u=~~((Math.random()+.5)*(1<<i))*n.errorRetryInterval;setTimeout(r,u,o)}},errorRetryInterval:1e3*(y?10:5),focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:1e3*(y?5:3),refreshInterval:0,revalidateOnFocus:!0,revalidateOnReconnect:!0,refreshWhenHidden:!1,refreshWhenOffline:!1,shouldRetryOnError:!0,suspense:!1,compare:i.a},m=!1;if("undefined"!=typeof window&&window.addEventListener&&!m){var g=function(){if(a()&&u())for(var e in p)p[e][0]&&p[e][0]()};window.addEventListener("visibilitychange",g,!1),window.addEventListener("focus",g,!1),m=!0}var w=b;function _(e,t){var n=!1;return function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];n||(n=!0,e.apply(void 0,r),setTimeout((function(){return n=!1}),t))}}var C=Object(r.createContext)({});C.displayName="SWRConfigContext";var O=C,k=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function u(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((r=r.apply(e,t||[])).next())}))},S=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},x="undefined"==typeof window,A=x?r.useEffect:r.useLayoutEffect,M=function(e,t){void 0===t&&(t=!0);var n=c.serializeKey(e),r=n[0],o=n[2];if(!r)return Promise.resolve();var i=h[r];if(r&&i){for(var a=c.get(r),u=c.get(o),s=[],l=0;l<i.length;++l)s.push(i[l](t,a,u,l>0));return Promise.all(s).then((function(){return c.get(r)}))}return Promise.resolve(c.get(r))},j=function(e,t,n){var r=h[e];if(e&&r)for(var o=0;o<r.length;++o)r[o](!1,t,n)},E=function(e,t,n){return void 0===n&&(n=!0),k(void 0,void 0,void 0,(function(){var r,o,i,a,u,s,l,f,p,y;return S(this,(function(b){switch(b.label){case 0:if(!(r=c.serializeKey(e)[0]))return[2];if(void 0===t)return[2,M(e,n)];if(v[r]=Date.now()-1,a=v[r],u=d[r],!t||"function"!=typeof t)return[3,5];b.label=1;case 1:return b.trys.push([1,3,,4]),[4,t(c.get(r))];case 2:return o=b.sent(),[3,4];case 3:return s=b.sent(),i=s,[3,4];case 4:return[3,11];case 5:if(!t||"function"!=typeof t.then)return[3,10];b.label=6;case 6:return b.trys.push([6,8,,9]),[4,t];case 7:return o=b.sent(),[3,9];case 8:return l=b.sent(),i=l,[3,9];case 9:return[3,11];case 10:o=t,b.label=11;case 11:if(a!==v[r]||u!==d[r]){if(i)throw i;return[2,o]}if(void 0!==o&&c.set(r,o,!1),f=h[r]){for(p=[],y=0;y<f.length;++y)p.push(f[y](!!n,o,i,y>0));return[2,Promise.all(p).then((function(){return c.get(r)}))]}if(i)throw i;return[2,o]}}))}))};O.Provider;var P=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o,i,s={};t.length>=1&&(o=t[0]),t.length>2?(i=t[1],s=t[2]):"function"==typeof t[1]?i=t[1]:"object"==typeof t[1]&&(s=t[1]);var l=c.serializeKey(o),y=l[0],b=l[1],m=l[2];s=Object.assign({},w,Object(r.useContext)(O),s),void 0===i&&(i=s.fetcher);var g=c.get(y)||s.initialData,C=c.get(m),M=Object(r.useRef)({data:!1,error:!1,isValidating:!1}),P=Object(r.useRef)({data:g,error:C,isValidating:!1}),I=Object(r.useState)(null)[1],R=Object(r.useCallback)((function(e){var t=!1;for(var n in e)P.current[n]=e[n],M.current[n]&&(t=!0);(t||s.suspense)&&I({})}),[]),T=Object(r.useRef)(!1),L=Object(r.useRef)(y),F=Object(r.useRef)({emit:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];T.current||s[e].apply(s,t)}}),z=Object(r.useCallback)((function(e,t){return E(y,e,t)}),[y]),N=Object(r.useCallback)((function(t){return void 0===t&&(t={}),k(e,void 0,void 0,(function(){var e,n,r,o,a,u,l;return S(this,(function(p){switch(p.label){case 0:if(!y||!i)return[2,!1];if(T.current)return[2,!1];t=Object.assign({dedupe:!1},t),e=!0,n=void 0!==f[y]&&t.dedupe,p.label=1;case 1:return p.trys.push([1,6,,7]),R({isValidating:!0}),r=void 0,o=void 0,n?(o=d[y],[4,f[y]]):[3,3];case 2:return r=p.sent(),[3,5];case 3:return f[y]&&(v[y]=Date.now()-1),s.loadingTimeout&&!c.get(y)&&setTimeout((function(){e&&F.current.emit("onLoadingSlow",y,s)}),s.loadingTimeout),f[y]=null!==b?i.apply(void 0,b):i(y),d[y]=o=Date.now(),[4,f[y]];case 4:r=p.sent(),setTimeout((function(){delete f[y],delete d[y]}),s.dedupingInterval),F.current.emit("onSuccess",r,y,s),p.label=5;case 5:return v[y]&&o<=v[y]?(R({isValidating:!1}),[2,!1]):(c.set(y,r,!1),c.set(m,void 0,!1),a={isValidating:!1},void 0!==P.current.error&&(a.error=void 0),s.compare(P.current.data,r)||(a.data=r),R(a),n||j(y,r,void 0),[3,7]);case 6:return u=p.sent(),delete f[y],delete d[y],c.set(m,u,!1),P.current.error!==u&&(R({isValidating:!1,error:u}),n||j(y,void 0,u)),F.current.emit("onError",u,y,s),s.shouldRetryOnError&&(l=(t.retryCount||0)+1,F.current.emit("onErrorRetry",u,y,s,N,Object.assign({dedupe:!0},t,{retryCount:l}))),[3,7];case 7:return e=!1,[2,!0]}}))}))}),[y]);if(A((function(){if(y){T.current=!1;var e=P.current.data,t=c.get(y)||s.initialData;L.current===y&&s.compare(e,t)||(R({data:t}),L.current=y);var n,r=function(){return N({dedupe:!0})};(s.revalidateOnMount||!s.initialData&&void 0===s.revalidateOnMount)&&(void 0!==t&&!x&&window.requestIdleCallback?window.requestIdleCallback(r):r()),s.revalidateOnFocus&&(n=_(r,s.focusThrottleInterval),p[y]?p[y].push(n):p[y]=[n]);var o=function(e,t,n,o){void 0===e&&(e=!0),void 0===o&&(o=!0);var i={},a=!1;return void 0===t||s.compare(P.current.data,t)||(i.data=t,a=!0),P.current.error!==n&&(i.error=n,a=!0),a&&R(i),!!e&&(o?r():N())};h[y]?h[y].push(o):h[y]=[o];var i=null;return!x&&window.addEventListener&&s.revalidateOnReconnect&&window.addEventListener("online",i=r),function(){var e,t;(R=function(){return null},T.current=!0,n&&p[y])&&((t=(e=p[y]).indexOf(n))>=0&&(e[t]=e[e.length-1],e.pop()));h[y]&&((t=(e=h[y]).indexOf(o))>=0&&(e[t]=e[e.length-1],e.pop()));!x&&window.removeEventListener&&null!==i&&window.removeEventListener("online",i)}}}),[y,N]),A((function(){var t=null,n=function(){return k(e,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return P.current.error||!s.refreshWhenHidden&&!a()||!s.refreshWhenOffline&&!u()?[3,2]:[4,N({dedupe:!0})];case 1:e.sent(),e.label=2;case 2:return s.refreshInterval&&(t=setTimeout(n,s.refreshInterval)),[2]}}))}))};return s.refreshInterval&&(t=setTimeout(n,s.refreshInterval)),function(){t&&clearTimeout(t)}}),[s.refreshInterval,s.refreshWhenHidden,s.refreshWhenOffline,N]),s.suspense){var D=c.get(y)||g,H=c.get(m)||C;if(void 0===D&&void 0===H){if(f[y]||N(),f[y]&&"function"==typeof f[y].then)throw f[y];D=f[y]}if(void 0===D&&H)throw H;return{error:H,data:D,revalidate:N,mutate:z,isValidating:P.current.isValidating}}return Object(r.useMemo)((function(){var e={revalidate:N,mutate:z};return Object.defineProperties(e,{error:{get:function(){return M.current.error=!0,L.current===y?P.current.error:C},enumerable:!0},data:{get:function(){return M.current.data=!0,L.current===y?P.current.data:g},enumerable:!0},isValidating:{get:function(){return M.current.isValidating=!0,P.current.isValidating},enumerable:!0}}),e}),[N])};new Map;t.a=P},function(e,t){t.__esModule=!0,t.default={body:'<path d="M7.41 15.41L12 10.83l4.59 4.58L18 14l-6-6l-6 6l1.41 1.41z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M18.41 7.41L17 6l-6 6l6 6l1.41-1.41L13.83 12l4.58-4.59m-6 0L11 6l-6 6l6 6l1.41-1.41L7.83 12l4.58-4.59z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M5.59 7.41L7 6l6 6l-6 6l-1.41-1.41L10.17 12L5.59 7.41m6 0L13 6l6 6l-6 6l-1.41-1.41L16.17 12l-4.58-4.59z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M15.41 16.58L10.83 12l4.58-4.59L14 6l-6 6l6 6l1.41-1.42z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M14 19h4V5h-4M6 19h4V5H6v14z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M8 5.14v14l11-7l-11-7z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M18 18H6V6h12v12z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";e.exports=n(62)},function(e,t){t.__esModule=!0,t.default={body:'<path d="M19 3H5c-1.11 0-2 .89-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 2v14H5V5h14z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M10 17l-5-5l1.41-1.42L10 14.17l7.59-7.59L19 8m0-5H5c-1.11 0-2 .89-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M10 4H4c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-8l-2-2z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.canUseDOM=void 0;var r,o=n(74);var i=((r=o)&&r.__esModule?r:{default:r}).default,a=i.canUseDOM?window.HTMLElement:{};t.canUseDOM=i.canUseDOM;t.default=a},function(e,t,n){"use strict";var r=n(15),o={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},i={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},u={};function s(e){return r.isMemo(e)?a:u[e.$$typeof]||o}u[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},u[r.Memo]=a;var l=Object.defineProperty,c=Object.getOwnPropertyNames,f=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,p=Object.getPrototypeOf,h=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(h){var o=p(n);o&&o!==h&&e(t,o,r)}var a=c(n);f&&(a=a.concat(f(n)));for(var u=s(t),v=s(n),y=0;y<a.length;++y){var b=a[y];if(!(i[b]||r&&r[b]||v&&v[b]||u&&u[b])){var m=d(n,b);try{l(t,b,m)}catch(e){}}}}return t}},function(e,t,n){"use strict";n.d(t,"b",(function(){return S})),n.d(t,"a",(function(){return f}));var r=n(0),o=n(57),i=n.n(o);function a(){return"undefined"==typeof document||void 0===document.visibilityState||"hidden"!==document.visibilityState}function u(){return void 0===navigator.onLine||navigator.onLine}function s(e){return(s="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})(e)}var l=new WeakMap,c=0;var f=new(function(){function e(e){void 0===e&&(e={}),this.__cache=new Map(Object.entries(e)),this.__listeners=[]}return e.prototype.get=function(e){var t=this.serializeKey(e)[0];return this.__cache.get(t)},e.prototype.set=function(e,t,n){void 0===n&&(n=!0);var r=this.serializeKey(e)[0];this.__cache.set(r,t),n&&S(e,t,!1),this.notify()},e.prototype.keys=function(){return Array.from(this.__cache.keys())},e.prototype.has=function(e){var t=this.serializeKey(e)[0];return this.__cache.has(t)},e.prototype.clear=function(e){void 0===e&&(e=!0),e&&this.__cache.forEach((function(e){return S(e,null,!1)})),this.__cache.clear(),this.notify()},e.prototype.delete=function(e,t){void 0===t&&(t=!0);var n=this.serializeKey(e)[0];t&&S(e,null,!1),this.__cache.delete(n),this.notify()},e.prototype.serializeKey=function(e){var t=null;if("function"==typeof e)try{e=e()}catch(t){e=""}return Array.isArray(e)?(t=e,e=function(e){if(!e.length)return"";for(var t="arg",n=0;n<e.length;++n){var r=void 0;null===e[n]||"object"!==s(e[n])?r="string"==typeof e[n]?'"'+e[n]+'"':String(e[n]):l.has(e[n])?r=l.get(e[n]):(r=c,l.set(e[n],c++)),t+="@"+r}return t}(e)):e=String(e||""),[e,t,e?"err@"+e:""]},e.prototype.subscribe=function(e){var t=this;if("function"!=typeof e)throw new Error("Expected the listener to be a function.");var n=!0;return this.__listeners.push(e),function(){if(n){n=!1;var r=t.__listeners.indexOf(e);r>-1&&(t.__listeners[r]=t.__listeners[t.__listeners.length-1],t.__listeners.length--)}}},e.prototype.notify=function(){for(var e=0,t=this.__listeners;e<t.length;e++){(0,t[e])()}},e}()),d={},p={},h={},v={};var y="undefined"!=typeof window&&navigator.connection&&-1!==["slow-2g","2g"].indexOf(navigator.connection.effectiveType),b=(i.a,!1);if("undefined"!=typeof window&&window.addEventListener&&!b){var m=function(){if(a()&&u())for(var e in p)p[e][0]&&p[e][0]()};window.addEventListener("visibilitychange",m,!1),window.addEventListener("focus",m,!1),b=!0}var g=Object(r.createContext)({});g.displayName="SWRConfigContext";var w=g;var _=function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{s(r.next(e))}catch(e){i(e)}}function u(e){try{s(r.throw(e))}catch(e){i(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((r=r.apply(e,t||[])).next())}))},C=function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(i){return function(u){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=t.call(e,a)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,u])}}},O="undefined"==typeof window,k=(O?r.useEffect:r.useLayoutEffect,function(e,t){void 0===t&&(t=!0);var n=f.serializeKey(e),r=n[0],o=n[2];if(!r)return Promise.resolve();var i=h[r];if(r&&i){for(var a=f.get(r),u=f.get(o),s=[],l=0;l<i.length;++l)s.push(i[l](t,a,u,l>0));return Promise.all(s).then((function(){return f.get(r)}))}return Promise.resolve(f.get(r))}),S=function(e,t,n){return void 0===n&&(n=!0),_(void 0,void 0,void 0,(function(){var r,o,i,a,u,s,l,c,p,y;return C(this,(function(b){switch(b.label){case 0:if(!(r=f.serializeKey(e)[0]))return[2];if(void 0===t)return[2,k(e,n)];if(v[r]=Date.now()-1,a=v[r],u=d[r],!t||"function"!=typeof t)return[3,5];b.label=1;case 1:return b.trys.push([1,3,,4]),[4,t(f.get(r))];case 2:return o=b.sent(),[3,4];case 3:return s=b.sent(),i=s,[3,4];case 4:return[3,11];case 5:if(!t||"function"!=typeof t.then)return[3,10];b.label=6;case 6:return b.trys.push([6,8,,9]),[4,t];case 7:return o=b.sent(),[3,9];case 8:return l=b.sent(),i=l,[3,9];case 9:return[3,11];case 10:o=t,b.label=11;case 11:if(a!==v[r]||u!==d[r]){if(i)throw i;return[2,o]}if(void 0!==o&&f.set(r,o,!1),c=h[r]){for(p=[],y=0;y<c.length;++y)p.push(c[y](!!n,o,i,y>0));return[2,Promise.all(p).then((function(){return f.get(r)}))]}if(i)throw i;return[2,o]}}))}))};w.Provider,new Map},function(e,t,n){"use strict";var r=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,o=function(e){var t={};return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}((function(e){return r.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}));t.a=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return[].slice.call(e.querySelectorAll("*"),0).filter(a)};
|
2 |
+
/*!
|
3 |
+
* Adapted from jQuery UI core
|
4 |
+
*
|
5 |
+
* http://jqueryui.com
|
6 |
+
*
|
7 |
+
* Copyright 2014 jQuery Foundation and other contributors
|
8 |
+
* Released under the MIT license.
|
9 |
+
* http://jquery.org/license
|
10 |
+
*
|
11 |
+
* http://api.jqueryui.com/category/ui-core/
|
12 |
+
*/
|
13 |
+
var r=/input|select|textarea|button|object/;function o(e){var t=e.offsetWidth<=0&&e.offsetHeight<=0;if(t&&!e.innerHTML)return!0;var n=window.getComputedStyle(e);return t?"visible"!==n.getPropertyValue("overflow")||e.scrollWidth<=0&&e.scrollHeight<=0:"none"==n.getPropertyValue("display")}function i(e,t){var n=e.nodeName.toLowerCase();return(r.test(n)&&!e.disabled||"a"===n&&e.href||t)&&function(e){for(var t=e;t&&t!==document.body;){if(o(t))return!1;t=t.parentNode}return!0}(e)}function a(e){var t=e.getAttribute("tabindex");null===t&&(t=void 0);var n=isNaN(t);return(n||t>=0)&&i(e,!n)}e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.assertNodeList=s,t.setElement=function(e){var t=e;if("string"==typeof t&&a.canUseDOM){var n=document.querySelectorAll(t);s(n,t),t="length"in n?n[0]:n}return u=t||u},t.validateElement=l,t.hide=function(e){l(e)&&(e||u).setAttribute("aria-hidden","true")},t.show=function(e){l(e)&&(e||u).removeAttribute("aria-hidden")},t.documentNotReadyOrSSRTesting=function(){u=null},t.resetForTesting=function(){u=null};var r,o=n(73),i=(r=o)&&r.__esModule?r:{default:r},a=n(19);var u=null;function s(e,t){if(!e||!e.length)throw new Error("react-modal: No elements were found for selector "+t+".")}function l(e){return!(!e&&!u)||((0,i.default)(!1,["react-modal: App element is not defined.","Please use `Modal.setAppElement(el)` or set `appElement={el}`.","This is needed so screen readers don't see main content","when modal is opened. It is not recommended, but you can opt-out","by setting `ariaHideApp={false}`."].join(" ")),!1)}},function(e,t){(function(t){e.exports=t}).call(this,{})},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=new function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.register=function(e){-1===t.openInstances.indexOf(e)&&(t.openInstances.push(e),t.emit("register"))},this.deregister=function(e){var n=t.openInstances.indexOf(e);-1!==n&&(t.openInstances.splice(n,1),t.emit("deregister"))},this.subscribe=function(e){t.subscribers.push(e)},this.emit=function(e){t.subscribers.forEach((function(n){return n(e,t.openInstances.slice())}))},this.openInstances=[],this.subscribers=[]};t.default=r,e.exports=t.default},function(e,t){t.__esModule=!0,t.default={body:'<path d="M18 8a2 2 0 0 1 2 2v10c0 1.1-.9 2-2 2H6a2 2 0 0 1-2-2V10c0-1.11.89-2 2-2h1V6C7 3.24 9.24.998 12 .998S17 3.24 17 6v2h1m-6-5c-1.66 0-3 1.34-3 3v2h6V6c0-1.66-1.34-3-3-3m-1 16l6.25-6.24l-1.41-1.41L11 16.18L8.41 13.6L7 15l4 4z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M18 1c-2.76 0-5 2.24-5 5v2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12c1.11 0 2-.89 2-2V10a2 2 0 0 0-2-2h-1V6c0-1.66 1.34-3 3-3s3 1.34 3 3v2h2V6c0-2.76-2.24-5-5-5m-8 12a2 2 0 0 1 2 2c0 1.11-.89 2-2 2a2 2 0 1 1 0-4z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M13 9h5.5L13 3.5V9M6 2h8l6 6v12a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2m6.16 12.31c-1.56 0-2.97.58-4.05 1.52L6 13.72V19h5.28l-2.13-2.12c.82-.68 1.85-1.1 3.01-1.1c2.07 0 3.84 1.35 4.45 3.22l1.39-.46c-.81-2.45-3.12-4.23-5.84-4.23z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 5V1L7 6l5 5V7a6 6 0 0 1 6 6a6 6 0 0 1-6 6a6 6 0 0 1-6-6H4a8 8 0 0 0 8 8a8 8 0 0 0 8-8a8 8 0 0 0-8-8z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M21 7L9 19l-5.5-5.5l1.41-1.41L9 16.17L19.59 5.59L21 7z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6v12z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12.5 8c-2.65 0-5.05 1-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88c3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M13 13h-2V7h2m0 10h-2v-2h2M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 3C7.58 3 4 4.79 4 7s3.58 4 8 4s8-1.79 8-4s-3.58-4-8-4M4 9v3c0 2.21 3.58 4 8 4s8-1.79 8-4V9c0 2.21-3.58 4-8 4s-8-1.79-8-4m0 5v3c0 2.21 3.58 4 8 4s8-1.79 8-4v-3c0 2.21-3.58 4-8 4s-8-1.79-8-4z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M20.71 7.04c.39-.39.39-1.04 0-1.41l-2.34-2.34c-.37-.39-1.02-.39-1.41 0l-1.84 1.83l3.75 3.75M3 17.25V21h3.75L17.81 9.93l-3.75-3.75L3 17.25z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M21.71 20.29l-1.42 1.42a1 1 0 0 1-1.41 0L7 9.85A3.81 3.81 0 0 1 6 10a4 4 0 0 1-3.78-5.3l2.54 2.54l.53-.53l1.42-1.42l.53-.53L4.7 2.22A4 4 0 0 1 10 6a3.81 3.81 0 0 1-.15 1l11.86 11.88a1 1 0 0 1 0 1.41M2.29 18.88a1 1 0 0 0 0 1.41l1.42 1.42a1 1 0 0 0 1.41 0l5.47-5.46l-2.83-2.83M20 2l-4 2v2l-2.17 2.17l2 2L18 8h2l2-4z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97c0-.33-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1c0 .33.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.66z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 8l-1.33.09C9.81 7.07 7.4 4.5 5 4.5c0 0-1.97 2.96-.04 6.91c-.55.83-.89 1.26-.96 2.25l-1.93.29l.21.98l1.76-.26l.14.71l-1.57.94l.47.89l1.45-.89C5.68 18.76 8.59 20 12 20s6.32-1.24 7.47-3.68l1.45.89l.47-.89l-1.57-.94l.14-.71l1.76.26l.21-.98l-1.93-.29c-.07-.99-.41-1.42-.96-2.25C20.97 7.46 19 4.5 19 4.5c-2.4 0-4.81 2.57-5.67 3.59L12 8m-3 3a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m6 0a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m-4 3h2l-.7 1.39c.2.64.76 1.11 1.45 1.11a1.5 1.5 0 0 0 1.5-1.5h.5a2 2 0 0 1-2 2c-.75 0-1.4-.41-1.75-1c-.35.59-1 1-1.75 1a2 2 0 0 1-2-2h.5a1.5 1.5 0 0 0 1.5 1.5c.69 0 1.25-.47 1.45-1.11L11 14z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M9 16v-6H5l7-7l7 7h-4v6H9m-4 4v-2h14v2H5z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M9 3v1H4v2h1v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6h1V4h-5V3H9m0 5h2v9H9V8m4 0h2v9h-2V8z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M16.84 2.73c-.39 0-.77.15-1.07.44l-2.12 2.12l5.3 5.31l2.12-2.1c.6-.61.6-1.56 0-2.14L17.9 3.17c-.3-.29-.68-.44-1.06-.44M12.94 6l-8.1 8.11l2.56.28l.18 2.29l2.28.17l.29 2.56l8.1-8.11m-14 3.74L2.5 21.73l6.7-1.79l-.24-2.16l-2.31-.17l-.18-2.32" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M13 3v6h8V3m-8 18h8V11h-8M3 21h8v-6H3m0-2h8V3H3v10z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M18.68 12.32a4.49 4.49 0 0 0-6.36.01a4.49 4.49 0 0 0 0 6.36a4.508 4.508 0 0 0 5.57.63L21 22.39L22.39 21l-3.09-3.11c1.13-1.77.87-4.09-.62-5.57m-1.41 4.95c-.98.98-2.56.97-3.54 0c-.97-.98-.97-2.56.01-3.54c.97-.97 2.55-.97 3.53 0c.97.98.97 2.56 0 3.54M10.9 20.1a6.527 6.527 0 0 1-1.48-2.32C6.27 17.25 4 15.76 4 14v3c0 2.21 3.58 4 8 4c-.4-.26-.77-.56-1.1-.9M4 9v3c0 1.68 2.07 3.12 5 3.7v-.2c0-.93.2-1.85.58-2.69C6.34 12.3 4 10.79 4 9m8-6C7.58 3 4 4.79 4 7c0 2 3 3.68 6.85 4h.05c1.2-1.26 2.86-2 4.6-2c.91 0 1.81.19 2.64.56A3.215 3.215 0 0 0 20 7c0-2.21-3.58-4-8-4z" fill="currentColor"/>',width:24,height:24}},function(e,t){e.exports=function(e,t,n,r){var o=n?n.call(r,e,t):void 0;if(void 0!==o)return!!o;if(e===t)return!0;if("object"!=typeof e||!e||"object"!=typeof t||!t)return!1;var i=Object.keys(e),a=Object.keys(t);if(i.length!==a.length)return!1;for(var u=Object.prototype.hasOwnProperty.bind(t),s=0;s<i.length;s++){var l=i[s];if(!u(l))return!1;var c=e[l],f=t[l];if(!1===(o=n?n.call(r,c,f,l):void 0)||void 0===o&&c!==f)return!1}return!0}},function(e,t,n){"use strict";t.a=function(e){function t(e,t,r){var o=t.trim().split(h);t=o;var i=o.length,a=e.length;switch(a){case 0:case 1:var u=0;for(e=0===a?"":e[0]+" ";u<i;++u)t[u]=n(e,t[u],r).trim();break;default:var s=u=0;for(t=[];u<i;++u)for(var l=0;l<a;++l)t[s++]=n(e[l]+" ",o[u],r).trim()}return t}function n(e,t,n){var r=t.charCodeAt(0);switch(33>r&&(r=(t=t.trim()).charCodeAt(0)),r){case 38:return t.replace(v,"$1"+e.trim());case 58:return e.trim()+t.replace(v,"$1"+e.trim());default:if(0<1*n&&0<t.indexOf("\f"))return t.replace(v,(58===e.charCodeAt(0)?"":"$1")+e.trim())}return e+t}function r(e,t,n,i){var a=e+";",u=2*t+3*n+4*i;if(944===u){e=a.indexOf(":",9)+1;var s=a.substring(e,a.length-1).trim();return s=a.substring(0,e).trim()+s+";",1===j||2===j&&o(s,1)?"-webkit-"+s+s:s}if(0===j||2===j&&!o(a,1))return a;switch(u){case 1015:return 97===a.charCodeAt(10)?"-webkit-"+a+a:a;case 951:return 116===a.charCodeAt(3)?"-webkit-"+a+a:a;case 963:return 110===a.charCodeAt(5)?"-webkit-"+a+a:a;case 1009:if(100!==a.charCodeAt(4))break;case 969:case 942:return"-webkit-"+a+a;case 978:return"-webkit-"+a+"-moz-"+a+a;case 1019:case 983:return"-webkit-"+a+"-moz-"+a+"-ms-"+a+a;case 883:if(45===a.charCodeAt(8))return"-webkit-"+a+a;if(0<a.indexOf("image-set(",11))return a.replace(S,"$1-webkit-$2")+a;break;case 932:if(45===a.charCodeAt(4))switch(a.charCodeAt(5)){case 103:return"-webkit-box-"+a.replace("-grow","")+"-webkit-"+a+"-ms-"+a.replace("grow","positive")+a;case 115:return"-webkit-"+a+"-ms-"+a.replace("shrink","negative")+a;case 98:return"-webkit-"+a+"-ms-"+a.replace("basis","preferred-size")+a}return"-webkit-"+a+"-ms-"+a+a;case 964:return"-webkit-"+a+"-ms-flex-"+a+a;case 1023:if(99!==a.charCodeAt(8))break;return"-webkit-box-pack"+(s=a.substring(a.indexOf(":",15)).replace("flex-","").replace("space-between","justify"))+"-webkit-"+a+"-ms-flex-pack"+s+a;case 1005:return d.test(a)?a.replace(f,":-webkit-")+a.replace(f,":-moz-")+a:a;case 1e3:switch(t=(s=a.substring(13).trim()).indexOf("-")+1,s.charCodeAt(0)+s.charCodeAt(t)){case 226:s=a.replace(g,"tb");break;case 232:s=a.replace(g,"tb-rl");break;case 220:s=a.replace(g,"lr");break;default:return a}return"-webkit-"+a+"-ms-"+s+a;case 1017:if(-1===a.indexOf("sticky",9))break;case 975:switch(t=(a=e).length-10,u=(s=(33===a.charCodeAt(t)?a.substring(0,t):a).substring(e.indexOf(":",7)+1).trim()).charCodeAt(0)+(0|s.charCodeAt(7))){case 203:if(111>s.charCodeAt(8))break;case 115:a=a.replace(s,"-webkit-"+s)+";"+a;break;case 207:case 102:a=a.replace(s,"-webkit-"+(102<u?"inline-":"")+"box")+";"+a.replace(s,"-webkit-"+s)+";"+a.replace(s,"-ms-"+s+"box")+";"+a}return a+";";case 938:if(45===a.charCodeAt(5))switch(a.charCodeAt(6)){case 105:return s=a.replace("-items",""),"-webkit-"+a+"-webkit-box-"+s+"-ms-flex-"+s+a;case 115:return"-webkit-"+a+"-ms-flex-item-"+a.replace(C,"")+a;default:return"-webkit-"+a+"-ms-flex-line-pack"+a.replace("align-content","").replace(C,"")+a}break;case 973:case 989:if(45!==a.charCodeAt(3)||122===a.charCodeAt(4))break;case 931:case 953:if(!0===k.test(e))return 115===(s=e.substring(e.indexOf(":")+1)).charCodeAt(0)?r(e.replace("stretch","fill-available"),t,n,i).replace(":fill-available",":stretch"):a.replace(s,"-webkit-"+s)+a.replace(s,"-moz-"+s.replace("fill-",""))+a;break;case 962:if(a="-webkit-"+a+(102===a.charCodeAt(5)?"-ms-"+a:"")+a,211===n+i&&105===a.charCodeAt(13)&&0<a.indexOf("transform",10))return a.substring(0,a.indexOf(";",27)+1).replace(p,"$1-webkit-$2")+a}return a}function o(e,t){var n=e.indexOf(1===t?":":"{"),r=e.substring(0,3!==t?n:10);return n=e.substring(n+1,e.length-1),R(2!==t?r:r.replace(O,"$1"),n,t)}function i(e,t){var n=r(t,t.charCodeAt(0),t.charCodeAt(1),t.charCodeAt(2));return n!==t+";"?n.replace(_," or ($1)").substring(4):"("+t+")"}function a(e,t,n,r,o,i,a,u,l,c){for(var f,d=0,p=t;d<I;++d)switch(f=P[d].call(s,e,p,n,r,o,i,a,u,l,c)){case void 0:case!1:case!0:case null:break;default:p=f}if(p!==t)return p}function u(e){return void 0!==(e=e.prefix)&&(R=null,e?"function"!=typeof e?j=1:(j=2,R=e):j=0),u}function s(e,n){var u=e;if(33>u.charCodeAt(0)&&(u=u.trim()),u=[u],0<I){var s=a(-1,n,u,u,A,x,0,0,0,0);void 0!==s&&"string"==typeof s&&(n=s)}var f=function e(n,u,s,f,d){for(var p,h,v,g,_,C=0,O=0,k=0,S=0,P=0,R=0,L=v=p=0,F=0,z=0,N=0,D=0,H=s.length,q=H-1,$="",V="",U="",W="";F<H;){if(h=s.charCodeAt(F),F===q&&0!==O+S+k+C&&(0!==O&&(h=47===O?10:47),S=k=C=0,H++,q++),0===O+S+k+C){if(F===q&&(0<z&&($=$.replace(c,"")),0<$.trim().length)){switch(h){case 32:case 9:case 59:case 13:case 10:break;default:$+=s.charAt(F)}h=59}switch(h){case 123:for(p=($=$.trim()).charCodeAt(0),v=1,D=++F;F<H;){switch(h=s.charCodeAt(F)){case 123:v++;break;case 125:v--;break;case 47:switch(h=s.charCodeAt(F+1)){case 42:case 47:e:{for(L=F+1;L<q;++L)switch(s.charCodeAt(L)){case 47:if(42===h&&42===s.charCodeAt(L-1)&&F+2!==L){F=L+1;break e}break;case 10:if(47===h){F=L+1;break e}}F=L}}break;case 91:h++;case 40:h++;case 34:case 39:for(;F++<q&&s.charCodeAt(F)!==h;);}if(0===v)break;F++}switch(v=s.substring(D,F),0===p&&(p=($=$.replace(l,"").trim()).charCodeAt(0)),p){case 64:switch(0<z&&($=$.replace(c,"")),h=$.charCodeAt(1)){case 100:case 109:case 115:case 45:z=u;break;default:z=E}if(D=(v=e(u,z,v,h,d+1)).length,0<I&&(_=a(3,v,z=t(E,$,N),u,A,x,D,h,d,f),$=z.join(""),void 0!==_&&0===(D=(v=_.trim()).length)&&(h=0,v="")),0<D)switch(h){case 115:$=$.replace(w,i);case 100:case 109:case 45:v=$+"{"+v+"}";break;case 107:v=($=$.replace(y,"$1 $2"))+"{"+v+"}",v=1===j||2===j&&o("@"+v,3)?"@-webkit-"+v+"@"+v:"@"+v;break;default:v=$+v,112===f&&(V+=v,v="")}else v="";break;default:v=e(u,t(u,$,N),v,f,d+1)}U+=v,v=N=z=L=p=0,$="",h=s.charCodeAt(++F);break;case 125:case 59:if(1<(D=($=(0<z?$.replace(c,""):$).trim()).length))switch(0===L&&(p=$.charCodeAt(0),45===p||96<p&&123>p)&&(D=($=$.replace(" ",":")).length),0<I&&void 0!==(_=a(1,$,u,n,A,x,V.length,f,d,f))&&0===(D=($=_.trim()).length)&&($="\0\0"),p=$.charCodeAt(0),h=$.charCodeAt(1),p){case 0:break;case 64:if(105===h||99===h){W+=$+s.charAt(F);break}default:58!==$.charCodeAt(D-1)&&(V+=r($,p,h,$.charCodeAt(2)))}N=z=L=p=0,$="",h=s.charCodeAt(++F)}}switch(h){case 13:case 10:47===O?O=0:0===1+p&&107!==f&&0<$.length&&(z=1,$+="\0"),0<I*T&&a(0,$,u,n,A,x,V.length,f,d,f),x=1,A++;break;case 59:case 125:if(0===O+S+k+C){x++;break}default:switch(x++,g=s.charAt(F),h){case 9:case 32:if(0===S+C+O)switch(P){case 44:case 58:case 9:case 32:g="";break;default:32!==h&&(g=" ")}break;case 0:g="\\0";break;case 12:g="\\f";break;case 11:g="\\v";break;case 38:0===S+O+C&&(z=N=1,g="\f"+g);break;case 108:if(0===S+O+C+M&&0<L)switch(F-L){case 2:112===P&&58===s.charCodeAt(F-3)&&(M=P);case 8:111===R&&(M=R)}break;case 58:0===S+O+C&&(L=F);break;case 44:0===O+k+S+C&&(z=1,g+="\r");break;case 34:case 39:0===O&&(S=S===h?0:0===S?h:S);break;case 91:0===S+O+k&&C++;break;case 93:0===S+O+k&&C--;break;case 41:0===S+O+C&&k--;break;case 40:if(0===S+O+C){if(0===p)switch(2*P+3*R){case 533:break;default:p=1}k++}break;case 64:0===O+k+S+C+L+v&&(v=1);break;case 42:case 47:if(!(0<S+C+k))switch(O){case 0:switch(2*h+3*s.charCodeAt(F+1)){case 235:O=47;break;case 220:D=F,O=42}break;case 42:47===h&&42===P&&D+2!==F&&(33===s.charCodeAt(D+2)&&(V+=s.substring(D,F+1)),g="",O=0)}}0===O&&($+=g)}R=P,P=h,F++}if(0<(D=V.length)){if(z=u,0<I&&(void 0!==(_=a(2,V,z,n,A,x,D,f,d,f))&&0===(V=_).length))return W+V+U;if(V=z.join(",")+"{"+V+"}",0!=j*M){switch(2!==j||o(V,2)||(M=0),M){case 111:V=V.replace(m,":-moz-$1")+V;break;case 112:V=V.replace(b,"::-webkit-input-$1")+V.replace(b,"::-moz-$1")+V.replace(b,":-ms-input-$1")+V}M=0}}return W+V+U}(E,u,n,0,0);return 0<I&&(void 0!==(s=a(-2,f,u,u,A,x,f.length,0,0,0))&&(f=s)),"",M=0,x=A=1,f}var l=/^\0+/g,c=/[\0\r\f]/g,f=/: */g,d=/zoo|gra/,p=/([,: ])(transform)/g,h=/,\r+?/g,v=/([\t\r\n ])*\f?&/g,y=/@(k\w+)\s*(\S*)\s*/,b=/::(place)/g,m=/:(read-only)/g,g=/[svh]\w+-[tblr]{2}/,w=/\(\s*(.*)\s*\)/g,_=/([\s\S]*?);/g,C=/-self|flex-/g,O=/[^]*?(:[rp][el]a[\w-]+)[^]*/,k=/stretch|:\s*\w+\-(?:conte|avail)/,S=/([^-])(image-set\()/,x=1,A=1,M=0,j=1,E=[],P=[],I=0,R=null,T=0;return s.use=function e(t){switch(t){case void 0:case null:I=P.length=0;break;default:if("function"==typeof t)P[I++]=t;else if("object"==typeof t)for(var n=0,r=t.length;n<r;++n)e(t[n]);else T=0|!!t}return e},s.set=u,void 0!==e&&u(e),s}},function(e,t,n){"use strict";t.a={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},function(e,t,n){"use strict";function r(e,t,n,r,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void n(e)}u.done?t(s):Promise.resolve(s).then(r,o)}function o(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function u(e){r(a,o,i,u,s,"next",e)}function s(e){r(a,o,i,u,s,"throw",e)}u(void 0)}))}}function i(e){return(i="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})(e)}function a(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function s(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=f(e);if(t){var o=f(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return l(this,n)}}function l(e,t){return!t||"object"!==i(t)&&"function"!=typeof t?c(e):t}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}Object.defineProperty(t,"__esModule",{value:!0});var d=n(63),p=n(64),h=n(66),v=function(){},y=new p.TimeoutError,b=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&u(e,t)}(g,e);var t,n,r,l,f,d,b,m=s(g);function g(e){var t,n,r,o,a;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,g),t=m.call(this),Object.defineProperty(c(t),"_carryoverConcurrencyCount",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_isIntervalIgnored",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_intervalCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(c(t),"_intervalCap",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_interval",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_intervalEnd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(c(t),"_intervalId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_timeoutId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_queue",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_queueClass",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_pendingCount",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(c(t),"_concurrency",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_isPaused",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_resolveEmpty",{enumerable:!0,configurable:!0,writable:!0,value:v}),Object.defineProperty(c(t),"_resolveIdle",{enumerable:!0,configurable:!0,writable:!0,value:v}),Object.defineProperty(c(t),"_timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(c(t),"_throwOnTimeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),!("number"==typeof(e=Object.assign({carryoverConcurrencyCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:h.default},e)).intervalCap&&e.intervalCap>=1))throw new TypeError("Expected `intervalCap` to be a number from 1 and up, got `".concat(null!==(r=null===(n=e.intervalCap)||void 0===n?void 0:n.toString())&&void 0!==r?r:"","` (").concat(i(e.intervalCap),")"));if(void 0===e.interval||!(Number.isFinite(e.interval)&&e.interval>=0))throw new TypeError("Expected `interval` to be a finite number >= 0, got `".concat(null!==(a=null===(o=e.interval)||void 0===o?void 0:o.toString())&&void 0!==a?a:"","` (").concat(i(e.interval),")"));return t._carryoverConcurrencyCount=e.carryoverConcurrencyCount,t._isIntervalIgnored=e.intervalCap===1/0||0===e.interval,t._intervalCap=e.intervalCap,t._interval=e.interval,t._queue=new e.queueClass,t._queueClass=e.queueClass,t.concurrency=e.concurrency,t._timeout=e.timeout,t._throwOnTimeout=!0===e.throwOnTimeout,t._isPaused=!1===e.autoStart,t}return t=g,(n=[{key:"_next",value:function(){this._pendingCount--,this._tryToStartAnother()}},{key:"_resolvePromises",value:function(){this._resolveEmpty(),this._resolveEmpty=v,0===this._pendingCount&&(this._resolveIdle(),this._resolveIdle=v,this.emit("idle"))}},{key:"_onResumeInterval",value:function(){this._onInterval(),this._initializeIntervalIfNeeded(),this._timeoutId=void 0}},{key:"_isIntervalPaused",value:function(){var e=this,t=Date.now();if(void 0===this._intervalId){var n=this._intervalEnd-t;if(!(n<0))return void 0===this._timeoutId&&(this._timeoutId=setTimeout((function(){e._onResumeInterval()}),n)),!0;this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0}return!1}},{key:"_tryToStartAnother",value:function(){if(0===this._queue.size)return this._intervalId&&clearInterval(this._intervalId),this._intervalId=void 0,this._resolvePromises(),!1;if(!this._isPaused){var e=!this._isIntervalPaused();if(this._doesIntervalAllowAnother&&this._doesConcurrentAllowAnother)return this.emit("active"),this._queue.dequeue()(),e&&this._initializeIntervalIfNeeded(),!0}return!1}},{key:"_initializeIntervalIfNeeded",value:function(){var e=this;this._isIntervalIgnored||void 0!==this._intervalId||(this._intervalId=setInterval((function(){e._onInterval()}),this._interval),this._intervalEnd=Date.now()+this._interval)}},{key:"_onInterval",value:function(){0===this._intervalCount&&0===this._pendingCount&&this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),this._intervalCount=this._carryoverConcurrencyCount?this._pendingCount:0,this._processQueue()}},{key:"_processQueue",value:function(){for(;this._tryToStartAnother(););}},{key:"add",value:(b=o(regeneratorRuntime.mark((function e(t){var n,r=this,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.length>1&&void 0!==i[1]?i[1]:{},e.abrupt("return",new Promise((function(e,i){var a=function(){var a=o(regeneratorRuntime.mark((function o(){var a;return regeneratorRuntime.wrap((function(o){for(;;)switch(o.prev=o.next){case 0:return r._pendingCount++,r._intervalCount++,o.prev=2,a=void 0===r._timeout&&void 0===n.timeout?t():p.default(Promise.resolve(t()),void 0===n.timeout?r._timeout:n.timeout,(function(){(void 0===n.throwOnTimeout?r._throwOnTimeout:n.throwOnTimeout)&&i(y)})),o.t0=e,o.next=7,a;case 7:o.t1=o.sent,(0,o.t0)(o.t1),o.next=14;break;case 11:o.prev=11,o.t2=o.catch(2),i(o.t2);case 14:r._next();case 15:case"end":return o.stop()}}),o,null,[[2,11]])})));return function(){return a.apply(this,arguments)}}();r._queue.enqueue(a,n),r._tryToStartAnother()})));case 2:case"end":return e.stop()}}),e)}))),function(e){return b.apply(this,arguments)})},{key:"addAll",value:(d=o(regeneratorRuntime.mark((function e(t,n){var r=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",Promise.all(t.map(function(){var e=o(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",r.add(t,n));case 1:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}())));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return d.apply(this,arguments)})},{key:"start",value:function(){return this._isPaused?(this._isPaused=!1,this._processQueue(),this):this}},{key:"pause",value:function(){this._isPaused=!0}},{key:"clear",value:function(){this._queue=new this._queueClass}},{key:"onEmpty",value:(f=o(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._queue.size){e.next=2;break}return e.abrupt("return");case 2:return e.abrupt("return",new Promise((function(e){var n=t._resolveEmpty;t._resolveEmpty=function(){n(),e()}})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return f.apply(this,arguments)})},{key:"onIdle",value:(l=o(regeneratorRuntime.mark((function e(){var t=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(0!==this._pendingCount||0!==this._queue.size){e.next=2;break}return e.abrupt("return");case 2:return e.abrupt("return",new Promise((function(e){var n=t._resolveIdle;t._resolveIdle=function(){n(),e()}})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"sizeBy",value:function(e){return this._queue.filter(e).length}},{key:"_doesIntervalAllowAnother",get:function(){return this._isIntervalIgnored||this._intervalCount<this._intervalCap}},{key:"_doesConcurrentAllowAnother",get:function(){return this._pendingCount<this._concurrency}},{key:"concurrency",get:function(){return this._concurrency},set:function(e){if(!("number"==typeof e&&e>=1))throw new TypeError("Expected `concurrency` to be a number from 1 and up, got `".concat(e,"` (").concat(i(e),")"));this._concurrency=e,this._processQueue()}},{key:"size",get:function(){return this._queue.size}},{key:"pending",get:function(){return this._pendingCount}},{key:"isPaused",get:function(){return this._isPaused}},{key:"timeout",get:function(){return this._timeout},set:function(e){this._timeout=e}}])&&a(t.prototype,n),r&&a(t,r),g}(d);t.default=b},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 20a8 8 0 0 1-8-8a8 8 0 0 1 8-8a8 8 0 0 1 8 8a8 8 0 0 1-8 8m0-18A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M12 2A10 10 0 0 0 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2m0 7a3 3 0 0 1 3 3a3 3 0 0 1-3 3a3 3 0 0 1-3-3a3 3 0 0 1 3-3z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M19 20H4a2 2 0 0 1-2-2V6c0-1.11.89-2 2-2h6l2 2h7a2 2 0 0 1 2 2H4v10l2.14-8h17.07l-2.28 8.5c-.23.87-1.01 1.5-1.93 1.5z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M21 17H7V3h14m0-2H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2M3 5H1v16a2 2 0 0 0 2 2h16v-2H3m12.96-10.71l-2.75 3.54l-1.96-2.36L8.5 15h11l-3.54-4.71z" fill="currentColor"/>',width:24,height:24}},function(e,t){t.__esModule=!0,t.default={body:'<path d="M15 9H5V5h10m-3 14a3 3 0 0 1-3-3a3 3 0 0 1 3-3a3 3 0 0 1 3 3a3 3 0 0 1-3 3m5-16H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V7l-4-4z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,o=n(68),i=(r=o)&&r.__esModule?r:{default:r};t.default=i.default,e.exports=t.default},function(e,t){t.__esModule=!0,t.default={body:'<path d="M22 16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4c0-1.11.89-2 2-2h12a2 2 0 0 1 2 2v12m-6 4v2H4a2 2 0 0 1-2-2V7h2v13h12m-3-6l7-7l-1.41-1.41L13 11.17L9.91 8.09L8.5 9.5L13 14z" fill="currentColor"/>',width:24,height:24}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}var o=Array.isArray,i=Object.keys,a=Object.prototype.hasOwnProperty;e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==r(t)&&"object"==r(n)){var u,s,l,c=o(t),f=o(n);if(c&&f){if((s=t.length)!=n.length)return!1;for(u=s;0!=u--;)if(!e(t[u],n[u]))return!1;return!0}if(c!=f)return!1;var d=t instanceof Date,p=n instanceof Date;if(d!=p)return!1;if(d&&p)return t.getTime()==n.getTime();var h=t instanceof RegExp,v=n instanceof RegExp;if(h!=v)return!1;if(h&&v)return t.toString()==n.toString();var y=i(t);if((s=y.length)!==i(n).length)return!1;for(u=s;0!=u--;)if(!a.call(n,y[u]))return!1;for(u=s;0!=u--;)if(!e(t[l=y[u]],n[l]))return!1;return!0}return t!=t&&n!=n}},function(e,t,n){"use strict";var r=Array.isArray,o=Object.keys,i=Object.prototype.hasOwnProperty;e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){var a,u,s,l=r(t),c=r(n);if(l&&c){if((u=t.length)!=n.length)return!1;for(a=u;0!=a--;)if(!e(t[a],n[a]))return!1;return!0}if(l!=c)return!1;var f=t instanceof Date,d=n instanceof Date;if(f!=d)return!1;if(f&&d)return t.getTime()==n.getTime();var p=t instanceof RegExp,h=n instanceof RegExp;if(p!=h)return!1;if(p&&h)return t.toString()==n.toString();var v=o(t);if((u=v.length)!==o(n).length)return!1;for(a=u;0!=a--;)if(!i.call(n,v[a]))return!1;for(a=u;0!=a--;)if(!e(t[s=v[a]],n[s]))return!1;return!0}return t!=t&&n!=n}},function(e,t,n){"use strict";var r=n(60);function o(){}function i(){}i.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,i,a){if(a!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t){var n,r,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:a}catch(e){r=a}}();var s,l=[],c=!1,f=-1;function d(){c&&s&&(c=!1,s.length?l=s.concat(l):f=-1,l.length&&p())}function p(){if(!c){var e=u(d);c=!0;for(var t=l.length;t;){for(s=l,l=[];++f<t;)s&&s[f].run();f=-1,t=l.length}s=null,c=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===a||!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 v(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new h(e,t)),1!==l.length||c||u(p)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=v,o.addListener=v,o.once=v,o.off=v,o.removeListener=v,o.removeAllListeners=v,o.emit=v,o.prependListener=v,o.prependOnceListener=v,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";
|
14 |
+
/** @license React v16.13.1
|
15 |
+
* react-is.production.min.js
|
16 |
+
*
|
17 |
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
18 |
+
*
|
19 |
+
* This source code is licensed under the MIT license found in the
|
20 |
+
* LICENSE file in the root directory of this source tree.
|
21 |
+
*/var r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,i=r?Symbol.for("react.portal"):60106,a=r?Symbol.for("react.fragment"):60107,u=r?Symbol.for("react.strict_mode"):60108,s=r?Symbol.for("react.profiler"):60114,l=r?Symbol.for("react.provider"):60109,c=r?Symbol.for("react.context"):60110,f=r?Symbol.for("react.async_mode"):60111,d=r?Symbol.for("react.concurrent_mode"):60111,p=r?Symbol.for("react.forward_ref"):60112,h=r?Symbol.for("react.suspense"):60113,v=r?Symbol.for("react.suspense_list"):60120,y=r?Symbol.for("react.memo"):60115,b=r?Symbol.for("react.lazy"):60116,m=r?Symbol.for("react.block"):60121,g=r?Symbol.for("react.fundamental"):60117,w=r?Symbol.for("react.responder"):60118,_=r?Symbol.for("react.scope"):60119;function C(e){if("object"==typeof e&&null!==e){var t=e.$$typeof;switch(t){case o:switch(e=e.type){case f:case d:case a:case s:case u:case h:return e;default:switch(e=e&&e.$$typeof){case c:case p:case b:case y:case l:return e;default:return t}}case i:return t}}}function O(e){return C(e)===d}t.AsyncMode=f,t.ConcurrentMode=d,t.ContextConsumer=c,t.ContextProvider=l,t.Element=o,t.ForwardRef=p,t.Fragment=a,t.Lazy=b,t.Memo=y,t.Portal=i,t.Profiler=s,t.StrictMode=u,t.Suspense=h,t.isAsyncMode=function(e){return O(e)||C(e)===f},t.isConcurrentMode=O,t.isContextConsumer=function(e){return C(e)===c},t.isContextProvider=function(e){return C(e)===l},t.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},t.isForwardRef=function(e){return C(e)===p},t.isFragment=function(e){return C(e)===a},t.isLazy=function(e){return C(e)===b},t.isMemo=function(e){return C(e)===y},t.isPortal=function(e){return C(e)===i},t.isProfiler=function(e){return C(e)===s},t.isStrictMode=function(e){return C(e)===u},t.isSuspense=function(e){return C(e)===h},t.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===a||e===d||e===s||e===u||e===h||e===v||"object"==typeof e&&null!==e&&(e.$$typeof===b||e.$$typeof===y||e.$$typeof===l||e.$$typeof===c||e.$$typeof===p||e.$$typeof===g||e.$$typeof===w||e.$$typeof===_||e.$$typeof===m)},t.typeOf=C},function(e,t,n){"use strict";var r=Object.prototype.hasOwnProperty,o="~";function i(){}function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function u(e,t,n,r,i){if("function"!=typeof n)throw new TypeError("The listener must be a function");var u=new a(n,r||e,i),s=o?o+t:t;return e._events[s]?e._events[s].fn?e._events[s]=[e._events[s],u]:e._events[s].push(u):(e._events[s]=u,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function l(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(o=!1)),l.prototype.eventNames=function(){var e,t,n=[];if(0===this._eventsCount)return n;for(t in e=this._events)r.call(e,t)&&n.push(o?t.slice(1):t);return Object.getOwnPropertySymbols?n.concat(Object.getOwnPropertySymbols(e)):n},l.prototype.listeners=function(e){var t=o?o+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var r=0,i=n.length,a=new Array(i);r<i;r++)a[r]=n[r].fn;return a},l.prototype.listenerCount=function(e){var t=o?o+e:e,n=this._events[t];return n?n.fn?1:n.length:0},l.prototype.emit=function(e,t,n,r,i,a){var u=o?o+e:e;if(!this._events[u])return!1;var s,l,c=this._events[u],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,r),!0;case 5:return c.fn.call(c.context,t,n,r,i),!0;case 6:return c.fn.call(c.context,t,n,r,i,a),!0}for(l=1,s=new Array(f-1);l<f;l++)s[l-1]=arguments[l];c.fn.apply(c.context,s)}else{var d,p=c.length;for(l=0;l<p;l++)switch(c[l].once&&this.removeListener(e,c[l].fn,void 0,!0),f){case 1:c[l].fn.call(c[l].context);break;case 2:c[l].fn.call(c[l].context,t);break;case 3:c[l].fn.call(c[l].context,t,n);break;case 4:c[l].fn.call(c[l].context,t,n,r);break;default:if(!s)for(d=1,s=new Array(f-1);d<f;d++)s[d-1]=arguments[d];c[l].fn.apply(c[l].context,s)}}return!0},l.prototype.on=function(e,t,n){return u(this,e,t,n,!1)},l.prototype.once=function(e,t,n){return u(this,e,t,n,!0)},l.prototype.removeListener=function(e,t,n,r){var i=o?o+e:e;if(!this._events[i])return this;if(!t)return s(this,i),this;var a=this._events[i];if(a.fn)a.fn!==t||r&&!a.once||n&&a.context!==n||s(this,i);else{for(var u=0,l=[],c=a.length;u<c;u++)(a[u].fn!==t||r&&!a[u].once||n&&a[u].context!==n)&&l.push(a[u]);l.length?this._events[i]=1===l.length?l[0]:l:s(this,i)}return this},l.prototype.removeAllListeners=function(e){var t;return e?(t=o?o+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},l.prototype.off=l.prototype.removeListener,l.prototype.addListener=l.prototype.on,l.prefixed=o,l.EventEmitter=l,e.exports=l},function(e,t,n){"use strict";function r(e){return(r="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})(e)}function o(e,t){return!t||"object"!==r(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function i(e){var t="function"==typeof Map?new Map:void 0;return(i=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return a(e,arguments,l(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),s(r,e)})(e)}function a(e,t,n){return(a=u()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&s(o,n.prototype),o}).apply(null,arguments)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(e){return(l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var c=n(65),f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&s(e,t)}(i,e);var t,n,r=(t=i,n=u(),function(){var e,r=l(t);if(n){var i=l(this).constructor;e=Reflect.construct(r,arguments,i)}else e=r.apply(this,arguments);return o(this,e)});function i(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,i),(t=r.call(this,e)).name="TimeoutError",t}return i}(i(Error)),d=function(e,t,n){return new Promise((function(r,o){if("number"!=typeof t||t<0)throw new TypeError("Expected `milliseconds` to be a positive number");if(t!==1/0){var i=setTimeout((function(){if("function"!=typeof n){var i="string"==typeof n?n:"Promise timed out after ".concat(t," milliseconds"),a=n instanceof Error?n:new f(i);"function"==typeof e.cancel&&e.cancel(),o(a)}else try{r(n())}catch(e){o(e)}}),t);c(e.then(r,o),(function(){clearTimeout(i)}))}else r(e)}))};e.exports=d,e.exports.default=d,e.exports.TimeoutError=f},function(e,t,n){"use strict";e.exports=function(e,t){return t=t||function(){},e.then((function(e){return new Promise((function(e){e(t())})).then((function(){return e}))}),(function(e){return new Promise((function(e){e(t())})).then((function(){throw e}))}))}},function(e,t,n){"use strict";function r(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(67),i=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),Object.defineProperty(this,"_queue",{enumerable:!0,configurable:!0,writable:!0,value:[]})}var t,n,i;return t=e,(n=[{key:"enqueue",value:function(e,t){var n={priority:(t=Object.assign({priority:0},t)).priority,run:e};if(this.size&&this._queue[this.size-1].priority>=t.priority)this._queue.push(n);else{var r=o.default(this._queue,n,(function(e,t){return t.priority-e.priority}));this._queue.splice(r,0,n)}}},{key:"dequeue",value:function(){var e=this._queue.shift();return null==e?void 0:e.run}},{key:"filter",value:function(e){return this._queue.filter((function(t){return t.priority===e.priority})).map((function(e){return e.run}))}},{key:"size",get:function(){return this._queue.length}}])&&r(t.prototype,n),i&&r(t,i),e}();t.default=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){for(var r=0,o=e.length;o>0;){var i=o/2|0,a=r+i;n(e[a],t)<=0?(r=++a,o-=i+1):o=i}return r}},function(e,t,n){"use strict";function r(e){return(r="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})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.bodyOpenClassName=t.portalClassName=void 0;var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=n(0),u=v(a),s=v(n(69)),l=v(n(1)),c=v(n(70)),f=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(n(24)),d=n(19),p=v(d),h=n(77);function v(e){return e&&e.__esModule?e:{default:e}}function y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function b(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==r(t)&&"function"!=typeof t?e:t}var m=t.portalClassName="ReactModalPortal",g=t.bodyOpenClassName="ReactModal__Body--open",w=void 0!==s.default.createPortal,_=function(){return w?s.default.createPortal:s.default.unstable_renderSubtreeIntoContainer};function C(e){return e()}var O=function(e){function t(){var e,n,r;y(this,t);for(var i=arguments.length,a=Array(i),l=0;l<i;l++)a[l]=arguments[l];return n=r=b(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.removePortal=function(){!w&&s.default.unmountComponentAtNode(r.node);var e=C(r.props.parentSelector);e?e.removeChild(r.node):console.warn('React-Modal: "parentSelector" prop did not returned any DOM element. Make sure that the parent element is unmounted to avoid any memory leaks.')},r.portalRef=function(e){r.portal=e},r.renderPortal=function(e){var n=_()(r,u.default.createElement(c.default,o({defaultStyles:t.defaultStyles},e)),r.node);r.portalRef(n)},b(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+r(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),i(t,[{key:"componentDidMount",value:function(){d.canUseDOM&&(w||(this.node=document.createElement("div")),this.node.className=this.props.portalClassName,C(this.props.parentSelector).appendChild(this.node),!w&&this.renderPortal(this.props))}},{key:"getSnapshotBeforeUpdate",value:function(e){return{prevParent:C(e.parentSelector),nextParent:C(this.props.parentSelector)}}},{key:"componentDidUpdate",value:function(e,t,n){if(d.canUseDOM){var r=this.props,o=r.isOpen,i=r.portalClassName;e.portalClassName!==i&&(this.node.className=i);var a=n.prevParent,u=n.nextParent;u!==a&&(a.removeChild(this.node),u.appendChild(this.node)),(e.isOpen||o)&&!w&&this.renderPortal(this.props)}}},{key:"componentWillUnmount",value:function(){if(d.canUseDOM&&this.node&&this.portal){var e=this.portal.state,t=Date.now(),n=e.isOpen&&this.props.closeTimeoutMS&&(e.closesAt||t+this.props.closeTimeoutMS);n?(e.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal,n-t)):this.removePortal()}}},{key:"render",value:function(){return d.canUseDOM&&w?(!this.node&&w&&(this.node=document.createElement("div")),_()(u.default.createElement(c.default,o({ref:this.portalRef,defaultStyles:t.defaultStyles},this.props)),this.node)):null}}],[{key:"setAppElement",value:function(e){f.setElement(e)}}]),t}(a.Component);O.propTypes={isOpen:l.default.bool.isRequired,style:l.default.shape({content:l.default.object,overlay:l.default.object}),portalClassName:l.default.string,bodyOpenClassName:l.default.string,htmlOpenClassName:l.default.string,className:l.default.oneOfType([l.default.string,l.default.shape({base:l.default.string.isRequired,afterOpen:l.default.string.isRequired,beforeClose:l.default.string.isRequired})]),overlayClassName:l.default.oneOfType([l.default.string,l.default.shape({base:l.default.string.isRequired,afterOpen:l.default.string.isRequired,beforeClose:l.default.string.isRequired})]),appElement:l.default.instanceOf(p.default),onAfterOpen:l.default.func,onRequestClose:l.default.func,closeTimeoutMS:l.default.number,ariaHideApp:l.default.bool,shouldFocusAfterRender:l.default.bool,shouldCloseOnOverlayClick:l.default.bool,shouldReturnFocusAfterClose:l.default.bool,parentSelector:l.default.func,aria:l.default.object,data:l.default.object,role:l.default.string,contentLabel:l.default.string,shouldCloseOnEsc:l.default.bool,overlayRef:l.default.func,contentRef:l.default.func},O.defaultProps={isOpen:!1,portalClassName:m,bodyOpenClassName:g,role:"dialog",ariaHideApp:!0,closeTimeoutMS:0,shouldFocusAfterRender:!0,shouldCloseOnEsc:!0,shouldCloseOnOverlayClick:!0,shouldReturnFocusAfterClose:!0,parentSelector:function(){return document.body}},O.defaultStyles={overlay:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.75)"},content:{position:"absolute",top:"40px",left:"40px",right:"40px",bottom:"40px",border:"1px solid #ccc",background:"#fff",overflow:"auto",WebkitOverflowScrolling:"touch",borderRadius:"4px",outline:"none",padding:"20px"}},(0,h.polyfill)(O),t.default=O},,function(e,t,n){"use strict";function r(e){return(r="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})(e)}Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i="function"==typeof Symbol&&"symbol"===r(Symbol.iterator)?function(e){return r(e)}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":r(e)},a=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=n(0),s=b(u),l=b(n(1)),c=y(n(71)),f=b(n(72)),d=y(n(24)),p=y(n(75)),h=b(n(19)),v=b(n(26));function y(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function b(e){return e&&e.__esModule?e:{default:e}}n(76);var m={overlay:"ReactModal__Overlay",content:"ReactModal__Content"},g=0,w=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!==r(t)&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.setOverlayRef=function(e){n.overlay=e,n.props.overlayRef&&n.props.overlayRef(e)},n.setContentRef=function(e){n.content=e,n.props.contentRef&&n.props.contentRef(e)},n.afterClose=function(){var e=n.props,t=e.appElement,r=e.ariaHideApp,o=e.htmlOpenClassName,i=e.bodyOpenClassName;i&&p.remove(document.body,i),o&&p.remove(document.getElementsByTagName("html")[0],o),r&&g>0&&0===(g-=1)&&d.show(t),n.props.shouldFocusAfterRender&&(n.props.shouldReturnFocusAfterClose?(c.returnFocus(),c.teardownScopedFocus()):c.popWithoutFocus()),n.props.onAfterClose&&n.props.onAfterClose(),v.default.deregister(n)},n.open=function(){n.beforeOpen(),n.state.afterOpen&&n.state.beforeClose?(clearTimeout(n.closeTimer),n.setState({beforeClose:!1})):(n.props.shouldFocusAfterRender&&(c.setupScopedFocus(n.node),c.markForFocusLater()),n.setState({isOpen:!0},(function(){n.setState({afterOpen:!0}),n.props.isOpen&&n.props.onAfterOpen&&n.props.onAfterOpen({overlayEl:n.overlay,contentEl:n.content})})))},n.close=function(){n.props.closeTimeoutMS>0?n.closeWithTimeout():n.closeWithoutTimeout()},n.focusContent=function(){return n.content&&!n.contentHasFocus()&&n.content.focus()},n.closeWithTimeout=function(){var e=Date.now()+n.props.closeTimeoutMS;n.setState({beforeClose:!0,closesAt:e},(function(){n.closeTimer=setTimeout(n.closeWithoutTimeout,n.state.closesAt-Date.now())}))},n.closeWithoutTimeout=function(){n.setState({beforeClose:!1,isOpen:!1,afterOpen:!1,closesAt:null},n.afterClose)},n.handleKeyDown=function(e){9===e.keyCode&&(0,f.default)(n.content,e),n.props.shouldCloseOnEsc&&27===e.keyCode&&(e.stopPropagation(),n.requestClose(e))},n.handleOverlayOnClick=function(e){null===n.shouldClose&&(n.shouldClose=!0),n.shouldClose&&n.props.shouldCloseOnOverlayClick&&(n.ownerHandlesClose()?n.requestClose(e):n.focusContent()),n.shouldClose=null},n.handleContentOnMouseUp=function(){n.shouldClose=!1},n.handleOverlayOnMouseDown=function(e){n.props.shouldCloseOnOverlayClick||e.target!=n.overlay||e.preventDefault()},n.handleContentOnClick=function(){n.shouldClose=!1},n.handleContentOnMouseDown=function(){n.shouldClose=!1},n.requestClose=function(e){return n.ownerHandlesClose()&&n.props.onRequestClose(e)},n.ownerHandlesClose=function(){return n.props.onRequestClose},n.shouldBeClosed=function(){return!n.state.isOpen&&!n.state.beforeClose},n.contentHasFocus=function(){return document.activeElement===n.content||n.content.contains(document.activeElement)},n.buildClassName=function(e,t){var r="object"===(void 0===t?"undefined":i(t))?t:{base:m[e],afterOpen:m[e]+"--after-open",beforeClose:m[e]+"--before-close"},o=r.base;return n.state.afterOpen&&(o=o+" "+r.afterOpen),n.state.beforeClose&&(o=o+" "+r.beforeClose),"string"==typeof t&&t?o+" "+t:o},n.attributesFromObject=function(e,t){return Object.keys(t).reduce((function(n,r){return n[e+"-"+r]=t[r],n}),{})},n.state={afterOpen:!1,beforeClose:!1},n.shouldClose=null,n.moveFromContentToOverlay=null,n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+r(t));e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,e),a(t,[{key:"componentDidMount",value:function(){this.props.isOpen&&this.open()}},{key:"componentDidUpdate",value:function(e,t){this.props.isOpen&&!e.isOpen?this.open():!this.props.isOpen&&e.isOpen&&this.close(),this.props.shouldFocusAfterRender&&this.state.isOpen&&!t.isOpen&&this.focusContent()}},{key:"componentWillUnmount",value:function(){this.state.isOpen&&this.afterClose(),clearTimeout(this.closeTimer)}},{key:"beforeOpen",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,r=e.htmlOpenClassName,o=e.bodyOpenClassName;o&&p.add(document.body,o),r&&p.add(document.getElementsByTagName("html")[0],r),n&&(g+=1,d.hide(t)),v.default.register(this)}},{key:"render",value:function(){var e=this.props,t=e.id,n=e.className,r=e.overlayClassName,i=e.defaultStyles,a=n?{}:i.content,u=r?{}:i.overlay;return this.shouldBeClosed()?null:s.default.createElement("div",{ref:this.setOverlayRef,className:this.buildClassName("overlay",r),style:o({},u,this.props.style.overlay),onClick:this.handleOverlayOnClick,onMouseDown:this.handleOverlayOnMouseDown},s.default.createElement("div",o({id:t,ref:this.setContentRef,style:o({},a,this.props.style.content),className:this.buildClassName("content",n),tabIndex:"-1",onKeyDown:this.handleKeyDown,onMouseDown:this.handleContentOnMouseDown,onMouseUp:this.handleContentOnMouseUp,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.attributesFromObject("aria",this.props.aria||{}),this.attributesFromObject("data",this.props.data||{}),{"data-testid":this.props.testId}),this.props.children))}}]),t}(u.Component);w.defaultProps={style:{overlay:{},content:{}},defaultStyles:{}},w.propTypes={isOpen:l.default.bool.isRequired,defaultStyles:l.default.shape({content:l.default.object,overlay:l.default.object}),style:l.default.shape({content:l.default.object,overlay:l.default.object}),className:l.default.oneOfType([l.default.string,l.default.object]),overlayClassName:l.default.oneOfType([l.default.string,l.default.object]),bodyOpenClassName:l.default.string,htmlOpenClassName:l.default.string,ariaHideApp:l.default.bool,appElement:l.default.instanceOf(h.default),onAfterOpen:l.default.func,onAfterClose:l.default.func,onRequestClose:l.default.func,closeTimeoutMS:l.default.number,shouldFocusAfterRender:l.default.bool,shouldCloseOnOverlayClick:l.default.bool,shouldReturnFocusAfterClose:l.default.bool,role:l.default.string,contentLabel:l.default.string,aria:l.default.object,data:l.default.object,children:l.default.node,shouldCloseOnEsc:l.default.bool,overlayRef:l.default.func,contentRef:l.default.func,id:l.default.string,testId:l.default.string},t.default=w,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.handleBlur=l,t.handleFocus=c,t.markForFocusLater=function(){a.push(document.activeElement)},t.returnFocus=function(){var e=null;try{return void(0!==a.length&&(e=a.pop()).focus())}catch(t){console.warn(["You tried to return focus to",e,"but it is not in the DOM anymore"].join(" "))}},t.popWithoutFocus=function(){a.length>0&&a.pop()},t.setupScopedFocus=function(e){u=e,window.addEventListener?(window.addEventListener("blur",l,!1),document.addEventListener("focus",c,!0)):(window.attachEvent("onBlur",l),document.attachEvent("onFocus",c))},t.teardownScopedFocus=function(){u=null,window.addEventListener?(window.removeEventListener("blur",l),document.removeEventListener("focus",c)):(window.detachEvent("onBlur",l),document.detachEvent("onFocus",c))};var r,o=n(23),i=(r=o)&&r.__esModule?r:{default:r};var a=[],u=null,s=!1;function l(){s=!0}function c(){if(s){if(s=!1,!u)return;setTimeout((function(){u.contains(document.activeElement)||((0,i.default)(u)[0]||u).focus()}),0)}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var n=(0,i.default)(e);if(!n.length)return void t.preventDefault();var r=void 0,o=t.shiftKey,a=n[0],u=n[n.length-1];if(e===document.activeElement){if(!o)return;r=u}u!==document.activeElement||o||(r=a);a===document.activeElement&&o&&(r=u);if(r)return t.preventDefault(),void r.focus();var s=/(\bChrome\b|\bSafari\b)\//.exec(navigator.userAgent);if(null==s||"Chrome"==s[1]||null!=/\biPod\b|\biPad\b/g.exec(navigator.userAgent))return;var l=n.indexOf(document.activeElement);l>-1&&(l+=o?-1:1);if(void 0===(r=n[l]))return t.preventDefault(),void(r=o?u:a).focus();t.preventDefault(),r.focus()};var r,o=n(23),i=(r=o)&&r.__esModule?r:{default:r};e.exports=t.default},function(e,t,n){"use strict";var r=function(){};e.exports=r},function(e,t,n){var r;function o(e){return(o="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})(e)}
|
22 |
+
/*!
|
23 |
+
Copyright (c) 2015 Jed Watson.
|
24 |
+
Based on code that is Copyright 2013-2015, Facebook, Inc.
|
25 |
+
All rights reserved.
|
26 |
+
*/!function(){"use strict";var i=!("undefined"==typeof window||!window.document||!window.document.createElement),a={canUseDOM:i,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:i&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:i&&!!window.screen};"object"===o(n(25))&&n(25)?void 0===(r=function(){return a}.call(t,n,t,e))||(e.exports=r):e.exports?e.exports=a:window.ExecutionEnvironment=a}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.dumpClassLists=function(){0};var r={},o={};t.add=function(e,t){return n=e.classList,i="html"==e.nodeName.toLowerCase()?r:o,void t.split(" ").forEach((function(e){!function(e,t){e[t]||(e[t]=0),e[t]+=1}(i,e),n.add(e)}));var n,i},t.remove=function(e,t){return n=e.classList,i="html"==e.nodeName.toLowerCase()?r:o,void t.split(" ").forEach((function(e){!function(e,t){e[t]&&(e[t]-=1)}(i,e),0===i[e]&&n.remove(e)}));var n,i}},function(e,t,n){"use strict";var r,o=n(26),i=(r=o)&&r.__esModule?r:{default:r};var a=void 0,u=void 0,s=[];function l(){0!==s.length&&s[s.length-1].focusContent()}i.default.subscribe((function(e,t){a&&u||((a=document.createElement("div")).setAttribute("data-react-modal-body-trap",""),a.style.position="absolute",a.style.opacity="0",a.setAttribute("tabindex","0"),a.addEventListener("focus",l),(u=a.cloneNode()).addEventListener("focus",l)),(s=t).length>0?(document.body.firstChild!==a&&document.body.insertBefore(a,document.body.firstChild),document.body.lastChild!==u&&document.body.appendChild(u)):(a.parentElement&&a.parentElement.removeChild(a),u.parentElement&&u.parentElement.removeChild(u))}))},function(e,t,n){"use strict";function r(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);null!=e&&this.setState(e)}function o(e){this.setState(function(t){var n=this.constructor.getDerivedStateFromProps(e,t);return null!=n?n:null}.bind(this))}function i(e,t){try{var n=this.props,r=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,r)}finally{this.props=n,this.state=r}}function a(e){var t=e.prototype;if(!t||!t.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof e.getDerivedStateFromProps&&"function"!=typeof t.getSnapshotBeforeUpdate)return e;var n=null,a=null,u=null;if("function"==typeof t.componentWillMount?n="componentWillMount":"function"==typeof t.UNSAFE_componentWillMount&&(n="UNSAFE_componentWillMount"),"function"==typeof t.componentWillReceiveProps?a="componentWillReceiveProps":"function"==typeof t.UNSAFE_componentWillReceiveProps&&(a="UNSAFE_componentWillReceiveProps"),"function"==typeof t.componentWillUpdate?u="componentWillUpdate":"function"==typeof t.UNSAFE_componentWillUpdate&&(u="UNSAFE_componentWillUpdate"),null!==n||null!==a||null!==u){var s=e.displayName||e.name,l="function"==typeof e.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+s+" uses "+l+" but also contains the following legacy lifecycles:"+(null!==n?"\n "+n:"")+(null!==a?"\n "+a:"")+(null!==u?"\n "+u:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof e.getDerivedStateFromProps&&(t.componentWillMount=r,t.componentWillReceiveProps=o),"function"==typeof t.getSnapshotBeforeUpdate){if("function"!=typeof t.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");t.componentWillUpdate=i;var c=t.componentDidUpdate;t.componentDidUpdate=function(e,t,n){var r=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n;c.call(this,e,t,r)}}return e}n.r(t),n.d(t,"polyfill",(function(){return a})),r.__suppressDeprecationWarning=!0,o.__suppressDeprecationWarning=!0,i.__suppressDeprecationWarning=!0}]]);
|
27 |
+
//# sourceMappingURL=vendor.js.map
|
classes/admin.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Meow_MFRH_Admin extends MeowCommon_Admin {
|
4 |
+
|
5 |
+
public function __construct() {
|
6 |
+
parent::__construct( MFRH_PREFIX, MFRH_ENTRY, MFRH_DOMAIN, class_exists( 'MeowPro_MFRH_Core' ) );
|
7 |
+
if ( is_admin() ) {
|
8 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
9 |
+
|
10 |
+
// Load the scripts only if they are needed by the current screen
|
11 |
+
$uri = $_SERVER['REQUEST_URI'];
|
12 |
+
$page = isset( $_GET["page"] ) ? $_GET["page"] : null;
|
13 |
+
$is_media_library = preg_match( '/wp\-admin\/upload\.php/', $uri );
|
14 |
+
$is_post_edit = preg_match( '/wp\-admin\/post\.php/', $uri );
|
15 |
+
$is_mfrh_screen = in_array( $page, [ 'mfrh_dashboard', 'mfrh_settings' ] );
|
16 |
+
$is_meowapps_dashboard = $page === 'meowapps-main-menu';
|
17 |
+
if ( $is_meowapps_dashboard || $is_media_library || $is_mfrh_screen || $is_post_edit ) {
|
18 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
22 |
+
|
23 |
+
function admin_enqueue_scripts() {
|
24 |
+
|
25 |
+
// Load the scripts
|
26 |
+
$physical_file = MFRH_PATH . '/app/index.js';
|
27 |
+
$cache_buster = file_exists( $physical_file ) ? filemtime( $physical_file ) : MFRH_VERSION;
|
28 |
+
wp_register_script( 'mfrh_media_file_renamer-vendor', MFRH_URL . 'app/vendor.js',
|
29 |
+
['wp-element', 'wp-i18n'], $cache_buster
|
30 |
+
);
|
31 |
+
wp_register_script( 'mfrh_media_file_renamer', MFRH_URL . 'app/index.js',
|
32 |
+
['mfrh_media_file_renamer-vendor', 'wp-i18n'], $cache_buster
|
33 |
+
);
|
34 |
+
wp_set_script_translations( 'mfrh_media_file_renamer', 'media-file-renamer' );
|
35 |
+
wp_enqueue_script('mfrh_media_file_renamer' );
|
36 |
+
|
37 |
+
// Load the fonts
|
38 |
+
wp_register_style( 'meow-neko-ui-lato-font',
|
39 |
+
'//fonts.googleapis.com/css2?family=Lato:wght@100;300;400;700;900&display=swap');
|
40 |
+
wp_enqueue_style( 'meow-neko-ui-lato-font' );
|
41 |
+
|
42 |
+
// Localize and options
|
43 |
+
wp_localize_script( 'mfrh_media_file_renamer', 'mfrh_media_file_renamer', array_merge( [
|
44 |
+
//'api_nonce' => wp_create_nonce( 'mfrh_media_file_renamer' ),
|
45 |
+
'api_url' => get_rest_url(null, '/media-file-renamer/v1/'),
|
46 |
+
'rest_url' => get_rest_url(),
|
47 |
+
'plugin_url' => MFRH_URL,
|
48 |
+
'prefix' => MFRH_PREFIX,
|
49 |
+
'domain' => MFRH_DOMAIN,
|
50 |
+
'is_pro' => class_exists( 'MeowPro_MFRH_Core' ),
|
51 |
+
'is_registered' => !!$this->is_registered(),
|
52 |
+
], $this->get_all_options() ) );
|
53 |
+
}
|
54 |
+
|
55 |
+
function admin_menu() {
|
56 |
+
add_submenu_page( 'meowapps-main-menu', __( 'Renamer', MFRH_DOMAIN ), __( 'Renamer', MFRH_DOMAIN ),
|
57 |
+
'manage_options', 'mfrh_settings', array( $this, 'admin_settings' )
|
58 |
+
);
|
59 |
+
}
|
60 |
+
|
61 |
+
public function admin_settings() {
|
62 |
+
echo '<div id="mfrh-admin-settings"></div>';
|
63 |
+
}
|
64 |
+
|
65 |
+
function get_all_options() {
|
66 |
+
return array(
|
67 |
+
'mfrh_auto_rename' => get_option( 'mfrh_auto_rename', false ),
|
68 |
+
'mfrh_on_upload' => get_option( 'mfrh_on_upload', false ),
|
69 |
+
'mfrh_rename_slug' => get_option( 'mfrh_rename_slug', false ),
|
70 |
+
'mfrh_convert_to_ascii' => $this->is_registered() && get_option( 'mfrh_convert_to_ascii', false ),
|
71 |
+
'mfrh_update_posts' => get_option( 'mfrh_update_posts', true ),
|
72 |
+
'mfrh_update_postmeta' => get_option( 'mfrh_update_postmeta', true ),
|
73 |
+
'mfrh_undo' => get_option( 'mfrh_undo', false ),
|
74 |
+
'mfrh_manual_rename' => get_option( 'mfrh_manual_rename', false ),
|
75 |
+
'mfrh_numbered_files' => $this->is_registered() && get_option( 'mfrh_numbered_files', false ),
|
76 |
+
'mfrh_sync_alt' => $this->is_registered() && get_option( 'mfrh_sync_alt', false ),
|
77 |
+
'mfrh_sync_media_title' => $this->is_registered() && get_option( 'mfrh_sync_media_title', false ),
|
78 |
+
'mfrh_force_rename' => $this->is_registered() && get_option( 'mfrh_force_rename', false ),
|
79 |
+
'mfrh_log' => get_option( 'mfrh_log', false ),
|
80 |
+
'mfrh_logsql' => $this->is_registered() && get_option( 'mfrh_logsql', false ),
|
81 |
+
'mfrh_rename_guid' => get_option( 'mfrh_rename_guid', false ),
|
82 |
+
'mfrh_case_sensitive_check' => get_option( 'mfrh_case_sensitive_check', true ),
|
83 |
+
'mfrh_rename_on_save' => get_option( 'mfrh_rename_on_save', false ),
|
84 |
+
);
|
85 |
+
}
|
86 |
+
}
|
87 |
+
|
88 |
+
?>
|
api.php → classes/api.php
RENAMED
@@ -8,7 +8,7 @@
|
|
8 |
|
9 |
// Rename the media automatically based on the settings
|
10 |
function mfrh_rename( $mediaId ) {
|
11 |
-
|
12 |
return $mfrh_core->rename( $mediaId );
|
13 |
}
|
14 |
|
8 |
|
9 |
// Rename the media automatically based on the settings
|
10 |
function mfrh_rename( $mediaId ) {
|
11 |
+
global $mfrh_core;
|
12 |
return $mfrh_core->rename( $mediaId );
|
13 |
}
|
14 |
|
core.php → classes/core.php
RENAMED
@@ -2,29 +2,56 @@
|
|
2 |
|
3 |
class Meow_MFRH_Core {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
public
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
|
|
|
|
10 |
}
|
11 |
|
12 |
function init() {
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
-
|
|
|
|
|
|
|
19 |
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
//
|
24 |
if ( is_admin() ) {
|
|
|
25 |
add_filter( 'attachment_fields_to_save', array( $this, 'attachment_fields_to_save' ), 20, 2 );
|
26 |
-
|
27 |
-
|
|
|
28 |
if ( get_option( 'mfrh_on_upload', false ) ) {
|
29 |
add_filter( 'wp_handle_upload_prefilter', array( $this, 'wp_handle_upload_prefilter' ), 10, 2 );
|
30 |
}
|
@@ -114,18 +141,6 @@ class Meow_MFRH_Core {
|
|
114 |
return $new_filename;
|
115 |
}
|
116 |
|
117 |
-
function get_post_from_media( $id ) {
|
118 |
-
global $wpdb;
|
119 |
-
$postid = $wpdb->get_var( $wpdb->prepare( "
|
120 |
-
SELECT post_parent p
|
121 |
-
FROM $wpdb->posts p
|
122 |
-
WHERE ID = %d", $id ),
|
123 |
-
0, 0 );
|
124 |
-
if ( empty( $postid ) )
|
125 |
-
return null;
|
126 |
-
return get_post( $postid, OBJECT );
|
127 |
-
}
|
128 |
-
|
129 |
/**
|
130 |
* Returns all the media sharing the same file
|
131 |
* @param string $file The attached file path
|
@@ -162,18 +177,17 @@ SQL;
|
|
162 |
|
163 |
function wp_handle_upload_prefilter( $file ) {
|
164 |
|
165 |
-
$this->log( "
|
166 |
$pp = mfrh_pathinfo( $file['name'] );
|
167 |
|
168 |
// If everything's fine, renames in based on the Title in the EXIF
|
169 |
-
|
170 |
-
switch ( $method ) {
|
171 |
case 'media_title':
|
172 |
$exif = wp_read_image_metadata( $file['tmp_name'] );
|
173 |
if ( !empty( $exif ) && isset( $exif[ 'title' ] ) && !empty( $exif[ 'title' ] ) ) {
|
174 |
-
$new_filename = $this->new_filename(
|
175 |
if ( !is_null( $new_filename ) ) {
|
176 |
-
$file['name'] =
|
177 |
$this->log( "New file should be: " . $file['name'] );
|
178 |
}
|
179 |
return $file;
|
@@ -184,9 +198,9 @@ SQL;
|
|
184 |
if ( !isset( $_POST['post_id'] ) || $_POST['post_id'] < 1 ) break;
|
185 |
$post = get_post( $_POST['post_id'] );
|
186 |
if ( !empty( $post ) && !empty( $post->post_title ) ) {
|
187 |
-
$new_filename = $this->new_filename(
|
188 |
if ( !is_null( $new_filename ) ) {
|
189 |
-
$file['name'] =
|
190 |
$this->log( "New file should be: " . $file['name'] );
|
191 |
}
|
192 |
return $file;
|
@@ -203,8 +217,10 @@ SQL;
|
|
203 |
|
204 |
// Modify the filename
|
205 |
$pp = mfrh_pathinfo( $file['name'] );
|
206 |
-
$new_filename = $this->new_filename(
|
207 |
-
if ( !is_null( $new_filename ) )
|
|
|
|
|
208 |
return $file;
|
209 |
}
|
210 |
|
@@ -251,8 +267,7 @@ SQL;
|
|
251 |
$output['manual'] = true;
|
252 |
}
|
253 |
else {
|
254 |
-
$method
|
255 |
-
if ( $method === 'none') {
|
256 |
delete_post_meta( $id, '_require_file_renaming' );
|
257 |
return false;
|
258 |
}
|
@@ -266,25 +281,11 @@ SQL;
|
|
266 |
return false;
|
267 |
}
|
268 |
|
269 |
-
|
270 |
-
$
|
271 |
-
|
272 |
-
|
273 |
-
case 'product_title':
|
274 |
-
$attachedpost = $this->get_post_from_media( $id );
|
275 |
-
if ( is_null( $attachedpost ) )
|
276 |
-
return false;
|
277 |
-
$base_title = $attachedpost->post_title;
|
278 |
-
break;
|
279 |
-
case 'alt_text':
|
280 |
-
$image_alt = get_post_meta( $id, '_wp_attachment_image_alt', true );
|
281 |
-
if ( is_null( $image_alt ) )
|
282 |
-
return false;
|
283 |
-
$base_title = $image_alt;
|
284 |
-
break;
|
285 |
}
|
286 |
-
$new_filename = $this->new_filename( $post, $base_title );
|
287 |
-
if ( is_null( $new_filename ) ) return false; // Leave it as it is
|
288 |
}
|
289 |
|
290 |
// If a filename has a counter, and the ideal is without the counter, let's ignore it
|
@@ -303,6 +304,7 @@ SQL;
|
|
303 |
}
|
304 |
|
305 |
// Check for case issue, numbering
|
|
|
306 |
$new_filepath = trailingslashit( $directory ) . $new_filename;
|
307 |
$existing_file = Meow_MFRH_Core::sensitive_file_exists( $new_filepath );
|
308 |
$case_issue = strtolower( $old_filename ) == strtolower( $new_filename );
|
@@ -325,12 +327,13 @@ SQL;
|
|
325 |
$output['post_title'] = $post['post_title'];
|
326 |
$output['current_filename'] = $old_filename;
|
327 |
$output['current_filepath'] = $old_filepath;
|
328 |
-
$output['
|
|
|
329 |
$output['desired_filepath'] = $new_filepath;
|
330 |
$output['case_issue'] = $case_issue;
|
331 |
$output['manual'] = !empty( $manual_filename );
|
332 |
$output['locked'] = get_post_meta( $id, '_manual_file_renaming', true );
|
333 |
-
$output['
|
334 |
$output['original_image'] = null;
|
335 |
|
336 |
// If the ideal filename already exists
|
@@ -340,12 +343,13 @@ SQL;
|
|
340 |
$meta = wp_get_attachment_metadata( $id );
|
341 |
if ( isset( $meta['original_image'] ) && $new_filename === $meta['original_image'] ) {
|
342 |
$output['original_image'] = $meta['original_image'];
|
343 |
-
$output['
|
344 |
}
|
345 |
}
|
346 |
|
347 |
-
// Set the '_require_file_renaming', even though it's not really used at this point
|
348 |
-
|
|
|
349 |
add_post_meta( $post['ID'], '_require_file_renaming', true, true );
|
350 |
}
|
351 |
return true;
|
@@ -377,13 +381,10 @@ SQL;
|
|
377 |
$status = get_post_status( $post_id );
|
378 |
if ( !in_array( $status, array( 'publish', 'draft', 'future', 'private' ) ) )
|
379 |
return;
|
380 |
-
$onsave = get_option( "mfrh_rename_on_save" );
|
381 |
-
if ( !$onsave )
|
382 |
-
return;
|
383 |
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' =>'any', 'post_parent' => $post_id );
|
384 |
$medias = get_posts( $args );
|
385 |
if ( $medias ) {
|
386 |
-
$this->log( '
|
387 |
foreach ( $medias as $attach ) {
|
388 |
// In the past, I used this to detect if the Media Library is NOT used:
|
389 |
// isset( $attachment['image-size'] );
|
@@ -399,17 +400,23 @@ SQL;
|
|
399 |
*/
|
400 |
|
401 |
function attachment_fields_to_save( $post, $attachment ) {
|
402 |
-
$this->log( '
|
403 |
$post = $this->rename( $post );
|
404 |
return $post;
|
405 |
}
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
function log_sql( $data, $antidata ) {
|
408 |
if ( !get_option( 'mfrh_logsql' ) || !$this->admin->is_registered() )
|
409 |
return;
|
410 |
-
$
|
411 |
-
$
|
412 |
-
$
|
413 |
fwrite( $fh, "{$data}\n" );
|
414 |
fwrite( $fh_anti, "{$antidata}\n" );
|
415 |
fclose( $fh );
|
@@ -422,7 +429,8 @@ SQL;
|
|
422 |
if ( !get_option( 'mfrh_log' ) ) {
|
423 |
return;
|
424 |
}
|
425 |
-
$
|
|
|
426 |
$date = date( "Y-m-d H:i:s" );
|
427 |
fwrite( $fh, "$date: {$data}\n" );
|
428 |
fclose( $fh );
|
@@ -586,6 +594,33 @@ SQL;
|
|
586 |
return $str;
|
587 |
}
|
588 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
589 |
/**
|
590 |
* Computes the ideal filename based on a text
|
591 |
* @param array $media
|
@@ -593,33 +628,26 @@ SQL;
|
|
593 |
* @param string $manual_filename
|
594 |
* @return string|NULL If the resulting filename had no any valid characters, NULL is returned
|
595 |
*/
|
596 |
-
function new_filename( $
|
597 |
|
598 |
-
|
599 |
-
$old_filename_no_ext = null;
|
600 |
-
$new_ext = null;
|
601 |
|
602 |
-
if ( !empty( $media ) ) {
|
603 |
-
|
604 |
-
$old_filepath = get_attached_file( $media['ID'] );
|
605 |
-
$pp = mfrh_pathinfo( $old_filepath );
|
606 |
-
$new_ext = empty( $pp['extension'] ) ? "" : $pp['extension'];
|
607 |
-
$old_filename = $pp['basename'];
|
608 |
-
$old_filename_no_ext = $pp['filename'];
|
609 |
-
}
|
610 |
-
else {
|
611 |
-
// It's an upload, let's check if the extension is provided in the text
|
612 |
-
$pp = mfrh_pathinfo( $text );
|
613 |
-
$new_ext = empty( $pp['extension'] ) ? "" : $pp['extension'];
|
614 |
-
$text = $pp['filename'];
|
615 |
}
|
616 |
|
|
|
|
|
|
|
|
|
|
|
617 |
// Generate the new filename.
|
|
|
618 |
if ( !empty( $manual_filename ) ) {
|
619 |
-
//
|
620 |
-
$
|
621 |
-
$manual_filename = $
|
622 |
-
$new_ext = empty( $
|
623 |
$new_filename = $manual_filename;
|
624 |
}
|
625 |
else {
|
@@ -633,6 +661,7 @@ SQL;
|
|
633 |
// Changed strolower to mb_strtolower...
|
634 |
$text = mb_strtolower( $text );
|
635 |
$text = sanitize_file_name( $text );
|
|
|
636 |
$new_filename = $this->format_hyphens( $text );
|
637 |
$new_filename = trim( $new_filename, '-.' );
|
638 |
}
|
@@ -650,7 +679,9 @@ SQL;
|
|
650 |
}
|
651 |
|
652 |
// If the resulting filename had no any valid character, return NULL
|
653 |
-
if ( empty( $new_filename ) )
|
|
|
|
|
654 |
|
655 |
if ( !$manual_filename )
|
656 |
$new_filename = apply_filters( 'mfrh_new_filename', $new_filename, $old_filename_no_ext, $media );
|
@@ -674,14 +705,27 @@ SQL;
|
|
674 |
* RENAME FILES + COFFEE TIME
|
675 |
*/
|
676 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
677 |
function call_hooks_rename_url( $post, $orig_image_url, $new_image_url ) {
|
678 |
// With the full URLs
|
679 |
do_action( 'mfrh_url_renamed', $post, $orig_image_url, $new_image_url );
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
|
|
685 |
}
|
686 |
|
687 |
function rename_file( $old, $new, $case_issue = false ) {
|
@@ -690,19 +734,19 @@ SQL;
|
|
690 |
wp_mkdir_p( dirname($new) );
|
691 |
|
692 |
// If there is a case issue, that means the system doesn't make the difference between AA.jpg and aa.jpg even though WordPress does.
|
693 |
-
// In that case it is important to rename the file to a temporary filename in between like: AA.jpg
|
694 |
if ( $case_issue ) {
|
695 |
if ( !rename( $old, $old . md5( $old ) ) ) {
|
696 |
-
$this->log( "The file couldn't be renamed (case issue) from $old to " . $old . md5( $old ) . "." );
|
697 |
return false;
|
698 |
}
|
699 |
if ( !rename( $old . md5( $old ), $new ) ) {
|
700 |
-
$this->log( "The file couldn't be renamed (case issue) from " . $old . md5( $old ) . " to $new." );
|
701 |
return false;
|
702 |
}
|
703 |
}
|
704 |
else if ( ( !rename( $old, $new ) ) ) {
|
705 |
-
$this->log( "The file couldn't be renamed from $old to $new." );
|
706 |
return false;
|
707 |
}
|
708 |
return true;
|
@@ -735,7 +779,7 @@ SQL;
|
|
735 |
$filename = $path_parts['basename']; // 'whatever.jpeg'
|
736 |
$new_filepath = trailingslashit( trailingslashit( $upload_dir['basedir'] ) . $new_directory ) . $filename;
|
737 |
|
738 |
-
$this->log( "
|
739 |
$this->log( "The new directory will be: " . mfrh_dirname( $new_filepath ) );
|
740 |
|
741 |
// Create the directory if it does not exist
|
@@ -747,11 +791,11 @@ SQL;
|
|
747 |
|
748 |
// Move the main media file
|
749 |
if ( !$this->rename_file( $old_filepath, $new_filepath ) ) {
|
750 |
-
$this->log( "
|
751 |
return false;
|
752 |
}
|
753 |
update_attached_file( $id, $new_filepath );
|
754 |
-
$this->log( "File
|
755 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
756 |
|
757 |
// Update the attachment meta
|
@@ -794,22 +838,22 @@ SQL;
|
|
794 |
|
795 |
// Rename retina file
|
796 |
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath ) ) {
|
797 |
-
$this->log( "
|
798 |
return $post;
|
799 |
}
|
800 |
-
$this->log( "Retina
|
801 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
802 |
}
|
803 |
}
|
804 |
|
805 |
// Rename meta file
|
806 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath ) ) {
|
807 |
-
$this->log( "
|
808 |
return false;
|
809 |
}
|
810 |
|
811 |
// Success, call other plugins
|
812 |
-
$this->log( "File
|
813 |
do_action( 'mfrh_path_renamed', $post, $meta_old_filepath, $meta_new_filepath );
|
814 |
|
815 |
}
|
@@ -850,6 +894,18 @@ SQL;
|
|
850 |
do_action( 'mfrh_media_renamed', $post, $old_filepath, $new_filepath );
|
851 |
return true;
|
852 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
853 |
|
854 |
function rename( $media, $manual_filename = null, $fromMediaLibrary = true ) {
|
855 |
$id = null;
|
@@ -875,7 +931,6 @@ SQL;
|
|
875 |
}
|
876 |
|
877 |
$force_rename = apply_filters( 'mfrh_force_rename', false );
|
878 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
879 |
|
880 |
// Check attachment
|
881 |
$need_rename = $this->check_attachment( $post, $output, $manual_filename );
|
@@ -888,7 +943,7 @@ SQL;
|
|
888 |
$old_filepath = $output['current_filepath'];
|
889 |
$case_issue = $output['case_issue'];
|
890 |
$new_filepath = $output['desired_filepath'];
|
891 |
-
$new_filename = $output['
|
892 |
$manual = $output['manual'] || !empty( $manual_filename );
|
893 |
$path_parts = mfrh_pathinfo( $old_filepath );
|
894 |
$directory = $path_parts['dirname']; // Directory where the files are, under 'uploads', such as '2011/01'
|
@@ -904,8 +959,8 @@ SQL;
|
|
904 |
$noext_new_filename = $this->str_replace( '.' . $old_ext, '', $new_filename ); // New filename without extension
|
905 |
|
906 |
|
907 |
-
$this->log( "
|
908 |
-
$this->log( "New file
|
909 |
|
910 |
// Check for issues with the files
|
911 |
if ( !file_exists( $old_filepath ) ) {
|
@@ -918,8 +973,8 @@ SQL;
|
|
918 |
|
919 |
// Get the information about the original image
|
920 |
// (which means the current file is a rescaled version of it)
|
921 |
-
$
|
922 |
-
$original_is_ideal = $
|
923 |
|
924 |
if ( !$original_is_ideal && !$case_issue && !$force_rename && file_exists( $new_filepath ) ) {
|
925 |
$this->log( "The new file already exists ($new_filepath). It is not a case issue. Renaming cancelled." );
|
@@ -935,45 +990,37 @@ SQL;
|
|
935 |
// We should rename the -rescaled image first, as it could cause an issue
|
936 |
// if renamed after the main file. In fact, the original file might have already
|
937 |
// the best filename and evidently, the "-rescaled" one not.
|
938 |
-
if ( $
|
939 |
$meta_old_filename = $meta['original_image'];
|
940 |
$meta_old_filepath = trailingslashit( $directory ) . $meta_old_filename;
|
941 |
// In case of the undo, since we do not have the actual real original filename for that un-scaled image,
|
942 |
// we make sure the -scaled part of the original filename is not used (that could bring some confusion otherwise).
|
943 |
-
$meta_new_filename =
|
944 |
$meta_new_filepath = trailingslashit( $directory ) . $meta_new_filename;
|
945 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
946 |
-
$this->log( "
|
947 |
return $post;
|
948 |
}
|
949 |
// Manual Rename also uses the new extension (if it was not stripped to avoid user mistake)
|
950 |
if ( $force_rename && !empty( $new_ext ) ) {
|
951 |
$meta_new_filename = $this->str_replace( $old_ext, $new_ext, $meta_new_filename );
|
952 |
}
|
953 |
-
$this->log( "
|
954 |
-
|
955 |
$meta['original_image'] = $meta_new_filename;
|
956 |
}
|
957 |
|
958 |
// Rename the main media file.
|
959 |
if ( !$this->rename_file( $old_filepath, $new_filepath, $case_issue ) && !$force_rename ) {
|
960 |
-
$this->log( "
|
961 |
return $post;
|
962 |
}
|
963 |
-
|
964 |
-
$this->log( "File\t$old_filepath -> $new_filepath" );
|
965 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
966 |
|
967 |
// Rename the main media file in WebP if it exists.
|
968 |
-
$this->rename_webp_file_if_exist(
|
969 |
-
$
|
970 |
-
$old_ext,
|
971 |
-
$new_filepath,
|
972 |
-
$new_ext,
|
973 |
-
$case_issue,
|
974 |
-
$force_rename,
|
975 |
-
$post
|
976 |
-
);
|
977 |
|
978 |
if ( $meta ) {
|
979 |
if ( isset( $meta['file'] ) && !empty( $meta['file'] ) )
|
@@ -982,7 +1029,6 @@ SQL;
|
|
982 |
$meta['url'] = $this->str_replace( $noext_old_filename, $noext_new_filename, $meta['url'] );
|
983 |
else
|
984 |
$meta['url'] = $noext_new_filename . '.' . $old_ext;
|
985 |
-
wp_update_attachment_metadata( $id, $meta );
|
986 |
}
|
987 |
|
988 |
// Better to check like this rather than with wp_attachment_is_image
|
@@ -991,6 +1037,16 @@ SQL;
|
|
991 |
|
992 |
// Loop through the different sizes in the case of an image, and rename them.
|
993 |
if ( $has_thumbnails ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
994 |
$orig_image_urls = array();
|
995 |
$orig_image_data = wp_get_attachment_image_src( $id, 'full' );
|
996 |
$orig_image_urls['full'] = $orig_image_data[0];
|
@@ -1022,27 +1078,20 @@ SQL;
|
|
1022 |
|
1023 |
// Rename retina file
|
1024 |
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath, $case_issue ) && !$force_rename ) {
|
1025 |
-
$this->log( "
|
1026 |
return $post;
|
1027 |
}
|
1028 |
-
$this->log( "Retina
|
1029 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
1030 |
}
|
1031 |
}
|
1032 |
// If webp file existed, that one as well.
|
1033 |
-
$this->rename_webp_file_if_exist(
|
1034 |
-
$
|
1035 |
-
$old_ext,
|
1036 |
-
$meta_new_filepath,
|
1037 |
-
$new_ext,
|
1038 |
-
$case_issue,
|
1039 |
-
$force_rename,
|
1040 |
-
$post
|
1041 |
-
);
|
1042 |
|
1043 |
// Rename meta file
|
1044 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
1045 |
-
$this->log( "
|
1046 |
return $post;
|
1047 |
}
|
1048 |
|
@@ -1052,14 +1101,13 @@ SQL;
|
|
1052 |
if ( !isset( $meta['sizes'][$s]['file'] ) )
|
1053 |
continue;
|
1054 |
if ( $meta['sizes'][$s]['file'] == $meta_old_filename ) {
|
1055 |
-
$this->log( "Updated $s based on $size, as they use the same file (probably same size)." );
|
1056 |
$meta['sizes'][$s]['file'] = $meta_new_filename;
|
1057 |
}
|
1058 |
}
|
1059 |
-
wp_update_attachment_metadata( $id, $meta );
|
1060 |
|
1061 |
// Success, call other plugins
|
1062 |
-
$this->log( "File
|
1063 |
do_action( 'mfrh_path_renamed', $post, $meta_old_filepath, $meta_new_filepath );
|
1064 |
|
1065 |
}
|
@@ -1077,9 +1125,9 @@ SQL;
|
|
1077 |
add_post_meta( $id, '_manual_file_renaming', true, true );
|
1078 |
|
1079 |
// Update metadata
|
1080 |
-
|
1081 |
-
|
1082 |
-
|
1083 |
|
1084 |
// I wonder about cleaning the cache for this media. It might have no impact, and will not reset the cache for the posts using this media anyway, and it adds processing time. I keep it for now, but there might be something better to do.
|
1085 |
clean_post_cache( $id );
|
@@ -1091,7 +1139,7 @@ SQL;
|
|
1091 |
$newslug = preg_replace( '/\\.[^.\\s]{3,4}$/', '', $info['basename'] );
|
1092 |
$post['post_name'] = $newslug;
|
1093 |
if ( wp_update_post( $post ) )
|
1094 |
-
$this->log( "Slug
|
1095 |
}
|
1096 |
|
1097 |
// Call the actions so that the plugin's plugins can update everything else (than the files)
|
@@ -1127,25 +1175,17 @@ SQL;
|
|
1127 |
/**
|
1128 |
* Rename webp file only if existed.
|
1129 |
*/
|
1130 |
-
function rename_webp_file_if_exist(
|
1131 |
-
$
|
1132 |
-
$old_ext,
|
1133 |
-
$new_finepath,
|
1134 |
-
$new_ext,
|
1135 |
-
$case_issue,
|
1136 |
-
$force_rename,
|
1137 |
-
$post
|
1138 |
-
) {
|
1139 |
-
|
1140 |
-
// TODO: Without this check, the code following actually doesn't work with PDF Thumbnails (because the old_ext and new_ext doesn't correspond to jpg, which is used for the thumbnails in the PDF case, and not .pdf). In fact, the code after that should be rewritten.
|
1141 |
-
if ( !preg_match( '/\.webp$/', $old_filepath ) ) {
|
1142 |
-
return;
|
1143 |
-
}
|
1144 |
|
1145 |
-
//
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
|
|
|
|
|
|
|
|
1149 |
[
|
1150 |
'old' => $this->str_replace( '.' . $old_ext, '.webp', $old_filepath ),
|
1151 |
'new' => $this->str_replace( '.' . $new_ext, '.webp', $new_finepath ),
|
@@ -1155,17 +1195,25 @@ SQL;
|
|
1155 |
'new' => $this->str_replace( '.' . $new_ext, '.' . $new_ext . '.webp', $new_finepath ),
|
1156 |
],
|
1157 |
];
|
1158 |
-
foreach ($webp_files as $webp_file) {
|
1159 |
-
if ( file_exists( $webp_file['old'] )
|
1160 |
-
&& ( ( !file_exists( $webp_file['new'] ) ) || is_writable( $webp_file['new'] ) ) ) {
|
1161 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1162 |
// Rename webp file
|
1163 |
-
if ( !$this->rename_file( $
|
1164 |
-
$this->log( "
|
1165 |
return $post;
|
1166 |
}
|
1167 |
-
$this->log( "
|
1168 |
-
do_action( 'mfrh_path_renamed', $post, $
|
1169 |
}
|
1170 |
}
|
1171 |
}
|
@@ -1176,7 +1224,11 @@ SQL;
|
|
1176 |
* @return True on success, false on failure
|
1177 |
*/
|
1178 |
function lock( $post ) {
|
1179 |
-
|
|
|
|
|
|
|
|
|
1180 |
}
|
1181 |
|
1182 |
/**
|
@@ -1185,7 +1237,8 @@ SQL;
|
|
1185 |
* @return True on success, false on failure
|
1186 |
*/
|
1187 |
function unlock( $post ) {
|
1188 |
-
|
|
|
1189 |
}
|
1190 |
|
1191 |
/**
|
2 |
|
3 |
class Meow_MFRH_Core {
|
4 |
|
5 |
+
public $admin = null;
|
6 |
+
public $pro = false;
|
7 |
+
public $is_rest = false;
|
8 |
+
public $is_cli = false;
|
9 |
+
public $method = 'media_title';
|
10 |
+
public $upload_folder = null;
|
11 |
+
public $site_url = null;
|
12 |
+
public $contentDir = null; // becomes 'wp-content/uploads'
|
13 |
+
|
14 |
+
public function __construct() {
|
15 |
+
$this->site_url = get_site_url();
|
16 |
+
$this->upload_folder = wp_upload_dir();
|
17 |
+
$this->contentDir = substr( $this->upload_folder['baseurl'], 1 + strlen( $this->site_url ) );
|
18 |
add_action( 'plugins_loaded', array( $this, 'init' ) );
|
19 |
+
$this->is_rest = MeowCommon_Helpers::is_rest();
|
20 |
+
$this->is_cli = defined( 'WP_CLI' ) && WP_CLI;
|
21 |
}
|
22 |
|
23 |
function init() {
|
24 |
+
load_plugin_textdomain( MFRH_DOMAIN, false, basename( MFRH_PATH ) . '/languages' );
|
25 |
+
|
26 |
+
// Part of the core, settings and stuff
|
27 |
+
$this->admin = new Meow_MFRH_Admin();
|
28 |
+
if ( class_exists( 'MeowPro_MFRH_Core' ) ) {
|
29 |
+
new MeowPro_MFRH_Core( $this, $this->admin );
|
30 |
+
$this->pro = true;
|
31 |
+
}
|
32 |
+
|
33 |
+
// Initialize
|
34 |
+
$this->method = apply_filters( 'mfrh_method', get_option( 'mfrh_method', 'none' ) );
|
35 |
|
36 |
+
// Only for REST
|
37 |
+
if ( $this->is_rest ) {
|
38 |
+
new Meow_MFRH_Rest( $this );
|
39 |
+
}
|
40 |
|
41 |
+
// Side-updates should be ran for CLI and REST
|
42 |
+
if ( is_admin() || $this->is_rest || $this->is_cli ) {
|
43 |
+
new Meow_MFRH_Updates( $this );
|
44 |
+
// if ( $this->method === 'product_title' && class_exists( 'WooCommerce' ) )
|
45 |
+
// require_once( 'plugins/woocommerce.php' );
|
46 |
+
}
|
47 |
|
48 |
+
// Admin screens
|
49 |
if ( is_admin() ) {
|
50 |
+
new Meow_MFRH_UI( $this );
|
51 |
add_filter( 'attachment_fields_to_save', array( $this, 'attachment_fields_to_save' ), 20, 2 );
|
52 |
+
if ( get_option( 'mfrh_rename_on_save', false ) ) {
|
53 |
+
add_action( 'save_post', array( $this, 'save_post' ) );
|
54 |
+
}
|
55 |
if ( get_option( 'mfrh_on_upload', false ) ) {
|
56 |
add_filter( 'wp_handle_upload_prefilter', array( $this, 'wp_handle_upload_prefilter' ), 10, 2 );
|
57 |
}
|
141 |
return $new_filename;
|
142 |
}
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
/**
|
145 |
* Returns all the media sharing the same file
|
146 |
* @param string $file The attached file path
|
177 |
|
178 |
function wp_handle_upload_prefilter( $file ) {
|
179 |
|
180 |
+
$this->log( "⏰ Event: New Upload (" . $file['name'] . ")" );
|
181 |
$pp = mfrh_pathinfo( $file['name'] );
|
182 |
|
183 |
// If everything's fine, renames in based on the Title in the EXIF
|
184 |
+
switch ( $this->method ) {
|
|
|
185 |
case 'media_title':
|
186 |
$exif = wp_read_image_metadata( $file['tmp_name'] );
|
187 |
if ( !empty( $exif ) && isset( $exif[ 'title' ] ) && !empty( $exif[ 'title' ] ) ) {
|
188 |
+
$new_filename = $this->new_filename( $exif[ 'title' ], $file['name'] );
|
189 |
if ( !is_null( $new_filename ) ) {
|
190 |
+
$file['name'] = $new_filename;
|
191 |
$this->log( "New file should be: " . $file['name'] );
|
192 |
}
|
193 |
return $file;
|
198 |
if ( !isset( $_POST['post_id'] ) || $_POST['post_id'] < 1 ) break;
|
199 |
$post = get_post( $_POST['post_id'] );
|
200 |
if ( !empty( $post ) && !empty( $post->post_title ) ) {
|
201 |
+
$new_filename = $this->new_filename( $post->post_title, $file['name'] );
|
202 |
if ( !is_null( $new_filename ) ) {
|
203 |
+
$file['name'] = $new_filename;
|
204 |
$this->log( "New file should be: " . $file['name'] );
|
205 |
}
|
206 |
return $file;
|
217 |
|
218 |
// Modify the filename
|
219 |
$pp = mfrh_pathinfo( $file['name'] );
|
220 |
+
$new_filename = $this->new_filename( $pp['filename'], $file['name'] );
|
221 |
+
if ( !is_null( $new_filename ) ) {
|
222 |
+
$file['name'] = $new_filename;
|
223 |
+
}
|
224 |
return $file;
|
225 |
}
|
226 |
|
267 |
$output['manual'] = true;
|
268 |
}
|
269 |
else {
|
270 |
+
if ( $this->method === 'none') {
|
|
|
271 |
delete_post_meta( $id, '_require_file_renaming' );
|
272 |
return false;
|
273 |
}
|
281 |
return false;
|
282 |
}
|
283 |
|
284 |
+
$base_for_rename = apply_filters( 'mfrh_base_for_rename', $post['post_title'], $id );
|
285 |
+
$new_filename = $this->new_filename( $base_for_rename, $old_filename, null, $post );
|
286 |
+
if ( is_null( $new_filename ) ) {
|
287 |
+
return false; // Leave it as it is
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
}
|
|
|
|
|
289 |
}
|
290 |
|
291 |
// If a filename has a counter, and the ideal is without the counter, let's ignore it
|
304 |
}
|
305 |
|
306 |
// Check for case issue, numbering
|
307 |
+
$ideal_filename = $new_filename;
|
308 |
$new_filepath = trailingslashit( $directory ) . $new_filename;
|
309 |
$existing_file = Meow_MFRH_Core::sensitive_file_exists( $new_filepath );
|
310 |
$case_issue = strtolower( $old_filename ) == strtolower( $new_filename );
|
327 |
$output['post_title'] = $post['post_title'];
|
328 |
$output['current_filename'] = $old_filename;
|
329 |
$output['current_filepath'] = $old_filepath;
|
330 |
+
$output['ideal_filename'] = $ideal_filename;
|
331 |
+
$output['proposed_filename'] = $new_filename;
|
332 |
$output['desired_filepath'] = $new_filepath;
|
333 |
$output['case_issue'] = $case_issue;
|
334 |
$output['manual'] = !empty( $manual_filename );
|
335 |
$output['locked'] = get_post_meta( $id, '_manual_file_renaming', true );
|
336 |
+
$output['proposed_filename_exists'] = !!$existing_file;
|
337 |
$output['original_image'] = null;
|
338 |
|
339 |
// If the ideal filename already exists
|
343 |
$meta = wp_get_attachment_metadata( $id );
|
344 |
if ( isset( $meta['original_image'] ) && $new_filename === $meta['original_image'] ) {
|
345 |
$output['original_image'] = $meta['original_image'];
|
346 |
+
$output['proposed_filename_exists'] = false;
|
347 |
}
|
348 |
}
|
349 |
|
350 |
+
// Set the '_require_file_renaming', even though it's not really used at this point (but will be,
|
351 |
+
// with the new UI).
|
352 |
+
if ( !get_post_meta( $post['ID'], '_require_file_renaming', true ) && !$output['locked']) {
|
353 |
add_post_meta( $post['ID'], '_require_file_renaming', true, true );
|
354 |
}
|
355 |
return true;
|
381 |
$status = get_post_status( $post_id );
|
382 |
if ( !in_array( $status, array( 'publish', 'draft', 'future', 'private' ) ) )
|
383 |
return;
|
|
|
|
|
|
|
384 |
$args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' =>'any', 'post_parent' => $post_id );
|
385 |
$medias = get_posts( $args );
|
386 |
if ( $medias ) {
|
387 |
+
$this->log( '⏰ Event: Save Post' );
|
388 |
foreach ( $medias as $attach ) {
|
389 |
// In the past, I used this to detect if the Media Library is NOT used:
|
390 |
// isset( $attachment['image-size'] );
|
400 |
*/
|
401 |
|
402 |
function attachment_fields_to_save( $post, $attachment ) {
|
403 |
+
$this->log( '⏰ Event: Save Attachment' );
|
404 |
$post = $this->rename( $post );
|
405 |
return $post;
|
406 |
}
|
407 |
|
408 |
+
function logs_directory_check() {
|
409 |
+
if ( !file_exists( MFRH_PATH . '/logs/' ) ) {
|
410 |
+
mkdir( MFRH_PATH . '/logs/', 0777 );
|
411 |
+
}
|
412 |
+
}
|
413 |
+
|
414 |
function log_sql( $data, $antidata ) {
|
415 |
if ( !get_option( 'mfrh_logsql' ) || !$this->admin->is_registered() )
|
416 |
return;
|
417 |
+
$this->logs_directory_check();
|
418 |
+
$fh = fopen( MFRH_PATH . '/logs/mfrh_sql.log', 'a' );
|
419 |
+
$fh_anti = fopen( MFRH_PATH . '/logs/mfrh_sql_revert.log', 'a' );
|
420 |
fwrite( $fh, "{$data}\n" );
|
421 |
fwrite( $fh_anti, "{$antidata}\n" );
|
422 |
fclose( $fh );
|
429 |
if ( !get_option( 'mfrh_log' ) ) {
|
430 |
return;
|
431 |
}
|
432 |
+
$this->logs_directory_check();
|
433 |
+
$fh = fopen( MFRH_PATH . '/logs/media-file-renamer.log', 'a' );
|
434 |
$date = date( "Y-m-d H:i:s" );
|
435 |
fwrite( $fh, "$date: {$data}\n" );
|
436 |
fclose( $fh );
|
594 |
return $str;
|
595 |
}
|
596 |
|
597 |
+
/// https://stackoverflow.com/questions/12807176/php-writing-a-simple-removeemoji-function
|
598 |
+
public function remove_emoji( $text ) {
|
599 |
+
$clean_text = "";
|
600 |
+
|
601 |
+
// Match Emoticons
|
602 |
+
$regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u';
|
603 |
+
$clean_text = preg_replace($regexEmoticons, '', $text);
|
604 |
+
|
605 |
+
// Match Miscellaneous Symbols and Pictographs
|
606 |
+
$regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u';
|
607 |
+
$clean_text = preg_replace($regexSymbols, '', $clean_text);
|
608 |
+
|
609 |
+
// Match Transport And Map Symbols
|
610 |
+
$regexTransport = '/[\x{1F680}-\x{1F6FF}]/u';
|
611 |
+
$clean_text = preg_replace($regexTransport, '', $clean_text);
|
612 |
+
|
613 |
+
// Match Miscellaneous Symbols
|
614 |
+
$regexMisc = '/[\x{2600}-\x{26FF}]/u';
|
615 |
+
$clean_text = preg_replace($regexMisc, '', $clean_text);
|
616 |
+
|
617 |
+
// Match Dingbats
|
618 |
+
$regexDingbats = '/[\x{2700}-\x{27BF}]/u';
|
619 |
+
$clean_text = preg_replace($regexDingbats, '', $clean_text);
|
620 |
+
|
621 |
+
return $clean_text;
|
622 |
+
}
|
623 |
+
|
624 |
/**
|
625 |
* Computes the ideal filename based on a text
|
626 |
* @param array $media
|
628 |
* @param string $manual_filename
|
629 |
* @return string|NULL If the resulting filename had no any valid characters, NULL is returned
|
630 |
*/
|
631 |
+
function new_filename( $text, $current_filename, $manual_filename = null, $media = null ) {
|
632 |
|
633 |
+
// Gather the base values.
|
|
|
|
|
634 |
|
635 |
+
if ( empty( $current_filename ) && !empty( $media ) ) {
|
636 |
+
$current_filename = get_attached_file( $media['ID'] );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
637 |
}
|
638 |
|
639 |
+
$pp = mfrh_pathinfo( $current_filename );
|
640 |
+
$new_ext = empty( $pp['extension'] ) ? '' : $pp['extension'];
|
641 |
+
$old_filename_no_ext = $pp['filename'];
|
642 |
+
$text = empty( $text ) ? $old_filename_no_ext : $text;
|
643 |
+
|
644 |
// Generate the new filename.
|
645 |
+
|
646 |
if ( !empty( $manual_filename ) ) {
|
647 |
+
// Forced filename (manual or undo, basically). Keep this extension in $new_ext.
|
648 |
+
$manual_pp = mfrh_pathinfo( $manual_filename );
|
649 |
+
$manual_filename = $manual_pp['filename'];
|
650 |
+
$new_ext = empty( $manual_pp['extension'] ) ? $new_ext : $manual_pp['extension'];
|
651 |
$new_filename = $manual_filename;
|
652 |
}
|
653 |
else {
|
661 |
// Changed strolower to mb_strtolower...
|
662 |
$text = mb_strtolower( $text );
|
663 |
$text = sanitize_file_name( $text );
|
664 |
+
$text = $this->remove_emoji( $text );
|
665 |
$new_filename = $this->format_hyphens( $text );
|
666 |
$new_filename = trim( $new_filename, '-.' );
|
667 |
}
|
679 |
}
|
680 |
|
681 |
// If the resulting filename had no any valid character, return NULL
|
682 |
+
if ( empty( $new_filename ) ) {
|
683 |
+
return null;
|
684 |
+
}
|
685 |
|
686 |
if ( !$manual_filename )
|
687 |
$new_filename = apply_filters( 'mfrh_new_filename', $new_filename, $old_filename_no_ext, $media );
|
705 |
* RENAME FILES + COFFEE TIME
|
706 |
*/
|
707 |
|
708 |
+
// From a url to the shortened and cleaned url (for example '2025/02/file.png')
|
709 |
+
function clean_url( $url ) {
|
710 |
+
$dirIndex = strpos( $url, $this->contentDir );
|
711 |
+
if ( empty( $url ) || $dirIndex === false ) {
|
712 |
+
$finalUrl = null;
|
713 |
+
}
|
714 |
+
else {
|
715 |
+
$finalUrl = urldecode( substr( $url, 1 + strlen( $this->contentDir ) + $dirIndex ) );
|
716 |
+
}
|
717 |
+
return $finalUrl;
|
718 |
+
}
|
719 |
+
|
720 |
function call_hooks_rename_url( $post, $orig_image_url, $new_image_url ) {
|
721 |
// With the full URLs
|
722 |
do_action( 'mfrh_url_renamed', $post, $orig_image_url, $new_image_url );
|
723 |
+
// With clean URLs relative to /uploads
|
724 |
+
do_action( 'mfrh_url_renamed', $post, $this->clean_url( $orig_image_url ), $this->clean_url( $new_image_url ) );
|
725 |
+
// With DB URLs (honestly, not sure about this...)
|
726 |
+
// $upload_dir = wp_upload_dir();
|
727 |
+
// do_action( 'mfrh_url_renamed', $post, str_replace( $upload_dir, "", $orig_image_url ),
|
728 |
+
// str_replace( $upload_dir, "", $new_image_url ) );
|
729 |
}
|
730 |
|
731 |
function rename_file( $old, $new, $case_issue = false ) {
|
734 |
wp_mkdir_p( dirname($new) );
|
735 |
|
736 |
// If there is a case issue, that means the system doesn't make the difference between AA.jpg and aa.jpg even though WordPress does.
|
737 |
+
// In that case it is important to rename the file to a temporary filename in between like: AA.jpg ➡️ TMP.jpg ➡️ aa.jpg.
|
738 |
if ( $case_issue ) {
|
739 |
if ( !rename( $old, $old . md5( $old ) ) ) {
|
740 |
+
$this->log( "🚫 The file couldn't be renamed (case issue) from $old to " . $old . md5( $old ) . "." );
|
741 |
return false;
|
742 |
}
|
743 |
if ( !rename( $old . md5( $old ), $new ) ) {
|
744 |
+
$this->log( "🚫 The file couldn't be renamed (case issue) from " . $old . md5( $old ) . " to $new." );
|
745 |
return false;
|
746 |
}
|
747 |
}
|
748 |
else if ( ( !rename( $old, $new ) ) ) {
|
749 |
+
$this->log( "🚫 The file couldn't be renamed from $old to $new." );
|
750 |
return false;
|
751 |
}
|
752 |
return true;
|
779 |
$filename = $path_parts['basename']; // 'whatever.jpeg'
|
780 |
$new_filepath = trailingslashit( trailingslashit( $upload_dir['basedir'] ) . $new_directory ) . $filename;
|
781 |
|
782 |
+
$this->log( "🏁 Move Media: " . $filename );
|
783 |
$this->log( "The new directory will be: " . mfrh_dirname( $new_filepath ) );
|
784 |
|
785 |
// Create the directory if it does not exist
|
791 |
|
792 |
// Move the main media file
|
793 |
if ( !$this->rename_file( $old_filepath, $new_filepath ) ) {
|
794 |
+
$this->log( "🚫 File $old_filepath ➡️ $new_filepath" );
|
795 |
return false;
|
796 |
}
|
797 |
update_attached_file( $id, $new_filepath );
|
798 |
+
$this->log( "✅ File $old_filepath ➡️ $new_filepath" );
|
799 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
800 |
|
801 |
// Update the attachment meta
|
838 |
|
839 |
// Rename retina file
|
840 |
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath ) ) {
|
841 |
+
$this->log( "🚫 Retina $wr2x_old_filepath ➡️ $wr2x_new_filepath" );
|
842 |
return $post;
|
843 |
}
|
844 |
+
$this->log( "✅ Retina $wr2x_old_filepath ➡️ $wr2x_new_filepath" );
|
845 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
846 |
}
|
847 |
}
|
848 |
|
849 |
// Rename meta file
|
850 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath ) ) {
|
851 |
+
$this->log( "🚫 File $meta_old_filepath ➡️ $meta_new_filepath" );
|
852 |
return false;
|
853 |
}
|
854 |
|
855 |
// Success, call other plugins
|
856 |
+
$this->log( "✅ File $meta_old_filepath ➡️ $meta_new_filepath" );
|
857 |
do_action( 'mfrh_path_renamed', $post, $meta_old_filepath, $meta_new_filepath );
|
858 |
|
859 |
}
|
894 |
do_action( 'mfrh_media_renamed', $post, $old_filepath, $new_filepath );
|
895 |
return true;
|
896 |
}
|
897 |
+
|
898 |
+
function undo( $mediaId ) {
|
899 |
+
$original_filename = get_post_meta( $mediaId, '_original_filename', true );
|
900 |
+
if ( empty( $original_filename ) ) {
|
901 |
+
return true;
|
902 |
+
}
|
903 |
+
$res = $this->rename( $mediaId, $original_filename );
|
904 |
+
if (!!$res) {
|
905 |
+
delete_post_meta( $mediaId, '_original_filename' );
|
906 |
+
}
|
907 |
+
return $res;
|
908 |
+
}
|
909 |
|
910 |
function rename( $media, $manual_filename = null, $fromMediaLibrary = true ) {
|
911 |
$id = null;
|
931 |
}
|
932 |
|
933 |
$force_rename = apply_filters( 'mfrh_force_rename', false );
|
|
|
934 |
|
935 |
// Check attachment
|
936 |
$need_rename = $this->check_attachment( $post, $output, $manual_filename );
|
943 |
$old_filepath = $output['current_filepath'];
|
944 |
$case_issue = $output['case_issue'];
|
945 |
$new_filepath = $output['desired_filepath'];
|
946 |
+
$new_filename = $output['proposed_filename'];
|
947 |
$manual = $output['manual'] || !empty( $manual_filename );
|
948 |
$path_parts = mfrh_pathinfo( $old_filepath );
|
949 |
$directory = $path_parts['dirname']; // Directory where the files are, under 'uploads', such as '2011/01'
|
959 |
$noext_new_filename = $this->str_replace( '.' . $old_ext, '', $new_filename ); // New filename without extension
|
960 |
|
961 |
|
962 |
+
$this->log( "🏁 Rename Media: " . $old_filename );
|
963 |
+
$this->log( "New file will be: " . $new_filename );
|
964 |
|
965 |
// Check for issues with the files
|
966 |
if ( !file_exists( $old_filepath ) ) {
|
973 |
|
974 |
// Get the information about the original image
|
975 |
// (which means the current file is a rescaled version of it)
|
976 |
+
$is_scaled_image = isset( $meta['original_image'] ) && !empty( $meta['original_image'] );
|
977 |
+
$original_is_ideal = $is_scaled_image ? $new_filename === $meta['original_image'] : false;
|
978 |
|
979 |
if ( !$original_is_ideal && !$case_issue && !$force_rename && file_exists( $new_filepath ) ) {
|
980 |
$this->log( "The new file already exists ($new_filepath). It is not a case issue. Renaming cancelled." );
|
990 |
// We should rename the -rescaled image first, as it could cause an issue
|
991 |
// if renamed after the main file. In fact, the original file might have already
|
992 |
// the best filename and evidently, the "-rescaled" one not.
|
993 |
+
if ( $is_scaled_image ) {
|
994 |
$meta_old_filename = $meta['original_image'];
|
995 |
$meta_old_filepath = trailingslashit( $directory ) . $meta_old_filename;
|
996 |
// In case of the undo, since we do not have the actual real original filename for that un-scaled image,
|
997 |
// we make sure the -scaled part of the original filename is not used (that could bring some confusion otherwise).
|
998 |
+
$meta_new_filename = preg_replace( '/\-scaled$/', '', $noext_new_filename ) . '-mfrh-original.' . $new_ext;
|
999 |
$meta_new_filepath = trailingslashit( $directory ) . $meta_new_filename;
|
1000 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
1001 |
+
$this->log( "🚫 File $meta_old_filepath ➡️ $meta_new_filepath" );
|
1002 |
return $post;
|
1003 |
}
|
1004 |
// Manual Rename also uses the new extension (if it was not stripped to avoid user mistake)
|
1005 |
if ( $force_rename && !empty( $new_ext ) ) {
|
1006 |
$meta_new_filename = $this->str_replace( $old_ext, $new_ext, $meta_new_filename );
|
1007 |
}
|
1008 |
+
$this->log( "✅ File $old_filepath ➡️ $new_filepath" );
|
1009 |
+
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
1010 |
$meta['original_image'] = $meta_new_filename;
|
1011 |
}
|
1012 |
|
1013 |
// Rename the main media file.
|
1014 |
if ( !$this->rename_file( $old_filepath, $new_filepath, $case_issue ) && !$force_rename ) {
|
1015 |
+
$this->log( "🚫 File $old_filepath ➡️ $new_filepath" );
|
1016 |
return $post;
|
1017 |
}
|
1018 |
+
$this->log( "✅ File $old_filepath ➡️ $new_filepath" );
|
|
|
1019 |
do_action( 'mfrh_path_renamed', $post, $old_filepath, $new_filepath );
|
1020 |
|
1021 |
// Rename the main media file in WebP if it exists.
|
1022 |
+
$this->rename_webp_file_if_exist( $old_filepath, $old_ext, $new_filepath,
|
1023 |
+
$new_ext, $case_issue, $force_rename, $post );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1024 |
|
1025 |
if ( $meta ) {
|
1026 |
if ( isset( $meta['file'] ) && !empty( $meta['file'] ) )
|
1029 |
$meta['url'] = $this->str_replace( $noext_old_filename, $noext_new_filename, $meta['url'] );
|
1030 |
else
|
1031 |
$meta['url'] = $noext_new_filename . '.' . $old_ext;
|
|
|
1032 |
}
|
1033 |
|
1034 |
// Better to check like this rather than with wp_attachment_is_image
|
1037 |
|
1038 |
// Loop through the different sizes in the case of an image, and rename them.
|
1039 |
if ( $has_thumbnails ) {
|
1040 |
+
|
1041 |
+
// In the case of a -scaled image, we need to update the next_old_filename.
|
1042 |
+
// next_old_filename is based on the filename of the main file, but since
|
1043 |
+
// it contains '-scaled' but not its thumbnails, we need to modify it here.
|
1044 |
+
// $noext_new_filename is to support this in case of undo.
|
1045 |
+
if ( $is_scaled_image ) {
|
1046 |
+
$noext_new_filename = preg_replace( '/\-scaled$/', '', $noext_new_filename );
|
1047 |
+
$noext_old_filename = preg_replace( '/\-scaled$/', '', $noext_old_filename );
|
1048 |
+
}
|
1049 |
+
|
1050 |
$orig_image_urls = array();
|
1051 |
$orig_image_data = wp_get_attachment_image_src( $id, 'full' );
|
1052 |
$orig_image_urls['full'] = $orig_image_data[0];
|
1078 |
|
1079 |
// Rename retina file
|
1080 |
if ( !$this->rename_file( $wr2x_old_filepath, $wr2x_new_filepath, $case_issue ) && !$force_rename ) {
|
1081 |
+
$this->log( "🚫 Retina $wr2x_old_filepath ➡️ $wr2x_new_filepath" );
|
1082 |
return $post;
|
1083 |
}
|
1084 |
+
$this->log( "✅ Retina $wr2x_old_filepath ➡️ $wr2x_new_filepath" );
|
1085 |
do_action( 'mfrh_path_renamed', $post, $wr2x_old_filepath, $wr2x_new_filepath );
|
1086 |
}
|
1087 |
}
|
1088 |
// If webp file existed, that one as well.
|
1089 |
+
$this->rename_webp_file_if_exist( $meta_old_filepath, $old_ext, $meta_new_filepath,
|
1090 |
+
$new_ext, $case_issue, $force_rename, $post );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1091 |
|
1092 |
// Rename meta file
|
1093 |
if ( !$this->rename_file( $meta_old_filepath, $meta_new_filepath, $case_issue ) && !$force_rename ) {
|
1094 |
+
$this->log( "🚫 File $meta_old_filepath ➡️ $meta_new_filepath" );
|
1095 |
return $post;
|
1096 |
}
|
1097 |
|
1101 |
if ( !isset( $meta['sizes'][$s]['file'] ) )
|
1102 |
continue;
|
1103 |
if ( $meta['sizes'][$s]['file'] == $meta_old_filename ) {
|
1104 |
+
$this->log( "✅ Updated $s based on $size, as they use the same file (probably same size)." );
|
1105 |
$meta['sizes'][$s]['file'] = $meta_new_filename;
|
1106 |
}
|
1107 |
}
|
|
|
1108 |
|
1109 |
// Success, call other plugins
|
1110 |
+
$this->log( "✅ File $meta_old_filepath ➡️ $meta_new_filepath" );
|
1111 |
do_action( 'mfrh_path_renamed', $post, $meta_old_filepath, $meta_new_filepath );
|
1112 |
|
1113 |
}
|
1125 |
add_post_meta( $id, '_manual_file_renaming', true, true );
|
1126 |
|
1127 |
// Update metadata
|
1128 |
+
if ( $meta )
|
1129 |
+
wp_update_attachment_metadata( $id, $meta );
|
1130 |
+
update_attached_file( $id, $new_filepath );
|
1131 |
|
1132 |
// I wonder about cleaning the cache for this media. It might have no impact, and will not reset the cache for the posts using this media anyway, and it adds processing time. I keep it for now, but there might be something better to do.
|
1133 |
clean_post_cache( $id );
|
1139 |
$newslug = preg_replace( '/\\.[^.\\s]{3,4}$/', '', $info['basename'] );
|
1140 |
$post['post_name'] = $newslug;
|
1141 |
if ( wp_update_post( $post ) )
|
1142 |
+
$this->log( "🚀 Slug $oldslug ➡️ $newslug" );
|
1143 |
}
|
1144 |
|
1145 |
// Call the actions so that the plugin's plugins can update everything else (than the files)
|
1175 |
/**
|
1176 |
* Rename webp file only if existed.
|
1177 |
*/
|
1178 |
+
function rename_webp_file_if_exist( $old_filepath, $old_ext, $new_finepath,
|
1179 |
+
$new_ext, $case_issue, $force_rename, $post ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1180 |
|
1181 |
+
// Two WebP patterns exist: filename.webp and filename.ext.webp
|
1182 |
+
|
1183 |
+
if ( $old_ext === 'pdf' & $new_ext === 'pdf' ) {
|
1184 |
+
$old_ext = 'jpg';
|
1185 |
+
$new_ext = 'jpg';
|
1186 |
+
}
|
1187 |
+
|
1188 |
+
$webps = [
|
1189 |
[
|
1190 |
'old' => $this->str_replace( '.' . $old_ext, '.webp', $old_filepath ),
|
1191 |
'new' => $this->str_replace( '.' . $new_ext, '.webp', $new_finepath ),
|
1195 |
'new' => $this->str_replace( '.' . $new_ext, '.' . $new_ext . '.webp', $new_finepath ),
|
1196 |
],
|
1197 |
];
|
|
|
|
|
|
|
1198 |
|
1199 |
+
// // TODO: Without this check, the code following actually doesn't work with PDF Thumbnails (because the old_ext and new_ext doesn't correspond to jpg, which is used for the thumbnails in the PDF case, and not .pdf). In fact, the code after that should be rewritten.
|
1200 |
+
// if ( !preg_match( '/\.webp$/', $old_filepath ) ) {
|
1201 |
+
// return;
|
1202 |
+
// }
|
1203 |
+
|
1204 |
+
foreach ( $webps as $webp ) {
|
1205 |
+
$is_webp = preg_match( '/\.webp$/', $webp['old'] );
|
1206 |
+
$old_file_ok = $is_webp && file_exists( $webp['old'] );
|
1207 |
+
$new_file_ok = ( ( !file_exists( $webp['new'] ) ) || is_writable( $webp['new'] ) );
|
1208 |
+
|
1209 |
+
if ( $old_file_ok && $new_file_ok ) {
|
1210 |
// Rename webp file
|
1211 |
+
if ( !$this->rename_file( $webp['old'], $webp['new'], $case_issue ) && !$force_rename ) {
|
1212 |
+
$this->log( "🚫 WebP $webp[old] ➡️ $webp[new]" );
|
1213 |
return $post;
|
1214 |
}
|
1215 |
+
$this->log( "✅ WebP $webp[old] ➡️ $webp[new]" );
|
1216 |
+
do_action( 'mfrh_path_renamed', $post, $webp['old'], $webp['new'] );
|
1217 |
}
|
1218 |
}
|
1219 |
}
|
1224 |
* @return True on success, false on failure
|
1225 |
*/
|
1226 |
function lock( $post ) {
|
1227 |
+
//TODO: We should probably only take an ID as the argument
|
1228 |
+
$id = $post instanceof WP_Post ? $post->ID : $post;
|
1229 |
+
delete_post_meta( $id, '_require_file_renaming' );
|
1230 |
+
update_post_meta( $id, '_manual_file_renaming', true, true );
|
1231 |
+
return true;
|
1232 |
}
|
1233 |
|
1234 |
/**
|
1237 |
* @return True on success, false on failure
|
1238 |
*/
|
1239 |
function unlock( $post ) {
|
1240 |
+
delete_post_meta( $post instanceof WP_Post ? $post->ID : $post, '_manual_file_renaming' );
|
1241 |
+
return true;
|
1242 |
}
|
1243 |
|
1244 |
/**
|
classes/init.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( class_exists( 'MeowPro_MFRH_Core' ) && class_exists( 'Meow_MFRH_Core' ) ) {
|
4 |
+
function mfrh_admin_notices() {
|
5 |
+
echo '<div class="error"><p>Thanks for installing the Pro version of Media File Renamer :) However, the free version is still enabled. Please disable or uninstall it.</p></div>';
|
6 |
+
}
|
7 |
+
add_action( 'admin_notices', 'mfrh_admin_notices' );
|
8 |
+
return;
|
9 |
+
}
|
10 |
+
|
11 |
+
spl_autoload_register(function ( $class ) {
|
12 |
+
$necessary = true;
|
13 |
+
$file = null;
|
14 |
+
if ( strpos( $class, 'Meow_MFRH' ) !== false ) {
|
15 |
+
$file = MFRH_PATH . '/classes/' . str_replace( 'meow_mfrh_', '', strtolower( $class ) ) . '.php';
|
16 |
+
}
|
17 |
+
else if ( strpos( $class, 'MeowCommon_Classes_' ) !== false ) {
|
18 |
+
$file = MFRH_PATH . '/common/classes/' . str_replace( 'meowcommon_classes_', '', strtolower( $class ) ) . '.php';
|
19 |
+
}
|
20 |
+
else if ( strpos( $class, 'MeowCommon_' ) !== false ) {
|
21 |
+
$file = MFRH_PATH . '/common/' . str_replace( 'meowcommon_', '', strtolower( $class ) ) . '.php';
|
22 |
+
}
|
23 |
+
else if ( strpos( $class, 'MeowPro_MFRH' ) !== false ) {
|
24 |
+
$necessary = false;
|
25 |
+
$file = MFRH_PATH . '/premium/' . str_replace( 'meowpro_mfrh_', '', strtolower( $class ) ) . '.php';
|
26 |
+
}
|
27 |
+
if ( $file ) {
|
28 |
+
if ( !$necessary && !file_exists( $file ) ) {
|
29 |
+
return;
|
30 |
+
}
|
31 |
+
require( $file );
|
32 |
+
}
|
33 |
+
});
|
34 |
+
|
35 |
+
require_once( MFRH_PATH . '/classes/api.php');
|
36 |
+
require_once( MFRH_PATH . '/common/helpers.php');
|
37 |
+
|
38 |
+
// In admin or Rest API request (REQUEST URI begins with '/wp-json/')
|
39 |
+
if ( is_admin() || MeowCommon_Helpers::is_rest() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
|
40 |
+
global $mfrh_core;
|
41 |
+
$mfrh_core = new Meow_MFRH_Core();
|
42 |
+
}
|
43 |
+
|
44 |
+
?>
|
{plugins → classes/plugins}/beaverbuilder.php
RENAMED
File without changes
|
{plugins → classes/plugins}/custom.php
RENAMED
File without changes
|
plugins/woocommerce.php → classes/plugins/unused_woocommerce.php
RENAMED
File without changes
|
{plugins → classes/plugins}/wpml.php
RENAMED
File without changes
|
classes/rest.php
ADDED
@@ -0,0 +1,440 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Meow_MFRH_Rest
|
4 |
+
{
|
5 |
+
private $core = null;
|
6 |
+
private $admin = null;
|
7 |
+
private $namespace = 'media-file-renamer/v1';
|
8 |
+
|
9 |
+
public function __construct( $core ) {
|
10 |
+
if ( !current_user_can( 'administrator' ) ) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
$this->core = $core;
|
14 |
+
$this->admin = $core->admin;
|
15 |
+
|
16 |
+
// FOR DEBUG
|
17 |
+
// For experiencing the UI behavior on a slower install.
|
18 |
+
// sleep(1);
|
19 |
+
// For experiencing the UI behavior on a buggy install.
|
20 |
+
// trigger_error( "Error", E_USER_ERROR);
|
21 |
+
// trigger_error( "Warning", E_USER_WARNING);
|
22 |
+
// trigger_error( "Notice", E_USER_NOTICE);
|
23 |
+
// trigger_error( "Deprecated", E_USER_DEPRECATED);
|
24 |
+
|
25 |
+
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
|
26 |
+
}
|
27 |
+
|
28 |
+
function rest_api_init() {
|
29 |
+
// SETTINGS
|
30 |
+
register_rest_route( $this->namespace, '/update_option/', array(
|
31 |
+
'methods' => 'POST',
|
32 |
+
'callback' => array( $this, 'rest_update_option' )
|
33 |
+
) );
|
34 |
+
register_rest_route( $this->namespace, '/all_settings/', array(
|
35 |
+
'methods' => 'GET',
|
36 |
+
'callback' => array( $this, 'rest_all_settings' )
|
37 |
+
) );
|
38 |
+
|
39 |
+
// STATS & LISTING
|
40 |
+
register_rest_route( $this->namespace, '/stats/', array(
|
41 |
+
'methods' => 'GET',
|
42 |
+
'callback' => array( $this, 'rest_get_stats' )
|
43 |
+
) );
|
44 |
+
register_rest_route( $this->namespace, '/media/', array(
|
45 |
+
'methods' => 'GET',
|
46 |
+
'callback' => array( $this, 'rest_media' ),
|
47 |
+
'args' => array(
|
48 |
+
'limit' => array( 'required' => false, 'default' => 10 ),
|
49 |
+
'skip' => array( 'required' => false, 'default' => 20 ),
|
50 |
+
'filterBy' => array( 'required' => false, 'default' => 'all' ),
|
51 |
+
'orderBy' => array( 'required' => false, 'default' => 'id' ),
|
52 |
+
'order' => array( 'required' => false, 'default' => 'desc' ),
|
53 |
+
'search' => array( 'required' => false ),
|
54 |
+
'offset' => array( 'required' => false ),
|
55 |
+
'order' => array( 'required' => false ),
|
56 |
+
)
|
57 |
+
) );
|
58 |
+
register_rest_route( $this->namespace, '/analyze/', array(
|
59 |
+
'methods' => 'POST',
|
60 |
+
'callback' => array( $this, 'rest_analyze' )
|
61 |
+
) );
|
62 |
+
register_rest_route( $this->namespace, '/get_all_ids/', array(
|
63 |
+
'methods' => 'POST',
|
64 |
+
'callback' => array( $this, 'rest_get_all_ids' )
|
65 |
+
) );
|
66 |
+
|
67 |
+
// ACTIONS
|
68 |
+
register_rest_route( $this->namespace, '/set_lock/', array(
|
69 |
+
'methods' => 'POST',
|
70 |
+
'callback' => array( $this, 'rest_set_lock' )
|
71 |
+
) );
|
72 |
+
register_rest_route( $this->namespace, '/rename/', array(
|
73 |
+
'methods' => 'POST',
|
74 |
+
'callback' => array( $this, 'rest_rename' )
|
75 |
+
) );
|
76 |
+
register_rest_route( $this->namespace, '/undo/', array(
|
77 |
+
'methods' => 'POST',
|
78 |
+
'callback' => array( $this, 'rest_undo' )
|
79 |
+
) );
|
80 |
+
register_rest_route( $this->namespace, '/status/', array(
|
81 |
+
'methods' => 'POST',
|
82 |
+
'callback' => array( $this, 'rest_status' )
|
83 |
+
) );
|
84 |
+
|
85 |
+
// LOGS
|
86 |
+
register_rest_route( $this->namespace, '/refresh_logs/', array(
|
87 |
+
'methods' => 'POST',
|
88 |
+
'callback' => array( $this, 'refresh_logs' )
|
89 |
+
) );
|
90 |
+
register_rest_route( $this->namespace, '/clear_logs/', array(
|
91 |
+
'methods' => 'POST',
|
92 |
+
'callback' => array( $this, 'clear_logs' )
|
93 |
+
) );
|
94 |
+
}
|
95 |
+
|
96 |
+
function refresh_logs() {
|
97 |
+
$data = "No data.";
|
98 |
+
if ( file_exists( MFRH_PATH . '/logs/media-file-renamer.log' ) ) {
|
99 |
+
$data = file_get_contents( MFRH_PATH . '/logs/media-file-renamer.log' );
|
100 |
+
}
|
101 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $data ], 200 );
|
102 |
+
}
|
103 |
+
|
104 |
+
function clear_logs() {
|
105 |
+
unlink( MFRH_PATH . '/logs/media-file-renamer.log' );
|
106 |
+
return new WP_REST_Response( [ 'success' => true ], 200 );
|
107 |
+
}
|
108 |
+
|
109 |
+
function rest_analyze( $request ) {
|
110 |
+
$params = $request->get_json_params();
|
111 |
+
$mediaIds = isset( $params['mediaIds'] ) ? (array)$params['mediaIds'] : null;
|
112 |
+
$mediaId = isset( $params['mediaId'] ) ? (int)$params['mediaId'] : null;
|
113 |
+
$data = array();
|
114 |
+
if ( !empty( $mediaIds ) ) {
|
115 |
+
foreach ( $mediaIds as $mediaId ) {
|
116 |
+
$entry = $this->get_media_status_one( $mediaId );
|
117 |
+
array_push( $data, $entry );
|
118 |
+
}
|
119 |
+
}
|
120 |
+
else if ( !empty( $mediaId ) ) {
|
121 |
+
$data = $this->get_media_status_one( $mediaId );
|
122 |
+
}
|
123 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $data ], 200 );
|
124 |
+
}
|
125 |
+
|
126 |
+
function rest_get_all_ids( $request ) {
|
127 |
+
global $wpdb;
|
128 |
+
$params = $request->get_json_params();
|
129 |
+
$unlockedOnly = isset( $params['unlockedOnly'] ) ? (bool)$params['unlockedOnly'] : false;
|
130 |
+
if ( $unlockedOnly ) {
|
131 |
+
$ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts p
|
132 |
+
LEFT JOIN wp_postmeta pm ON p.ID = pm.post_id
|
133 |
+
AND pm.meta_key='_manual_file_renaming'
|
134 |
+
WHERE post_type='attachment'
|
135 |
+
AND post_status='inherit'
|
136 |
+
AND pm.meta_value IS NULL"
|
137 |
+
);
|
138 |
+
}
|
139 |
+
else {
|
140 |
+
$ids = $wpdb->get_col( "SELECT ID FROM $wpdb->posts p
|
141 |
+
WHERE post_type='attachment'
|
142 |
+
AND post_status='inherit'"
|
143 |
+
);
|
144 |
+
}
|
145 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $ids ], 200 );
|
146 |
+
}
|
147 |
+
|
148 |
+
function rest_status( $request ) {
|
149 |
+
$params = $request->get_json_params();
|
150 |
+
$mediaId = (int)$params['mediaId'];
|
151 |
+
$entry = $this->get_media_status_one( $mediaId );
|
152 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $entry ], 200 );
|
153 |
+
}
|
154 |
+
|
155 |
+
function rest_rename( $request ) {
|
156 |
+
$params = $request->get_json_params();
|
157 |
+
$mediaId = (int)$params['mediaId'];
|
158 |
+
$filename = isset( $params['filename'] ) ? (string)$params['filename'] : null;
|
159 |
+
$res = $this->core->rename( $mediaId, $filename );
|
160 |
+
$entry = $this->get_media_status_one( $mediaId );
|
161 |
+
return new WP_REST_Response( [ 'success' => !!$res, 'data' => $entry ], 200 );
|
162 |
+
}
|
163 |
+
|
164 |
+
function rest_undo( $request ) {
|
165 |
+
$params = $request->get_json_params();
|
166 |
+
$mediaId = (int)$params['mediaId'];
|
167 |
+
$res = $this->core->undo( $mediaId );
|
168 |
+
$entry = $this->get_media_status_one( $mediaId );
|
169 |
+
return new WP_REST_Response( [ 'success' => !!$res, 'data' => $entry ], 200 );
|
170 |
+
}
|
171 |
+
|
172 |
+
function rest_set_lock( $request ) {
|
173 |
+
$params = $request->get_json_params();
|
174 |
+
$lock = (boolean)$params['lock'];
|
175 |
+
$mediaIds = isset( $params['mediaIds'] ) ? (array)$params['mediaIds'] : null;
|
176 |
+
$mediaId = isset( $params['mediaId'] ) ? (int)$params['mediaId'] : null;
|
177 |
+
$data = null;
|
178 |
+
if ( !empty( $mediaIds ) ) {
|
179 |
+
foreach ( $mediaIds as $mediaId ) {
|
180 |
+
$lock ? $this->core->lock( $mediaId ) : $this->core->unlock( $mediaId );
|
181 |
+
}
|
182 |
+
$data = 'N/A';
|
183 |
+
}
|
184 |
+
else if ( !empty( $mediaId ) ) {
|
185 |
+
$lock ? $this->core->lock( $mediaId ) : $this->core->unlock( $mediaId );
|
186 |
+
$data = $this->get_media_status_one( $mediaId );
|
187 |
+
}
|
188 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $data ], 200 );
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Organize the data of the entry.
|
193 |
+
* It is used by get_media_status and get_media_status_one.
|
194 |
+
*
|
195 |
+
* @param [type] $entry
|
196 |
+
* @return void
|
197 |
+
*/
|
198 |
+
function consolidate_media_status( &$entry ) {
|
199 |
+
$entry->ID = (int)$entry->ID;
|
200 |
+
$entry->post_parent = !empty( $entry->post_parent ) ? (int)$entry->post_parent : null;
|
201 |
+
$entry->post_parent_title = !empty( $entry->post_parent ) ? get_the_title( $entry->post_parent ) : null;
|
202 |
+
$entry->metadata = unserialize( $entry->metadata );
|
203 |
+
$entry->thumbnail_url = wp_get_attachment_thumb_url( $entry->ID );
|
204 |
+
$entry->current_filename = pathinfo( $entry->current_filename, PATHINFO_BASENAME );
|
205 |
+
$entry->locked = $entry->locked === '1';
|
206 |
+
$entry->pending = $entry->pending === '1';
|
207 |
+
|
208 |
+
$entry->proposed_filename = null;
|
209 |
+
if ( !$entry->locked ) {
|
210 |
+
$output = null;
|
211 |
+
// TODO: We should optimize this check_attachment function one day.
|
212 |
+
$this->core->check_attachment( get_post( $entry->ID, ARRAY_A ), $output );
|
213 |
+
if ( isset( $output['ideal_filename'] ) ) {
|
214 |
+
$entry->ideal_filename = $output['ideal_filename'];
|
215 |
+
}
|
216 |
+
if ( isset( $output['proposed_filename'] ) ) {
|
217 |
+
$entry->proposed_filename = $output['proposed_filename'];
|
218 |
+
$entry->proposed_filename_exists = $output['proposed_filename_exists'];
|
219 |
+
}
|
220 |
+
//error_log( print_r( $output, 1 ) );
|
221 |
+
}
|
222 |
+
return $entry;
|
223 |
+
}
|
224 |
+
|
225 |
+
function count_pending() {
|
226 |
+
global $wpdb;
|
227 |
+
return (int)$wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p
|
228 |
+
INNER JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
|
229 |
+
WHERE pm.meta_key = '_require_file_renaming'"
|
230 |
+
);
|
231 |
+
}
|
232 |
+
|
233 |
+
function count_renamed() {
|
234 |
+
global $wpdb;
|
235 |
+
return (int)$wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p
|
236 |
+
INNER JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
|
237 |
+
WHERE pm.meta_key = '_original_filename'"
|
238 |
+
);
|
239 |
+
}
|
240 |
+
|
241 |
+
function count_all() {
|
242 |
+
global $wpdb;
|
243 |
+
return (int)$wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p
|
244 |
+
WHERE post_type='attachment'
|
245 |
+
AND post_status='inherit'"
|
246 |
+
);
|
247 |
+
}
|
248 |
+
|
249 |
+
function rest_get_stats() {
|
250 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => array(
|
251 |
+
'pending' => $this->count_pending(),
|
252 |
+
'renamed' => $this->count_renamed(),
|
253 |
+
'all' => $this->count_all()
|
254 |
+
) ], 200 );
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Get the status for many Media IDs.
|
259 |
+
*
|
260 |
+
* @param integer $skip
|
261 |
+
* @param integer $limit
|
262 |
+
* @return void
|
263 |
+
*/
|
264 |
+
function get_media_status( $skip = 0, $limit = 10, $filterBy, $orderBy, $order ) {
|
265 |
+
global $wpdb;
|
266 |
+
// I used this before to gather the metadata in a json object
|
267 |
+
// JSON_OBJECTAGG(pm.meta_key, pm.meta_value) as meta
|
268 |
+
// That was cool, but I prefer the MAX technique in order to apply filters
|
269 |
+
$havingSql = '';
|
270 |
+
if ( $filterBy === 'pending' ) {
|
271 |
+
$havingSql = 'HAVING pending IS NOT NULL';
|
272 |
+
}
|
273 |
+
else if ( $filterBy === 'renamed' ) {
|
274 |
+
$havingSql = 'HAVING original_filename IS NOT NULL';
|
275 |
+
}
|
276 |
+
$orderSql = 'ORDER BY p.ID DESC';
|
277 |
+
if ($orderBy === 'post_title') {
|
278 |
+
$orderSql = 'ORDER BY post_title ' . ( $order === 'asc' ? 'ASC' : 'DESC' );
|
279 |
+
}
|
280 |
+
else if ($orderBy === 'post_parent') {
|
281 |
+
$orderSql = 'ORDER BY post_parent ' . ( $order === 'asc' ? 'ASC' : 'DESC' );
|
282 |
+
}
|
283 |
+
else if ($orderBy === 'current_filename') {
|
284 |
+
$orderSql = 'ORDER BY current_filename ' . ( $order === 'asc' ? 'ASC' : 'DESC' );
|
285 |
+
}
|
286 |
+
$entries = $wpdb->get_results(
|
287 |
+
$wpdb->prepare( "SELECT p.ID, p.post_title, p.post_parent,
|
288 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attached_file' THEN pm.meta_value END) AS current_filename,
|
289 |
+
MAX(CASE WHEN pm.meta_key = '_original_filename' THEN pm.meta_value END) AS original_filename,
|
290 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attachment_metadata' THEN pm.meta_value END) AS metadata,
|
291 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attachment_image_alt' THEN pm.meta_value END) AS image_alt,
|
292 |
+
MAX(CASE WHEN pm.meta_key = '_require_file_renaming' THEN pm.meta_value END) AS pending,
|
293 |
+
MAX(CASE WHEN pm.meta_key = '_manual_file_renaming' THEN pm.meta_value END) AS locked
|
294 |
+
FROM $wpdb->posts p
|
295 |
+
INNER JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
|
296 |
+
WHERE post_type='attachment'
|
297 |
+
AND (pm.meta_key = '_wp_attached_file'
|
298 |
+
OR pm.meta_key = '_original_filename'
|
299 |
+
OR pm.meta_key = '_wp_attachment_metadata'
|
300 |
+
OR pm.meta_key = '_wp_attachment_image_alt'
|
301 |
+
OR pm.meta_key = '_require_file_renaming'
|
302 |
+
OR pm.meta_key = '_manual_file_renaming'
|
303 |
+
)
|
304 |
+
GROUP BY p.ID
|
305 |
+
$havingSql
|
306 |
+
$orderSql
|
307 |
+
LIMIT %d, %d", $skip, $limit
|
308 |
+
)
|
309 |
+
);
|
310 |
+
foreach ( $entries as $entry ) {
|
311 |
+
$this->consolidate_media_status( $entry );
|
312 |
+
}
|
313 |
+
return $entries;
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* Get the status for many Media IDs.
|
318 |
+
*
|
319 |
+
* @param integer $mediaId
|
320 |
+
* @return void
|
321 |
+
*/
|
322 |
+
function get_media_status_one( $mediaId ) {
|
323 |
+
global $wpdb;
|
324 |
+
$entry = $wpdb->get_row(
|
325 |
+
$wpdb->prepare( "SELECT p.ID, p.post_title, p.post_parent,
|
326 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attached_file' THEN pm.meta_value END) AS current_filename,
|
327 |
+
MAX(CASE WHEN pm.meta_key = '_original_filename' THEN pm.meta_value END) AS original_filename,
|
328 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attachment_metadata' THEN pm.meta_value END) AS metadata,
|
329 |
+
MAX(CASE WHEN pm.meta_key = '_wp_attachment_image_alt' THEN pm.meta_value END) AS image_alt,
|
330 |
+
MAX(CASE WHEN pm.meta_key = '_require_file_renaming' THEN pm.meta_value END) AS pending,
|
331 |
+
MAX(CASE WHEN pm.meta_key = '_manual_file_renaming' THEN pm.meta_value END) AS locked
|
332 |
+
FROM $wpdb->posts p
|
333 |
+
INNER JOIN $wpdb->postmeta pm ON pm.post_id = p.ID
|
334 |
+
WHERE p.ID = %d
|
335 |
+
AND post_type='attachment'
|
336 |
+
AND (pm.meta_key = '_wp_attached_file'
|
337 |
+
OR pm.meta_key = '_original_filename'
|
338 |
+
OR pm.meta_key = '_wp_attachment_metadata'
|
339 |
+
OR pm.meta_key = '_wp_attachment_image_alt'
|
340 |
+
OR pm.meta_key = '_require_file_renaming'
|
341 |
+
OR pm.meta_key = '_manual_file_renaming'
|
342 |
+
)
|
343 |
+
GROUP BY p.ID", $mediaId
|
344 |
+
)
|
345 |
+
);
|
346 |
+
return $this->consolidate_media_status( $entry );
|
347 |
+
}
|
348 |
+
|
349 |
+
function rest_media( $request ) {
|
350 |
+
$limit = trim( $request->get_param('limit') );
|
351 |
+
$skip = trim( $request->get_param('skip') );
|
352 |
+
$filterBy = trim( $request->get_param('filterBy') );
|
353 |
+
$orderBy = trim( $request->get_param('orderBy') );
|
354 |
+
$order = trim( $request->get_param('order') );
|
355 |
+
$entries = $this->get_media_status( $skip, $limit, $filterBy, $orderBy, $order );
|
356 |
+
$total = 0;
|
357 |
+
if ( $filterBy == 'pending' ) {
|
358 |
+
$total = $this->count_pending();
|
359 |
+
}
|
360 |
+
else if ( $filterBy == 'renamed' ) {
|
361 |
+
$total = $this->count_renamed();
|
362 |
+
}
|
363 |
+
else if ( $filterBy == 'all' ) {
|
364 |
+
$total = $this->count_all();
|
365 |
+
}
|
366 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $entries, 'total' => $total ], 200 );
|
367 |
+
}
|
368 |
+
|
369 |
+
function rest_all_settings() {
|
370 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $this->admin->get_all_options() ], 200 );
|
371 |
+
}
|
372 |
+
|
373 |
+
function rest_update_option( $request ) {
|
374 |
+
$params = $request->get_json_params();
|
375 |
+
try {
|
376 |
+
$name = $params['name'];
|
377 |
+
$value = is_bool( $params['value'] ) ? ( $params['value'] ? '1' : '' ) : $params['value'];
|
378 |
+
$success = update_option( $name, $value );
|
379 |
+
if ( !$success ) {
|
380 |
+
return new WP_REST_Response([ 'success' => false, 'message' => 'Could not update option.' ], 200 );
|
381 |
+
}
|
382 |
+
$res = $this->validate_updated_option( $name );
|
383 |
+
return new WP_REST_Response([ 'success' => $res['result'], 'message' => $res['message'], 'data' => $value ], 200 );
|
384 |
+
}
|
385 |
+
catch (Exception $e) {
|
386 |
+
return new WP_REST_Response([ 'success' => false, 'message' => $e->getMessage() ], 500 );
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
function validate_updated_option( $option_name ) {
|
391 |
+
$needsCheckingOptions = [
|
392 |
+
'mfrh_method',
|
393 |
+
'mfrh_sync_alt',
|
394 |
+
'mfrh_sync_media_title',
|
395 |
+
'mfrh_force_rename',
|
396 |
+
'mfrh_numbered_files'
|
397 |
+
];
|
398 |
+
if ( !in_array( $option_name, $needsCheckingOptions ) ) {
|
399 |
+
return $this->createValidationResult();
|
400 |
+
}
|
401 |
+
|
402 |
+
if ( $option_name === 'mfrh_force_rename' || $option_name === 'mfrh_numbered_files' ) {
|
403 |
+
$force_rename = get_option( 'mfrh_force_rename', false );
|
404 |
+
$numbered_files = get_option( 'mfrh_numbered_files', false );
|
405 |
+
|
406 |
+
if ( !$force_rename || !$numbered_files ) {
|
407 |
+
return $this->createValidationResult();
|
408 |
+
}
|
409 |
+
|
410 |
+
update_option( 'mfrh_force_rename', false, false );
|
411 |
+
return $this->createValidationResult( false, __( 'Force Rename and Numbered Files cannot be used at the same time. Please use Force Rename only when you are trying to repair a broken install. For now, Force Rename has been disabled.', 'media-file-renamer' ));
|
412 |
+
|
413 |
+
}
|
414 |
+
else if ( $option_name === 'mfrh_method' || $option_name === 'mfrh_sync_alt' || $option_name ==='mfrh_sync_media_title' ) {
|
415 |
+
if ( $this->core->method !== 'alt_text' && $this->core->method !== 'media_title' ) {
|
416 |
+
return $this->createValidationResult();
|
417 |
+
}
|
418 |
+
|
419 |
+
$sync_alt = get_option( 'mfrh_sync_alt' );
|
420 |
+
if ( $sync_alt && $this->core->method === 'alt_text' ) {
|
421 |
+
update_option( 'mfrh_sync_alt', false, false );
|
422 |
+
return $this->createValidationResult( false, __( 'The option Sync ALT was turned off since it does not make sense to have it with this Auto-Rename mode.', 'media-file-renamer' ));
|
423 |
+
}
|
424 |
+
|
425 |
+
$sync_meta_title = get_option( 'mfrh_sync_media_title' );
|
426 |
+
if ( $sync_meta_title && $this->core->method === 'media_title' ) {
|
427 |
+
update_option( 'mfrh_sync_media_title', false, false );
|
428 |
+
return $this->createValidationResult( false, __( 'The option Sync Media Title was turned off since it does not make sense to have it with this Auto-Rename mode.', 'media-file-renamer' ));
|
429 |
+
}
|
430 |
+
}
|
431 |
+
return $this->createValidationResult();
|
432 |
+
}
|
433 |
+
|
434 |
+
function createValidationResult( $result = true, $message = null) {
|
435 |
+
$message = $message ? $message : __( 'Option updated.', 'media-file-renamer' );
|
436 |
+
return ['result' => $result, 'message' => $message];
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
?>
|
classes/ui.php
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Meow_MFRH_UI {
|
4 |
+
private $core = null;
|
5 |
+
|
6 |
+
function __construct( $core ) {
|
7 |
+
$this->core = $core;
|
8 |
+
$is_manual = get_option( 'mfrh_manual', false );
|
9 |
+
|
10 |
+
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
11 |
+
add_filter( 'media_send_to_editor', array( $this, 'media_send_to_editor' ), 20, 3 );
|
12 |
+
|
13 |
+
// Add the metabox and the column if it's either manual or automatic
|
14 |
+
if ( $core->method != 'none' || $is_manual ) {
|
15 |
+
add_filter( 'manage_media_columns', array( $this, 'add_media_columns' ) );
|
16 |
+
add_action( 'manage_media_custom_column', array( $this, 'manage_media_custom_column' ), 10, 2 );
|
17 |
+
add_action( 'add_meta_boxes', array( $this, 'add_rename_metabox' ) );
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
function admin_menu() {
|
22 |
+
add_media_page( 'Media File Renamer', __( 'Renamer', 'media-file-renamer' ), 'manage_options',
|
23 |
+
'mfrh_dashboard', array( $this, 'rename_media_files' ), 1 );
|
24 |
+
}
|
25 |
+
|
26 |
+
function media_send_to_editor( $html, $id, $attachment ) {
|
27 |
+
$output = array();
|
28 |
+
$this->core->check_attachment( get_post( $id, ARRAY_A ), $output );
|
29 |
+
return $html;
|
30 |
+
}
|
31 |
+
|
32 |
+
public function rename_media_files() {
|
33 |
+
echo '<div id="mfrh-media-rename"></div>';
|
34 |
+
}
|
35 |
+
|
36 |
+
function add_rename_metabox() {
|
37 |
+
add_meta_box( 'mfrh_media', 'Renamer', array( $this, 'attachment_fields' ), 'attachment', 'side', 'high' );
|
38 |
+
}
|
39 |
+
|
40 |
+
function attachment_fields( $post ) {
|
41 |
+
if ( $post ) {
|
42 |
+
echo '
|
43 |
+
<div class="mfrh-renamer-field" data-id="' . $post->ID . '"></div>
|
44 |
+
<div style="line-height: 15px; font-size: 12px; margin-top: 10px;">After an update, please reload this Edit Media page.</div>
|
45 |
+
';
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
function add_media_columns( $columns ) {
|
50 |
+
$columns['mfrh_column'] = __( 'Renamer', 'media-file-renamer' );
|
51 |
+
return $columns;
|
52 |
+
}
|
53 |
+
|
54 |
+
function manage_media_custom_column( $column_name, $id ) {
|
55 |
+
if ( $column_name === 'mfrh_column' ) {
|
56 |
+
echo '<div class="mfrh-renamer-field" data-id="' . $id . '"></div>';
|
57 |
+
}
|
58 |
+
}
|
59 |
+
}
|
updates.php → classes/updates.php
RENAMED
@@ -1,13 +1,10 @@
|
|
1 |
<?php
|
2 |
|
3 |
class Meow_MFRH_Updates {
|
4 |
-
|
5 |
private $core = null;
|
6 |
-
private $admin = null;
|
7 |
|
8 |
-
public function __construct( $core
|
9 |
$this->core = $core;
|
10 |
-
$this->admin = $admin;
|
11 |
|
12 |
$this->init_actions();
|
13 |
|
@@ -46,7 +43,7 @@ class Meow_MFRH_Updates {
|
|
46 |
", $orig_image_url, $new_image_url );
|
47 |
$wpdb->query( $query );
|
48 |
$this->core->log_sql( $query, $query_revert );
|
49 |
-
$this->core->log( "
|
50 |
}
|
51 |
|
52 |
// Mass update of all the articles with the new filenames
|
@@ -80,7 +77,7 @@ class Meow_MFRH_Updates {
|
|
80 |
AND post_type != 'auto-draft'", $new_image_url, $orig_image_url );
|
81 |
$wpdb->query( $query );
|
82 |
$this->core->log_sql( $query, $query_revert );
|
83 |
-
$this->core->log( "
|
84 |
|
85 |
// Excerpt
|
86 |
$query = $wpdb->prepare( "UPDATE $wpdb->posts
|
@@ -109,7 +106,7 @@ class Meow_MFRH_Updates {
|
|
109 |
AND post_type != 'auto-draft'", $new_image_url, $orig_image_url );
|
110 |
$wpdb->query( $query );
|
111 |
$this->core->log_sql( $query, $query_revert );
|
112 |
-
$this->core->log( "
|
113 |
}
|
114 |
|
115 |
// The GUID should never be updated but... this will if the option is checked.
|
@@ -126,7 +123,7 @@ class Meow_MFRH_Updates {
|
|
126 |
$this->core->log_sql( $query, $query_revert );
|
127 |
$wpdb->query( $query );
|
128 |
clean_post_cache( $post['ID'] );
|
129 |
-
$this->core->log( "GUID
|
130 |
}
|
131 |
|
132 |
/**
|
1 |
<?php
|
2 |
|
3 |
class Meow_MFRH_Updates {
|
|
|
4 |
private $core = null;
|
|
|
5 |
|
6 |
+
public function __construct( $core ) {
|
7 |
$this->core = $core;
|
|
|
8 |
|
9 |
$this->init_actions();
|
10 |
|
43 |
", $orig_image_url, $new_image_url );
|
44 |
$wpdb->query( $query );
|
45 |
$this->core->log_sql( $query, $query_revert );
|
46 |
+
$this->core->log( "🚀 Rewrite meta $orig_image_url ➡️ $new_image_url" );
|
47 |
}
|
48 |
|
49 |
// Mass update of all the articles with the new filenames
|
77 |
AND post_type != 'auto-draft'", $new_image_url, $orig_image_url );
|
78 |
$wpdb->query( $query );
|
79 |
$this->core->log_sql( $query, $query_revert );
|
80 |
+
$this->core->log( "🚀 Rewrite content $orig_image_url ➡️ $new_image_url" );
|
81 |
|
82 |
// Excerpt
|
83 |
$query = $wpdb->prepare( "UPDATE $wpdb->posts
|
106 |
AND post_type != 'auto-draft'", $new_image_url, $orig_image_url );
|
107 |
$wpdb->query( $query );
|
108 |
$this->core->log_sql( $query, $query_revert );
|
109 |
+
$this->core->log( "🚀 Rewrite excerpts $orig_image_url ➡️ $new_image_url" );
|
110 |
}
|
111 |
|
112 |
// The GUID should never be updated but... this will if the option is checked.
|
123 |
$this->core->log_sql( $query, $query_revert );
|
124 |
$wpdb->query( $query );
|
125 |
clean_post_cache( $post['ID'] );
|
126 |
+
$this->core->log( "🚀 GUID $old_guid ➡️ $new_filepath." );
|
127 |
}
|
128 |
|
129 |
/**
|
common/admin.css
DELETED
@@ -1,404 +0,0 @@
|
|
1 |
-
/* MEOW-TABS */
|
2 |
-
|
3 |
-
.meow-tabs {
|
4 |
-
display: flex;
|
5 |
-
flex-wrap: wrap;
|
6 |
-
box-sizing: border-box;
|
7 |
-
}
|
8 |
-
|
9 |
-
.meow-tabs * {
|
10 |
-
box-sizing: border-box;
|
11 |
-
}
|
12 |
-
|
13 |
-
.meow-tabs .meow-tabs-input {
|
14 |
-
position: absolute;
|
15 |
-
opacity: 0;
|
16 |
-
}
|
17 |
-
|
18 |
-
.meow-tabs .meow-tabs-label {
|
19 |
-
width: auto;
|
20 |
-
padding: 4px 12px;
|
21 |
-
background: #3c3c3c;
|
22 |
-
cursor: pointer;
|
23 |
-
font-weight: bold;
|
24 |
-
font-size: 13px;
|
25 |
-
text-transform: uppercase;
|
26 |
-
color: white;
|
27 |
-
transition: background 0.1s, color 0.1s;
|
28 |
-
}
|
29 |
-
|
30 |
-
.meow-tabs .inside {
|
31 |
-
display: none;
|
32 |
-
width: 100%;
|
33 |
-
}
|
34 |
-
|
35 |
-
.meow-tabs .meow-tabs-label:hover {
|
36 |
-
background: #36495f;
|
37 |
-
}
|
38 |
-
|
39 |
-
.meow-tabs .meow-tabs-label:active {
|
40 |
-
background: #3C82C7;
|
41 |
-
}
|
42 |
-
|
43 |
-
.meow-tabs .meow-tabs-input:focus + .meow-tabs-label {
|
44 |
-
box-shadow: inset 0px 0px 0px 3px #2aa1c0;
|
45 |
-
z-index: 1;
|
46 |
-
}
|
47 |
-
|
48 |
-
.meow-tabs .meow-tabs-input:checked + .meow-tabs-label {
|
49 |
-
background: #3C82C7 !important;
|
50 |
-
}
|
51 |
-
|
52 |
-
.meow-tabs-input:checked + .meow-tabs-label + .inside {
|
53 |
-
display: block;
|
54 |
-
order: 99;
|
55 |
-
}
|
56 |
-
|
57 |
-
.meow-tabs .inside {
|
58 |
-
background: #fff;
|
59 |
-
}
|
60 |
-
|
61 |
-
/* MEOW-BOX */
|
62 |
-
|
63 |
-
.meow-box {
|
64 |
-
box-sizing: border-box;
|
65 |
-
border: 1px solid #e5e5e5;
|
66 |
-
box-shadow: 0px 3px 5px rgba(0, 0, 0, .1);
|
67 |
-
background: #fff;
|
68 |
-
color: #444;
|
69 |
-
margin-bottom: 15px;
|
70 |
-
font-size: 13px !important;
|
71 |
-
border-top-right-radius: 8px;
|
72 |
-
}
|
73 |
-
|
74 |
-
.meow-box input, .meow-box th, .meow-box label, .meow-box select {
|
75 |
-
font-size: 13px !important;
|
76 |
-
}
|
77 |
-
|
78 |
-
.meow-box small {
|
79 |
-
font-size: 12px !important;
|
80 |
-
}
|
81 |
-
|
82 |
-
.meow-box h3 {
|
83 |
-
font-size: 14px;
|
84 |
-
padding: 10px 12px;
|
85 |
-
margin: 0;
|
86 |
-
background: #3c3c3c;
|
87 |
-
color: #ffffff;
|
88 |
-
text-transform: uppercase;
|
89 |
-
/*border-bottom: 1px solid #eee;*/
|
90 |
-
}
|
91 |
-
|
92 |
-
.meow-box h3 .dashicons {
|
93 |
-
position: relative;
|
94 |
-
top: 0px;
|
95 |
-
margin-right: 5px;
|
96 |
-
}
|
97 |
-
|
98 |
-
.meow-box .pro_info {
|
99 |
-
padding: 5px;
|
100 |
-
margin: 10px -10px 5px -10px;
|
101 |
-
font-size: 11px;
|
102 |
-
line-height: 13px;
|
103 |
-
}
|
104 |
-
|
105 |
-
.meow-box .pro_info.enabled {
|
106 |
-
background: #4482d2;
|
107 |
-
border-left: 5px solid #4482d2;
|
108 |
-
color: white;
|
109 |
-
}
|
110 |
-
|
111 |
-
.meow-box .pro_info.disabled {
|
112 |
-
background: #96555b;
|
113 |
-
border-left: 5px solid #632329;
|
114 |
-
color: white;
|
115 |
-
}
|
116 |
-
|
117 |
-
.meow-box .pro_info.disabled a {
|
118 |
-
background: #96555b;
|
119 |
-
color: red;
|
120 |
-
text-decoration: none;
|
121 |
-
}
|
122 |
-
|
123 |
-
.meow-box .inside {
|
124 |
-
margin: 10px;
|
125 |
-
}
|
126 |
-
|
127 |
-
.meow-box th {
|
128 |
-
padding: 10px 10px 10px 0px;
|
129 |
-
width: 22%;
|
130 |
-
}
|
131 |
-
|
132 |
-
.meow-box td {
|
133 |
-
padding: 10px 10px;
|
134 |
-
}
|
135 |
-
|
136 |
-
.meow-box p.submit, .meow-box div.submit {
|
137 |
-
text-align: right;
|
138 |
-
margin: 10px -10px -10px -10px;
|
139 |
-
padding: 7px 10px 10px 0px !important;
|
140 |
-
border-top: 1px solid #eee !important;
|
141 |
-
max-width: inherit;
|
142 |
-
background: rgba(125, 125, 125, 0.04);
|
143 |
-
border-radius: 0px;
|
144 |
-
}
|
145 |
-
|
146 |
-
.meow-box [type="text"], .meow-box select {
|
147 |
-
width: 100%;
|
148 |
-
}
|
149 |
-
|
150 |
-
/* CONTROLS INSIDE A COLUMN (LABEL ON THE LEFT, VALUE ON THE RIGHT) */
|
151 |
-
.meow-box td [type="text"], .meow-box td [type="checkbox"], .meow-box td select {
|
152 |
-
margin-top: -3px;
|
153 |
-
}
|
154 |
-
|
155 |
-
.meow-header-ad {
|
156 |
-
float: right;
|
157 |
-
}
|
158 |
-
|
159 |
-
/* BUTTONS */
|
160 |
-
|
161 |
-
.meow-button-xs {
|
162 |
-
font-size: 10px !important;
|
163 |
-
height: 20px !important;
|
164 |
-
line-height: 18px !important;
|
165 |
-
position: relative !important;
|
166 |
-
top: 1px !important;
|
167 |
-
text-align: center !important
|
168 |
-
}
|
169 |
-
|
170 |
-
/* MODAL */
|
171 |
-
|
172 |
-
#meow-modal-info-backdrop {
|
173 |
-
background: rgba(0, 0, 0, 0.75);
|
174 |
-
position: fixed;
|
175 |
-
top: 0px;
|
176 |
-
bottom: 0px;
|
177 |
-
right: 0px;
|
178 |
-
left: 0px;
|
179 |
-
z-index: 10000;
|
180 |
-
}
|
181 |
-
|
182 |
-
#meow-modal-info {
|
183 |
-
background: white;
|
184 |
-
box-shadow: 0px 0px 5px black;
|
185 |
-
padding: 15px;
|
186 |
-
overflow-y: scroll;
|
187 |
-
position: fixed;
|
188 |
-
z-index: 10000;
|
189 |
-
left: 100px;
|
190 |
-
right: 100px;
|
191 |
-
top: 50px;
|
192 |
-
bottom: 50px;
|
193 |
-
}
|
194 |
-
|
195 |
-
#meow-modal-info h3 {
|
196 |
-
height: 25px;
|
197 |
-
border-bottom: 2px solid #808080;
|
198 |
-
}
|
199 |
-
|
200 |
-
#meow-modal-info td {
|
201 |
-
text-align: center;
|
202 |
-
font-size: 11px;
|
203 |
-
border: 1px solid #D3DCFF;
|
204 |
-
padding: 10px 15px;
|
205 |
-
background: #EFF8FF;
|
206 |
-
}
|
207 |
-
|
208 |
-
#meow-modal-info .close {
|
209 |
-
float: right;
|
210 |
-
font-size: 18px;
|
211 |
-
font-weight: bold;
|
212 |
-
font-family: Verdana;
|
213 |
-
cursor: pointer;
|
214 |
-
}
|
215 |
-
|
216 |
-
#meow-modal-info .loading {
|
217 |
-
background-color: #F2F2F2;
|
218 |
-
text-align: center;
|
219 |
-
padding-top: 10px;
|
220 |
-
background-size: 32px 32px;
|
221 |
-
}
|
222 |
-
|
223 |
-
#meow-modal-info .meow-sized-image {
|
224 |
-
width: 19px;
|
225 |
-
height: 19px;
|
226 |
-
margin-right: 10px;
|
227 |
-
}
|
228 |
-
|
229 |
-
/* IMAGE SIZES RELATED INFO */
|
230 |
-
|
231 |
-
.meow-sized-images {
|
232 |
-
margin-top: 0px;
|
233 |
-
cursor: pointer;
|
234 |
-
}
|
235 |
-
|
236 |
-
.meow-sized-images li, #meow-modal-info .meow-sized-image {
|
237 |
-
display: block;
|
238 |
-
color: white;
|
239 |
-
padding: 5px 0px;
|
240 |
-
font-size: 10px;
|
241 |
-
text-align: center;
|
242 |
-
width: 18px;
|
243 |
-
height: 18px;
|
244 |
-
line-height: 8px;
|
245 |
-
background: black;
|
246 |
-
float: left;
|
247 |
-
margin-right: 1px;
|
248 |
-
box-sizing: border-box;
|
249 |
-
margin-bottom: 2px;
|
250 |
-
}
|
251 |
-
|
252 |
-
.meow-sized-images:after {
|
253 |
-
clear: both;
|
254 |
-
content:""; display:table;
|
255 |
-
}
|
256 |
-
|
257 |
-
.meow-sized-images + span {
|
258 |
-
position: relative;
|
259 |
-
top: -12px;
|
260 |
-
}
|
261 |
-
|
262 |
-
/* MEOW COLORS */
|
263 |
-
|
264 |
-
.meow-bk-blue {
|
265 |
-
background: #3C82C7 !important;
|
266 |
-
color: white;
|
267 |
-
}
|
268 |
-
|
269 |
-
.meow-bk-orange {
|
270 |
-
background: #f1900e !important;
|
271 |
-
color: white;
|
272 |
-
}
|
273 |
-
|
274 |
-
.meow-bk-red {
|
275 |
-
background: #c53a47 !important;
|
276 |
-
color: white;
|
277 |
-
}
|
278 |
-
|
279 |
-
.meow-bk-gray {
|
280 |
-
background: gray !important;
|
281 |
-
color: white;
|
282 |
-
}
|
283 |
-
|
284 |
-
.meow-bk-green {
|
285 |
-
background: #2b9463 !important;
|
286 |
-
color: white;
|
287 |
-
}
|
288 |
-
|
289 |
-
.meow-bk-black {
|
290 |
-
background: #3c3c3c !important;
|
291 |
-
color: white;
|
292 |
-
}
|
293 |
-
|
294 |
-
.meow-bk-purple {
|
295 |
-
background: #984c96 !important;
|
296 |
-
color: white;
|
297 |
-
}
|
298 |
-
|
299 |
-
/* DASHBOARD */
|
300 |
-
|
301 |
-
.meow-dashboard {
|
302 |
-
box-sizing: border-box;
|
303 |
-
}
|
304 |
-
|
305 |
-
.meow-dashboard .meow-box ul {
|
306 |
-
padding: 0px;
|
307 |
-
margin: 0px;
|
308 |
-
}
|
309 |
-
|
310 |
-
.meow-featured-plugins .meow-box li {
|
311 |
-
min-height: 80px;
|
312 |
-
}
|
313 |
-
|
314 |
-
.meow-dashboard .meow-box li {
|
315 |
-
border-bottom: 1px solid #eee;
|
316 |
-
margin: 0px;
|
317 |
-
padding: 10px;
|
318 |
-
box-sizing: border-box;
|
319 |
-
}
|
320 |
-
|
321 |
-
.meow-dashboard .meow-box li img {
|
322 |
-
width: 80px;
|
323 |
-
height: 80px;
|
324 |
-
float: left;
|
325 |
-
margin: -10px 10px -10px -10px;
|
326 |
-
|
327 |
-
}
|
328 |
-
|
329 |
-
.meow-dashboard .meow-box li:last-child {
|
330 |
-
border: none;
|
331 |
-
padding-bottom: 0px;
|
332 |
-
}
|
333 |
-
|
334 |
-
.meow-button-xs .dashicons {
|
335 |
-
font-size: 18px !important;
|
336 |
-
}
|
337 |
-
|
338 |
-
.meow-button-xs.updating-message:before {
|
339 |
-
margin-top: 0px !important;
|
340 |
-
}
|
341 |
-
|
342 |
-
.meow-button-xs.updating-message * {
|
343 |
-
display: none;
|
344 |
-
}
|
345 |
-
|
346 |
-
#phpinfo {
|
347 |
-
font-size: 11px;
|
348 |
-
}
|
349 |
-
|
350 |
-
#phpinfo .e {
|
351 |
-
padding: 5px;
|
352 |
-
background: lightgray;
|
353 |
-
}
|
354 |
-
|
355 |
-
#phpinfo .h th {
|
356 |
-
padding: 5px;
|
357 |
-
color: white;
|
358 |
-
background: gray;
|
359 |
-
text-align: left;
|
360 |
-
font-size: 14px !important;
|
361 |
-
}
|
362 |
-
|
363 |
-
#phpinfo h1 {
|
364 |
-
padding: 10px 0px;
|
365 |
-
font-weight: bold;
|
366 |
-
}
|
367 |
-
|
368 |
-
#phpinfo h2 {
|
369 |
-
padding: 10px 0px;
|
370 |
-
font-weight: bold;
|
371 |
-
font-size: 20px;
|
372 |
-
}
|
373 |
-
|
374 |
-
#error_log {
|
375 |
-
font-size: 12px;
|
376 |
-
}
|
377 |
-
|
378 |
-
/* ROWS AND COLUMNS */
|
379 |
-
.meow-col { display: block; float:left; margin: 1% 0 1% 1.6%; }
|
380 |
-
.meow-col:first-child { margin-left: 0; }
|
381 |
-
|
382 |
-
/* GROUPING */
|
383 |
-
.meow-row { clear: both; padding: 0px; margin: 0px; }
|
384 |
-
.meow-row:before,
|
385 |
-
.meow-row:after { content:""; display:table; }
|
386 |
-
.meow-row:after { clear:both; }
|
387 |
-
.meow-row { zoom:1; /* For IE 6/7 */ }
|
388 |
-
|
389 |
-
/* GRID OF THREE */
|
390 |
-
.meow-span_3_of_3 { width: 100%; }
|
391 |
-
.meow-span_2_of_3 { width: 66.1%; }
|
392 |
-
.meow-span_1_of_3 { width: 32.2%; }
|
393 |
-
|
394 |
-
/* GRID OF TWO */
|
395 |
-
.meow-span_2_of_2 { width: 100%; }
|
396 |
-
.meow-span_1_of_2 { width: 49.2%; }
|
397 |
-
|
398 |
-
@media only screen and (max-width: 480px) {
|
399 |
-
.meow-col { margin: 0 0 0px 0;}
|
400 |
-
.meow-span_3_of_3, .meow-span_2_of_3, .meow-span_1_of_3 { width: 100%; }
|
401 |
-
.meow-span_2_of_2, .meow-span_1_of_2 { width: 100%; }
|
402 |
-
.meow-header-ad { display: none !important; }
|
403 |
-
.meow-box [type="text"] { width: 100% !important; }
|
404 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
common/admin.php
CHANGED
@@ -1,150 +1,78 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
if ( !class_exists( '
|
4 |
|
5 |
-
class
|
6 |
-
|
7 |
-
public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
|
8 |
|
9 |
public static $loaded = false;
|
10 |
-
public static $admin_version = "
|
11 |
|
12 |
public $prefix; // prefix used for actions, filters (mfrh)
|
13 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
14 |
public $domain; // domain used for translation (media-file-renamer)
|
|
|
|
|
|
|
15 |
|
16 |
-
public function __construct( $prefix, $mainfile, $domain, $disableReview = false ) {
|
17 |
|
18 |
// Core Admin (used by all Meow Apps plugins)
|
19 |
-
if ( !
|
20 |
if ( is_admin() ) {
|
21 |
add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
|
22 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
23 |
-
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ) );
|
24 |
-
add_action( 'wp_ajax_meow_perf_load', array( $this, 'wp_ajax_meow_perf_load' ) );
|
25 |
-
add_action( 'wp_ajax_meow_file_check', array( $this, 'wp_ajax_meow_file_check' ) );
|
26 |
if ( isset( $_GET['page'] ) && $_GET['page'] === 'meowapps-main-menu' ) {
|
27 |
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 100000, 1 );
|
28 |
}
|
29 |
}
|
30 |
-
|
|
|
|
|
|
|
31 |
}
|
32 |
|
33 |
// Variables for this plugin
|
34 |
$this->prefix = $prefix;
|
35 |
$this->mainfile = $mainfile;
|
36 |
$this->domain = $domain;
|
37 |
-
$this->
|
38 |
|
39 |
// If there is no mainfile, it's either a Pro only Plugin (with no Free version available) or a Theme.
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
}
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
add_filter( 'edd_sl_api_request_verify_ssl', array( $this, 'request_verify_ssl' ), 10, 0 );
|
57 |
}
|
58 |
|
59 |
-
function
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
$
|
65 |
-
|
66 |
-
|
67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
}
|
69 |
|
70 |
function request_verify_ssl() {
|
71 |
return get_option( 'force_sslverify', false );
|
72 |
}
|
73 |
|
74 |
-
function show_meowapps_create_rating_date() {
|
75 |
-
delete_option( 'meowapps_hide_meowapps' );
|
76 |
-
$this->create_rating_date();
|
77 |
-
}
|
78 |
-
|
79 |
-
function create_rating_date() {
|
80 |
-
$rating_date = get_option( $this->prefix . '_rating_date' );
|
81 |
-
if ( empty( $rating_date ) ) {
|
82 |
-
$two_months = strtotime( '+2 months' );
|
83 |
-
$six_months = strtotime( '+4 months' );
|
84 |
-
$rating_date = mt_rand( $two_months, $six_months );
|
85 |
-
update_option( $this->prefix . '_rating_date', $rating_date, false );
|
86 |
-
}
|
87 |
-
return $rating_date;
|
88 |
-
}
|
89 |
-
|
90 |
-
function admin_notices_rating() {
|
91 |
-
if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) {
|
92 |
-
$two_weeks = strtotime( '+2 weeks' );
|
93 |
-
$six_weeks = strtotime( '+6 weeks' );
|
94 |
-
$future_date = mt_rand( $two_weeks, $six_weeks );
|
95 |
-
update_option( $this->prefix . '_rating_date', $future_date, false );
|
96 |
-
return;
|
97 |
-
}
|
98 |
-
else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) {
|
99 |
-
$twenty_years = strtotime( '+5 years' );
|
100 |
-
update_option( $this->prefix . '_rating_date', $twenty_years, false );
|
101 |
-
return;
|
102 |
-
}
|
103 |
-
else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) {
|
104 |
-
$twenty_years = strtotime( '+10 years' );
|
105 |
-
update_option( $this->prefix . '_rating_date', $twenty_years, false );
|
106 |
-
return;
|
107 |
-
}
|
108 |
-
$rating_date = get_option( $this->prefix . '_rating_date' );
|
109 |
-
echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
|
110 |
-
echo '<p style="font-size: 100%;">';
|
111 |
-
printf(
|
112 |
-
// translators: %1$s is a plugin nicename, %2$s is a short url (slug)
|
113 |
-
__( 'You have been using <b>%1$s</b> for some time now. Thank you! Could you kindly share your opinion with me, along with, maybe, features you would like to see implemented? Then, please <a style="font-weight: bold; color: #b926ff;" target="_blank" href="https://wordpress.org/support/plugin/%2$s/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation, and I will get back to you :) <u>In the case you already have written a review</u>, please check again. Many reviews got removed from WordPress recently.', $this->domain ),
|
114 |
-
$this->nice_name_from_file( $this->mainfile ),
|
115 |
-
$this->nice_short_url_from_file( $this->mainfile )
|
116 |
-
);
|
117 |
-
echo '<p>
|
118 |
-
<form method="post" action="" style="float: right;">
|
119 |
-
<input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
|
120 |
-
<input type="submit" name="submit" id="submit" class="button button-red" value="'
|
121 |
-
. __( 'Never remind me!', $this->domain ) . '">
|
122 |
-
</form>
|
123 |
-
<form method="post" action="" style="float: right; margin-right: 10px;">
|
124 |
-
<input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
|
125 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
126 |
-
. __( 'Remind me in a few weeks...', $this->domain ) . '">
|
127 |
-
</form>
|
128 |
-
<form method="post" action="" style="float: right; margin-right: 10px;">
|
129 |
-
<input type="hidden" name="' . $this->prefix . '_did_it" value="true">
|
130 |
-
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
131 |
-
. __( 'Yes, I did it!', $this->domain ) . '">
|
132 |
-
</form>
|
133 |
-
<div style="clear: both;"></div>
|
134 |
-
</p>
|
135 |
-
';
|
136 |
-
echo '</div>';
|
137 |
-
}
|
138 |
-
|
139 |
-
function nice_short_url_from_file( $file ) {
|
140 |
-
$info = pathinfo( $file );
|
141 |
-
if ( !empty( $info ) ) {
|
142 |
-
$info['filename'] = str_replace( '-pro', '', $info['filename'] );
|
143 |
-
return $info['filename'];
|
144 |
-
}
|
145 |
-
return "";
|
146 |
-
}
|
147 |
-
|
148 |
function nice_name_from_file( $file ) {
|
149 |
$info = pathinfo( $file );
|
150 |
if ( !empty( $info ) ) {
|
@@ -163,9 +91,8 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
163 |
delete_option( $this->prefix . '_license' );
|
164 |
return;
|
165 |
}
|
166 |
-
echo '<div class="error">';
|
167 |
printf(
|
168 |
-
// translators: %s is a plugin nicename
|
169 |
__( '<p>It looks like you are using the free version of the plugin (<b>%s</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.', $this->domain ),
|
170 |
$this->nice_name_from_file( $this->mainfile ) );
|
171 |
echo '<p>
|
@@ -179,103 +106,29 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
179 |
echo '</div>';
|
180 |
}
|
181 |
|
182 |
-
function display_ads() {
|
183 |
-
return !get_option( 'meowapps_hide_ads', false );
|
184 |
-
}
|
185 |
-
|
186 |
-
function display_title( $title = "Meow Apps",
|
187 |
-
$author = "By <a style='text-decoration: none;' href='https://meowapps.com' target='_blank'>Jordy Meow</a>" ) {
|
188 |
-
if ( !empty( $this->prefix ) && $title !== "Meow Apps" )
|
189 |
-
$title = apply_filters( $this->prefix . '_plugin_title', $title );
|
190 |
-
if ( $this->display_ads() ) {
|
191 |
-
}
|
192 |
-
?>
|
193 |
-
<h1 style="line-height: 16px;">
|
194 |
-
<img width="42" style="margin-right: 10px; float: left; position: relative; top: -5px;"
|
195 |
-
src="<?php echo MeowApps_Admin::$logo ?>"><?php echo $title; ?><br />
|
196 |
-
<span style="font-size: 12px"><?php echo $author; ?></span>
|
197 |
-
</h1>
|
198 |
-
<div style="clear: both;"></div>
|
199 |
-
<?php
|
200 |
-
}
|
201 |
-
|
202 |
-
function admin_enqueue_scripts() {
|
203 |
-
wp_register_style( 'meowapps-core-css', $this->common_url( 'admin.css' ) );
|
204 |
-
wp_enqueue_style( 'meowapps-core-css' );
|
205 |
-
}
|
206 |
-
|
207 |
function admin_menu_start() {
|
|
|
208 |
if ( get_option( 'meowapps_hide_meowapps', false ) ) {
|
209 |
register_setting( 'general', 'meowapps_hide_meowapps' );
|
210 |
add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
|
211 |
return;
|
212 |
}
|
213 |
|
214 |
-
//
|
215 |
global $submenu;
|
216 |
if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
|
217 |
-
add_menu_page( 'Meow Apps', '<img alt="Meow Apps" style="width: 24px; margin-left: -30px; position: absolute; margin-top: -3px;" src="' .
|
218 |
array( $this, 'admin_meow_apps' ), '', 82 );
|
219 |
add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', $this->domain ),
|
220 |
__( 'Dashboard', $this->domain ), 'manage_options',
|
221 |
'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
|
222 |
}
|
223 |
-
|
224 |
-
add_settings_section( 'meowapps_common_settings', null, null, 'meowapps_common_settings-menu' );
|
225 |
-
add_settings_field( 'meowapps_hide_meowapps', __( 'Main Menu', $this->domain ),
|
226 |
-
array( $this, 'meowapps_hide_dashboard_callback' ),
|
227 |
-
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
228 |
-
add_settings_field( 'meowapps_force_sslverify', __( 'SSL Verify', $this->domain ),
|
229 |
-
array( $this, 'meowapps_force_sslverify_callback' ),
|
230 |
-
'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
231 |
-
// add_settings_field( 'meowapps_hide_ads', __( 'Ads', $this->domain ),
|
232 |
-
// array( $this, 'meowapps_hide_ads_callback' ),
|
233 |
-
// 'meowapps_common_settings-menu', 'meowapps_common_settings' );
|
234 |
-
register_setting( 'meowapps_common_settings', 'force_sslverify' );
|
235 |
-
register_setting( 'meowapps_common_settings', 'meowapps_hide_meowapps' );
|
236 |
-
register_setting( 'meowapps_common_settings', 'meowapps_hide_ads' );
|
237 |
-
}
|
238 |
-
|
239 |
-
function meowapps_hide_ads_callback() {
|
240 |
-
$value = get_option( 'meowapps_hide_ads', null );
|
241 |
-
$html = '<input type="checkbox" id="meowapps_hide_ads" name="meowapps_hide_ads" value="1" ' .
|
242 |
-
checked( 1, get_option( 'meowapps_hide_ads' ), false ) . '/>';
|
243 |
-
$html .= __( '<label>Hide</label><br /><small>Doesn\'t display the ads.</small>', $this->domain );
|
244 |
-
echo $html;
|
245 |
}
|
246 |
|
247 |
function meowapps_hide_dashboard_callback() {
|
248 |
-
$value = get_option( 'meowapps_hide_meowapps', null );
|
249 |
$html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
|
250 |
checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
|
251 |
$html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
|
252 |
-
echo $html;
|
253 |
-
}
|
254 |
-
|
255 |
-
function meowapps_force_sslverify_callback() {
|
256 |
-
$value = get_option( 'force_sslverify', null );
|
257 |
-
$html = '<input type="checkbox" id="force_sslverify" name="force_sslverify" value="1" ' .
|
258 |
-
checked( 1, get_option( 'force_sslverify' ), false ) . '/>';
|
259 |
-
$html .= __( '<label>Force</label><br /><small>Updates and licenses checks are usually made without checking SSL certificates and it is actually fine this way. But if you are intransigent when it comes to SSL matters, this option will force it.</small>', $this->domain );
|
260 |
-
echo $html;
|
261 |
-
}
|
262 |
-
|
263 |
-
function display_serialkey_box( $url = "https://meowapps.com/" ) {
|
264 |
-
$html = '<div class="meow-box">';
|
265 |
-
$html .= '<h3 class="' . ( $this->is_registered( $this->prefix ) ? 'meow-bk-blue' : 'meow-bk-red' ) . '">'
|
266 |
-
. __( 'Pro Version', $this->domain ) . ' '
|
267 |
-
. ( $this->is_registered( $this->prefix ) ? __( '(enabled)', $this->domain ) : __( '(disabled)', $this->domain ) )
|
268 |
-
. '</h3>';
|
269 |
-
$html .= '<div class="inside">';
|
270 |
-
echo $html;
|
271 |
-
$html = apply_filters(
|
272 |
-
$this->prefix . '_meowapps_license_input',
|
273 |
-
sprintf(
|
274 |
-
// translators: %1$s is a url attribute, %2$s is a url visible for user
|
275 |
-
__( 'More information about the Pro version here: <a target="_blank" href="%1$s">%2$s</a>. If you actually bought the Pro version already, please remove the current plugin and download the Pro version from your account at the <a target="_blank" href="https://store.meowapps.com/account/downloads/">Meow Apps Store</a>.', $this->domain ), $url, $url ),
|
276 |
-
$url );
|
277 |
-
$html .= '</div>';
|
278 |
-
$html .= '</div>';
|
279 |
echo $html;
|
280 |
}
|
281 |
|
@@ -283,342 +136,81 @@ if ( !class_exists( 'MeowApps_Admin' ) ) {
|
|
283 |
return apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix );
|
284 |
}
|
285 |
|
286 |
-
function
|
287 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
288 |
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
}
|
297 |
-
|
298 |
-
|
299 |
-
$plugin = $plugin . "-pro";
|
300 |
-
}
|
301 |
-
|
302 |
-
$plugin_file = $plugin . '/' . $plugin . '.php';
|
303 |
-
if ( is_plugin_active( $plugin_file ) ) {
|
304 |
-
if ( $plugin == 'wplr-sync' )
|
305 |
-
$pro = true;
|
306 |
-
if ( $pro )
|
307 |
-
return "<small><span style='float: right;'><span class='dashicons dashicons-heart' style='color: rgba(255, 63, 0, 1); font-size: 30px !important; margin-right: 10px;'></span></span></small>";
|
308 |
-
else
|
309 |
-
return "<small><span style='float: right;'><span class='dashicons dashicons-yes' style='color: #00b4ff; font-size: 30px !important; margin-right: 10px;'></span></span></small>";
|
310 |
}
|
311 |
else {
|
312 |
-
$
|
313 |
-
|
314 |
-
|
315 |
-
(
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
}
|
325 |
-
|
326 |
-
function meowapps_logo_url() {
|
327 |
-
return $this->common_url( 'img/meowapps.png' );
|
328 |
-
}
|
329 |
-
|
330 |
-
function plugins_loaded() {
|
331 |
-
if ( isset( $_GET[ 'tool' ] ) && $_GET[ 'tool' ] == 'error_log' ) {
|
332 |
-
$sec = "5";
|
333 |
-
header( "Refresh: $sec;" );
|
334 |
}
|
335 |
}
|
336 |
|
337 |
function admin_meow_apps() {
|
|
|
|
|
|
|
|
|
|
|
338 |
|
339 |
-
echo
|
340 |
-
|
341 |
-
|
342 |
-
echo '<div id="phpinfo">';
|
343 |
-
ob_start();
|
344 |
-
phpinfo();
|
345 |
-
$pinfo = ob_get_contents();
|
346 |
-
ob_end_clean();
|
347 |
-
$pinfo = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $pinfo );
|
348 |
-
echo $pinfo;
|
349 |
-
echo "</div>";
|
350 |
-
}
|
351 |
-
else if ( isset( $_GET['tool'] ) && $_GET['tool'] == 'error_log' ) {
|
352 |
-
$log_msg = __( '=== MEOW APPS DEBUG (This is not an error) ===', $this->domain );
|
353 |
-
if ( isset( $_POST['write_logs'] ) ) {
|
354 |
-
error_log( $log_msg );
|
355 |
-
}
|
356 |
-
$errorpath = ini_get( 'error_log' );
|
357 |
-
echo "<a href=\"javascript:history.go(-1)\">< ". __( 'Go back', $this->domain ) . "</a><br /><br />";
|
358 |
-
echo '
|
359 |
-
<form method="post">
|
360 |
-
<input type="hidden" name="write_logs" value="true">
|
361 |
-
<input class="button button-primary" type="submit" value=" ' . __( 'Write in the Error Logs', $this->domain ) . '">
|
362 |
-
</form><br />';
|
363 |
-
echo '<div id="error_log">';
|
364 |
-
if ( file_exists( $errorpath ) ) {
|
365 |
-
printf(
|
366 |
-
// translators: %s is a preformatted timestamp
|
367 |
-
__( "Now (auto-reload every 5 seconds): [%s UTC]", $this->domain ),
|
368 |
-
date( "d-M-Y H:i:s", time() )
|
369 |
-
);
|
370 |
-
echo "<br /><br /><h2 style='margin: 0px;'>" . __( 'Errors (order by latest)', $this->domain ) . "</h2>";
|
371 |
-
$errors = file_get_contents( $errorpath );
|
372 |
-
$errors = explode( "\n", $errors );
|
373 |
-
$errors = array_reverse( $errors );
|
374 |
-
$errors = implode( "<br />", $errors );
|
375 |
-
echo $errors;
|
376 |
-
}
|
377 |
-
else {
|
378 |
-
_e( "The PHP Error Logs cannot be found. Please ask your hosting service for it.", $this->domain );
|
379 |
-
}
|
380 |
-
echo "</div>";
|
381 |
-
|
382 |
-
}
|
383 |
-
else {
|
384 |
-
|
385 |
-
?>
|
386 |
-
<?php $this->display_title( 'Meow Apps' ); ?>
|
387 |
-
<p>
|
388 |
-
<?php _e( 'Meow Apps is run by Jordy Meow, a photographer and software developer living in Japan (and taking <a target="_blank" href="http://offbeatjapan.org">a lot of photos</a>). Meow Apps is a suite of plugins focusing on photography, imaging, optimization and it teams up with the best players in the community (other themes and plugins developers). For more information, please check <a href="http://meowapps.com" target="_blank">Meow Apps</a>.', $this->domain )
|
389 |
-
?>
|
390 |
-
</p>
|
391 |
-
|
392 |
-
<h2 style="margin-bottom: 0px; margin-top: 25px;"><?php _e( 'Recommended Meow Apps Plugins', $this->domain ); ?></h2>
|
393 |
-
<div class="meow-row meow-featured-plugins">
|
394 |
-
<div class="meow-box meow-col meow-span_1_of_2">
|
395 |
-
<ul class="">
|
396 |
-
<li><img src='<?= $this->common_url( 'img/media-cleaner.jpg' ) ?>' />
|
397 |
-
<a href='https://meowapps.com/plugin/media-cleaner/'><b>Media Cleaner</b></a>
|
398 |
-
<?php echo $this->check_install( 'media-cleaner' ) ?><br />
|
399 |
-
<?php _e( 'Very complex plugin which analyzes your WordPress deeply to find out which files are in use, or not. Then you can trash them, before deleting them permanently.', $this->domain ); ?></li>
|
400 |
-
<li><img src='<?= $this->common_url( 'img/media-file-renamer.jpg' ) ?>' />
|
401 |
-
<a href='https://meowapps.com/plugin/media-file-renamer/'><b>Media File Renamer</b></a>
|
402 |
-
<?php echo $this->check_install( 'media-file-renamer' ) ?><br />
|
403 |
-
<?php _e( 'The Renamer will help you in getting nicer filenames, a better SEO and well-organized files. Extremely popular.', $this->domain ); ?></li>
|
404 |
-
<li><img src='<?= $this->common_url( 'img/default.png' ) ?>' />
|
405 |
-
<a href='https://meowapps.com/plugin/contact-form-block/'><b>Contact Form Block</b></a>
|
406 |
-
<?php echo $this->check_install( 'contact-form-block' ) ?><br />
|
407 |
-
<?php _e( 'A simpler, nicer, prettier contact form. If you simply want your visitors to get in touch with you, this very light plugin will make your life easier.', $this->domain ); ?></li>
|
408 |
-
<li><img src='<?= $this->common_url( 'img/default.png' ) ?>' />
|
409 |
-
<a href='https://meowapps.com/plugin/meow-analytics/'><b>Meow Analytics</b></a>
|
410 |
-
<?php echo $this->check_install( 'meow-analytics' ) ?><br />
|
411 |
-
<?php _e( 'Tired of those fat plugins which are messing-up with your install? Switch to Meow Analytics, it\'s extremely light and features a cute dashboard.', $this->domain ); ?></li>
|
412 |
-
</ul>
|
413 |
-
</div>
|
414 |
-
<div class="meow-box meow-col meow-span_1_of_2 ">
|
415 |
-
<ul class="">
|
416 |
-
<li><img src='<?= $this->common_url( 'img/meow-gallery.jpg' ) ?>' />
|
417 |
-
<a href='https://meowapps.com/plugin/meow-gallery/'><b>Meow Gallery</b></a>
|
418 |
-
<?php echo $this->check_install( 'meow-gallery' ) ?><br />
|
419 |
-
<?php _e( 'Beautiful but lightweight gallery with many layouts. The only one that allows you to uninstall it without losing anything.', $this->domain ); ?></li>
|
420 |
-
<li><img src='<?= $this->common_url( 'img/meow-lightbox.jpg' ) ?>' />
|
421 |
-
<a href='https://meowapps.com/plugin/meow-lightbox/'><b>Meow Lightbox</b></a>
|
422 |
-
<?php echo $this->check_install( 'meow-lightbox' ) ?><br />
|
423 |
-
<?php _e( 'A very smooth and fast Lightbox which will also display your EXIF data (camera, lens, etc). Try it, you will love it.', $this->domain ); ?></li>
|
424 |
-
<li><img src='<?= $this->common_url( 'img/wplr-sync.jpg' ) ?>' />
|
425 |
-
<a href='https://meowapps.com/plugin/wplr-sync/'><b>WP/LR Sync</b></a>
|
426 |
-
<?php echo $this->check_install( 'wplr-sync' ) ?><br />
|
427 |
-
<?php _e( 'Synchronize your Lightroom to your WordPress. This plugin is loved by a huge community of photographers.', $this->domain ); ?></li>
|
428 |
-
<li><img src='<?= $this->common_url( 'img/wp-retina-2x.jpg' ) ?>' />
|
429 |
-
<a href='https://meowapps.com/plugin/wp-retina-2x/'><b>WP Retina 2x</b></a>
|
430 |
-
<?php echo $this->check_install( 'wp-retina-2x' ) ?><br />
|
431 |
-
<?php _e( 'Here is the very famous plugin that adds Retina support to any website.', $this->domain ); ?></li>
|
432 |
-
</ul>
|
433 |
-
</div>
|
434 |
-
</div>
|
435 |
-
|
436 |
-
<h2><?php _e( 'WordPress Performance', $this->domain ); ?></h2>
|
437 |
-
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-bottom: 15px;">
|
438 |
-
<p><?php _e( 'The <b>Empty Request Time</b> helps you analyzing the raw performance of your install by giving you the average time it takes to run an empty request to your server. You can try to disable some plugins (or change their options) then and click on Reset to see how it influences the results. With <b>File Operation Time</b>, you will find out if your server is slow with files. An excellent install would have an Empty Request Time of less than 500 ms. Keep it absolutely under 2,000 ms. File Operation Time should take only a few milliseconds more than the Empty Request Time. For more information about this, <a href="https://meowapps.com/clean-optimize-wordpress/#Optimize_your_Empty_Request_Time" target="_blank">click here</a>.', $this->domain ); ?></p>
|
439 |
-
</div>
|
440 |
-
|
441 |
-
<div>
|
442 |
-
|
443 |
-
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
444 |
-
<div style='font-size: 14px; line-height: 14px; margin-bottom: 20px;'><?php _e( 'Empty Request Time', $this->domain ); ?></div>
|
445 |
-
<div style='font-size: 32px; line-height: 32px; margin-bottom: 10px;' id='meow-perf-load-average'><?php _e( 'N/A', $this->domain ); ?></div>
|
446 |
-
<div style='font-size: 12px; line-height: 12px; margin-bottom: 20px;'><?php _e( 'Based on', $this->domain ); ?>
|
447 |
-
<span id='meow-perf-load-count'>0</span> <?php _e( 'request(s)', $this->domain ); ?>
|
448 |
-
</div>
|
449 |
-
<input type='submit' style='text-align: center; width: 100%;' id="meow-perf-reset" value="Reset" class="button button-primary">
|
450 |
-
</div>
|
451 |
-
|
452 |
-
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
453 |
-
<div style='font-size: 14px; line-height: 14px; margin-bottom: 20px;'><?php _e( 'File Operation Time', $this->domain ); ?></div>
|
454 |
-
<div style='font-size: 32px; line-height: 32px; margin-bottom: 10px;' id='meow-file-check-time'><?php _e( 'N/A', $this->domain ); ?></div>
|
455 |
-
<div style='font-size: 12px; line-height: 12px; margin-bottom: 20px;'><?php _e( 'Create temporary file and delete it.', $this->domain ); ?></div>
|
456 |
-
<input type='submit' style='text-align: center; width: 100%;' id="meow-file-check-start" value="<?php _e( 'Check', $this->domain ); ?>" class="button button-primary">
|
457 |
-
</div>
|
458 |
-
|
459 |
-
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
460 |
-
<a target='_blank' href='https://kinsta.com/?kaid=MFROFDOOINML'>
|
461 |
-
<img style='height: 116px;' src='<?= $this->common_url( 'img/kinsta.png' ) ?>'>
|
462 |
-
<div>Meow's 2020 Favorite Hosting</div>
|
463 |
-
</a>
|
464 |
-
</div>
|
465 |
-
|
466 |
-
<div style="float: left; margin-right: 10px; text-align: center; padding: 10px; background: white; width: 200px; border: 1px solid #e2e2e2;">
|
467 |
-
<a target='_blank' href='https://tracking.maxcdn.com/rPK13'>
|
468 |
-
<img style='height: 116px;' src='<?= $this->common_url( 'img/stackpath.png' ) ?>'>
|
469 |
-
<div>Meow's 2020 Favorite CDN</div>
|
470 |
-
</a>
|
471 |
-
</div>
|
472 |
-
|
473 |
-
<div style="clear: both;"></div>
|
474 |
-
|
475 |
-
</div>
|
476 |
-
|
477 |
-
<script>
|
478 |
-
(function ($) {
|
479 |
-
var calls = 0;
|
480 |
-
var times = [];
|
481 |
-
|
482 |
-
$('#meow-perf-reset').on('click', function () {
|
483 |
-
calls = 0;
|
484 |
-
times = [];
|
485 |
-
$('#meow-perf-load-average').text('<?php _e( "N/A", $this->domain ); ?>');
|
486 |
-
$('#meow-perf-load-count').text('0');
|
487 |
-
});
|
488 |
-
|
489 |
-
function perfLoad() {
|
490 |
-
var start = new Date().getTime();
|
491 |
-
$.ajax(ajaxurl, {
|
492 |
-
method: 'post',
|
493 |
-
dataType: 'json',
|
494 |
-
data: {
|
495 |
-
action: 'meow_perf_load',
|
496 |
-
}
|
497 |
-
}).done(function (response) {
|
498 |
-
var end = new Date().getTime();
|
499 |
-
var time = end - start;
|
500 |
-
calls++;
|
501 |
-
times.push(time);
|
502 |
-
var sum = times.reduce(function(a, b) { return a + b; });
|
503 |
-
var avg = Math.ceil(sum / times.length);
|
504 |
-
$('#meow-perf-load-average').text(avg + ' <?php _e( "ms", $this->domain ); ?>');
|
505 |
-
$('#meow-perf-load-count').text(calls);
|
506 |
-
setTimeout(perfLoad, 5000);
|
507 |
-
});
|
508 |
-
};
|
509 |
-
|
510 |
-
function perfFile() {
|
511 |
-
var start = new Date().getTime();
|
512 |
-
$.ajax(ajaxurl, {
|
513 |
-
method: 'post',
|
514 |
-
dataType: 'json',
|
515 |
-
data: {
|
516 |
-
action: 'meow_file_check',
|
517 |
-
}
|
518 |
-
}).done(function (response) {
|
519 |
-
var end = new Date().getTime();
|
520 |
-
var time = end - start;
|
521 |
-
$('#meow-file-check-time').text(time + ' <?php _e( "ms", $this->domain ); ?>');
|
522 |
-
$('#meow-file-check-start').text('<?php _e( "Check", $this->domain ); ?>');
|
523 |
-
});
|
524 |
-
};
|
525 |
-
|
526 |
-
$('#meow-file-check-start').on('click', function () {
|
527 |
-
$('#meow-file-check-start').text('...');
|
528 |
-
perfFile();
|
529 |
-
});
|
530 |
-
|
531 |
-
setTimeout(perfLoad, 1500);
|
532 |
-
|
533 |
-
})(jQuery);
|
534 |
-
</script>
|
535 |
-
|
536 |
-
<h2><?php _e( 'WordPress Recommendations', $this->domain ); ?></h2>
|
537 |
-
<div style="background: white; padding: 5px 15px 5px 15px; box-shadow: 2px 2px 1px rgba(0,0,0,.02); margin-top: 15px;">
|
538 |
-
<p>
|
539 |
-
<?php _e( 'Too many WordPress installs are blown-up with useless and/or huge plugins, and bad practices. But that is because most users are overwhelmed by the diversity and immensity of the WordPress jungle. One rule of thumb is to keep your install the simplest as possible, with the least number of plugins (avoiding heavy ones too) and a good hosting service (avoid VPS except if you know exactly what you are doing). Articles are kept being updated on the Meow Apps website, with all the latest recommendations: ', $this->domain )?>
|
540 |
-
<a href='https://meowapps.com/debugging-wordpress/' target='_blank'>
|
541 |
-
How To Debug</a>,
|
542 |
-
<a href='https://meowapps.com/seo-optimization/' target='_blank'>
|
543 |
-
SEO Checklist & Optimization</a>,
|
544 |
-
<a href='https://meowapps.com/clean-optimize-wordpress/' target='_blank'>
|
545 |
-
Clean Up and Optimize</a>,
|
546 |
-
<a href='https://meowapps.com/optimize-images-cdn/' target='_blank'>
|
547 |
-
Optimize Images</a>,
|
548 |
-
<a href='https://meowapps.com/best-hosting-services-wordpress/' target='_blank'>
|
549 |
-
Best Hosting Services</a>.
|
550 |
-
</p>
|
551 |
-
</div>
|
552 |
-
|
553 |
-
<h2 style="margin-bottom: 0px; margin-top: 25px;"><?php _e( 'Common Options & Tools', $this->domain ); ?></h2>
|
554 |
-
<div class="meow-row">
|
555 |
-
<div class="meow-box meow-col meow-span_2_of_3">
|
556 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Common', $this->domain ); ?></h3>
|
557 |
-
<div class="inside">
|
558 |
-
<form method="post" action="options.php">
|
559 |
-
<?php settings_fields( 'meowapps_common_settings' ); ?>
|
560 |
-
<?php do_settings_sections( 'meowapps_common_settings-menu' ); ?>
|
561 |
-
<?php submit_button(); ?>
|
562 |
-
</form>
|
563 |
-
</div>
|
564 |
-
</div>
|
565 |
-
|
566 |
-
<div class="meow-box meow-col meow-span_1_of_3">
|
567 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Debug', $this->domain ); ?></h3>
|
568 |
-
<div class="inside">
|
569 |
-
<ul>
|
570 |
-
<li><a href="?page=meowapps-main-menu&tool=error_log"><?php _e( 'Display Error Log', $this->domain ); ?></a></li>
|
571 |
-
<li><a href="?page=meowapps-main-menu&tool=phpinfo"><?php _e( 'Display PHP Info', $this->domain ); ?></a></li>
|
572 |
-
</ul>
|
573 |
-
</div>
|
574 |
-
</div>
|
575 |
-
|
576 |
-
<div class="meow-box meow-col meow-span_1_of_3">
|
577 |
-
<h3><span class="dashicons dashicons-admin-tools"></span> <?php _e( 'Post Types (used by this install)', $this->domain ); ?></h3>
|
578 |
-
<div class="inside">
|
579 |
-
<?php
|
580 |
-
global $wpdb;
|
581 |
-
// Maybe we could avoid to check more post_types.
|
582 |
-
// SELECT post_type, COUNT(*) FROM `wp_posts` GROUP BY post_type
|
583 |
-
$types = $wpdb->get_results( "SELECT post_type as 'type', COUNT(*) as 'count' FROM $wpdb->posts GROUP BY post_type" );
|
584 |
-
$result = array();
|
585 |
-
foreach( $types as $type )
|
586 |
-
array_push( $result, "{$type->type} ({$type->count})" );
|
587 |
-
echo implode( ', ', $result );
|
588 |
-
?>
|
589 |
-
</div>
|
590 |
-
</div>
|
591 |
-
</div>
|
592 |
-
|
593 |
-
<?php
|
594 |
-
}
|
595 |
}
|
596 |
|
597 |
function admin_footer_text( $current ) {
|
598 |
return sprintf(
|
599 |
// translators: %1$s is the version of the interface; %2$s is a file path.
|
600 |
__( 'Thanks for using <a href="https://meowapps.com">Meow Apps</a>! This is the Meow Admin %1$s <br /><i>Loaded from %2$s </i>', $this->domain ),
|
601 |
-
|
602 |
__FILE__
|
603 |
);
|
604 |
}
|
605 |
-
|
606 |
-
// HELPERS
|
607 |
-
|
608 |
-
static function size_shortname( $name ) {
|
609 |
-
$name = preg_split( '[_-]', $name );
|
610 |
-
$short = strtoupper( substr( $name[0], 0, 1 ) );
|
611 |
-
if ( count( $name ) > 1 )
|
612 |
-
$short .= strtoupper( substr( $name[1], 0, 1 ) );
|
613 |
-
return $short;
|
614 |
-
}
|
615 |
-
|
616 |
}
|
617 |
-
|
618 |
-
}
|
619 |
-
|
620 |
-
if ( file_exists( plugin_dir_path( __FILE__ ) . '/meowapps/admin.php' ) ) {
|
621 |
-
require( 'meowapps/admin.php' );
|
622 |
}
|
623 |
|
624 |
?>
|
1 |
<?php
|
2 |
|
3 |
+
if ( !class_exists( 'MeowCommon_Admin' ) ) {
|
4 |
|
5 |
+
class MeowCommon_Admin {
|
|
|
|
|
6 |
|
7 |
public static $loaded = false;
|
8 |
+
public static $admin_version = "3.0";
|
9 |
|
10 |
public $prefix; // prefix used for actions, filters (mfrh)
|
11 |
public $mainfile; // plugin main file (media-file-renamer.php)
|
12 |
public $domain; // domain used for translation (media-file-renamer)
|
13 |
+
public $isPro = false;
|
14 |
+
|
15 |
+
public static $logo = 'data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxIiB2aWV3Qm94PSIwIDAgMTY1IDE2NSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8c3R5bGU+CiAgICAuc3Qye2ZpbGw6IzgwNDYyNX0uc3Qze2ZpbGw6I2ZkYTk2MH0KICA8L3N0eWxlPgogIDxwYXRoIGQ9Ik03MiA3YTc2IDc2IDAgMCAxIDg0IDkxQTc1IDc1IDAgMSAxIDcyIDd6IiBmaWxsPSIjNGE2YjhjIi8+CiAgPHBhdGggZD0iTTQ4IDQ4YzIgNSAyIDEwIDUgMTQgNSA4IDEzIDE3IDIyIDIwbDEtMTBjMS0yIDMtMyA1LTNoMTNjMiAwIDQgMSA1IDNsMyA5IDQtMTBjMi0zIDYtMiA5LTJoMTFjMyAyIDMgNSAzIDhsMiAzN2MwIDMtMSA3LTQgOGgtMTJjLTIgMC0zLTItNS00LTEgMS0yIDMtNCAzLTUgMS05IDEtMTMtMS0zIDItNSAyLTkgMnMtOSAxLTEwLTNjLTItNC0xLTggMC0xMi04LTMtMTUtNy0yMi0xMi03LTctMTUtMTQtMjAtMjMtMy00LTUtOC01LTEzIDEtNCAzLTEwIDYtMTMgNC0zIDEyLTIgMTUgMnoiIGZpbGw9IiMxMDEwMTAiLz4KICA8cGF0aCBjbGFzcz0ic3QyIiBkPSJNNDMgNTFsNCAxMS02IDVoLTZjLTMtNS0zLTExIDAtMTYgMi0yIDYtMyA4IDB6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTQ3IDYybDMgNmMwIDMgMCA0LTIgNnMtNCAyLTcgMmwtNi05aDZsNi01eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik01MCA2OGw4IDljLTMgMy01IDYtOSA4bC04LTljMyAwIDUgMCA3LTJzMy0zIDItNnoiLz4KICA8cGF0aCBkPSJNODIgNzRoMTJsNSAxOCAzIDExIDgtMjloMTNsMiA0MmgtOGwtMS0yLTEtMzEtMTAgMzItNyAxLTktMzMtMSAyOS0xIDRoLThsMy00MnoiIGZpbGw9IiNmZmYiLz4KICA8cGF0aCBjbGFzcz0ic3QzIiBkPSJNNTggNzdsNSA1Yy0xIDQtMiA4LTcgOGwtNy01YzQtMiA2LTUgOS04eiIvPgogIDxwYXRoIGNsYXNzPSJzdDIiIGQ9Ik02MyA4Mmw5IDUtNiA5LTEwLTZjNSAwIDYtNCA3LTh6Ii8+CiAgPHBhdGggY2xhc3M9InN0MyIgZD0iTTcyIDg3bDMgMS0xIDExLTgtMyA2LTEweiIvPgo8L3N2Zz4K';
|
16 |
|
17 |
+
public function __construct( $prefix, $mainfile, $domain, $isPro = false, $disableReview = false ) {
|
18 |
|
19 |
// Core Admin (used by all Meow Apps plugins)
|
20 |
+
if ( !MeowCommon_Admin::$loaded ) {
|
21 |
if ( is_admin() ) {
|
22 |
add_action( 'admin_menu', array( $this, 'admin_menu_start' ) );
|
|
|
|
|
|
|
|
|
23 |
if ( isset( $_GET['page'] ) && $_GET['page'] === 'meowapps-main-menu' ) {
|
24 |
add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ), 100000, 1 );
|
25 |
}
|
26 |
}
|
27 |
+
if ( MeowCommon_Helpers::is_rest() ) {
|
28 |
+
new MeowCommon_Classes_Rest( $this );
|
29 |
+
}
|
30 |
+
MeowCommon_Admin::$loaded = true;
|
31 |
}
|
32 |
|
33 |
// Variables for this plugin
|
34 |
$this->prefix = $prefix;
|
35 |
$this->mainfile = $mainfile;
|
36 |
$this->domain = $domain;
|
37 |
+
$this->isPro = $isPro;
|
38 |
|
39 |
// If there is no mainfile, it's either a Pro only Plugin (with no Free version available) or a Theme.
|
40 |
+
register_activation_hook( $mainfile, array( $this, 'show_meowapps_create_rating_date' ) );
|
41 |
+
if ( is_admin() ) {
|
42 |
+
$license = get_option( $this->prefix . '_license', "" );
|
43 |
+
if ( !empty( $license ) && !$this->isPro ) {
|
44 |
+
add_action( 'admin_notices', array( $this, 'admin_notices_licensed_free' ) );
|
45 |
+
}
|
46 |
+
if ( !$disableReview ) {
|
47 |
+
new MeowCommon_Classes_Ratings( $prefix, $mainfile, $domain );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
add_filter( 'plugin_row_meta', array( $this, 'custom_plugin_row_meta' ), 10, 2 );
|
|
|
|
|
|
|
|
|
|
|
51 |
add_filter( 'edd_sl_api_request_verify_ssl', array( $this, 'request_verify_ssl' ), 10, 0 );
|
52 |
}
|
53 |
|
54 |
+
function custom_plugin_row_meta( $links, $file ) {
|
55 |
+
$path = pathinfo( $file );
|
56 |
+
$pathName = basename( $path['dirname'] );
|
57 |
+
$thisPath = pathinfo( $this->mainfile );
|
58 |
+
$thisPathName = basename( $thisPath['dirname'] );
|
59 |
+
if ( strpos( $pathName, $thisPathName ) !== false ) {
|
60 |
+
$new_links = array(
|
61 |
+
'settings' =>
|
62 |
+
sprintf( __( '<a href="admin.php?page=%s_settings">Settings</a>', $this->domain ), $this->prefix ),
|
63 |
+
'license' =>
|
64 |
+
$this->is_registered() ? '<span style="color: #a75bd6;">' . __( 'Pro Version', $this->domain ) . '</span>' :
|
65 |
+
sprintf( '<span style="color: #ff3434;">' . __( 'License Issue', $this->domain ), $this->prefix ) . '</span>',
|
66 |
+
);
|
67 |
+
$links = array_merge( $new_links, $links );
|
68 |
+
}
|
69 |
+
return $links;
|
70 |
}
|
71 |
|
72 |
function request_verify_ssl() {
|
73 |
return get_option( 'force_sslverify', false );
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
function nice_name_from_file( $file ) {
|
77 |
$info = pathinfo( $file );
|
78 |
if ( !empty( $info ) ) {
|
91 |
delete_option( $this->prefix . '_license' );
|
92 |
return;
|
93 |
}
|
94 |
+
echo '<div class="notice notice-error">';
|
95 |
printf(
|
|
|
96 |
__( '<p>It looks like you are using the free version of the plugin (<b>%s</b>) but a license for the Pro version was also found. The Pro version might have been replaced by the Free version during an update (might be caused by a temporarily issue). If it is the case, <b>please download it again</b> from the <a target="_blank" href="https://store.meowapps.com">Meow Store</a>. If you wish to continue using the free version and clear this message, click on this button.', $this->domain ),
|
97 |
$this->nice_name_from_file( $this->mainfile ) );
|
98 |
echo '<p>
|
106 |
echo '</div>';
|
107 |
}
|
108 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
109 |
function admin_menu_start() {
|
110 |
+
// Hide the admin if user doesn't like Meow much
|
111 |
if ( get_option( 'meowapps_hide_meowapps', false ) ) {
|
112 |
register_setting( 'general', 'meowapps_hide_meowapps' );
|
113 |
add_settings_field( 'meowapps_hide_ads', 'Meow Apps Menu', array( $this, 'meowapps_hide_dashboard_callback' ), 'general' );
|
114 |
return;
|
115 |
}
|
116 |
|
117 |
+
// Create standard menu if it does not already exist
|
118 |
global $submenu;
|
119 |
if ( !isset( $submenu[ 'meowapps-main-menu' ] ) ) {
|
120 |
+
add_menu_page( 'Meow Apps', '<img alt="Meow Apps" style="width: 24px; margin-left: -30px; position: absolute; margin-top: -3px;" src="' . MeowCommon_Admin::$logo . '" />Meow Apps', 'manage_options', 'meowapps-main-menu',
|
121 |
array( $this, 'admin_meow_apps' ), '', 82 );
|
122 |
add_submenu_page( 'meowapps-main-menu', __( 'Dashboard', $this->domain ),
|
123 |
__( 'Dashboard', $this->domain ), 'manage_options',
|
124 |
'meowapps-main-menu', array( $this, 'admin_meow_apps' ) );
|
125 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
}
|
127 |
|
128 |
function meowapps_hide_dashboard_callback() {
|
|
|
129 |
$html = '<input type="checkbox" id="meowapps_hide_meowapps" name="meowapps_hide_meowapps" value="1" ' .
|
130 |
checked( 1, get_option( 'meowapps_hide_meowapps' ), false ) . '/>';
|
131 |
$html .= __( '<label>Hide <b>Meow Apps</b> Menu</label><br /><small>Hide Meow Apps menu and all its components, for a cleaner admin. This option will be reset if a new Meow Apps plugin is installed. <b>Once activated, an option will be added in your General settings to display it again.</b></small>', $this->domain );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
echo $html;
|
133 |
}
|
134 |
|
136 |
return apply_filters( $this->prefix . '_meowapps_is_registered', false, $this->prefix );
|
137 |
}
|
138 |
|
139 |
+
function get_phpinfo() {
|
140 |
+
ob_start();
|
141 |
+
phpinfo( INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES );
|
142 |
+
$html = ob_get_contents();
|
143 |
+
ob_end_clean();
|
144 |
+
$html = preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', $html );
|
145 |
+
echo $html;
|
146 |
+
}
|
147 |
|
148 |
+
function get_phperrorlogs() {
|
149 |
+
$errorpath = ini_get( 'error_log' );
|
150 |
+
$output_lines = array();
|
151 |
+
if ( !empty( $errorpath ) ) {
|
152 |
+
$file = new SplFileObject( $errorpath, 'r' );
|
153 |
+
$file->seek( PHP_INT_MAX );
|
154 |
+
$last_line = $file->key();
|
155 |
+
$iterator = new LimitIterator( $file, $last_line - 500, $last_line );
|
156 |
+
$lines = iterator_to_array( $iterator );
|
157 |
+
foreach ( $lines as $line ) {
|
158 |
+
$newline = '';
|
159 |
+
if ( preg_match( '/PHP Fatal/', $line ) ) {
|
160 |
+
$newline = '<div class="fatal">' . $line . '</div>';
|
161 |
+
}
|
162 |
+
else if ( preg_match( '/PHP Warning/', $line ) ) {
|
163 |
+
$newline = '<div class="warning">' . $line . '</div>';
|
164 |
+
}
|
165 |
+
else if ( preg_match( '/PHP Notice/', $line ) ) {
|
166 |
+
$newline = '<div class="notice">' . $line . '</div>';
|
167 |
+
}
|
168 |
+
else {
|
169 |
+
continue;
|
170 |
+
}
|
171 |
+
array_push( $output_lines, $newline );
|
172 |
}
|
173 |
}
|
174 |
+
if ( empty( $output_lines ) ) {
|
175 |
+
return '<div class="fatal">Your PHP Error Logs is either empty, or (more likely is not accessible through PHP. You should contact your hosting service and ask them how to get it.</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
else {
|
178 |
+
$output_lines = array_reverse( $output_lines );
|
179 |
+
$html = '';
|
180 |
+
$previous = '';
|
181 |
+
foreach ( $output_lines as $line ) {
|
182 |
+
// Let's avoid similar errors, since it's not useful. We should also make this better
|
183 |
+
// and not only theck this depending on tie.
|
184 |
+
if ( preg_replace( '/\[.*\] PHP/', '', $previous ) !== preg_replace( '/\[.*\] PHP/', '', $line ) ) {
|
185 |
+
$html .= $line;
|
186 |
+
$previous = $line;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
return $html;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
}
|
191 |
}
|
192 |
|
193 |
function admin_meow_apps() {
|
194 |
+
echo "<div id='meow-common-dashboard'></div>";
|
195 |
+
|
196 |
+
echo "<div style='display: none;' id='meow-common-phperrorlogs'>";
|
197 |
+
echo $this->get_phperrorlogs();
|
198 |
+
echo "</div>";
|
199 |
|
200 |
+
echo "<div style='display: none;' id='meow-common-phpinfo'>";
|
201 |
+
echo $this->get_phpinfo();
|
202 |
+
echo "</div>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
203 |
}
|
204 |
|
205 |
function admin_footer_text( $current ) {
|
206 |
return sprintf(
|
207 |
// translators: %1$s is the version of the interface; %2$s is a file path.
|
208 |
__( 'Thanks for using <a href="https://meowapps.com">Meow Apps</a>! This is the Meow Admin %1$s <br /><i>Loaded from %2$s </i>', $this->domain ),
|
209 |
+
MeowCommon_Admin::$admin_version,
|
210 |
__FILE__
|
211 |
);
|
212 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
213 |
}
|
|
|
|
|
|
|
|
|
|
|
214 |
}
|
215 |
|
216 |
?>
|
common/classes/ratings.php
ADDED
@@ -0,0 +1,114 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( !class_exists( 'MeowCommon_Classes_Ratings' ) ) {
|
4 |
+
|
5 |
+
class MeowCommon_Classes_Ratings {
|
6 |
+
|
7 |
+
public $mainfile; // plugin main file (media-file-renamer.php)
|
8 |
+
public $domain; // domain used for translation (media-file-renamer)
|
9 |
+
public $prefix; // used for many things (filters, options, etc)
|
10 |
+
|
11 |
+
public function __construct( $prefix, $mainfile, $domain ) {
|
12 |
+
$this->mainfile = $mainfile;
|
13 |
+
$this->domain = $domain;
|
14 |
+
$this->prefix = $prefix;
|
15 |
+
|
16 |
+
register_activation_hook( $mainfile, array( $this, 'show_meowapps_create_rating_date' ) );
|
17 |
+
|
18 |
+
if ( is_admin() ) {
|
19 |
+
$rating_date = $this->create_rating_date();
|
20 |
+
if ( time() > $rating_date ) {
|
21 |
+
add_action( 'admin_notices', array( $this, 'admin_notices_rating' ) );
|
22 |
+
}
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
function show_meowapps_create_rating_date() {
|
27 |
+
delete_option( 'meowapps_hide_meowapps' );
|
28 |
+
$this->create_rating_date();
|
29 |
+
}
|
30 |
+
|
31 |
+
function create_rating_date() {
|
32 |
+
$rating_date = get_option( $this->prefix . '_rating_date' );
|
33 |
+
if ( empty( $rating_date ) ) {
|
34 |
+
$two_months = strtotime( '+2 months' );
|
35 |
+
$six_months = strtotime( '+4 months' );
|
36 |
+
$rating_date = mt_rand( $two_months, $six_months );
|
37 |
+
update_option( $this->prefix . '_rating_date', $rating_date, false );
|
38 |
+
}
|
39 |
+
return $rating_date;
|
40 |
+
}
|
41 |
+
|
42 |
+
function admin_notices_rating() {
|
43 |
+
if ( isset( $_POST[$this->prefix . '_remind_me'] ) ) {
|
44 |
+
$two_weeks = strtotime( '+2 weeks' );
|
45 |
+
$six_weeks = strtotime( '+6 weeks' );
|
46 |
+
$future_date = mt_rand( $two_weeks, $six_weeks );
|
47 |
+
update_option( $this->prefix . '_rating_date', $future_date, false );
|
48 |
+
return;
|
49 |
+
}
|
50 |
+
else if ( isset( $_POST[$this->prefix . '_never_remind_me'] ) ) {
|
51 |
+
$twenty_years = strtotime( '+5 years' );
|
52 |
+
update_option( $this->prefix . '_rating_date', $twenty_years, false );
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
else if ( isset( $_POST[$this->prefix . '_did_it'] ) ) {
|
56 |
+
$twenty_years = strtotime( '+10 years' );
|
57 |
+
update_option( $this->prefix . '_rating_date', $twenty_years, false );
|
58 |
+
return;
|
59 |
+
}
|
60 |
+
$rating_date = get_option( $this->prefix . '_rating_date' );
|
61 |
+
echo '<div class="notice notice-success" data-rating-date="' . date( 'Y-m-d', $rating_date ) . '">';
|
62 |
+
echo '<p style="font-size: 100%;">';
|
63 |
+
printf(
|
64 |
+
// translators: %1$s is a plugin nicename, %2$s is a short url (slug)
|
65 |
+
__( 'You have been using <b>%1$s</b> for some time now. Thank you! Could you kindly share your opinion with me, along with, maybe, features you would like to see implemented? Then, please <a style="font-weight: bold; color: #b926ff;" target="_blank" href="https://wordpress.org/support/plugin/%2$s/reviews/?rate=5#new-post">write a little review</a>. That will also bring me joy and motivation! I will get back to you :)', $this->domain ),
|
66 |
+
$this->nice_name_from_file( $this->mainfile ),
|
67 |
+
$this->nice_short_url_from_file( $this->mainfile )
|
68 |
+
);
|
69 |
+
echo '<p>
|
70 |
+
<form method="post" action="" style="float: right;">
|
71 |
+
<input type="hidden" name="' . $this->prefix . '_never_remind_me" value="true">
|
72 |
+
<input type="submit" name="submit" id="submit" class="button button-red" value="'
|
73 |
+
. __( 'Never remind me!', $this->domain ) . '">
|
74 |
+
</form>
|
75 |
+
<form method="post" action="" style="float: right; margin-right: 10px;">
|
76 |
+
<input type="hidden" name="' . $this->prefix . '_remind_me" value="true">
|
77 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
78 |
+
. __( 'Remind me in a few weeks...', $this->domain ) . '">
|
79 |
+
</form>
|
80 |
+
<form method="post" action="" style="float: right; margin-right: 10px;">
|
81 |
+
<input type="hidden" name="' . $this->prefix . '_did_it" value="true">
|
82 |
+
<input type="submit" name="submit" id="submit" class="button button-primary" value="'
|
83 |
+
. __( 'Yes, I did it!', $this->domain ) . '">
|
84 |
+
</form>
|
85 |
+
<div style="clear: both;"></div>
|
86 |
+
</p>
|
87 |
+
';
|
88 |
+
echo '</div>';
|
89 |
+
}
|
90 |
+
|
91 |
+
function nice_short_url_from_file( $file ) {
|
92 |
+
$info = pathinfo( $file );
|
93 |
+
if ( !empty( $info ) ) {
|
94 |
+
$info['filename'] = str_replace( '-pro', '', $info['filename'] );
|
95 |
+
return $info['filename'];
|
96 |
+
}
|
97 |
+
return "";
|
98 |
+
}
|
99 |
+
|
100 |
+
function nice_name_from_file( $file ) {
|
101 |
+
$info = pathinfo( $file );
|
102 |
+
if ( !empty( $info ) ) {
|
103 |
+
if ( $info['filename'] == 'wplr-sync' ) {
|
104 |
+
return "WP/LR Sync";
|
105 |
+
}
|
106 |
+
$info['filename'] = str_replace( '-', ' ', $info['filename'] );
|
107 |
+
$file = ucwords( $info['filename'] );
|
108 |
+
}
|
109 |
+
return $file;
|
110 |
+
}
|
111 |
+
}
|
112 |
+
}
|
113 |
+
|
114 |
+
?>
|
common/classes/rest.php
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MeowCommon_Classes_Rest
|
4 |
+
{
|
5 |
+
private $namespace = null;
|
6 |
+
|
7 |
+
public function __construct( &$admin ) {
|
8 |
+
$this->admin = $admin;
|
9 |
+
$this->namespace = "meow-common/v1";
|
10 |
+
if ( !current_user_can( 'administrator' ) ) {
|
11 |
+
return;
|
12 |
+
}
|
13 |
+
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
function rest_api_init() {
|
17 |
+
register_rest_route( $this->namespace, '/empty_request/', [
|
18 |
+
'methods' => 'POST',
|
19 |
+
'callback' => [ $this, 'empty_request' ]
|
20 |
+
]);
|
21 |
+
register_rest_route( $this->namespace, '/file_operation/', [
|
22 |
+
'methods' => 'POST',
|
23 |
+
'callback' => [ $this, 'file_operation' ]
|
24 |
+
]);
|
25 |
+
register_rest_route( $this->namespace, '/sql_request/', [
|
26 |
+
'methods' => 'POST',
|
27 |
+
'callback' => [ $this, 'sql_request' ]
|
28 |
+
]);
|
29 |
+
register_rest_route( $this->namespace, '/all_settings/', [
|
30 |
+
'methods' => 'GET',
|
31 |
+
'callback' => [ $this, 'rest_all_settings' ]
|
32 |
+
]);
|
33 |
+
register_rest_route( $this->namespace, '/update_option/', [
|
34 |
+
'methods' => 'POST',
|
35 |
+
'callback' => [ $this, 'rest_update_option' ]
|
36 |
+
]);
|
37 |
+
}
|
38 |
+
|
39 |
+
function file_rand( $filesize ) {
|
40 |
+
$tmp_file = tmpfile();
|
41 |
+
fseek( $tmp_file, $filesize - 1, SEEK_CUR );
|
42 |
+
fwrite( $tmp_file, 'a');
|
43 |
+
fclose( $tmp_file );
|
44 |
+
}
|
45 |
+
|
46 |
+
function empty_request() {
|
47 |
+
return new WP_REST_Response( [ 'success' => true ], 200 );
|
48 |
+
}
|
49 |
+
|
50 |
+
function file_operation() {
|
51 |
+
$this->file_rand( 1024 * 10 );
|
52 |
+
return new WP_REST_Response( [ 'success' => true ], 200 );
|
53 |
+
}
|
54 |
+
|
55 |
+
function sql_request() {
|
56 |
+
global $wpdb;
|
57 |
+
$count = $wpdb->get_var( "SELECT COUNT(*) FROM {$wpdb->posts}" );
|
58 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $count ], 200 );
|
59 |
+
}
|
60 |
+
|
61 |
+
function rest_all_settings() {
|
62 |
+
$settings = array(
|
63 |
+
'meowapps_hide_meowapps' => get_option( 'meowapps_hide_meowapps', false ),
|
64 |
+
'force_sslverify' => get_option( 'force_sslverify', false )
|
65 |
+
);
|
66 |
+
return new WP_REST_Response([ 'success' => true, 'data' => $settings ], 200 );
|
67 |
+
}
|
68 |
+
|
69 |
+
function rest_update_option( $request ) {
|
70 |
+
$params = $request->get_json_params();
|
71 |
+
try {
|
72 |
+
$result = update_option( $params['name'], $params['value'] );
|
73 |
+
return new WP_REST_Response([ 'success' => $result ], 200 );
|
74 |
+
}
|
75 |
+
catch (Exception $e) {
|
76 |
+
return new WP_REST_Response([ 'success' => false, 'message' => $e->getMessage() ], 500 );
|
77 |
+
}
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
?>
|
common/classes/rest_license.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class MeowCommon_Classes_Rest_License
|
4 |
+
{
|
5 |
+
private $licenser = null;
|
6 |
+
private $namespace = null;
|
7 |
+
|
8 |
+
public function __construct( &$licenser ) {
|
9 |
+
$this->licenser = $licenser;
|
10 |
+
$this->namespace = "meow-licenser/{$licenser->prefix}/v1";
|
11 |
+
if ( !current_user_can( 'administrator' ) ) {
|
12 |
+
return;
|
13 |
+
}
|
14 |
+
add_action( 'rest_api_init', array( $this, 'rest_api_init' ) );
|
15 |
+
}
|
16 |
+
|
17 |
+
function rest_api_init() {
|
18 |
+
register_rest_route( $this->namespace, '/get_license/', [
|
19 |
+
'methods' => 'POST',
|
20 |
+
'callback' => [ $this, 'get_license' ]
|
21 |
+
]);
|
22 |
+
register_rest_route( $this->namespace, '/set_license/', [
|
23 |
+
'methods' => 'POST',
|
24 |
+
'callback' => [ $this, 'set_license' ]
|
25 |
+
]);
|
26 |
+
}
|
27 |
+
|
28 |
+
function get_license() {
|
29 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $this->licenser->license ], 200 );
|
30 |
+
}
|
31 |
+
|
32 |
+
function set_license( $request ) {
|
33 |
+
$params = $request->get_json_params();
|
34 |
+
$serialKey = $params['serialKey'];
|
35 |
+
$this->licenser->validate_pro( $serialKey );
|
36 |
+
return new WP_REST_Response( [ 'success' => true, 'data' => $this->licenser->license ], 200 );
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
?>
|
common/classes/updater.php
ADDED
@@ -0,0 +1,591 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
// Exit if accessed directly
|
4 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Allows plugins to use their own update API.
|
8 |
+
*
|
9 |
+
* @author Easy Digital Downloads
|
10 |
+
* @version 1.6.18
|
11 |
+
*/
|
12 |
+
class MeowCommon_Classes_Updater {
|
13 |
+
|
14 |
+
private $api_url = '';
|
15 |
+
private $api_data = array();
|
16 |
+
private $name = '';
|
17 |
+
private $slug = '';
|
18 |
+
private $version = '';
|
19 |
+
private $wp_override = false;
|
20 |
+
private $cache_key = '';
|
21 |
+
|
22 |
+
private $health_check_timeout = 5;
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Class constructor.
|
26 |
+
*
|
27 |
+
* @uses plugin_basename()
|
28 |
+
* @uses hook()
|
29 |
+
*
|
30 |
+
* @param string $_api_url The URL pointing to the custom API endpoint.
|
31 |
+
* @param string $_plugin_file Path to the plugin file.
|
32 |
+
* @param array $_api_data Optional data to send with API calls.
|
33 |
+
*/
|
34 |
+
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
|
35 |
+
|
36 |
+
global $edd_plugin_data;
|
37 |
+
|
38 |
+
$this->api_url = trailingslashit( $_api_url );
|
39 |
+
$this->api_data = $_api_data;
|
40 |
+
$this->name = plugin_basename( $_plugin_file );
|
41 |
+
$this->slug = basename( $_plugin_file, '.php' );
|
42 |
+
$this->version = $_api_data['version'];
|
43 |
+
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
|
44 |
+
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
|
45 |
+
$this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
46 |
+
|
47 |
+
$edd_plugin_data[ $this->slug ] = $this->api_data;
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Fires after the $edd_plugin_data is setup.
|
51 |
+
*
|
52 |
+
* @since x.x.x
|
53 |
+
*
|
54 |
+
* @param array $edd_plugin_data Array of EDD SL plugin data.
|
55 |
+
*/
|
56 |
+
do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
|
57 |
+
|
58 |
+
// Set up hooks.
|
59 |
+
$this->init();
|
60 |
+
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Set up WordPress filters to hook into WP's update process.
|
65 |
+
*
|
66 |
+
* @uses add_filter()
|
67 |
+
*
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
public function init() {
|
71 |
+
|
72 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
73 |
+
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
|
74 |
+
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
|
75 |
+
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
|
76 |
+
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
77 |
+
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
82 |
+
*
|
83 |
+
* This function dives into the update API just when WordPress creates its update array,
|
84 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
85 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
86 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
87 |
+
*
|
88 |
+
* @uses api_request()
|
89 |
+
*
|
90 |
+
* @param array $_transient_data Update array build by WordPress.
|
91 |
+
* @return array Modified update array with custom plugin data.
|
92 |
+
*/
|
93 |
+
public function check_update( $_transient_data ) {
|
94 |
+
|
95 |
+
global $pagenow;
|
96 |
+
|
97 |
+
if ( ! is_object( $_transient_data ) ) {
|
98 |
+
$_transient_data = new stdClass;
|
99 |
+
}
|
100 |
+
|
101 |
+
if ( 'plugins.php' == $pagenow && is_multisite() ) {
|
102 |
+
return $_transient_data;
|
103 |
+
}
|
104 |
+
|
105 |
+
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
|
106 |
+
return $_transient_data;
|
107 |
+
}
|
108 |
+
|
109 |
+
$version_info = $this->get_cached_version_info();
|
110 |
+
|
111 |
+
if ( false === $version_info ) {
|
112 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
113 |
+
|
114 |
+
$this->set_version_info_cache( $version_info );
|
115 |
+
|
116 |
+
}
|
117 |
+
|
118 |
+
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
|
119 |
+
|
120 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
121 |
+
|
122 |
+
$_transient_data->response[ $this->name ] = $version_info;
|
123 |
+
|
124 |
+
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
|
125 |
+
$_transient_data->response[ $this->name ]->plugin = $this->name;
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
$_transient_data->last_checked = time();
|
130 |
+
$_transient_data->checked[ $this->name ] = $this->version;
|
131 |
+
|
132 |
+
}
|
133 |
+
|
134 |
+
return $_transient_data;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
|
139 |
+
*
|
140 |
+
* @param string $file
|
141 |
+
* @param array $plugin
|
142 |
+
*/
|
143 |
+
public function show_update_notification( $file, $plugin ) {
|
144 |
+
|
145 |
+
if ( is_network_admin() ) {
|
146 |
+
return;
|
147 |
+
}
|
148 |
+
|
149 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
150 |
+
return;
|
151 |
+
}
|
152 |
+
|
153 |
+
if( ! is_multisite() ) {
|
154 |
+
return;
|
155 |
+
}
|
156 |
+
|
157 |
+
if ( $this->name != $file ) {
|
158 |
+
return;
|
159 |
+
}
|
160 |
+
|
161 |
+
// Remove our filter on the site transient
|
162 |
+
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
163 |
+
|
164 |
+
$update_cache = get_site_transient( 'update_plugins' );
|
165 |
+
|
166 |
+
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
|
167 |
+
|
168 |
+
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
|
169 |
+
|
170 |
+
$version_info = $this->get_cached_version_info();
|
171 |
+
|
172 |
+
if ( false === $version_info ) {
|
173 |
+
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
|
174 |
+
|
175 |
+
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
|
176 |
+
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
|
177 |
+
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
|
178 |
+
}
|
179 |
+
|
180 |
+
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
|
181 |
+
$version_info->sections = $this->convert_object_to_array( $version_info->sections );
|
182 |
+
}
|
183 |
+
|
184 |
+
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
|
185 |
+
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
|
186 |
+
}
|
187 |
+
|
188 |
+
$this->set_version_info_cache( $version_info );
|
189 |
+
}
|
190 |
+
|
191 |
+
if ( ! is_object( $version_info ) ) {
|
192 |
+
return;
|
193 |
+
}
|
194 |
+
|
195 |
+
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
196 |
+
|
197 |
+
$update_cache->response[ $this->name ] = $version_info;
|
198 |
+
|
199 |
+
}
|
200 |
+
|
201 |
+
$update_cache->last_checked = time();
|
202 |
+
$update_cache->checked[ $this->name ] = $this->version;
|
203 |
+
|
204 |
+
set_site_transient( 'update_plugins', $update_cache );
|
205 |
+
|
206 |
+
} else {
|
207 |
+
|
208 |
+
$version_info = $update_cache->response[ $this->name ];
|
209 |
+
|
210 |
+
}
|
211 |
+
|
212 |
+
// Restore our filter
|
213 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
214 |
+
|
215 |
+
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
216 |
+
|
217 |
+
// build a plugin list row, with update notification
|
218 |
+
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
|
219 |
+
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
|
220 |
+
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
|
221 |
+
echo '<td colspan="3" class="plugin-update colspanchange">';
|
222 |
+
echo '<div class="update-message notice inline notice-warning notice-alt">';
|
223 |
+
|
224 |
+
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
|
225 |
+
|
226 |
+
if ( empty( $version_info->download_link ) ) {
|
227 |
+
printf(
|
228 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
|
229 |
+
esc_html( $version_info->name ),
|
230 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
231 |
+
esc_html( $version_info->new_version ),
|
232 |
+
'</a>'
|
233 |
+
);
|
234 |
+
} else {
|
235 |
+
printf(
|
236 |
+
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
|
237 |
+
esc_html( $version_info->name ),
|
238 |
+
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
|
239 |
+
esc_html( $version_info->new_version ),
|
240 |
+
'</a>',
|
241 |
+
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
|
242 |
+
'</a>'
|
243 |
+
);
|
244 |
+
}
|
245 |
+
|
246 |
+
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
|
247 |
+
|
248 |
+
echo '</div></td></tr>';
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Updates information on the "View version x.x details" page with custom data.
|
254 |
+
*
|
255 |
+
* @uses api_request()
|
256 |
+
*
|
257 |
+
* @param mixed $_data
|
258 |
+
* @param string $_action
|
259 |
+
* @param object $_args
|
260 |
+
* @return object $_data
|
261 |
+
*/
|
262 |
+
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
|
263 |
+
|
264 |
+
if ( $_action != 'plugin_information' ) {
|
265 |
+
|
266 |
+
return $_data;
|
267 |
+
|
268 |
+
}
|
269 |
+
|
270 |
+
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
|
271 |
+
|
272 |
+
return $_data;
|
273 |
+
|
274 |
+
}
|
275 |
+
|
276 |
+
$to_send = array(
|
277 |
+
'slug' => $this->slug,
|
278 |
+
'is_ssl' => is_ssl(),
|
279 |
+
'fields' => array(
|
280 |
+
'banners' => array(),
|
281 |
+
'reviews' => false,
|
282 |
+
'icons' => array(),
|
283 |
+
)
|
284 |
+
);
|
285 |
+
|
286 |
+
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
|
287 |
+
|
288 |
+
// Get the transient where we store the api request for this plugin for 24 hours
|
289 |
+
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
|
290 |
+
|
291 |
+
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
|
292 |
+
if ( empty( $edd_api_request_transient ) ) {
|
293 |
+
|
294 |
+
$api_response = $this->api_request( 'plugin_information', $to_send );
|
295 |
+
|
296 |
+
// Expires in 3 hours
|
297 |
+
$this->set_version_info_cache( $api_response, $cache_key );
|
298 |
+
|
299 |
+
if ( false !== $api_response ) {
|
300 |
+
$_data = $api_response;
|
301 |
+
}
|
302 |
+
|
303 |
+
} else {
|
304 |
+
$_data = $edd_api_request_transient;
|
305 |
+
}
|
306 |
+
|
307 |
+
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
|
308 |
+
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
|
309 |
+
$_data->sections = $this->convert_object_to_array( $_data->sections );
|
310 |
+
}
|
311 |
+
|
312 |
+
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
|
313 |
+
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
|
314 |
+
$_data->banners = $this->convert_object_to_array( $_data->banners );
|
315 |
+
}
|
316 |
+
|
317 |
+
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
|
318 |
+
if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
|
319 |
+
$_data->icons = $this->convert_object_to_array( $_data->icons );
|
320 |
+
}
|
321 |
+
|
322 |
+
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
|
323 |
+
if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
|
324 |
+
$_data->contributors = $this->convert_object_to_array( $_data->contributors );
|
325 |
+
foreach ( $_data->contributors as $key => $value ) {
|
326 |
+
$_data->contributors[$key] = $this->convert_object_to_array( $value );
|
327 |
+
}
|
328 |
+
}
|
329 |
+
|
330 |
+
// FOR DEBUG
|
331 |
+
// $fordebug = clone $_data;
|
332 |
+
// foreach ( $fordebug->sections as $key => $value ) {
|
333 |
+
// if ( strlen( $fordebug->sections[$key] ) > 200 )
|
334 |
+
// $fordebug->sections[$key] = '...';
|
335 |
+
// }
|
336 |
+
// $fordebug->description = '...';
|
337 |
+
// $fordebug->changelog = '...';
|
338 |
+
// var_dump( $fordebug, 1 );
|
339 |
+
// exit;
|
340 |
+
|
341 |
+
if ( !empty( $_data ) && !isset( $_data->plugin ) ) {
|
342 |
+
$_data->plugin = $this->name;
|
343 |
+
}
|
344 |
+
|
345 |
+
return $_data;
|
346 |
+
}
|
347 |
+
|
348 |
+
/**
|
349 |
+
* Convert some objects to arrays when injecting data into the update API
|
350 |
+
*
|
351 |
+
* Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
|
352 |
+
* decoding, they are objects. This method allows us to pass in the object and return an associative array.
|
353 |
+
*
|
354 |
+
* @since 3.6.5
|
355 |
+
*
|
356 |
+
* @param stdClass $data
|
357 |
+
*
|
358 |
+
* @return array
|
359 |
+
*/
|
360 |
+
private function convert_object_to_array( $data ) {
|
361 |
+
$new_data = array();
|
362 |
+
foreach ( $data as $key => $value ) {
|
363 |
+
$new_data[ $key ] = $value;
|
364 |
+
}
|
365 |
+
|
366 |
+
return $new_data;
|
367 |
+
}
|
368 |
+
|
369 |
+
/**
|
370 |
+
* Disable SSL verification in order to prevent download update failures
|
371 |
+
*
|
372 |
+
* @param array $args
|
373 |
+
* @param string $url
|
374 |
+
* @return object $array
|
375 |
+
*/
|
376 |
+
public function http_request_args( $args, $url ) {
|
377 |
+
|
378 |
+
$verify_ssl = $this->verify_ssl();
|
379 |
+
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
|
380 |
+
$args['sslverify'] = $verify_ssl;
|
381 |
+
}
|
382 |
+
return $args;
|
383 |
+
|
384 |
+
}
|
385 |
+
|
386 |
+
/**
|
387 |
+
* Calls the API and, if successfull, returns the object delivered by the API.
|
388 |
+
*
|
389 |
+
* @uses get_bloginfo()
|
390 |
+
* @uses wp_remote_post()
|
391 |
+
* @uses is_wp_error()
|
392 |
+
*
|
393 |
+
* @param string $_action The requested action.
|
394 |
+
* @param array $_data Parameters for the API action.
|
395 |
+
* @return false|object
|
396 |
+
*/
|
397 |
+
private function api_request( $_action, $_data ) {
|
398 |
+
|
399 |
+
global $wp_version, $edd_plugin_url_available;
|
400 |
+
|
401 |
+
$verify_ssl = $this->verify_ssl();
|
402 |
+
|
403 |
+
// Do a quick status check on this domain if we haven't already checked it.
|
404 |
+
$store_hash = md5( $this->api_url );
|
405 |
+
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
|
406 |
+
$test_url_parts = parse_url( $this->api_url );
|
407 |
+
|
408 |
+
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
|
409 |
+
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
|
410 |
+
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
|
411 |
+
|
412 |
+
if ( empty( $host ) ) {
|
413 |
+
$edd_plugin_url_available[ $store_hash ] = false;
|
414 |
+
} else {
|
415 |
+
$test_url = $scheme . '://' . $host . $port;
|
416 |
+
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
|
417 |
+
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
|
418 |
+
}
|
419 |
+
}
|
420 |
+
|
421 |
+
if ( false === $edd_plugin_url_available[ $store_hash ] ) {
|
422 |
+
return;
|
423 |
+
}
|
424 |
+
|
425 |
+
$data = array_merge( $this->api_data, $_data );
|
426 |
+
|
427 |
+
if ( $data['slug'] != $this->slug ) {
|
428 |
+
return;
|
429 |
+
}
|
430 |
+
|
431 |
+
if( $this->api_url == trailingslashit ( home_url() ) ) {
|
432 |
+
return false; // Don't allow a plugin to ping itself
|
433 |
+
}
|
434 |
+
|
435 |
+
$api_params = array(
|
436 |
+
'edd_action' => 'get_version',
|
437 |
+
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
|
438 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
439 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
440 |
+
'version' => isset( $data['version'] ) ? $data['version'] : false,
|
441 |
+
'slug' => $data['slug'],
|
442 |
+
'author' => $data['author'],
|
443 |
+
'url' => home_url(),
|
444 |
+
'beta' => ! empty( $data['beta'] ),
|
445 |
+
);
|
446 |
+
|
447 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
448 |
+
|
449 |
+
if ( ! is_wp_error( $request ) ) {
|
450 |
+
$request = json_decode( wp_remote_retrieve_body( $request ) );
|
451 |
+
}
|
452 |
+
|
453 |
+
if ( $request && isset( $request->sections ) ) {
|
454 |
+
$request->sections = maybe_unserialize( $request->sections );
|
455 |
+
} else {
|
456 |
+
$request = false;
|
457 |
+
}
|
458 |
+
|
459 |
+
if ( $request && isset( $request->banners ) ) {
|
460 |
+
$request->banners = maybe_unserialize( $request->banners );
|
461 |
+
}
|
462 |
+
|
463 |
+
if ( $request && isset( $request->icons ) ) {
|
464 |
+
$request->icons = maybe_unserialize( $request->icons );
|
465 |
+
}
|
466 |
+
|
467 |
+
if( ! empty( $request->sections ) ) {
|
468 |
+
foreach( $request->sections as $key => $section ) {
|
469 |
+
$request->$key = (array) $section;
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
return $request;
|
474 |
+
}
|
475 |
+
|
476 |
+
public function show_changelog() {
|
477 |
+
|
478 |
+
global $edd_plugin_data;
|
479 |
+
|
480 |
+
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
|
481 |
+
return;
|
482 |
+
}
|
483 |
+
|
484 |
+
if( empty( $_REQUEST['plugin'] ) ) {
|
485 |
+
return;
|
486 |
+
}
|
487 |
+
|
488 |
+
if( empty( $_REQUEST['slug'] ) ) {
|
489 |
+
return;
|
490 |
+
}
|
491 |
+
|
492 |
+
if( ! current_user_can( 'update_plugins' ) ) {
|
493 |
+
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
|
494 |
+
}
|
495 |
+
|
496 |
+
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
|
497 |
+
$beta = ! empty( $data['beta'] ) ? true : false;
|
498 |
+
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
|
499 |
+
$version_info = $this->get_cached_version_info( $cache_key );
|
500 |
+
|
501 |
+
if( false === $version_info ) {
|
502 |
+
|
503 |
+
$api_params = array(
|
504 |
+
'edd_action' => 'get_version',
|
505 |
+
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
|
506 |
+
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
|
507 |
+
'slug' => $_REQUEST['slug'],
|
508 |
+
'author' => $data['author'],
|
509 |
+
'url' => home_url(),
|
510 |
+
'beta' => ! empty( $data['beta'] )
|
511 |
+
);
|
512 |
+
|
513 |
+
$verify_ssl = $this->verify_ssl();
|
514 |
+
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
|
515 |
+
|
516 |
+
if ( ! is_wp_error( $request ) ) {
|
517 |
+
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
|
518 |
+
}
|
519 |
+
|
520 |
+
|
521 |
+
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
|
522 |
+
$version_info->sections = maybe_unserialize( $version_info->sections );
|
523 |
+
} else {
|
524 |
+
$version_info = false;
|
525 |
+
}
|
526 |
+
|
527 |
+
if( ! empty( $version_info ) ) {
|
528 |
+
foreach( $version_info->sections as $key => $section ) {
|
529 |
+
$version_info->$key = (array) $section;
|
530 |
+
}
|
531 |
+
}
|
532 |
+
|
533 |
+
$this->set_version_info_cache( $version_info, $cache_key );
|
534 |
+
|
535 |
+
}
|
536 |
+
|
537 |
+
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
|
538 |
+
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
|
539 |
+
}
|
540 |
+
|
541 |
+
exit;
|
542 |
+
}
|
543 |
+
|
544 |
+
public function get_cached_version_info( $cache_key = '' ) {
|
545 |
+
|
546 |
+
if( empty( $cache_key ) ) {
|
547 |
+
$cache_key = $this->cache_key;
|
548 |
+
}
|
549 |
+
|
550 |
+
$cache = get_option( $cache_key );
|
551 |
+
|
552 |
+
if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
|
553 |
+
return false; // Cache is expired
|
554 |
+
}
|
555 |
+
|
556 |
+
// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
|
557 |
+
$cache['value'] = json_decode( $cache['value'] );
|
558 |
+
if ( ! empty( $cache['value']->icons ) ) {
|
559 |
+
$cache['value']->icons = (array) $cache['value']->icons;
|
560 |
+
}
|
561 |
+
|
562 |
+
return $cache['value'];
|
563 |
+
|
564 |
+
}
|
565 |
+
|
566 |
+
public function set_version_info_cache( $value = '', $cache_key = '' ) {
|
567 |
+
|
568 |
+
if( empty( $cache_key ) ) {
|
569 |
+
$cache_key = $this->cache_key;
|
570 |
+
}
|
571 |
+
|
572 |
+
$data = array(
|
573 |
+
'timeout' => strtotime( '+3 hours', time() ),
|
574 |
+
'value' => json_encode( $value )
|
575 |
+
);
|
576 |
+
|
577 |
+
update_option( $cache_key, $data, 'no' );
|
578 |
+
|
579 |
+
}
|
580 |
+
|
581 |
+
/**
|
582 |
+
* Returns if the SSL of the store should be verified.
|
583 |
+
*
|
584 |
+
* @since 1.6.13
|
585 |
+
* @return bool
|
586 |
+
*/
|
587 |
+
private function verify_ssl() {
|
588 |
+
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
|
589 |
+
}
|
590 |
+
|
591 |
+
}
|
common/helpers.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( !class_exists( 'MeowCommon_Helpers' ) ) {
|
4 |
+
|
5 |
+
class MeowCommon_Helpers {
|
6 |
+
|
7 |
+
/**
|
8 |
+
* Checks if the current request is a WP REST API request.
|
9 |
+
*
|
10 |
+
* Case #1: After WP_REST_Request initialisation
|
11 |
+
* Case #2: Support "plain" permalink settings
|
12 |
+
* Case #3: It can happen that WP_Rewrite is not yet initialized,
|
13 |
+
* so do this (wp-settings.php)
|
14 |
+
* Case #4: URL Path begins with wp-json/ (your REST prefix)
|
15 |
+
* Also supports WP installations in subfolders
|
16 |
+
*
|
17 |
+
* @returns boolean
|
18 |
+
* @author matzeeable
|
19 |
+
*/
|
20 |
+
|
21 |
+
static function is_rest() {
|
22 |
+
$prefix = rest_get_url_prefix( );
|
23 |
+
if ( defined('REST_REQUEST') && REST_REQUEST || isset( $_GET['rest_route'] ) // (#2)
|
24 |
+
&& strpos( trim( $_GET['rest_route'], '\\/' ), $prefix , 0 ) === 0)
|
25 |
+
return true;
|
26 |
+
// (#3)
|
27 |
+
global $wp_rewrite;
|
28 |
+
if ($wp_rewrite === null) $wp_rewrite = new WP_Rewrite();
|
29 |
+
|
30 |
+
// (#4)
|
31 |
+
$rest_url = wp_parse_url( trailingslashit( rest_url( ) ) );
|
32 |
+
$current_url = wp_parse_url( add_query_arg( array( ) ) );
|
33 |
+
if ( !$rest_url || !$current_url )
|
34 |
+
return false;
|
35 |
+
if ( !empty( $current_url['path'] ) && !empty( $rest_url['path'] ) ) {
|
36 |
+
return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0;
|
37 |
+
}
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
}
|
41 |
+
|
42 |
+
if ( MeowCommon_Helpers::is_rest() ) {
|
43 |
+
ini_set( 'display_errors', 0 );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
?>
|
common/licenser.php
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( !class_exists( 'MeowCommon_Licenser' ) ) {
|
4 |
+
|
5 |
+
class MeowCommon_Licenser {
|
6 |
+
public $license = null;
|
7 |
+
public $prefix; // prefix used for actions, filters (mfrh)
|
8 |
+
public $mainfile; // plugin main file (media-file-renamer.php)
|
9 |
+
public $domain; // domain used for translation (media-file-renamer)
|
10 |
+
public $item; // name of the Pro plugin (Media File Renamer Pro)
|
11 |
+
public $version; // version of the plugin (Media File Renamer Pro)
|
12 |
+
|
13 |
+
public function __construct( $prefix, $mainfile, $domain, $item, $version ) {
|
14 |
+
$this->prefix = $prefix;
|
15 |
+
$this->mainfile = $mainfile;
|
16 |
+
$this->domain = $domain;
|
17 |
+
$this->item = $item;
|
18 |
+
$this->version = $version;
|
19 |
+
|
20 |
+
if ( $this->is_registered() ) {
|
21 |
+
add_filter( $this->prefix . '_meowapps_is_registered', array( $this, 'is_registered' ), 10 );
|
22 |
+
}
|
23 |
+
|
24 |
+
if ( MeowCommon_Helpers::is_rest() ) {
|
25 |
+
new MeowCommon_Classes_Rest_License( $this );
|
26 |
+
}
|
27 |
+
else if ( is_admin() ) {
|
28 |
+
$license_key = $this->license && isset( $this->license['key'] ) ? $this->license['key'] : "";
|
29 |
+
new MeowCommon_Classes_Updater(
|
30 |
+
( get_option( 'force_sslverify', false ) ? 'https' : 'http' ) . '://store.meowapps.com', $this->mainfile,
|
31 |
+
array(
|
32 |
+
'version' => $this->version,
|
33 |
+
'license' => $license_key,
|
34 |
+
'item_name' => $this->item,
|
35 |
+
'wp_override' => true,
|
36 |
+
'author' => 'Jordy Meow',
|
37 |
+
'url' => strtolower( home_url() ),
|
38 |
+
'beta' => false
|
39 |
+
)
|
40 |
+
);
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
function retry_validation() {
|
45 |
+
if ( isset( $_POST[$this->prefix . '_pro_serial'] ) ) {
|
46 |
+
$serial = $_POST[$this->prefix . '_pro_serial'];
|
47 |
+
$this->validate_pro( $serial );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
|
51 |
+
function is_registered( $force = false ) {
|
52 |
+
if ( !$force && !empty( $this->license ) )
|
53 |
+
return empty( $this->license['issue'] );
|
54 |
+
$this->license = get_option( $this->prefix . '_license', "" );
|
55 |
+
if ( empty( $this->license ) || !empty( $this->license['issue'] ) )
|
56 |
+
return false;
|
57 |
+
if ( $this->license['expires'] == "lifetime" )
|
58 |
+
return true;
|
59 |
+
$datediff = strtotime( $this->license['expires'] ) - time();
|
60 |
+
$days = floor( $datediff / ( 60 * 60 * 24 ) );
|
61 |
+
if ( $days < 0 )
|
62 |
+
$this->validate_pro( $this->license['key'] );
|
63 |
+
return true;
|
64 |
+
}
|
65 |
+
|
66 |
+
function validate_pro( $subscr_id ) {
|
67 |
+
$prefix = $this->prefix;
|
68 |
+
delete_option( $prefix . '_license', "" );
|
69 |
+
if ( empty( $subscr_id ) )
|
70 |
+
return false;
|
71 |
+
$url = ( get_option( 'force_sslverify', false ) ? 'https' : 'http' ) .
|
72 |
+
'://store.meowapps.com/?edd_action=activate_license' .
|
73 |
+
'&item_name=' . urlencode( $this->item ) .
|
74 |
+
'&license=' . $subscr_id . '&url=' . strtolower( home_url() ) . '&cache=' . bin2hex( openssl_random_pseudo_bytes( 4 ) );
|
75 |
+
$response = wp_remote_get( $url, array(
|
76 |
+
'user-agent' => "MeowApps",
|
77 |
+
'sslverify' => get_option( 'force_sslverify', false ),
|
78 |
+
'timeout' => 45,
|
79 |
+
'method' => 'GET'
|
80 |
+
)
|
81 |
+
);
|
82 |
+
$body = is_array( $response ) ? $response['body'] : null;
|
83 |
+
$post = @json_decode( $body );
|
84 |
+
$status = null;
|
85 |
+
$license = null;
|
86 |
+
$expires = null;
|
87 |
+
$logs = null;
|
88 |
+
if ( !$post || ( property_exists( $post, 'code' ) ) ) {
|
89 |
+
$status = 'error';
|
90 |
+
// $status = __( "There was an error while validating the serial.<br />Please contact <a target='_blank' href='https://meowapps.com/contact/'>Meow Apps</a> and mention the following log: <br /><ul>", $this->domain );
|
91 |
+
$logs = "<li>Server IP: <b>" . gethostbyname( $_SERVER['SERVER_NAME'] ) . "</b></li>";
|
92 |
+
$logs .= "<li>Google GET: ";
|
93 |
+
$r = wp_remote_get( 'http://google.com' );
|
94 |
+
$logs .= is_wp_error( $r ) ? print_r( $r, true ) : 'OK';
|
95 |
+
$logs .= "</li><li>MeowApps GET: ";
|
96 |
+
$r = wp_remote_get( 'http://meowapps.com' );
|
97 |
+
$logs .= is_wp_error( $r ) ? print_r( $r, true ) : 'OK';
|
98 |
+
$logs .= "</li><li>MeowApps STORE:<br /><br />";
|
99 |
+
$logs .= "REQUEST: $url<br /><br />";
|
100 |
+
$logs .= "RESPONSE: ";
|
101 |
+
$logs .= print_r( $response, true );
|
102 |
+
$logs .= "</li></ul>";
|
103 |
+
error_log( print_r( $response, true ) );
|
104 |
+
}
|
105 |
+
else if ( $post->license !== "valid" ) {
|
106 |
+
$status = $post->error ;
|
107 |
+
}
|
108 |
+
else {
|
109 |
+
$license = $post->license;
|
110 |
+
$expires = $post->expires;
|
111 |
+
delete_option( '_site_transient_update_plugins' );
|
112 |
+
}
|
113 |
+
update_option( $prefix . '_license', array(
|
114 |
+
'key' => $subscr_id,
|
115 |
+
'issue' => $status,
|
116 |
+
'expires' => $expires,
|
117 |
+
'license' => $license ) );
|
118 |
+
return $this->is_registered( true );
|
119 |
+
}
|
120 |
+
|
121 |
+
}
|
122 |
+
|
123 |
+
}
|
124 |
+
|
125 |
+
?>
|
helpers.php
DELETED
@@ -1,39 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
if ( !function_exists( 'is_rest' ) ) {
|
4 |
-
/**
|
5 |
-
* Checks if the current request is a WP REST API request.
|
6 |
-
*
|
7 |
-
* Case #1: After WP_REST_Request initialisation
|
8 |
-
* Case #2: Support "plain" permalink settings
|
9 |
-
* Case #3: It can happen that WP_Rewrite is not yet initialized,
|
10 |
-
* so do this (wp-settings.php)
|
11 |
-
* Case #4: URL Path begins with wp-json/ (your REST prefix)
|
12 |
-
* Also supports WP installations in subfolders
|
13 |
-
*
|
14 |
-
* @returns boolean
|
15 |
-
* @author matzeeable
|
16 |
-
*/
|
17 |
-
function is_rest() {
|
18 |
-
$prefix = rest_get_url_prefix( );
|
19 |
-
if (defined('REST_REQUEST') && REST_REQUEST // (#1)
|
20 |
-
|| isset($_GET['rest_route']) // (#2)
|
21 |
-
&& strpos( trim( $_GET['rest_route'], '\\/' ), $prefix , 0 ) === 0)
|
22 |
-
return true;
|
23 |
-
// (#3)
|
24 |
-
global $wp_rewrite;
|
25 |
-
if ($wp_rewrite === null) $wp_rewrite = new WP_Rewrite();
|
26 |
-
|
27 |
-
// (#4)
|
28 |
-
$rest_url = wp_parse_url( trailingslashit( rest_url( ) ) );
|
29 |
-
$current_url = wp_parse_url( add_query_arg( array( ) ) );
|
30 |
-
if ( !$rest_url || !$current_url )
|
31 |
-
return false;
|
32 |
-
if ( !empty( $current_url['path'] ) && !empty( $rest_url['path'] ) ) {
|
33 |
-
return strpos( $current_url['path'], $rest_url['path'], 0 ) === 0;
|
34 |
-
}
|
35 |
-
return false;
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
languages/media-file-renamer-fr_FR.mo
ADDED
Binary file
|
media-file-renamer.php
CHANGED
@@ -1,49 +1,27 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
-
Plugin Name: Media File Renamer
|
4 |
Plugin URI: https://meowapps.com
|
5 |
-
Description: Renames
|
6 |
-
Version:
|
7 |
Author: Jordy Meow
|
8 |
-
Author URI: https://
|
|
|
9 |
Text Domain: media-file-renamer
|
10 |
Domain Path: /languages
|
11 |
|
12 |
-
Dual licensed under the MIT and GPL licenses:
|
13 |
-
https://www.opensource.org/licenses/mit-license.php
|
14 |
-
https://www.gnu.org/licenses/gpl.html
|
15 |
-
|
16 |
Originally developed for two of my websites:
|
17 |
- Jordy Meow (https://offbeatjapan.org)
|
18 |
- Haikyo (https://haikyo.org)
|
19 |
*/
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
}
|
28 |
-
|
29 |
-
require( 'helpers.php');
|
30 |
-
|
31 |
-
// In admin or Rest API request (REQUEST URI begins with '/wp-json/')
|
32 |
-
if ( is_admin() || is_rest() ) {
|
33 |
-
|
34 |
-
global $mfrh_version, $mfrh_core;
|
35 |
-
$mfrh_version = '4.7.0';
|
36 |
-
|
37 |
-
// Admin
|
38 |
-
require( 'mfrh_admin.php');
|
39 |
-
$mfrh_admin = new Meow_MFRH_Admin( 'mfrh', __FILE__, 'media-file-renamer' );
|
40 |
|
41 |
-
|
42 |
-
require( 'core.php' );
|
43 |
-
global $mfrh_core;
|
44 |
-
$mfrh_core = new Meow_MFRH_Core( $mfrh_admin );
|
45 |
|
46 |
-
|
47 |
-
require( 'ui.php' );
|
48 |
-
new Meow_MFRH_UI( $mfrh_core, $mfrh_admin );
|
49 |
-
}
|
1 |
<?php
|
2 |
/*
|
3 |
+
Plugin Name: Media File Renamer
|
4 |
Plugin URI: https://meowapps.com
|
5 |
+
Description: Renames your media files for better SEO and a nicer filesystem (automatically or manually).
|
6 |
+
Version: 5.0.0
|
7 |
Author: Jordy Meow
|
8 |
+
Author URI: https://meowapps.com
|
9 |
+
Domain Path: /languages
|
10 |
Text Domain: media-file-renamer
|
11 |
Domain Path: /languages
|
12 |
|
|
|
|
|
|
|
|
|
13 |
Originally developed for two of my websites:
|
14 |
- Jordy Meow (https://offbeatjapan.org)
|
15 |
- Haikyo (https://haikyo.org)
|
16 |
*/
|
17 |
|
18 |
+
define( 'MFRH_VERSION', '5.0.0' );
|
19 |
+
define( 'MFRH_PREFIX', 'mfrh' );
|
20 |
+
define( 'MFRH_DOMAIN', 'media-file-renamer' );
|
21 |
+
define( 'MFRH_ENTRY', __FILE__ );
|
22 |
+
define( 'MFRH_PATH', dirname( __FILE__ ) );
|
23 |
+
define( 'MFRH_URL', plugin_dir_url( __FILE__ ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
require_once( 'classes/init.php');
|
|
|
|
|
|
|
26 |
|
27 |
+
?>
|
|
|
|
|
|
mfrh_admin.php
DELETED
@@ -1,575 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
include "common/admin.php";
|
4 |
-
|
5 |
-
class Meow_MFRH_Admin extends MeowApps_Admin {
|
6 |
-
|
7 |
-
public function __construct( $prefix, $mainfile, $domain ) {
|
8 |
-
parent::__construct( $prefix, $mainfile, $domain );
|
9 |
-
if ( is_admin() ) {
|
10 |
-
add_action( 'admin_menu', array( $this, 'app_menu' ) );
|
11 |
-
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
12 |
-
}
|
13 |
-
}
|
14 |
-
|
15 |
-
function admin_notices() {
|
16 |
-
if ( isset( $_GET['reset'] ) ) {
|
17 |
-
if ( file_exists( plugin_dir_path( __FILE__ ) . '/media-file-renamer.log' ) )
|
18 |
-
unlink( plugin_dir_path( __FILE__ ) . '/media-file-renamer.log' );
|
19 |
-
if ( file_exists( plugin_dir_path( __FILE__ ) . '/mfrh_sql.log' ) )
|
20 |
-
unlink( plugin_dir_path( __FILE__ ) . '/mfrh_sql.log' );
|
21 |
-
if ( file_exists( plugin_dir_path( __FILE__ ) . '/mfrh_sql_revert.log' ) )
|
22 |
-
unlink( plugin_dir_path( __FILE__ ) . '/mfrh_sql_revert.log' );
|
23 |
-
}
|
24 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
25 |
-
$sync_alt = get_option( 'mfrh_sync_alt' );
|
26 |
-
$sync_meta_title = get_option( 'mfrh_sync_media_title' );
|
27 |
-
|
28 |
-
$force_rename = get_option( 'mfrh_force_rename', false );
|
29 |
-
$numbered_files = get_option( 'mfrh_numbered_files', false );
|
30 |
-
|
31 |
-
if ( $force_rename && $numbered_files ) {
|
32 |
-
update_option( 'mfrh_force_rename', false, false );
|
33 |
-
?>
|
34 |
-
<div class="notice notice-warning is-dismissible">
|
35 |
-
<p><?php _e( 'Force Rename and Numbered Files cannot be used at the same time. Please use Force Rename only when you are trying to repair a broken install. For now, Force Rename has been disabled.', 'media-file-renamer' ); ?></p>
|
36 |
-
</div>
|
37 |
-
<?php
|
38 |
-
}
|
39 |
-
|
40 |
-
if ( $sync_alt && $method == 'alt_text' ) {
|
41 |
-
update_option( 'mfrh_sync_alt', false, false );
|
42 |
-
?>
|
43 |
-
<div class="notice notice-warning is-dismissible">
|
44 |
-
<p><?php _e( 'The option Sync ALT was turned off since it does not make sense to have it with this Auto-Rename mode.', 'media-file-renamer' ); ?></p>
|
45 |
-
</div>
|
46 |
-
<?php
|
47 |
-
}
|
48 |
-
|
49 |
-
if ( $sync_meta_title && $method == 'media_title' ) {
|
50 |
-
update_option( 'mfrh_sync_media_title', false, false );
|
51 |
-
?>
|
52 |
-
<div class="notice notice-warning is-dismissible">
|
53 |
-
<p><?php _e( 'The option Sync Media Title was turned off since it does not make sense to have it with this Auto-Rename mode.', 'media-file-renamer' ); ?></p>
|
54 |
-
</div>
|
55 |
-
<?php
|
56 |
-
}
|
57 |
-
}
|
58 |
-
|
59 |
-
function common_url( $file ) {
|
60 |
-
return trailingslashit( plugin_dir_url( __FILE__ ) ) . 'common/' . $file;
|
61 |
-
}
|
62 |
-
|
63 |
-
function app_menu() {
|
64 |
-
|
65 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
66 |
-
|
67 |
-
// SUBMENU > Settings
|
68 |
-
add_submenu_page( 'meowapps-main-menu', 'Media File Renamer', 'Media Renamer', 'manage_options',
|
69 |
-
'mfrh_settings-menu', array( $this, 'admin_settings' ) );
|
70 |
-
|
71 |
-
// SUBMENU > Settings > Basic Settings
|
72 |
-
add_settings_section( 'mfrh_settings', null, null, 'mfrh_settings-menu' );
|
73 |
-
add_settings_field( 'mfrh_auto_rename', "Auto Rename",
|
74 |
-
array( $this, 'admin_auto_rename_callback' ),
|
75 |
-
'mfrh_settings-menu', 'mfrh_settings' );
|
76 |
-
add_settings_field( 'mfrh_on_upload', "On Upload",
|
77 |
-
array( $this, 'admin_on_upload_callback' ),
|
78 |
-
'mfrh_settings-menu', 'mfrh_settings' );
|
79 |
-
|
80 |
-
add_settings_field( 'mfrh_rename_slug', "Sync Slug<br /><i>Permalink</i>",
|
81 |
-
array( $this, 'admin_rename_slug_callback' ),
|
82 |
-
'mfrh_settings-menu', 'mfrh_settings' );
|
83 |
-
|
84 |
-
add_settings_field( 'mfrh_convert_to_ascii', "Transliteration<br /><i>To ASCII</i> (Pro)",
|
85 |
-
array( $this, 'admin_convert_to_ascii_callback' ),
|
86 |
-
'mfrh_settings-menu', 'mfrh_settings' );
|
87 |
-
|
88 |
-
register_setting( 'mfrh_settings', 'mfrh_auto_rename' );
|
89 |
-
register_setting( 'mfrh_settings', 'mfrh_on_upload' );
|
90 |
-
register_setting( 'mfrh_settings', 'mfrh_rename_slug' );
|
91 |
-
register_setting( 'mfrh_settings', 'mfrh_convert_to_ascii' );
|
92 |
-
|
93 |
-
// SUBMENU > Settings > Side Settings
|
94 |
-
add_settings_section( 'mfrh_side_settings', null, null, 'mfrh_side_settings-menu' );
|
95 |
-
add_settings_field( 'mfrh_update_posts', __( 'Posts', 'media-file-renamer' ),
|
96 |
-
array( $this, 'admin_update_posts_callback' ),
|
97 |
-
'mfrh_side_settings-menu', 'mfrh_side_settings' );
|
98 |
-
add_settings_field( 'mfrh_update_postmeta', __( 'Post Meta', 'media-file-renamer' ),
|
99 |
-
array( $this, 'admin_update_postmeta_callback' ),
|
100 |
-
'mfrh_side_settings-menu', 'mfrh_side_settings' );
|
101 |
-
|
102 |
-
register_setting( 'mfrh_side_settings', 'mfrh_update_posts' );
|
103 |
-
register_setting( 'mfrh_side_settings', 'mfrh_update_postmeta' );
|
104 |
-
|
105 |
-
// SUBMENU > Settings > Advanced Settings
|
106 |
-
add_settings_section( 'mfrh_advanced_settings', null, null, 'mfrh_advanced_settings-menu' );
|
107 |
-
add_settings_field( 'mfrh_undo', "Undo",
|
108 |
-
array( $this, 'admin_undo_callback' ),
|
109 |
-
'mfrh_advanced_settings-menu', 'mfrh_advanced_settings' );
|
110 |
-
add_settings_field( 'mfrh_manual_rename', "Manual Rename<br />(Pro)",
|
111 |
-
array( $this, 'admin_manual_rename_callback' ),
|
112 |
-
'mfrh_advanced_settings-menu', 'mfrh_advanced_settings' );
|
113 |
-
add_settings_field( 'mfrh_numbered_files', "Numbered Files<br />(Pro)",
|
114 |
-
array( $this, 'admin_numbered_files_callback' ),
|
115 |
-
'mfrh_advanced_settings-menu', 'mfrh_advanced_settings' );
|
116 |
-
|
117 |
-
if ( $method == 'media_title' || $method == 'post_title' || $method == 'product_title' ) {
|
118 |
-
add_settings_field( 'mfrh_sync_alt', "Sync ALT<br />(Pro)",
|
119 |
-
array( $this, 'admin_sync_alt_callback' ),
|
120 |
-
'mfrh_advanced_settings-menu', 'mfrh_advanced_settings' );
|
121 |
-
}
|
122 |
-
if ( $method == 'post_title' || $method == 'product_title' || $method == 'alt_text' ) {
|
123 |
-
add_settings_field( 'mfrh_sync_media_title', "Sync Media Title<br />(Pro)",
|
124 |
-
array( $this, 'admin_sync_media_title_callback' ),
|
125 |
-
'mfrh_advanced_settings-menu', 'mfrh_advanced_settings' );
|
126 |
-
}
|
127 |
-
|
128 |
-
register_setting( 'mfrh_advanced_settings', 'mfrh_undo' );
|
129 |
-
register_setting( 'mfrh_advanced_settings', 'mfrh_manual_rename' );
|
130 |
-
register_setting( 'mfrh_advanced_settings', 'mfrh_numbered_files' );
|
131 |
-
register_setting( 'mfrh_advanced_settings', 'mfrh_sync_alt' );
|
132 |
-
register_setting( 'mfrh_advanced_settings', 'mfrh_sync_media_title' );
|
133 |
-
|
134 |
-
// SUBMENU > Settings > Developer Settings
|
135 |
-
add_settings_section( 'mfrh_developer_settings', null, null, 'mfrh_developer_settings-menu' );
|
136 |
-
add_settings_field( 'mfrh_force_rename', __( 'Force Rename<br />(Pro)', 'media-file-renamer' ),
|
137 |
-
array( $this, 'admin_force_rename_callback' ),
|
138 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
139 |
-
add_settings_field( 'mfrh_log', __( 'Logs', 'media-file-renamer' ),
|
140 |
-
array( $this, 'admin_log_callback' ),
|
141 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
142 |
-
add_settings_field( 'mfrh_logsql', __( 'SQL Logs<br />(Pro)', 'media-file-renamer' ),
|
143 |
-
array( $this, 'admin_logsql_callback' ),
|
144 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
145 |
-
add_settings_field( 'mfrh_rename_guid', "Sync GUID",
|
146 |
-
array( $this, 'admin_rename_guid_callback' ),
|
147 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
148 |
-
add_settings_field( 'mfrh_case_sensitive_check', "Case Sensitive",
|
149 |
-
array( $this, 'admin_case_sensitive_callback' ),
|
150 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
151 |
-
add_settings_field( 'mfrh_rename_on_save', "Rename on Post Save",
|
152 |
-
array( $this, 'admin_rename_on_save_callback' ),
|
153 |
-
'mfrh_developer_settings-menu', 'mfrh_developer_settings' );
|
154 |
-
|
155 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_rename_guid' );
|
156 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_case_sensitive_check' );
|
157 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_force_rename' );
|
158 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_log' );
|
159 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_logsql' );
|
160 |
-
register_setting( 'mfrh_developer_settings', 'mfrh_rename_on_save' );
|
161 |
-
}
|
162 |
-
|
163 |
-
function admin_settings() {
|
164 |
-
?>
|
165 |
-
<div class="wrap">
|
166 |
-
<?php echo $this->display_title( "Media File Renamer" ); ?>
|
167 |
-
|
168 |
-
<div class="meow-row">
|
169 |
-
<div class="meow-box meow-col meow-span_2_of_2">
|
170 |
-
<h3>How to use</h3>
|
171 |
-
<div class="inside">
|
172 |
-
<?php
|
173 |
-
printf(
|
174 |
-
/* Translators: %s: link to tutorial */
|
175 |
-
esc_html__( 'This plugin works out of the box, the default settings are the best for most installs. However, you should have a look at the %s.', 'media-file-renamer' ),
|
176 |
-
'<a target="_blank" href="https://meowapps.com/plugin/media-file-renamer/">' . esc_html__( 'tutorial', 'media-file-renamer' ) . '</a>'
|
177 |
-
);
|
178 |
-
?>
|
179 |
-
<?php
|
180 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
181 |
-
if ( $method != 'none' ) {
|
182 |
-
?>
|
183 |
-
<p class="submit">
|
184 |
-
<a class="button button-primary" href="upload.php?page=rename_media_files">
|
185 |
-
<?php esc_html_e( "Access the Renamer Dashboard", 'media-file-renamer' ); ?>
|
186 |
-
</a>
|
187 |
-
</p>
|
188 |
-
<?php
|
189 |
-
}
|
190 |
-
?>
|
191 |
-
</div>
|
192 |
-
</div>
|
193 |
-
</div>
|
194 |
-
|
195 |
-
<div class="meow-row">
|
196 |
-
|
197 |
-
<div class="meow-col meow-span_1_of_2">
|
198 |
-
|
199 |
-
<div class="meow-box">
|
200 |
-
<h3>Settings</h3>
|
201 |
-
<div class="inside">
|
202 |
-
<form method="post" action="options.php">
|
203 |
-
<?php settings_fields( 'mfrh_settings' ); ?>
|
204 |
-
<?php do_settings_sections( 'mfrh_settings-menu' ); ?>
|
205 |
-
<?php submit_button(); ?>
|
206 |
-
</form>
|
207 |
-
</div>
|
208 |
-
</div>
|
209 |
-
|
210 |
-
<div class="meow-box">
|
211 |
-
<h3>Side Updates</h3>
|
212 |
-
<div class="inside">
|
213 |
-
<p><?php _e( 'When the files are renamed, many links to them on your WordPress might be broken. Those options are updating the references to those files. <b>Give it a try, every install is different and it might not work for certain kind of references.</b>', 'media-file-renamer' );
|
214 |
-
?></p>
|
215 |
-
<form method="post" action="options.php">
|
216 |
-
<?php settings_fields( 'mfrh_side_settings' ); ?>
|
217 |
-
<?php do_settings_sections( 'mfrh_side_settings-menu' ); ?>
|
218 |
-
<?php submit_button(); ?>
|
219 |
-
</form>
|
220 |
-
</div>
|
221 |
-
</div>
|
222 |
-
|
223 |
-
</div>
|
224 |
-
|
225 |
-
<div class="meow-col meow-span_1_of_2">
|
226 |
-
<?php $this->display_serialkey_box( "https://meowapps.com/plugin/media-file-renamer/" ); ?>
|
227 |
-
|
228 |
-
<div class="meow-box">
|
229 |
-
<h3>Advanced Settings</h3>
|
230 |
-
<div class="inside">
|
231 |
-
<form method="post" action="options.php">
|
232 |
-
<?php settings_fields( 'mfrh_advanced_settings' ); ?>
|
233 |
-
<?php do_settings_sections( 'mfrh_advanced_settings-menu' ); ?>
|
234 |
-
<?php submit_button(); ?>
|
235 |
-
</form>
|
236 |
-
</div>
|
237 |
-
</div>
|
238 |
-
|
239 |
-
<div class="meow-box">
|
240 |
-
<h3>Developer Settings</h3>
|
241 |
-
<div class="inside">
|
242 |
-
<form method="post" action="options.php">
|
243 |
-
<?php settings_fields( 'mfrh_developer_settings' ); ?>
|
244 |
-
<?php do_settings_sections( 'mfrh_developer_settings-menu' ); ?>
|
245 |
-
<?php _e( 'Do you want to clear/reset the logs? Click <a href="?page=mfrh_settings-menu&reset=true">here</a>.</b>', 'media-file-renamer' ); ?>
|
246 |
-
<?php submit_button(); ?>
|
247 |
-
</form>
|
248 |
-
</div>
|
249 |
-
</div>
|
250 |
-
|
251 |
-
</div>
|
252 |
-
|
253 |
-
</div>
|
254 |
-
|
255 |
-
</div>
|
256 |
-
<?php
|
257 |
-
}
|
258 |
-
|
259 |
-
/*
|
260 |
-
OPTIONS CALLBACKS
|
261 |
-
*/
|
262 |
-
|
263 |
-
function admin_rename_slug_callback( $args ) {
|
264 |
-
$value = get_option( 'mfrh_rename_slug', null );
|
265 |
-
$html = '<input type="checkbox" id="mfrh_rename_slug" name="mfrh_rename_slug" value="1" ' .
|
266 |
-
checked( 1, get_option( 'mfrh_rename_slug' ), false ) . '/>';
|
267 |
-
$html .= '<label>' .esc_html__( 'Update slug with filename', 'media-file-renamer' ). '</label><br />';
|
268 |
-
$html .= '<small>' .esc_html__( 'Better to keep this un-checked as the link might have been referenced somewhere else.', 'media-file-renamer' ). '</small>';
|
269 |
-
echo $html;
|
270 |
-
}
|
271 |
-
|
272 |
-
function admin_convert_to_ascii_callback( $args ) {
|
273 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_convert_to_ascii" name="mfrh_convert_to_ascii" value="1" ' .
|
274 |
-
checked( 1, apply_filters( 'mfrh_converts', false ), false ) . '/>';
|
275 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
276 |
-
$html .= '<small>' .esc_html__( 'Replace accents, umlauts, cyrillic, diacritics, by their ASCII equivalent.', 'media-file-renamer' )
|
277 |
-
.'<br /><i>' .esc_html__( 'Examples: ', 'media-file-renamer' ). 'tête -> tete, schön -> schon, Добро -> dobro, etc.</i></small>';
|
278 |
-
echo $html;
|
279 |
-
}
|
280 |
-
|
281 |
-
function admin_manual_rename_callback( $args ) {
|
282 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_manual_rename" name="mfrh_manual_rename" value="1" ' .
|
283 |
-
checked( 1, apply_filters( 'mfrh_manual', false ), false ) . '/>';
|
284 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
285 |
-
$html .= '<small>' .esc_html__( 'Manual field will be enabled in the Media Library and the Media Edit Screen.', 'media-file-renamer' ). '</small>';
|
286 |
-
echo $html;
|
287 |
-
}
|
288 |
-
|
289 |
-
function admin_numbered_files_callback( $args ) {
|
290 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_numbered_files" name="mfrh_numbered_files" value="1" ' .
|
291 |
-
checked( 1, apply_filters( 'mfrh_numbered', false ), false ) . '/>';
|
292 |
-
$html .= '<label>' .esc_html__( 'Enable Numbering', 'media-file-renamer' ). '</label><br />';
|
293 |
-
$html .= '<small>' .esc_html__( 'Identical filenames will be allowed by the plugin and a number will be appended automatically (myfile.jpg, myfile-2.jpg, myfile-3.jpg, etc).', 'media-file-renamer' ). '</small>';
|
294 |
-
echo $html;
|
295 |
-
}
|
296 |
-
|
297 |
-
function admin_rename_guid_callback( $args ) {
|
298 |
-
$html = '<input type="checkbox" id="mfrh_rename_guid" name="mfrh_rename_guid" value="1" ' .
|
299 |
-
checked( 1, get_option( 'mfrh_rename_guid' ), false ) . '/>';
|
300 |
-
$html .= '<label>' .esc_html__( 'Update GUID with Filename', 'media-file-renamer' ). '</label><br />';
|
301 |
-
$html .= '<small>' .esc_html__( 'The GUID will be renamed like the new filename. Better to keep this un-checked.', 'media-file-renamer' ). '</small>';
|
302 |
-
echo $html;
|
303 |
-
}
|
304 |
-
|
305 |
-
function admin_case_sensitive_callback( $args ) {
|
306 |
-
$html = '<input type="checkbox" id="mfrh_case_sensitive_check" name="mfrh_case_sensitive_check" value="1" ' .
|
307 |
-
checked( 1, get_option( 'mfrh_case_sensitive_check', true ), false ) . '/>';
|
308 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
309 |
-
$html .= '<small>' .esc_html__( 'This will check and detect as different such files as "abc.jpg" and "ABC.jpg". PHP itself recognize it as a same file, but probably not your system.', 'media-file-renamer' ). '</small>';
|
310 |
-
echo $html;
|
311 |
-
}
|
312 |
-
|
313 |
-
function admin_sync_alt_callback( $args ) {
|
314 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_sync_alt" name="mfrh_sync_alt" value="1" ' .
|
315 |
-
checked( 1, get_option( 'mfrh_sync_alt' ), false ) . '/>';
|
316 |
-
|
317 |
-
$what = '';
|
318 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
319 |
-
switch ( $method ) {
|
320 |
-
case 'media_title':
|
321 |
-
$what = __( "Title of Media", 'media-file-renamer' );
|
322 |
-
break;
|
323 |
-
case 'post_title':
|
324 |
-
$what = __( "Attached Post Title", 'media-file-renamer' );
|
325 |
-
break;
|
326 |
-
case 'product_title':
|
327 |
-
$what = __( "Title of Product", 'media-file-renamer' );
|
328 |
-
break;
|
329 |
-
default:
|
330 |
-
$what = __( "Error!", 'media-file-renamer' );
|
331 |
-
}
|
332 |
-
$label = sprintf(
|
333 |
-
/* Translators: %1$s: update target name, %2$s: update resourse name */
|
334 |
-
esc_html__( 'Update %1$s with %2$s', 'media-file-renamer' ),
|
335 |
-
esc_html__( 'ALT', 'media-file-renamer' ),
|
336 |
-
'<b>' .$what. '</b>'
|
337 |
-
);
|
338 |
-
$html .= '<label>' .$label. '</label><br />';
|
339 |
-
$html .= '<small>' .esc_html__( 'Keep in mind that the HTML of your posts and pages WILL NOT be modified, as that is simply too dangerous for a plug-in.', 'media-file-renamer' ). '</small>';
|
340 |
-
echo $html;
|
341 |
-
}
|
342 |
-
|
343 |
-
function admin_sync_media_title_callback( $args ) {
|
344 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_sync_media_title" name="mfrh_sync_media_title" value="1" ' .
|
345 |
-
checked( 1, get_option( 'mfrh_sync_media_title' ), false ) . '/>';
|
346 |
-
$what = __( "Error!", 'media-file-renamer' );
|
347 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
348 |
-
switch ( $method ) {
|
349 |
-
case 'alt_text':
|
350 |
-
$what = __( "Media ALT", 'media-file-renamer' );
|
351 |
-
break;
|
352 |
-
case 'post_title':
|
353 |
-
$what = __( "Attached Post Title", 'media-file-renamer' );
|
354 |
-
break;
|
355 |
-
case 'product_title':
|
356 |
-
$what = __( "Title of Product", 'media-file-renamer' );
|
357 |
-
break;
|
358 |
-
}
|
359 |
-
$label = sprintf(
|
360 |
-
/* Translators: %1$s: update target name, %2$s: update resourse name */
|
361 |
-
esc_html__( 'Update %1$s with %2$s', 'media-file-renamer' ),
|
362 |
-
esc_html__( 'Media Title', 'media-file-renamer' ),
|
363 |
-
'<b>' .$what. '</b>'
|
364 |
-
);
|
365 |
-
$html .= '<label>' .$label. '</label><br />';
|
366 |
-
$html .= '<small>' .esc_html__( 'Keep in mind that the HTML of your posts and pages WILL NOT be modified, as that is simply too dangerous for a plug-in.', 'media-file-renamer' ). '</small>';
|
367 |
-
echo $html;
|
368 |
-
}
|
369 |
-
|
370 |
-
function admin_undo_callback( $args ) {
|
371 |
-
$html = '<input type="checkbox" id="mfrh_undo" name="mfrh_undo" value="1" ' .
|
372 |
-
checked( 1, get_option( 'mfrh_undo', false ), false ) . '/>';
|
373 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
374 |
-
$html .= '<small>' .esc_html__( 'A little undo icon will be added in the Rename column (Media Library). When clicked, the filename will be renamed back to the original.', 'media-file-renamer' ). '</small>';
|
375 |
-
echo $html;
|
376 |
-
}
|
377 |
-
|
378 |
-
function admin_auto_rename_callback( $args ) {
|
379 |
-
$r = '';
|
380 |
-
$value = apply_filters( 'mfrh_method', 'media_title' );
|
381 |
-
|
382 |
-
// Available options
|
383 |
-
$options = array (
|
384 |
-
0 => array (
|
385 |
-
'value' => 'media_title',
|
386 |
-
'label' => 'Title of Media'
|
387 |
-
),
|
388 |
-
10 => array (
|
389 |
-
'value' => 'post_title',
|
390 |
-
'label' => 'Attached Post Title (Pro)',
|
391 |
-
'disabled' => !$this->is_registered()
|
392 |
-
),
|
393 |
-
20 => array (
|
394 |
-
'value' => 'alt_text',
|
395 |
-
'label' => 'Alternative Text (Pro)',
|
396 |
-
'disabled' => !$this->is_registered()
|
397 |
-
),
|
398 |
-
100 => array (
|
399 |
-
'value' => 'none',
|
400 |
-
'label' => 'None'
|
401 |
-
)
|
402 |
-
);
|
403 |
-
//// WooCommerce suppport
|
404 |
-
$x = is_plugin_active( 'woocommerce/woocommerce.php' );
|
405 |
-
$options[1] = array (
|
406 |
-
'value' => 'product_title',
|
407 |
-
'label' => 'Title of Product (Pro)',
|
408 |
-
'disabled' => !$x || !$this->is_registered(),
|
409 |
-
'hidden' => !$x
|
410 |
-
);
|
411 |
-
// Convert the options to HTML
|
412 |
-
ksort( $options );
|
413 |
-
foreach ( $options as $option ) {
|
414 |
-
$option['selected'] = $value == $option['value'];
|
415 |
-
$r .= $this->elm( 'option', $option, $option['label'] );
|
416 |
-
}
|
417 |
-
// Wrap with <select>
|
418 |
-
$r = $this->elm( 'select', array (
|
419 |
-
'id' => 'mfrh_auto_rename',
|
420 |
-
'name' => 'mfrh_auto_rename'
|
421 |
-
), $r );
|
422 |
-
// Add a note
|
423 |
-
$r = "<label>{$r}</label>" . '<small><br />' . __( 'If the plugin considers that it is too dangerous to rename the file directly at some point, it will be flagged internally <b>as to be renamed</b>. The list of those flagged files can be found in Media > File Renamer and they can be renamed from there.', 'media-file-renamer' ) . '</small>';
|
424 |
-
|
425 |
-
echo $r;
|
426 |
-
}
|
427 |
-
|
428 |
-
function admin_on_upload_callback( $args ) {
|
429 |
-
$html = '<input type="checkbox" id="mfrh_on_upload" name="mfrh_on_upload" value="1" ' .
|
430 |
-
checked( 1, get_option( 'mfrh_on_upload', false ), false ) . '/>';
|
431 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
432 |
-
$html .= '<small>' .esc_html__( 'During upload, the filename will be renamed based on the title of the media if there is any EXIF with the file. Otherwise, it will optimize the upload filename.', 'media-file-renamer' ). '</small>';
|
433 |
-
echo $html;
|
434 |
-
}
|
435 |
-
|
436 |
-
function admin_update_postmeta_callback( $args ) {
|
437 |
-
$value = get_option( 'mfrh_update_postmeta', true );
|
438 |
-
$html = '<input type="checkbox" id="mfrh_update_postmeta" name="mfrh_update_postmeta" value="1" ' .
|
439 |
-
checked( 1, get_option( 'mfrh_update_postmeta', true ), false ) . '/>';
|
440 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
441 |
-
$desc = sprintf(
|
442 |
-
/* Translators: %s: custom fields */
|
443 |
-
esc_html__( 'Update the references in the %s of the posts (including pages and custom types metadata).', 'media-file-renamer' ),
|
444 |
-
'<b>'.esc_html__( 'custom fields', 'media-file-renamer' ).'</b>'
|
445 |
-
);
|
446 |
-
$html .= '<small>' .$desc. '</small>';
|
447 |
-
echo $html;
|
448 |
-
}
|
449 |
-
|
450 |
-
function admin_update_posts_callback( $args ) {
|
451 |
-
$value = get_option( 'mfrh_update_posts', true );
|
452 |
-
$html = '<input type="checkbox" id="mfrh_update_posts" name="mfrh_update_posts" value="1" ' .
|
453 |
-
checked( 1, get_option( 'mfrh_update_posts', true ), false ) . '/>';
|
454 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
455 |
-
$desc = sprintf(
|
456 |
-
/* Translators: %1$s: content, %2$s: excerpt, */
|
457 |
-
esc_html__( 'Update the references to the renamed files in the %1$s and %2$s of the posts (pages and custom types included).', 'media-file-renamer' ),
|
458 |
-
'<b>'.esc_html__( 'content', 'media-file-renamer' ).'</b>',
|
459 |
-
'<b>'.esc_html__( 'excerpt', 'media-file-renamer' ).'</b>'
|
460 |
-
);
|
461 |
-
$html .= '<small>' .$desc. '</small>';
|
462 |
-
echo $html;
|
463 |
-
}
|
464 |
-
|
465 |
-
function admin_rename_on_save_callback( $args ) {
|
466 |
-
$value = get_option( 'mfrh_rename_on_save', null );
|
467 |
-
$html = '<input type="checkbox" id="mfrh_rename_on_save" name="mfrh_rename_on_save" value="1" ' .
|
468 |
-
checked( 1, get_option( 'mfrh_rename_on_save' ), false ) . '/>';
|
469 |
-
$html .= '<label>' .esc_html__( 'Enable (NOT RECOMMENDED)', 'media-file-renamer' ). '</label><br />';
|
470 |
-
$html .= '<small>' .esc_html__( 'You can modify the titles of your media while editing a post but, of course, the plugin can\'t update the HTML at this stage. With this option, the plugin will update the filenames and HTML after that you saved the post.', 'media-file-renamer' ). '</small>';
|
471 |
-
echo $html;
|
472 |
-
}
|
473 |
-
|
474 |
-
function admin_force_rename_callback( $args ) {
|
475 |
-
$value = get_option( 'mfrh_force_rename', false );
|
476 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_force_rename" name="mfrh_force_rename" value="1" ' .
|
477 |
-
checked( 1, get_option( 'mfrh_force_rename' ), false ) . '/>';
|
478 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
479 |
-
$html .= '<small>' .esc_html__( 'Update the references to the file even if the file renaming itself was not successful. You might want to use that option if your install is broken and you are trying to link your Media to files for which the filenames has been altered (after a migration for exemple)', 'media-file-renamer' ). '</small>';
|
480 |
-
echo $html;
|
481 |
-
}
|
482 |
-
|
483 |
-
function admin_log_callback( $args ) {
|
484 |
-
$value = get_option( 'mfrh_log', null );
|
485 |
-
$html = '<input type="checkbox" id="mfrh_log" name="mfrh_log" value="1" ' .
|
486 |
-
checked( 1, get_option( 'mfrh_log' ), false ) . '/>';
|
487 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
488 |
-
$desc = sprintf(
|
489 |
-
/* Translators: %s: link to media-file-renamer.log */
|
490 |
-
esc_html__( 'Simple logging that explains which actions has been run. The file is %s.', 'media-file-renamer' ),
|
491 |
-
'<a target="_blank" href="' . plugin_dir_url( __FILE__ ) . 'media-file-renamer.log">media-file-renamer.log</a>'
|
492 |
-
);
|
493 |
-
$html .= '<small>' .$desc. '</small>';
|
494 |
-
echo $html;
|
495 |
-
}
|
496 |
-
|
497 |
-
function admin_logsql_callback( $args ) {
|
498 |
-
$value = get_option( 'mfrh_logsql', null );
|
499 |
-
$html = '<input ' . disabled( $this->is_registered(), false, false ) . ' type="checkbox" id="mfrh_logsql" name="mfrh_logsql" value="1" ' .
|
500 |
-
checked( 1, get_option( 'mfrh_logsql' ), false ) . '/>';
|
501 |
-
$html .= '<label>' .esc_html__( 'Enable', 'media-file-renamer' ). '</label><br />';
|
502 |
-
$desc = sprintf(
|
503 |
-
/* Translators: %1$s: link to mfrh_sql.log, %2$s: link to mfrh_sql_revert.log */
|
504 |
-
esc_html__( 'The files %1$s and %2$s will be created and they will include the raw SQL queries which were run by the plugin. If there is an issue, the revert file can help you reverting the changes more easily.', 'media-file-renamer' ),
|
505 |
-
'<a target="_blank" href="' . plugin_dir_url( __FILE__ ) . 'mfrh_sql.log">mfrh_sql.log</a>',
|
506 |
-
'<a target="_blank" href="' . plugin_dir_url( __FILE__ ) . 'mfrh_sql_revert.log">mfrh_sql_revert.log</a>'
|
507 |
-
);
|
508 |
-
$html .= '<small>' .$desc. '</small>';
|
509 |
-
echo $html;
|
510 |
-
}
|
511 |
-
|
512 |
-
/**
|
513 |
-
*
|
514 |
-
* GET / SET OPTIONS (TO REMOVE)
|
515 |
-
*
|
516 |
-
*/
|
517 |
-
|
518 |
-
function old_getoption( $option, $section, $default = '' ) {
|
519 |
-
$options = get_option( $section );
|
520 |
-
if ( isset( $options[$option] ) ) {
|
521 |
-
if ( $options[$option] == "off" ) {
|
522 |
-
return false;
|
523 |
-
}
|
524 |
-
if ( $options[$option] == "on" ) {
|
525 |
-
return true;
|
526 |
-
}
|
527 |
-
return $options[$option];
|
528 |
-
}
|
529 |
-
return $default;
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* TODO: Move to the common library
|
534 |
-
* Composes HTML expression for a single element
|
535 |
-
* @param string $tag Tag name
|
536 |
-
* @param array|string $attrs Attributes
|
537 |
-
* @param string $content='' Content. Null omits the closing tag
|
538 |
-
* @return string HTML expression for an element
|
539 |
-
*/
|
540 |
-
public function elm( $tag, $attrs = null, $content = '' ) {
|
541 |
-
$r = "<{$tag}";
|
542 |
-
if ( $attrs ) $r .= is_string( $attrs ) ? " {$attrs}" : $this->attrs( $attrs );
|
543 |
-
$r .= '>';
|
544 |
-
if ( is_null( $content ) ) return $r;
|
545 |
-
return "{$r}{$content}</{$tag}>";
|
546 |
-
}
|
547 |
-
|
548 |
-
/**
|
549 |
-
* TODO: Move to the common library
|
550 |
-
* Converts an associative array to HTML attributes
|
551 |
-
* @param array $map An associative array
|
552 |
-
* @return string HTML expression for attributes
|
553 |
-
*/
|
554 |
-
public function attrs( $map ) {
|
555 |
-
$r = '';
|
556 |
-
foreach ( $map as $attr => $value ) $r .= $this->attr( $attr, $value );
|
557 |
-
return $r;
|
558 |
-
}
|
559 |
-
|
560 |
-
/**
|
561 |
-
* TODO: Move to the common library
|
562 |
-
* Composes HTML expression for a single attribute.
|
563 |
-
* If the value was exact FALSE, returns empty string
|
564 |
-
* @param string $name
|
565 |
-
* @param mixed $value
|
566 |
-
* @return string HTML expression for an attribute
|
567 |
-
*/
|
568 |
-
public function attr( $name, $value ) {
|
569 |
-
if ( is_null( $value ) ) return '';
|
570 |
-
if ( is_bool( $value ) ) return $value ? " {$name}" : '';
|
571 |
-
return " {$name}=\"" . ( esc_attr( (string) $value ) ) . '"';
|
572 |
-
}
|
573 |
-
}
|
574 |
-
|
575 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
readme.txt
CHANGED
@@ -1,51 +1,57 @@
|
|
1 |
-
=== Media File Renamer
|
2 |
-
Contributors: TigrouMeow
|
3 |
-
Tags: rename,
|
4 |
Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a950f61832f
|
5 |
Requires at least: 4.8
|
6 |
-
Tested up to: 5.
|
7 |
-
Requires PHP:
|
8 |
-
Stable tag:
|
9 |
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
-
|
14 |
-
Media File Renamer Auto is a WordPress plugin that physically renames media files nicely for a cleaner system and for a better SEO. Please read this description.
|
15 |
-
|
16 |
-
=== IMPORTANT ===
|
17 |
-
This is an *automatic* renamer based on the Media title. This plugin features were all meant to be automatic depending on the title of the Media. Manual Rename (and a few more features) were added two years later, in a Pro version. I add complex features based on requests usually in the Pro to be able to maintain the quality of the plugin and its support.
|
18 |
|
19 |
=== HOW IT WORKS ===
|
20 |
-
|
21 |
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
The [Pro Version](https://meowapps.com/plugin/media-file-renamer/) gives a few more features like manual renaming, renaming depending on the post the media is attached to or the content of the alternative text (ALT), logging of SQL queries and a few more options. A good process is to actually let the plugin do the renaming automatically (like in the free version) and to do manual renaming for the files that require fine tuning.
|
26 |
|
27 |
-
|
28 |
-
File renaming is a dangerous process. Before renaming everything automatically, try to rename a few files first and check carefully that all the references to those files have been properly updated on your website. WordPress has so many themes and plugins that this renaming process can't unfortunately cover all the cases, especially if other plugins are using unconventional ways. If references aren't updated properly, please write a nice post (not an angry one) in the support threads :) I will try my best to cover more and more special cases. In any case, always make a **backup** of your database and files before using a plugin that alter your install. Also, if your website seems broken after a few renames, try to **clear your cache**. The cached HTML will indeed not be linked to the new filenames.
|
29 |
|
30 |
-
===
|
31 |
-
|
32 |
|
33 |
-
===
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
-
|
|
|
39 |
|
40 |
== Installation ==
|
41 |
|
42 |
-
1. Upload
|
43 |
-
2. Activate the plugin through the 'Plugins' menu
|
44 |
3. Try it with one file first! :)
|
45 |
|
46 |
-
==
|
47 |
|
48 |
-
|
|
|
49 |
|
50 |
== Screenshots ==
|
51 |
|
@@ -57,6 +63,11 @@ Check the FAQ on the official website, [here](https://meowapps.com/media-file-re
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
|
|
60 |
= 4.7.0 =
|
61 |
* Fix: Issue with rare characters used in the title.
|
62 |
* Fix: Issue with PDF thumbnails.
|
@@ -270,7 +281,7 @@ Check the FAQ on the official website, [here](https://meowapps.com/media-file-re
|
|
270 |
= 2.2.0 =
|
271 |
* Add: Many new options.
|
272 |
* Add: Pro version.
|
273 |
-
* Add: Manual file rename
|
274 |
* Update: Use actions for renaming (to facilitate support for more renaming features).
|
275 |
|
276 |
= 2.0.0 =
|
1 |
+
=== Media File Renamer ===
|
2 |
+
Contributors: TigrouMeow
|
3 |
+
Tags: rename, file, media, seo, files, renamer, optimize, library
|
4 |
Donate link: https://commerce.coinbase.com/checkout/d047546a-77a8-41c8-9ea9-4a950f61832f
|
5 |
Requires at least: 4.8
|
6 |
+
Tested up to: 5.5
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 5.0.0
|
9 |
|
10 |
+
Renames your media files for better SEO and a nicer filesystem (automatically or manually).
|
11 |
|
12 |
== Description ==
|
13 |
+
Renames your media files for better SEO and a nicer filesystem (automatically or manually). For more information, please visit the official website: [Media File Renamer](https://meowapps.com/plugin/media-file-renamer/).
|
|
|
|
|
|
|
|
|
14 |
|
15 |
=== HOW IT WORKS ===
|
16 |
+
Media File Renamer, by default, automatically renames the filenames of your Media entries based on their titles. You can trigger this, or you can let it happen every time you modify titles. You can also rename the files manually. The references to those files will be also updated (posts, pages, custom types, metadata, etc...). You can use the Media Library, or the Media Edit screen.
|
17 |
|
18 |
+
However, it is highly recommended to use the pretty and very dynamic Renamer Dashboard. If you like to work fast and well, you will really love working with this modern dashboard.
|
19 |
|
20 |
+
[youtube https://youtu.be/XPbKE8pq0i0]
|
|
|
21 |
|
22 |
+
Please have a look at the [tutorial](https://meowapps.com/media-file-renamer-tutorial/).
|
|
|
23 |
|
24 |
+
=== COMPATIBILITY ===
|
25 |
+
It works with a lot of features of WordPress and other plugins, such as Retina files, WebP, rescaled image (since WP 5.3), PDF Thumbnails, UTF8 files, optimized images, various encodings, etc. There are too many handled and specific cases to be listed here, but we are doing our best to keep up with everything :)
|
26 |
|
27 |
+
=== PRO VERSION ===
|
28 |
+
More features are added in the [Pro Version](https://meowapps.com/plugin/media-file-renamer/), such as:
|
29 |
+
* Transliteration (replace various accents, emoticons, umlauts, cyrillic, diacritics, by their ASCII equivalent)
|
30 |
+
* Automatic renaming based on the attached posts, products (and other post types), or ALT text
|
31 |
+
* Anonymizer (rename the files with anonymous files)
|
32 |
+
* Metadata syncing (ALT text, title, etc)
|
33 |
+
* Numbered files (to allow similar filenames to be renamed)
|
34 |
+
* Force Rename (if your install is broken, this will help you to re-link your media entries to your files)
|
35 |
+
|
36 |
+
=== BE CAREFUL: PREPARE A BACKUP ===
|
37 |
+
Renaming (or moving) files is a dangerous process. Before doing anything in bulk, try renaming your files on by one, then check if the references (in your pages) have been updated properly. The renaming can't cover all use cases, as some plugins are unfortunately using unconventional ways to encode the usage of the files. Therefore, **it is absolutely necessary to backup your files and database** in order to enjoy this plugin at its full extent.
|
38 |
|
39 |
+
=== WHEN SOMETHING BAD HAPPENS ===
|
40 |
+
If your website seems broken after a few renames, try to **clear your cache**. The cached HTML is often using the old references. You can also enable the Undo feature and try to rollback to the previous filenames. If references aren't updated properly, please write a nice post (not an angry one) in the support threads :) I am trying my best to cover more and more use cases. Please have a look here: [Questions & Issues](https://meowapps.com/media-file-renamer-faq-issues/).
|
41 |
|
42 |
+
=== FOR DEVELOPERS ===
|
43 |
+
The plugin can be tweaked in many ways, there are many actions and filters available. Through them, for example, you can customize the automatic renaming to your liking. There is also a little API that you can call. More about this [here](https://meowapps.com/media-file-renamer-faq/).
|
44 |
|
45 |
== Installation ==
|
46 |
|
47 |
+
1. Upload the plugin to your WordPress.
|
48 |
+
2. Activate the plugin through the 'Plugins' menu.
|
49 |
3. Try it with one file first! :)
|
50 |
|
51 |
+
== Upgrade Notice ==
|
52 |
|
53 |
+
1. Replace the plugin with the new one.
|
54 |
+
2. Nothing else is required! :)
|
55 |
|
56 |
== Screenshots ==
|
57 |
|
63 |
|
64 |
== Changelog ==
|
65 |
|
66 |
+
= 5.0.0 =
|
67 |
+
* Info: Brand new UI! Made everything much clearer.
|
68 |
+
* Fix: Issues related to WebP and PDF thumbnails.
|
69 |
+
* Fix: Issues related to breaking characters in the Media or Attached Post Title.
|
70 |
+
|
71 |
= 4.7.0 =
|
72 |
* Fix: Issue with rare characters used in the title.
|
73 |
* Fix: Issue with PDF thumbnails.
|
281 |
= 2.2.0 =
|
282 |
* Add: Many new options.
|
283 |
* Add: Pro version.
|
284 |
+
* Add: Manual file rename.
|
285 |
* Update: Use actions for renaming (to facilitate support for more renaming features).
|
286 |
|
287 |
= 2.0.0 =
|
scripts/media-library.js
DELETED
@@ -1,280 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* The script for Media File Renamer in Media Library
|
3 |
-
*/
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Quick Renamer
|
7 |
-
*/
|
8 |
-
(function($) {
|
9 |
-
var col;
|
10 |
-
|
11 |
-
/**
|
12 |
-
* Initializes the entire part of the UI
|
13 |
-
*/
|
14 |
-
$(document).ready(function($) {
|
15 |
-
init('.mfrh_column');
|
16 |
-
});
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Initializes the specified columns
|
20 |
-
* @param {string|DOMElement|jQuery} cols - Columns to initialize
|
21 |
-
*/
|
22 |
-
function init(cols) {
|
23 |
-
cols = $(cols);
|
24 |
-
cols.each(function() {
|
25 |
-
var col = $(this);
|
26 |
-
var id = col.find('input[data-name="id"]').val();
|
27 |
-
|
28 |
-
// Quick Renamer
|
29 |
-
(function() {
|
30 |
-
var wrap = col;
|
31 |
-
var button = wrap.find('.button.rename');
|
32 |
-
var input = wrap.find('input[data-name="filename"]');
|
33 |
-
|
34 |
-
button.on('click', function(ev) {
|
35 |
-
ev.preventDefault();
|
36 |
-
if (isBusy(col)) return;
|
37 |
-
goBusy(col);
|
38 |
-
button.addClass('updating-message');
|
39 |
-
rename(col, input.val());
|
40 |
-
});
|
41 |
-
input.on('keydown', function(ev) {
|
42 |
-
if (ev.which != 13) return; // 13 = Enter
|
43 |
-
ev.preventDefault();
|
44 |
-
button.trigger('click');
|
45 |
-
});
|
46 |
-
input.on('change keyup', function(ev) {
|
47 |
-
if (input.val() == input.attr('data-origin')) input.removeClass('changed');
|
48 |
-
else input.addClass('changed');
|
49 |
-
});
|
50 |
-
})();
|
51 |
-
|
52 |
-
// Quick Auto Renamer
|
53 |
-
(function() {
|
54 |
-
var wrap = col;
|
55 |
-
var button = wrap.find('.button.auto-rename');
|
56 |
-
var input = wrap.find('input[data-name="filename"]');
|
57 |
-
|
58 |
-
button.on('mouseover', function(ev) {
|
59 |
-
if (isBusy(col)) return;
|
60 |
-
input.addClass('hidden');
|
61 |
-
});
|
62 |
-
button.on('mouseout', function(ev) {
|
63 |
-
if (isBusy(col)) return;
|
64 |
-
input.removeClass('hidden');
|
65 |
-
});
|
66 |
-
button.on('click', function(ev) {
|
67 |
-
ev.preventDefault();
|
68 |
-
if (isBusy(col)) return;
|
69 |
-
goBusy(col);
|
70 |
-
button.addClass('updating-message');
|
71 |
-
rename(col, null);
|
72 |
-
});
|
73 |
-
})();
|
74 |
-
|
75 |
-
// Quick Undo
|
76 |
-
(function() {
|
77 |
-
var wrap = col;
|
78 |
-
var button = wrap.find('.undo');
|
79 |
-
|
80 |
-
button.on('click', function(ev) {
|
81 |
-
ev.preventDefault();
|
82 |
-
if (isBusy(col)) return;
|
83 |
-
goBusy(col);
|
84 |
-
|
85 |
-
$.ajax(ajaxurl, {
|
86 |
-
type: 'POST',
|
87 |
-
dataType: 'json',
|
88 |
-
data: {
|
89 |
-
action: 'mfrh_undo_media',
|
90 |
-
subaction: 'undoMediaId',
|
91 |
-
id: id
|
92 |
-
}
|
93 |
-
|
94 |
-
}).done(function(result) {
|
95 |
-
/**
|
96 |
-
* Expected result format: {
|
97 |
-
* success: True or False
|
98 |
-
* data: {
|
99 |
-
* filename: New Filename
|
100 |
-
* ids: Affected Posts IDs
|
101 |
-
* }
|
102 |
-
* }
|
103 |
-
*/
|
104 |
-
if (result.success === false) { // Rejected
|
105 |
-
alert(result.data);
|
106 |
-
return;
|
107 |
-
}
|
108 |
-
// Update all the affected posts' columns
|
109 |
-
for (var i = 0; i < result.data.ids.length; i++) {
|
110 |
-
var id = result.data.ids[i];
|
111 |
-
update('#post-' + id + ' .mfrh_column', result.data.filename);
|
112 |
-
}
|
113 |
-
});
|
114 |
-
});
|
115 |
-
})();
|
116 |
-
|
117 |
-
// Quick Lock
|
118 |
-
(function() {
|
119 |
-
var wrap = col;
|
120 |
-
var button = wrap.find('.lock');
|
121 |
-
|
122 |
-
button.on('click', function(ev) {
|
123 |
-
ev.preventDefault();
|
124 |
-
if (isBusy(col)) return;
|
125 |
-
goBusy(col);
|
126 |
-
|
127 |
-
$.ajax(ajaxurl, {
|
128 |
-
type: 'POST',
|
129 |
-
dataType: 'json',
|
130 |
-
data: {
|
131 |
-
action: 'mfrh_lock_media',
|
132 |
-
id: id
|
133 |
-
}
|
134 |
-
|
135 |
-
}).done(function(result) {
|
136 |
-
if (result.success === false) { // Rejected
|
137 |
-
alert(result.data);
|
138 |
-
return;
|
139 |
-
}
|
140 |
-
update(col, null);
|
141 |
-
});
|
142 |
-
});
|
143 |
-
})();
|
144 |
-
|
145 |
-
// Quick Unlock
|
146 |
-
(function() {
|
147 |
-
var wrap = col;
|
148 |
-
var button = wrap.find('.unlock');
|
149 |
-
|
150 |
-
button.on('click', function(ev) {
|
151 |
-
ev.preventDefault();
|
152 |
-
if (isBusy(col)) return;
|
153 |
-
goBusy(col);
|
154 |
-
|
155 |
-
$.ajax(ajaxurl, {
|
156 |
-
type: 'POST',
|
157 |
-
dataType: 'json',
|
158 |
-
data: {
|
159 |
-
action: 'mfrh_lock_media',
|
160 |
-
subaction: 'unlock',
|
161 |
-
id: id
|
162 |
-
}
|
163 |
-
|
164 |
-
}).done(function(result) {
|
165 |
-
if (result.success === false) { // Rejected
|
166 |
-
alert(result.data);
|
167 |
-
return;
|
168 |
-
}
|
169 |
-
update(col, null);
|
170 |
-
});
|
171 |
-
});
|
172 |
-
})();
|
173 |
-
});
|
174 |
-
|
175 |
-
cols.removeClass('busy');
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* Returns whether a column is busy
|
180 |
-
* @param {string|DOMElement|jQuery} col - A column to check
|
181 |
-
* @return {boolean}
|
182 |
-
*/
|
183 |
-
function isBusy(col) {
|
184 |
-
return $(col).hasClass('busy');
|
185 |
-
}
|
186 |
-
|
187 |
-
/**
|
188 |
-
* Makes a column busy
|
189 |
-
* @param {string|DOMElement|jQuery} col - A column to make busy
|
190 |
-
*/
|
191 |
-
function goBusy(col) {
|
192 |
-
col = $(col);
|
193 |
-
col.addClass('busy');
|
194 |
-
col.find('input[type="text"]').prop('disabled', true);
|
195 |
-
}
|
196 |
-
|
197 |
-
/**
|
198 |
-
* Sends a rename request
|
199 |
-
* @param {string|DOMElement|jQuery} col - A column to update
|
200 |
-
* @param {string|null} newName - The new name of the media. null means auto
|
201 |
-
* @return {jQuery.Deffered} - The actual ajax request
|
202 |
-
*/
|
203 |
-
function rename(col, newName) {
|
204 |
-
col = $(col);
|
205 |
-
var id = col.find('input[data-name="id"]').val();
|
206 |
-
|
207 |
-
var data = {
|
208 |
-
action: 'mfrh_rename_media',
|
209 |
-
subaction: 'renameMediaId',
|
210 |
-
id: id
|
211 |
-
}
|
212 |
-
if (typeof newName == 'string') data.newName = newName;
|
213 |
-
|
214 |
-
return $.ajax(ajaxurl, {
|
215 |
-
type: 'POST',
|
216 |
-
dataType: 'json',
|
217 |
-
data: data
|
218 |
-
|
219 |
-
}).done(function(result) {
|
220 |
-
/**
|
221 |
-
* Expected result format: {
|
222 |
-
* success: True or False
|
223 |
-
* data: {
|
224 |
-
* filename: New Filename
|
225 |
-
* ids: Affected Posts IDs
|
226 |
-
* }
|
227 |
-
* }
|
228 |
-
*/
|
229 |
-
if (result.success === false) { // Rejected
|
230 |
-
alert(result.data);
|
231 |
-
return;
|
232 |
-
}
|
233 |
-
// Update all the affected posts' columns
|
234 |
-
for (var i = 0; i < result.data.ids.length; i++) {
|
235 |
-
var id = result.data.ids[i];
|
236 |
-
update('#post-' + id + ' .mfrh_column', result.data.filename);
|
237 |
-
}
|
238 |
-
});
|
239 |
-
}
|
240 |
-
|
241 |
-
/**
|
242 |
-
* Updates the view of the row which affected by asynchronous rename
|
243 |
-
* @param {string|DOMElement|jQuery} col - A column to update
|
244 |
-
* @param {string|null} newName - The new name of the media
|
245 |
-
* @return {jQuery.Deffered} - The actual ajax request
|
246 |
-
*/
|
247 |
-
function update(col, newName) {
|
248 |
-
col = $(col);
|
249 |
-
var id = col.find('input[data-name="id"]').val();
|
250 |
-
|
251 |
-
// Update the filename information in 'File' column
|
252 |
-
if (typeof newName == 'string') {
|
253 |
-
var filename = col.closest('tr').find('.column-title .filename');
|
254 |
-
var children = filename.children().detach();
|
255 |
-
filename.text(newName);
|
256 |
-
filename.prepend(children);
|
257 |
-
}
|
258 |
-
|
259 |
-
// Re-render the column
|
260 |
-
return $.ajax(ajaxurl, {
|
261 |
-
type: 'POST',
|
262 |
-
dataType: 'json',
|
263 |
-
data: {
|
264 |
-
action: 'mfrh_render_column',
|
265 |
-
id: id
|
266 |
-
}
|
267 |
-
|
268 |
-
}).done(function(result) {
|
269 |
-
if (result.success === false) { // Rejected
|
270 |
-
// TODO Reload the page
|
271 |
-
return;
|
272 |
-
}
|
273 |
-
// Overwrite the column content with the rendering result
|
274 |
-
col.html(result.data);
|
275 |
-
// Re-initialize the content
|
276 |
-
init(col);
|
277 |
-
});
|
278 |
-
}
|
279 |
-
|
280 |
-
})(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
style.css
DELETED
@@ -1,94 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* The common styles for Media File Renamer
|
3 |
-
*/
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Rename column in Media Library
|
7 |
-
*/
|
8 |
-
.mfrh_column {
|
9 |
-
position: relative;
|
10 |
-
}
|
11 |
-
.mfrh_column.busy a {
|
12 |
-
cursor: default;
|
13 |
-
pointer-events: none;
|
14 |
-
}
|
15 |
-
|
16 |
-
/* Buttons */
|
17 |
-
.mfrh_column .button {
|
18 |
-
display: inline-block;
|
19 |
-
}
|
20 |
-
.mfrh_column .button-primary,
|
21 |
-
.mfrh_column .button-primary .dashicons {
|
22 |
-
line-height: 24px;
|
23 |
-
}
|
24 |
-
.mfrh_column .button-primary {
|
25 |
-
padding: 4px 8px;
|
26 |
-
text-align: center;
|
27 |
-
min-height: auto;
|
28 |
-
line-height: unset;
|
29 |
-
}
|
30 |
-
.mfrh_column .button-primary.updating-message:before {
|
31 |
-
margin: 3px 0 0 0;
|
32 |
-
}
|
33 |
-
.mfrh_column .button-primary.updating-message .label {
|
34 |
-
display: none;
|
35 |
-
}
|
36 |
-
.mfrh_column .button.rename {
|
37 |
-
display: none;
|
38 |
-
}
|
39 |
-
|
40 |
-
/* Icons */
|
41 |
-
.mfrh_column .icons-wrap {
|
42 |
-
display: inline-block;
|
43 |
-
}
|
44 |
-
.mfrh_column .icons-wrap .dashicons {
|
45 |
-
display: inline-block;
|
46 |
-
}
|
47 |
-
.mfrh_column.busy .icons-wrap a.dashicons {
|
48 |
-
opacity: 0.5;
|
49 |
-
}
|
50 |
-
.mfrh_column .icons-wrap .dashicons + .dashicons {
|
51 |
-
margin-left: -2px; /* Shrinks the gaps between icons */
|
52 |
-
}
|
53 |
-
.mfrh_column .icons-wrap .dashicons-lock,
|
54 |
-
.mfrh_column .icons-wrap .dashicons-unlock {
|
55 |
-
font-size: 20px;
|
56 |
-
}
|
57 |
-
.mfrh_column .icons-wrap .dashicons-lock {
|
58 |
-
color: #36b15c;
|
59 |
-
}
|
60 |
-
.mfrh_column .icons-wrap .dashicons-yes {
|
61 |
-
font-size: 24px;
|
62 |
-
color: #36b15c;
|
63 |
-
}
|
64 |
-
.mfrh_column .icons-wrap .dashicons-undo {
|
65 |
-
font-size: 15px;
|
66 |
-
vertical-align: -4px;
|
67 |
-
color: #de4817;
|
68 |
-
}
|
69 |
-
|
70 |
-
/* Text Fields */
|
71 |
-
.mfrh_column input[type="text"] {
|
72 |
-
display: inline-block;
|
73 |
-
position: relative;
|
74 |
-
width: calc(100% - 128px);
|
75 |
-
height: 28px;
|
76 |
-
font-size: 11px;
|
77 |
-
}
|
78 |
-
.mfrh_column input[data-name="recommended-filename"] {
|
79 |
-
display: none;
|
80 |
-
background-color: white;
|
81 |
-
color: #0073aa;
|
82 |
-
}
|
83 |
-
.mfrh_column input[data-name="filename"].hidden {
|
84 |
-
display: none;
|
85 |
-
}
|
86 |
-
.mfrh_column input[data-name="filename"].hidden ~ input[data-name="recommended-filename"] {
|
87 |
-
display: inline-block;
|
88 |
-
}
|
89 |
-
.mfrh_column input[data-name="filename"].changed ~ .button.rename {
|
90 |
-
display: inline-block;
|
91 |
-
}
|
92 |
-
.mfrh_column input[data-name="filename"].changed ~ .button.auto-rename {
|
93 |
-
display: none;
|
94 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ui.php
DELETED
@@ -1,459 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Meow_MFRH_UI {
|
4 |
-
private $core = null;
|
5 |
-
private $admin = null;
|
6 |
-
|
7 |
-
function __construct( $core, $admin ) {
|
8 |
-
$this->core = $core;
|
9 |
-
$this->admin = $admin;
|
10 |
-
add_action( 'admin_head', array( $this, 'admin_head' ) );
|
11 |
-
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
12 |
-
add_action( 'add_meta_boxes', array( $this, 'add_rename_metabox' ) );
|
13 |
-
add_action( 'wp_ajax_mfrh_rename_media', array( $this, 'wp_ajax_mfrh_rename_media' ) );
|
14 |
-
add_action( 'wp_ajax_mfrh_undo_media', array( $this, 'wp_ajax_mfrh_undo_media' ) );
|
15 |
-
add_action( 'wp_ajax_mfrh_lock_media', array( $this, 'wp_ajax_mfrh_lock_media' ) );
|
16 |
-
add_action( 'wp_ajax_mfrh_analyze_media', array( $this, 'wp_ajax_mfrh_analyze_media' ) );
|
17 |
-
add_action( 'wp_ajax_mfrh_render_column', array( $this, 'wp_ajax_mfrh_render_column' ) );
|
18 |
-
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
19 |
-
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
20 |
-
add_filter( 'media_send_to_editor', array( $this, 'media_send_to_editor' ), 20, 3 );
|
21 |
-
add_filter( 'option_active_plugins', array( $this, 'active_plugins' ) );
|
22 |
-
|
23 |
-
// Column for Media Library
|
24 |
-
$is_manual = apply_filters( 'mfrh_manual', false );
|
25 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
26 |
-
if ( $method != 'none' || $is_manual ) {
|
27 |
-
add_filter( 'manage_media_columns', array( $this, 'add_media_columns' ) );
|
28 |
-
add_action( 'manage_media_custom_column', array( $this, 'manage_media_custom_column' ), 10, 2 );
|
29 |
-
}
|
30 |
-
|
31 |
-
// Media Library Bulk Actions
|
32 |
-
add_filter( 'bulk_actions-upload', array( $this, 'library_bulk_actions' ) );
|
33 |
-
add_filter( 'handle_bulk_actions-upload', array( $this, 'library_bulk_actions_handler' ), 10, 3 );
|
34 |
-
}
|
35 |
-
|
36 |
-
function active_plugins( $plugins ) {
|
37 |
-
if ( // Media File Renamer is doing Ajax
|
38 |
-
wp_doing_ajax() &&
|
39 |
-
isset( $_REQUEST['action'] ) &&
|
40 |
-
substr( $_REQUEST['action'], 0, 5 ) == 'mfrh_'
|
41 |
-
) {
|
42 |
-
// Remove the all active plugins except for this plugin itself and a few supported plugins
|
43 |
-
foreach ( $plugins as $i => $plugin ) {
|
44 |
-
if ( preg_match( '/\/media-file-renamer(-pro)?\.php$/', $plugin ) ) continue;
|
45 |
-
if ( preg_match( '/^polylang(-pro)\//', $plugin ) ) continue; // Polylang
|
46 |
-
unset( $plugins[$i] );
|
47 |
-
}
|
48 |
-
}
|
49 |
-
return $plugins;
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Renders a view within the views directory.
|
54 |
-
* @param string $view The name of the view to render
|
55 |
-
* @param array $data
|
56 |
-
* An associative array of variables to bind to the view.
|
57 |
-
* Each key turns into a variable name.
|
58 |
-
* @return string Rendered view
|
59 |
-
*/
|
60 |
-
function render_view( $view, $data = null ) {
|
61 |
-
ob_start();
|
62 |
-
if ( is_array( $data ) ) extract( $data );
|
63 |
-
include( __DIR__ . "/views/$view.php" );
|
64 |
-
return ob_get_clean();
|
65 |
-
}
|
66 |
-
|
67 |
-
/**
|
68 |
-
* Loads some scripts & styles for certain pages
|
69 |
-
* @param string $page The current page identifier
|
70 |
-
*/
|
71 |
-
function admin_enqueue_scripts( $page ) {
|
72 |
-
global $mfrh_version;
|
73 |
-
$base = plugin_dir_url( __FILE__ );
|
74 |
-
wp_enqueue_style( 'mfrh_style', $base . 'style.css', array(), $mfrh_version );
|
75 |
-
|
76 |
-
switch ( $page ) {
|
77 |
-
case 'upload.php': // Media Library
|
78 |
-
wp_enqueue_script( 'mfrh_media-library', $base . 'scripts/media-library.js', array( 'jquery' ), $mfrh_version );
|
79 |
-
break;
|
80 |
-
}
|
81 |
-
}
|
82 |
-
|
83 |
-
function admin_head() {
|
84 |
-
if ( !empty( $_GET['mfrh_rename'] ) ) {
|
85 |
-
$mfrh_rename = $_GET['mfrh_rename'];
|
86 |
-
$this->core->rename( $mfrh_rename );
|
87 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'mfrh_rename' ), $_SERVER['REQUEST_URI'] );
|
88 |
-
}
|
89 |
-
if ( !empty( $_GET['mfrh_unlock'] ) ) {
|
90 |
-
$mfrh_unlock = $_GET['mfrh_unlock'];
|
91 |
-
delete_post_meta( $mfrh_unlock, '_manual_file_renaming' );
|
92 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'mfrh_unlock' ), $_SERVER['REQUEST_URI'] );
|
93 |
-
}
|
94 |
-
if ( !empty( $_GET['mfrh_undo'] ) ) {
|
95 |
-
$mfrh_undo = $_GET['mfrh_undo'];
|
96 |
-
$original_filename = get_post_meta( $mfrh_undo, '_original_filename', true );
|
97 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'mfrh_undo' ), $_SERVER['REQUEST_URI'] );
|
98 |
-
$this->core->rename( $mfrh_undo, $original_filename );
|
99 |
-
|
100 |
-
$fp = get_attached_file( $mfrh_undo );
|
101 |
-
$path_parts = mfrh_pathinfo( $fp );
|
102 |
-
$basename = $path_parts['basename'];
|
103 |
-
if ( $basename == $original_filename )
|
104 |
-
delete_post_meta( $mfrh_undo, '_original_filename' );
|
105 |
-
}
|
106 |
-
if ( !empty( $_GET['mfrh_lock'] ) ) {
|
107 |
-
$mfrh_lock = $_GET['mfrh_lock'];
|
108 |
-
add_post_meta( $mfrh_lock, '_manual_file_renaming', true, true );
|
109 |
-
$_SERVER['REQUEST_URI'] = remove_query_arg( array( 'mfrh_lock' ), $_SERVER['REQUEST_URI'] );
|
110 |
-
}
|
111 |
-
|
112 |
-
echo $this->render_view( 'admin-head' );
|
113 |
-
}
|
114 |
-
|
115 |
-
function admin_menu() {
|
116 |
-
$method = apply_filters( 'mfrh_method', 'media_title' );
|
117 |
-
if ( $method != 'none' ) {
|
118 |
-
add_media_page( 'Media File Renamer', __( 'Rename', 'media-file-renamer' ), 'manage_options', 'rename_media_files', array( $this, 'rename_media_files' ) );
|
119 |
-
}
|
120 |
-
}
|
121 |
-
|
122 |
-
function rename_media_files() {
|
123 |
-
global $wpdb;
|
124 |
-
if ( $locked = ( isset( $_GET ) && isset( $_GET['mfrh_lockall'] ) ) ) {
|
125 |
-
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_manual_file_renaming'" );
|
126 |
-
$wpdb->query( "INSERT INTO $wpdb->postmeta (meta_key, meta_value, post_id)
|
127 |
-
SELECT '_manual_file_renaming', 1, p.ID
|
128 |
-
FROM $wpdb->posts p WHERE post_status = 'inherit' AND post_type = 'attachment'"
|
129 |
-
);
|
130 |
-
}
|
131 |
-
|
132 |
-
if ( isset( $_GET ) && isset( $_GET['mfrh_unlockall'] ) ) {
|
133 |
-
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_manual_file_renaming'" );
|
134 |
-
}
|
135 |
-
|
136 |
-
$checkFiles = null;
|
137 |
-
if ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) )
|
138 |
-
$checkFiles = $this->core->check_text();
|
139 |
-
|
140 |
-
$all_media = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts p
|
141 |
-
WHERE post_status = 'inherit' AND post_type = 'attachment'" );
|
142 |
-
$manual_media = $wpdb->get_var( "SELECT COUNT(*)
|
143 |
-
FROM $wpdb->postmeta pm, $wpdb->posts p
|
144 |
-
WHERE pm.meta_key = '_manual_file_renaming' AND pm.meta_value = 1 AND p.ID = pm.post_id
|
145 |
-
AND p.post_status = 'inherit' AND p.post_type = 'attachment'" );
|
146 |
-
|
147 |
-
// error_log( 'ALL: ' . $all_media );
|
148 |
-
// error_log( 'RENAMED MANUALLY: ' . $manual_media );
|
149 |
-
|
150 |
-
echo $this->render_view( 'menu-screen', array(
|
151 |
-
'wpdb' => $wpdb,
|
152 |
-
'ui' => $this,
|
153 |
-
'core' => $this->core,
|
154 |
-
'admin' => $this->admin,
|
155 |
-
'locked' => $locked,
|
156 |
-
'checkFiles' => $checkFiles,
|
157 |
-
'all_media' => $all_media,
|
158 |
-
'manual_media' => $manual_media
|
159 |
-
) );
|
160 |
-
}
|
161 |
-
|
162 |
-
function add_rename_metabox() {
|
163 |
-
add_meta_box( 'mfrh_media', 'Filename', array( $this, 'attachment_fields' ), 'attachment', 'side', 'high' );
|
164 |
-
}
|
165 |
-
|
166 |
-
function attachment_fields( $post ) {
|
167 |
-
$info = mfrh_pathinfo( get_attached_file( $post->ID ) );
|
168 |
-
$basename = $info['basename'];
|
169 |
-
$is_manual = apply_filters( 'mfrh_manual', false );
|
170 |
-
$html = '<input type="text" readonly class="widefat" name="mfrh_new_filename" value="' . $basename. '" />';
|
171 |
-
$html .= __( '<p class="description">This feature is for <a target="_blank" href="https://store.meowapps.com/">Pro users</a> only.</p>', 'media-file-renamer' );
|
172 |
-
echo apply_filters( "mfrh_admin_attachment_fields", $html, $post );
|
173 |
-
return $post;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
*
|
178 |
-
* 'RENAME' LINK IN MEDIA LIBRARY
|
179 |
-
*
|
180 |
-
*/
|
181 |
-
|
182 |
-
function add_media_columns( $columns ) {
|
183 |
-
$columns['mfrh_column'] = __( 'Rename', 'media-file-renamer' );
|
184 |
-
return $columns;
|
185 |
-
}
|
186 |
-
|
187 |
-
function manage_media_custom_column( $column_name, $id ) {
|
188 |
-
if ( $column_name !== 'mfrh_column' ) return;
|
189 |
-
echo $this->render_column( $id );
|
190 |
-
}
|
191 |
-
|
192 |
-
/**
|
193 |
-
* Renders a custom column content for a specific post
|
194 |
-
* @param int $id The post id to render
|
195 |
-
* @return string Rendered content
|
196 |
-
*/
|
197 |
-
function render_column( $id ) {
|
198 |
-
$r = $this->render_view( 'column', array(
|
199 |
-
'ui' => $this,
|
200 |
-
'core' => $this->core,
|
201 |
-
'admin' => $this->admin,
|
202 |
-
'id' => $id
|
203 |
-
) );
|
204 |
-
return $r;
|
205 |
-
}
|
206 |
-
|
207 |
-
function generate_explanation( $file ) {
|
208 |
-
|
209 |
-
static $previous = array();
|
210 |
-
|
211 |
-
$smallDiv = '<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">';
|
212 |
-
|
213 |
-
if ( $file['post_title'] == "" ) {
|
214 |
-
echo " <a class='button-primary' href='post.php?post=" . $file['post_id'] . "&action=edit'>" . __( 'Edit Media', 'media-file-renamer' ) . "</a><br /><small>" . __( 'This title cannot be used for a filename.', 'media-file-renamer' ) . "</small>";
|
215 |
-
}
|
216 |
-
else if ( $file['desired_filename_exists'] ) {
|
217 |
-
echo "<a class='button-primary' href='post.php?post=" . $file['post_id'] . "&action=edit'>" . __( 'Edit Media', 'media-file-renamer' ) . "</a><br />$smallDiv" . __( 'The ideal filename already exists. If you would like to use a count and rename it, enable the <b>Numbered Files</b> option in the plugin settings.', 'media-file-renamer' ) . "</div>";
|
218 |
-
}
|
219 |
-
else {
|
220 |
-
$page = isset( $_GET['page'] ) ? ( '&page=' . $_GET['page'] ) : "";
|
221 |
-
$mfrh_scancheck = ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) ) ? '&mfrh_scancheck' : '';
|
222 |
-
$mfrh_to_rename = ( !empty( $_GET['to_rename'] ) && $_GET['to_rename'] == 1 ) ? '&to_rename=1' : '';
|
223 |
-
$modify_url = "post.php?post=" . $file['post_id'] . "&action=edit";
|
224 |
-
$page = isset( $_GET['page'] ) ? ( '&page=' . $_GET['page'] ) : "";
|
225 |
-
|
226 |
-
$isNew = true;
|
227 |
-
if ( in_array( $file['desired_filename'], $previous ) )
|
228 |
-
$isNew = false;
|
229 |
-
else
|
230 |
-
array_push( $previous, $file['desired_filename'] );
|
231 |
-
|
232 |
-
echo "<a class='button button-primary auto-rename' href='?" . $page . $mfrh_scancheck . $mfrh_to_rename . "&mfrh_rename=" . $file['post_id'] . "'>" . __( 'Auto-Rename', 'media-file-renamer' ) . "</a>";
|
233 |
-
echo "<a title='" . __( 'Click to lock it to manual only.', 'media-file-renamer' ) . "' href='?" . $page . "&mfrh_lock=" . $file['post_id'] . "' class='lock'><span style='font-size: 16px; margin-top: 5px;' class='dashicons dashicons-unlock'></span></a>";
|
234 |
-
|
235 |
-
if ( $file['case_issue'] ) {
|
236 |
-
echo '<br />' . $smallDiv .
|
237 |
-
sprintf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ),
|
238 |
-
$file['desired_filename'], $modify_url ) . "</div>";
|
239 |
-
}
|
240 |
-
else if ( $file['original_image'] ) {
|
241 |
-
echo '<br />' . $smallDiv .
|
242 |
-
sprintf( __( 'Rename to %s. The original image will be also be renamed. You can also <a href="%s">EDIT THIS MEDIA</a>.', 'media-file-renamer' ),
|
243 |
-
$file['desired_filename'], $modify_url ) . "</div>";
|
244 |
-
}
|
245 |
-
else {
|
246 |
-
echo '<br />' . $smallDiv .
|
247 |
-
sprintf( __( 'Rename to %s. You can also <a href="%s">EDIT THIS MEDIA</a>.', 'media-file-renamer' ),
|
248 |
-
$file['desired_filename'], $modify_url ) . "</div>";
|
249 |
-
}
|
250 |
-
|
251 |
-
if ( !$isNew ) {
|
252 |
-
echo $smallDiv . "<i>";
|
253 |
-
echo __( 'The first media you rename will actually get this filename; the next will be either not renamed or will have a counter appended to it.', 'media-file-renamer' );
|
254 |
-
echo '</i></div>';
|
255 |
-
}
|
256 |
-
}
|
257 |
-
}
|
258 |
-
|
259 |
-
/**
|
260 |
-
*
|
261 |
-
* BULK ACTIONS IN MEDIA LIBRARY
|
262 |
-
*
|
263 |
-
*/
|
264 |
-
|
265 |
-
function library_bulk_actions( $bulk_actions ) {
|
266 |
-
$bulk_actions['mfrh_lock_all'] = __( 'Lock (Renamer)', 'media-file-renamer');
|
267 |
-
$bulk_actions['mfrh_unlock_all'] = __( 'Unlock (Renamer)', 'media-file-renamer');
|
268 |
-
$bulk_actions['mfrh_rename_all'] = __( 'Rename (Renamer)', 'media-file-renamer');
|
269 |
-
return $bulk_actions;
|
270 |
-
}
|
271 |
-
|
272 |
-
function library_bulk_actions_handler( $redirect_to, $doaction, $ids ) {
|
273 |
-
if ( $doaction == 'mfrh_lock_all' ) {
|
274 |
-
foreach ( $ids as $post_id ) {
|
275 |
-
add_post_meta( $post_id, '_manual_file_renaming', true, true );
|
276 |
-
}
|
277 |
-
}
|
278 |
-
if ( $doaction == 'mfrh_unlock_all' ) {
|
279 |
-
foreach ( $ids as $post_id ) {
|
280 |
-
delete_post_meta( $post_id, '_manual_file_renaming' );
|
281 |
-
}
|
282 |
-
}
|
283 |
-
if ( $doaction == 'mfrh_rename_all' ) {
|
284 |
-
foreach ( $ids as $post_id ) {
|
285 |
-
$this->core->rename( $post_id );
|
286 |
-
}
|
287 |
-
}
|
288 |
-
return $redirect_to;
|
289 |
-
}
|
290 |
-
|
291 |
-
/**
|
292 |
-
*
|
293 |
-
* BULK MEDIA RENAME PAGE
|
294 |
-
*
|
295 |
-
*/
|
296 |
-
|
297 |
-
function wp_ajax_mfrh_rename_media() {
|
298 |
-
$subaction = $_POST['subaction'];
|
299 |
-
if ( $subaction == 'getMediaIds' ) {
|
300 |
-
$all = intval( $_POST['all'] );
|
301 |
-
global $wpdb;
|
302 |
-
$ids = $wpdb->get_col( "SELECT p.ID FROM $wpdb->posts p WHERE post_status = 'inherit' AND post_type = 'attachment'" );
|
303 |
-
if ( !$all ) {
|
304 |
-
$idsToRemove = $wpdb->get_col( "SELECT m.post_id FROM $wpdb->postmeta m
|
305 |
-
WHERE m.meta_key = '_manual_file_renaming' and m.meta_value = 1" );
|
306 |
-
$ids = array_values( array_diff( $ids, $idsToRemove ) );
|
307 |
-
}
|
308 |
-
else {
|
309 |
-
// We rename all, so we should unlock everything.
|
310 |
-
$wpdb->query( "DELETE FROM $wpdb->postmeta WHERE meta_key = '_manual_file_renaming'" );
|
311 |
-
}
|
312 |
-
$reply = array();
|
313 |
-
$reply['ids'] = $ids;
|
314 |
-
$reply['total'] = count( $ids );
|
315 |
-
echo json_encode( $reply );
|
316 |
-
die;
|
317 |
-
}
|
318 |
-
else if ( $subaction == 'renameMediaId' ) {
|
319 |
-
$id = intval( $_POST['id'] );
|
320 |
-
$newName = array_key_exists( 'newName', $_POST ) ? $_POST['newName'] : null;
|
321 |
-
if ( isset( $newName ) ) { // Manual Rename
|
322 |
-
if ( !$this->admin->is_registered() ) {
|
323 |
-
wp_send_json_error( __( 'This feature is for Pro users only', 'media-file-renamer' ) );
|
324 |
-
} else if ( !get_option( 'mfrh_manual_rename' ) ) {
|
325 |
-
wp_send_json_error( __( 'You need to enable Manual Rename in the plugin settings', 'media-file-renamer' ) );
|
326 |
-
}
|
327 |
-
}
|
328 |
-
$this->core->rename( $id, $newName );
|
329 |
-
$file = get_attached_file( $id );
|
330 |
-
wp_send_json_success( array (
|
331 |
-
'filename' => mfrh_basename( $file ),
|
332 |
-
'ids' => $this->core->get_posts_by_attached_file( $file )
|
333 |
-
) );
|
334 |
-
}
|
335 |
-
echo 0;
|
336 |
-
die();
|
337 |
-
}
|
338 |
-
|
339 |
-
function wp_ajax_mfrh_undo_media() {
|
340 |
-
$subaction = $_POST['subaction'];
|
341 |
-
if ( $subaction == 'getMediaIds' ) {
|
342 |
-
global $wpdb;
|
343 |
-
$ids = $wpdb->get_col( "
|
344 |
-
SELECT p.ID FROM $wpdb->posts p
|
345 |
-
WHERE post_status = 'inherit' AND post_type = 'attachment'" );
|
346 |
-
$reply = array();
|
347 |
-
$reply['ids'] = $ids;
|
348 |
-
$reply['total'] = count( $ids );
|
349 |
-
echo json_encode( $reply );
|
350 |
-
die;
|
351 |
-
}
|
352 |
-
else if ( $subaction == 'undoMediaId' ) {
|
353 |
-
$id = intval( $_POST['id'] );
|
354 |
-
$original_filename = get_post_meta( $id, '_original_filename', true );
|
355 |
-
$this->core->rename( $id, $original_filename );
|
356 |
-
delete_post_meta( $id, '_original_filename' );
|
357 |
-
$file = get_attached_file( $id );
|
358 |
-
wp_send_json_success( array (
|
359 |
-
'filename' => mfrh_basename( $file ),
|
360 |
-
'ids' => $this->core->get_posts_by_attached_file( $file )
|
361 |
-
) );
|
362 |
-
}
|
363 |
-
echo 0;
|
364 |
-
die();
|
365 |
-
}
|
366 |
-
|
367 |
-
/**
|
368 |
-
* An ajax action to lock a media.
|
369 |
-
*
|
370 |
-
* Ajax parameters:
|
371 |
-
* - id : The post id to lock
|
372 |
-
* - subaction : (optional)
|
373 |
-
* + 'unlock' : Unlocks the post
|
374 |
-
*/
|
375 |
-
function wp_ajax_mfrh_lock_media() {
|
376 |
-
if ( !isset( $_POST['id'] ) )
|
377 |
-
wp_send_json_error( __( 'Invalid request', 'media-file-renamer' ) );
|
378 |
-
|
379 |
-
// Default operation
|
380 |
-
if ( !isset( $_POST['subaction'] ) ) {
|
381 |
-
if ( !$this->core->lock( (int) $_POST['id'] ) )
|
382 |
-
wp_send_json_error( __( 'Failed to lock', 'media-file-renamer' ) );
|
383 |
-
wp_send_json_success();
|
384 |
-
}
|
385 |
-
|
386 |
-
// Optional operations
|
387 |
-
switch ( $_POST['subaction'] ) {
|
388 |
-
case 'unlock':
|
389 |
-
if ( !$this->core->unlock( (int) $_POST['id'] ) )
|
390 |
-
wp_send_json_error( __( 'Failed to unlock', 'media-file-renamer' ) );
|
391 |
-
wp_send_json_success();
|
392 |
-
break;
|
393 |
-
}
|
394 |
-
|
395 |
-
wp_send_json_error( __( 'Invalid request', 'media-file-renamer' ) );
|
396 |
-
}
|
397 |
-
|
398 |
-
/**
|
399 |
-
* An ajax action that analyzes a media
|
400 |
-
*
|
401 |
-
* Ajax parameters:
|
402 |
-
* - id : The post id to analyze
|
403 |
-
*/
|
404 |
-
function wp_ajax_mfrh_analyze_media() {
|
405 |
-
if ( !isset( $_POST['id'] ) )
|
406 |
-
wp_send_json_error( __( 'Invalid request', 'media-file-renamer' ) );
|
407 |
-
|
408 |
-
if ( !$post = get_post( (int) $_POST['id'], ARRAY_A ) )
|
409 |
-
wp_send_json_error( __( 'No such post', 'media-file-renamer' ) );
|
410 |
-
|
411 |
-
$result = array ();
|
412 |
-
$this->core->check_attachment( $post, $result );
|
413 |
-
wp_send_json_success( $result );
|
414 |
-
}
|
415 |
-
|
416 |
-
/**
|
417 |
-
* An ajax action that simply calls render_column() and returns the result.
|
418 |
-
*
|
419 |
-
* Ajax parameters:
|
420 |
-
* - id : The post id to render
|
421 |
-
*/
|
422 |
-
function wp_ajax_mfrh_render_column() {
|
423 |
-
if ( !isset( $_POST['id'] ) ) wp_send_json_error();
|
424 |
-
wp_send_json_success( $this->render_column( (int) $_POST['id'] ) );
|
425 |
-
}
|
426 |
-
|
427 |
-
/**
|
428 |
-
*
|
429 |
-
* ERROR/INFO MESSAGE HANDLING
|
430 |
-
*
|
431 |
-
*/
|
432 |
-
|
433 |
-
function admin_notices() {
|
434 |
-
$screen = get_current_screen();
|
435 |
-
$output = array();
|
436 |
-
if ( ( $screen->base == 'post' && $screen->post_type == 'attachment' ) ||
|
437 |
-
( $screen->base == 'media' && isset( $_GET['attachment_id'] ) ) ) {
|
438 |
-
$id = isset( $_GET['post'] ) ? $_GET['post'] : $_GET['attachment_id'];
|
439 |
-
if ( $this->core->check_attachment( get_post( $id, ARRAY_A ), $output ) ) {
|
440 |
-
if ( $output['desired_filename_exists'] ) {
|
441 |
-
echo '<div class="error"><p>
|
442 |
-
The file ' . $output['desired_filename'] . ' already exists. Please give a new title for this media.
|
443 |
-
</p></div>';
|
444 |
-
}
|
445 |
-
}
|
446 |
-
if ( $this->core->wpml_media_is_installed() && !$this->core->is_real_media( $id ) ) {
|
447 |
-
echo '<div class="error"><p>
|
448 |
-
This attachment seems to be a virtual copy (or translation). Media File Renamer will not make any modification from here.
|
449 |
-
</p></div>';
|
450 |
-
}
|
451 |
-
}
|
452 |
-
}
|
453 |
-
|
454 |
-
function media_send_to_editor( $html, $id, $attachment ) {
|
455 |
-
$output = array();
|
456 |
-
$this->core->check_attachment( get_post( $id, ARRAY_A ), $output );
|
457 |
-
return $html;
|
458 |
-
}
|
459 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/admin-head.php
DELETED
@@ -1,92 +0,0 @@
|
|
1 |
-
<script type="text/javascript" >
|
2 |
-
|
3 |
-
var current;
|
4 |
-
var ids = [];
|
5 |
-
|
6 |
-
function mfrh_process_next() {
|
7 |
-
var data = { action: 'mfrh_rename_media', subaction: 'renameMediaId', id: ids[current - 1] };
|
8 |
-
jQuery('#mfrh_progression').text(current + "/" + ids.length);
|
9 |
-
jQuery.post(ajaxurl, data, function (response) {
|
10 |
-
if (++current <= ids.length) {
|
11 |
-
mfrh_process_next();
|
12 |
-
}
|
13 |
-
else {
|
14 |
-
jQuery('#mfrh_progression').html("<?php echo __( "Done. Please <a href='?page=rename_media_files'>refresh</a> this page.", 'media-file-renamer' ); ?>");
|
15 |
-
}
|
16 |
-
});
|
17 |
-
}
|
18 |
-
|
19 |
-
function mfrh_rename_media(all) {
|
20 |
-
current = 1;
|
21 |
-
ids = [];
|
22 |
-
var data = { action: 'mfrh_rename_media', subaction: 'getMediaIds', all: all ? '1' : '0' };
|
23 |
-
jQuery('#mfrh_progression').text("<?php echo __( "Please wait...", 'media-file-renamer' ); ?>");
|
24 |
-
jQuery.post(ajaxurl, data, function (response) {
|
25 |
-
reply = jQuery.parseJSON(response);
|
26 |
-
ids = reply.ids;
|
27 |
-
jQuery('#mfrh_progression').html(current + "/" + ids.length);
|
28 |
-
mfrh_process_next();
|
29 |
-
});
|
30 |
-
}
|
31 |
-
|
32 |
-
function mfrh_process_next_undo() {
|
33 |
-
var data = { action: 'mfrh_undo_media', subaction: 'undoMediaId', id: ids[current - 1] };
|
34 |
-
jQuery('#mfrh_progression').text(current + "/" + ids.length);
|
35 |
-
jQuery.post(ajaxurl, data, function (response) {
|
36 |
-
if (++current <= ids.length) {
|
37 |
-
mfrh_process_next_undo();
|
38 |
-
}
|
39 |
-
else {
|
40 |
-
jQuery('#mfrh_progression').html("<?php echo __( "Done. Please <a href='?page=rename_media_files'>refresh</a> this page.", 'media-file-renamer' ); ?>");
|
41 |
-
}
|
42 |
-
});
|
43 |
-
}
|
44 |
-
|
45 |
-
function mfrh_undo_media(all) {
|
46 |
-
current = 1;
|
47 |
-
ids = [];
|
48 |
-
var data = { action: 'mfrh_undo_media', subaction: 'getMediaIds', all: all ? '1' : '0' };
|
49 |
-
jQuery('#mfrh_progression').text("<?php echo __( "Please wait...", 'media-file-renamer' ); ?>");
|
50 |
-
jQuery.post(ajaxurl, data, function (response) {
|
51 |
-
reply = jQuery.parseJSON(response);
|
52 |
-
ids = reply.ids;
|
53 |
-
jQuery('#mfrh_progression').html(current + "/" + ids.length);
|
54 |
-
mfrh_process_next_undo();
|
55 |
-
});
|
56 |
-
}
|
57 |
-
|
58 |
-
function mfrh_export_table(table) {
|
59 |
-
var table = jQuery(table);
|
60 |
-
var data = [];
|
61 |
-
// Header
|
62 |
-
table.find('thead tr').each(function(i, tr) {
|
63 |
-
var row = [];
|
64 |
-
jQuery(tr).find('th').each(function(i, td) {
|
65 |
-
var text = jQuery(td).text();
|
66 |
-
row.push(text);
|
67 |
-
});
|
68 |
-
data.push(row);
|
69 |
-
});
|
70 |
-
// Body
|
71 |
-
table.find('tbody tr').each(function(i, tr) {
|
72 |
-
var row = [];
|
73 |
-
jQuery(tr).find('td').each(function(i, td) {
|
74 |
-
var text = jQuery(td).text();
|
75 |
-
row.push(text);
|
76 |
-
});
|
77 |
-
data.push(row);
|
78 |
-
});
|
79 |
-
var csvContent = "data:text/csv;charset=utf-8,";
|
80 |
-
data.forEach(function(infoArray, index){
|
81 |
-
dataString = infoArray.join(",");
|
82 |
-
csvContent += index < data.length ? dataString+ "\n" : dataString;
|
83 |
-
});
|
84 |
-
var encodedUri = encodeURI(csvContent);
|
85 |
-
var link = document.createElement("a");
|
86 |
-
link.setAttribute("href", encodedUri);
|
87 |
-
link.setAttribute("download", "media-file-renamer.csv");
|
88 |
-
document.body.appendChild(link);
|
89 |
-
link.click();
|
90 |
-
}
|
91 |
-
|
92 |
-
</script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/column.php
DELETED
@@ -1,95 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @param Meow_MFRH_UI $ui
|
4 |
-
* @param Meow_MFRH_Core $core
|
5 |
-
* @param Meow_MFRH_Admin $admin
|
6 |
-
* @param int $id
|
7 |
-
*/
|
8 |
-
|
9 |
-
$page = isset( $_GET['page'] ) ? ( '&page=' . $_GET['page'] ) : ""; // What for?
|
10 |
-
$paged = isset( $_GET['paged'] ) ? ( '&paged=' . $_GET['paged'] ) : "";
|
11 |
-
|
12 |
-
$file = array (); // Various stats of the attachment
|
13 |
-
$needsRename = $core->check_attachment( get_post( $id, ARRAY_A ), $file );
|
14 |
-
?>
|
15 |
-
<input type="hidden" data-name="id" value="<?php echo $id; ?>">
|
16 |
-
|
17 |
-
<?php // Quick Renamer ?>
|
18 |
-
<?php $filename = mfrh_basename( get_attached_file( $id ) ); ?>
|
19 |
-
<?php $disabled = !( $admin->is_registered() && apply_filters( 'mfrh_manual', false ) ); ?>
|
20 |
-
<input type="text" data-name="filename" value="<?php esc_attr_e( $filename ); ?>" autocomplete="off" data-origin="<?php esc_attr_e( $filename ); ?>"<?php if ($disabled) echo ' readonly'; ?>>
|
21 |
-
<?php if ( isset( $file['desired_filename'] ) ): // i ?>
|
22 |
-
<input type="text" data-name="recommended-filename" value="<?php esc_attr_e( $file['desired_filename'] ); ?>" readonly>
|
23 |
-
<?php endif; // i ?>
|
24 |
-
<a href="#" class="button button-primary rename hidden">
|
25 |
-
<span class="label dashicons dashicons-edit"></span>
|
26 |
-
</a>
|
27 |
-
|
28 |
-
<?php // Locked media ?>
|
29 |
-
<?php if ( $locked = get_post_meta( $id, '_manual_file_renaming', true ) ): // i ?>
|
30 |
-
<div class="icons-wrap">
|
31 |
-
<span title="<?php _e( 'Manually renamed.', 'media-file-renamer' ); ?>" class="dashicons dashicons-yes"></span>
|
32 |
-
<a title="<?php _e( 'Locked to manual only. Click to unlock it.', 'media-file-renamer' ); ?>" href="?<?php echo $page . '&mfrh_unlock=' . $id . $paged; ?>" class="unlock dashicons dashicons-lock"></a>
|
33 |
-
</div>
|
34 |
-
|
35 |
-
<?php // Media that needs renaming ?>
|
36 |
-
<?php elseif ( $needsRename ): // i ?>
|
37 |
-
<?php static $previous = array(); // This doesn't work ?>
|
38 |
-
<?php if ( $file['post_title'] == "" ): // ii ?>
|
39 |
-
<a class="button-primary" href="post.php?post=<?php echo $id . '&action=edit'; ?>"><?php _e( 'Edit Media', 'media-file-renamer' ); ?></a><br />
|
40 |
-
<small><?php _e( 'This title cannot be used for a filename.', 'media-file-renamer' ); ?></small>
|
41 |
-
<?php elseif ( $file['desired_filename_exists'] ): // ii ?>
|
42 |
-
<a class="button-primary" href="post.php?post=<?php echo $id . '&action=edit'; ?>"><?php _e( 'Edit Media', 'media-file-renamer' ); ?></a><br />
|
43 |
-
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
44 |
-
<?php _e( 'The ideal filename already exists. If you would like to use a count and rename it, enable the <b>Numbered Files</b> option in the plugin settings.', 'media-file-renamer' ); ?>
|
45 |
-
</div>
|
46 |
-
<?php else: // ii ?>
|
47 |
-
<?php
|
48 |
-
$mfrh_scancheck = ( isset( $_GET ) && isset( $_GET['mfrh_scancheck'] ) ) ? '&mfrh_scancheck' : '';
|
49 |
-
$mfrh_to_rename = ( !empty( $_GET['to_rename'] ) && $_GET['to_rename'] == 1 ) ? '&to_rename=1' : '';
|
50 |
-
$modify_url = "post.php?post=" . $id . "&action=edit";
|
51 |
-
|
52 |
-
// This doesn't work
|
53 |
-
$isNew = true;
|
54 |
-
if ( in_array( $file['desired_filename'], $previous ) )
|
55 |
-
$isNew = false;
|
56 |
-
else
|
57 |
-
array_push( $previous, $file['desired_filename'] );
|
58 |
-
?>
|
59 |
-
<a class="button button-primary auto-rename" href="?<?php echo $page . $mfrh_scancheck . $mfrh_to_rename . '&mfrh_rename=' . $id; ?>">
|
60 |
-
<span class="label"><?php _e( 'Auto', 'media-file-renamer' ); ?></span>
|
61 |
-
</a>
|
62 |
-
<div class="icons-wrap">
|
63 |
-
<a title="<?php _e( 'Click to lock it to manual only.', 'media-file-renamer' ); ?>" href="?<?php echo $page . '&mfrh_lock=' . $id; ?>" class="lock dashicons dashicons-unlock"></a>
|
64 |
-
</div>
|
65 |
-
<?php if ( $file['case_issue'] ): // iii ?>
|
66 |
-
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
67 |
-
<?php printf( __( 'Rename in lowercase, to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
68 |
-
</div>
|
69 |
-
<?php elseif ( $file['original_image'] ): // iii ?>
|
70 |
-
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
71 |
-
<?php printf( __( 'Rename in lowercase, to %s. The original image will be also be renamed. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
72 |
-
</div>
|
73 |
-
<?php else: // iii ?>
|
74 |
-
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
75 |
-
<?php printf( __( 'Rename to %s. You can also <a href="%s">edit this media</a>.', 'media-file-renamer' ), $file['desired_filename'], $modify_url ); ?>
|
76 |
-
</div>
|
77 |
-
<?php endif; // iii ?>
|
78 |
-
<?php if ( !$isNew ): // iii ?>
|
79 |
-
<div style="line-height: 12px; font-size: 10px; margin-top: 5px;">
|
80 |
-
<i><?php _e( 'The first media you rename will actually get this filename; the next will be either not renamed or will have a counter appended to it.', 'media-file-renamer' ); ?></i>
|
81 |
-
</div>
|
82 |
-
<?php endif; // iii ?>
|
83 |
-
<?php endif; // ii ?>
|
84 |
-
|
85 |
-
<?php // Non-locked media ?>
|
86 |
-
<?php else: // i ?>
|
87 |
-
<div class="icons-wrap">
|
88 |
-
<?php $original_filename = get_post_meta( $id, '_original_filename', true ); ?>
|
89 |
-
<span title="<?php _e( 'Automatically renamed.', 'media-file-renamer' ); ?>" class="dashicons dashicons-yes"></span>
|
90 |
-
<?php if ( get_option( 'mfrh_undo', false ) && !empty( $original_filename ) ): // ii ?>
|
91 |
-
<a title="<?php echo __( 'Rename to original filename: ', 'media-file-renamer' ) . $original_filename; ?>" href="?<?php echo $page . "&mfrh_undo=" . $id . $paged; ?>" class="undo dashicons dashicons-undo"></a>
|
92 |
-
<?php endif; // ii ?>
|
93 |
-
<a title="<?php _e( 'Click to lock it to manual only.', 'media-file-renamer' ); ?>" href="?<?php echo $page . "&mfrh_lock=" . $id . $paged; ?>" class="lock dashicons dashicons-unlock"></a>
|
94 |
-
</div>
|
95 |
-
<?php endif; // i ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
views/menu-screen.php
DELETED
@@ -1,145 +0,0 @@
|
|
1 |
-
<div class="wrap">
|
2 |
-
<?php $admin->display_title( "Media File Renamer" ); ?>
|
3 |
-
|
4 |
-
<?php if ( $locked ): ?>
|
5 |
-
<div class="updated">
|
6 |
-
<p><?php _e( 'All the media files are now locked.', 'media-file-renamer' ); ?></p>
|
7 |
-
</div>
|
8 |
-
<?php endif; ?>
|
9 |
-
|
10 |
-
<?php if ( !$admin->is_registered() ): ?>
|
11 |
-
<div class="updated">
|
12 |
-
<p>
|
13 |
-
<?php _e( '<b>The Pro version</b> of the plugin allows you to <b>rename based on the title of the post</b> (product or whatever else) you media is attached to, <b>rename manually</b>, use <b>numbered files</b> (by adding a counter if the filenames are similar), <b>sync the title with your ALT text</b>, a force rename (to repair a broken install), and, more importantly, <b>supports the developer</b> :) Thank you!<br /><br /><a class="button-primary" href="https://store.meowapps.com/" target="_blank">Get the Pro</a>', 'media-file-renamer' ); ?>
|
14 |
-
</p>
|
15 |
-
</div>
|
16 |
-
<?php endif; ?>
|
17 |
-
|
18 |
-
<h2>Rename in Bulk</h2>
|
19 |
-
|
20 |
-
<p>
|
21 |
-
<?php _e( 'You might have noticed that some of your media are locked by the file renamer, others are unlocked. Automatically, the plugin locks the media you renamed manually. By default, they are unlocked. Here, you have the choice of rename all the media in your DB or only the ones which are unlocked (to keep the files you renamed manually). <span style="color: red; font-weight: bold;">Please backup your uploads folder + DB before using this.</span> If you don\'t know how, give a try to this: <a href="https://meow.click/blogvault" target="_blank">BlogVault</a>.', 'media-file-renamer' ); ?>
|
22 |
-
</p>
|
23 |
-
|
24 |
-
<div style='margin-top: 12px; background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
|
25 |
-
|
26 |
-
<a onclick='mfrh_rename_media(false)' id='mfrh_rename_all_images' class='button-primary'
|
27 |
-
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
28 |
-
<?php echo sprintf( __( "Rename ALL [%d]", 'media-file-renamer' ), $all_media - $manual_media ); ?>
|
29 |
-
</a>
|
30 |
-
<a onclick='mfrh_rename_media(true)' id='mfrh_unlock_rename_all_images' class='button-primary'
|
31 |
-
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
32 |
-
<?php echo sprintf( __( "Unlock ALL & Rename [%d]", 'media-file-renamer' ), $all_media ); ?>
|
33 |
-
</a>
|
34 |
-
<span style='margin-right: 5px; margin-left: 5px;'>|</span>
|
35 |
-
<a href="?page=rename_media_files&mfrh_lockall" id='mfrh_lock_all_images' class='button-primary'
|
36 |
-
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
37 |
-
<?php echo sprintf( __( "Lock ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
38 |
-
</a>
|
39 |
-
<a href="?page=rename_media_files&mfrh_unlockall" id='mfrh_unblock_all_images' class='button-primary'
|
40 |
-
style='margin-right: 0px;'><span class="dashicons dashicons-controls-play" style="position: relative; top: 3px; left: -2px;"></span>
|
41 |
-
<?php echo sprintf( __( "Unlock ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
42 |
-
</a>
|
43 |
-
<a onclick='mfrh_undo_media()' id='mfrh_undo_all_images' class='button button-red'
|
44 |
-
style='margin-right: 0px; float: right;'><span class="dashicons dashicons-undo" style="position: relative; top: 3px; left: -2px;"></span>
|
45 |
-
<?php echo sprintf( __( "Undo ALL [%d]", 'media-file-renamer' ), $all_media ); ?>
|
46 |
-
</a>
|
47 |
-
<span id='mfrh_progression'></span>
|
48 |
-
|
49 |
-
<?php if ( get_option( 'mfrh_flagging' ) ): ?>
|
50 |
-
<?php if ($flagged > 0): ?>
|
51 |
-
<a onclick='mfrh_rename_media(false)' id='mfrh_rename_dued_images' class='button-primary'>
|
52 |
-
<?php echo sprintf( __( "Rename <span class='mfrh-flagged'>%d</span> flagged media", 'media-file-renamer' ), $flagged ); ?>
|
53 |
-
</a>
|
54 |
-
<?php else: ?>
|
55 |
-
<a id='mfrh_rename_dued_images' class='button-primary'>
|
56 |
-
<?php echo sprintf( __( "Rename <span class='mfrh-flagged'>%d</span> flagged media", 'media-file-renamer' ), $flagged ); ?>
|
57 |
-
</a>
|
58 |
-
<?php endif; ?>
|
59 |
-
<?php endif; ?>
|
60 |
-
|
61 |
-
</div>
|
62 |
-
|
63 |
-
<h2>Rename 1 by 1</h2>
|
64 |
-
<p><?php _e( 'If you want to rename the media this way, I recommend you to do it from the Media Library directly. If you think this "Scan All" is really handy, please tell me that you are using it on the forums. I am currently planning to remove it and moving the "Rename in Bulk" with the settings of File Renamer (to clean the WordPress UI).', 'media-file-renamer' ); ?></p>
|
65 |
-
<table class='wp-list-table widefat fixed media' style='margin-top: 15px;'>
|
66 |
-
<thead>
|
67 |
-
<tr><th><?php _e( 'Title', 'media-file-renamer' ); ?></th><th><?php _e( 'Current Filename', 'media-file-renamer' ); ?></th><th><?php _e( 'Desired Filename', 'media-file-renamer' ); ?></th><th><?php _e( 'Action', 'media-file-renamer' ); ?></th></tr>
|
68 |
-
</thead>
|
69 |
-
<tfoot>
|
70 |
-
<tr><th><?php _e( 'Title', 'media-file-renamer' ); ?></th><th><?php _e( 'Current Filename', 'media-file-renamer' ); ?></th><th><?php _e( 'Desired Filename', 'media-file-renamer' ); ?></th><th><?php _e( 'Action', 'media-file-renamer' ); ?></th></tr>
|
71 |
-
</tfoot>
|
72 |
-
<tbody>
|
73 |
-
<?php
|
74 |
-
if ( $checkFiles != null ) {
|
75 |
-
foreach ( $checkFiles as $file ) {
|
76 |
-
echo "<tr><td><a href='post.php?post=" . $file['post_id'] . "&action=edit'>" . ( $file['post_title'] == "" ? "(no title)" : $file['post_title'] ) . "</a></td>"
|
77 |
-
. "<td>" . $file['current_filename'] . "</td>"
|
78 |
-
. "<td>" . $file['desired_filename'] . "</td>";
|
79 |
-
echo "<td>";
|
80 |
-
$ui->generate_explanation( $file );
|
81 |
-
echo "</td></tr>";
|
82 |
-
}
|
83 |
-
}
|
84 |
-
else if ( isset( $_GET['mfrh_scancheck'] ) && ( $checkFiles == null || count( $checkFiles ) < 1 ) ) {
|
85 |
-
?><tr><td colspan='4'><div style='width: 100%; margin-top: 15px; margin-bottom: 15px; text-align: center;'>
|
86 |
-
<div style='margin-top: 15px;'><?php _e( 'There are no issues. Cool!<br />Let\'s go visit <a target="_blank" href=\'https://offbeatjapan.org\'>The Offbeat Guide of Japan</a> :)', 'media-file-renamer' ); ?></div>
|
87 |
-
</div></td><?php
|
88 |
-
}
|
89 |
-
else if ( $checkFiles == null ) {
|
90 |
-
?><tr><td colspan='4'><div style='width: 100%; text-align: center;'>
|
91 |
-
<a class='button-primary' href="?page=rename_media_files&mfrh_scancheck" style='margin-top: 15px; margin-bottom: 15px;'><span class="dashicons dashicons-admin-generic" style="position: relative; top: 3px; left: -2px;"></span>
|
92 |
-
<?php _e( "Scan All & Show Issues", 'media-file-renamer' ); ?>
|
93 |
-
</a>
|
94 |
-
</div></td><?php
|
95 |
-
}
|
96 |
-
?>
|
97 |
-
</tbody>
|
98 |
-
</table>
|
99 |
-
|
100 |
-
<h2>Before / After</h2>
|
101 |
-
<p><?php _e( 'This is useful if you wish to create redirections from your old filenames to your new ones. The CSV file generated by Media File Renamer is compatible with the import function of the <a href="https://wordpress.org/plugins/redirection/" target="_blank">Redirection</a> plugin. The redirections with slugs are already automatically and natively handled by WordPress.', 'media-file-renamer' ); ?></p>
|
102 |
-
|
103 |
-
<div style='margin-top: 12px; background: #FFF; padding: 5px; border-radius: 4px; height: 28px; box-shadow: 0px 0px 6px #C2C2C2;'>
|
104 |
-
|
105 |
-
<a href="?page=rename_media_files&mfrh_beforeafter_filenames" class='button-primary' style='margin-right: 0px;'>
|
106 |
-
<span class="dashicons dashicons-media-spreadsheet" style="position: relative; top: 3px; left: -2px;"></span>
|
107 |
-
<?php esc_html_e( "Display Filenames", 'media-file-renamer' ); ?>
|
108 |
-
</a>
|
109 |
-
|
110 |
-
<a onclick="mfrh_export_table('#mfrh-before-after')" class='button-primary' style='margin-right: 0px; float: right;'>
|
111 |
-
<span class="dashicons dashicons-arrow-down-alt" style="position: relative; top: 3px; left: -2px;"></span>
|
112 |
-
<?php esc_html_e( "Export as CSV", 'media-file-renamer' ); ?>
|
113 |
-
</a>
|
114 |
-
|
115 |
-
</div>
|
116 |
-
|
117 |
-
<table id='mfrh-before-after' class='wp-list-table widefat fixed media' style='margin-top: 15px;'>
|
118 |
-
<thead>
|
119 |
-
<tr><th><?php _e( 'Before', 'media-file-renamer' ); ?></th><th><?php _e( 'After', 'media-file-renamer' ); ?></th></tr>
|
120 |
-
</thead>
|
121 |
-
<tfoot>
|
122 |
-
<tr><th><?php _e( 'Before', 'media-file-renamer' ); ?></th><th><?php _e( 'After', 'media-file-renamer' ); ?></th></tr>
|
123 |
-
</tfoot>
|
124 |
-
<tbody>
|
125 |
-
<?php
|
126 |
-
if ( isset( $_GET['mfrh_beforeafter_filenames'] ) || isset( $_GET['mfrh_beforeafter_slugs'] ) ) {
|
127 |
-
$results = $wpdb->get_results( "
|
128 |
-
SELECT m.post_id as ID, m.meta_value as original_filename, m2.meta_value as current_filename
|
129 |
-
FROM {$wpdb->postmeta} m
|
130 |
-
JOIN {$wpdb->postmeta} m2 on m2.post_id = m.post_id AND m2.meta_key = '_wp_attached_file'
|
131 |
-
WHERE m.meta_key = '_original_filename'" );
|
132 |
-
foreach ( $results as $row ) {
|
133 |
-
$fullsize_path = wp_get_attachment_url( $row->ID );
|
134 |
-
$parts = mfrh_pathinfo( $fullsize_path );
|
135 |
-
$shorten_url = trailingslashit( $parts['dirname'] ) . $row->original_filename;
|
136 |
-
if ( isset( $_GET['mfrh_beforeafter_filenames'] ) )
|
137 |
-
echo "<tr><td>{$shorten_url}</td><td>$fullsize_path</td></tr>";
|
138 |
-
else
|
139 |
-
echo "<tr><td>{$row->original_slug}</td><td>{$row->current_slug}</td></tr>";
|
140 |
-
}
|
141 |
-
}
|
142 |
-
?>
|
143 |
-
</tbody>
|
144 |
-
</table>
|
145 |
-
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|