Skip to content

Instantly share code, notes, and snippets.

@jeherve

jeherve/direct-podcast.php

Last active Jul 10, 2020
Embed
What would you like to do?
[Jetpack] Display a Podcast player anywhere. See https://wordpress.org/support/topic/embedding-the-podcast-player-with-code/
<?php
/**
* Display a Podcast player anywhere.
* Pulled from extensions/blocks/podcast-player/podcast-player.php
* @see https://github.com/Automattic/jetpack/blob/b88b1edbdce4d8576ce9be02a9093702ae112fed/extensions/blocks/podcast-player/podcast-player.php
* @see https://wordpress.org/support/topic/embedding-the-podcast-player-with-code/
*/
function jeherve_display_podcast() {
// bail early if Jetpack isn't installed.
if ( ! class_exists( 'Jetpack' ) ) {
return;
}
// Load the necessary libs.
if ( ! class_exists( 'Jetpack_Podcast_Helper' ) ) {
jetpack_require_lib( 'class-jetpack-podcast-helper' );
}
$attributes = array(
'url' => 'https://distributed.blog/category/podcast/feed/',
'itemsToShow' => 2,
'primaryColor' => 'accent',
'hexPrimaryColor' => '#e22658',
'secondaryColor' => 'primary',
'hexSecondaryColor' => '#000000',
'backgroundColor' => 'subtle-background',
'hexBackgroundColor' => '#dbdbdb',
'showCoverArt' => true,
'showEpisodeDescription' => true,
);
$player_data = Jetpack_Podcast_Helper::get_player_data( $attributes['url'] );
// No info from that feed. Bail.
if ( is_wp_error( $player_data ) ) {
return;
}
echo \Automattic\Jetpack\Extensions\Podcast_Player\render_player( $player_data, $attributes );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.