public function get()
 {
     $license = $this->get_license();
     $downloads = $this->get_downloads();
     $config = ["alwaysShowHours" => true, "alwaysShowControls" => true, "chaptersVisible" => true, "permalink" => get_permalink($this->post->ID), "publicationDate" => mysql2date("c", $this->post->post_date), "title" => get_the_title($this->post->ID), "subtitle" => wptexturize(convert_chars(trim($this->episode->subtitle))), "summary" => nl2br(wptexturize(convert_chars(trim($this->episode->summary)))), "poster" => $this->episode->cover_art_with_fallback()->setWidth(500)->url(), "show" => ['title' => $this->podcast->title, 'subtitle' => $this->podcast->subtitle, 'summary' => $this->podcast->summary, 'poster' => $this->podcast->cover_art()->setWidth(500)->url(), 'url' => \Podlove\get_landing_page_url()], "license" => ["name" => $license['name'], "url" => $license['url']], "downloads" => $downloads, "duration" => $this->episode->get_duration(), "features" => ["current", "progress", "duration", "tracks", "fullscreen", "volume"], "chapters" => json_decode($this->episode->get_chapters('json')), "languageCode" => $this->podcast->language];
     return $config;
 }
 /**
  * Render player
  * 
  * @param  string $context (optional) player context for tracking. Set to NULL for auto-detection. Default: NULL
  * @return string
  */
 public function render($context = NULL)
 {
     if (count($this->player_format_assignments) == 0) {
         return '';
     }
     // build main audio/video tag
     $xml = new \SimpleXMLElement('<' . $this->get_media_tag() . '/>');
     $xml->addAttribute('id', $this->get_html_id());
     $xml->addAttribute('controls', 'controls');
     $xml->addAttribute('preload', 'none');
     $width = strtolower(trim($this->get_webplayer_setting($this->get_media_tag(), 'width')));
     $height = strtolower(trim($this->get_webplayer_setting($this->get_media_tag(), 'height')));
     if ($this->is_video) {
         $xml->addAttribute('poster', $this->episode->cover_art_with_fallback()->url());
         $xml->addAttribute('width', $width);
         $xml->addAttribute('height', $height);
     } else {
         $xml->addAttribute('style', sprintf('width: %s; height: %s', empty($width) || $width == 'auto' ? '100%' : $width . 'px', empty($height) ? '30px' : $height));
     }
     // get all relevant info about media files
     $media_files = array();
     foreach ($this->files as $file) {
         $asset = $file->episode_asset();
         $mime = $asset->file_type()->mime_type;
         $media_files[$mime] = array('file' => $file, 'mime_type' => $mime, 'url' => $file->get_file_url(), 'publicUrl' => $file->get_public_file_url("webplayer", is_null($context) ? $this->get_tracking_context() : $context), 'assetTitle' => $asset->title());
     }
     if (!count($media_files)) {
         return "";
     }
     // sort files bases on mime type so preferred get output first
     $sorted_files = array();
     $preferred_order = array('audio/mp4', 'audio/aac', 'audio/opus', 'audio/ogg', 'audio/vorbis');
     foreach ($preferred_order as $order_key) {
         if (isset($media_files[$order_key]) && $media_files[$order_key]) {
             $sorted_files[] = $media_files[$order_key];
             unset($media_files[$order_key]);
         }
     }
     foreach ($media_files as $file) {
         $sorted_files[] = $file;
     }
     // add all sources
     $flash_fallback_func = function (&$xml) {
     };
     foreach ($sorted_files as $file) {
         $mime_type = $file['mime_type'];
         $source = $xml->addChild('source');
         $source->addAttribute('src', $file['publicUrl']);
         $source->addAttribute('type', $mime_type);
         if ($mime_type == 'audio/mpeg') {
             $flash_fallback_func = function (&$xml) use($file) {
                 $flash_fallback = $xml->addChild('object');
                 $flash_fallback->addAttribute('type', 'application/x-shockwave-flash');
                 $flash_fallback->addAttribute('data', plugins_url('player/podlove-web-player/static/', __FILE__) . 'flashmediaelement.swf');
                 $params = array(array('name' => 'movie', 'value' => plugins_url('player/podlove-web-player/static/', __FILE__) . 'flashmediaelement.swf'), array('name' => 'flashvars', 'value' => 'controls=true&file=' . $file['url']));
                 foreach ($params as $param) {
                     $p = $flash_fallback->addChild('param');
                     $p->addAttribute('name', $param['name']);
                     $p->addAttribute('value', $param['value']);
                 }
             };
         }
     }
     // add flash fallback after all <source>s
     $flash_fallback_func($xml);
     // prettify and prepare to render
     $xml_string = $xml->asXML();
     $xml_string = $this->format_xml($xml_string);
     $xml_string = $this->remove_xml_header($xml_string);
     // get podcast object
     $podcast = Podcast::get();
     if ($this->episode->license_name && $this->episode->license_url) {
         $license_name = $this->episode->license_name;
         $license_url = $this->episode->license_url;
     } else {
         $license_name = $podcast->license_name;
         $license_url = $podcast->license_url;
     }
     // set JavaScript options
     $truthy = array(true, 'true', 'on', 1, "1");
     $init_options = array('pluginPath' => plugins_url('player/podlove-web-player/static/', __FILE__), 'alwaysShowHours' => true, 'alwaysShowControls' => true, 'timecontrolsVisible' => false, 'summaryVisible' => false, 'hidetimebutton' => in_array($this->get_webplayer_setting('buttons_time'), $truthy, true), 'hidedownloadbutton' => in_array($this->get_webplayer_setting('buttons_download'), $truthy, true), 'hidesharebutton' => in_array($this->get_webplayer_setting('buttons_share'), $truthy, true), 'sharewholeepisode' => in_array($this->get_webplayer_setting('buttons_sharemode'), $truthy, true), 'loop' => false, 'chapterlinks' => 'all', 'permalink' => get_permalink($this->post->ID), 'title' => get_the_title($this->post->ID), 'subtitle' => wptexturize(convert_chars(trim($this->episode->subtitle))), 'summary' => nl2br(wptexturize(convert_chars(trim($this->episode->summary)))), 'publicationDate' => mysql2date("c", $this->post->post_date), 'poster' => $this->episode->cover_art_with_fallback()->setWidth(200)->url(), 'showTitle' => $podcast->title, 'showSubtitle' => $podcast->subtitle, 'showSummary' => $podcast->summary, 'showPoster' => $podcast->cover_art()->setWidth(200)->url(), 'show' => array('title' => $podcast->title, 'subtitle' => $podcast->subtitle, 'summary' => $podcast->summary, 'poster' => $podcast->cover_art()->setWidth(200)->url(), 'url' => \Podlove\get_landing_page_url()), 'license' => array('name' => $license_name, 'url' => $license_url), 'downloads' => array_map(function ($mf) {
         return array('assetTitle' => $mf['assetTitle'], 'downloadUrl' => $mf['publicUrl'], 'url' => $mf['url']);
     }, array_values($sorted_files)), 'duration' => $this->episode->get_duration(), 'chaptersVisible' => in_array(\Podlove\get_webplayer_setting('chaptersVisible'), $truthy, true), 'features' => array("current", "progress", "duration", "tracks", "fullscreen", "volume"));
     if ($chapters = $this->episode->get_chapters('json')) {
         $init_options['chapters'] = json_decode($chapters);
     }
     $xml_string .= "\n" . "\n<script>\n" . "jQuery('#" . $this->get_html_id() . "').podlovewebplayer(" . json_encode($init_options) . ");" . "\n</script>\n";
     return $xml_string;
 }
 public static function podcast_flattr_button($args = [])
 {
     return (new Template\Flattr())->button(['url' => \Podlove\get_landing_page_url(), 'style' => isset($args['style']) ? $args['style'] : 'compact', 'user' => Flattr::get_setting('account')]);
 }
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
?>
<rss version="2.0"
	xmlns:atom="http://www.w3.org/2005/Atom"
	<?php 
do_action('rss2_ns');
?>
>

<channel>
	<title><?php 
echo apply_filters('podlove_feed_title', '');
?>
</title>
	<link><?php 
echo apply_filters('podlove_feed_link', \Podlove\get_landing_page_url());
?>
</link>
	<description><?php 
echo apply_filters('podlove_rss_feed_description', get_bloginfo_rss('description'));
?>
</description>
	<lastBuildDate><?php 
echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
?>
</lastBuildDate>
	<?php 
do_action('rss2_head');
?>
	<?php 
while (have_posts()) {
 public function landing_page_url()
 {
     return $this->with_blog_scope(function () {
         return \Podlove\get_landing_page_url();
     });
 }
function override_feed_head($hook, $podcast, $feed, $format)
{
    $filter_hooks = array('podlove_feed_itunes_author', 'podlove_feed_itunes_owner', 'podlove_feed_itunes_subtitle', 'podlove_feed_itunes_keywords', 'podlove_feed_itunes_summary', 'podlove_feed_itunes_complete', 'podlove_feed_itunes_explicit');
    foreach ($filter_hooks as $filter) {
        add_filter($filter, 'convert_chars');
    }
    add_filter('podlove_feed_content', '\\Podlove\\Feeds\\prepare_for_feed');
    remove_action($hook, 'the_generator');
    add_action($hook, function () use($hook) {
        switch ($hook) {
            case 'rss2_head':
                $gen = '<generator>' . \Podlove\get_plugin_header('Name') . ' v' . \Podlove\get_plugin_header('Version') . '</generator>';
                break;
            case 'atom_head':
                $gen = '<generator uri="' . \Podlove\get_plugin_header('PluginURI') . '" version="' . \Podlove\get_plugin_header('Version') . '">' . \Podlove\get_plugin_header('Name') . '</generator>';
                break;
        }
        echo $gen;
    });
    add_action($hook, function () use($feed) {
        echo $feed->get_self_link();
        echo $feed->get_alternate_links();
    }, 9);
    // add rss image
    add_action($hook, function () use($podcast, $hook) {
        $image = ['url' => $podcast->cover_art()->url(), 'title' => $podcast->title, 'link' => apply_filters('podlove_feed_link', \Podlove\get_landing_page_url())];
        $image = apply_filters('podlove_feed_image', $image);
        if (!$image['url']) {
            return;
        }
        // remove WordPress provided favicon
        remove_action($hook, 'rss2_site_icon');
        // generate our own image tag
        $dom = new \Podlove\DomDocumentFragment();
        $image_tag = $dom->createElement('image');
        foreach ($image as $tag_name => $tag_text) {
            if ($tag_text) {
                $tag = $dom->createElement($tag_name);
                $tag_text = $dom->createTextNode($tag_text);
                $tag->appendChild($tag_text);
                $image_tag->appendChild($tag);
            }
        }
        $dom->appendChild($image_tag);
        echo (string) $dom;
    }, 5);
    // let it run early so we can stop the `rss2_site_icon` call
    add_action($hook, function () use($podcast, $feed, $format) {
        echo PHP_EOL;
        $author = "\t" . sprintf('<itunes:author>%s</itunes:author>', $podcast->author_name);
        echo apply_filters('podlove_feed_itunes_author', $author);
        echo PHP_EOL;
        $summary = "\t" . sprintf('<itunes:summary>%s</itunes:summary>', $podcast->summary);
        echo apply_filters('podlove_feed_itunes_summary', $summary);
        echo PHP_EOL;
        $categories = \Podlove\Itunes\categories(false);
        $category_html = '';
        for ($i = 1; $i <= 3; $i++) {
            $category_id = $podcast->{'category_' . $i};
            if (!$category_id) {
                continue;
            }
            list($cat, $subcat) = explode('-', $category_id);
            if ($subcat == '00') {
                $category_html .= sprintf('<itunes:category text="%s"></itunes:category>', htmlspecialchars($categories[$category_id]));
            } else {
                $category_html .= sprintf('<itunes:category text="%s"><itunes:category text="%s"></itunes:category></itunes:category>', htmlspecialchars($categories[$cat . '-00']), htmlspecialchars($categories[$category_id]));
            }
        }
        echo apply_filters('podlove_feed_itunes_categories', $category_html);
        echo PHP_EOL;
        $owner = sprintf('
	<itunes:owner>
		<itunes:name>%s</itunes:name>
		<itunes:email>%s</itunes:email>
	</itunes:owner>', $podcast->owner_name, $podcast->owner_email);
        echo "\t" . apply_filters('podlove_feed_itunes_owner', $owner);
        echo PHP_EOL;
        if ($podcast->cover_art()->url()) {
            $coverimage = sprintf('<itunes:image href="%s" />', $podcast->cover_art()->url());
        } else {
            $coverimage = '';
        }
        echo "\t" . apply_filters('podlove_feed_itunes_image', $coverimage);
        echo PHP_EOL;
        $subtitle = sprintf('<itunes:subtitle>%s</itunes:subtitle>', $podcast->subtitle);
        echo "\t" . apply_filters('podlove_feed_itunes_subtitle', $subtitle);
        echo PHP_EOL;
        $keywords = sprintf('<itunes:keywords>%s</itunes:keywords>', $podcast->keywords);
        echo "\t" . apply_filters('podlove_feed_itunes_keywords', $keywords);
        echo PHP_EOL;
        $block = sprintf('<itunes:block>%s</itunes:block>', $feed->enable ? 'no' : 'yes');
        echo "\t" . apply_filters('podlove_feed_itunes_block', $block);
        echo PHP_EOL;
        $explicit = sprintf('<itunes:explicit>%s</itunes:explicit>', $podcast->explicit == 2 ? 'clean' : ($podcast->explicit ? 'yes' : 'no'));
        echo "\t" . apply_filters('podlove_feed_itunes_explicit', $explicit);
        echo PHP_EOL;
        $complete = sprintf('<itunes:complete>%s</itunes:complete>', $podcast->complete ? 'yes' : 'no');
        echo apply_filters('podlove_feed_itunes_complete', $podcast->complete ? "\t{$complete}" : '');
        echo PHP_EOL;
        do_action('podlove_append_to_feed_head', $podcast, $feed, $format);
    });
}