Prep Plugin for release on WordPress.org (#23)
* Update translation text domain * Escape everything that should be escaped. * Add nonce checks where needed. * Sanitize all inputs. * Apply Code style changes across the codebase. * Correct many deprecation notices. * Optimize load order of many filters. * Add Proper Build script * Use emojii flags * Fix i18n deprecation notice for translating too early * Put all scripts in footer and load async
This commit is contained in:
4
assets/js/vue-apps.min.js
vendored
4
assets/js/vue-apps.min.js
vendored
@ -1,3 +1 @@
|
||||
(() => {
|
||||
"use strict";const{Vue:Vue$1,defineComponent}=window.wu_vue||{},hooks=wp.hooks||{},loadApp=(element,app_id,callback=null)=>{window["wu_"+app_id]&&!["add_checkout_form_field"].includes(app_id)||(window["wu_"+app_id]=new Vue$1(defineComponent({name:typeof app_id=="string"?app_id:"",el:element,directives:{init:{bind(el,binding,vnode){vnode.context[binding.arg]=binding.value}},initempty:{bind(el,binding,vnode){vnode.context[binding.arg]===""&&(vnode.context[binding.arg]=binding.value)}}},data(){let prefix=wu_settings.currency_symbol,suffix="";wu_settings.currency_position==="%v%s"?(prefix="",suffix=wu_settings.currency_symbol):wu_settings.currency_position==="%s %v"?prefix=wu_settings.currency_symbol+" ":wu_settings.currency_position==="%v %s"&&(prefix="",suffix=" "+wu_settings.currency_symbol);const settings={money_settings:{prefix,suffix,decimal:wu_settings.decimal_separator,thousands:wu_settings.thousand_separator,precision:parseInt(wu_settings.precision,10),masked:!1}};return Object.assign({},JSON.parse(element.dataset.state||"{}"),settings)},computed:{hooks:()=>hooks,console:()=>console,window:()=>window,shortcode(){return typeof this.id>"u"||typeof this.attributes>"u"?"":"["+(this.id+" "+Object.entries(this.attributes).map(([key,value])=>value===this.defaults[key]||typeof value=="object"||this.attributes[key+"_shortcode_requires"]&&Object.entries(this.attributes[key+"_shortcode_requires"]).some(([k,v])=>this.attributes[k]!==v)?"":key+'="'+(typeof value=="string"?value.trim():value)+'"').filter(value=>value).join(" ")).trim()+"]"}},mounted(){wu_on_load(),hooks.doAction("wu_"+app_id+"_mounted",this.$data);const cb=element.dataset.onLoad;typeof window[cb]=="function"&&window[cb](),callback&&callback(),this.$nextTick(function(){window.wu_initialize_code_editors(),window.wubox.refresh()})},updated(){this._priorState||(this._priorState=this.$options.data());const self=this,changedProp=Object.keys(this._data).find(key=>JSON.stringify(this._data[key])!==JSON.stringify(self._priorState[key]));this._priorState={...this._data},this.$nextTick(function(){hooks.doAction("wu_"+app_id+"_changed",changedProp,self.$data),window.wu_initialize_code_editors(),window.wubox.refresh()})},methods:{send(scope,function_name,value,cb){return scope==="window"?window[function_name](value,cb):window[scope][function_name](value,cb)},get_value(variable_name){return window[variable_name]},set_value(key,value){this[key]=value},get_state_value(value,default_value){return typeof this[value]>"u"?default_value:this[value]},duplicate_and_clean($event,query){var _a;const elements=document.querySelectorAll(query),target=elements.item(elements.length-1),clone=target.cloneNode(!0);clone.id=clone.id+"_copy",clone.querySelectorAll("input, textarea").forEach(el=>el.value=""),(_a=target.parentNode)==null||_a.insertBefore(clone,target.nextSibling)},wu_format_money(value){return wu_format_money(value)},require(data,value){return Object.prototype.toString.call(this[data])==="[object Array]"?this[data].indexOf(value)>-1:Object.prototype.toString.call(value)==="[object Array]"?value.indexOf(this[data])>-1:this[data]==value},open($event){$event.preventDefault(),this.edit=!0}}})),window["wu_"+app_id].$watch("section",function(new_value){try{const url=new URL(window.location.href);url.searchParams.set(app_id,new_value),history.pushState({},"",url)}catch(err){console.warn("Browser does not support pushState.",err)}}))},{Vue}=window.wu_vue||{},loadApps=()=>{document.querySelectorAll("[data-wu-app]").forEach(element=>{if(!Vue)return;const appId=element.dataset.wuApp;appId&&loadApp(element,appId)})};document.addEventListener("DOMContentLoaded",()=>{Vue.component("colorPicker",{props:["value"],template:'<input type="text">',mounted(){const vm=this;jQuery(this.$el).val(this.value).wpColorPicker({width:200,defaultColor:this.value,change(event,ui){vm.$emit("input",ui.color.toString())}})},watch:{value(value){jQuery(this.$el).wpColorPicker("color",value)}},destroyed(){jQuery(this.$el).off().wpColorPicker("destroy")}}),Vue.component("wpEditor",{props:["value","id","name"],template:'<textarea v-bind="$props"></textarea>',mounted(){if(typeof wp.editor>"u")return;const that=this;wp.editor.remove(this.id),wp.editor.initialize(this.id,{tinymce:{setup(editor){editor.on("init",function(){wubox.refresh()}),editor.on("keyup",()=>{editor.isDirty()&&that.$emit("input",editor.getContent())})}}})},destroyed(){typeof wp.editor>"u"||wp.editor.remove(this.id)}}),document.body.addEventListener("wubox:unload",function(){const app_name="wu_"+document.getElementById("WUB_window").querySelector("ul[data-wu-app]").dataset.wuApp;delete window[app_name],delete window[app_name+"_errors"]}),document.body.addEventListener("wubox:load",loadApps),loadApps()});
|
||||
})()
|
||||
(()=>{let{Vue:n,defineComponent:r}=window.wu_vue||{},s=wp.hooks||{},i=(window.wu_vue||{}).Vue,t=()=>{document.querySelectorAll("[data-wu-app]").forEach(t=>{var e;i&&(e=t.dataset.wuApp)&&((o,i,e=null)=>{if(window["wu_"+i]&&!["add_checkout_form_field"].includes(i))return;window["wu_"+i]=new n(r({name:"string"==typeof i?i:"",el:o,directives:{init:{bind(t,e,i){i.context[e.arg]=e.value}},initempty:{bind(t,e,i){""===i.context[e.arg]&&(i.context[e.arg]=e.value)}}},data(){let t=wu_settings.currency_symbol,e="";"%v%s"===wu_settings.currency_position?(t="",e=wu_settings.currency_symbol):"%s %v"===wu_settings.currency_position?t=wu_settings.currency_symbol+" ":"%v %s"===wu_settings.currency_position&&(t="",e=" "+wu_settings.currency_symbol);var i={money_settings:{prefix:t,suffix:e,decimal:wu_settings.decimal_separator,thousands:wu_settings.thousand_separator,precision:parseInt(wu_settings.precision,10),masked:!1}};return Object.assign({},JSON.parse(o.dataset.state||"{}"),i)},computed:{hooks:()=>s,console:()=>console,window:()=>window,shortcode(){return void 0===this.id||void 0===this.attributes?"":"["+(this.id+" "+Object.entries(this.attributes).map(([t,e])=>{if(e===this.defaults[t]||"object"==typeof e)return"";if(this.attributes[t+"_shortcode_requires"]&&Object.entries(this.attributes[t+"_shortcode_requires"]).some(([t,e])=>this.attributes[t]!==e))return"";return t+'="'+("string"==typeof e?e.trim():e)+'"'}).filter(t=>t).join(" ")).trim()+"]"}},mounted(){wu_on_load(),s.doAction("wu_"+i+"_mounted",this.$data);var t=o.dataset.onLoad;"function"==typeof window[t]&&window[t](),e&&e(),this.$nextTick(function(){window.wu_initialize_code_editors(),window.wubox.refresh()})},updated(){this._priorState||(this._priorState=this.$options.data());let e=this,t=Object.keys(this._data).find(t=>JSON.stringify(this._data[t])!==JSON.stringify(e._priorState[t]));this._priorState={...this._data},this.$nextTick(function(){s.doAction("wu_"+i+"_changed",t,e.$data),window.wu_initialize_code_editors(),window.wubox.refresh()})},methods:{send(t,e,i,o){return("window"===t?window:window[t])[e](i,o)},get_value(t){return window[t]},set_value(t,e){this[t]=e},get_state_value(t,e){return void 0===this[t]?e:this[t]},duplicate_and_clean(t,e){var i,e=document.querySelectorAll(e),e=e.item(e.length-1),o=e.cloneNode(!0);o.id=o.id+"_copy",o.querySelectorAll("input, textarea").forEach(t=>t.value=""),null!=(i=e.parentNode)&&i.insertBefore(o,e.nextSibling)},wu_format_money(t){return wu_format_money(t)},require(t,e){return"[object Array]"===Object.prototype.toString.call(this[t])?-1<this[t].indexOf(e):"[object Array]"===Object.prototype.toString.call(e)?-1<e.indexOf(this[t]):this[t]==e},open(t){t.preventDefault(),this.edit=!0}}})),window["wu_"+i].$watch("section",function(t){try{var e=new URL(window.location.href);e.searchParams.set(i,t),history.pushState({},"",e)}catch(t){console.warn("Browser does not support pushState.",t)}})})(t,e)})};document.addEventListener("DOMContentLoaded",()=>{i.component("colorPicker",{props:["value"],template:'<input type="text">',mounted(){let i=this;jQuery(this.$el).val(this.value).wpColorPicker({width:200,defaultColor:this.value,change(t,e){i.$emit("input",e.color.toString())}})},watch:{value(t){jQuery(this.$el).wpColorPicker("color",t)}},destroyed(){jQuery(this.$el).off().wpColorPicker("destroy")}}),i.component("wpEditor",{props:["value","id","name"],template:'<textarea v-bind="$props"></textarea>',mounted(){if(void 0!==wp.editor){let e=this;wp.editor.remove(this.id),wp.editor.initialize(this.id,{tinymce:{setup(t){t.on("init",function(){wubox.refresh()}),t.on("keyup",()=>{t.isDirty()&&e.$emit("input",t.getContent())})}}})}},destroyed(){void 0!==wp.editor&&wp.editor.remove(this.id)}}),document.body.addEventListener("wubox:unload",function(){var t="wu_"+document.getElementById("WUB_window").querySelector("ul[data-wu-app]").dataset.wuApp;delete window[t],delete window[t+"_errors"]}),document.body.addEventListener("wubox:load",t),t()})})();
|
||||
|
Reference in New Issue
Block a user