• Resolved formlos

    (@formlos)


    first of all: thank you very much for this amazing plugin! It’s really a great help to manage a podcast on our very own server ??

    We want to show a list of all the distribution URLs, that we entered in the backend (e.g. wp-admin/edit.php?post_type=podcast&page=podcast_options and /wp-admin/edit.php?post_type=podcast&page=podcast_settings&tab=feed-details).

    We figured out, that these URLs get saved as a wp_option with the prefix “ss_podcasting_{servicename}_url”. So we are able to search for these options and display them via get_option(). But if we do not know, which URLs are set, we need to try every single option and check if they are set or not.

    We also searched the plugin code and found :

    php/classes/controllers/class-players-controller.php line 606

    where there is the following object used:

    new Option_Handler();

    But this seems only to work if we set an episode ID and a “context”.

    [EDIT] We could do something like this, but this feels like unnecessary guessing and is very tedious to figure out which services are set

    $subscribe_urls['google'] = get_option('ss_podcasting_google_podcasts_url');
    
    $subscribe_urls['apple'] = get_option('ss_podcasting_apple_podcasts_url');
    
    $subscribe_urls['amazon'] = get_option('ss_podcasting_amazon_url');
    
    $subscribe_urls['rss'] = get_option('ss_podcasting_rss_url');
    
    $subscribe_urls['spotify'] = get_option('ss_podcasting_spotify_url');

    [/EDIT]

    Question: is there an easier way to get all the URLs that were set via the aforementioned wordpress backend settings? (without “guessing” the used distribution services?)

    • This topic was modified 12 months ago by formlos.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    Hi @formlos,

    I would suggest obtaining the distribution URLs this way:
    1. You get the enabled services:
    $services = ssp_get_option( ‘subscribe_options’ );
    2. You get URL for the each service.

    Something like this:

    // $series_id - current series ID, 0 - for the default feed 
    function get_distribution_urls ( $series_id = 0 ) {
    	$services = ssp_get_option( 'subscribe_options' );
    
    	$urls = array();
    	if ( ! array( $services ) ) {
    		return $urls;
    	}
    
    	foreach ( $services as $service ) {
    		$urls[ $service ] = ssp_get_option( $service . '_url', '', $series_id );
    	}
    
    	return $urls;
    }

    Also, you can cache the obtained list to the transient.

    Hope this helps,
    Serhiy.

    Thread Starter formlos

    (@formlos)

    Oh wow – this seems perfect! Thank you very much. Maybe you should integrate this on the developer docs here: https://support.castos.com/category/44-advanced-installation-developers (I was searching around there, but didn’t find any infos).

    Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    @formlos
    Did you want to show the list in the admin area, or for your users? Maybe, we could create a shortcode for it in our future plugin versions.

    Thread Starter formlos

    (@formlos)

    I wanted to show it in the frontend to all (anonymous and logged in) users.

    A shortcode sounds really really useful! This could be perfect for every sidebar or widget area or even for blog posts/pages when using gutenberg etc.

    Fot the shortcode it would also be very benificiary, if it only outputs the filled out distribution channels. Because

    ssp_get_option( 'subscribe_options' )

    outputs ALL the subcribe options that are checked, regardless if I actually filled out the field ??

    Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    @formlos

    Okay, thank you for the idea!

    Have you realized this on your site already? If so, could you please share a link to the page to check how it looks on your site?

    Thread Starter formlos

    (@formlos)

    @zahardoc Yes, we realized it here (in the blue left sidebar): https://www.hi-deutschland-projekte.de/crossroads/podcast/ This only outputs the filled out settings. (We used a custom template with a widget area to include the headline and image.)

    Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    @formlos

    Thank you for sharing your implementation. We’ll explore the possibility of creating a block for this purpose, maybe with a different design to accommodate various user needs.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to get all distribution URLs for use in a template (archive/single/sidebar)?’ is closed to new replies.