Plugin Directory

Changeset 3437810


Ignore:
Timestamp:
01/12/2026 02:39:24 PM (2 months ago)
Author:
vedathemes
Message:

bug fix tinymce error message

Location:
selfhost-podcasting
Files:
499 added
4 edited

Legend:

Unmodified
Added
Removed
  • selfhost-podcasting/trunk/README.txt

    r3408883 r3437810  
    55Tested up to: 6.9
    66Requires PHP: 7.4
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • selfhost-podcasting/trunk/admin/js/admin.build.js

    r3405603 r3437810  
    1 (()=>{var e={814:()=>{window.SHP_Hooks=window.SHP_Hooks||{hooks:{},addFilter(e,s,t=10){const i=this.hooks[e]=this.hooks[e]||[];i.push({callback:s,priority:t}),i.sort(((e,s)=>e.priority-s.priority))},applyFilters(e,s,...t){const i=this.hooks[e];return i?i.reduce(((e,{callback:s})=>s(e,...t)),s):s}}}},s={};function t(i){var o=s[i];if(void 0!==o)return o.exports;var r=s[i]={exports:{}};return e[i](r,r.exports,t),r.exports}(()=>{"use strict";t(814);const e=window.Sh_Podcasting_Data||{},s={ajaxUrl:e.ajaxUrl,security:e.security,i18n:e.i18n,podReq:e.podReq,epReq:e.epReq};class i{constructor(e,s=document){this.elements="string"==typeof e?this.get(e,s):[e]}static async sendAjaxRequest(e,s,t=console.error){const i=new URLSearchParams;for(const e in s)"object"==typeof s[e]?i.append(e,JSON.stringify(s[e])):i.append(e,s[e]);try{const s=await fetch(e,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if(!s.ok)throw new Error("Network response was not ok");return await s.json()}catch(e){return t(e.message),null}}static template(e,s){return e.replace(/\{\{(\w+)\}\}/g,((e,t)=>s[t]||""))}static strToHTML(e){const s=document.createElement("div");return s.innerHTML=e,s.firstElementChild}static probeAudioInBrowser(e){return new Promise(((s,t)=>{try{new URL(e)}catch(e){return void t(new Error("Provided string is not a valid URL."))}const i=new Audio;i.preload="metadata",i.src=e,i.addEventListener("loadedmetadata",(()=>{s({ok:!0,duration:i.duration})})),i.addEventListener("error",(()=>{t(new Error("Could not load audio"))}))}))}static probeImageInBrowser(e){return new Promise(((s,t)=>{let i;try{i=new URL(e)}catch(e){return void t(new Error("Provided string is not a valid URL."))}const o=i.pathname,r=o.substring(o.lastIndexOf("/")+1).split("?")[0].split("#")[0].split(".").pop().toLowerCase();if(!["jpg","jpeg","png"].includes(r))return void t(new Error("Image must be a .jpg, .jpeg, or .png file."));const n=new Image;n.onload=function(){const e=n.naturalWidth,t=n.naturalHeight;s({ok:!0,width:e,height:t})},n.onerror=function(){t(new Error("Invalid image or cannot be loaded."))},n.src=e}))}static isValidURL(e){try{return new URL(e),!0}catch(e){return!1}}static showFeedback(e="",s="success",t=1500,i=!1){const o=jQuery("#selfhost-podcasting-action-feedback");o.addClass("toggled-feedback").children("span").addClass("hidden").removeClass("inline-block"),e&&(o.find(".selfhost-podcasting-feedback").removeClass("hidden").text(e),"error"===s&&o.find(".selfhost-podcasting-error-close").removeClass("hidden").addClass("inline-block")),"success"===s&&(o.find(".dashicons-yes").removeClass("hidden").addClass("inline-block"),setTimeout(function(){o.removeClass("toggled-feedback").find("span").addClass("hidden"),i&&"function"==typeof i&&i()}.bind(this),t))}}var o,r,n;o=i,n=!1,(r=function(e){var s=function(e){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var t=s.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof s?s:s+""}(r="isFormDirty"))in o?Object.defineProperty(o,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):o[r]=n;const d=(e,s=document)=>new i(e,s);Object.getOwnPropertyNames(i).forEach((e=>{"function"==typeof i[e]&&"prototype"!==e&&(d[e]=i[e])}));const a=class{constructor(){this.createBtn=jQuery("#selfhost-podcasting-create-new"),this.overlay=jQuery("#selfhost-podcasting-overlay"),this.createForm=jQuery("#selfhost-podcasting-feed-form"),this.formInput=this.createForm.find("#selfhost-podcasting-feed-name"),this.slugInput=this.createForm.find("#selfhost-podcasting-feed-slug"),this.formSubmit=jQuery("#selfhost-podcasting-feed-form-submit"),this.formClose=jQuery("#selfhost-podcasting-feed-form-close"),this.listWrapper=jQuery("#selfhost-podcasting-list-table"),this.events()}events(){const e=this;let s=null;this.createBtn.on("click",this.openOverlay.bind(this)),this.formClose.on("click",this.closeOverlay.bind(this)),this.formSubmit.on("click",this.submitForm.bind(this)),this.formInput.on("keyup",(t=>{clearTimeout(s),s=setTimeout((()=>{e.validatePodcastTitle(),e.updateSlug()}),300)})),this.listWrapper.on("click",".selfhost-podcasting-delete-podcast",(function(){const s=jQuery(this).closest(".selfhost-podcasting-list-item").data("id");e.deletePodcast(s,jQuery(this))}))}openOverlay(){this.formInput.val(""),this.overlay.show(),this.createForm.show(),this.formInput.focus()}closeOverlay(){this.formInput.val(""),this.createForm.find(".selfhost-podcasting-error-msg").remove(),this.createForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.createForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.overlay.hide(),this.createForm.hide()}validatePodcastTitle(){this.createForm.find(".selfhost-podcasting-error-msg").remove();const e=this.formInput.val().trim();if(e)return this.createForm.find(".selfhost-podcasting-error-msg").remove(),e;{const e=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text("Podcast name is required");return this.formInput.after(e),!1}}updateSlug(){const e=this.formInput.val().trim().toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/_+/g,"-").replace(/-+/g,"-");this.slugInput.val(e)}async submitForm(){const e=this.validatePodcastTitle();if(!e)return;const t=this.slugInput.val().trim();if(this.listWrapper.find('[data-title="'.concat(t,'"]')).length){const e=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text("Podcast with this feed slug already exists");return void this.formInput.after(e)}let i={name:e,slug:t};window.SHP_Hooks&&(i=window.SHP_Hooks.applyFilters("create_podcast_meta",i)),this.createForm.find(".dashicons-plus-alt2").addClass("hidden"),this.createForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o={action:"sh_podcasting_create_podcast",security:s.security,...i},r=await d.sendAjaxRequest(s.ajaxUrl,o,this.handleError.bind(this));if(!r.success){const e=r.message?r.message:"Something went wrong",s=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(e);return this.composeFormInput.after(s),this.composeForm.find(".dashicons-plus-alt2").removeClass("hidden"),void this.composeForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden")}d.showFeedback("Podcast Created Successfully","success",1e3,(()=>{window.location.reload()}))}async deletePodcast(e,t){if(!e)return;t.find(".selfhost-podcasting-icon").addClass("hidden"),t.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const i={action:"sh_podcasting_delete_podcast",security:s.security,id:e};(await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this))).success||d.showFeedback("Episodes Imported Successfully","error"),d.showFeedback("Podcast Deleted Successfully","success",1e3,(()=>{window.location.reload()}))}handleError(e){console.log(e)}},c=class{constructor(){this.podcastForm=jQuery("#selfhost-podcasting-podcast-form"),this.sidebar=jQuery("#selfhost-podcasting-podcast-sidebar"),this.submitButton=jQuery("#selfhost-podcasting-podcast-form-submit"),this.requiredFields=s.podReq,this.formErrors=null,this.events()}events(){const e=this,s=this.podcastForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),this.sidebar.on("click",".litem",(s=>{s.preventDefault(),e.tabFunctionality(s.target)})),jQuery(".selfhost-podcasting-group-header").on("click",(e=>{const s=jQuery(e.target).closest(".selfhost-podcasting-podcast-field-group");s.length&&s.toggleClass("selfhost-toggled")})),s.each((function(){const s=jQuery(this),t=s.prop("tagName").toLowerCase(),i=s.attr("type");if("select"===t)s.on("change",(s=>e.handleFieldChange(jQuery(s.target))));else if("input"===t||"textarea"===t){if("checkbox"===i||"radio"===i)return;if(s.hasClass("wp-editor-area")){const t=s.attr("id");return void("undefined"!=typeof tinymce&&tinymce.get(t)&&!tinymce.get(t).isHidden()&&tinymce.get(t).on("blur",(function(){e.handleTinyMCEChange(s)})))}s.on("blur",(t=>e.handleFieldChange(s)))}s.on("change input paste",(()=>{d.isFormDirty=!0}))})),this.podcastForm.find(".selfhost-tomselect").each((function(){const s=jQuery(this).attr("id");jQuery(this).removeClass("tom-select-hidden"),new TomSelect("#".concat(s),{plugins:["remove_button"],persist:!1,create:!1,render:{option:function(e,s){return"<div>"+s(e.text)+"</div>"}}}).on("change",(()=>e.handleFieldChange(jQuery(this))))}));const t=jQuery("#selfhost-podcasting-action-feedback");t.find(".selfhost-podcasting-error-close").on("click",(()=>{t.removeClass("toggled-feedback").find("span").addClass("hidden")})),window.addEventListener("beforeunload",(e=>{d.isFormDirty&&(e.preventDefault(),e.returnValue="")}))}handleFieldChange(e){const t=e.val(),i=e.attr("id");if(!i)return;const o=e.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove();const r=i.replace("selfhost-podcasting-",""),n=r.replace(/[-_]/g," ");this.requiredFields.includes(r)&&(!t||Array.isArray(t)&&0===t.length)?o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.podreq+n+"</div>")):"cover_image-src"===r&&this.validateImage(e)}handleTinyMCEChange(e){const t=(e=jQuery(e)).attr("id");if(!t)return;const i="undefined"!=typeof tinymce&&tinymce.get(t);if(!i)return;const o=e.closest(".selfhost-podcasting-form-field"),r=i.getContent(),n=t.replace("selfhost-podcasting-",""),d=n.replace(/[-_]/g," ");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),this.requiredFields.includes(n)&&!r&&o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.podreq+d+"</div>"))}async validateImage(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeImageInBrowser(i).then((e=>{const t=e.width;t===e.height?(t<1400||t>3e3)&&o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_min_size+"</div>")):o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_sq_err+"</div>"))})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+e.message+"</div>"))}))}tabFunctionality(e){const s=jQuery(e),t=s.attr("data-attr"),i=jQuery("#selfhost-podcasting-"+t);i&&(s.closest(".selfhost-podcasting-sidebar-manu").find(".litem-active").removeClass("litem-active"),s.addClass("litem-active"),i.siblings(".selfhost-visible").removeClass("selfhost-visible").addClass("hidden"),i.removeClass("hidden").addClass("selfhost-visible"),this.reloadEditors(i))}reloadEditors(e){const s=this;e.hasClass("editor-refreshed")||(e.find("textarea.wp-editor-area").each((function(){const e=this,t=e.id;"undefined"!=typeof tinymce&&(tinymce.get(t)&&tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t),tinymce.get(t).on("blur",(function(){s.handleTinyMCEChange(e)})))})),e.addClass("editor-refreshed"))}getFormValues(){const e=this;if(this.podcastForm.find(".selfhost-input-error").length)return!1;this.formErrors=null;const s=this.podcastForm.find(".selfhost-form-field"),t={};return s.each((function(){const s=jQuery(this),i=s.attr("id");if(!i)return;const o=i.replace("selfhost-podcasting-","");let r=s.val();if(s.hasClass("wp-editor-area")&&"undefined"!=typeof tinymce&&tinymce.get(i)&&!tinymce.get(i).isHidden()&&(r=tinymce.get(i).getContent()),(!r||Array.isArray(r)&&0===r.length)&&e.requiredFields.includes(o)){e.formErrors=!0;const t=s.attr("type");if("checkbox"===t||"radio"===t)return;s.hasClass("wp-editor-area")?e.handleTinyMCEChange(s):e.handleFieldChange(s)}s.is(":checkbox")?r=s.is(":checked")?"yes":"":s.is("select")&&(s.attr("multiple")?(r=[],s.find("option:selected").each((function(){r.push(jQuery(this).val())}))):r=s.find("option:selected").val()),t[o]=r})),!this.formErrors&&t}async submitForm(){const e=this.getFormValues(),t=this.podcastForm.data("id");if(!1===e){const e=this.podcastForm.find(".selfhost-input-error");return void(e.length&&jQuery("html, body").animate({scrollTop:e.first().offset().top-100},400))}if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_save_podcast",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Podcast Data Updated Successfully"),d.isFormDirty=!1)}handleError(e){console.log(e)}},l=class{constructor(){this.createButton=jQuery("#selfhost-podcasting-create-new-episode"),this.importBtn=jQuery("#selfhost-podcasting-import-new"),this.overlay=jQuery("#selfhost-podcasting-overlay"),this.importForm=jQuery("#selfhost-podcasting-episodes-import-form"),this.episodesWrap=jQuery("#selfhost-podcasting-podcast-episodes"),this.episodeForm=jQuery("#selfhost-podcasting-episode-form"),this.submitButton=this.episodeForm.find("#selfhost-podcasting-episode-form-submit"),this.podcastId=this.episodeForm.closest("#selfhost-podcasting-podcast-episodes").attr("data-id"),this.requiredFields=s.epReq,this.formErrors=null,this.events()}events(){const e=this,s=this.episodeForm.find(".selfhost-form-field");this.submitButton.on("click",(()=>{e.submitForm()})),this.episodeForm.find(".selfhost-field-audio").on("blur",(s=>{e.validateAudio(s.target)})),this.createButton.on("click",(s=>{e.showCreateNew()})),this.importBtn.on("click",this.openOverlay.bind(this)),this.importForm.find("#selfhost-podcasting-feed-url-close").on("click",this.closeOverlay.bind(this)),this.importForm.find("#selfhost-podcasting-feed-url-submit").on("click",this.showPodcastEpisodes.bind(this)),this.episodesWrap.on("click",".selfhost-podcasting-delete-episode",(s=>{e.deleteEpisode(s.target)})),jQuery(".selfhost-toggle-link").on("click",(e=>{e.preventDefault();const s=jQuery(e.target);s.closest(".selfhost-podcasting-form-field").find(".selfhost-toggle-wrapper").show(),s.closest(".selfhost-date-label").remove()})),this.episodeForm.find(".selfhost-field-upload-to-bucket").on("click",(s=>{s.preventDefault(),e.uploadMediatoBucket(jQuery(this))}));const t=this.importForm.find(".selfhost-podcasting-import-episodes-list");t.on("click",".selfhost-checkbox-select-all",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').prop("checked",!0)})),t.on("click",".selfhost-checkbox-deselect-all",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').prop("checked",!1)})),t.on("click",".selfhost-checkbox-select-inverse",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').each((function(){jQuery(this).prop("checked",!jQuery(this).prop("checked"))}))})),this.importForm.find("#selfhost-podcasting-import-episodes-submit").on("click",this.importSelectedEpisodes.bind(this)),s.each((function(){const s=jQuery(this),t=s.prop("tagName").toLowerCase(),i=s.attr("type");if("select"===t)s.on("change",(s=>e.handleFieldChange(jQuery(s.target))));else if("input"===t||"textarea"===t){if("checkbox"===i||"radio"===i)return;if(s.hasClass("wp-editor-area")){const t=s.attr("id");return void("undefined"!=typeof tinymce&&tinymce.get(t)&&!tinymce.get(t).isHidden()&&tinymce.get(t).on("blur",(function(){e.handleTinyMCEChange(s)})))}s.on("blur",(t=>e.handleFieldChange(s)))}s.on("change input paste",(()=>{d.isFormDirty=!0}))}))}handleFieldChange(e){const t=this,i=e.val(),o=e.attr("id");if(!o)return;const r=e.closest(".selfhost-podcasting-form-field");r.removeClass("selfhost-input-error").find(".selfhost-error-message").remove();const n=o.replace("selfhost-podcasting-episode-",""),d=n.replace(/[-_]/g," ");if(!this.requiredFields.includes(n)||i)switch(n){case"enclosure-src":t.validateAudio(e);break;case"episode_art-src":t.validateImage(e)}else r.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.epireq+d+"</div>"))}handleTinyMCEChange(e){const t=e.attr("id");if(!t)return;const i="undefined"!=typeof tinymce&&tinymce.get(t);if(!i)return;const o=e.closest(".selfhost-podcasting-form-field"),r=i.getContent(),n=t.replace("selfhost-podcasting-episode-",""),d=n.replace(/[-_]/g," ");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),this.requiredFields.includes(n)&&!r&&o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.epireq+d+"</div>"))}getFormValues(){const e=this;if(this.episodeForm.find(".selfhost-input-error").length)return!1;this.formErrors=null;const s=this.episodeForm.find(".selfhost-form-field"),t={};return s.each((function(){const s=jQuery(this),i=s.attr("id"),o=s.attr("data-validation");if(!i)return;const r=i.replace("selfhost-podcasting-episode-","");if("invalid"===o)return void(t[r]=!1);let n=s.val();if(s.hasClass("wp-editor-area")&&"undefined"!=typeof tinymce&&tinymce.get(i)&&!tinymce.get(i).isHidden()&&(n=tinymce.get(i).getContent()),!n&&e.requiredFields.includes(r)){e.formErrors=!0;const t=s.attr("type");if("checkbox"===t||"radio"===t)return;s.hasClass("wp-editor-area")?e.handleTinyMCEChange(s):e.handleFieldChange(s)}s.is(":checkbox")?n=s.is(":checked")?"yes":"":s.is("select")&&(s.attr("multiple")?(n=[],s.find("option:selected").each((function(){n.push(jQuery(this).val())}))):n=s.find("option:selected").val()),t[r]=n})),!this.formErrors&&t}async submitForm(){const e=this.getFormValues();if(!1===e){const e=this.episodeForm.find(".selfhost-input-error");return void(e.length&&jQuery("html, body").animate({scrollTop:e.first().offset().top-100},400))}const t=this.episodeForm.attr("data-episode");if(!this.podcastId)return void d.showFeedback("Podcast ID is missing.","error");if(!e["enclosure-src"])return void d.showFeedback("Episode Audio is required.","error");e.id=this.podcastId;const i={action:"sh_podcasting_create_episode",security:s.security,formData:e,episodeId:t||0};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),(await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this))).success&&(d.showFeedback("Episodes Updated Successfully"),d.isFormDirty=!1),this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden")}async uploadMediatoBucket(e){const t=this.episodeForm.find("#selfhost-podcasting-episode-enclosure-src").val(),i=this.episodeForm.find("#selfhost-podcasting-episode-enclosure-id").val(),o=this.episodeForm.attr("data-episode");if(!this.podcastId)return void d.showFeedback("Podcast ID is missing.","error");if(!t||!o)return void d.showFeedback("Required media or episode information is not available.","error");const r={action:"sh_podcasting_upload_media",security:s.security,podcastId:this.podcastId,mediaUrl:t,mediaId:i,episodeId:o};e.prop("disabled",!0).next(".icon-selfhost-podcasting-spinner").removeClass("hidden"),(await d.sendAjaxRequest(s.ajaxUrl,r,this.handleError.bind(this))).success&&(d.showFeedback("Media Uploaded Successfully"),d.isFormDirty=!1),e.prop("disabled",!1).next(".icon-selfhost-podcasting-spinner").addClass("hidden")}async validateAudio(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeAudioInBrowser(i).then((e=>{const s=t.closest(".selfhost-podcasting-form-field"),i=!!s&&s.next(".selfhost-duration"),o=!!i&&i.find("input");o&&o.val(e.duration)})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.invalid_audio+"</div>")),o.find("#selfhost-podcasting-episode-enclosure-id").val("")}))}async validateImage(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeImageInBrowser(i).then((e=>{const t=e.width;return t!==e.height?(o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_sq_err+"</div>")),void o.find("#selfhost-podcasting-episode-episode_art-id").val("")):t<1400||t>3e3?(o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_min_size+"</div>")),void o.find("#selfhost-podcasting-episode-episode_art-id").val("")):void 0})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.invalid_image+"</div>")),o.find("#selfhost-podcasting-episode-episode_art-id").val("")}))}async deleteEpisode(e){const t=jQuery(e).closest(".selfhost-table-row"),i=t.closest("#selfhost-podcasting-podcast-episodes"),o=!!t&&t.attr("data-episode"),r=!!i&&i.attr("data-id");if(!o||!r)return;const n={action:"sh_podcasting_delete_episode",security:s.security,id:o,podcastId:r},a=this.episodesWrap.find(".selfhost-podcasting-delete-episode");a.prop("disabled",!0),console.log(a),(await d.sendAjaxRequest(s.ajaxUrl,n,this.handleError.bind(this))).success&&(t.remove(),d.showFeedback("Episode Removed Successfully")),a.prop("disabled",!1)}showCreateNew(){this.episodesWrap.find(".selfhost-podcasting-podcast-form-fields").addClass("hidden"),this.episodeForm.removeClass("hidden"),this.reloadEditors(this.episodeForm)}reloadEditors(e){const s=this;e.hasClass("editor-refreshed")||(e.find("textarea.wp-editor-area").each((function(){const e=this,t=e.id;"undefined"!=typeof tinymce&&(tinymce.get(t)&&tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t),tinymce.get(t).on("blur",(function(){s.handleTinyMCEChange(jQuery(e))})))})),e.addClass("editor-refreshed"))}openOverlay(){const e=this.importForm.find("#selfhost-podcasting-feed-url");this.overlay.show(),this.importForm.show(),e.val("").focus()}closeOverlay(){this.importForm.find("#selfhost-podcasting-feed-url").val(""),this.importForm.find(".selfhost-podcasting-error-msg").remove(),this.importForm.find(".selfhost-podcasting-import-episodes-list").empty().addClass("hidden"),this.importForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.importForm.find(".selfhost-podcasting-import-episodes-list").empty().addClass("hidden"),this.importForm.find(".selfhost-podcasting-input-feed-url").removeClass("hidden"),this.importForm.find("#selfhost-podcasting-feed-url-submit").removeClass("hidden"),this.importForm.find("#selfhost-podcasting-import-episodes-submit").addClass("hidden"),this.overlay.hide(),this.importForm.hide()}showPodcastEpisodes(){const e=this.getValidFeedUrl();e&&(this.importForm.find(".dashicons-plus-alt2").addClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),this.fetchPodcastEpisodes(e))}async importSelectedEpisodes(){const e=this.importForm.find(".selfhost-podcasting-import-episodes-list"),t=e.find("ul"),i=t.length?t.attr("data-feed"):"",o=this.overlay.attr("data-id");if(!i)return void d.showFeedback("Feed URL not provided","error");const r=e.find('input[type="checkbox"]:checked').map((function(){return this.id})).get();if(0===r.length)return void d.showFeedback("Select an episode to continue","error");const n={action:"sh_podcasting_import_episodes",security:s.security,feedUrl:i,selectedIds:r,podcastId:o};this.importForm.find(".dashicons-plus-alt2").addClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const a=await d.sendAjaxRequest(s.ajaxUrl,n,this.handleError.bind(this));this.closeOverlay(),a.success&&d.showFeedback("Episodes Imported Successfully","success",1e3,(()=>{window.location.reload()}))}async fetchPodcastEpisodes(e){const t={action:"sh_podcasting_fetch_episodes",security:s.security,feedUrl:e},i=await d.sendAjaxRequest(s.ajaxUrl,t,this.handleError.bind(this));if(i.success){const s=i.data;if(0===s.length)return;const t=s.title,o=s.items,r=Object.keys(o),n='\n            <h2 class="mb-2 font-bold text-lg">'.concat(t,'</h2>\n            <div class="selfhost-checkbox-actions my-2 mb-2 flex items-center">\n                <a class="selfhost-checkbox-select-all mr-2 px-3 py-2 block border focus:shadow-none" href="#">Select All</a>\n                <a class="selfhost-checkbox-deselect-all mr-2 px-3 py-2 block border focus:shadow-none" href="#">Clear Selection</a>\n                <a class="selfhost-checkbox-select-inverse mr-2 px-3 py-2 block border focus:shadow-none" href="#">Inverse Selection</a>\n            </div>\n            <ul class="max-h-[400px] overflow-y-scroll" data-feed="').concat(e,'">').concat(r.map((e=>{const s=o[e];return'<li class="flex items-center border-b flex-wrap" data-guid="'.concat(e,'"><input class="block mr-2" type="checkbox" id="').concat(e,'" /><label class="flex-1 cursor-pointer py-2" for="').concat(e,'">').concat(s,"</label></li>")})).join(""),"</ul>\n            "),a=this.importForm.find(".selfhost-podcasting-import-episodes-list");this.importForm.find(".selfhost-podcasting-input-feed-url").addClass("hidden"),this.importForm.find("#selfhost-podcasting-feed-url-submit").addClass("hidden"),this.importForm.find("#selfhost-podcasting-import-episodes-submit").removeClass("hidden"),a.removeClass("hidden"),a.html(n),d.showFeedback("Episodes Fetched Successfully")}else d.showFeedback("Could not load episodes.","error");this.importForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden")}getValidFeedUrl(){this.importForm.find(".selfhost-podcasting-error-msg").remove();const e=this.importForm.find("#selfhost-podcasting-feed-url"),t=e.val().trim();if(t){if(d.isValidURL(t))return this.importForm.find(".selfhost-podcasting-error-msg").remove(),t;const i=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(s.i18n.invalid_feed);return e.after(i),!1}{const t=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(s.i18n.feed_required);return e.after(t),!1}}handleError(e){console.log(e)}},h=class{constructor(){this.uploadText=s.i18n,this.fileFrame=wp.media.frames.fileFrame=wp.media({title:this.uploadText.title,button:{text:this.uploadText.btn_text},multiple:!1}),this.clickedUploader=null,this.fileFrame.on("select",(()=>{const e=this.fileFrame.state().get("selection").first().toJSON(),s=this.clickedUploader,t=e.url,i=e.id;s.find(".selfhost-img-id").val(i),s.find(".selfhost-img-src").val(t).focus().trigger("change")})),this.events()}events(){const e=this;jQuery(document).on("click",".selfhost-podcasting-img-uploader",(function(s){s.preventDefault(),e.addImage(jQuery(this))}))}addImage(e){const s=e.prevAll(".selfhost-image-upload");this.clickedUploader=s,this.fileFrame.open()}},p=class{constructor(){this.uploadText=s.i18n,this.fileFrame=wp.media.frames.fileFrame=wp.media({title:this.uploadText.aud_title,button:{text:this.uploadText.btn_text},multiple:!1,library:{type:"audio"}}),this.clickedUploader=null,this.fileFrame.on("select",(()=>{const e=this.fileFrame.state().get("selection").first().toJSON(),s=this.clickedUploader,t=e.url,i=e.id;s.find(".selfhost-audio-id").val(i),s.find(".selfhost-audio-src").val(t).focus().trigger("change")})),this.events()}events(){const e=this;jQuery(document).on("click",".selfhost-podcasting-audio-uploader",(function(s){s.preventDefault(),e.addAudio(jQuery(this))}))}addAudio(e){const s=e.prevAll(".selfhost-audio-upload");this.clickedUploader=s,this.fileFrame.open()}},f=class{constructor(){this.settingForm=jQuery("#selfhost-podcasting-podcast-settings"),this.submitButton=jQuery("#selfhost-podcasting-settings-form-submit"),this.events()}events(){const e=this,s=this.settingForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),s.each((function(){jQuery(this).on("change input paste",(()=>{d.isFormDirty=!0}))}))}getFormValues(){const e=this.settingForm.find(".selfhost-form-field"),s={};return e.each((function(){const e=jQuery(this),t=e.attr("id");if(!t)return;const i=t.replace("selfhost-podcasting-settings-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),s[i]=o})),s}async submitForm(){const e=this.getFormValues(),t=this.settingForm.data("id");if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_save_settings",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Data Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}},u=class{constructor(){this.manageForm=jQuery("#selfhost-podcasting-podcast-manager"),this.submitButton=jQuery("#selfhost-podcasting-manage-form-submit"),this.events()}events(){const e=this,s=this.manageForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),s.each((function(){jQuery(this).on("change input paste",(()=>{d.isFormDirty=!0}))}))}getFormValues(){const e=this.manageForm.find(".selfhost-form-field"),s={};return e.each((function(){const e=jQuery(this),t=e.attr("id");if(!t)return;const i=t.replace("selfhost-podcasting-manage-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),s[i]=o})),s}async submitForm(){const e=this.getFormValues(),t=this.manageForm.data("id");if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_update_options",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Data Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}},m=class{constructor(){this.integrationForm=jQuery("#selfhost-podcasting-podcast-integrations"),this.submitButton=jQuery(".selfhost-integration-submit"),this.events()}events(){const e=this,s=this.integrationForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){const t=jQuery(this);s.preventDefault(),e.submitForm(t)})),s.each((function(){const e=jQuery(this);e.on("change input paste",(()=>{d.isFormDirty=!0})),e.hasClass("useBucket")&&e.on("change",(()=>{const s=e.is(":checked"),t=e.closest(".selfhost-podcasting-form-field");if(!s)return void t.nextAll(".selfhost-podcasting-form-field").hide();const i=t.next(".selfhost-provider").find(".provider").val();t.nextAll(".selfhost-podcasting-form-field").hide(),t.nextAll(".selfhost-all, .selfhost-"+i).show()})),e.hasClass("provider")&&e.on("change",(()=>{const s=e.closest(".selfhost-podcasting-form-field"),t=e.val();s.nextAll(".selfhost-podcasting-form-field").hide(),s.nextAll(".selfhost-all, .selfhost-"+t).show()}))}))}getFormValues(e){const s=e.find(".selfhost-form-field"),t={};return s.each((function(){const e=jQuery(this),s=e.attr("id");if(!s)return;const i=s.replace("selfhost-podcasting-settings-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),t[i]=o})),t}async submitForm(e){const t=this.getFormValues(e.closest(".selfhost-podcasting-group-content")),i=e.data("podcast-id"),o=e.data("integration");if(!i)return void d.showFeedback("Podcast ID is missing.","error");if(!o)return void d.showFeedback("Integration is missing.","error");t.id=i;const r={action:"sh_podcasting_update_integration",security:s.security,formData:t,podcastId:i,integration:o};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),this.submitButton.find(".icon-selfhost-podcasting-save").addClass("hidden");const n=await d.sendAjaxRequest(s.ajaxUrl,r,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.submitButton.find(".icon-selfhost-podcasting-save").removeClass("hidden"),n.success&&(d.showFeedback("Integration Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}};jQuery((function(e){new a,new c,new l,new h,new p,new f,new u,new m}))})()})();
     1(()=>{var e={814:()=>{window.SHP_Hooks=window.SHP_Hooks||{hooks:{},addFilter(e,s,t=10){const i=this.hooks[e]=this.hooks[e]||[];i.push({callback:s,priority:t}),i.sort(((e,s)=>e.priority-s.priority))},applyFilters(e,s,...t){const i=this.hooks[e];return i?i.reduce(((e,{callback:s})=>s(e,...t)),s):s}}}},s={};function t(i){var o=s[i];if(void 0!==o)return o.exports;var r=s[i]={exports:{}};return e[i](r,r.exports,t),r.exports}(()=>{"use strict";t(814);const e=window.Sh_Podcasting_Data||{},s={ajaxUrl:e.ajaxUrl,security:e.security,i18n:e.i18n,podReq:e.podReq,epReq:e.epReq};class i{constructor(e,s=document){this.elements="string"==typeof e?this.get(e,s):[e]}static async sendAjaxRequest(e,s,t=console.error){const i=new URLSearchParams;for(const e in s)"object"==typeof s[e]?i.append(e,JSON.stringify(s[e])):i.append(e,s[e]);try{const s=await fetch(e,{method:"POST",body:i,headers:{"Content-Type":"application/x-www-form-urlencoded; charset=UTF-8"}});if(!s.ok)throw new Error("Network response was not ok");return await s.json()}catch(e){return t(e.message),null}}static template(e,s){return e.replace(/\{\{(\w+)\}\}/g,((e,t)=>s[t]||""))}static strToHTML(e){const s=document.createElement("div");return s.innerHTML=e,s.firstElementChild}static probeAudioInBrowser(e){return new Promise(((s,t)=>{try{new URL(e)}catch(e){return void t(new Error("Provided string is not a valid URL."))}const i=new Audio;i.preload="metadata",i.src=e,i.addEventListener("loadedmetadata",(()=>{s({ok:!0,duration:i.duration})})),i.addEventListener("error",(()=>{t(new Error("Could not load audio"))}))}))}static probeImageInBrowser(e){return new Promise(((s,t)=>{let i;try{i=new URL(e)}catch(e){return void t(new Error("Provided string is not a valid URL."))}const o=i.pathname,r=o.substring(o.lastIndexOf("/")+1).split("?")[0].split("#")[0].split(".").pop().toLowerCase();if(!["jpg","jpeg","png"].includes(r))return void t(new Error("Image must be a .jpg, .jpeg, or .png file."));const n=new Image;n.onload=function(){const e=n.naturalWidth,t=n.naturalHeight;s({ok:!0,width:e,height:t})},n.onerror=function(){t(new Error("Invalid image or cannot be loaded."))},n.src=e}))}static isValidURL(e){try{return new URL(e),!0}catch(e){return!1}}static showFeedback(e="",s="success",t=1500,i=!1){const o=jQuery("#selfhost-podcasting-action-feedback");o.addClass("toggled-feedback").children("span").addClass("hidden").removeClass("inline-block"),e&&(o.find(".selfhost-podcasting-feedback").removeClass("hidden").text(e),"error"===s&&o.find(".selfhost-podcasting-error-close").removeClass("hidden").addClass("inline-block")),"success"===s&&(o.find(".dashicons-yes").removeClass("hidden").addClass("inline-block"),setTimeout(function(){o.removeClass("toggled-feedback").find("span").addClass("hidden"),i&&"function"==typeof i&&i()}.bind(this),t))}}var o,r,n;o=i,n=!1,(r=function(e){var s=function(e){if("object"!=typeof e||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var t=s.call(e,"string");if("object"!=typeof t)return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==typeof s?s:s+""}(r="isFormDirty"))in o?Object.defineProperty(o,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):o[r]=n;const d=(e,s=document)=>new i(e,s);Object.getOwnPropertyNames(i).forEach((e=>{"function"==typeof i[e]&&"prototype"!==e&&(d[e]=i[e])}));const a=class{constructor(){this.createBtn=jQuery("#selfhost-podcasting-create-new"),this.overlay=jQuery("#selfhost-podcasting-overlay"),this.createForm=jQuery("#selfhost-podcasting-feed-form"),this.formInput=this.createForm.find("#selfhost-podcasting-feed-name"),this.slugInput=this.createForm.find("#selfhost-podcasting-feed-slug"),this.formSubmit=jQuery("#selfhost-podcasting-feed-form-submit"),this.formClose=jQuery("#selfhost-podcasting-feed-form-close"),this.listWrapper=jQuery("#selfhost-podcasting-list-table"),this.events()}events(){const e=this;let s=null;this.createBtn.on("click",this.openOverlay.bind(this)),this.formClose.on("click",this.closeOverlay.bind(this)),this.formSubmit.on("click",this.submitForm.bind(this)),this.formInput.on("keyup",(t=>{clearTimeout(s),s=setTimeout((()=>{e.validatePodcastTitle(),e.updateSlug()}),300)})),this.listWrapper.on("click",".selfhost-podcasting-delete-podcast",(function(){const s=jQuery(this).closest(".selfhost-podcasting-list-item").data("id");e.deletePodcast(s,jQuery(this))}))}openOverlay(){this.formInput.val(""),this.overlay.show(),this.createForm.show(),this.formInput.focus()}closeOverlay(){this.formInput.val(""),this.createForm.find(".selfhost-podcasting-error-msg").remove(),this.createForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.createForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.overlay.hide(),this.createForm.hide()}validatePodcastTitle(){this.createForm.find(".selfhost-podcasting-error-msg").remove();const e=this.formInput.val().trim();if(e)return this.createForm.find(".selfhost-podcasting-error-msg").remove(),e;{const e=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text("Podcast name is required");return this.formInput.after(e),!1}}updateSlug(){const e=this.formInput.val().trim().toLowerCase().replace(/[^\w\s-]/g,"").trim().replace(/\s+/g,"-").replace(/_+/g,"-").replace(/-+/g,"-");this.slugInput.val(e)}async submitForm(){const e=this.validatePodcastTitle();if(!e)return;const t=this.slugInput.val().trim();if(this.listWrapper.find('[data-title="'.concat(t,'"]')).length){const e=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text("Podcast with this feed slug already exists");return void this.formInput.after(e)}let i={name:e,slug:t};window.SHP_Hooks&&(i=window.SHP_Hooks.applyFilters("create_podcast_meta",i)),this.createForm.find(".dashicons-plus-alt2").addClass("hidden"),this.createForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o={action:"sh_podcasting_create_podcast",security:s.security,...i},r=await d.sendAjaxRequest(s.ajaxUrl,o,this.handleError.bind(this));if(!r.success){const e=r.message?r.message:"Something went wrong",s=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(e);return this.composeFormInput.after(s),this.composeForm.find(".dashicons-plus-alt2").removeClass("hidden"),void this.composeForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden")}d.showFeedback("Podcast Created Successfully","success",1e3,(()=>{window.location.reload()}))}async deletePodcast(e,t){if(!e)return;t.find(".selfhost-podcasting-icon").addClass("hidden"),t.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const i={action:"sh_podcasting_delete_podcast",security:s.security,id:e};(await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this))).success||d.showFeedback("Episodes Imported Successfully","error"),d.showFeedback("Podcast Deleted Successfully","success",1e3,(()=>{window.location.reload()}))}handleError(e){console.log(e)}},c=class{constructor(){this.podcastForm=jQuery("#selfhost-podcasting-podcast-form"),this.sidebar=jQuery("#selfhost-podcasting-podcast-sidebar"),this.submitButton=jQuery("#selfhost-podcasting-podcast-form-submit"),this.requiredFields=s.podReq,this.formErrors=null,this.events()}events(){const e=this,s=this.podcastForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),this.sidebar.on("click",".litem",(s=>{s.preventDefault(),e.tabFunctionality(s.target)})),jQuery(".selfhost-podcasting-group-header").on("click",(e=>{const s=jQuery(e.target).closest(".selfhost-podcasting-podcast-field-group");s.length&&s.toggleClass("selfhost-toggled")})),s.each((function(){const s=jQuery(this),t=s.prop("tagName").toLowerCase(),i=s.attr("type");if("select"===t)s.on("change",(s=>e.handleFieldChange(jQuery(s.target))));else if("input"===t||"textarea"===t){if("checkbox"===i||"radio"===i)return;if(s.hasClass("wp-editor-area")){const t=s.attr("id");return void("undefined"!=typeof tinymce&&tinymce.get(t)&&!tinymce.get(t).isHidden()&&tinymce.get(t).on("blur",(function(){e.handleTinyMCEChange(s)})))}s.on("blur",(t=>e.handleFieldChange(s)))}s.on("change input paste",(()=>{d.isFormDirty=!0}))})),this.podcastForm.find(".selfhost-tomselect").each((function(){const s=jQuery(this).attr("id");jQuery(this).removeClass("tom-select-hidden"),new TomSelect("#".concat(s),{plugins:["remove_button"],persist:!1,create:!1,render:{option:function(e,s){return"<div>"+s(e.text)+"</div>"}}}).on("change",(()=>e.handleFieldChange(jQuery(this))))}));const t=jQuery("#selfhost-podcasting-action-feedback");t.find(".selfhost-podcasting-error-close").on("click",(()=>{t.removeClass("toggled-feedback").find("span").addClass("hidden")})),window.addEventListener("beforeunload",(e=>{d.isFormDirty&&(e.preventDefault(),e.returnValue="")}))}handleFieldChange(e){const t=e.val(),i=e.attr("id");if(!i)return;const o=e.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove();const r=i.replace("selfhost-podcasting-",""),n=r.replace(/[-_]/g," ");this.requiredFields.includes(r)&&(!t||Array.isArray(t)&&0===t.length)?o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.podreq+n+"</div>")):"cover_image-src"===r&&this.validateImage(e)}handleTinyMCEChange(e){const t=(e=jQuery(e)).attr("id");if(!t)return;const i="undefined"!=typeof tinymce&&tinymce.get(t);if(!i)return;const o=e.closest(".selfhost-podcasting-form-field"),r=i.getContent(),n=t.replace("selfhost-podcasting-",""),d=n.replace(/[-_]/g," ");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),this.requiredFields.includes(n)&&!r&&o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.podreq+d+"</div>"))}async validateImage(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeImageInBrowser(i).then((e=>{const t=e.width;t===e.height?(t<1400||t>3e3)&&o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_min_size+"</div>")):o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_sq_err+"</div>"))})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+e.message+"</div>"))}))}tabFunctionality(e){const s=jQuery(e),t=s.attr("data-attr"),i=jQuery("#selfhost-podcasting-"+t);i&&(s.closest(".selfhost-podcasting-sidebar-manu").find(".litem-active").removeClass("litem-active"),s.addClass("litem-active"),i.siblings(".selfhost-visible").removeClass("selfhost-visible").addClass("hidden"),i.removeClass("hidden").addClass("selfhost-visible"),this.reloadEditors(i))}reloadEditors(e){const s=this;e.hasClass("editor-refreshed")||(e.find("textarea.wp-editor-area").each((function(){const e=this,t=e.id;"undefined"!=typeof tinymce&&(tinymce.get(t)&&tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t),tinymce.get(t).on("blur",(function(){s.handleTinyMCEChange(e)})))})),e.addClass("editor-refreshed"))}getFormValues(){const e=this;if(this.podcastForm.find(".selfhost-input-error").length)return!1;this.formErrors=null;const s=this.podcastForm.find(".selfhost-form-field"),t={};return s.each((function(){const s=jQuery(this),i=s.attr("id");if(!i)return;const o=i.replace("selfhost-podcasting-","");let r=s.val();if(s.hasClass("wp-editor-area")&&"undefined"!=typeof tinymce&&tinymce.get(i)&&!tinymce.get(i).isHidden()&&(r=tinymce.get(i).getContent()),(!r||Array.isArray(r)&&0===r.length)&&e.requiredFields.includes(o)){e.formErrors=!0;const t=s.attr("type");if("checkbox"===t||"radio"===t)return;s.hasClass("wp-editor-area")?e.handleTinyMCEChange(s):e.handleFieldChange(s)}s.is(":checkbox")?r=s.is(":checked")?"yes":"":s.is("select")&&(s.attr("multiple")?(r=[],s.find("option:selected").each((function(){r.push(jQuery(this).val())}))):r=s.find("option:selected").val()),t[o]=r})),!this.formErrors&&t}async submitForm(){const e=this.getFormValues(),t=this.podcastForm.data("id");if(!1===e){const e=this.podcastForm.find(".selfhost-input-error");return void(e.length&&jQuery("html, body").animate({scrollTop:e.first().offset().top-100},400))}if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_save_podcast",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Podcast Data Updated Successfully"),d.isFormDirty=!1)}handleError(e){console.log(e)}},l=class{constructor(){this.createButton=jQuery("#selfhost-podcasting-create-new-episode"),this.importBtn=jQuery("#selfhost-podcasting-import-new"),this.overlay=jQuery("#selfhost-podcasting-overlay"),this.importForm=jQuery("#selfhost-podcasting-episodes-import-form"),this.episodesWrap=jQuery("#selfhost-podcasting-podcast-episodes"),this.episodeForm=jQuery("#selfhost-podcasting-episode-form"),this.submitButton=this.episodeForm.find("#selfhost-podcasting-episode-form-submit"),this.podcastId=this.episodeForm.closest("#selfhost-podcasting-podcast-episodes").attr("data-id"),this.requiredFields=s.epReq,this.formErrors=null,this.events()}events(){const e=this,s=this.episodeForm.find(".selfhost-form-field");this.submitButton.on("click",(()=>{e.submitForm()})),this.episodeForm.find(".selfhost-field-audio").on("blur",(s=>{e.validateAudio(s.target)})),this.createButton.on("click",(s=>{e.showCreateNew()})),this.importBtn.on("click",this.openOverlay.bind(this)),this.importForm.find("#selfhost-podcasting-feed-url-close").on("click",this.closeOverlay.bind(this)),this.importForm.find("#selfhost-podcasting-feed-url-submit").on("click",this.showPodcastEpisodes.bind(this)),this.episodesWrap.on("click",".selfhost-podcasting-delete-episode",(s=>{e.deleteEpisode(s.target)})),jQuery(".selfhost-toggle-link").on("click",(e=>{e.preventDefault();const s=jQuery(e.target);s.closest(".selfhost-podcasting-form-field").find(".selfhost-toggle-wrapper").show(),s.closest(".selfhost-date-label").remove()})),this.episodeForm.find(".selfhost-field-upload-to-bucket").on("click",(s=>{s.preventDefault(),e.uploadMediatoBucket(jQuery(this))}));const t=this.importForm.find(".selfhost-podcasting-import-episodes-list");t.on("click",".selfhost-checkbox-select-all",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').prop("checked",!0)})),t.on("click",".selfhost-checkbox-deselect-all",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').prop("checked",!1)})),t.on("click",".selfhost-checkbox-select-inverse",(function(e){e.preventDefault(),t.find('input[type="checkbox"]').each((function(){jQuery(this).prop("checked",!jQuery(this).prop("checked"))}))})),this.importForm.find("#selfhost-podcasting-import-episodes-submit").on("click",this.importSelectedEpisodes.bind(this)),s.each((function(){const s=jQuery(this),t=s.prop("tagName").toLowerCase(),i=s.attr("type");if("select"===t)s.on("change",(s=>e.handleFieldChange(jQuery(s.target))));else if("input"===t||"textarea"===t){if("checkbox"===i||"radio"===i)return;if(s.hasClass("wp-editor-area")){const t=s.attr("id");return s.on("input blur",(function(){e.handleTinyMCEChange(s)})),void("undefined"!=typeof tinymce&&tinymce.get(t)&&!tinymce.get(t).isHidden()&&(tinymce.get(t).off("blur change undo redo SetContent"),tinymce.get(t).on("blur change undo redo SetContent",(function(){e.handleTinyMCEChange(s)}))))}s.on("blur",(t=>e.handleFieldChange(s)))}s.on("change input paste",(()=>{d.isFormDirty=!0}))}))}handleFieldChange(e){const t=this,i=e.val(),o=e.attr("id");if(!o)return;const r=e.closest(".selfhost-podcasting-form-field");r.removeClass("selfhost-input-error").find(".selfhost-error-message").remove();const n=o.replace("selfhost-podcasting-episode-",""),d=n.replace(/[-_]/g," ");if(!this.requiredFields.includes(n)||i)switch(n){case"enclosure-src":t.validateAudio(e);break;case"episode_art-src":t.validateImage(e)}else r.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.epireq+d+"</div>"))}handleTinyMCEChange(e){const t=e.attr("id");if(!t)return;let i="";i="undefined"!=typeof tinymce&&tinymce.get(t)&&!tinymce.get(t).isHidden()?tinymce.get(t).getContent({format:"text"}).trim():e.val().trim();const o=e.closest(".selfhost-podcasting-form-field"),r=t.replace("selfhost-podcasting-episode-",""),n=r.replace(/[-_]/g," ");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),this.requiredFields.includes(r)&&!i&&o.addClass("selfhost-input-error").append('<div class="selfhost-error-message">\n                    '.concat(s.i18n.epireq+n,"\n                </div>"))}getFormValues(){const e=this;if(this.episodeForm.find(".selfhost-input-error").length)return!1;this.formErrors=null;const s=this.episodeForm.find(".selfhost-form-field"),t={};return s.each((function(){const s=jQuery(this),i=s.attr("id"),o=s.attr("data-validation");if(!i)return;const r=i.replace("selfhost-podcasting-episode-","");if("invalid"===o)return void(t[r]=!1);let n=s.val();if(s.hasClass("wp-editor-area")&&"undefined"!=typeof tinymce&&tinymce.get(i)&&!tinymce.get(i).isHidden()&&(n=tinymce.get(i).getContent()),!n&&e.requiredFields.includes(r)){e.formErrors=!0;const t=s.attr("type");if("checkbox"===t||"radio"===t)return;s.hasClass("wp-editor-area")?e.handleTinyMCEChange(s):e.handleFieldChange(s)}s.is(":checkbox")?n=s.is(":checked")?"yes":"":s.is("select")&&(s.attr("multiple")?(n=[],s.find("option:selected").each((function(){n.push(jQuery(this).val())}))):n=s.find("option:selected").val()),t[r]=n})),!this.formErrors&&t}async submitForm(){const e=this.getFormValues();if(!1===e){const e=this.episodeForm.find(".selfhost-input-error");return void(e.length&&jQuery("html, body").animate({scrollTop:e.first().offset().top-100},400))}const t=this.episodeForm.attr("data-episode");if(!this.podcastId)return void d.showFeedback("Podcast ID is missing.","error");if(!e["enclosure-src"])return void d.showFeedback("Episode Audio is required.","error");e.id=this.podcastId;const i={action:"sh_podcasting_create_episode",security:s.security,formData:e,episodeId:t||0};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),(await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this))).success&&(d.showFeedback("Episodes Updated Successfully"),d.isFormDirty=!1),this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden")}async uploadMediatoBucket(e){const t=this.episodeForm.find("#selfhost-podcasting-episode-enclosure-src").val(),i=this.episodeForm.find("#selfhost-podcasting-episode-enclosure-id").val(),o=this.episodeForm.attr("data-episode");if(!this.podcastId)return void d.showFeedback("Podcast ID is missing.","error");if(!t||!o)return void d.showFeedback("Required media or episode information is not available.","error");const r={action:"sh_podcasting_upload_media",security:s.security,podcastId:this.podcastId,mediaUrl:t,mediaId:i,episodeId:o};e.prop("disabled",!0).next(".icon-selfhost-podcasting-spinner").removeClass("hidden"),(await d.sendAjaxRequest(s.ajaxUrl,r,this.handleError.bind(this))).success&&(d.showFeedback("Media Uploaded Successfully"),d.isFormDirty=!1),e.prop("disabled",!1).next(".icon-selfhost-podcasting-spinner").addClass("hidden")}async validateAudio(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeAudioInBrowser(i).then((e=>{const s=t.closest(".selfhost-podcasting-form-field"),i=!!s&&s.next(".selfhost-duration"),o=!!i&&i.find("input");o&&o.val(e.duration)})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.invalid_audio+"</div>")),o.find("#selfhost-podcasting-episode-enclosure-id").val("")}))}async validateImage(e){const t=jQuery(e),i=t.val();if(!i)return;const o=t.closest(".selfhost-podcasting-form-field");o.removeClass("selfhost-input-error").find(".selfhost-error-message").remove(),d.probeImageInBrowser(i).then((e=>{const t=e.width;return t!==e.height?(o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_sq_err+"</div>")),void o.find("#selfhost-podcasting-episode-episode_art-id").val("")):t<1400||t>3e3?(o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.img_min_size+"</div>")),void o.find("#selfhost-podcasting-episode-episode_art-id").val("")):void 0})).catch((e=>{console.log(e),o.addClass("selfhost-input-error").append(jQuery('<div class="selfhost-error-message">'+s.i18n.invalid_image+"</div>")),o.find("#selfhost-podcasting-episode-episode_art-id").val("")}))}async deleteEpisode(e){const t=jQuery(e).closest(".selfhost-table-row"),i=t.closest("#selfhost-podcasting-podcast-episodes"),o=!!t&&t.attr("data-episode"),r=!!i&&i.attr("data-id");if(!o||!r)return;const n={action:"sh_podcasting_delete_episode",security:s.security,id:o,podcastId:r},a=this.episodesWrap.find(".selfhost-podcasting-delete-episode");a.prop("disabled",!0),console.log(a),(await d.sendAjaxRequest(s.ajaxUrl,n,this.handleError.bind(this))).success&&(t.remove(),d.showFeedback("Episode Removed Successfully")),a.prop("disabled",!1)}showCreateNew(){this.episodesWrap.find(".selfhost-podcasting-podcast-form-fields").addClass("hidden"),this.episodeForm.removeClass("hidden"),this.reloadEditors(this.episodeForm)}reloadEditors(e){const s=this;e.hasClass("editor-refreshed")||(e.find("textarea.wp-editor-area").each((function(){const e=this,t=e.id;"undefined"!=typeof tinymce&&(tinymce.get(t)&&tinymce.execCommand("mceRemoveEditor",!0,t),tinymce.execCommand("mceAddEditor",!0,t),tinymce.get(t).on("blur",(function(){s.handleTinyMCEChange(jQuery(e))})))})),e.addClass("editor-refreshed"))}openOverlay(){const e=this.importForm.find("#selfhost-podcasting-feed-url");this.overlay.show(),this.importForm.show(),e.val("").focus()}closeOverlay(){this.importForm.find("#selfhost-podcasting-feed-url").val(""),this.importForm.find(".selfhost-podcasting-error-msg").remove(),this.importForm.find(".selfhost-podcasting-import-episodes-list").empty().addClass("hidden"),this.importForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.importForm.find(".selfhost-podcasting-import-episodes-list").empty().addClass("hidden"),this.importForm.find(".selfhost-podcasting-input-feed-url").removeClass("hidden"),this.importForm.find("#selfhost-podcasting-feed-url-submit").removeClass("hidden"),this.importForm.find("#selfhost-podcasting-import-episodes-submit").addClass("hidden"),this.overlay.hide(),this.importForm.hide()}showPodcastEpisodes(){const e=this.getValidFeedUrl();e&&(this.importForm.find(".dashicons-plus-alt2").addClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),this.fetchPodcastEpisodes(e))}async importSelectedEpisodes(){const e=this.importForm.find(".selfhost-podcasting-import-episodes-list"),t=e.find("ul"),i=t.length?t.attr("data-feed"):"",o=this.overlay.attr("data-id");if(!i)return void d.showFeedback("Feed URL not provided","error");const r=e.find('input[type="checkbox"]:checked').map((function(){return this.id})).get();if(0===r.length)return void d.showFeedback("Select an episode to continue","error");const n={action:"sh_podcasting_import_episodes",security:s.security,feedUrl:i,selectedIds:r,podcastId:o};this.importForm.find(".dashicons-plus-alt2").addClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const a=await d.sendAjaxRequest(s.ajaxUrl,n,this.handleError.bind(this));this.closeOverlay(),a.success&&d.showFeedback("Episodes Imported Successfully","success",1e3,(()=>{window.location.reload()}))}async fetchPodcastEpisodes(e){const t={action:"sh_podcasting_fetch_episodes",security:s.security,feedUrl:e},i=await d.sendAjaxRequest(s.ajaxUrl,t,this.handleError.bind(this));if(i.success){const s=i.data;if(0===s.length)return;const t=s.title,o=s.items,r=Object.keys(o),n='\n            <h2 class="mb-2 font-bold text-lg">'.concat(t,'</h2>\n            <div class="selfhost-checkbox-actions my-2 mb-2 flex items-center">\n                <a class="selfhost-checkbox-select-all mr-2 px-3 py-2 block border focus:shadow-none" href="#">Select All</a>\n                <a class="selfhost-checkbox-deselect-all mr-2 px-3 py-2 block border focus:shadow-none" href="#">Clear Selection</a>\n                <a class="selfhost-checkbox-select-inverse mr-2 px-3 py-2 block border focus:shadow-none" href="#">Inverse Selection</a>\n            </div>\n            <ul class="max-h-[400px] overflow-y-scroll" data-feed="').concat(e,'">').concat(r.map((e=>{const s=o[e];return'<li class="flex items-center border-b flex-wrap" data-guid="'.concat(e,'"><input class="block mr-2" type="checkbox" id="').concat(e,'" /><label class="flex-1 cursor-pointer py-2" for="').concat(e,'">').concat(s,"</label></li>")})).join(""),"</ul>\n            "),a=this.importForm.find(".selfhost-podcasting-import-episodes-list");this.importForm.find(".selfhost-podcasting-input-feed-url").addClass("hidden"),this.importForm.find("#selfhost-podcasting-feed-url-submit").addClass("hidden"),this.importForm.find("#selfhost-podcasting-import-episodes-submit").removeClass("hidden"),a.removeClass("hidden"),a.html(n),d.showFeedback("Episodes Fetched Successfully")}else d.showFeedback("Could not load episodes.","error");this.importForm.find(".dashicons-plus-alt2").removeClass("hidden"),this.importForm.find(".icon-selfhost-podcasting-spinner").addClass("hidden")}getValidFeedUrl(){this.importForm.find(".selfhost-podcasting-error-msg").remove();const e=this.importForm.find("#selfhost-podcasting-feed-url"),t=e.val().trim();if(t){if(d.isValidURL(t))return this.importForm.find(".selfhost-podcasting-error-msg").remove(),t;const i=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(s.i18n.invalid_feed);return e.after(i),!1}{const t=jQuery("<div />").addClass("selfhost-podcasting-error-msg text-red-500").text(s.i18n.feed_required);return e.after(t),!1}}handleError(e){console.log(e)}},h=class{constructor(){this.uploadText=s.i18n,this.fileFrame=wp.media.frames.fileFrame=wp.media({title:this.uploadText.title,button:{text:this.uploadText.btn_text},multiple:!1}),this.clickedUploader=null,this.fileFrame.on("select",(()=>{const e=this.fileFrame.state().get("selection").first().toJSON(),s=this.clickedUploader,t=e.url,i=e.id;s.find(".selfhost-img-id").val(i),s.find(".selfhost-img-src").val(t).focus().trigger("change")})),this.events()}events(){const e=this;jQuery(document).on("click",".selfhost-podcasting-img-uploader",(function(s){s.preventDefault(),e.addImage(jQuery(this))}))}addImage(e){const s=e.prevAll(".selfhost-image-upload");this.clickedUploader=s,this.fileFrame.open()}},p=class{constructor(){this.uploadText=s.i18n,this.fileFrame=wp.media.frames.fileFrame=wp.media({title:this.uploadText.aud_title,button:{text:this.uploadText.btn_text},multiple:!1,library:{type:"audio"}}),this.clickedUploader=null,this.fileFrame.on("select",(()=>{const e=this.fileFrame.state().get("selection").first().toJSON(),s=this.clickedUploader,t=e.url,i=e.id;s.find(".selfhost-audio-id").val(i),s.find(".selfhost-audio-src").val(t).focus().trigger("change")})),this.events()}events(){const e=this;jQuery(document).on("click",".selfhost-podcasting-audio-uploader",(function(s){s.preventDefault(),e.addAudio(jQuery(this))}))}addAudio(e){const s=e.prevAll(".selfhost-audio-upload");this.clickedUploader=s,this.fileFrame.open()}},f=class{constructor(){this.settingForm=jQuery("#selfhost-podcasting-podcast-settings"),this.submitButton=jQuery("#selfhost-podcasting-settings-form-submit"),this.events()}events(){const e=this,s=this.settingForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),s.each((function(){jQuery(this).on("change input paste",(()=>{d.isFormDirty=!0}))}))}getFormValues(){const e=this.settingForm.find(".selfhost-form-field"),s={};return e.each((function(){const e=jQuery(this),t=e.attr("id");if(!t)return;const i=t.replace("selfhost-podcasting-settings-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),s[i]=o})),s}async submitForm(){const e=this.getFormValues(),t=this.settingForm.data("id");if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_save_settings",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Data Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}},u=class{constructor(){this.manageForm=jQuery("#selfhost-podcasting-podcast-manager"),this.submitButton=jQuery("#selfhost-podcasting-manage-form-submit"),this.events()}events(){const e=this,s=this.manageForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){s.preventDefault(),e.submitForm()})),s.each((function(){jQuery(this).on("change input paste",(()=>{d.isFormDirty=!0}))}))}getFormValues(){const e=this.manageForm.find(".selfhost-form-field"),s={};return e.each((function(){const e=jQuery(this),t=e.attr("id");if(!t)return;const i=t.replace("selfhost-podcasting-manage-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),s[i]=o})),s}async submitForm(){const e=this.getFormValues(),t=this.manageForm.data("id");if(!t)return void d.showFeedback("Podcast ID is missing.","error");e.id=t;const i={action:"sh_podcasting_update_options",security:s.security,formData:e};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden");const o=await d.sendAjaxRequest(s.ajaxUrl,i,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),o.success&&(d.showFeedback("Data Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}},m=class{constructor(){this.integrationForm=jQuery("#selfhost-podcasting-podcast-integrations"),this.submitButton=jQuery(".selfhost-integration-submit"),this.events()}events(){const e=this,s=this.integrationForm.find(".selfhost-form-field");this.submitButton.on("click",(function(s){const t=jQuery(this);s.preventDefault(),e.submitForm(t)})),s.each((function(){const e=jQuery(this);e.on("change input paste",(()=>{d.isFormDirty=!0})),e.hasClass("useBucket")&&e.on("change",(()=>{const s=e.is(":checked"),t=e.closest(".selfhost-podcasting-form-field");if(!s)return void t.nextAll(".selfhost-podcasting-form-field").hide();const i=t.next(".selfhost-provider").find(".provider").val();t.nextAll(".selfhost-podcasting-form-field").hide(),t.nextAll(".selfhost-all, .selfhost-"+i).show()})),e.hasClass("provider")&&e.on("change",(()=>{const s=e.closest(".selfhost-podcasting-form-field"),t=e.val();s.nextAll(".selfhost-podcasting-form-field").hide(),s.nextAll(".selfhost-all, .selfhost-"+t).show()}))}))}getFormValues(e){const s=e.find(".selfhost-form-field"),t={};return s.each((function(){const e=jQuery(this),s=e.attr("id");if(!s)return;const i=s.replace("selfhost-podcasting-settings-","");let o=e.val();e.is(":checkbox")?o=e.is(":checked")?"yes":"":e.is("select")&&(e.attr("multiple")?(o=[],e.find("option:selected").each((function(){o.push(jQuery(this).val())}))):o=e.find("option:selected").val()),t[i]=o})),t}async submitForm(e){const t=this.getFormValues(e.closest(".selfhost-podcasting-group-content")),i=e.data("podcast-id"),o=e.data("integration");if(!i)return void d.showFeedback("Podcast ID is missing.","error");if(!o)return void d.showFeedback("Integration is missing.","error");t.id=i;const r={action:"sh_podcasting_update_integration",security:s.security,formData:t,podcastId:i,integration:o};this.submitButton.prop("disabled",!0).find(".icon-selfhost-podcasting-spinner").removeClass("hidden"),this.submitButton.find(".icon-selfhost-podcasting-save").addClass("hidden");const n=await d.sendAjaxRequest(s.ajaxUrl,r,this.handleError.bind(this));this.submitButton.prop("disabled",!1).find(".icon-selfhost-podcasting-spinner").addClass("hidden"),this.submitButton.find(".icon-selfhost-podcasting-save").removeClass("hidden"),n.success&&(d.showFeedback("Integration Updated Successfully."),d.isFormDirty=!1)}handleError(e){console.log(e)}};jQuery((function(e){new a,new c,new l,new h,new p,new f,new u,new m}))})()})();
  • selfhost-podcasting/trunk/admin/js/partials/episode.js

    r3405603 r3437810  
    7272                } else if (field.hasClass('wp-editor-area')) {
    7373                    const id = field.attr('id');
     74                    field.on('input blur', function () {
     75                        _this.handleTinyMCEChange(field);
     76                    });
    7477                    if (typeof tinymce !== 'undefined' && tinymce.get(id) && !tinymce.get(id).isHidden()) {
    75                         tinymce.get(id).on('blur', function() {
     78                        tinymce.get(id).off('blur change undo redo SetContent');
     79                        tinymce.get(id).on('blur change undo redo SetContent', function() {
    7680                            _this.handleTinyMCEChange(field);
    7781                        });
     
    114118        const id = field.attr('id');
    115119        if (!id) return;
    116         const editor = 'undefined' !== typeof tinymce ? tinymce.get(id) : false;
    117         if (!editor) return;
     120
     121        let fieldVal = '';
     122
     123        // Visual mode
     124        if (typeof tinymce !== 'undefined' && tinymce.get(id) && !tinymce.get(id).isHidden()) {
     125            fieldVal = tinymce.get(id).getContent({ format: 'text' }).trim();
     126        }
     127        // Code mode
     128        else {
     129            fieldVal = field.val().trim();
     130        }
     131
    118132        const wrapper = field.closest('.selfhost-podcasting-form-field');
    119         const fieldVal = editor.getContent();
    120133        const name = id.replace('selfhost-podcasting-episode-', '');
    121134        const label = name.replace(/[-_]/g, " ");
    122         wrapper.removeClass('selfhost-input-error').find('.selfhost-error-message').remove();
    123         if (this.requiredFields.includes(name) && ! fieldVal) {
    124             wrapper.addClass('selfhost-input-error').append(jQuery('<div class="selfhost-error-message">' + config.i18n.epireq + label + '</div>'));
     135
     136        wrapper.removeClass('selfhost-input-error')
     137            .find('.selfhost-error-message').remove();
     138
     139        if (this.requiredFields.includes(name) && !fieldVal) {
     140            wrapper.addClass('selfhost-input-error')
     141                .append(`<div class="selfhost-error-message">
     142                    ${config.i18n.epireq + label}
     143                </div>`);
    125144        }
    126145    }
  • selfhost-podcasting/trunk/selfhost-podcasting.php

    r3405603 r3437810  
    1515 * Plugin URI:        https://easypodcastpro.com/selfhost-podcasting
    1616 * Description:       Easily create and manage your podcast.
    17  * Version:           1.1.1
     17 * Version:           1.1.2
    1818 * Author:            vedathemes
    1919 * Author URI:        https://easypodcastpro.com
     
    3030// Currently plugin version.
    3131if ( ! defined( 'SH_PODCASTING_VERSION' ) ) {
    32     define( 'SH_PODCASTING_VERSION', '1.1.1' );
     32    define( 'SH_PODCASTING_VERSION', '1.1.2' );
    3333}
    3434
Note: See TracChangeset for help on using the changeset viewer.