/** * Get Feed Information (Size (gzip) and Last Modifcation) */ public static function getInformation($feedid, $redirected = FALSE) { $feed = \Podlove\Model\Feed::find_by_id($feedid); $source = self::getSource($feedid, $redirected); $feed_header = $source['headers']; $feed_body = $source['body']; $feed_items = $feed->post_ids(); $last_modification = \Podlove\relative_time_steps(strtotime(isset($feed_header['last-modified']) ? $feed_header['last-modified'] : 0)); $size = \Podlove\format_bytes(strlen($feed_body)); if (extension_loaded('zlib')) { $size .= " (" . \Podlove\format_bytes(strlen(gzdeflate($feed_body, 9))) . ")"; } if ($redirected === FALSE) { $latest_item = "<a href=\"" . get_permalink($feed_items[0]) . "\">" . get_the_title($feed_items[0]) . "</a>"; } else { // Fetch latest item from source of redirected feed $start_item_tag = strpos($feed_body, '<item'); $end_item_tag = strpos($feed_body, '</item>'); $first_item = substr($feed_body, $start_item_tag + 7, $end_item_tag - $start_item_tag); $start_title_tag = strpos($first_item, '<title'); $end_title_tag = strpos($first_item, '</title>'); $start_link_tag = strpos($first_item, '<link'); $end_link_tag = strpos($first_item, '</link>'); $title = substr($first_item, $start_title_tag + 7, $end_title_tag - $start_title_tag - 7); $permalink = substr($first_item, $start_link_tag + 6, $end_link_tag - $start_link_tag - 7); $latest_item = "<a href=\"" . $permalink . "\">" . $title . "</a>"; } return array('size' => $size, 'last_modification' => $last_modification, 'latest_item' => $latest_item); }
public function column_latest_episode($podcast) { return $podcast->with_blog_scope(function () { if ($latest_episode = Episode::latest()) { $latest_episode_blog_post = get_post($latest_episode->post_id); return "<a title='Published on " . date('Y-m-d h:i:s', strtotime($latest_episode_blog_post->post_date)) . "' href='" . admin_url() . "post.php?post=" . $latest_episode->post_id . "&action=edit'>" . $latest_episode_blog_post->post_title . "</a>" . "<br />" . \Podlove\relative_time_steps(strtotime($latest_episode_blog_post->post_date)); } else { return "—"; } }); }