* 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
2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
(n=>{jQuery(document).ready(function(){jQuery(document).on("click","#action_button",function(e){e.preventDefault();var t,e=n(this).data("page");let a="",o="";"list"===e&&(a=n(this).data("url"),o=n(this).data("event"),t=n(this).data("object"),jQuery('[data-loading="wu_action_button_loading_'+t+'"]').removeClass("hidden")),"edit"===e&&(a=n("input[name=webhook_url]").val(),o=n("select[name=event]").val(),t=n(this).data("object"),jQuery('[data-loading="wu_action_button_loading_'+t+'"]').removeClass("hidden")),n.ajax({method:"post",url:ajaxurl,data:{action:n(this).data("action"),webhook_id:n(this).data("object"),webhook_url:a,webhook_event:o},success(e){e.response?(n('[data-loading="wu_action_button_loading_'+e.id+'"]').addClass("hidden"),Swal.fire({title:"Test Response",icon:"success",html:'<pre id="content" class="wu-overflow-auto wu-p-4 wu-m-0 wu-mt-2 wu-rounded wu-text-left wu-bg-gray-800 wu-text-white wu-font-mono wu-border wu-border-solid wu-border-gray-300 wu-max-h-screen wu-overflow-y-auto">'+JSON.stringify(e.response,null,2)+"</pre>",showCloseButton:!0,showCancelButton:!1})):(n('[data-loading="wu_action_button_loading_'+e.id+'"]').addClass("hidden"),Swal.fire({title:wu_webhook_page.i18n.error_title,icon:"error",html:wu_webhook_page.i18n.error_message,showCloseButton:!0,showCancelButton:!1}))}})});let e;n("#wu_payload").length&&(e=new Vue({el:"#wu_payload",data(){return{payload:"",event:n('select[name="event"]').val(),loading:!0}},watch:{event(){this.get_event_payload()}},methods:{get_event_payload(){let t=this;t.loading=!0,n.ajax({method:"post",url:ajaxurl,data:{action:"wu_get_event_payload_preview",event:t.event},success(e){t.payload=e.data??{},t.loading=!1}})}},mounted(){this.get_event_payload()}})),n(document).on("change",'select[name="event"]',function(){e.event=n('select[name="event"]').val()}),new ClipboardJS(".btn-clipboard").on("success",function(e){let t=n(e.trigger),a=t.text();t.attr("disabled","disabled").text(wu_webhook_page.i18n.copied),setTimeout(function(){t.text(a).removeAttr("disabled")},3e3)})})})(jQuery);
|