/** * Meta Box Template */ public static function post_type_meta_box_callback($post) { $post_id = $post->ID; $podcast = Model\Podcast::get_instance(); $episode = Model\Episode::find_or_create_by_post_id($post_id); wp_nonce_field(\Podlove\PLUGIN_FILE, 'podlove_noncename'); ?> <input type="hidden" name="show-media-file-base-uri" value="<?php echo $podcast->media_file_base_uri; ?> " /> <table class="form-table"> <?php $form_args = array('context' => '_podlove_meta', 'submit_button' => false, 'form' => false); \Podlove\Form\build_for($episode, $form_args, function ($form) use($podcast) { $wrapper = new \Podlove\Form\Input\TableWrapper($form); $episode = $form->object; $wrapper->checkbox('active', array('label' => __('Post Episode to Show', 'podlove'), 'description' => '', 'default' => true)); $wrapper->string('slug', array('label' => __('Episode Media File Slug', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text'))); // TODO: validate and parse $wrapper->string('duration', array('label' => __('Duration', 'podlove'), 'description' => '', 'html' => array('class' => 'regular-text'))); $wrapper->string('subtitle', array('label' => __('Subtitle', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text'))); $wrapper->text('summary', array('label' => __('Summary', 'podlove'), 'description' => '', 'html' => array('class' => 'large-text', 'rows' => max(2, count(explode("\n", $episode->summary)))))); if ($podcast->supports_cover_art === 'manual') { $wrapper->string('cover_art', array('label' => __('Episode Cover Art URL', 'podlove'), 'description' => __('JPEG or PNG. At least 1400 x 1400 pixels.', 'podlove'), 'html' => array('class' => 'regular-text'))); } $wrapper->text('chapters', array('label' => __('Chapter Marks', 'podlove'), 'description' => __('One timepoint (hh:mm:ss[.mmm]) and the chapter title per line.', 'podlove'), 'html' => array('class' => 'large-text code', 'placeholder' => '00:00:00.000 Intro', 'rows' => max(2, count(explode("\n", $episode->chapters)))))); $wrapper->checkbox('enable', array('label' => __('Enable?', 'podlove'), 'description' => __('Allow this episode to appear in podcast directories.', 'podlove'), 'default' => true)); // TODO: button to update // TODO: pretty display // TODO: don't display link // TODO: display last modified from header $wrapper->multiselect('episode_assets', Podcast_Post_Meta_Box::episode_assets_form($episode)); }); ?> </table> <?php }
/** * Meta Box Template */ public static function post_type_meta_box_callback($post) { $post_id = $post->ID; $podcast = Model\Podcast::get(); $episode = Model\Episode::find_or_create_by_post_id($post_id); wp_nonce_field(\Podlove\PLUGIN_FILE, 'podlove_noncename'); ?> <?php do_action('podlove_episode_meta_box_start'); ?> <input type="hidden" name="show-media-file-base-uri" value="<?php echo $podcast->media_file_base_uri; ?> " /> <div class="podlove-div-wrapper-form"> <?php $form_args = array('context' => '_podlove_meta', 'submit_button' => false, 'form' => false, 'is_table' => false); $form_data = self::get_form_data($episode); \Podlove\Form\build_for($episode, $form_args, function ($form) use($podcast, $form_data) { $wrapper = new \Podlove\Form\Input\DivWrapper($form); $episode = $form->object; foreach ($form_data as $entry) { $wrapper->{$entry['type']}($entry['key'], $entry['options']); } }); ?> </div> <?php do_action('podlove_episode_meta_box_end'); ?> <?php }
function activate_for_current_blog() { Model\Feed::build(); Model\FileType::build(); Model\EpisodeAsset::build(); Model\MediaFile::build(); Model\Episode::build(); Model\Template::build(); Model\DownloadIntent::build(); Model\DownloadIntentClean::build(); Model\UserAgent::build(); Model\GeoArea::build(); Model\GeoAreaName::build(); \podlove_init_capabilities(); if (!Model\FileType::has_entries()) { $default_types = array(array('name' => 'MP3 Audio', 'type' => 'audio', 'mime_type' => 'audio/mpeg', 'extension' => 'mp3'), array('name' => 'BitTorrent (MP3 Audio)', 'type' => 'audio', 'mime_type' => 'application/x-bittorrent', 'extension' => 'mp3.torrent'), array('name' => 'MPEG-1 Video', 'type' => 'video', 'mime_type' => 'video/mpeg', 'extension' => 'mpg'), array('name' => 'MPEG-4 AAC Audio', 'type' => 'audio', 'mime_type' => 'audio/mp4', 'extension' => 'm4a'), array('name' => 'MPEG-4 ALAC Audio', 'type' => 'audio', 'mime_type' => 'audio/mp4', 'extension' => 'm4a'), array('name' => 'MPEG-4 Video', 'type' => 'video', 'mime_type' => 'video/mp4', 'extension' => 'mp4'), array('name' => 'M4V Video (Apple)', 'type' => 'video', 'mime_type' => 'video/x-m4v', 'extension' => 'm4v'), array('name' => 'Ogg Vorbis Audio', 'type' => 'audio', 'mime_type' => 'audio/ogg', 'extension' => 'oga'), array('name' => 'Ogg Vorbis Audio', 'type' => 'audio', 'mime_type' => 'audio/ogg', 'extension' => 'ogg'), array('name' => 'Ogg Theora Video', 'type' => 'video', 'mime_type' => 'video/ogg', 'extension' => 'ogv'), array('name' => 'WebM Audio', 'type' => 'audio', 'mime_type' => 'audio/webm', 'extension' => 'webm'), array('name' => 'WebM Video', 'type' => 'video', 'mime_type' => 'video/webm', 'extension' => 'webm'), array('name' => 'FLAC Audio', 'type' => 'audio', 'mime_type' => 'audio/flac', 'extension' => 'flac'), array('name' => 'Opus Audio', 'type' => 'audio', 'mime_type' => 'audio/ogg;codecs=opus', 'extension' => 'opus'), array('name' => 'Matroska Audio', 'type' => 'audio', 'mime_type' => 'audio/x-matroska', 'extension' => 'mka'), array('name' => 'Matroska Video', 'type' => 'video', 'mime_type' => 'video/x-matroska', 'extension' => 'mkv'), 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'), array('name' => 'mp4chaps Chapter File', 'type' => 'chapters', 'mime_type' => 'text/plain', 'extension' => 'chapters.txt'), array('name' => 'Podlove Simple Chapters', 'type' => 'chapters', 'mime_type' => 'application/xml', 'extension' => 'psc'), array('name' => 'Subrip Captions', 'type' => 'captions', 'mime_type' => 'application/x-subrip', 'extension' => 'srt'), array('name' => 'WebVTT Captions', 'type' => 'captions', 'mime_type' => 'text/vtt', 'extension' => 'vtt'), array('name' => 'Auphonic Production Description', 'type' => 'metadata', 'mime_type' => 'application/json', 'extension' => 'json')); foreach ($default_types as $file_type) { $f = new Model\FileType(); foreach ($file_type as $key => $value) { $f->{$key} = $value; } $f->save(); } } $podcast = Model\Podcast::get(); if (!$podcast->limit_items) { $podcast->limit_items = Model\Feed::ITEMS_NO_LIMIT; } $podcast->save(); // required for all module hooks to fire correctly add_option('podlove_active_modules', []); // set default modules $default_modules = array('logging', 'podlove_web_player', 'open_graph', 'asset_validation', 'oembed', 'feed_validation', 'import_export', 'subscribe_button'); foreach ($default_modules as $module) { \Podlove\Modules\Base::activate($module); } // set default expert settings $settings = get_option('podlove', array()); if ($settings === array()) { $settings = array('merge_episodes' => 'on', 'hide_wp_feed_discovery' => 'off', 'use_post_permastruct' => 'on', 'episode_archive' => 'on', 'episode_archive_slug' => '/podcast/', 'custom_episode_slug' => '/podcast/%podcast%/'); update_option('podlove', $settings); } // set default template if (!($template = Model\Template::find_one_by_property('title', 'default'))) { $template = new Model\Template(); $template->title = 'default'; $template->content = <<<EOT {% if not is_feed() %} \t{# display web player for episode #} \t{{ episode.player }} \t \t{# display download menu for episode #} \t{% include "@core/shortcode/downloads-select.twig" %} {% endif %} EOT; $template->save(); $assignment = Model\TemplateAssignment::get_instance(); $assignment->top = $template->id; $assignment->save(); } }
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(); }
/** * Get Podlove podcast template object. * * @param int $blog_id Optional. Blog ID. Defaults to global $blog_id. * @return \Podlove\Template\Podcast */ function get_podcast($blog_id = null) { return new Template\Podcast(Model\Podcast::get($blog_id)); }