diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml index fa9ea7c..8ccd9bd 100644 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -20,7 +20,7 @@ body: attributes: label: Plugin version description: | - e.g `1.1.5` + e.g `1.1.6` validations: required: true diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 481f0ca..fed7ac6 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,7 +1,7 @@ blank_issues_enabled: false contact_links: - name: Help & support - FAQ - url: https://github.com/ajrsoftware/WPClothes2Order/discussions/new?category=q-a&body=%23%23%23%20Your%20question%20here%0A%0A-%20What%20version%20of%20the%20plugin%20are%20you%20using%3F%20e.g%20%601.1.5%60%0A-%20What%20PHP%20version%20are%20you%20using%3F%20e.g%20%607.4%60%0A-%20Where%20did%20you%20install%20the%20plugin%20from%3F%20e.g%20%60WordPress%20org%60%0A%0A--- + url: https://github.com/ajrsoftware/WPClothes2Order/discussions/new?category=q-a&body=%23%23%23%20Your%20question%20here%0A%0A-%20What%20version%20of%20the%20plugin%20are%20you%20using%3F%20e.g%20%601.1.6%60%0A-%20What%20PHP%20version%20are%20you%20using%3F%20e.g%20%607.4%60%0A-%20Where%20did%20you%20install%20the%20plugin%20from%3F%20e.g%20%60WordPress%20org%60%0A%0A--- about: "If you can't get something to work the way you expect, check out our FAQ's." - name: Feature Request url: https://github.com/ajrsoftware/WPClothes2Order/discussions/new?category=ideas diff --git a/SECURITY.md b/SECURITY.md index 758bd32..9e615d2 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -4,8 +4,8 @@ | Version | Supported | | ------- | ------------------ | -| 1.1.5 | :white_check_mark: | -| > 1.1.5 | :x: | +| 1.1.6 | :white_check_mark: | +| > 1.1.6 | :x: | ## Reporting a Vulnerability diff --git a/bun.lockb b/bun.lockb index a2cc5e3..32252ab 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/composer.lock b/composer.lock index aeff9a2..bb56fbb 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "htmlburger/carbon-fields", - "version": "v3.6.3", + "version": "v3.6.5", "source": { "type": "git", "url": "https://github.com/htmlburger/carbon-fields.git", - "reference": "d913a5148cb9dc61ed239719c747f4ebb513003f" + "reference": "b18f8e2a2cc4cc976306eb867ad1d740a8e7c1d9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/htmlburger/carbon-fields/zipball/d913a5148cb9dc61ed239719c747f4ebb513003f", - "reference": "d913a5148cb9dc61ed239719c747f4ebb513003f", + "url": "https://api.github.com/repos/htmlburger/carbon-fields/zipball/b18f8e2a2cc4cc976306eb867ad1d740a8e7c1d9", + "reference": "b18f8e2a2cc4cc976306eb867ad1d740a8e7c1d9", "shasum": "" }, "require": { @@ -144,7 +144,7 @@ "issues": "https://github.com/htmlburger/carbon-fields/issues", "source": "https://github.com/htmlburger/carbon-fields" }, - "time": "2023-11-28T15:52:46+00:00" + "time": "2024-07-31T08:17:38+00:00" } ], "packages-dev": [ @@ -354,16 +354,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "3.9.2", + "version": "3.10.3", "source": { "type": "git", "url": "https://github.com/PHPCSStandards/PHP_CodeSniffer.git", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480" + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/aac1f6f347a5c5ac6bc98ad395007df00990f480", - "reference": "aac1f6f347a5c5ac6bc98ad395007df00990f480", + "url": "https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/62d32998e820bddc40f99f8251958aed187a5c9c", + "reference": "62d32998e820bddc40f99f8251958aed187a5c9c", "shasum": "" }, "require": { @@ -430,7 +430,7 @@ "type": "open_collective" } ], - "time": "2024-04-23T20:25:34+00:00" + "time": "2024-09-18T10:38:58+00:00" }, { "name": "wp-coding-standards/wpcs", diff --git a/dist/app.js b/dist/app.js index 0b745ae..7d4cb56 100644 --- a/dist/app.js +++ b/dist/app.js @@ -1,4 +1,4 @@ -var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S}=Object;var T=Object.prototype.hasOwnProperty;var A=(o,r,s)=>{s=o!=null?P(x(o)):{};const l=r||!o||!o.__esModule?v(s,"default",{value:o,enumerable:!0}):s;for(let m of S(o))if(!T.call(l,m))v(l,m,{get:()=>o[m],enumerable:!0});return l};var N=(o,r)=>()=>(r||o((r={exports:{}}).exports,r),r.exports);var b=N((g,w)=>{(function(o,r){typeof g=="object"&&typeof w!="undefined"?w.exports=r():typeof define=="function"&&define.amd?define(r):(o=o||self).JSONFormatter=r()})(g,function(){function o(e){return e===null?"null":typeof e}function r(e){return!!e&&typeof e=="object"}function s(e){if(e===void 0)return"";if(e===null)return"Object";if(typeof e=="object"&&!e.constructor)return"Object";var t=/function ([^(]*)/.exec(e.constructor.toString());return t&&t.length>1?t[1]:""}function l(e,t,n){return e==="null"||e==="undefined"?e:(e!=="string"&&e!=="stringifiable"||(n='"'+n.replace(/"/g,'\\"')+'"'),e==="function"?t.toString().replace(/[\r\n]/g,"").replace(/\{.*\}/,"")+"{\u2026}":n)}function m(e){var t="";return r(e)?(t=s(e),Array.isArray(e)&&(t+="["+e.length+"]")):t=l(o(e),e,e),t}function a(e){return"json-formatter-"+e}function c(e,t,n){var i=document.createElement(e);return t&&i.classList.add(a(t)),n!==void 0&&(n instanceof Node?i.appendChild(n):i.appendChild(document.createTextNode(String(n)))),i}(function(e){if(e&&typeof window!="undefined"){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}})(`.json-formatter-row { +function u(e){return e===null?"null":typeof e}function y(e){return!!e&&typeof e=="object"}function g(e){if(e===void 0)return"";if(e===null)return"Object";if(typeof e=="object"&&!e.constructor)return"Object";var t=/function ([^(]*)/.exec(e.constructor.toString());return t&&t.length>1?t[1]:""}function w(e,t,n){return e==="null"||e==="undefined"?e:(e!=="string"&&e!=="stringifiable"||(n='"'+(n.replace(/"/g,'\\"')+'"')),e==="function"?t.toString().replace(/[\r\n]/g,"").replace(/\{.*\}/,"")+"{\u2026}":n)}function j(e){var t="";return y(e)?(t=g(e),Array.isArray(e)&&(t+="["+e.length+"]")):t=w(u(e),e,e),t}function i(e){return"json-formatter-".concat(e)}function a(e,t,n){var r=document.createElement(e);return t&&r.classList.add(i(t)),n!==void 0&&(n instanceof Node?r.appendChild(n):r.appendChild(document.createTextNode(String(n)))),r}(function(e){if(e&&typeof window!="undefined"){var t=document.createElement("style");t.setAttribute("media","screen"),t.innerHTML=e,document.head.appendChild(t)}})(`.json-formatter-row { font-family: monospace; } .json-formatter-row, @@ -36,7 +36,7 @@ var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S} color: red; } .json-formatter-row .json-formatter-null { - color: #855A00; + color: #855a00; } .json-formatter-row .json-formatter-undefined { color: #ca0b69; @@ -56,7 +56,7 @@ var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S} color: blue; } .json-formatter-row .json-formatter-key { - color: #00008B; + color: #00008b; padding-right: 0.2rem; } .json-formatter-row .json-formatter-toggler-link { @@ -122,12 +122,12 @@ var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S} } .json-formatter-dark.json-formatter-row .json-formatter-string, .json-formatter-dark.json-formatter-row .json-formatter-stringifiable { - color: #31F031; + color: #31f031; white-space: pre; word-wrap: break-word; } .json-formatter-dark.json-formatter-row .json-formatter-number { - color: #66C2FF; + color: #66c2ff; } .json-formatter-dark.json-formatter-row .json-formatter-boolean { color: #EC4242; @@ -146,14 +146,14 @@ var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S} } .json-formatter-dark.json-formatter-row .json-formatter-url { text-decoration: underline; - color: #027BFF; + color: #027bff; cursor: pointer; } .json-formatter-dark.json-formatter-row .json-formatter-bracket { - color: #9494FF; + color: #9494ff; } .json-formatter-dark.json-formatter-row .json-formatter-key { - color: #23A0DB; + color: #23a0db; padding-right: 0.2rem; } .json-formatter-dark.json-formatter-row .json-formatter-toggler-link { @@ -192,4 +192,4 @@ var P=Object.create;var{defineProperty:v,getPrototypeOf:x,getOwnPropertyNames:S} .json-formatter-dark.json-formatter-row.json-formatter-open.json-formatter-empty:after { display: block; } -`);var C=/(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/,E=/\d{2}:\d{2}:\d{2} GMT-\d{4}/,L=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,u=window.requestAnimationFrame||function(e){return e(),0},j={hoverPreviewEnabled:!1,hoverPreviewArrayCount:100,hoverPreviewFieldCount:5,animateOpen:!0,animateClose:!0,theme:null,useToJSON:!0,sortPropertiesBy:null};return function(){function e(t,n,i,f){n===void 0&&(n=1),i===void 0&&(i=j),this.json=t,this.open=n,this.config=i,this.key=f,this._isOpen=null,this.config.hoverPreviewEnabled===void 0&&(this.config.hoverPreviewEnabled=j.hoverPreviewEnabled),this.config.hoverPreviewArrayCount===void 0&&(this.config.hoverPreviewArrayCount=j.hoverPreviewArrayCount),this.config.hoverPreviewFieldCount===void 0&&(this.config.hoverPreviewFieldCount=j.hoverPreviewFieldCount),this.config.useToJSON===void 0&&(this.config.useToJSON=j.useToJSON),this.key===""&&(this.key='""')}return Object.defineProperty(e.prototype,"isOpen",{get:function(){return this._isOpen!==null?this._isOpen:this.open>0},set:function(t){this._isOpen=t},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isDate",{get:function(){return this.json instanceof Date||this.type==="string"&&(C.test(this.json)||L.test(this.json)||E.test(this.json))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUrl",{get:function(){return this.type==="string"&&this.json.indexOf("http")===0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isArray",{get:function(){return Array.isArray(this.json)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isObject",{get:function(){return r(this.json)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isEmptyObject",{get:function(){return!this.keys.length&&!this.isArray},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.isEmptyObject||this.keys&&!this.keys.length&&this.isArray},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useToJSON",{get:function(){return this.config.useToJSON&&this.type==="stringifiable"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasKey",{get:function(){return this.key!==void 0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"constructorName",{get:function(){return s(this.json)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.config.useToJSON&&this.json&&this.json.toJSON?"stringifiable":o(this.json)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"keys",{get:function(){if(this.isObject){var t=Object.keys(this.json);return!this.isArray&&this.config.sortPropertiesBy?t.sort(this.config.sortPropertiesBy):t}return[]},enumerable:!0,configurable:!0}),e.prototype.toggleOpen=function(){this.isOpen=!this.isOpen,this.element&&(this.isOpen?this.appendChildren(this.config.animateOpen):this.removeChildren(this.config.animateClose),this.element.classList.toggle(a("open")))},e.prototype.openAtDepth=function(t){t===void 0&&(t=1),t<0||(this.open=t,this.isOpen=t!==0,this.element&&(this.removeChildren(!1),t===0?this.element.classList.remove(a("open")):(this.appendChildren(this.config.animateOpen),this.element.classList.add(a("open")))))},e.prototype.getInlinepreview=function(){var t=this;if(this.isArray)return this.json.length>this.config.hoverPreviewArrayCount?"Array["+this.json.length+"]":"["+this.json.map(m).join(", ")+"]";var n=this.keys,i=n.slice(0,this.config.hoverPreviewFieldCount).map(function(d){return d+":"+m(t.json[d])}),f=n.length>=this.config.hoverPreviewFieldCount?"\u2026":"";return"{"+i.join(", ")+f+"}"},e.prototype.render=function(){this.element=c("div","row");var t=this.isObject?c("a","toggler-link"):c("span");if(this.isObject&&!this.useToJSON&&t.appendChild(c("span","toggler")),this.hasKey&&t.appendChild(c("span","key",this.key+":")),this.isObject&&!this.useToJSON){var n=c("span","value"),i=c("span"),f=c("span","constructor-name",this.constructorName);if(i.appendChild(f),this.isArray){var d=c("span");d.appendChild(c("span","bracket","[")),d.appendChild(c("span","number",this.json.length)),d.appendChild(c("span","bracket","]")),i.appendChild(d)}n.appendChild(i),t.appendChild(n)}else{(n=this.isUrl?c("a"):c("span")).classList.add(a(this.type)),this.isDate&&n.classList.add(a("date")),this.isUrl&&(n.classList.add(a("url")),n.setAttribute("href",this.json));var p=l(this.type,this.json,this.useToJSON?this.json.toJSON():this.json);n.appendChild(document.createTextNode(p)),t.appendChild(n)}if(this.isObject&&this.config.hoverPreviewEnabled){var h=c("span","preview-text");h.appendChild(document.createTextNode(this.getInlinepreview())),t.appendChild(h)}var y=c("div","children");return this.isObject&&y.classList.add(a("object")),this.isArray&&y.classList.add(a("array")),this.isEmpty&&y.classList.add(a("empty")),this.config&&this.config.theme&&this.element.classList.add(a(this.config.theme)),this.isOpen&&this.element.classList.add(a("open")),this.element.appendChild(t),this.element.appendChild(y),this.isObject&&this.isOpen&&this.appendChildren(),this.isObject&&!this.useToJSON&&t.addEventListener("click",this.toggleOpen.bind(this)),this.element},e.prototype.appendChildren=function(t){var n=this;t===void 0&&(t=!1);var i=this.element.querySelector("div."+a("children"));if(i&&!this.isEmpty)if(t){var f=0,d=function(){var p=n.keys[f],h=new e(n.json[p],n.open-1,n.config,p);i.appendChild(h.render()),(f+=1)10?d():u(d))};u(d)}else this.keys.forEach(function(p){var h=new e(n.json[p],n.open-1,n.config,p);i.appendChild(h.render())})},e.prototype.removeChildren=function(t){t===void 0&&(t=!1);var n=this.element.querySelector("div."+a("children"));if(t){var i=0,f=function(){n&&n.children.length&&(n.removeChild(n.children[0]),(i+=1)>10?f():u(f))};u(f)}else n&&(n.innerHTML="")},e}()})});var O=A(b(),1);var k=async()=>{let o=null;try{const r=await fetch("/wp-json/wpc2o/v1/stock-sync",{method:"get",headers:{"Content-Type":"application/json"}});if(r.ok)o=await r.json()}catch(r){o={status:!1,message:"There was a problem requesting a stock sync."}}return o};document.querySelectorAll(".wpc2o-expand-details").forEach((o)=>{o?.addEventListener("click",(r)=>{r.preventDefault(),o?.nextElementSibling?.classList.toggle("show")})});document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".wpc2o-code-block").forEach((r)=>{const s=r.getElementsByTagName("code")[0],l=new O.default(JSON.parse(s.innerText),Infinity);r.removeChild(s),r.appendChild(l.render())})});document.addEventListener("DOMContentLoaded",()=>{const o=document.getElementById("wpc2o-example-json");if(o)document.getElementById("wpc2o-expand-api-request")?.addEventListener("click",(r)=>{r.preventDefault(),o.classList.toggle("wpc2o-example-show")}),document.getElementById("wpc2o-copy-api-request")?.addEventListener("click",(r)=>{r.preventDefault(),navigator.clipboard.writeText(o.innerText)}),document.getElementById("wpc2o-manual-stock-sync-trigger")?.addEventListener("submit",async(r)=>{r.preventDefault();const s=document.getElementById("wpc2o-manual-stock-sync-trigger-button");if(s)s.disabled=!0;const l=document.createElement("span");l.id="wpc2o-manual-stock-sync-message",l.style.display="block",l.style.marginBottom="16px",l.innerText="Sync in progress... please do NOT close this page.",l.style.color="#3858e9",l.style.fontWeight="500",s?.after(l);const m=document.getElementById("wpc2o-manual-stock-sync-message"),a=await k();if(m&&a){const c=a.status?"green":"red";l.style.color=c,m.innerText=a.message}if(s)s.disabled=!1})});document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".wpc2o-view-order-payload").forEach((o)=>{o?.addEventListener("click",(r)=>{r.preventDefault();const s=o.nextElementSibling;if(s)s.classList.toggle("open")})}),document.querySelectorAll(".wpc2o-view-payload-modal-close").forEach((o)=>{o.addEventListener("click",(r)=>{r.preventDefault(),document.querySelectorAll(".wpc2o-view-payload-modal.open").forEach((s)=>s.classList.toggle("open"))})}),document.querySelectorAll(".wpc2o-view-payload-modal-copy").forEach((o)=>{o.addEventListener("click",(r)=>{r.preventDefault();const s=document.querySelector(".wpc2o-view-payload-modal.open .wpc2o-view-payload-modal-content");if(s)navigator.clipboard.writeText(s.innerText)})})}); +`);var O=/(^\d{1,4}[\.|\\/|-]\d{1,2}[\.|\\/|-]\d{1,4})(\s*(?:0?[1-9]:[0-5]|1(?=[012])\d:[0-5])\d\s*[ap]m)?$/,C=/\d{2}:\d{2}:\d{2} GMT-\d{4}/,A=/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{3}Z/,E=/^https?:\/\//,p=window.requestAnimationFrame||function(e){return e(),0},m={hoverPreviewEnabled:!1,hoverPreviewArrayCount:100,hoverPreviewFieldCount:5,animateOpen:!0,animateClose:!0,theme:null,useToJSON:!0,sortPropertiesBy:null,maxArrayItems:100,exposePath:!1},x=function(){function e(t,n,r,s,o,l,c){n===void 0&&(n=1),r===void 0&&(r=m),l===void 0&&(l=[]),this.json=t,this.open=n,this.config=r,this.key=s,this.displayKey=o,this.path=l,this.arrayRange=c,this._isOpen=null,this.config.hoverPreviewEnabled===void 0&&(this.config.hoverPreviewEnabled=m.hoverPreviewEnabled),this.config.hoverPreviewArrayCount===void 0&&(this.config.hoverPreviewArrayCount=m.hoverPreviewArrayCount),this.config.hoverPreviewFieldCount===void 0&&(this.config.hoverPreviewFieldCount=m.hoverPreviewFieldCount),this.config.useToJSON===void 0&&(this.config.useToJSON=m.useToJSON),this.config.maxArrayItems===void 0&&(this.config.maxArrayItems=m.maxArrayItems),this.key===""&&(this.key='""'),this.displayKey===void 0&&(this.displayKey=this.key)}return Object.defineProperty(e.prototype,"isOpen",{get:function(){return this._isOpen!==null?this._isOpen:this.open>0},set:function(t){this._isOpen=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDate",{get:function(){return this.json instanceof Date||this.type==="string"&&(O.test(this.json)||A.test(this.json)||C.test(this.json))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUrl",{get:function(){return this.type==="string"&&E.test(this.json)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isArray",{get:function(){return Array.isArray(this.json)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLargeArray",{get:function(){return this.isArray&&this.json.length>this.config.maxArrayItems},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isArrayRange",{get:function(){return this.isArray&&this.arrayRange!==void 0&&this.arrayRange.length==2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isObject",{get:function(){return y(this.json)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmptyObject",{get:function(){return!this.keys.length&&!this.isArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return this.isEmptyObject||this.keys&&!this.keys.length&&this.isArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useToJSON",{get:function(){return this.config.useToJSON&&this.type==="stringifiable"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasKey",{get:function(){return this.key!==void 0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"constructorName",{get:function(){return g(this.json)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){return this.config.useToJSON&&this.json&&this.json.toJSON?"stringifiable":u(this.json)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"keys",{get:function(){if(this.isObject){var t=Object.keys(this.json);if(this.isLargeArray){var n=Math.ceil(this.json.length/this.config.maxArrayItems);t=[];for(var r=0;rthis.config.hoverPreviewArrayCount?"Array[".concat(this.json.length,"]"):"[".concat(this.json.map(j).join(", "),"]");var n=this.keys,r=n.slice(0,this.config.hoverPreviewFieldCount).map(function(o){return"".concat(o,":").concat(j(t.json[o]))}),s=n.length>=this.config.hoverPreviewFieldCount?"\u2026":"";return"{".concat(r.join(", ")).concat(s,"}")},e.prototype.render=function(){this.element=a("div","row");var t=this.isObject?a("a","toggler-link"):a("span");if(this.isObject&&!this.useToJSON&&t.appendChild(a("span","toggler")),this.isArrayRange?t.appendChild(a("span","range","[".concat(this.displayKey,"]"))):this.hasKey&&(t.appendChild(a("span","key","".concat(this.displayKey,":"))),this.config.exposePath&&(this.element.dataset.path=JSON.stringify(this.path))),this.isObject&&!this.useToJSON){var n=a("span","value"),r=a("span");if(!this.isArrayRange){var s=a("span","constructor-name",this.constructorName);r.appendChild(s)}if(this.isArray&&!this.isArrayRange){var o=a("span");o.appendChild(a("span","bracket","[")),o.appendChild(a("span","number",this.json.length)),o.appendChild(a("span","bracket","]")),r.appendChild(o)}n.appendChild(r),t.appendChild(n)}else{(n=this.isUrl?a("a"):a("span")).classList.add(i(this.type)),this.isDate&&n.classList.add(i("date")),this.isUrl&&(n.classList.add(i("url")),n.setAttribute("href",this.json));var l=w(this.type,this.json,this.useToJSON?this.json.toJSON():this.json);n.appendChild(document.createTextNode(l)),t.appendChild(n)}if(this.isObject&&this.config.hoverPreviewEnabled){var c=a("span","preview-text");c.appendChild(document.createTextNode(this.getInlinepreview())),t.appendChild(c)}var f=a("div","children");return this.isObject&&f.classList.add(i("object")),this.isArray&&f.classList.add(i("array")),this.isEmpty&&f.classList.add(i("empty")),this.config&&this.config.theme&&this.element.classList.add(i(this.config.theme)),this.isOpen&&this.element.classList.add(i("open")),this.element.appendChild(t),this.element.appendChild(f),this.isObject&&this.isOpen&&this.appendChildren(),this.isObject&&!this.useToJSON&&t.addEventListener("click",this.toggleOpen.bind(this)),this.element},e.prototype.appendChildren=function(t){var n=this;t===void 0&&(t=!1);var r=this.element.querySelector("div.".concat(i("children")));if(r&&!this.isEmpty){var s=function(c,f){var d=n.isLargeArray?[f*n.config.maxArrayItems,Math.min(n.json.length-1,f*n.config.maxArrayItems+(n.config.maxArrayItems-1))]:void 0,h=n.isArrayRange?(n.arrayRange[0]+f).toString():c,k=new e(d?n.json.slice(d[0],d[1]+1):n.json[c],n.open-1,n.config,c,h,d?n.path:n.path.concat(h),d);r.appendChild(k.render())};if(t){var o=0,l=function(){var c=n.keys[o];s(c,o),(o+=1)10?l():p(l))};p(l)}else this.keys.forEach(function(c,f){return s(c,f)})}},e.prototype.removeChildren=function(t){t===void 0&&(t=!1);var n=this.element.querySelector("div.".concat(i("children")));if(t){var r=0,s=function(){n&&n.children.length&&(n.removeChild(n.children[0]),(r+=1)>10?s():p(s))};p(s)}else n&&(n.innerHTML="")},e}(),v=x;var b=async()=>{let e=null;try{const t=await fetch("/wp-json/wpc2o/v1/stock-sync/",{method:"get",headers:{"Content-Type":"application/json"}});if(e=await t.json(),console.log(e),t.ok)e=await t.json()}catch(t){console.log({err:t}),e={status:!1,message:"There was a problem requesting a stock sync."}}return e};document.querySelectorAll(".wpc2o-expand-details").forEach((e)=>{e?.addEventListener("click",(t)=>{t.preventDefault(),e?.nextElementSibling?.classList.toggle("show")})});document.addEventListener("DOMContentLoaded",function(){document.querySelectorAll(".wpc2o-code-block").forEach((t)=>{const n=t.getElementsByTagName("code")[0],r=new v(JSON.parse(n.innerText),1/0);t.removeChild(n),t.appendChild(r.render())})});document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("wpc2o-example-json");if(e)document.getElementById("wpc2o-expand-api-request")?.addEventListener("click",(t)=>{t.preventDefault(),e.classList.toggle("wpc2o-example-show")}),document.getElementById("wpc2o-copy-api-request")?.addEventListener("click",(t)=>{t.preventDefault(),navigator.clipboard.writeText(e.innerText)}),document.getElementById("wpc2o-manual-stock-sync-trigger")?.addEventListener("submit",async(t)=>{t.preventDefault();const n=document.getElementById("wpc2o-manual-stock-sync-trigger-button");if(n)n.disabled=!0;const r=document.createElement("span");r.id="wpc2o-manual-stock-sync-message",r.style.display="block",r.style.marginBottom="16px",r.innerText="Sync in progress... please do NOT close this page.",r.style.color="#3858e9",r.style.fontWeight="500",n?.after(r);const s=document.getElementById("wpc2o-manual-stock-sync-message"),o=await b();if(s&&o){const l=o.status?"green":"red";r.style.color=l,s.innerText=o.message}if(n)n.disabled=!1})});document.addEventListener("DOMContentLoaded",()=>{document.querySelectorAll(".wpc2o-view-order-payload").forEach((e)=>{e?.addEventListener("click",(t)=>{t.preventDefault();const n=e.nextElementSibling;if(n)n.classList.toggle("open")})}),document.querySelectorAll(".wpc2o-view-payload-modal-close").forEach((e)=>{e.addEventListener("click",(t)=>{t.preventDefault(),document.querySelectorAll(".wpc2o-view-payload-modal.open").forEach((n)=>n.classList.toggle("open"))})}),document.querySelectorAll(".wpc2o-view-payload-modal-copy").forEach((e)=>{e.addEventListener("click",(t)=>{t.preventDefault();const n=document.querySelector(".wpc2o-view-payload-modal.open .wpc2o-view-payload-modal-content");if(n)navigator.clipboard.writeText(n.innerText)})})}); diff --git a/includes/wpc2o-constant.php b/includes/wpc2o-constant.php index ea8baed..de93859 100644 --- a/includes/wpc2o-constant.php +++ b/includes/wpc2o-constant.php @@ -5,7 +5,7 @@ */ /** Our plugin version, used to asset cache busting & more. */ -define('WP_C2O_VERSION', '1.1.5'); +define('WP_C2O_VERSION', '1.1.6'); /** API option values. */ define('WPC2O_API_KEY', '_wpc2o_api_key'); diff --git a/package.json b/package.json index d54cdd2..c9a6088 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "wpclothes2order", - "version": "1.1.5", + "version": "1.1.6", "author": "AJRSoftware", "repository": { "type": "git", "url": "git+https://github.com/ajrsoftware/WPClothes2Order.git" }, "devDependencies": { - "npm-check-updates": "^16.14.12", - "prettier": "^3.2.4", - "typescript": "^5.3.3" + "npm-check-updates": "^17.1.3", + "prettier": "^3.3.3", + "typescript": "^5.6.2" }, "bugs": { "url": "https://github.com/ajrsoftware/WPClothes2Order/issues" @@ -28,6 +28,6 @@ }, "type": "module", "dependencies": { - "json-formatter-js": "^2.3.4" + "json-formatter-js": "^2.5.18" } } diff --git a/src/ts/stock-sync.ts b/src/ts/stock-sync.ts index f038b63..4f2115b 100644 --- a/src/ts/stock-sync.ts +++ b/src/ts/stock-sync.ts @@ -7,17 +7,21 @@ export const sync = async (): Promise => { let res: Response | null = null; try { - const response = await fetch(`/wp-json/wpc2o/v1/stock-sync`, { + const response = await fetch(`/wp-json/wpc2o/v1/stock-sync/`, { method: 'get', headers: { 'Content-Type': 'application/json' } }); + res = await response.json(); + + console.log(res); if (response.ok) { res = await response.json(); } } catch (err) { + console.log({ err }); res = { status: false, message: 'There was a problem requesting a stock sync.' diff --git a/wpclothes2order.php b/wpclothes2order.php index 4eabca3..8e0000c 100644 --- a/wpclothes2order.php +++ b/wpclothes2order.php @@ -4,7 +4,7 @@ * Plugin Name: WPClothes2Order * Plugin URI: https://wpclothes2order.com * Description: Unofficial WooCommerce Plugin for Clothes2Order - * Version: 1.1.5 + * Version: 1.1.6 * Plugin URI: https://www.wpclothes2order.com * Author: AJR Software * Author URI: https://www.ajrsoftware.com