Plugin Directory

Changeset 3462195


Ignore:
Timestamp:
02/16/2026 05:25:04 AM (7 weeks ago)
Author:
vedathemes
Message:

code refactoring and bug fixes

Location:
podcast-player
Files:
188 added
15 edited

Legend:

Unmodified
Added
Removed
  • podcast-player/trunk/README.txt

    r3442200 r3462195  
    55Tested up to: 6.9
    66Requires PHP: 5.6
    7 Stable tag: 7.9.14
     7Stable tag: 8.0.0
    88License: GPLv3 or later
    99License URI: http://www.gnu.org/licenses/gpl-3.0.html
  • podcast-player/trunk/backend/admin/class-options.php

    r3442200 r3462195  
    9090        add_action( 'podcast_player_options_page_content', array( $inst, 'display_content' ) );
    9191        add_action( 'wp_ajax_pp_feed_editor', array( $inst, 'feed_editor_new' ) );
    92         add_action( 'wp_ajax_nopriv_pp_feed_editor', array( $inst, 'feed_editor_new' ) );
     92        // add_action( 'wp_ajax_nopriv_pp_feed_editor', array( $inst, 'feed_editor_new' ) );
    9393        add_action( 'wp_ajax_pp_migrate_podcast', array( $inst, 'migrate_podcast_source' ) );
    9494        add_action( 'wp_ajax_pp_delete_source', array( $inst, 'delete_podcast_source' ) );
     
    191191                ),
    192192                'check_cache_headers' => array(
    193                     'name'        => esc_html__( 'Vertify cache headers for feed update.', 'podcast-player' ),
     193                    'name'        => esc_html__( 'Verify cache headers for feed update.', 'podcast-player' ),
    194194                    'id'          => 'check_cache_headers',
    195195                    'description' => esc_html__( 'We vertify cache headers to quickly check if feed has been updated or not. It is recommended to enable this option. However, if your podcast is not updating, disable this option and check again.', 'podcast-player' ),
     
    584584    public function feed_editor_new() {
    585585        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     586        Utility_Fn::require_capabilities( 'manage_options', 'pp_feed_editor' );
    586587
    587588        $type = isset( $_POST['atype'] ) ? sanitize_text_field( wp_unslash( $_POST['atype'] ) ) : 'refresh';
     
    645646    public function migrate_podcast_source() {
    646647        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     648        Utility_Fn::require_capabilities( 'manage_options', 'pp_migrate_podcast' );
    647649
    648650        $podcast_id = isset( $_POST['podcast_id'] ) ? sanitize_text_field( wp_unslash( $_POST['podcast_id'] ) ) : false;
     
    717719    public function delete_podcast_source() {
    718720        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     721        Utility_Fn::require_capabilities( 'manage_options', 'pp_delete_source' );
    719722
    720723        $podcast_id = isset( $_POST['podcast_id'] ) ? sanitize_text_field( wp_unslash( $_POST['podcast_id'] ) ) : false;
  • podcast-player/trunk/backend/admin/class-shortcodegen.php

    r3339440 r3462195  
    14391439
    14401440    /**
     1441     * Get a unique shortcode instance ID.
     1442     *
     1443     * @since 7.9.1
     1444     *
     1445     * @return int
     1446     */
     1447    public function get_next_instance_id() {
     1448        $shortcode_list = $this->shortcode_settings;
     1449
     1450        if ( empty( $shortcode_list ) || ! is_array( $shortcode_list ) ) {
     1451            return 1;
     1452        }
     1453
     1454        $keys = array_map( 'absint', array_keys( $shortcode_list ) );
     1455        $max  = ! empty( $keys ) ? max( $keys ) : 0;
     1456
     1457        $candidate = $max + 1;
     1458        if ( ! isset( $shortcode_list[ $candidate ] ) ) {
     1459            return $candidate;
     1460        }
     1461
     1462        // Fallback: randomize to avoid collisions in concurrent requests.
     1463        for ( $i = 0; $i < 5; $i++ ) {
     1464            $candidate = wp_rand( 1000, 999999999 );
     1465            if ( ! isset( $shortcode_list[ $candidate ] ) ) {
     1466                return $candidate;
     1467            }
     1468        }
     1469
     1470        // Final fallback: increment until a free ID is found.
     1471        $candidate = $max + 1;
     1472        while ( isset( $shortcode_list[ $candidate ] ) ) {
     1473            $candidate++;
     1474        }
     1475        return $candidate;
     1476    }
     1477
     1478    /**
    14411479     * Save shortcode settings to the database.
    14421480     *
  • podcast-player/trunk/backend/inc/class-background-tasks.php

    r3442200 r3462195  
    7373
    7474        // Process maximum 50 items at a time.
    75         $items     = array_slice( $items, 0, 50 );
    76         $in_clause = implode( ',', array_filter( array_map( function ( $item ) use ( $wpdb ) {
    77             if ( ! empty( $item['featured'] ) ) {
    78                 return $wpdb->prepare( '%s', md5( $item['featured'] ) );
    79             }
    80             return false;
    81         }, $items ) ) );
     75        $items        = array_slice( $items, 0, 50 );
     76        $hashes       = array();
     77        $item_hashes  = array();
     78        foreach ( $items as $key => $item ) {
     79            if ( empty( $item['featured'] ) ) {
     80                continue;
     81            }
     82            $raw_hash = md5( $item['featured'] );
     83            $norm_url = Utility_Fn::normalize_media_url( $item['featured'] );
     84            $norm_hash = md5( $norm_url );
     85
     86            $item_hashes[ $key ] = array(
     87                'raw'  => $raw_hash,
     88                'norm' => $norm_hash,
     89            );
     90            $hashes[] = $raw_hash;
     91            $hashes[] = $norm_hash;
     92        }
     93        $hashes    = array_unique( array_filter( $hashes ) );
     94        $in_clause = implode( ',', array_map( function ( $hash ) use ( $wpdb ) {
     95            return $wpdb->prepare( '%s', $hash );
     96        }, $hashes ) );
    8297
    8398        if ( empty( $in_clause ) ) {
     
    86101        }
    87102
    88         $sql           = "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key = 'pp_featured_key' AND meta_value IN ( $in_clause )";
     103        $sql           = "SELECT post_id, meta_value FROM {$wpdb->postmeta} WHERE meta_key IN ( 'pp_featured_key', 'pp_featured_key_norm' ) AND meta_value IN ( $in_clause )";
    89104        $results       = $wpdb->get_results( $sql, ARRAY_A );
    90105        $featured_keys = array_column( $results, 'post_id', 'meta_value' );
     
    92107        $pending       = array();
    93108        foreach ( $items as $key => $item ) {
    94             $item_image_key = isset( $item['featured'] ) ? md5( $item['featured'] ) : '';
    95             if ( ! empty( $item_image_key ) && isset( $featured_keys[ $item_image_key ] ) ) {
    96                 $completed[ $key ] = array_merge( $item, array( 'post_id' => $featured_keys[ $item_image_key ] ) );
    97                 continue;
    98             }
    99 
    100             $pending[ $key ] = $item;
     109            $hash_pair = isset( $item_hashes[ $key ] ) ? $item_hashes[ $key ] : array();
     110            $raw_hash  = isset( $hash_pair['raw'] ) ? $hash_pair['raw'] : '';
     111            $norm_hash = isset( $hash_pair['norm'] ) ? $hash_pair['norm'] : '';
     112
     113            $matched_post_id = false;
     114            if ( $raw_hash && isset( $featured_keys[ $raw_hash ] ) ) {
     115                $matched_post_id = $featured_keys[ $raw_hash ];
     116            } elseif ( $norm_hash && isset( $featured_keys[ $norm_hash ] ) ) {
     117                $matched_post_id = $featured_keys[ $norm_hash ];
     118            }
     119
     120            if ( $matched_post_id ) {
     121                // Backfill normalized hash for future de-dupes if missing.
     122                if ( $norm_hash ) {
     123                    add_post_meta( $matched_post_id, 'pp_featured_key_norm', $norm_hash, true );
     124                }
     125                $completed[ $key ] = array_merge( $item, array( 'post_id' => $matched_post_id ) );
     126            } else {
     127                $pending[ $key ] = $item;
     128            }
    101129        }
    102130
     
    166194
    167195                    add_post_meta( $attachment_id, 'pp_featured_key', md5( $image_url ), true );
     196                    $normalized_url = Utility_Fn::normalize_media_url( $image_url );
     197                    add_post_meta( $attachment_id, 'pp_featured_key_norm', md5( $normalized_url ), true );
    168198
    169199                    // Let's do post_meta verification to see if data is getting saved correctly.
  • podcast-player/trunk/backend/inc/class-loader.php

    r3418338 r3462195  
    231231        }
    232232
    233         if ( defined( 'PP_PRO_VERSION' ) && version_compare( PP_PRO_VERSION, '5.8.5', '<' ) ) {
     233        if ( defined( 'PP_PRO_VERSION' ) && version_compare( PP_PRO_VERSION, '5.8.6', '<' ) ) {
    234234            ?>
    235235            <div class="notice-warning notice is-dismissible pp-welcome-notice">
    236                 <p><?php esc_html_e( 'There is an update available to Podcast Player Pro. Please update to Podcast Player Pro v5.8.5. If you have not received an automated update notice, please login to our website and download latest version.', 'podcast-player' ); ?></p>
     236                <p><?php esc_html_e( 'There is an update available to Podcast Player Pro. Please update to Podcast Player Pro v5.8.6. If you have not received an automated update notice, please login to our website and download latest version.', 'podcast-player' ); ?></p>
    237237            </div>
    238238            <?php
  • podcast-player/trunk/backend/inc/class-shortcode.php

    r3407648 r3462195  
    1515use Podcast_Player\Helper\Core\Singleton;
    1616use Podcast_Player\Backend\Admin\ShortCodeGen;
     17use Podcast_Player\Helper\Functions\Utility as Utility_Fn;
    1718
    1819/**
     
    232233    public function get_pp_preview() {
    233234        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     235        Utility_Fn::require_capabilities( 'manage_options', 'pp_render_preview' );
    234236        $shortcodegen = new ShortCodeGen();
    235237        $args = isset( $_POST['data'] ) ? $shortcodegen->escape( wp_unslash( $_POST['data'] ) ) : false;
     
    259261    public function get_shortcode_form() {
    260262        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
    261         $shortcodegen = new ShortCodeGen();
    262         $shortcode_list = $shortcodegen->shortcode_settings;
    263         $instance       = empty( $shortcode_list ) || ! is_array( $shortcode_list ) ? 0 : max( array_keys( $shortcode_list ) ) + 1;
     263        Utility_Fn::require_capabilities( 'manage_options', 'pp_blank_shortcode_template' );
     264        $shortcodegen = new ShortCodeGen();
     265        $instance       = $shortcodegen->get_next_instance_id();
    264266        ob_start();
    265267        $shortcodegen->form( $instance );
     
    279281    public function create_new_shortcode() {
    280282        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     283        Utility_Fn::require_capabilities( 'manage_options', 'pp_create_new_shortcode' );
    281284        $shortcodegen = new ShortCodeGen();
    282285        $args = isset( $_POST['data'] ) ? $shortcodegen->sanitize( wp_unslash( $_POST['data'] ) ) : false;
     
    289292        }
    290293        $shortcode_list = $shortcodegen->shortcode_settings;
     294        if ( isset( $shortcode_list[ $inst ] ) ) {
     295            $inst = $shortcodegen->get_next_instance_id();
     296        }
    291297        $shortcode_list[ $inst ] = $args;
    292298        $shortcodegen->shortcode_settings = $shortcode_list;
    293299        $shortcodegen->save();
    294300        echo wp_json_encode( array(
    295             'success' => __( 'Shortcode created successfully.', 'podcast-player' ),
     301            'success'  => __( 'Shortcode created successfully.', 'podcast-player' ),
     302            'instance' => $inst,
    296303        ) );
    297304        wp_die();
     
    305312    public function load_shortcode() {
    306313        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     314        Utility_Fn::require_capabilities( 'manage_options', 'pp_load_shortcode' );
    307315        $instance = isset( $_POST['instance'] ) ? absint( wp_unslash( $_POST['instance'] ) ) : false;
    308316        if ( false === $instance ) {
     
    337345    public function delete_shortcode() {
    338346        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     347        Utility_Fn::require_capabilities( 'manage_options', 'pp_delete_shortcode' );
    339348        $instance = isset( $_POST['instance'] ) ? absint( wp_unslash( $_POST['instance'] ) ) : false;
    340349        if ( false === $instance ) {
     
    364373    public function update_shortcode() {
    365374        check_ajax_referer( 'podcast-player-admin-options-ajax-nonce', 'security' );
     375        Utility_Fn::require_capabilities( 'manage_options', 'pp_update_shortcode' );
    366376        $shortcodegen = new ShortCodeGen();
    367377        $args = isset( $_POST['data'] ) ? $shortcodegen->sanitize( wp_unslash( $_POST['data'] ) ) : false;
  • podcast-player/trunk/backend/js/admin-options.build.js

    r3381875 r3462195  
    1 (()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,n(r.key),r)}}function o(e,o,n){return o&&t(e.prototype,o),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(t){var o=function(t){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(o)?o:o+""}const r=o((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),jQuery("#pp-options-module-help .pp-docs-hide").hide(),jQuery("#pp-options-module-help .pp-docs-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")})),jQuery("#pp-options-module-toolkit .pp-toolkit-content").hide(),jQuery("#pp-options-module-toolkit .pp-toolkit-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")})),jQuery(".pp-hidden-settings").hide(),jQuery(".pp-hidden-settings-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")}))}));function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function p(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=i(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}const a=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.adminPage=jQuery("#pp-options-page"),this.index=jQuery(".select-pp-feed-index").first(),this.refresh=jQuery(".pp-feed-refresh"),this.reset=jQuery(".pp-feed-reset"),this.feedback=jQuery(".pp-toolkit-feedback").first(),this.newFeedback=jQuery("#pp-action-feedback"),this.managePodcastList=this.adminPage.find(".pp-podcasts-list"),this.events()},t=[{key:"events",value:function(){var e=this,t=this;this.refresh.on("click",function(){this.ajaxFeedEditor("refresh")}.bind(this)),this.reset.on("click",function(){this.ajaxFeedEditor("reset")}.bind(this)),jQuery(".pp-feed-del").on("click",(function(){t.index.val()?(jQuery(this).next(".pp-toolkit-del-confirm").slideDown("fast"),t.response()):t.response(t.data.messages.nourl,"pp-error")})),jQuery(".pp-feed-cancel").on("click",(function(){jQuery(this).parents(".pp-toolkit-del-confirm").hide()})),this.managePodcastList.on("click",".pp-podcast-refresh-btn",(function(t){var o=jQuery(t.currentTarget);e.feedRefreshDelete("refresh",o)})),this.managePodcastList.on("click",".pp-podcast-delete-btn",(function(t){var o=jQuery(t.currentTarget);e.feedRefreshDelete("reset",o)})),this.newFeedback.on("click",".pp-error-close",(function(t){e.newFeedback.removeClass("pp-error")}))}},{key:"ajaxFeedEditor",value:function(e){var t=this,o=this.getAjaxConfig(e);this.response(this.data.messages.running,"pp-running"),o?jQuery.ajax({url:this.data.ajaxurl,data:o,type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.response(o.error,"pp-error"):void 0!==o.message&&t.response(o.message,"pp-success"))},error:function(e,o,n){t.response(n,"pp-error")}}):this.response(this.data.messages.nourl,"pp-error")}},{key:"feedRefreshDelete",value:function(e,t){var o=this,n=t.closest(".pp-podcast-list-item"),r=n.data("podcast"),i={action:"pp_feed_editor",security:this.data.security,atype:e,feedUrl:r};t.addClass("pp-wip"),this.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!0),jQuery.ajax({url:this.data.ajaxurl,data:i,type:"POST",timeout:6e4,success:function(r){var i=JSON.parse(r);jQuery.isEmptyObject(i)||(void 0!==i.error?o.newResponse(i.error,"pp-error"):void 0!==i.message&&(o.newResponse(i.message,"pp-success"),"reset"==e&&n.fadeOut(200,(function(){jQuery(this).remove()}))),t.removeClass("pp-wip"),setTimeout((function(){o.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!1)}),1500))},error:function(e,n,r){o.newResponse(r,"pp-error"),t.removeClass("pp-wip"),o.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!1)}})}},{key:"getAjaxConfig",value:function(e){var t=this.index.val();return!!t&&{action:"pp_feed_editor",security:this.data.security,atype:e,feedUrl:t}}},{key:"response",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.feedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.feedback.addClass(t),this.feedback.find(".pp-feedback").text(e))}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running")}.bind(this),1500)}}],t&&s(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function d(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=c(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}const l=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.adminPage=jQuery("#pp-options-page"),this.openSourceUrlBtn=this.adminPage.find(".pp-podcast-source-btn"),this.addSourceUrlBtn=this.adminPage.find(".pp-podcast-new-source-btn"),this.delSourceBtn=this.adminPage.find(".pp-podcast-delete-source-url"),this.newFeedback=jQuery("#pp-action-feedback"),this.events()},t=[{key:"events",value:function(){var e=this;this.openSourceUrlBtn.on("click",(function(e){jQuery(this).closest(".pp-podcast-info").find(".pp-podcast-source-container").slideToggle("fast")})),this.addSourceUrlBtn.on("click",(function(t){var o=jQuery(this),n=o.closest(".pp-podcast-source-container"),r=n.find(".pp-podcast-existing-source"),i=r.find(".pp-podcast-existing-source-url"),s=n.find(".pp-podcast-new-source"),p=s.find(".pp-podcast-new-source-url"),a=p.val();if(a){var c=s.closest(".pp-podcast-list-item").data("podcast"),u={action:"pp_migrate_podcast",security:e.data.security,podcast_id:c,source_url:a};p.attr("disabled",!0),o.attr("disabled",!0),jQuery.ajax({url:e.data.ajaxurl,data:u,type:"POST",timeout:6e4,success:function(t){var n=JSON.parse(t);jQuery.isEmptyObject(n)||(void 0!==n.error?e.newResponse(n.error,"pp-error"):void 0!==n.message&&(i.html(a),r.show(),p.val(""),e.newResponse(n.message,"pp-success"))),p.attr("disabled",!1),o.attr("disabled",!1)},error:function(t,n,r){p.attr("disabled",!1),o.attr("disabled",!1),e.newResponse(r,"pp-error")}})}else e.newResponse(e.data.messages.nosource,"pp-error")})),this.delSourceBtn.on("click",(function(t){t.preventDefault();var o=jQuery(this),n=o.closest(".pp-podcast-existing-source"),r=n.find(".pp-podcast-existing-source-url"),i={action:"pp_delete_source",podcast_id:o.closest(".pp-podcast-list-item").data("podcast"),security:e.data.security};o.attr("disabled",!0),jQuery.ajax({url:e.data.ajaxurl,data:i,type:"POST",timeout:6e4,success:function(t){var i=JSON.parse(t);jQuery.isEmptyObject(i)||(void 0!==i.error?e.newResponse(i.error,"pp-error"):void 0!==i.message&&(r.empty(),n.hide(),e.newResponse(i.message,"pp-success"))),o.attr("disabled",!1)},error:function(t,n,r){o.attr("disabled",!1),e.newResponse(r,"pp-error")}})}))}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running")}.bind(this),1500)}}],t&&u(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function h(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function y(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=f(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}const v=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.newFeedback=jQuery("#pp-action-feedback"),this.serverTimeOut=null,this.events()},t=[{key:"events",value:function(){var e=this,t=jQuery("#pp-options-module-shortcode");jQuery(document),t.on("change",".pp-getval",(function(){clearTimeout(e.serverTimeOut),e.serverTimeOut=setTimeout((function(){e.updatePreview(jQuery(this))}),100)})),t.on("click","#pp-shortcode-generator-btn",(function(){e.blankShortcodeTemplate(jQuery(this))})),t.on("click","#pp-shortcode-generator-submit-btn",(function(){e.createNewShortcode(jQuery(this))})),t.on("click","#pp-shortcode-generator-delete-btn",(function(){t.find("#pp-shortcode-action-modal").removeClass("podcast-player-hidden")})),t.on("click","#pp-shortcode-deletion-btn",(function(){e.deleteShortcode(jQuery(this))})),t.on("click","#pp-shortcode-deletion-cancel",(function(){t.find("#pp-shortcode-action-modal").addClass("podcast-player-hidden")})),t.on("click","#pp-shortcode-generator-update-btn",(function(){e.updateShortcode(jQuery(this))})),t.on("change","select.pp-shortcode-dropdown",(function(){e.loadShortcode(jQuery(this))})),t.on("click",".pp-collapse-sidebar",(function(t){t.preventDefault(),e.toggleSidebar(jQuery(this))})),t.on("click",".pp-copy-shortcode-text",(function(t){t.preventDefault(),e.copyShortcodeText(jQuery(this))}))}},{key:"getShortcodeFormValues",value:function(){var e=jQuery("#pp-shortcode-form"),t=e.find(".pp-getval"),o=e.data("instance"),n={};return t.each((function(){var e=this.name.replace(/^pp_field_name_/,"");e.endsWith("[]")?(e=e.replace(/\[\]$/,""),Array.isArray(n[e])||(n[e]=[]),"checkbox"===this.type?n[e].push(this.checked?this.value:""):n[e].push(this.value)):"checkbox"===this.type?n[e]=this.checked?this.value:"":n[e]=this.value})),console.log(o),{instance:o,values:n}}},{key:"updatePreview",value:function(e){var t=this,o=this,n=this.getShortcodeFormValues(),r=(n.instance,n.values);jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_render_preview",security:this.data.security,data:r},type:"POST",timeout:6e4,success:function(e){var n=JSON.parse(e);jQuery.isEmptyObject(n)||(void 0!==n.error?t.newResponse(n.error,"pp-error"):void 0!==n.markup&&(jQuery("#pp-shortcode-preview").html(n.markup),o.updateFont()))},error:function(e,o,n){t.newResponse(n,"dpt-error")}})}},{key:"blankShortcodeTemplate",value:function(e){var t=this;e.siblings("select.pp-shortcode-dropdown").val(""),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_blank_shortcode_template",security:this.data.security},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);if(!jQuery.isEmptyObject(o))if(void 0!==o.error)t.newResponse(o.error,"dpt-error");else if(void 0!==o.form&&void 0!==o.instance){var n='\n\t\t\t\t\t\t<div class="pp-shortcode-form-wrapper">'.concat(o.form,'</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-submit">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-submit-btn" class="button button-secondary" style="width: 100%;">Generate Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),r=jQuery("#pp-shortcode-form"),i=jQuery("#pp-shortcode-preview");jQuery(".pp-shortcode-result").html(""),r.html(n).data("instance",o.instance),i.html('\n\t\t\t\t\t\t<div style="padding: 20px; font-size: 20px; color: #aaa;">\n\t\t\t\t\t\t\t<span>Shortcode</span>\n\t\t\t\t\t\t\t<span style="color: #333;">Preview</span>\n\t\t\t\t\t\t\t<span> will be displayed here.</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),jQuery(document).trigger("pp-widget-added"),t.newResponse("Shortcode template created successfully","pp-success")}},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"createNewShortcode",value:function(){var e=this,t=this.getShortcodeFormValues(),o=t.instance,n=t.values,r=n.title||"Podcast Player Shortcode "+(o+1);jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_create_new_shortcode",security:this.data.security,data:n,instance:o},type:"POST",timeout:6e4,success:function(t){var n=JSON.parse(t);if(!jQuery.isEmptyObject(n))if(void 0!==n.error)e.newResponse(n.error,"pp-error");else if(void 0!==n.success){var i=jQuery("#pp-options-module-shortcode"),s=i.find(".pp-shortcode-action"),p=i.find("select.pp-shortcode-dropdown");0===p.length&&(s.append('\n\t\t\t\t\t\t\t\t<span class="pp-separator">or</span>\n\t\t\t\t\t\t\t\t<select class="pp-shortcode-dropdown">\n\t\t\t\t\t\t\t\t\t<option value="" selected="selected">Select a Shortcode to Edit</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t'),p=i.find("select.pp-shortcode-dropdown")),p.append('<option value="'.concat(o,'">').concat(r,"</option>")),p.val(o),p.trigger("change"),e.newResponse("New shortcode created successfully","pp-success")}},error:function(t,o,n){e.newResponse(n,"pp-error")}})}},{key:"loadShortcode",value:function(e){var t=this,o=this,n=e.val();if(!n)return jQuery("#pp-shortcode-form").html(""),jQuery("#pp-shortcode-preview").html('\n\t\t\t\t<div style="padding: 20px; font-size: 20px; color: #aaa;">\n\t\t\t\t\t<span>Create a </span>\n\t\t\t\t\t<span style="color: #333;">New Shortcode</span>\n\t\t\t\t\t<span> or </span>\n\t\t\t\t\t<span style="color: #333;">Edit an Existing</span>\n\t\t\t\t\t<span> Shortcode using the menu above.</span>\n\t\t\t\t</div>\n\t\t\t'),void jQuery(".pp-shortcode-result").html("");jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_load_shortcode",security:this.data.security,instance:n},type:"POST",timeout:6e4,success:function(e){var n=JSON.parse(e);if(!jQuery.isEmptyObject(n))if(void 0!==n.error)t.newResponse(n.error,"pp-error");else if(void 0!==n.form&&void 0!==n.preview){var r='\n\t\t\t\t\t\t<div class="pp-shortcode-form-wrapper">'.concat(n.form,'</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-update pp-button-wrapper">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-update-btn" class="button button-secondary" style="width: 100%;">Update Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-delete pp-button-wrapper">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-delete-btn" class="button button-secondary" style="width: 100%;">Delete Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),i="\n\t\t\t\t\t\t".concat(n.preview,"\n\t\t\t\t\t\t"),s=jQuery(".pp-shortcode-result"),p=jQuery("#pp-shortcode-form"),a=jQuery("#pp-shortcode-preview");p.html(r).data("instance",n.instance),a.html(i),s.html('\n\t\t\t\t\t\t\t<div class="pp-shortcode-sidebar-collapse">\n\t\t\t\t\t\t\t\t<a href="#" class="pp-collapse-sidebar">\n\t\t\t\t\t\t\t\t\t<span class="dashicons dashicons-arrow-left-alt2"></span>\n\t\t\t\t\t\t\t\t\t<span class="pp-collapse-side">Collapse</span>\n\t\t\t\t\t\t\t\t\t<span class="pp-expand-side" style="display: none;">Expand</span>\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class="pp-shortcode-copy">\n\t\t\t\t\t\t\t\t<span>Your shortcode is </span>\n\t\t\t\t\t\t\t\t<pre class="pp-shortcode-text"><code>[showpodcastplayer instance="'.concat(n.instance,'"]</code></pre>\n\t\t\t\t\t\t\t\t<a href="#" class="pp-copy-shortcode-text">(Copy shortcode)</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t')),o.updateFont(),jQuery(document).trigger("pp-widget-added")}},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"updateFont",value:function(){var e=jQuery("#pp-options-module-shortcode .podcast-player-pp-fonts");if(e.length){var t=e.val(),o=this.data.gfonts,n=!(!t||!o[t])&&o[t];if(n){var r=n.split(" ").join("+");if(0===jQuery("link#podcast-player-fonts-css-temp").length){var i=jQuery("<link>",{id:"podcast-player-fonts-css-temp",href:"//fonts.googleapis.com/css?family="+r,rel:"stylesheet",type:"text/css"});jQuery("link:last").after(i)}else{var s=jQuery("link#podcast-player-fonts-css-temp"),p=s.attr("href");s.attr("href",p+"%7C"+r)}}}}},{key:"deleteShortcode",value:function(e){var t=this,o=jQuery("#pp-options-module-shortcode"),n=o.find("#pp-shortcode-form").data("instance"),r=o.find("select.pp-shortcode-dropdown");o.find("#pp-shortcode-action-modal").addClass("podcast-player-hidden"),void 0!==n&&(o.find(".pp-shortcode-result").html(""),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_delete_shortcode",security:this.data.security,instance:n},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.newResponse(o.error,"pp-error"):void 0!==o.success&&(r.val(""),r.find('option[value="'.concat(n,'"]')).remove(),0===r.find("option").length?r.remove():r.trigger("change"),t.newResponse("Shortcode deleted successfully","pp-success",!0)))},error:function(e,o,n){t.newResponse(n,"pp-error")}}))}},{key:"updateShortcode",value:function(e){var t=this,o=this.getShortcodeFormValues(),n=o.instance,r=o.values;r.title&&jQuery(".pp-shortcode-dropdown option:selected").text(r.title),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_update_shortcode",security:this.data.security,data:r,instance:n},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.newResponse(o.error,"pp-error"):void 0!==o.success&&t.newResponse("Shortcode updated successfully","pp-success"))},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running"),o&&window.location.reload()}.bind(this),1e3)}},{key:"toggleSidebar",value:function(e){jQuery("#pp-shortcode-form").toggleClass("pp-sidebar-close"),e.toggleClass("pp-sidebar-close"),window.dispatchEvent(new Event("resize"))}},{key:"copyShortcodeText",value:function(e){var t=e.closest(".pp-shortcode-copy").find(".pp-shortcode-text code").text(),o=jQuery("<textarea>");jQuery("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove(),this.newResponse("Shortcode copied to clipboard","pp-success")}}],t&&h(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function g(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function b(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=m(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}const j=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this;jQuery((function(){e.colorPicker()})),jQuery(document).on("pp-widget-added",(function(){e.colorPicker()}))}},{key:"colorPicker",value:function(){var e={change:function(e,t){jQuery(e.target).val(t.color.toString()),jQuery(e.target).trigger("change")}},t=jQuery(".pp-color-picker").not('[id*="__i__"]');t.wpColorPicker(e),t.each((function(){var e=jQuery(this);e.closest(".wp-picker-container").find(".wp-picker-clear").on("click",(function(){e.val("").trigger("change")}))}))}}],t&&g(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function w(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_(n.key),n)}}function _(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=k(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}var x=function(){return e=function e(t,o,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.adminData=window.ppjsAdmin||{},this.wrapper=t,this.fetchMethod=o,this.isReset=n,this.adminData.ispremium&&this.runFetchAction()},(t=[{key:"runFetchAction",value:function(){var e=this.getAjaxData();!1===e?this.runFalseAction():(this.hideLists(),this.makeAjaxRequest(e))}},{key:"runFalseAction",value:function(e){this.hideLists(),e&&console.log(e)}},{key:"hideLists",value:function(){this.wrapper.find(".pp-episodes-list").hide(),"feed"===this.fetchMethod&&this.isReset&&(this.wrapper.find(".pp-categories-list").hide(),this.wrapper.find(".pp-seasons-list").hide())}},{key:"getAjaxData",value:function(){return"feed"===this.fetchMethod?this.getFeedAjaxData():"post"===this.fetchMethod?this.getPostAjaxData():void 0}},{key:"getFeedAjaxData",value:function(){var e=this.wrapper.find(".feed_url input").val();if(!(e="string"==typeof e&&e.trim()))return!1;var t=this.adminData.security,o=this.isReset?"true":"false",n=this.wrapper.find('.pp_slist-checklist input[type="checkbox"]:checked'),r=this.wrapper.find('.pp_catlist-checklist input[type="checkbox"]:checked'),i=[],s=[];return this.isReset||(jQuery.each(n,(function(){i.push(jQuery(this).val())})),jQuery.each(r,(function(){s.push(jQuery(this).val())}))),{action:"pp_feed_data_list",security:t,getAll:o,feedUrl:e,seasons:i,categories:s}}},{key:"getPostAjaxData",value:function(){var e=this.adminData.security,t=this.wrapper.find("select.podcast-player-pp-post-type").val(),o=this.wrapper.find("select.podcast-player-pp-taxonomy").val(),n=this.wrapper.find("select.podcast-player-sortby").val(),r=this.wrapper.find(".filterby input").val(),i=this.wrapper.find('.pp_terms-checklist input[type="checkbox"]:checked'),s=[];return jQuery.each(i,(function(){s.push(jQuery(this).val())})),{action:"pp_post_episodes_list",security:e,postType:t,taxonomy:o,sortby:n,filterby:r,terms:s}}},{key:"makeAjaxRequest",value:function(e){var t=this,o=this.adminData.ajaxurl;jQuery.ajax({url:o,data:e,type:"POST",timeout:1e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)?t.runFalseAction("PP Error: Empty object received"):o.items?t.createMarkup(o):o.error&&t.runFalseAction(o.error)},error:function(e,o,n){t.runFalseAction(n)}})}},{key:"createMarkup",value:function(e){e.items&&(this.template("episode","elist",e.items),this.wrapper.find(".pp-episodes-list").show()),e.seasons&&(this.template("season","slist",e.seasons),this.wrapper.find(".pp-seasons-list").show()),e.categories&&(this.template("cat","catlist",e.categories),this.wrapper.find(".pp-categories-list").show())}},{key:"template",value:function(e,t,o){this.wrapper.find(".d-".concat(e,' input[type="checkbox"]')).prop("checked",!0);var n=this.wrapper.find(".pp_".concat(t,"-checklist ul")),r=n.find("li.d-".concat(e)).clone();n.empty().append(r.clone()),r.removeClass("d-".concat(e)).addClass("pp-".concat(e,"s")),r.find('input[type="checkbox"]').prop("checked",!1).attr("disabled",!0),jQuery.each(o,(function(e,t){var o=r.clone();o.find('input[type="checkbox"]').val(e),o.find(".cblabel").html(t),n.append(o)}))}}])&&w(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const Q=x,S={ajaxtimeout:null};function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function O(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,T(n.key),n)}}function T(e){var t=function(e){if("object"!=P(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=P(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}var C=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this;jQuery("#pp-options-module-shortcode").on("change",".podcast-player-pp-fetch-method",(function(){e.changeFetchMethod(jQuery(this))}))}},{key:"changeFetchMethod",value:function(e){var t=e.closest(".pp-shortcode-form, .pp-shortcode-form"),o=e.val(),n=t.find(".podcast-player-pp-aspect-ratio"),r=["lv1","gv1",""],i=""===t.find(".podcast-player-pp-teaser-text").val(),s=["lv1","lv2","gv1","gv2"],p=t.find("select.podcast-player-pp-display-style").val(),a=[".feed_url",".pp_hide_content",".pp_slist",".pp_catlist",".pp-feedback-toggle"],c=[".pp_post_type",".pp_taxonomy",".pp_podtitle"],u=[".pp_audiosrc",".pp_audiotitle",".pp_audiolink",".pp_ahide_download",".pp_ahide_social",".pp-lshow-toggle",".pp-linfo-toggle"],d=[".pp_elist",".pp-filter-toggle",".pp-show-toggle",".pp_txtcolor",".number.pp-widget-option",".offset.pp-widget-option",".pp_grid_columns",".pp_crop_method",".pp_aspect_ratio"];t.find("select.podcast-player-pp-taxonomy").val(""),t.find(".toggle-active").removeClass("toggle-active"),t.find([".pp_settings-content",".pp_terms"].join(",")).hide(),"feed"===o?(t.find(a.join(",")).show(),t.find(c.join(",")).hide(),t.find(u.join(",")).hide(),t.find(d.join(",")).show()):"post"===o?(t.find(a.join(",")).hide(),t.find(c.join(",")).show(),t.find(u.join(",")).hide(),t.find(d.join(",")).show()):"link"===o&&(t.find(a.join(",")).hide(),t.find(c.join(",")).hide(),t.find(u.join(",")).show(),t.find(d.join(",")).hide()),"feed"!==o&&"post"!==o||(clearTimeout(S.ajaxtimeout),S.ajaxtimeout=setTimeout((function(){new Q(t,o,!0)}),500)),"feed"===o||"post"===o?(t.find(".pp_teaser_text").toggle(r.includes(p)),t.find(".pp_excerpt_length").toggle(r.includes(p)&&i),t.find(".pp_excerpt_unit").toggle(r.includes(p)&&i),t.find(".pp_txtcolor").toggle(["lv1","lv2","lv3","gv1"].includes(p)),t.find(".pp_grid_columns").toggle(["gv1","gv2"].includes(p)),t.find(".pp_crop_method").toggle(s.includes(p)&&!!n.val()),t.find(".pp_aspect_ratio").toggle(s.includes(p))):t.find(".pp_teaser_text, .pp_excerpt_length, .pp_excerpt_unit").hide()}}],t&&O(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const F=C;function R(e){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},R(e)}function E(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,A(n.key),n)}}function A(e){var t=function(e){if("object"!=R(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=R(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==R(t)?t:t+""}var D=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this,t=jQuery("#pp-options-module-shortcode");jQuery(document),t.on("change",".podcast-player-pp-post-type",(function(){e.postType(jQuery(this))})),t.on("change",".podcast-player-pp-taxonomy",(function(){e.taxonomy(jQuery(this))})),t.on("change",".podcast-player-pp-furl-select",(function(){var e=jQuery(this),t=e.val();e.siblings(".pp_feed-url").val(t).trigger("change").trigger("input")})),t.on("input",".feed_url input",(function(){e.feedUrl(jQuery(this))})),t.on("change",".podcast-player-pp-display-style",(function(){e.displayStyle(jQuery(this))})),t.on("change",".podcast-player-pp-aspect-ratio",(function(){e.aspectRatio(jQuery(this))})),t.on("change",".podcast-player-pp-start-when",(function(){e.startWhen(jQuery(this))})),t.on("change",'.d-episode input[type="checkbox"]',(function(){var t=jQuery(this),o=t.closest(".pp_elist").next(".pp_edisplay");e.filterCheckboxes(t,"episode"),t.is(":checked")?o.hide():o.show()})),t.on("change",'.d-season input[type="checkbox"]',(function(){e.filterCheckboxes(jQuery(this),"season")})),t.on("change",'.d-cat input[type="checkbox"]',(function(){e.filterCheckboxes(jQuery(this),"cat")})),t.on("change",'.pp_hide_header input[type="checkbox"]',(function(){e.hideHeader(jQuery(this))})),t.on("change",'.pp_terms-checklist input[type="checkbox"], .filterby input',(function(){e.postFetch(jQuery(this))})),t.on("change",'.pp_slist-checklist input[type="checkbox"], .pp_catlist-checklist input[type="checkbox"]',(function(){e.feedFetch(jQuery(this),!1)})),t.on("change","select.podcast-player-podcast-menu",(function(){e.toggleMenuItems(jQuery(this))})),t.on("change",'.main_menu_items input[type="number"]',(function(){e.toggleDepricatedSub(jQuery(this))})),t.on("change",".podcast-player-pp-teaser-text",(function(){e.toggleExcerptOptions(jQuery(this))})),t.on("change",'.pp_collect_feedback input[type="checkbox"]',(function(){e.toggleFeedbackOptions(jQuery(this))}))}},{key:"widgetAdded",value:function(e){if(e.hasClass("pp-filter-toggle")){var t=e.next(".pp_settings-content");t.find('.d-episode input[type="checkbox"]').is(":checked")&&t.find('.pp-episodes input[type="checkbox"]').attr("disabled",!0),t.find('.d-cat input[type="checkbox"]').is(":checked")&&t.find('.pp-cats input[type="checkbox"]').attr("disabled",!0),t.find('.d-season input[type="checkbox"]').is(":checked")&&t.find('.pp-seasons input[type="checkbox"]').attr("disabled",!0)}}},{key:"settingsToggle",value:function(e){e.next(".pp_settings-content").slideToggle("fast"),e.toggleClass("toggle-active")}},{key:"postType",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form").find(".podcast-player-pp-taxonomy");o.find("option").hide(),o.find(".always-visible, ."+t).show(),o.val(""),this.postFetch(e)}},{key:"taxonomy",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form").find(".pp_terms");o.find(".pp_terms-checklist input:checkbox").removeAttr("checked"),o.hide(),t&&(o.find(".pp_terms-checklist li").hide(),o.find(".pp_terms-checklist ."+t).show(),o.show()),this.postFetch(e)}},{key:"feedUrl",value:function(e){this.resetAutoFilters(),e.val()&&this.feedFetch(e,!0)}},{key:"aspectRatio",value:function(e){e.val()?e.closest(".pp-shortcode-form").find(".pp_crop_method").show():e.closest(".pp-shortcode-form").find(".pp_crop_method").hide()}},{key:"toggleExcerptOptions",value:function(e){e.val()?e.closest(".pp-shortcode-form").find(".pp_excerpt_length, .pp_excerpt_unit").hide():e.closest(".pp-shortcode-form").find(".pp_excerpt_length, .pp_excerpt_unit").show()}},{key:"startWhen",value:function(e){var t=e.val();t&&"custom"===t?e.closest(".pp-shortcode-form").find(".pp_start_time").show():e.closest(".pp-shortcode-form").find(".pp_start_time").hide()}},{key:"resetAutoFilters",value:function(){this.filterCheckboxes(jQuery('.d-episode input[type="checkbox"]'),"episode"),this.filterCheckboxes(jQuery('.d-season input[type="checkbox"]'),"season"),this.filterCheckboxes(jQuery('.d-cat input[type="checkbox"]'),"cat")}},{key:"filterCheckboxes",value:function(e,t){var o=e.closest(".pp-shortcode-form"),n=".pp-".concat(t,"s");e.is(":checked")?o.find(n+' input[type="checkbox"]').attr("disabled",!0).prop("checked",!1):o.find(n+' input[type="checkbox"]').attr("disabled",!1)}},{key:"hideHeader",value:function(e){var t=e.closest(".pp-shortcode-form");e.is(":checked")?t.find(".pp_hide_cover, .pp_hide_title, .pp_hide_description, .pp_hide_subscribe").hide():t.find(".pp_hide_cover, .pp_hide_title, .pp_hide_description, .pp_hide_subscribe").show()}},{key:"displayStyle",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form"),n=o.find(".podcast-player-pp-aspect-ratio"),r=["lv1","gv1",""],i=["lv1","lv2","gv1","gv2"],s=""===o.find(".podcast-player-pp-teaser-text").val();o.find(".pp_no_scroll").toggle(!t||"modern"===t),o.find(".pp_header_default").toggle(!t||"legacy"===t||"modern"===t),o.find(".pp_list_default").toggle(!t||"legacy"===t||"modern"===t),o.find(".pp_teaser_text").toggle(r.includes(t)),o.find(".pp_excerpt_length").toggle(r.includes(t)&&s),o.find(".pp_excerpt_unit").toggle(r.includes(t)&&s),o.find(".pp_grid_columns").toggle(["gv1","gv2"].includes(t)),o.find(".pp_txtcolor").toggle(["lv1","lv2","lv3","gv1"].includes(t)),o.find(".pp_crop_method").toggle(i.includes(t)&&!!n.val()),o.find(".pp_aspect_ratio").toggle(i.includes(t))}},{key:"postFetch",value:function(e){this.fetch(e.closest(".pp-shortcode-form"),"post")}},{key:"feedFetch",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.fetch(e.closest(".pp-shortcode-form"),"feed",t)}},{key:"fetch",value:function(e,t){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];"feed"!==t&&"post"!==t||(clearTimeout(S.ajaxtimeout),S.ajaxtimeout=setTimeout((function(){new Q(e,t,o)}),500))}},{key:"toggleMenuItems",value:function(e){var t=e.val(),o=e.closest(".podcast_menu").next(".main_menu_items");t||o.hide()}},{key:"toggleDepricatedSub",value:function(e){var t=e.val(),o=e.closest(".main_menu_items").siblings(".pp_apple_sub, .pp_google_sub, .pp_spotify_sub");t>0?o.hide():o.show()}},{key:"toggleFeedbackOptions",value:function(e){var t=e.closest(".pp-shortcode-form");e.is(":checked")?t.find(".pp_show_form_time, .pp_feedback_text, .pp_positive_text, .pp_positive_url, .pp_negative_text, .pp_negative_form").show():t.find(".pp_show_form_time, .pp_feedback_text, .pp_positive_text, .pp_positive_url, .pp_negative_text, .pp_negative_form").hide()}}],t&&E(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const N=D;new r,new a,new l,new v,jQuery((function(){new j,new F,new N}))})();
     1(()=>{"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(e,t){for(var o=0;o<t.length;o++){var r=t[o];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,n(r.key),r)}}function o(e,o,n){return o&&t(e.prototype,o),n&&t(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function n(t){var o=function(t){if("object"!=e(t)||!t)return t;var o=t[Symbol.toPrimitive];if(void 0!==o){var n=o.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(o)?o:o+""}const r=o((function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),jQuery("#pp-options-module-help .pp-docs-hide").hide(),jQuery("#pp-options-module-help .pp-docs-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")})),jQuery("#pp-options-module-toolkit .pp-toolkit-content").hide(),jQuery("#pp-options-module-toolkit .pp-toolkit-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")})),jQuery(".pp-hidden-settings").hide(),jQuery(".pp-hidden-settings-title").on("click",(function(){jQuery(this).toggleClass("pp-toggle"),jQuery(this).next().slideToggle("fast")}))}));function i(e){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i(e)}function s(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,p(n.key),n)}}function p(e){var t=function(e){if("object"!=i(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=i(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==i(t)?t:t+""}const a=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.adminPage=jQuery("#pp-options-page"),this.index=jQuery(".select-pp-feed-index").first(),this.refresh=jQuery(".pp-feed-refresh"),this.reset=jQuery(".pp-feed-reset"),this.feedback=jQuery(".pp-toolkit-feedback").first(),this.newFeedback=jQuery("#pp-action-feedback"),this.managePodcastList=this.adminPage.find(".pp-podcasts-list"),this.events()},t=[{key:"events",value:function(){var e=this,t=this;this.refresh.on("click",function(){this.ajaxFeedEditor("refresh")}.bind(this)),this.reset.on("click",function(){this.ajaxFeedEditor("reset")}.bind(this)),jQuery(".pp-feed-del").on("click",(function(){t.index.val()?(jQuery(this).next(".pp-toolkit-del-confirm").slideDown("fast"),t.response()):t.response(t.data.messages.nourl,"pp-error")})),jQuery(".pp-feed-cancel").on("click",(function(){jQuery(this).parents(".pp-toolkit-del-confirm").hide()})),this.managePodcastList.on("click",".pp-podcast-refresh-btn",(function(t){var o=jQuery(t.currentTarget);e.feedRefreshDelete("refresh",o)})),this.managePodcastList.on("click",".pp-podcast-delete-btn",(function(t){var o=jQuery(t.currentTarget);e.feedRefreshDelete("reset",o)})),this.newFeedback.on("click",".pp-error-close",(function(t){e.newFeedback.removeClass("pp-error")}))}},{key:"ajaxFeedEditor",value:function(e){var t=this,o=this.getAjaxConfig(e);this.response(this.data.messages.running,"pp-running"),o?jQuery.ajax({url:this.data.ajaxurl,data:o,type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.response(o.error,"pp-error"):void 0!==o.message&&t.response(o.message,"pp-success"))},error:function(e,o,n){t.response(n,"pp-error")}}):this.response(this.data.messages.nourl,"pp-error")}},{key:"feedRefreshDelete",value:function(e,t){var o=this,n=t.closest(".pp-podcast-list-item"),r=n.data("podcast"),i={action:"pp_feed_editor",security:this.data.security,atype:e,feedUrl:r};t.addClass("pp-wip"),this.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!0),jQuery.ajax({url:this.data.ajaxurl,data:i,type:"POST",timeout:6e4,success:function(r){var i=JSON.parse(r);jQuery.isEmptyObject(i)||(void 0!==i.error?o.newResponse(i.error,"pp-error"):void 0!==i.message&&(o.newResponse(i.message,"pp-success"),"reset"==e&&n.fadeOut(200,(function(){jQuery(this).remove()}))),t.removeClass("pp-wip"),setTimeout((function(){o.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!1)}),1500))},error:function(e,n,r){o.newResponse(r,"pp-error"),t.removeClass("pp-wip"),o.managePodcastList.find(".pp-toolkit-buttons").prop("disabled",!1)}})}},{key:"getAjaxConfig",value:function(e){var t=this.index.val();return!!t&&{action:"pp_feed_editor",security:this.data.security,atype:e,feedUrl:t}}},{key:"response",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.feedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.feedback.addClass(t),this.feedback.find(".pp-feedback").text(e))}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running")}.bind(this),1500)}}],t&&s(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function d(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=c(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}const l=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.adminPage=jQuery("#pp-options-page"),this.openSourceUrlBtn=this.adminPage.find(".pp-podcast-source-btn"),this.addSourceUrlBtn=this.adminPage.find(".pp-podcast-new-source-btn"),this.delSourceBtn=this.adminPage.find(".pp-podcast-delete-source-url"),this.newFeedback=jQuery("#pp-action-feedback"),this.events()},t=[{key:"events",value:function(){var e=this;this.openSourceUrlBtn.on("click",(function(e){jQuery(this).closest(".pp-podcast-info").find(".pp-podcast-source-container").slideToggle("fast")})),this.addSourceUrlBtn.on("click",(function(t){var o=jQuery(this),n=o.closest(".pp-podcast-source-container"),r=n.find(".pp-podcast-existing-source"),i=r.find(".pp-podcast-existing-source-url"),s=n.find(".pp-podcast-new-source"),p=s.find(".pp-podcast-new-source-url"),a=p.val();if(a){var c=s.closest(".pp-podcast-list-item").data("podcast"),u={action:"pp_migrate_podcast",security:e.data.security,podcast_id:c,source_url:a};p.attr("disabled",!0),o.attr("disabled",!0),jQuery.ajax({url:e.data.ajaxurl,data:u,type:"POST",timeout:6e4,success:function(t){var n=JSON.parse(t);jQuery.isEmptyObject(n)||(void 0!==n.error?e.newResponse(n.error,"pp-error"):void 0!==n.message&&(i.html(a),r.show(),p.val(""),e.newResponse(n.message,"pp-success"))),p.attr("disabled",!1),o.attr("disabled",!1)},error:function(t,n,r){p.attr("disabled",!1),o.attr("disabled",!1),e.newResponse(r,"pp-error")}})}else e.newResponse(e.data.messages.nosource,"pp-error")})),this.delSourceBtn.on("click",(function(t){t.preventDefault();var o=jQuery(this),n=o.closest(".pp-podcast-existing-source"),r=n.find(".pp-podcast-existing-source-url"),i={action:"pp_delete_source",podcast_id:o.closest(".pp-podcast-list-item").data("podcast"),security:e.data.security};o.attr("disabled",!0),jQuery.ajax({url:e.data.ajaxurl,data:i,type:"POST",timeout:6e4,success:function(t){var i=JSON.parse(t);jQuery.isEmptyObject(i)||(void 0!==i.error?e.newResponse(i.error,"pp-error"):void 0!==i.message&&(r.empty(),n.hide(),e.newResponse(i.message,"pp-success"))),o.attr("disabled",!1)},error:function(t,n,r){o.attr("disabled",!1),e.newResponse(r,"pp-error")}})}))}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running")}.bind(this),1500)}}],t&&u(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function h(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,y(n.key),n)}}function y(e){var t=function(e){if("object"!=f(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=f(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==f(t)?t:t+""}const v=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.data=window.ppjsAdminOpt||{},this.newFeedback=jQuery("#pp-action-feedback"),this.serverTimeOut=null,this.events()},t=[{key:"events",value:function(){var e=this,t=jQuery("#pp-options-module-shortcode");jQuery(document),t.on("change",".pp-getval",(function(){clearTimeout(e.serverTimeOut),e.serverTimeOut=setTimeout((function(){e.updatePreview(jQuery(this))}),100)})),t.on("click","#pp-shortcode-generator-btn",(function(){e.blankShortcodeTemplate(jQuery(this))})),t.on("click","#pp-shortcode-generator-submit-btn",(function(){e.createNewShortcode(jQuery(this))})),t.on("click","#pp-shortcode-generator-delete-btn",(function(){t.find("#pp-shortcode-action-modal").removeClass("podcast-player-hidden")})),t.on("click","#pp-shortcode-deletion-btn",(function(){e.deleteShortcode(jQuery(this))})),t.on("click","#pp-shortcode-deletion-cancel",(function(){t.find("#pp-shortcode-action-modal").addClass("podcast-player-hidden")})),t.on("click","#pp-shortcode-generator-update-btn",(function(){e.updateShortcode(jQuery(this))})),t.on("change","select.pp-shortcode-dropdown",(function(){e.loadShortcode(jQuery(this))})),t.on("click",".pp-collapse-sidebar",(function(t){t.preventDefault(),e.toggleSidebar(jQuery(this))})),t.on("click",".pp-copy-shortcode-text",(function(t){t.preventDefault(),e.copyShortcodeText(jQuery(this))}))}},{key:"getShortcodeFormValues",value:function(){var e=jQuery("#pp-shortcode-form"),t=e.find(".pp-getval"),o=e.data("instance"),n={};return t.each((function(){var e=this.name.replace(/^pp_field_name_/,"");e.endsWith("[]")?(e=e.replace(/\[\]$/,""),Array.isArray(n[e])||(n[e]=[]),"checkbox"===this.type?n[e].push(this.checked?this.value:""):n[e].push(this.value)):"checkbox"===this.type?n[e]=this.checked?this.value:"":n[e]=this.value})),{instance:o,values:n}}},{key:"updatePreview",value:function(e){var t=this,o=this,n=this.getShortcodeFormValues(),r=(n.instance,n.values);jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_render_preview",security:this.data.security,data:r},type:"POST",timeout:6e4,success:function(e){var n=JSON.parse(e);jQuery.isEmptyObject(n)||(void 0!==n.error?t.newResponse(n.error,"pp-error"):void 0!==n.markup&&(jQuery("#pp-shortcode-preview").html(n.markup),o.updateFont()))},error:function(e,o,n){t.newResponse(n,"dpt-error")}})}},{key:"blankShortcodeTemplate",value:function(e){var t=this;e.siblings("select.pp-shortcode-dropdown").val(""),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_blank_shortcode_template",security:this.data.security},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);if(!jQuery.isEmptyObject(o))if(void 0!==o.error)t.newResponse(o.error,"dpt-error");else if(void 0!==o.form&&void 0!==o.instance){var n='\n\t\t\t\t\t\t<div class="pp-shortcode-form-wrapper">'.concat(o.form,'</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-submit">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-submit-btn" class="button button-secondary" style="width: 100%;">Generate Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),r=jQuery("#pp-shortcode-form"),i=jQuery("#pp-shortcode-preview");jQuery(".pp-shortcode-result").html(""),r.html(n).attr("data-instance",o.instance),i.html('\n\t\t\t\t\t\t<div style="padding: 20px; font-size: 20px; color: #aaa;">\n\t\t\t\t\t\t\t<span>Shortcode</span>\n\t\t\t\t\t\t\t<span style="color: #333;">Preview</span>\n\t\t\t\t\t\t\t<span> will be displayed here.</span>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),jQuery(document).trigger("pp-widget-added"),t.newResponse("Shortcode template created successfully","pp-success")}},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"createNewShortcode",value:function(){var e=this,t=this.getShortcodeFormValues(),o=t.instance,n=t.values;jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_create_new_shortcode",security:this.data.security,data:n,instance:o},type:"POST",timeout:6e4,success:function(t){var r=JSON.parse(t);if(!jQuery.isEmptyObject(r))if(void 0!==r.error)e.newResponse(r.error,"pp-error");else if(void 0!==r.success){var i=void 0!==r.instance?r.instance:o,s=n.title||"Podcast Player Shortcode "+i,p=jQuery("#pp-options-module-shortcode"),a=p.find(".pp-shortcode-action"),c=p.find("select.pp-shortcode-dropdown");0===c.length&&(a.append('\n\t\t\t\t\t\t\t\t<span class="pp-separator">or</span>\n\t\t\t\t\t\t\t\t<select class="pp-shortcode-dropdown">\n\t\t\t\t\t\t\t\t\t<option value="" selected="selected">Select a Shortcode to Edit</option>\n\t\t\t\t\t\t\t\t</select>\n\t\t\t\t\t\t\t'),c=p.find("select.pp-shortcode-dropdown")),c.append('<option value="'.concat(i,'">').concat(s,"</option>")),c.val(i),c.trigger("change"),e.newResponse("New shortcode created successfully","pp-success")}},error:function(t,o,n){e.newResponse(n,"pp-error")}})}},{key:"loadShortcode",value:function(e){var t=this,o=this,n=e.val();if(!n)return jQuery("#pp-shortcode-form").html(""),jQuery("#pp-shortcode-preview").html('\n\t\t\t\t<div style="padding: 20px; font-size: 20px; color: #aaa;">\n\t\t\t\t\t<span>Create a </span>\n\t\t\t\t\t<span style="color: #333;">New Shortcode</span>\n\t\t\t\t\t<span> or </span>\n\t\t\t\t\t<span style="color: #333;">Edit an Existing</span>\n\t\t\t\t\t<span> Shortcode using the menu above.</span>\n\t\t\t\t</div>\n\t\t\t'),void jQuery(".pp-shortcode-result").html("");jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_load_shortcode",security:this.data.security,instance:n},type:"POST",timeout:6e4,success:function(e){var n=JSON.parse(e);if(!jQuery.isEmptyObject(n))if(void 0!==n.error)t.newResponse(n.error,"pp-error");else if(void 0!==n.form&&void 0!==n.preview){var r='\n\t\t\t\t\t\t<div class="pp-shortcode-form-wrapper">'.concat(n.form,'</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-update pp-button-wrapper">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-update-btn" class="button button-secondary" style="width: 100%;">Update Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class="pp-shortcode-form-delete pp-button-wrapper">\n\t\t\t\t\t\t\t<button id="pp-shortcode-generator-delete-btn" class="button button-secondary" style="width: 100%;">Delete Shortcode</button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t'),i="\n\t\t\t\t\t\t".concat(n.preview,"\n\t\t\t\t\t\t"),s=jQuery(".pp-shortcode-result"),p=jQuery("#pp-shortcode-form"),a=jQuery("#pp-shortcode-preview");p.html(r).data("instance",n.instance),a.html(i),s.html('\n\t\t\t\t\t\t\t<div class="pp-shortcode-sidebar-collapse">\n\t\t\t\t\t\t\t\t<a href="#" class="pp-collapse-sidebar">\n\t\t\t\t\t\t\t\t\t<span class="dashicons dashicons-arrow-left-alt2"></span>\n\t\t\t\t\t\t\t\t\t<span class="pp-collapse-side">Collapse</span>\n\t\t\t\t\t\t\t\t\t<span class="pp-expand-side" style="display: none;">Expand</span>\n\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t<div class="pp-shortcode-copy">\n\t\t\t\t\t\t\t\t<span>Your shortcode is </span>\n\t\t\t\t\t\t\t\t<pre class="pp-shortcode-text"><code>[showpodcastplayer instance="'.concat(n.instance,'"]</code></pre>\n\t\t\t\t\t\t\t\t<a href="#" class="pp-copy-shortcode-text">(Copy shortcode)</a>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t')),o.updateFont(),jQuery(document).trigger("pp-widget-added")}},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"updateFont",value:function(){var e=jQuery("#pp-options-module-shortcode .podcast-player-pp-fonts");if(e.length){var t=e.val(),o=this.data.gfonts,n=!(!t||!o[t])&&o[t];if(n){var r=n.split(" ").join("+");if(0===jQuery("link#podcast-player-fonts-css-temp").length){var i=jQuery("<link>",{id:"podcast-player-fonts-css-temp",href:"//fonts.googleapis.com/css?family="+r,rel:"stylesheet",type:"text/css"});jQuery("link:last").after(i)}else{var s=jQuery("link#podcast-player-fonts-css-temp"),p=s.attr("href");s.attr("href",p+"%7C"+r)}}}}},{key:"deleteShortcode",value:function(e){var t=this,o=jQuery("#pp-options-module-shortcode"),n=o.find("#pp-shortcode-form").data("instance"),r=o.find("select.pp-shortcode-dropdown");o.find("#pp-shortcode-action-modal").addClass("podcast-player-hidden"),void 0!==n&&(o.find(".pp-shortcode-result").html(""),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_delete_shortcode",security:this.data.security,instance:n},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.newResponse(o.error,"pp-error"):void 0!==o.success&&(r.val(""),r.find('option[value="'.concat(n,'"]')).remove(),0===r.find("option").length?r.remove():r.trigger("change"),t.newResponse("Shortcode deleted successfully","pp-success",!0)))},error:function(e,o,n){t.newResponse(n,"pp-error")}}))}},{key:"updateShortcode",value:function(e){var t=this,o=this.getShortcodeFormValues(),n=o.instance,r=o.values;r.title&&jQuery(".pp-shortcode-dropdown option:selected").text(r.title),jQuery.ajax({url:this.data.ajaxurl,data:{action:"pp_update_shortcode",security:this.data.security,data:r,instance:n},type:"POST",timeout:6e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)||(void 0!==o.error?t.newResponse(o.error,"pp-error"):void 0!==o.success&&t.newResponse("Shortcode updated successfully","pp-success"))},error:function(e,o,n){t.newResponse(n,"pp-error")}})}},{key:"newResponse",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=arguments.length>2&&void 0!==arguments[2]&&arguments[2];this.newFeedback.removeClass("pp-error pp-success pp-running"),!1!==t&&(this.newFeedback.addClass(t),this.newFeedback.find(".pp-feedback").text(e)),setTimeout(function(){this.newFeedback.removeClass("pp-success pp-running"),o&&window.location.reload()}.bind(this),1e3)}},{key:"toggleSidebar",value:function(e){jQuery("#pp-shortcode-form").toggleClass("pp-sidebar-close"),e.toggleClass("pp-sidebar-close"),window.dispatchEvent(new Event("resize"))}},{key:"copyShortcodeText",value:function(e){var t=e.closest(".pp-shortcode-copy").find(".pp-shortcode-text code").text(),o=jQuery("<textarea>");jQuery("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove(),this.newResponse("Shortcode copied to clipboard","pp-success")}}],t&&h(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}function g(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,b(n.key),n)}}function b(e){var t=function(e){if("object"!=m(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=m(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==m(t)?t:t+""}const j=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this;jQuery((function(){e.colorPicker()})),jQuery(document).on("pp-widget-added",(function(){e.colorPicker()}))}},{key:"colorPicker",value:function(){var e={change:function(e,t){jQuery(e.target).val(t.color.toString()),jQuery(e.target).trigger("change")}},t=jQuery(".pp-color-picker").not('[id*="__i__"]');t.wpColorPicker(e),t.each((function(){var e=jQuery(this);e.closest(".wp-picker-container").find(".wp-picker-clear").on("click",(function(){e.val("").trigger("change")}))}))}}],t&&g(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();function k(e){return k="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},k(e)}function w(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,_(n.key),n)}}function _(e){var t=function(e){if("object"!=k(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=k(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==k(t)?t:t+""}var x=function(){return e=function e(t,o,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.adminData=window.ppjsAdmin||{},this.wrapper=t,this.fetchMethod=o,this.isReset=n,this.adminData.ispremium&&this.runFetchAction()},(t=[{key:"runFetchAction",value:function(){var e=this.getAjaxData();!1===e?this.runFalseAction():(this.hideLists(),this.makeAjaxRequest(e))}},{key:"runFalseAction",value:function(e){this.hideLists(),e&&console.log(e)}},{key:"hideLists",value:function(){this.wrapper.find(".pp-episodes-list").hide(),"feed"===this.fetchMethod&&this.isReset&&(this.wrapper.find(".pp-categories-list").hide(),this.wrapper.find(".pp-seasons-list").hide())}},{key:"getAjaxData",value:function(){return"feed"===this.fetchMethod?this.getFeedAjaxData():"post"===this.fetchMethod?this.getPostAjaxData():void 0}},{key:"getFeedAjaxData",value:function(){var e=this.wrapper.find(".feed_url input").val();if(!(e="string"==typeof e&&e.trim()))return!1;var t=this.adminData.security,o=this.isReset?"true":"false",n=this.wrapper.find('.pp_slist-checklist input[type="checkbox"]:checked'),r=this.wrapper.find('.pp_catlist-checklist input[type="checkbox"]:checked'),i=[],s=[];return this.isReset||(jQuery.each(n,(function(){i.push(jQuery(this).val())})),jQuery.each(r,(function(){s.push(jQuery(this).val())}))),{action:"pp_feed_data_list",security:t,getAll:o,feedUrl:e,seasons:i,categories:s}}},{key:"getPostAjaxData",value:function(){var e=this.adminData.security,t=this.wrapper.find("select.podcast-player-pp-post-type").val(),o=this.wrapper.find("select.podcast-player-pp-taxonomy").val(),n=this.wrapper.find("select.podcast-player-sortby").val(),r=this.wrapper.find(".filterby input").val(),i=this.wrapper.find('.pp_terms-checklist input[type="checkbox"]:checked'),s=[];return jQuery.each(i,(function(){s.push(jQuery(this).val())})),{action:"pp_post_episodes_list",security:e,postType:t,taxonomy:o,sortby:n,filterby:r,terms:s}}},{key:"makeAjaxRequest",value:function(e){var t=this,o=this.adminData.ajaxurl;jQuery.ajax({url:o,data:e,type:"POST",timeout:1e4,success:function(e){var o=JSON.parse(e);jQuery.isEmptyObject(o)?t.runFalseAction("PP Error: Empty object received"):o.items?t.createMarkup(o):o.error&&t.runFalseAction(o.error)},error:function(e,o,n){t.runFalseAction(n)}})}},{key:"createMarkup",value:function(e){e.items&&(this.template("episode","elist",e.items),this.wrapper.find(".pp-episodes-list").show()),e.seasons&&(this.template("season","slist",e.seasons),this.wrapper.find(".pp-seasons-list").show()),e.categories&&(this.template("cat","catlist",e.categories),this.wrapper.find(".pp-categories-list").show())}},{key:"template",value:function(e,t,o){this.wrapper.find(".d-".concat(e,' input[type="checkbox"]')).prop("checked",!0);var n=this.wrapper.find(".pp_".concat(t,"-checklist ul")),r=n.find("li.d-".concat(e)).clone();n.empty().append(r.clone()),r.removeClass("d-".concat(e)).addClass("pp-".concat(e,"s")),r.find('input[type="checkbox"]').prop("checked",!1).attr("disabled",!0),jQuery.each(o,(function(e,t){var o=r.clone();o.find('input[type="checkbox"]').val(e),o.find(".cblabel").html(t),n.append(o)}))}}])&&w(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const Q=x,S={ajaxtimeout:null};function P(e){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},P(e)}function O(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,T(n.key),n)}}function T(e){var t=function(e){if("object"!=P(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=P(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==P(t)?t:t+""}var C=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this;jQuery("#pp-options-module-shortcode").on("change",".podcast-player-pp-fetch-method",(function(){e.changeFetchMethod(jQuery(this))}))}},{key:"changeFetchMethod",value:function(e){var t=e.closest(".pp-shortcode-form, .pp-shortcode-form"),o=e.val(),n=t.find(".podcast-player-pp-aspect-ratio"),r=["lv1","gv1",""],i=""===t.find(".podcast-player-pp-teaser-text").val(),s=["lv1","lv2","gv1","gv2"],p=t.find("select.podcast-player-pp-display-style").val(),a=[".feed_url",".pp_hide_content",".pp_slist",".pp_catlist",".pp-feedback-toggle"],c=[".pp_post_type",".pp_taxonomy",".pp_podtitle"],u=[".pp_audiosrc",".pp_audiotitle",".pp_audiolink",".pp_ahide_download",".pp_ahide_social",".pp-lshow-toggle",".pp-linfo-toggle"],d=[".pp_elist",".pp-filter-toggle",".pp-show-toggle",".pp_txtcolor",".number.pp-widget-option",".offset.pp-widget-option",".pp_grid_columns",".pp_crop_method",".pp_aspect_ratio"];t.find("select.podcast-player-pp-taxonomy").val(""),t.find(".toggle-active").removeClass("toggle-active"),t.find([".pp_settings-content",".pp_terms"].join(",")).hide(),"feed"===o?(t.find(a.join(",")).show(),t.find(c.join(",")).hide(),t.find(u.join(",")).hide(),t.find(d.join(",")).show()):"post"===o?(t.find(a.join(",")).hide(),t.find(c.join(",")).show(),t.find(u.join(",")).hide(),t.find(d.join(",")).show()):"link"===o&&(t.find(a.join(",")).hide(),t.find(c.join(",")).hide(),t.find(u.join(",")).show(),t.find(d.join(",")).hide()),"feed"!==o&&"post"!==o||(clearTimeout(S.ajaxtimeout),S.ajaxtimeout=setTimeout((function(){new Q(t,o,!0)}),500)),"feed"===o||"post"===o?(t.find(".pp_teaser_text").toggle(r.includes(p)),t.find(".pp_excerpt_length").toggle(r.includes(p)&&i),t.find(".pp_excerpt_unit").toggle(r.includes(p)&&i),t.find(".pp_txtcolor").toggle(["lv1","lv2","lv3","gv1"].includes(p)),t.find(".pp_grid_columns").toggle(["gv1","gv2"].includes(p)),t.find(".pp_crop_method").toggle(s.includes(p)&&!!n.val()),t.find(".pp_aspect_ratio").toggle(s.includes(p))):t.find(".pp_teaser_text, .pp_excerpt_length, .pp_excerpt_unit").hide()}}],t&&O(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const F=C;function R(e){return R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},R(e)}function E(e,t){for(var o=0;o<t.length;o++){var n=t[o];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,A(n.key),n)}}function A(e){var t=function(e){if("object"!=R(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var o=t.call(e,"string");if("object"!=R(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==R(t)?t:t+""}var D=function(){return e=function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.events()},t=[{key:"events",value:function(){var e=this,t=jQuery("#pp-options-module-shortcode");jQuery(document),t.on("change",".podcast-player-pp-post-type",(function(){e.postType(jQuery(this))})),t.on("change",".podcast-player-pp-taxonomy",(function(){e.taxonomy(jQuery(this))})),t.on("change",".podcast-player-pp-furl-select",(function(){var e=jQuery(this),t=e.val();e.siblings(".pp_feed-url").val(t).trigger("change").trigger("input")})),t.on("input",".feed_url input",(function(){e.feedUrl(jQuery(this))})),t.on("change",".podcast-player-pp-display-style",(function(){e.displayStyle(jQuery(this))})),t.on("change",".podcast-player-pp-aspect-ratio",(function(){e.aspectRatio(jQuery(this))})),t.on("change",".podcast-player-pp-start-when",(function(){e.startWhen(jQuery(this))})),t.on("change",'.d-episode input[type="checkbox"]',(function(){var t=jQuery(this),o=t.closest(".pp_elist").next(".pp_edisplay");e.filterCheckboxes(t,"episode"),t.is(":checked")?o.hide():o.show()})),t.on("change",'.d-season input[type="checkbox"]',(function(){e.filterCheckboxes(jQuery(this),"season")})),t.on("change",'.d-cat input[type="checkbox"]',(function(){e.filterCheckboxes(jQuery(this),"cat")})),t.on("change",'.pp_hide_header input[type="checkbox"]',(function(){e.hideHeader(jQuery(this))})),t.on("change",'.pp_terms-checklist input[type="checkbox"], .filterby input',(function(){e.postFetch(jQuery(this))})),t.on("change",'.pp_slist-checklist input[type="checkbox"], .pp_catlist-checklist input[type="checkbox"]',(function(){e.feedFetch(jQuery(this),!1)})),t.on("change","select.podcast-player-podcast-menu",(function(){e.toggleMenuItems(jQuery(this))})),t.on("change",'.main_menu_items input[type="number"]',(function(){e.toggleDepricatedSub(jQuery(this))})),t.on("change",".podcast-player-pp-teaser-text",(function(){e.toggleExcerptOptions(jQuery(this))})),t.on("change",'.pp_collect_feedback input[type="checkbox"]',(function(){e.toggleFeedbackOptions(jQuery(this))}))}},{key:"widgetAdded",value:function(e){if(e.hasClass("pp-filter-toggle")){var t=e.next(".pp_settings-content");t.find('.d-episode input[type="checkbox"]').is(":checked")&&t.find('.pp-episodes input[type="checkbox"]').attr("disabled",!0),t.find('.d-cat input[type="checkbox"]').is(":checked")&&t.find('.pp-cats input[type="checkbox"]').attr("disabled",!0),t.find('.d-season input[type="checkbox"]').is(":checked")&&t.find('.pp-seasons input[type="checkbox"]').attr("disabled",!0)}}},{key:"settingsToggle",value:function(e){e.next(".pp_settings-content").slideToggle("fast"),e.toggleClass("toggle-active")}},{key:"postType",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form").find(".podcast-player-pp-taxonomy");o.find("option").hide(),o.find(".always-visible, ."+t).show(),o.val(""),this.postFetch(e)}},{key:"taxonomy",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form").find(".pp_terms");o.find(".pp_terms-checklist input:checkbox").removeAttr("checked"),o.hide(),t&&(o.find(".pp_terms-checklist li").hide(),o.find(".pp_terms-checklist ."+t).show(),o.show()),this.postFetch(e)}},{key:"feedUrl",value:function(e){this.resetAutoFilters(),e.val()&&this.feedFetch(e,!0)}},{key:"aspectRatio",value:function(e){e.val()?e.closest(".pp-shortcode-form").find(".pp_crop_method").show():e.closest(".pp-shortcode-form").find(".pp_crop_method").hide()}},{key:"toggleExcerptOptions",value:function(e){e.val()?e.closest(".pp-shortcode-form").find(".pp_excerpt_length, .pp_excerpt_unit").hide():e.closest(".pp-shortcode-form").find(".pp_excerpt_length, .pp_excerpt_unit").show()}},{key:"startWhen",value:function(e){var t=e.val();t&&"custom"===t?e.closest(".pp-shortcode-form").find(".pp_start_time").show():e.closest(".pp-shortcode-form").find(".pp_start_time").hide()}},{key:"resetAutoFilters",value:function(){this.filterCheckboxes(jQuery('.d-episode input[type="checkbox"]'),"episode"),this.filterCheckboxes(jQuery('.d-season input[type="checkbox"]'),"season"),this.filterCheckboxes(jQuery('.d-cat input[type="checkbox"]'),"cat")}},{key:"filterCheckboxes",value:function(e,t){var o=e.closest(".pp-shortcode-form"),n=".pp-".concat(t,"s");e.is(":checked")?o.find(n+' input[type="checkbox"]').attr("disabled",!0).prop("checked",!1):o.find(n+' input[type="checkbox"]').attr("disabled",!1)}},{key:"hideHeader",value:function(e){var t=e.closest(".pp-shortcode-form");e.is(":checked")?t.find(".pp_hide_cover, .pp_hide_title, .pp_hide_description, .pp_hide_subscribe").hide():t.find(".pp_hide_cover, .pp_hide_title, .pp_hide_description, .pp_hide_subscribe").show()}},{key:"displayStyle",value:function(e){var t=e.val(),o=e.closest(".pp-shortcode-form"),n=o.find(".podcast-player-pp-aspect-ratio"),r=["lv1","gv1",""],i=["lv1","lv2","gv1","gv2"],s=""===o.find(".podcast-player-pp-teaser-text").val();o.find(".pp_no_scroll").toggle(!t||"modern"===t),o.find(".pp_header_default").toggle(!t||"legacy"===t||"modern"===t),o.find(".pp_list_default").toggle(!t||"legacy"===t||"modern"===t),o.find(".pp_teaser_text").toggle(r.includes(t)),o.find(".pp_excerpt_length").toggle(r.includes(t)&&s),o.find(".pp_excerpt_unit").toggle(r.includes(t)&&s),o.find(".pp_grid_columns").toggle(["gv1","gv2"].includes(t)),o.find(".pp_txtcolor").toggle(["lv1","lv2","lv3","gv1"].includes(t)),o.find(".pp_crop_method").toggle(i.includes(t)&&!!n.val()),o.find(".pp_aspect_ratio").toggle(i.includes(t))}},{key:"postFetch",value:function(e){this.fetch(e.closest(".pp-shortcode-form"),"post")}},{key:"feedFetch",value:function(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.fetch(e.closest(".pp-shortcode-form"),"feed",t)}},{key:"fetch",value:function(e,t){var o=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];"feed"!==t&&"post"!==t||(clearTimeout(S.ajaxtimeout),S.ajaxtimeout=setTimeout((function(){new Q(e,t,o)}),500))}},{key:"toggleMenuItems",value:function(e){var t=e.val(),o=e.closest(".podcast_menu").next(".main_menu_items");t||o.hide()}},{key:"toggleDepricatedSub",value:function(e){var t=e.val(),o=e.closest(".main_menu_items").siblings(".pp_apple_sub, .pp_google_sub, .pp_spotify_sub");t>0?o.hide():o.show()}},{key:"toggleFeedbackOptions",value:function(e){var t=e.closest(".pp-shortcode-form");e.is(":checked")?t.find(".pp_show_form_time, .pp_feedback_text, .pp_positive_text, .pp_positive_url, .pp_negative_text, .pp_negative_form").show():t.find(".pp_show_form_time, .pp_feedback_text, .pp_positive_text, .pp_positive_url, .pp_negative_text, .pp_negative_form").hide()}}],t&&E(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const N=D;new r,new a,new l,new v,jQuery((function(){new j,new F,new N}))})();
  • podcast-player/trunk/backend/js/partials/options/shortgen.js

    r3381875 r3462195  
    9797            }
    9898        );
    99         console.log(instance);
    10099        return { instance, values };
    101100    }
     
    167166                        const previewWrapper = jQuery('#pp-shortcode-preview');
    168167                        jQuery('.pp-shortcode-result').html( '' );
    169                         formWrapper.html( form ).data('instance', details.instance);
     168                        formWrapper.html( form ).attr('data-instance', details.instance);
    170169                        previewWrapper.html( preview );
    171170                        jQuery(document).trigger('pp-widget-added');
     
    182181    createNewShortcode() {
    183182        const { instance, values } = this.getShortcodeFormValues();
    184         const title = values.title || 'Podcast Player Shortcode' + ' ' + (instance + 1);
    185183        // Let's get next set of episodes.
    186184        jQuery.ajax( {
     
    200198                        this.newResponse(details.error, 'pp-error');
    201199                    } else if ('undefined' !== typeof details.success) {
     200                        const savedInstance = 'undefined' !== typeof details.instance ? details.instance : instance;
     201                        const title = values.title || 'Podcast Player Shortcode' + ' ' + savedInstance;
    202202                        const widget   = jQuery('#pp-options-module-shortcode');
    203203                        const wrapper  = widget.find('.pp-shortcode-action');
     
    212212                            dropdown = widget.find('select.pp-shortcode-dropdown');
    213213                        }
    214                         dropdown.append(`<option value="${instance}">${title}</option>`);
    215                         dropdown.val(instance);
     214                        dropdown.append(`<option value="${savedInstance}">${title}</option>`);
     215                        dropdown.val(savedInstance);
    216216                        dropdown.trigger('change');
    217217                        this.newResponse('New shortcode created successfully', 'pp-success');
  • podcast-player/trunk/frontend/class-register.php

    r3442200 r3462195  
    107107     */
    108108    public static function load_resources( $instance ) {
     109        // Register and conditionally enqueue styles in head when detectable.
     110        add_action( 'wp_enqueue_scripts', array( $instance, 'register_styles' ), 1 );
     111        add_action( 'wp_enqueue_scripts', array( $instance, 'maybe_enqueue_styles_early' ), 20 );
    109112
    110113        // The script must be loaded before mediaelement-migrate script.
  • podcast-player/trunk/frontend/inc/class-loader.php

    r3245675 r3462195  
    150150
    151151    /**
    152      * Enqueue podcast player front-end styles and scripts in footer.
    153      *
    154      * @since 1.0.0
    155      */
    156     public function enqueue_resources() {
    157 
    158         // Return if podcast player is not available on the page.
    159         if ( ! $this->has_podcast_player() ) {
    160             return;
    161         }
    162 
    163         // Enqueue podcast player styles.
    164         $this->enqueue_styles();
    165 
    166         // Load mm error fix script if not already loaded.
    167         if ( ! wp_script_is( 'podcast-player-mmerrorfix' ) && $this->has_mediaelement() ) {
    168             $this->enqueue_mm_error_fix( true );
    169             $this->move_mm_errorfix_to_top();
    170         }
    171 
    172         // Enqueue podcast player scripts.
    173         $this->enqueue_scripts();
    174     }
    175 
    176     /**
    177      * Enqueue front-end styles and scripts in elementor preview screen.
    178      *
    179      * @since 1.0.0
    180      */
    181     public function enqueue_elementor_resources() {
    182 
    183         // TODO: This is mostly the same function as the enqueue_resources() function. Refactor and unify.
    184         // Enqueue podcast player styles.
    185         $this->enqueue_styles();
    186 
    187         // Load mm error fix script if not already loaded.
    188         if ( ! wp_script_is( 'podcast-player-mmerrorfix' ) && $this->has_mediaelement() ) {
    189             $this->enqueue_mm_error_fix( true );
    190             $this->move_mm_errorfix_to_top();
    191         }
    192 
    193         // Enqueue podcast player scripts.
    194         $this->enqueue_scripts();
    195     }
    196 
    197     /**
    198      * Register the stylesheets for the public-facing side of the site.
    199      *
    200      * @since    1.0.0
    201      */
    202     public function enqueue_styles() {
    203         wp_enqueue_style(
     152     * Register podcast player front-end stylesheet.
     153     *
     154     * @since 8.0.0
     155     */
     156    public function register_styles() {
     157        wp_register_style(
    204158            'pppublic',
    205159            PODCAST_PLAYER_URL . 'frontend/css/podcast-player-public.css',
     
    209163        );
    210164        wp_style_add_data( 'pppublic', 'rtl', 'replace' );
     165    }
     166
     167    /**
     168     * Attempt to enqueue podcast player styles in head.
     169     *
     170     * @since 8.0.0
     171     */
     172    public function maybe_enqueue_styles_early() {
     173        if ( ! $this->should_enqueue_styles_early() ) {
     174            return;
     175        }
     176
     177        $this->enqueue_styles();
     178    }
     179
     180    /**
     181     * Check whether podcast player styles can be enqueued early.
     182     *
     183     * @since 8.0.0
     184     *
     185     * @return bool
     186     */
     187    private function should_enqueue_styles_early() {
     188
     189        // Never run this in admin pages.
     190        if ( is_admin() ) {
     191            return false;
     192        }
     193
     194        // Respect existing customizer/Ajax conditions.
     195        if ( $this->has_podcast_player() ) {
     196            return true;
     197        }
     198
     199        // Check known frontend render markers in singular content.
     200        if ( is_singular() ) {
     201            $post = get_queried_object();
     202            if ( $post instanceof \WP_Post && $this->has_podcast_markup( $post->post_content ) ) {
     203                return true;
     204            }
     205        }
     206
     207        return false;
     208    }
     209
     210    /**
     211     * Check if content includes known podcast player markers.
     212     *
     213     * @since 8.0.0
     214     *
     215     * @param string $content Post content.
     216     * @return bool
     217     */
     218    private function has_podcast_markup( $content ) {
     219        if ( ! is_string( $content ) || '' === $content ) {
     220            return false;
     221        }
     222
     223        // Podcast player shortcodes.
     224        if ( has_shortcode( $content, 'podcastplayer' ) || has_shortcode( $content, 'showpodcastplayer' ) ) {
     225            return true;
     226        }
     227
     228        // Podcast player dynamic block.
     229        if ( function_exists( 'has_block' ) && has_block( 'podcast-player/podcast-player', $content ) ) {
     230            return true;
     231        }
     232
     233        return false;
     234    }
     235
     236    /**
     237     * Enqueue podcast player front-end styles and scripts in footer.
     238     *
     239     * @since 1.0.0
     240     */
     241    public function enqueue_resources() {
     242
     243        // Return if podcast player is not available on the page.
     244        if ( ! $this->has_podcast_player() ) {
     245            return;
     246        }
     247
     248        // Enqueue podcast player styles.
     249        $this->enqueue_styles();
     250
     251        // Load mm error fix script if not already loaded.
     252        if ( ! wp_script_is( 'podcast-player-mmerrorfix' ) && $this->has_mediaelement() ) {
     253            $this->enqueue_mm_error_fix( true );
     254            $this->move_mm_errorfix_to_top();
     255        }
     256
     257        // Enqueue podcast player scripts.
     258        $this->enqueue_scripts();
     259    }
     260
     261    /**
     262     * Enqueue front-end styles and scripts in elementor preview screen.
     263     *
     264     * @since 1.0.0
     265     */
     266    public function enqueue_elementor_resources() {
     267
     268        // TODO: This is mostly the same function as the enqueue_resources() function. Refactor and unify.
     269        // Enqueue podcast player styles.
     270        $this->enqueue_styles();
     271
     272        // Load mm error fix script if not already loaded.
     273        if ( ! wp_script_is( 'podcast-player-mmerrorfix' ) && $this->has_mediaelement() ) {
     274            $this->enqueue_mm_error_fix( true );
     275            $this->move_mm_errorfix_to_top();
     276        }
     277
     278        // Enqueue podcast player scripts.
     279        $this->enqueue_scripts();
     280    }
     281
     282    /**
     283     * Register the stylesheets for the public-facing side of the site.
     284     *
     285     * @since    1.0.0
     286     */
     287    public function enqueue_styles() {
     288        if ( ! wp_style_is( 'pppublic', 'registered' ) ) {
     289            $this->register_styles();
     290        }
     291        wp_enqueue_style( 'pppublic' );
    211292    }
    212293
  • podcast-player/trunk/helper/core/class-background-jobs.php

    r3442200 r3462195  
    6363        $identifier = wp_http_validate_url( $identifier ) ? md5( $identifier ) : $identifier;
    6464        $unique_id  = substr( md5( $identifier . $task_type ), 0, 12 );
     65        $lock_token = $instance->acquire_queue_lock();
    6566        $queue      = $instance->get_tasks_queue( false );
    6667
     
    6970            $queue = array_slice( $queue, 0, 50 );
    7071            $instance->set_tasks_queue( $queue );
     72            $instance->release_queue_lock( $lock_token );
    7173            return $instance;
    7274        }
     
    8587            $instance->set_tasks_queue( $queue );
    8688        }
     89        $instance->release_queue_lock( $lock_token );
    8790        return $instance;
    8891    }
     
    9497     */
    9598    public function dispatch() {
     99        return $this->dispatch_internal( false );
     100    }
     101
     102    /**
     103     * Dispatch an async request to start processing the queue.
     104     *
     105     * @since 7.9.15
     106     *
     107     * @param bool $force Skip recent dispatch throttle.
     108     */
     109    private function dispatch_internal( $force = false ) {
    96110        $instance = self::get_instance();
    97         if ( $this->is_processing() || $this->is_queue_empty() || $this->recently_dispatched() ) {
     111        if ( $force && $this->force_dispatch_throttled() ) {
    98112            return;
    99113        }
     114        if ( $this->is_processing() || $this->is_queue_empty() || ( ! $force && $this->recently_dispatched() ) ) {
     115            return;
     116        }
    100117
    101118        $this->set_recent_dispatch();
     119        if ( $force ) {
     120            $this->set_force_dispatch();
     121        }
    102122
    103123        $url  = add_query_arg( $instance->get_query_args(), $instance->get_query_url() );
     
    113133    private function set_recent_dispatch() {
    114134        set_transient( $this->identifier . '_recent_dispatch', 1, 60 ); // 60 seconds
     135    }
     136
     137    private function force_dispatch_throttled() {
     138        return get_transient( $this->identifier . '_force_dispatch' );
     139    }
     140
     141    private function set_force_dispatch() {
     142        $interval = apply_filters( $this->identifier . '_force_dispatch_interval', 30 );
     143        set_transient( $this->identifier . '_force_dispatch', 1, $interval );
    115144    }
    116145
     
    236265        sleep( 5 );
    237266        $this->unlock_process();
     267
     268        // If import tasks are pending and current task didn't error, re-dispatch to prioritize completion.
     269        if ( ! $error && $this->has_pending_type( 'import_episodes' ) ) {
     270            $this->dispatch_internal( true );
     271        }
    238272    }
    239273
     
    270304     */
    271305    private function update_tasks_queue( $task_id, $data ) {
    272         $queue = $this->get_tasks_queue();
     306        $lock_token = $this->acquire_queue_lock();
     307        $queue      = $this->get_tasks_queue();
    273308        if ( ! isset( $queue[ $task_id ] ) ) {
     309            $this->release_queue_lock( $lock_token );
    274310            return;
    275311        }
     
    293329        }
    294330        $this->set_tasks_queue( $queue );
     331        $this->release_queue_lock( $lock_token );
    295332    }
    296333
     
    304341    private function set_tasks_queue( $tasks ) {
    305342        update_option( $this->identifier, $tasks, 'no' );
     343    }
     344
     345    /**
     346     * Check if queue has pending task of a specific type.
     347     *
     348     * @param string $type Task type.
     349     * @return bool
     350     */
     351    private function has_pending_type( $type ) {
     352        $queue = $this->get_tasks_queue( false );
     353        foreach ( $queue as $task ) {
     354            if ( isset( $task['type'] ) && $type === $task['type'] ) {
     355                return true;
     356            }
     357        }
     358        return false;
    306359    }
    307360
     
    428481
    429482    /**
     483     * Acquire a short-lived queue lock to reduce race conditions.
     484     *
     485     * @return string|false Lock token or false if not acquired.
     486     */
     487    private function acquire_queue_lock() {
     488        $lock_key = $this->identifier . '_queue_lock';
     489        $token    = wp_generate_uuid4();
     490        $start    = microtime( true );
     491        $ttl      = apply_filters( $this->identifier . '_queue_lock_ttl', 10 );
     492
     493        do {
     494            $current = get_transient( $lock_key );
     495            if ( empty( $current ) ) {
     496                set_transient( $lock_key, $token, $ttl );
     497                if ( get_transient( $lock_key ) === $token ) {
     498                    return $token;
     499                }
     500            }
     501            usleep( 20000 ); // 20ms
     502        } while ( ( microtime( true ) - $start ) < 2 );
     503
     504        return false;
     505    }
     506
     507    /**
     508     * Release the queue lock if owned.
     509     *
     510     * @param string|false $token Lock token.
     511     */
     512    private function release_queue_lock( $token ) {
     513        if ( ! $token ) {
     514            return;
     515        }
     516        $lock_key = $this->identifier . '_queue_lock';
     517        $stored_t = get_transient( $lock_key );
     518        if ( $stored_t === $token ) {
     519            delete_transient( $lock_key );
     520        }
     521    }
     522
     523    /**
    430524     * Log Error Message.
    431525     *
  • podcast-player/trunk/helper/feed/class-fetch-feed.php

    r3300373 r3462195  
    510510                $content  = $link_mod->init( $content );
    511511            }
    512             return $content;
     512            return apply_filters( 'podcast_player_feed_episode_content', $content );
    513513        } else {
    514514            return '';
     
    862862                }
    863863            } else {
    864                 trim( (string) $links );
     864                return trim( (string) $links );
    865865            }
    866866        }
     
    10971097     */
    10981098    private function get_podcast_analysis( $episodes ) {
     1099        if ( empty( $episodes ) ) {
     1100            return array( false, 0, 0, 7 * DAY_IN_SECONDS );
     1101        }
     1102
     1103        $episodes = array_filter(
     1104            $episodes,
     1105            function ( $episode ) {
     1106                return $episode instanceof ItemData;
     1107            }
     1108        );
     1109        if ( empty( $episodes ) ) {
     1110            return array( false, 0, 0, 7 * DAY_IN_SECONDS );
     1111        }
     1112
    10991113        // Step 1: Sort episodes according to their release date.
    11001114        usort( $episodes, function( $a, $b ) {
     
    11451159
    11461160        // Step 6: Calculate when the last episode was released
    1147         $last_episode_release_date = end( $episodes )->get( 'date' )['date'];
     1161        $last_episode = end( $episodes );
     1162        $last_episode_release_date = $last_episode ? $last_episode->get( 'date' )['date'] : 0;
    11481163
    11491164        // Step 7: Calculate how mamy days ago last episode was released
    1150         $days_since_last_episode = ( time() - $last_episode_release_date ) / (60 * 60 * 24);
     1165        $days_since_last_episode = $last_episode_release_date ? ( time() - $last_episode_release_date ) / (60 * 60 * 24) : 0;
    11511166
    11521167        // Step 8: Check if podcast is active ( Release an episode in last 3 months )
  • podcast-player/trunk/helper/feed/class-modify-feed-data.php

    r3381875 r3462195  
    101101        // Get cumulative array of all available categories.
    102102        $cats = array_column( $new_items, 'categories' );
    103         $cats = array_unique( call_user_func_array( 'array_merge', $cats ) );
     103        $cats = array_filter(
     104            array_map(
     105                function ( $val ) {
     106                    return is_array( $val ) ? $val : array();
     107                },
     108                $cats
     109            )
     110        );
     111        $cats = empty( $cats ) ? array() : array_unique( call_user_func_array( 'array_merge', $cats ) );
    104112
    105113        // Sort filtered items by data or title.
  • podcast-player/trunk/helper/functions/class-utility.php

    r3407648 r3462195  
    3333     */
    3434    public function __construct() {}
     35
     36    /**
     37     * Require a capability for admin-ajax actions.
     38     *
     39     * Call this after nonce verification in admin-ajax handlers.
     40     *
     41     * @since 7.9.1
     42     *
     43     * @param string $cap     Capability required to proceed.
     44     * @param string $context Optional context string for filters/logs.
     45     */
     46    public static function require_capabilities( $cap = 'manage_options', $context = '' ) {
     47        $cap = apply_filters( 'podcast_player_ajax_capability', $cap, $context );
     48
     49        if ( ! wp_doing_ajax() ) {
     50            wp_send_json_error(
     51                array( 'message' => esc_html__( 'Invalid request context.', 'podcast-player' ) ),
     52                400
     53            );
     54        }
     55
     56        if ( ! is_user_logged_in() || ! current_user_can( $cap ) ) {
     57            wp_send_json_error(
     58                array( 'message' => esc_html__( 'Unauthorized', 'podcast-player' ) ),
     59                403
     60            );
     61        }
     62    }
    3563
    3664    /**
     
    111139    }
    112140
     141    /**
     142     * Normalize a media URL for stable hashing.
     143     *
     144     * Strips query and fragment to reduce cache-busting noise.
     145     *
     146     * @since 7.9.15
     147     *
     148     * @param string $url Media URL.
     149     * @return string Normalized URL or original if parsing fails.
     150     */
     151    public static function normalize_media_url( $url ) {
     152        $url   = trim( (string) $url );
     153        $parts = wp_parse_url( $url );
     154
     155        if ( empty( $parts ) || empty( $parts['host'] ) || empty( $parts['path'] ) ) {
     156            return $url;
     157        }
     158
     159        $scheme = isset( $parts['scheme'] ) ? $parts['scheme'] : 'https';
     160        return $scheme . '://' . $parts['host'] . $parts['path'];
     161    }
    113162
    114163    /**
  • podcast-player/trunk/podcast-player.php

    r3442200 r3462195  
    1515 * Plugin URI:        https://easypodcastpro.com
    1616 * Description:       Host your podcast episodes anywhere, display them only using podcast feed url. Use custom widget or shortcode to display podcast player anywhere on your site.
    17  * Version:           7.9.14
     17 * Version:           8.0.0
    1818 * Author:            vedathemes
    1919 * Author URI:        https://easypodcastpro.com
     
    3030
    3131// Currently plugin version.
    32 define( 'PODCAST_PLAYER_VERSION', '7.9.14' );
     32define( 'PODCAST_PLAYER_VERSION', '8.0.0' );
    3333
    3434// Define plugin constants.
Note: See TracChangeset for help on using the changeset viewer.