public function register_page()
    {
        $podcast = \Podlove\Model\Podcast::get();
        $form_attributes = array('context' => 'podlove_podcast', 'action' => $this->get_url());
        ?>
		<p>
			<?php 
        echo __('You may provide additional information about your podcast that may or may not be used by podcast directories like iTunes.', 'podlove');
        ?>
		</p>
		<?php 
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('author_name', array('label' => __('Author Name', 'podlove'), 'description' => __('Publicly displayed in Podcast directories.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('publisher_name', array('label' => __('Publisher Name', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('publisher_url', array('label' => __('Publisher URL', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url')));
            $wrapper->string('owner_name', array('label' => __('Owner Name', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->string('owner_email', array('label' => __('Owner Email', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'email')));
            $wrapper->string('keywords', array('label' => __('Keywords', 'podlove'), 'description' => __('List of keywords. Separate with commas.', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input')));
            $wrapper->select('category_1', array('label' => __('iTunes Categories', 'podlove'), 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_2', array('label' => '', 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_3', array('label' => '', 'description' => '<br>' . __('For placement within the older, text-based browse system, podcast feeds may list up to 3 category/subcategory pairs. (For example, "Music" counts as 1, as does "Business > Careers.") For placement within the newer browse system based on Category links, however, and for placement within the Top Podcasts and Top Episodes lists that appear in the right column of most podcast pages, only the first category listed in the feed is used.') . ' (<a href="http://www.apple.com/itunes/podcasts/specs.html#category" target="_blank">http://www.apple.com/itunes/podcasts/specs.html#category</a>)', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('explicit', array('label' => __('Explicit Content?', 'podlove'), 'description' => __('', 'podlove'), 'type' => 'checkbox', 'options' => array(0 => 'no', 1 => 'yes', 2 => 'clean')));
            $wrapper->checkbox('complete', array('label' => __('Podcast complete?', 'podlove'), 'description' => __('Shows that this Podcast is finished and no further episodes will be added.', 'podlove'), 'default' => false));
        });
    }
Example #2
0
    function page()
    {
        ?>
		<div class="wrap">
			<div id="icon-options-general" class="icon32"></div>
			<h2><?php 
        echo __('Podcast Settings');
        ?>
</h2>

			<form method="post" action="options.php">
				<?php 
        settings_fields(Podcast::$pagehook);
        ?>

				<?php 
        $podcast = \Podlove\Model\Podcast::get_instance();
        $form_attributes = array('context' => 'podlove_podcast', 'form' => false);
        \Podlove\Form\build_for($podcast, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $podcast = $form->object;
            $wrapper->string('title', array('label' => __('Title', 'podlove'), 'description' => __('', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'description' => __('The subtitle is used by iTunes.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->text('summary', array('label' => __('Summary', 'podlove'), 'description' => __('A couple of sentences describing the podcast.', 'podlove'), 'html' => array('rows' => 5, 'cols' => 40)));
            $wrapper->string('slug', array('label' => __('Mnemonic', 'podlove'), 'description' => __('The abbreviation for your podcast. Commonly the initials of the title.', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $wrapper->image('cover_image', array('label' => __('Cover Art URL', 'podlove'), 'description' => __('JPEG or PNG. At least 1400 x 1400 pixels.', 'podlove'), 'html' => array('class' => 'regular-text'), 'image_width' => 300, 'image_height' => 300));
            $wrapper->string('author_name', array('label' => __('Author Name', 'podlove'), 'description' => __('Publicly displayed in Podcast directories.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('owner_name', array('label' => __('Owner Name', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('owner_email', array('label' => __('Owner Email', 'podlove'), 'description' => __('Used by iTunes and other Podcast directories to contact you.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->string('keywords', array('label' => __('Keywords', 'podlove'), 'description' => __('List of keywords. Separate with commas.', 'podlove'), 'html' => array('class' => 'regular-text')));
            $wrapper->select('category_1', array('label' => __('iTunes Categories', 'podlove'), 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_2', array('label' => '', 'description' => '', 'type' => 'select', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('category_3', array('label' => '', 'description' => '<br>' . __('For placement within the older, text-based browse system, podcast feeds may list up to 3 category/subcategory pairs. (For example, "Music" counts as 1, as does "Business > Careers.") For placement within the newer browse system based on Category links, however, and for placement within the Top Podcasts and Top Episodes lists that appear in the right column of most podcast pages, only the first category listed in the feed is used.') . ' (<a href="http://www.apple.com/itunes/podcasts/specs.html#category" target="_blank">http://www.apple.com/itunes/podcasts/specs.html#category</a>)', 'options' => \Podlove\Itunes\categories()));
            $wrapper->select('language', array('label' => __('Language', 'podlove'), 'description' => __('', 'podlove'), 'default' => get_bloginfo('language'), 'options' => \Podlove\Locale\locales()));
            $wrapper->select('explicit', array('label' => __('Explicit Content?', 'podlove'), 'description' => __('', 'podlove'), 'type' => 'checkbox', 'options' => array(0 => 'no', 1 => 'yes', 2 => 'clean')));
            $wrapper->string('media_file_base_uri', array('label' => __('Media File Base URL', 'podlove'), 'description' => __('Example: http://cdn.example.com/pod/', 'podlove'), 'html' => array('class' => 'regular-text required')));
            $artwork_options = array('0' => __('None', 'podlove'), 'manual' => __('Manual Entry', 'podlove'));
            $episode_assets = Model\EpisodeAsset::all();
            foreach ($episode_assets as $episode_asset) {
                $file_type = $episode_asset->file_type();
                if ($file_type && $file_type->type === 'image') {
                    $artwork_options[$episode_asset->id] = sprintf(__('Media File: %s', 'podlove'), $episode_asset->title);
                }
            }
            $wrapper->select('supports_cover_art', array('label' => __('Episode Artwork Media File', 'podlove'), 'options' => $artwork_options));
        });
        ?>
				
			</form>
		</div>	
		<?php 
    }
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);
    });
}
Example #4
0
function override_feed_head($hook, $podcast, $feed, $format)
{
    add_filter('podlove_feed_itunes_author', 'convert_chars');
    add_filter('podlove_feed_itunes_owner', 'convert_chars');
    add_filter('podlove_feed_itunes_subtitle', 'convert_chars');
    add_filter('podlove_feed_itunes_keywords', 'convert_chars');
    add_filter('podlove_feed_itunes_summary', 'convert_chars');
    remove_action($hook, 'the_generator');
    add_action($hook, function () use($hook) {
        switch ($hook) {
            case 'rss2_head':
                $gen = '<generator>Podlove Publishing Plugin for WordPress 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($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_image) {
            $coverimage = sprintf('<itunes:image href="%s" />', $podcast->cover_image);
        } 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;
    });
}