public function was_deactivated()
 {
     $feeds = \Podlove\Model\Feed::all("WHERE `bitlove` = '1'");
     foreach ($feeds as $feed) {
         delete_transient("podlove_bitlove_feed_url_" . $feed->id);
     }
 }
 /**
  * Ping hub for every feed.
  *
  * @todo do it in a wp cron for more faster UX
  * @todo subscribe url or redirect=no url?
  */
 public function announce_feed_changes($post_ID, $post)
 {
     if (get_post_type($post) !== 'podcast') {
         return;
     }
     foreach (Model\Feed::all() as $feed) {
         $this->send_ping($feed->get_subscribe_url());
     }
 }
示例#3
0
文件: atom.php 项目: rthees/podlove
    public function __construct($feed_slug)
    {
        add_action('atom_ns', function () {
            echo 'xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd"';
        });
        add_filter('feed_link', function ($output, $feed) use($feed_slug) {
            return get_bloginfo('url') . '/feed/' . $feed_slug . '/';
        }, 10, 2);
        $podcast = Model\Podcast::get_instance();
        $feed = Model\Feed::find_one_by_slug($feed_slug);
        $episode_asset = $feed->episode_asset();
        $file_type = $episode_asset->file_type();
        add_filter('podlove_feed_enclosure', function ($enclosure, $enclosure_url, $enclosure_file_size, $mime_type) {
            return sprintf('<link rel="enclosure" href="%s" length="%s" type="%s"/>', $enclosure_url, $enclosure_file_size, $mime_type);
        }, 10, 4);
        mute_feed_title();
        override_feed_title($feed);
        override_feed_language($feed);
        override_feed_head('atom_head', $podcast, $feed, $file_type);
        override_feed_entry('atom_entry', $podcast, $feed, $file_type);
        add_action('atom_head', function () use($podcast, $feed, $file_type) {
            ?>
			<link rel="self" type="application/atom+xml" title="<?php 
            echo $feed->title_for_discovery();
            ?>
" href="<?php 
            echo $feed->get_subscribe_url();
            ?>
" />
			<?php 
            $feeds = Model\Feed::all();
            foreach ($feeds as $other_feed) {
                if ($other_feed->id !== $feed->id) {
                    ?>
					<link rel="alternate" type="application/atom+xml" title="<?php 
                    echo $other_feed->title_for_discovery();
                    ?>
" href="<?php 
                    echo $other_feed->get_subscribe_url();
                    ?>
" />
					<?php 
                }
            }
        }, 9);
        $this->do_feed($feed);
    }
 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();
     }
 }
示例#5
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\Feed::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 function prepare_items()
 {
     // number of items per page
     $per_page = get_user_meta(get_current_user_id(), 'podlove_feeds_per_page', true);
     if (empty($per_page)) {
         $per_page = 10;
     }
     // define column headers
     $this->_column_headers = $this->get_column_info();
     // retrieve data
     $data = \Podlove\Model\Feed::all('ORDER BY position ASC');
     // 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)));
 }
 /**
  * Renew Transients
  */
 public function renewFeedTransients()
 {
     foreach (\Podlove\Model\Feed::all() as $feed_key => $feed) {
         set_transient('podlove_dashboard_feed_information_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getInformation($feed->id), 3600 * 24);
         set_transient('podlove_dashboard_feed_validation_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationIcon($feed->id), 3600 * 24);
         if ($feed->redirect_http_status == '403' || $feed->redirect_http_status == '307') {
             set_transient('podlove_dashboard_feed_r_information_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getInformation($feed->id, TRUE), 3600 * 24);
             set_transient('podlove_dashboard_feed_r_validation_' . $feed->id, \Podlove\Modules\FeedValidation\Model\FeedValidator::getValidationIcon($feed->id, TRUE), 3600 * 24);
         }
     }
 }
        status_header(200);
        RSS::prepare_feed($feed->slug);
    }
}
# Prio 11 so it hooks *after* the domain mapping plugin.
# This is important when one moves a domain. That way the domain gets
# remapped/redirected correctly by the domain mapper before being redirected by us.
add_action('template_redirect', '\\Podlove\\Feeds\\handle_feed_proxy_redirects', 11);
function generate_podcast_feed()
{
    remove_podPress_hooks();
    remove_powerPress_hooks();
    RSS::render();
}
add_action('init', function () {
    foreach (Model\Feed::all() as $feed) {
        if ($feed->slug) {
            add_feed($feed->slug, "\\Podlove\\Feeds\\generate_podcast_feed");
        }
    }
    // changing feed settings may affect permalinks, so we need to flush
    if (isset($_REQUEST['page']) && $_REQUEST['page'] == 'podlove_feeds_settings_handle') {
        set_transient('podlove_needs_to_flush_rewrite_rules', true);
    }
});
function override_feed_item_limit($limits)
{
    global $wp_query;
    if (!is_feed()) {
        return $limits;
    }
    /**
     * Validate Feeds and show appropriate error messages.
     */
    private function validate_feeds()
    {
        $errors = [];
        // check for missing mandatory fields
        foreach (Model\Feed::all() as $feed) {
            if (!strlen(trim($feed->slug))) {
                $errors[] = sprintf(__('The feed %s has no slug.', 'podlove'), '<strong>' . $feed->name . '</strong>') . \Podlove\get_help_link('podlove_help_feed_slug') . ' ' . self::get_action_link($feed, __('Go fix it', 'podlove'));
            }
            if (!$feed->episode_asset_id) {
                $errors[] = sprintf(__('The feed %s has no assigned asset.', 'podlove'), '<strong>' . $feed->name . '</strong>') . \Podlove\get_help_link('podlove_help_feed_asset') . ' ' . self::get_action_link($feed, __('Go fix it', 'podlove'));
            }
        }
        // check for duplicate slugs
        foreach (Model\Feed::find_duplicate_slugs() as $duplicate) {
            $feeds = array_map(function ($feed_id) {
                return Model\Feed::find_by_id($feed_id);
            }, $duplicate['feed_ids']);
            $feed_links = array_map(function ($feed) {
                return self::get_action_link($feed, $feed->name);
            }, $feeds);
            $errors[] = sprintf(__('Some feeds (%s) use identical slugs. Please assign unique slugs.'), implode(', ', $feed_links)) . \Podlove\get_help_link('podlove_help_feed_slug');
        }
        if (count($errors)) {
            ?>
			<div class="error">
				<p>
					<strong><?php 
            echo __('Please resolve these issues so your feeds can work.', 'podlove');
            ?>
</strong>
				</p>
				<p>
					<?php 
            echo implode("</p><p>", $errors);
            ?>
				</p>
			</div>
			<?php 
        }
    }