Ejemplo n.º 1
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 
    }
 private function reset_migration()
 {
     delete_option('podlove_module_migration');
     delete_option('podlove_migration');
     delete_option('podlove_migration_validation_cache');
     delete_option('podlove_asset_assignment');
     delete_option('podlove_migrated_posts_cache');
     $args = array('post_type' => 'podcast', 'posts_per_page' => -1);
     $query = new \WP_Query($args);
     while ($query->have_posts()) {
         $query->the_post();
         wp_delete_post(get_the_ID());
     }
     wp_reset_postdata();
     foreach (Model\EpisodeAsset::all() as $asset) {
         $asset->delete();
     }
     foreach (Model\Feed::all() as $feed) {
         $feed->delete();
     }
 }
Ejemplo n.º 3
0
 public function prepare_items()
 {
     // number of items per page
     $per_page = 10;
     // define column headers
     $columns = $this->get_columns();
     $hidden = array();
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     // retrieve data
     $data = \Podlove\Model\EpisodeAsset::all();
     // get current page
     $current_page = $this->get_pagenum();
     // get total items
     $total_items = count($data);
     // extrage page for current page only
     $data = array_slice($data, ($current_page - 1) * $per_page, $per_page);
     // add items to table
     $this->items = $data;
     // register pagination options & calculations
     $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
 }
 public static function content()
 {
     global $wpdb;
     $sql = "\n\t\tSELECT\n\t\t\tp.post_status,\n\t\t\tmf.episode_id,\n\t\t\tmf.episode_asset_id,\n\t\t\tmf.size,\n\t\t\tmf.id media_file_id\n\t\tFROM\n\t\t\t`" . Model\MediaFile::table_name() . "` mf\n\t\t\tJOIN `" . Model\Episode::table_name() . "` e ON e.id = mf.`episode_id`\n\t\t\tJOIN `" . $wpdb->posts . "` p ON e.`post_id` = p.`ID`\n\t\tWHERE\n\t\t\tp.`post_type` = 'podcast'\n\t\t\tAND p.post_status in ('private', 'draft', 'publish', 'pending', 'future')\n\t\t";
     $rows = $wpdb->get_results($sql, ARRAY_A);
     $media_files = [];
     foreach ($rows as $row) {
         if (!isset($media_files[$row['episode_id']])) {
             $media_files[$row['episode_id']] = ['post_status' => $row["post_status"]];
         }
         $media_files[$row['episode_id']][$row['episode_asset_id']] = ['size' => $row['size'], 'media_file_id' => $row['media_file_id']];
     }
     $podcast = Model\Podcast::get();
     $episodes = $podcast->episodes();
     $assets = Model\EpisodeAsset::all();
     $header = [__('Episode', 'podlove')];
     foreach ($assets as $asset) {
         $header[] = $asset->title;
     }
     $header[] = __('Status', 'podlove');
     \Podlove\load_template('settings/dashboard/file_validation', ['episodes' => $episodes, 'assets' => $assets, 'media_files' => $media_files, 'header' => $header]);
 }
Ejemplo n.º 5
0
 public function refetch_files()
 {
     $valid_files = array();
     foreach (EpisodeAsset::all() as $asset) {
         if ($file = MediaFile::find_by_episode_id_and_episode_asset_id($this->id, $asset->id)) {
             $file->determine_file_size();
             $file->save();
             if ($file->is_valid()) {
                 $valid_files[] = $file->id;
             }
         }
     }
     if (empty($valid_files) && get_post_status($this->post_id) == 'publish') {
         Log::get()->addAlert('All assets for this episode are invalid!', array('episode_id' => $this->id));
     }
 }
Ejemplo n.º 6
0
    public function form_fields()
    {
        $formats = array('audio' => array('mp3' => array('title' => __('MP3 Audio', 'podlove'), 'mime_type' => 'audio/mpeg'), 'mp4' => array('title' => __('MP4 Audio', 'podlove'), 'mime_type' => 'audio/mp4'), 'ogg' => array('title' => __('OGG Audio', 'podlove'), 'mime_type' => 'audio/ogg')), 'video' => array('mp4' => array('title' => __('MP4 Video', 'podlove'), 'mime_type' => 'video/mp4'), 'ogg' => array('title' => __('OGG Video', 'podlove'), 'mime_type' => 'video/ogg'), 'webm' => array('title' => __('Webm Video', 'podlove'), 'mime_type' => 'video/webm')));
        $formats_data = get_option('podlove_webplayer_formats', array());
        $episode_assets = Model\EpisodeAsset::all();
        foreach ($formats as $format => $extensions) {
            foreach ($extensions as $extension => $extension_data) {
                $label = $extension_data['title'];
                $mime_type = $extension_data['mime_type'];
                $id = sprintf('podlove_webplayer_formats_%s_%s', $format, $extension);
                $name = sprintf('podlove_webplayer_formats[%s][%s]', $format, $extension);
                $value = isset($formats_data[$format]) && isset($formats_data[$format][$extension]) ? $formats_data[$format][$extension] : 0;
                ?>
				<tr valign="top">
					<th scope="row" valign="top">
						<label for="<?php 
                echo $id;
                ?>
"><?php 
                echo $label;
                ?>
</label>
					</th>
					<td>
						<div>
							<select name="<?php 
                echo $name;
                ?>
" id="<?php 
                echo $id;
                ?>
">
								<option value="0" <?php 
                selected(0, $value);
                ?>
 ><?php 
                echo __('Unused', 'podlove');
                ?>
</option>
								<?php 
                foreach ($episode_assets as $episode_asset) {
                    ?>
									<?php 
                    $file_type = $episode_asset->file_type();
                    ?>
									<?php 
                    if ($file_type && $file_type->mime_type === $mime_type) {
                        ?>
										<option value="<?php 
                        echo $episode_asset->id;
                        ?>
" <?php 
                        selected($episode_asset->id, $value);
                        ?>
><?php 
                        echo $episode_asset->title;
                        ?>
</option>
									<?php 
                    }
                    ?>
								<?php 
                }
                ?>
							</select>
						</div>
					</td>
				</tr>
				<?php 
            }
        }
    }
Ejemplo n.º 7
0
 public function __construct()
 {
     $errors =& $this->errors;
     $notices =& $this->notices;
     $this->fields = array('site' => array('title' => 'Website', 'callback' => function () {
         return get_site_url();
     }), 'php_version' => array('title' => 'PHP Version', 'callback' => function () {
         return phpversion();
     }), 'wp_version' => array('title' => 'WordPress Version', 'callback' => function () {
         return get_bloginfo('version');
     }), 'podlove_version' => array('title' => 'Publisher Version', 'callback' => function () {
         return \Podlove\get_plugin_header('Version');
     }), 'player_version' => array('title' => 'Web Player Version', 'callback' => function () {
         if (!defined('PODLOVEWEBPLAYER_DIR')) {
             return 'no web player found';
         }
         $pwp_file = PODLOVEWEBPLAYER_DIR . 'podlove-web-player.php';
         if (!is_readable($pwp_file)) {
             return 'not readable';
         }
         $plugin_data = \get_plugin_data($pwp_file);
         return $plugin_data['Version'];
     }), 'twig_version' => array('title' => 'Twig Version', 'callback' => function () {
         return \Twig_Environment::VERSION;
     }), 'open_basedir' => array('callback' => function () use(&$notices) {
         $open_basedir = trim(ini_get('open_basedir'));
         if ($open_basedir != '.') {
             $notices[] = 'The PHP setting "open_basedir" is not empty. This is incompatible with curl, a library required by Podlove Publisher. We have a workaround in place but it is preferred to fix the issue. Please ask your hoster to unset "open_basedir".';
         }
         if ($open_basedir) {
             return $open_basedir;
         } else {
             return 'ok';
         }
     }), 'curl' => array('title' => 'curl Version', 'callback' => function () use(&$errors) {
         $module_loaded = in_array('curl', get_loaded_extensions());
         $function_disabled = stripos(ini_get('disable_functions'), 'curl_exec') !== false;
         $out = '';
         if ($module_loaded) {
             $curl = curl_version();
             $out .= $curl['version'];
         } else {
             $out .= 'EXTENSION MISSING';
             $errors[] = 'curl extension is not loaded';
         }
         if ($function_disabled) {
             $out .= ' | curl_exec is disabled';
             $errors[] = 'curl_exec is disabled';
         }
         return $out;
     }), 'iconv' => array('callback' => function () use(&$errors) {
         $iconv_available = function_exists('iconv');
         if (!$iconv_available) {
             $errors[] = 'You need to install/activate php5-iconv';
         }
         return $iconv_available ? "available" : "MISSING";
     }), 'simplexml' => array('callback' => function () use(&$errors) {
         if (!($simplexml = in_array('SimpleXML', get_loaded_extensions()))) {
             $errors[] = 'You need to install/activate the PHP SimpleXML module';
         }
         return $simplexml ? 'ok' : 'missing!';
     }), 'max_execution_time' => array('callback' => function () {
         return ini_get('max_execution_time');
     }), 'upload_max_filesize' => array('callback' => function () {
         return ini_get('upload_max_filesize');
     }), 'memory_limit' => array('callback' => function () {
         return ini_get('memory_limit');
     }), 'disable_classes' => array('callback' => function () {
         return ini_get('disable_classes');
     }), 'disable_functions' => array('callback' => function () {
         return ini_get('disable_functions');
     }), 'permalinks' => array('callback' => function () use(&$errors) {
         $permalinks = \get_option('permalink_structure');
         if (!$permalinks) {
             $errors[] = sprintf(__('You are using the default WordPress permalink structure. This may cause problems with some podcast clients. Go to %s and set it to anything but default (for example "Post name").', 'podlove'), admin_url('options-permalink.php'));
             return __("\"non-pretty\" Permalinks: Please change permalink structure", 'podlove');
         }
         return "ok ({$permalinks})";
     }), 'podlove_permalinks' => array('callback' => function () use(&$errors) {
         if (\Podlove\get_setting('website', 'use_post_permastruct') == 'on') {
             return 'ok';
         }
         if (stristr(\Podlove\get_setting('website', 'custom_episode_slug'), '%podcast%') === FALSE) {
             $website_options = get_option('podlove_website');
             $website_options['use_post_permastruct'] = 'on';
             update_option('podlove_website', $website_options);
         }
         return 'ok';
     }), 'podcast_settings' => array('callback' => function () use(&$errors) {
         $out = '';
         $podcast = Model\Podcast::get();
         if (!$podcast->title) {
             $error = __('Your podcast needs a title.', 'podlove');
             $errors[] = $error;
             $out .= $error;
         }
         if (!$podcast->media_file_base_uri) {
             $error = __('Your podcast needs an upload location for file storage.', 'podlove');
             $errors[] = $error;
             $out .= $error;
         }
         if (!$out) {
             $out = "ok";
         }
         return $out;
     }), 'web_player' => array('callback' => function () use(&$errors) {
         foreach (get_option('podlove_webplayer_formats', array()) as $_ => $media_types) {
             foreach ($media_types as $extension => $asset_id) {
                 if ($asset_id) {
                     return "ok";
                 }
             }
         }
         $error = __('You need to assign at least one asset to the web player.', 'podlove');
         $errors[] = $error;
         return $error;
     }), 'podlove_cache' => array('callback' => function () {
         return \Podlove\Cache\TemplateCache::is_enabled() ? 'on' : 'off';
     }), 'assets' => array('callback' => function () {
         $assets = array();
         foreach (\Podlove\Model\EpisodeAsset::all() as $asset) {
             $file_type = $asset->file_type();
             $assets[] = array('extension' => $file_type->extension, 'mime_type' => $file_type->mime_type);
         }
         return "\n\t" . implode("\n\t", array_map(function ($asset) {
             return str_pad($asset['extension'], 7) . $asset['mime_type'];
         }, $assets));
     }));
     $this->fields = apply_filters('podlove_system_report_fields', $this->fields);
     $this->run();
 }
Ejemplo n.º 8
0
/**
 * Find and run migration for given version number.
 *
 * @todo  move migrations into separate files
 * 
 * @param  int $version
 */
function run_migrations_for_version($version)
{
    global $wpdb;
    switch ($version) {
        case 2:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `chapters` TEXT AFTER `cover_art`', \Podlove\Model\Release::table_name());
            $wpdb->query($sql);
            break;
        case 3:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `format` VARCHAR(255) AFTER `slug`', \Podlove\Model\Feed::table_name());
            $wpdb->query($sql);
            break;
        case 4:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `title` VARCHAR(255) AFTER `id`', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            break;
        case 5:
            \Podlove\Modules\Base::activate('podlove_web_player');
            break;
        case 6:
            // title column is "int" for some people. this migration fixes that
            $sql = sprintf('SHOW COLUMNS FROM `wp_podlove_medialocation` WHERE Field = "title"', \Podlove\Model\EpisodeAsset::table_name());
            $row = $wpdb->get_row($sql);
            if (strtolower(substr($row->Type, 0, 3)) === 'int') {
                $wpdb->query(sprintf('UPDATE `%s` SET title = NULL', \Podlove\Model\EpisodeAsset::table_name()));
                $wpdb->query(sprintf('ALTER TABLE `%s` MODIFY COLUMN `title` VARCHAR(255)', \Podlove\Model\EpisodeAsset::table_name()));
            }
            break;
        case 7:
            // move language from feed to show
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `language` VARCHAR(255) AFTER `summary`', \Podlove\Model\Show::table_name());
            $wpdb->query($sql);
            $sql = sprintf('ALTER TABLE `%s` DROP COLUMN `language`', \Podlove\Model\Feed::table_name());
            $wpdb->query($sql);
            break;
        case 8:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `supports_cover_art` INT', \Podlove\Model\Show::table_name());
            $wpdb->query($sql);
            break;
        case 9:
            // huge architecture migration
            // assume first show will be blueprint for the podcast
            $show = $wpdb->get_row(sprintf('SELECT * FROM %s LIMIT 1', $wpdb->prefix . 'podlove_show'), ARRAY_A);
            $show_id = $show['id'];
            // On my local machine the migration runs twice.
            // This is a quick fix. caveat: someone who has no show defined
            // will need to uninstall the plugin. That seems acceptable.
            if (!$show_id) {
                return;
            }
            // all releases of this show will be converted to episodes
            $releases = $wpdb->get_results(sprintf('
					SELECT
						E.post_id, R.episode_id, R.active, R.enable, R.slug, R.duration, R.cover_art, R.chapters
					FROM 
						%s R
						INNER JOIN %s E ON R.episode_id = E.id
					WHERE
						R.show_id = "%s"
					', $wpdb->prefix . 'podlove_release', $wpdb->prefix . 'podlove_episode', $show_id), ARRAY_A);
            // write show settings to podcast
            $podcast = \Podlove\Model\Podcast::get_instance();
            foreach ($show as $key => $value) {
                $podcast->{$key} = $value;
            }
            $podcast->save();
            // rebuild show table
            \Podlove\Model\Show::destroy();
            \Podlove\Model\Show::build();
            // rebuild episodes table
            \Podlove\Model\Episode::destroy();
            \Podlove\Model\Episode::build();
            foreach ($releases as $release) {
                $episode = new \Podlove\Model\Episode();
                foreach ($release as $key => $value) {
                    if (!in_array($key, array('episode_id'))) {
                        $episode->{$key} = $value;
                    }
                }
                $episode->save();
            }
            // clean feed table
            $sql = sprintf('DELETE FROM `%s` WHERE `show_id` != "%s"', \Podlove\Model\Feed::table_name(), $show_id);
            $wpdb->query($sql);
            $sql = sprintf('ALTER TABLE `%s` DROP COLUMN `show_id`', \Podlove\Model\Feed::table_name());
            $wpdb->query($sql);
            // fix mediafile table
            $sql = sprintf('ALTER TABLE `%s` CHANGE `release_id` `episode_id` INT', \Podlove\Model\MediaFile::table_name());
            $wpdb->query($sql);
            // remove suffix
            $sql = sprintf('ALTER TABLE `%s` DROP COLUMN `suffix`', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            // add more default formats
            $default_formats = array(array('name' => 'PDF Document', 'type' => 'ebook', 'mime_type' => 'application/pdf', 'extension' => 'pdf'), array('name' => 'ePub Document', 'type' => 'ebook', 'mime_type' => 'application/epub+zip', 'extension' => 'epub'), array('name' => 'PNG Image', 'type' => 'image', 'mime_type' => 'image/png', 'extension' => 'png'), array('name' => 'JPEG Image', 'type' => 'image', 'mime_type' => 'image/jpeg', 'extension' => 'jpg'));
            foreach ($default_formats as $format) {
                $f = new Model\FileType();
                foreach ($format as $key => $value) {
                    $f->{$key} = $value;
                }
                $f->save();
            }
            // update assistant
            $assistant = \Podlove\Modules\EpisodeAssistant\Episode_Assistant::instance();
            $template = $assistant->get_module_option('title_template');
            $template = str_replace('%show_slug%', '%podcast_slug%', $template);
            $assistant->update_module_option('title_template', $template);
            // update media locations
            $media_locations = \Podlove\Model\EpisodeAsset::all();
            foreach ($media_locations as $media_location) {
                $media_location->url_template = str_replace('%suffix%', '', $media_location->url_template);
                $media_location->save();
            }
            break;
        case 10:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `summary` TEXT', \Podlove\Model\Episode::table_name());
            $wpdb->query($sql);
            break;
        case 11:
            $sql = sprintf('ALTER TABLE `%s` ADD COLUMN `downloadable` INT', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            break;
        case 12:
            $sql = sprintf('UPDATE `%s` SET `downloadable` = 1', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            break;
        case 13:
            $opus = array('name' => 'Opus Audio', 'type' => 'audio', 'mime_type' => 'audio/opus', 'extension' => 'opus');
            $f = new \Podlove\Model\FileType();
            foreach ($opus as $key => $value) {
                $f->{$key} = $value;
            }
            $f->save();
            break;
        case 14:
            $sql = sprintf('ALTER TABLE `%s` RENAME TO `%s`', $wpdb->prefix . 'podlove_medialocation', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            break;
        case 15:
            $sql = sprintf('ALTER TABLE `%s` CHANGE `media_location_id` `episode_asset_id` INT', \Podlove\Model\MediaFile::table_name());
            $wpdb->query($sql);
            break;
        case 16:
            $sql = sprintf('ALTER TABLE `%s` CHANGE `media_location_id` `episode_asset_id` INT', \Podlove\Model\Feed::table_name());
            $wpdb->query($sql);
            break;
        case 17:
            $sql = sprintf('ALTER TABLE `%s` RENAME TO `%s`', $wpdb->prefix . 'podlove_mediaformat', \Podlove\Model\FileType::table_name());
            $wpdb->query($sql);
            break;
        case 18:
            $sql = sprintf('ALTER TABLE `%s` CHANGE `media_format_id` `file_type_id` INT', \Podlove\Model\EpisodeAsset::table_name());
            $wpdb->query($sql);
            break;
    }
}
Ejemplo n.º 9
0
    public static function validate_podcast_files()
    {
        $podcast = Model\Podcast::get_instance();
        $podcast_warnings = self::get_podcast_setting_warnings();
        if (!in_array('curl', get_loaded_extensions())) {
            ?>
			<div class="error">
				<p>
					<strong>ERROR: </strong>You need the <strong>curl PHP extension</strong> for Podlove to run properly.
					<br>
					If you think you can do it yourself, have a look at <a href="http://stackoverflow.com/questions/1347146/how-to-enable-curl-in-php">these instructions on how to enable curl in PHP</a>.
				</p>
			</div>
			<?php 
        }
        ?>
		<div id="validation">

			<?php 
        if (count($podcast_warnings)) {
            ?>
				<style type="text/css">
				#podcast_warnings {
					color: #333333;
					background-color: #FFEBE8;
					border: 1px solid #CC0000;
					border-radius: 3px;
					padding: 0.4em 1.0em;
					margin: 10px 0px;
				}
				#podcast_warnings h4 {
					margin: 10px 0px;
				}
				</style>
				<div id="podcast_warnings">
					<h4><?php 
            echo __('Critical Notes');
            ?>
</h4>
					<?php 
            foreach ($podcast_warnings as $warning) {
                ?>
						<div class="line">
							<?php 
                echo $warning;
                ?>
							<a href="<?php 
                echo admin_url('admin.php?page=podlove_settings_podcast_handle');
                ?>
">
								<?php 
                echo __('go fix it', 'podlove');
                ?>
							</a>
						</div>
					<?php 
            }
            ?>
				</div>
			<?php 
        }
        ?>

			<?php 
        $episodes = Model\Episode::all();
        $assets = Model\EpisodeAsset::all();
        $header = array(__('Episode', 'podlove'));
        foreach ($assets as $asset) {
            $header[] = $asset->title;
        }
        $header[] = __('Status', 'podlove');
        // $header[] = ''; // buttons
        define('ASSET_STATUS_OK', '<span style="color: green">✓</span>');
        define('ASSET_STATUS_INACTIVE', '—');
        define('ASSET_STATUS_ERROR', '<span style="color: red">!!!</span>');
        ?>

			<h4><?php 
        echo $podcast->title;
        ?>
</h4>

			<table>
				<thead>
					<tr>
						<?php 
        foreach ($header as $column_head) {
            ?>
							<th><?php 
            echo $column_head;
            ?>
</th>
						<?php 
        }
        ?>
					</tr>
				</thead>
				<tbody>
					<?php 
        foreach ($episodes as $episode) {
            ?>
						<?php 
            $post_id = $episode->post_id;
            $post = get_post($post_id);
            // skip deleted podcasts
            if (!in_array($post->post_status, array('draft', 'publish'))) {
                continue;
            }
            // skip versions
            if ($post->post_type != 'podcast') {
                continue;
            }
            ?>
						<tr>
							<td>
								<a href="<?php 
            echo get_edit_post_link($episode->post_id);
            ?>
"><?php 
            echo $episode->slug;
            ?>
</a>
							</td>
							<?php 
            $media_files = $episode->media_files();
            ?>
							<?php 
            foreach ($assets as $asset) {
                ?>
								<td style="text-align: center; font-weight: bold; font-size: 20px">
									<?php 
                $files = array_filter($media_files, function ($file) use($asset) {
                    return $file->episode_asset_id == $asset->id;
                });
                $file = array_pop($files);
                if (!$file) {
                    echo ASSET_STATUS_INACTIVE;
                } elseif ($file->size > 0) {
                    echo ASSET_STATUS_OK;
                } else {
                    echo ASSET_STATUS_ERROR;
                }
                ?>
								</td>
							<?php 
            }
            ?>
							<td>
								<?php 
            echo $post->post_status;
            ?>
							</td>
							<!-- <td>buttons</td> -->
						</tr>
					<?php 
        }
        ?>
				</tbody>
			</table>
		</div>

		<style type="text/css">
		#validation h4 {
			font-size: 20px;
		}

		#validation .episode {
			margin: 0 0 15px 0;
		}

		#validation .slug {
			font-size: 18px;
			margin: 0 0 5px 0;
		}

		#validation .warning {
			color: maroon;
		}

		#validation .error {
			color: red;
		}
		</style>
		<?php 
    }
    public static function chart()
    {
        $episode = Model\Episode::find_one_by_id((int) $_REQUEST['episode']);
        $post = get_post($episode->post_id);
        ?>
		<div id="chart-zoom-selection" class="chart-menubar">
			<span>Zoom</span>
			<a href="#" data-hours="24" class="button button-secondary">1d</a>
			<a href="#" data-hours="168" class="button button-secondary">1w</a>
			<a href="#" data-hours="672" class="button button-secondary">4w</a>
			<a href="#" data-hours="0" class="button button-secondary">all</a>
		</div>

		<div id="chart-grouping-selection" class="chart-menubar">
			<span>Unit</span>
			<a href="#" data-hours="1" class="button button-secondary">1h</a>
			<a href="#" data-hours="2" class="button button-secondary">2h</a>
			<!-- <a href="#" data-hours="3" class="button button-secondary">3h</a> -->
			<a href="#" data-hours="4" class="button button-secondary">4h</a>
			<a href="#" data-hours="6" class="button button-secondary">6h</a>
			<a href="#" data-hours="12" class="button button-secondary">12h</a>
			<a href="#" data-hours="24" class="button button-secondary">1d</a>
			<a href="#" data-hours="168" class="button button-secondary">1w</a>
			<a href="#" data-hours="672" class="button button-secondary">4w</a>
		</div>

		<div id="episode-performance-chart" data-episode="<?php 
        echo $episode->id;
        ?>
">
		</div>

		<div id="episode-range-chart"></div>

		<section id="episode-source-chart-wrapper" class="chart-wrapper" data-tile-id="download_source">
			<div id="episode-source-chart">
				<h1>Download Source <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<section id="episode-context-chart-wrapper" class="chart-wrapper" data-tile-id="download_context">
			<div id="episode-context-chart">
				<h1>Download Context <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<section id="episode-asset-chart-wrapper" class="chart-wrapper" data-tile-id="asset">
			<div id="episode-asset-chart">
				<h1>Episode Asset <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<section id="episode-client-chart-wrapper" class="chart-wrapper" data-tile-id="podcast_client">
			<div id="episode-client-chart">
				<h1>Podcast Client <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<section id="episode-system-chart-wrapper" class="chart-wrapper" data-tile-id="operating_system">
			<div id="episode-system-chart">
				<h1>Operating System <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<section id="episode-weekday-chart-wrapper" class="chart-wrapper" data-tile-id="day_of_week">
			<div id="episode-weekday-chart">
				<h1>Day of Week <a href="#" class="reset" style="display: none"><small>reset</small></a></h1>
			</div>
		</section>

		<div style="clear: both"></div>

		<script type="text/javascript">
		var assetNames = <?php 
        $assets = Model\EpisodeAsset::all();
        echo json_encode(array_combine(array_map(function ($a) {
            return $a->id;
        }, $assets), array_map(function ($a) {
            return $a->title;
        }, $assets)));
        ?>
;
		</script>

		<style type="text/css">
		section.chart-wrapper {
			float: left;
			height: 320px;
		}

		section.chart-wrapper h1 {
			font-size: 14px;
			margin-left: 10px;
		}

		section.chart-wrapper div {
			width: 285px;
			height: 285px;
		}

		.chart-wrapper h1, 
		.chart-wrapper h1 small {
			line-height: 19px;
			height: 19px;
		}

		.chart-wrapper h1 a {
			text-decoration: none;
		}

		.chart-menubar:first-child { float: right; }
		.chart-menubar:last-child  { float: left; }

		.chart-menubar span { line-height: 26px; }

		#episode-performance-chart {
			float: none;
			height: 250px
		}

		#episode-range-chart {
			float: none;
			height: 80px;
			margin-top: -15px;
		}

		#episode-source-chart g.row text,
		#episode-context-chart g.row text,
		#episode-weekday-chart g.row text,
		#episode-client-chart g.row text,
		#episode-system-chart g.row text,
		#episode-asset-chart g.row text {
			fill: black;
		}
		</style>

		<?php 
    }
Ejemplo n.º 11
0
 private function form_template($feed, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_feed', 'hidden' => array('feed' => $feed->id, 'action' => $action));
     \Podlove\Form\build_for($feed, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $feed = $form->object;
         $episode_assets = \Podlove\Model\EpisodeAsset::all();
         $assets = array();
         foreach ($episode_assets as $asset) {
             $assets[$asset->id] = $asset->title;
         }
         $wrapper->string('name', array('label' => __('Feed Title', 'podlove'), 'description' => __('Some podcast clients may display this title to describe the feed content.', 'podlove'), 'html' => array('class' => 'regular-text required')));
         $wrapper->checkbox('discoverable', array('label' => __('Discoverable?', 'podlove'), 'description' => __('Embed a meta tag into the head of your site so browsers and feed readers will find the link to the feed.', 'podlove'), 'default' => true));
         // TODO: update url
         $wrapper->string('slug', array('label' => __('Slug', 'podlove'), 'description' => $feed ? sprintf(__('Feed identifier. URL: %s', 'podlove'), $feed->get_subscribe_url()) : '', 'html' => array('class' => 'regular-text required')));
         $wrapper->radio('format', array('label' => __('Format', 'podlove'), 'options' => array('rss' => 'RSS', 'atom' => 'Atom'), 'default' => 'rss'));
         $wrapper->select('episode_asset_id', array('label' => __('Episode Media File', 'podlove'), 'options' => $assets, 'html' => array('class' => 'required')));
         $wrapper->string('itunes_feed_id', array('label' => __('iTunes Feed ID', 'podlove'), 'description' => __('Is used to generate a link to the iTunes directory.', 'podlove'), 'html' => array('class' => 'regular-text')));
         // todo: add PING url; see feedburner doc
         $wrapper->string('redirect_url', array('label' => __('Redirect Url', 'podlove'), 'description' => __('e.g. Feedburner URL', 'podlove'), 'html' => array('class' => 'regular-text')));
         $wrapper->checkbox('enable', array('label' => __('Allow Submission to Directories', 'podlove'), 'description' => __('Allow this feed to appear in podcast directories.', 'podlove'), 'default' => true));
         // TODO: choose description format: empty, simple, full-force
         $wrapper->checkbox('show_description', array('label' => __('Include Description?', 'podlove'), 'description' => __('You may want to hide the episode descriptions to reduce the feed file size.', 'podlove'), 'default' => true));
         // todo include summary?
         $wrapper->string('limit_items', array('label' => __('Limit Items', 'podlove'), 'description' => __('A feed only displays the most recent episodes. Define the amount. Leave empty to use the WordPress default.', 'podlove'), 'html' => array('class' => 'regular-text')));
     });
 }
    private function view_template()
    {
        $table = new \Podlove\Episode_Asset_List_Table();
        $table->prepare_items();
        $table->display();
        ?>
		<h3><?php 
        echo __('Assign Assets', 'podlove');
        ?>
</h3>
		<form method="post" action="options.php">
			<?php 
        settings_fields(EpisodeAsset::$pagehook);
        $asset_assignment = Model\AssetAssignment::get_instance();
        $form_attributes = array('context' => 'podlove_asset_assignment', 'form' => false);
        \Podlove\Form\build_for($asset_assignment, $form_attributes, function ($form) {
            $wrapper = new \Podlove\Form\Input\TableWrapper($form);
            $asset_assignment = $form->object;
            $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(__('Asset: %s', 'podlove'), $episode_asset->title);
                }
            }
            $wrapper->select('image', array('label' => __('Episode Image', 'podlove'), 'options' => $artwork_options));
            $chapter_file_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 === 'chapters') {
                    $chapter_file_options[$episode_asset->id] = sprintf(__('Asset: %s', 'podlove'), $episode_asset->title);
                }
            }
            $wrapper->select('chapters', array('label' => __('Episode Chapters', 'podlove'), 'options' => $chapter_file_options));
            do_action('podlove_asset_assignment_form', $wrapper, $asset_assignment);
        });
        ?>
		</form>
		<?php 
    }
Ejemplo n.º 13
0
    public function modal_box_html()
    {
        $podcast = Model\Podcast::get_instance();
        $episode_assets = Model\EpisodeAsset::all();
        $episode_asset = $episode_assets[0];
        $podcast_data = array('slug' => $podcast->slug, 'name' => $podcast->title, 'next_number' => $this->guess_next_episode_id_for_show(), 'base_url' => $podcast->media_file_base_uri, 'episode_asset' => array('template' => $episode_asset->url_template));
        ?>
		<div id="new-episode-modal" class="hidden wrap" title="Create New Episode">
			<div class="hidden" id="new-episode-podcast-data"><?php 
        echo json_encode($podcast_data);
        ?>
</div>
			<p>
				<div id="titlediv">
					<p>
						<strong>Episode Number</strong>
						<input type="text" name="episode_number" value="<?php 
        echo $this->guess_next_episode_id_for_show();
        ?>
" class="really-huge-text episode_number" autocomplete="off">
					</p>
					<p>
						<strong>Episode Title</strong>
						<input type="text" name="episode_title" value="" class="really-huge-text episode_title" autocomplete="off">
					</p>
					<p class="media_file_info result">
						<strong>Media Files</strong>
						<span class="url">Loading ...</span>
					</p>
					<p class="post_info result">
						<strong>Post Title</strong>
						<span class="post_title" data-template="<?php 
        echo $this->get_module_option('title_template', '%podcast_slug%%episode_number% %episode_title%');
        ?>
">Loading ...</span>
					</p>
				</div>
			</p>
		</div>

		<style type="text/css">
		#new-episode-modal .media_file_info, #new-episode-modal .post_info {
			color: #666;
		}

		#new-episode-modal p.result strong {
			display: inline-block;
			width: 115px;
		}

		#episode_file_slug {
			cursor: pointer;
			font-style: italic;
			color: black;
		}

		#episode_file_slug input {
			width: 70px;
			-webkit-border-radius: 3px;
			border-radius: 3px;
			border-width: 1px;
			border-style: solid;
			border-color: #DFDFDF;
		}

		input.really-huge-text {
			padding: 3px 8px;
			font-size: 1.7em;
			line-height: 100%;
			width: 100%;
		}
		</style>
		<?php 
    }
function migrate_post($post_id)
{
    $post = get_post($post_id);
    $migration_settings = get_option('podlove_migration', array());
    $post_content = $post->post_content;
    if ($migration_settings['cleanup']['player']) {
        $post_content = preg_replace('/\\[(powerpress|podloveaudio|podlovevideo|display_podcast)[^\\]]*\\]/', '', $post_content);
    }
    $new_post = array('menu_order' => $post->menu_order, 'comment_status' => $post->comment_status, 'ping_status' => $post->ping_status, 'post_author' => $post->post_author, 'post_content' => $post_content, 'post_excerpt' => $post->post_excerpt, 'post_mime_type' => $post->post_mime_type, 'post_parent' => $post_id, 'post_password' => $post->post_password, 'post_status' => 'pending', 'post_title' => $post->post_title, 'post_type' => 'podcast', 'post_date' => $post->post_date, 'post_date_gmt' => get_gmt_from_date($post->post_date));
    $new_slug = NULL;
    switch ($migration_settings['post_slug']) {
        case 'wordpress':
            $new_slug = $post->post_name;
            break;
        case 'file':
            $new_slug = Assistant::get_file_slug($post);
            break;
        case 'number':
            $new_slug = Assistant::get_number_slug($post);
            break;
    }
    $override_slug = function ($data, $postarr) use($new_slug) {
        if ($new_slug) {
            $data['post_name'] = $new_slug;
        }
        return $data;
    };
    add_filter('wp_insert_post_data', $override_slug, 10, 2);
    $new_post_id = wp_insert_post($new_post);
    remove_filter('wp_insert_post_data', $override_slug, 10, 2);
    $new_post = get_post($new_post_id);
    // update guid
    update_post_meta($new_post_id, '_podlove_guid', $post->guid);
    // add redirect from previous url
    add_post_meta($new_post_id, 'podlove_alternate_url', get_permalink($post_id));
    // prevent adn module from triggering a post
    update_post_meta($new_post_id, '_podlove_episode_was_published', true);
    // migrate taxonomies
    $taxonomies = get_object_taxonomies(get_post_type($post_id));
    foreach ($taxonomies as $tax) {
        $terms = wp_get_object_terms($post_id, $tax);
        $term = array();
        foreach ($terms as $t) {
            $term[] = $t->slug;
        }
        wp_set_object_terms($new_post_id, $term, $tax);
    }
    $post_data = new Legacy_Post_Parser($post_id);
    $episode = Model\Episode::find_or_create_by_post_id($new_post_id);
    $episode->slug = Assistant::get_episode_slug($post, $migration_settings['slug']);
    $episode->duration = $post_data->get_duration();
    $episode->subtitle = $post_data->get_subtitle();
    $episode->summary = $post_data->get_summary();
    $episode->save();
    foreach (Model\EpisodeAsset::all() as $asset) {
        Model\MediaFile::find_or_create_by_episode_id_and_episode_asset_id($episode->id, $asset->id);
    }
    // copy all meta
    $meta = get_post_meta($post_id);
    foreach ($meta as $key => $values) {
        if (!in_array($key, array('enclosure', '_podPressPostSpecific', '_podPressMedia')) || !$migration_settings['cleanup']['enclosures']) {
            foreach ($values as $value) {
                add_post_meta($new_post_id, $key, $value);
            }
        }
    }
    // copy all comments
    $comments_map = array();
    // map old comment IDs to new comment IDs
    foreach (get_comments(array('post_id' => $post_id, 'order' => 'ASC')) as $comment) {
        $old_comment_id = $comment->comment_ID;
        $comment->comment_post_ID = $new_post_id;
        if ($comment->comment_parent && isset($comments_map[$comment->comment_parent])) {
            $comment->comment_parent = $comments_map[$comment->comment_parent];
        }
        $new_comment_id = wp_insert_comment((array) $comment);
        $comments_map[$old_comment_id] = $new_comment_id;
    }
    return $new_post_id;
}
Ejemplo n.º 15
0
    public function form_fields()
    {
        $formats_data = get_option('podlove_webplayer_formats', array());
        $episode_assets = Model\EpisodeAsset::all();
        foreach (self::formats() as $format => $extensions) {
            ?>
			<tr valign="top">
				<th scope="row" valign="top" colspan="2">
					<h3><?php 
            echo ucfirst($format);
            ?>
</h3>
				</th>
			</tr>
			<?php 
            foreach ($extensions as $extension => $extension_data) {
                $label = $extension_data['title'];
                $mime_types = $extension_data['mime_types'];
                $id = sprintf('podlove_webplayer_formats_%s_%s', $format, $extension);
                $name = sprintf('podlove_webplayer_formats[%s][%s]', $format, $extension);
                $value = isset($formats_data[$format]) && isset($formats_data[$format][$extension]) ? $formats_data[$format][$extension] : 0;
                ?>
				<tr valign="top">
					<th scope="row" valign="top">
						<label for="<?php 
                echo $id;
                ?>
"><?php 
                echo $label;
                ?>
</label>
					</th>
					<td>
						<div>
							<select name="<?php 
                echo $name;
                ?>
" id="<?php 
                echo $id;
                ?>
">
								<option value="0" <?php 
                selected(0, $value);
                ?>
 ><?php 
                echo __('Unused', 'podlove');
                ?>
</option>
								<?php 
                foreach ($episode_assets as $episode_asset) {
                    ?>
									<?php 
                    $file_type = $episode_asset->file_type();
                    ?>
									<?php 
                    if ($file_type && in_array($file_type->mime_type, $mime_types)) {
                        ?>
										<option value="<?php 
                        echo $episode_asset->id;
                        ?>
" <?php 
                        selected($episode_asset->id, $value);
                        ?>
><?php 
                        echo $episode_asset->title;
                        ?>
</option>
									<?php 
                    }
                    ?>
								<?php 
                }
                ?>
							</select>
						</div>
					</td>
				</tr>
				<?php 
            }
        }
        // advanced settings
        $settings = array('inject' => array('label' => __('Insert player automatically', 'podlove'), 'description' => __('Automatically insert web player shortcode at beginning or end of an episode. Alternatvely, use the shortcode <code>[podlove-episode-web-player]</code>.', 'podlove'), 'options' => array('manually' => __('insert manually via shortcode', 'podlove'), 'beginning' => __('insert at the beginning', 'podlove'), 'end' => __('insert at the end', 'podlove'))), 'chaptersVisible' => array('label' => __('Chapters Visibility', 'podlove'), 'options' => array('true' => __('Visible when player loads', 'podlove'), 'false' => __('Hidden when player loads', 'podlove'))), 'version' => array('label' => __('Player Version', 'podlove'), 'options' => array('player_v2' => __('Podlove Web Player 2', 'podlove'), 'player_v3' => __('Podlove Web Player 3 (unstable beta, don\'t use in production)', 'podlove'))));
        ?>
		<tr valign="top">
			<th scope="row" valign="top" colspan="2">
				<h3><?php 
        echo __('Settings', 'podlove');
        ?>
</h3>
			</th>
		</tr>
		<?php 
        foreach ($settings as $setting_key => $field_values) {
            ?>
			<tr class="row_<?php 
            echo $setting_key;
            ?>
">
				<th scope="row" valign="top">
					<?php 
            if (isset($field_values['label']) && $field_values['label']) {
                ?>
						<label for="<?php 
                echo $setting_key;
                ?>
"><?php 
                echo $field_values['label'];
                ?>
</label>
					<?php 
            }
            ?>
				</th>
				<td>
					<select name="podlove_webplayer_settings[<?php 
            echo $setting_key;
            ?>
]" id="<?php 
            echo $setting_key;
            ?>
">
						<?php 
            foreach ($field_values['options'] as $key => $value) {
                ?>
							<option value="<?php 
                echo esc_attr($key);
                ?>
" <?php 
                if ($key == \Podlove\get_webplayer_setting($setting_key)) {
                    ?>
 selected="selected"<?php 
                }
                ?>
><?php 
                echo $value;
                ?>
</option>
						<?php 
            }
            ?>
					</select>
					<?php 
            if (isset($field_values['description']) && $field_values['description']) {
                ?>
						<div class="description"><?php 
                echo $field_values['description'];
                ?>
</div>
					<?php 
            }
            ?>
				</td>
			</tr>
		<?php 
        }
        ?>
		<?php 
    }
Ejemplo n.º 16
0
function create_episode()
{
    $slug = isset($_REQUEST['slug']) ? $_REQUEST['slug'] : NULL;
    $title = isset($_REQUEST['title']) ? $_REQUEST['title'] : NULL;
    if (!$slug || !$title) {
        die;
    }
    $args = array('post_type' => 'podcast', 'post_title' => $title, 'post_content' => \Podlove\Podcast_Post_Type::$default_post_content);
    // create post
    $post_id = wp_insert_post($args);
    // link episode and release
    $episode = \Podlove\Model\Episode::find_or_create_by_post_id($post_id);
    $episode->slug = $slug;
    $episode->enable = true;
    $episode->active = true;
    $episode->save();
    // activate all media files
    $episode_assets = Model\EpisodeAsset::all();
    foreach ($episode_assets as $episode_asset) {
        $media_file = new \Podlove\Model\MediaFile();
        $media_file->episode_id = $episode->id;
        $media_file->episode_asset_id = $episode_asset->id;
        $media_file->save();
    }
    // generate response
    $result = array();
    $result['post_id'] = $post_id;
    $result['post_edit_url'] = get_edit_post_link($post_id);
    header('Cache-Control: no-cache, must-revalidate');
    header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
    header('Content-type: application/json');
    echo json_encode($result);
    die;
}
Ejemplo n.º 17
0
 private function form_template($feed, $action, $button_text = NULL)
 {
     $form_args = array('context' => 'podlove_feed', 'hidden' => array('feed' => $feed->id, 'action' => $action), 'submit_button' => false, 'form_end' => function () {
         echo "<p>";
         submit_button(__('Save Changes'), 'primary', 'submit', false);
         echo " ";
         submit_button(__('Save Changes and Continue Editing', 'podlove'), 'secondary', 'submit_and_stay', false);
         echo "</p>";
     });
     \Podlove\Form\build_for($feed, $form_args, function ($form) {
         $wrapper = new \Podlove\Form\Input\TableWrapper($form);
         $feed = $form->object;
         $podcast = \Podlove\Model\Podcast::get();
         $episode_assets = \Podlove\Model\EpisodeAsset::all();
         $assets = array();
         foreach ($episode_assets as $asset) {
             $assets[$asset->id] = $asset->title;
         }
         $wrapper->subheader(__('Basic Settings', 'podlove'));
         $wrapper->select('episode_asset_id', array('label' => __('Episode Media File', 'podlove') . \Podlove\get_help_link('podlove_help_feed_asset'), 'options' => $assets, 'html' => array('class' => 'required')));
         $wrapper->string('name', array('label' => __('Feed Name', 'podlove'), 'description' => __('Some podcast clients may display this title to describe the feed content.', 'podlove'), 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('append_name_to_podcast_title', array('label' => __('Append Feed Name to Podcast title', 'podlove'), 'description' => sprintf(__('Structure of the feed title. Preview: %s', 'podlove'), $podcast->title . '<span id="feed_title_preview_append"></span>'), 'default' => false));
         $wrapper->string('slug', array('label' => __('Slug', 'podlove') . \Podlove\get_help_link('podlove_help_feed_slug'), 'description' => $feed ? sprintf(__('Feed identifier. URL Preview: %s', 'podlove'), '<span id="feed_subscribe_url_preview">' . $feed->get_subscribe_url() . '</span>') : '', 'html' => array('class' => 'regular-text required podlove-check-input')));
         $wrapper->checkbox('discoverable', array('label' => __('Discoverable?', 'podlove'), 'description' => __('Embed a meta tag into the head of your site so browsers and feed readers will find the link to the feed.', 'podlove'), 'default' => true));
         $wrapper->checkbox('embed_content_encoded', array('label' => __('Include HTML Content', 'podlove'), 'description' => __('Include episode show notes in the feed.', 'podlove'), 'default' => false));
         $wrapper->subheader(__('Directory Settings', 'podlove'));
         $wrapper->checkbox('enable', array('label' => __('Allow Submission to Directories', 'podlove'), 'description' => __('Allow this feed to appear in podcast directories.', 'podlove'), 'default' => true));
         do_action('podlove_feeds_directories', $wrapper);
         $wrapper->string('itunes_feed_id', array('label' => __('iTunes Feed ID', 'podlove'), 'description' => __('Is used to generate a link to the iTunes directory.', 'podlove') . ($feed->itunes_feed_id ? ' <a href="http://itunes.apple.com/podcast/id' . $feed->itunes_feed_id . '" target="_blank">' . __('Open in iTunes directory') . '</a>' : ''), 'html' => array('class' => 'regular-text podlove-check-input')));
         $wrapper->subheader(__('Advanced Settings', 'podlove'));
         $wrapper->select('redirect_http_status', array('label' => __('Redirect Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Don\'t redirect', '307' => 'Temporary Redirect (HTTP Status 307)', '301' => 'Permanent Redirect (HTTP Status 301)'), 'default' => 0, 'please_choose' => false));
         $wrapper->string('redirect_url', array('label' => __('Redirect Url', 'podlove'), 'description' => __('e.g. Feedburner URL', 'podlove'), 'html' => array('class' => 'regular-text podlove-check-input', 'data-podlove-input-type' => 'url')));
         $podcast_settings = get_option('podlove_podcast');
         if ($podcast_settings['limit_items'] < 0) {
             $limit_default = 'No limit';
         } else {
             $limit_default = $podcast_settings['limit_items'];
         }
         $limit_options = array('-2' => __("Use Podlove default (" . $limit_default . ")", 'podlove'), '-1' => __("No limit. Include all items.", 'podlove'), '0' => __('Use WordPress Default', 'podlove') . ' (' . get_option('posts_per_rss') . ')');
         for ($i = 1; $i * 5 <= 100; $i++) {
             $limit_options[$i * 5] = $i * 5;
         }
         $wrapper->select('limit_items', array('label' => __('Limit Items', 'podlove'), 'description' => __('If you have a lot of episodes, you might want to restrict the feed size.', 'podlove'), 'options' => $limit_options, 'please_choose' => false, 'default' => '-2'));
         $wrapper->subheader(__('Protection', 'podlove'));
         $wrapper->checkbox('protected', array('label' => __('Protect feed ', 'podlove'), 'description' => __('The feed will be protected by HTTP Basic Authentication.', 'podlove'), 'default' => false));
         $wrapper->select('protection_type', array('label' => __('Method', 'podlove'), 'description' => __('', 'podlove'), 'options' => array('0' => 'Custom Login', '1' => 'WordPress User database'), 'default' => -1, 'please_choose' => true));
         $wrapper->string('protection_user', array('label' => __('Username', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         $wrapper->string('protection_password', array('label' => __('Password', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text required')));
         do_action('podlove_feed_settings_bottom', $wrapper);
     });
 }