本文整理汇总了PHP中feed_content_type函数的典型用法代码示例。如果您正苦于以下问题:PHP feed_content_type函数的具体用法?PHP feed_content_type怎么用?PHP feed_content_type使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了feed_content_type函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upcoming_events
function upcoming_events()
{
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$xml = new DomDocument();
$xml->loadXML($this->get_upcoming_events());
echo $xml->saveXML();
}
示例2: memberful_private_user_feed_deliver
/**
* Deliver the Memberful Private User Feed.
* This Function should be used only within the "init" wordpress hook.
*/
function memberful_private_user_feed_deliver()
{
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
memberful_private_user_feed_disable_caching();
require MEMBERFUL_DIR . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'private_user_feed_content.php';
exit;
}
示例3: rss_feed
public function rss_feed()
{
global $CP_Smarty;
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
echo $CP_Smarty->smarty->fetch('rss.html');
exit;
}
示例4: replyToLoadRSS2Feed
/**
*
* @since 3.1.0
*/
public function replyToLoadRSS2Feed()
{
$_aArguments = $_GET;
$_aArguments['template_path'] = AmazonAutoLinks_Registry::$sDirPath . '/template/rss2/template.php';
$_aArguments['credit_link'] = false;
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
AmazonAutoLinks($_aArguments, true);
exit;
}
示例5: feed_link
/**
* Print the feed link tag.
*/
public function feed_link()
{
$post_title = self::feed_title();
$feed_link = LivePress_Updater::instance()->get_current_post_feed_link();
if (count($feed_link) > 0) {
$tag = '<link rel="alternate" type="' . esc_attr(feed_content_type('rss2')) . '" ';
$tag .= 'title="' . esc_attr(get_bloginfo('name')) . ' » ' . esc_attr($post_title) . '" ';
$tag .= 'href="' . esc_url($feed_link[0]) . '" />' . "\n";
echo $tag;
}
}
示例6: link_library_generate_rss_feed
function link_library_generate_rss_feed()
{
require_once plugin_dir_path(__FILE__) . 'rss.genesis.php';
global $wpdb;
if (isset($_GET['settingsset']) && !empty($_GET['settingsset'])) {
$settingsetid = intval($_GET['settingsset']);
} else {
$settingsetid = 1;
}
$settingsname = 'LinkLibraryPP' . $settingsetid;
$options = get_option($settingsname);
$rss = new rssGenesis();
$feedtitle = $options['rssfeedtitle'] == "" ? "Link Library Generated Feed" : $options['rssfeedtitle'];
$feeddescription = $options['rssfeeddescription'] == "" ? "Link Library Generated Feed Description" : $options['rssfeeddescription'];
// CHANNEL
$rss->setChannel($feedtitle, home_url() . '/feed/linklibraryfeed?settingsset=' . $settingsetid, $feeddescription, null, null, null, null, null, "auto", "auto", "Link Library Links", null, null, null, null);
$linkquery = "SELECT distinct *, UNIX_TIMESTAMP(l.link_updated) as link_date ";
$linkquery .= "FROM " . $wpdb->prefix . "terms t ";
$linkquery .= "LEFT JOIN " . $wpdb->prefix . "term_taxonomy tt ON (t.term_id = tt.term_id) ";
$linkquery .= "LEFT JOIN " . $wpdb->prefix . "term_relationships tr ON (tt.term_taxonomy_id = tr.term_taxonomy_id) ";
$linkquery .= "LEFT JOIN " . $wpdb->prefix . "links l ON (tr.object_id = l.link_id) ";
$linkquery .= "WHERE tt.taxonomy = 'link_category' ";
if ($options['hide_if_empty']) {
$linkquery .= "AND l.link_id is not NULL AND l.link_description not like '%LinkLibrary:AwaitingModeration:RemoveTextToApprove%' ";
}
if ($options['categorylist'] != "") {
$linkquery .= " AND t.term_id in (" . $options['categorylist'] . ")";
}
if ($options['excludecategorylist'] != "") {
$linkquery .= " AND t.term_id not in (" . $options['excludecategorylist'] . ")";
}
if ($options['showinvisible'] == false) {
$linkquery .= " AND l.link_visible != 'N'";
}
$linkquery .= " ORDER by link_date DESC";
$linkquery .= " LIMIT 0, " . $options['numberofrssitems'];
$linkitems = $wpdb->get_results($linkquery);
if ($linkitems) {
foreach ($linkitems as $linkitem) {
if ($linkitem->link_url != '') {
// ITEM
$rss->addItem($linkitem->link_name, $linkitem->link_url, $linkitem->link_description, $linkitem->link_updated, $linkitem->name);
}
}
}
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'));
print $rss->getFeed();
exit;
}
示例7: generate_edition_atom_feed
function generate_edition_atom_feed($edition_id, $include_hidden = false, $search_term = null)
{
// Check it exists
$edition = get_post($edition_id);
if (empty($edition)) {
header('HTTP/1.1 404 Not Found');
exit;
}
pugpig_remove_wordpress_headers();
$modified = pugpig_get_page_modified($edition);
if ($search_term) {
$modified = time();
}
if ($edition->post_status != 'publish') {
if (FALSE && !pugpig_is_internal_user()) {
header('HTTP/1.1 403 Forbidden');
exit;
}
header('X-Pugpig-Status: unpublished');
pugpig_set_cache_headers($modified, 0);
} else {
header('X-Pugpig-Status: published');
pugpig_set_cache_headers($modified, pugpig_get_feed_ttl());
}
$x_entitlement = pugpig_get_edition_entitlement_header($edition);
if (!empty($x_entitlement)) {
header('X-Pugpig-Entitlement: ' . $x_entitlement);
}
$links = pugpig_get_edition_atom_links($edition, true);
header('Content-Type: ' . feed_content_type('atom') . '; charset=' . get_option('blog_charset'), true);
header('Content-Disposition: inline');
global $wp_query;
$filter = "";
$regions = pugpig_get_available_region_array();
foreach (array_keys($regions) as $region) {
if (isset($wp_query->query_vars[$region . "_pugpig_atom_contents_manifest"])) {
$filter = $region;
}
}
$region = "";
$d = pugpig_get_atom_container($edition_id, $include_hidden, $search_term, $links, $filter);
$d->formatOutput = true;
echo $d->saveXML();
}
示例8: print_eventlist_feed
public function print_eventlist_feed()
{
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$events = $this->db->get_events($this->options->get('el_feed_upcoming_only') ? 'upcoming' : null);
// Print feeds
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
>
<channel>
<title>' . get_bloginfo_rss('name') . '</title>
<atom:link href="' . apply_filters('self_link', get_bloginfo()) . '" rel="self" type="application/rss+xml" />
<link>' . get_bloginfo_rss('url') . '</link>
<description>' . __('Eventlist') . '</description>
<lastBuildDate>' . mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false) . '</lastBuildDate>
<language>' . get_option('rss_language') . '</language>
<sy:updatePeriod>' . apply_filters('rss_update_period', 'hourly') . '</sy:updatePeriod>
<sy:updateFrequency>' . apply_filters('rss_update_frequency', '1') . '</sy:updateFrequency>
';
do_action('rss2_head');
if (!empty($events)) {
foreach ($events as $event) {
echo '
<item>
<title>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' - ' . $event->title) . '</title>
<pubDate>' . mysql2date('D, d M Y H:i:s +0000', $event->start_date, false) . '</pubDate>
<description>' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . '</description>
' . ('' != $event->details ? '<content:encoded><![CDATA[' . esc_attr($this->format_date($event->start_date, $event->end_date) . ' ' . ('' != $event->time ? $event->time : '') . ('' != $event->location ? ' - ' . $event->location : '')) . $event->details . ']]></content:encoded>' : '') . '
</item>';
}
}
echo '
</channel>
</rss>';
}
示例9: bbp_display_replies_feed_rss2
/**
* Output an RSS2 feed of replies, based on the query passed.
*
* @since bbPress (r3171)
*
* @uses bbp_version()
* @uses bbp_is_single_topic()
* @uses bbp_user_can_view_forum()
* @uses bbp_get_topic_forum_id()
* @uses bbp_show_load_topic()
* @uses bbp_topic_permalink()
* @uses bbp_topic_title()
* @uses bbp_get_topic_reply_count()
* @uses bbp_topic_content()
* @uses bbp_has_replies()
* @uses bbp_replies()
* @uses bbp_the_reply()
* @uses bbp_reply_url()
* @uses bbp_reply_title()
* @uses bbp_reply_content()
* @uses get_wp_title_rss()
* @uses get_option()
* @uses bloginfo_rss
* @uses self_link()
* @uses the_author()
* @uses get_post_time()
* @uses rss_enclosure()
* @uses do_action()
* @uses apply_filters()
*
* @param array $replies_query
*/
function bbp_display_replies_feed_rss2($replies_query = array())
{
// User cannot access forum this topic is in
if (bbp_is_single_topic() && !bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
return;
}
// Adjust the title based on context
if (bbp_is_single_topic() && bbp_user_can_view_forum(array('forum_id' => bbp_get_topic_forum_id()))) {
$title = apply_filters('wp_title_rss', get_wp_title_rss(' » '));
} elseif (!bbp_show_lead_topic()) {
$title = ' » ' . __('All Posts', 'bbpress');
} else {
$title = ' » ' . __('All Replies', 'bbpress');
}
// Display the feed
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
header('Status: 200 OK');
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
<?php
do_action('bbp_feed');
?>
>
<channel>
<title><?php
bloginfo_rss('name');
echo $title;
?>
</title>
<atom:link href="<?php
self_link();
?>
" rel="self" type="application/rss+xml" />
<link><?php
self_link();
?>
</link>
<description><?php
//
?>
</description>
<pubDate><?php
echo mysql2date('D, d M Y H:i:s O', current_time('mysql'), false);
?>
</pubDate>
<generator>http://bbpress.org/?v=<?php
bbp_version();
?>
</generator>
<language><?php
bloginfo_rss('language');
?>
</language>
<?php
do_action('bbp_feed_head');
?>
<?php
if (bbp_is_single_topic()) {
//.........这里部分代码省略.........
示例10: send_headers
/**
* Sends additional HTTP headers for caching, content type, etc.
*
* Sets the Content-Type header. Sets the 'error' status (if passed) and optionally exits.
* If showing a feed, it will also send Last-Modified, ETag, and 304 status if needed.
*
* @since 2.0.0
* @since 4.4.0 `X-Pingback` header is added conditionally after posts have been queried in handle_404().
* @access public
*/
public function send_headers()
{
$headers = array();
$status = null;
$exit_required = false;
if (is_user_logged_in()) {
$headers = array_merge($headers, wp_get_nocache_headers());
}
if (!empty($this->query_vars['error'])) {
$status = (int) $this->query_vars['error'];
if (404 === $status) {
if (!is_user_logged_in()) {
$headers = array_merge($headers, wp_get_nocache_headers());
}
$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
} elseif (in_array($status, array(403, 500, 502, 503))) {
$exit_required = true;
}
} elseif (empty($this->query_vars['feed'])) {
$headers['Content-Type'] = get_option('html_type') . '; charset=' . get_option('blog_charset');
} else {
// Set the correct content type for feeds
$type = $this->query_vars['feed'];
if ('feed' == $this->query_vars['feed']) {
$type = get_default_feed();
}
$headers['Content-Type'] = feed_content_type($type) . '; charset=' . get_option('blog_charset');
// We're showing a feed, so WP is indeed the only thing that last changed
if (!empty($this->query_vars['withcomments']) || false !== strpos($this->query_vars['feed'], 'comments-') || empty($this->query_vars['withoutcomments']) && (!empty($this->query_vars['p']) || !empty($this->query_vars['name']) || !empty($this->query_vars['page_id']) || !empty($this->query_vars['pagename']) || !empty($this->query_vars['attachment']) || !empty($this->query_vars['attachment_id']))) {
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastcommentmodified('GMT'), 0) . ' GMT';
} else {
$wp_last_modified = mysql2date('D, d M Y H:i:s', get_lastpostmodified('GMT'), 0) . ' GMT';
}
$wp_etag = '"' . md5($wp_last_modified) . '"';
$headers['Last-Modified'] = $wp_last_modified;
$headers['ETag'] = $wp_etag;
// Support for Conditional GET
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])) {
$client_etag = wp_unslash($_SERVER['HTTP_IF_NONE_MATCH']);
} else {
$client_etag = false;
}
$client_last_modified = empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? '' : trim($_SERVER['HTTP_IF_MODIFIED_SINCE']);
// If string is empty, return 0. If not, attempt to parse into a timestamp
$client_modified_timestamp = $client_last_modified ? strtotime($client_last_modified) : 0;
// Make a timestamp for our most recent modification...
$wp_modified_timestamp = strtotime($wp_last_modified);
if ($client_last_modified && $client_etag ? $client_modified_timestamp >= $wp_modified_timestamp && $client_etag == $wp_etag : $client_modified_timestamp >= $wp_modified_timestamp || $client_etag == $wp_etag) {
$status = 304;
$exit_required = true;
}
}
/**
* Filter the HTTP headers before they're sent to the browser.
*
* @since 2.8.0
*
* @param array $headers The list of headers to be sent.
* @param WP $this Current WordPress environment instance.
*/
$headers = apply_filters('wp_headers', $headers, $this);
if (!empty($status)) {
status_header($status);
}
// If Last-Modified is set to false, it should not be sent (no-cache situation).
if (isset($headers['Last-Modified']) && false === $headers['Last-Modified']) {
unset($headers['Last-Modified']);
// In PHP 5.3+, make sure we are not sending a Last-Modified header.
if (function_exists('header_remove')) {
@header_remove('Last-Modified');
} else {
// In PHP 5.2, send an empty Last-Modified header, but only as a
// last resort to override a header already sent. #WP23021
foreach (headers_list() as $header) {
if (0 === stripos($header, 'Last-Modified')) {
$headers['Last-Modified'] = '';
break;
}
}
}
}
foreach ((array) $headers as $name => $field_value) {
@header("{$name}: {$field_value}");
}
if ($exit_required) {
exit;
}
/**
* Fires once the requested HTTP headers for caching, content type, etc. have been sent.
*
//.........这里部分代码省略.........
示例11: wp_rss_multi_importer_feed
//.........这里部分代码省略.........
if ($sortDir == 1) {
for ($i = $maxfeed - 1; $i >= $maxfeed - $maxposts; $i--) {
$item = $feed->get_item($i);
if (empty($item)) {
continue;
}
$myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_description());
}
} else {
for ($i = 0; $i <= $maxposts - 1; $i++) {
$item = $feed->get_item($i);
if (empty($item)) {
continue;
}
$myarray[] = array("mystrdate" => strtotime($item->get_date()), "mytitle" => $item->get_title(), "mylink" => $item->get_link(), "myGroup" => $feeditem["FeedName"], "mydesc" => $item->get_description());
}
}
}
if ($cacheMin !== 0) {
set_transient($cachename, $myarray, 60 * $cacheMin);
// added for transient cache
}
}
// added for transient cache
if ($timerstop == 1) {
timer_stop(1);
echo ' seconds<br>';
//TIMER END for testing purposes
}
// CHECK $myarray BEFORE DOING ANYTHING ELSE //
if ($dumpthis == 1) {
var_dump($myarray);
}
if (!isset($myarray) || empty($myarray)) {
return "There is a problem with the feeds you entered. Go to our <a href='http://www.allenweiss.com/wp_plugin'>support page</a> and we'll help you diagnose the problem.";
exit;
}
//$myarrary sorted by mystrdate
foreach ($myarray as $key => $row) {
$dates[$key] = $row["mystrdate"];
}
//SORT, DEPENDING ON SETTINGS
if ($sortDir == 1) {
array_multisort($dates, SORT_ASC, $myarray);
} else {
array_multisort($dates, SORT_DESC, $myarray);
}
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
?>
<rss version="2.0">
<channel>
<title><?php
echo $feed_options['feedtitle'];
?>
</title>
<link></link>
<description><?php
echo $feed_options['feeddesc'];
?>
</description>
<language>en-us</language>
<?php
$total = 0;
foreach ($myarray as $items) {
$total = $total + 1;
if ($total > 20) {
break;
}
?>
<item>
<title><?php
echo $items["mytitle"];
?>
</title>
<link><?php
echo $items["mylink"];
?>
</link>
<description><?php
echo '<![CDATA[' . rss_text_limit($feed_options['striptags'], $items["mydesc"], 500) . '<br/><br/>Keep on reading: <a href="' . $items["mylink"] . '">' . $items["mytitle"] . '</a>' . ']]>';
?>
</description>
<pubdate><?php
echo date_i18n("D, M d, Y", $items["mystrdate"]);
?>
</pubdate>
<guid><?php
echo $items["mylink"];
?>
</guid>
</item>
<?php
}
?>
</channel></rss>
<?php
}
}
示例12: gwolle_gb_rss
function gwolle_gb_rss()
{
// Only show the first page of entries.
$entriesPerPage = (int) get_option('gwolle_gb-entriesPerPage', 20);
/* Get the entries for the RSS Feed */
$entries = gwolle_gb_get_entries(array('offset' => 0, 'num_entries' => $entriesPerPage, 'checked' => 'checked', 'trash' => 'notrash', 'spam' => 'nospam'));
/* Get the time of the last entry, else of the last edited post */
if (is_array($entries) && !empty($entries)) {
$lastbuild = gmdate('D, d M Y H:i:s', $entries[0]->get_datetime());
} else {
$lastbuild = mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false);
}
$postid = gwolle_gb_get_postid();
if ($postid) {
$permalink = get_bloginfo('url') . '?p=' . $postid;
} else {
$permalink = get_bloginfo('url');
}
/* Get the Language setting */
$WPLANG = get_option('WPLANG', false);
if (!$WPLANG) {
$WPLANG = WPLANG;
}
if (!$WPLANG) {
$WPLANG = 'en-us';
}
$WPLANG = str_replace('_', '-', $WPLANG);
$WPLANG = strtolower($WPLANG);
/* Build the XML content */
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
?>
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
<?php
do_action('rss2_ns');
?>
>
<channel>
<title><?php
bloginfo_rss('name');
echo " - " . __('Guestbook Feed', GWOLLE_GB_TEXTDOMAIN);
?>
</title>
<atom:link href="<?php
self_link();
?>
" rel="self" type="application/rss+xml" />
<link><?php
echo $permalink;
?>
</link>
<description><?php
bloginfo_rss('description');
echo " - " . __('Guestbook Feed', GWOLLE_GB_TEXTDOMAIN);
?>
</description>
<lastBuildDate><?php
echo $lastbuild;
?>
</lastBuildDate>
<language><?php
echo $WPLANG;
?>
</language>
<sy:updatePeriod><?php
echo apply_filters('rss_update_period', 'hourly');
?>
</sy:updatePeriod>
<sy:updateFrequency><?php
echo apply_filters('rss_update_frequency', '1');
?>
</sy:updateFrequency>
<?php
do_action('rss2_head');
?>
<?php
if (is_array($entries) && !empty($entries)) {
foreach ($entries as $entry) {
?>
<item>
<title><?php
_e('Guestbook Entry by', GWOLLE_GB_TEXTDOMAIN);
echo " " . trim($entry->get_author_name());
?>
</title>
<link><?php
echo $permalink;
?>
</link>
<pubDate><?php
echo gmdate('D, d M Y H:i:s', $entry->get_datetime());
//.........这里部分代码省略.........
示例13: get_bloginfo
/**
* Provide a public-facing view for the plugin
*
* This file is used to markup the public-facing aspects of the plugin.
*
* @link http://www.jonathandavidharris.co.uk
* @since 1.0.0
*
* @package Simple_Google_News_Sitemap
* @subpackage Simple_Google_News_Sitemap/public/partials
*/
$wp_lang = get_bloginfo('language');
$lang_array = explode("-", $wp_lang);
$lang = $lang_array[0];
$site_name = get_bloginfo('name');
header('Content-Type: ' . feed_content_type($this->plugin_name) . '; charset=' . get_option('blog_charset'), true);
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '"?' . '>';
?>
<!-- generator="simple-google-news-sitemap" datetime="<?php
echo date("Y-m-d H:i:s");
?>
" -->
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd http://www.google.com/schemas/sitemap-news/0.9 http://www.google.com/schemas/sitemap-news/0.9/sitemap-news.xsd"
>
开发者ID:spacedmonkey,项目名称:simple-google-news-sitemap,代码行数:29,代码来源:simple-google-news-sitemap-public-display.php
示例14: feed_links_extra
/**
* Display the links to the extra feeds such as category feeds.
*
* @since 2.8.0
*
* @param array $args Optional arguments.
*/
function feed_links_extra($args = array())
{
$defaults = array('separator' => _x('»', 'feed link'), 'singletitle' => __('%1$s %2$s %3$s Comments Feed'), 'cattitle' => __('%1$s %2$s %3$s Category Feed'), 'tagtitle' => __('%1$s %2$s %3$s Tag Feed'), 'authortitle' => __('%1$s %2$s Posts by %3$s Feed'), 'searchtitle' => __('%1$s %2$s Search Results for “%3$s” Feed'), 'posttypetitle' => __('%1$s %2$s %3$s Feed'));
$args = wp_parse_args($args, $defaults);
if (is_singular()) {
$id = 0;
$post = get_post($id);
if (comments_open() || pings_open() || $post->comment_count > 0) {
$title = sprintf($args['singletitle'], get_bloginfo('name'), $args['separator'], the_title_attribute(array('echo' => false)));
$href = get_post_comments_feed_link($post->ID);
}
} elseif (is_post_type_archive()) {
$post_type = get_query_var('post_type');
if (is_array($post_type)) {
$post_type = reset($post_type);
}
$post_type_obj = get_post_type_object($post_type);
$title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], $post_type_obj->labels->name);
$href = get_post_type_archive_feed_link($post_type_obj->name);
} elseif (is_category()) {
$term = get_queried_object();
if ($term) {
$title = sprintf($args['cattitle'], get_bloginfo('name'), $args['separator'], $term->name);
$href = get_category_feed_link($term->term_id);
}
} elseif (is_tag()) {
$term = get_queried_object();
if ($term) {
$title = sprintf($args['tagtitle'], get_bloginfo('name'), $args['separator'], $term->name);
$href = get_tag_feed_link($term->term_id);
}
} elseif (is_author()) {
$author_id = intval(get_query_var('author'));
$title = sprintf($args['authortitle'], get_bloginfo('name'), $args['separator'], get_the_author_meta('display_name', $author_id));
$href = get_author_feed_link($author_id);
} elseif (is_search()) {
$title = sprintf($args['searchtitle'], get_bloginfo('name'), $args['separator'], get_search_query(false));
$href = get_search_feed_link();
} elseif (is_post_type_archive()) {
$title = sprintf($args['posttypetitle'], get_bloginfo('name'), $args['separator'], post_type_archive_title('', false));
$post_type_obj = get_queried_object();
if ($post_type_obj) {
$href = get_post_type_archive_feed_link($post_type_obj->name);
}
}
if (isset($title) && isset($href)) {
echo '<link rel="alternate" type="' . feed_content_type() . '" title="' . esc_attr($title) . '" href="' . esc_url($href) . '" />' . "\n";
}
}
示例15: wpproads_rss
public function wpproads_rss($adzone_id = 0)
{
global $pro_ads_main, $pro_ads_adzones, $pro_ads_shortcodes;
if (!empty($adzone_id) || isset($_GET['wpproads-rss']) && !empty($_GET['wpproads-rss'])) {
$html = '';
$adzoneID = !empty($adzone_id) ? $adzone_id : $_GET['wpproads-rss'];
$atts = $pro_ads_shortcodes->default_atts($adzoneID);
// http://kb.mailchimp.com/merge-tags/rss-blog/rss-item-tags
// Mailchimp RSS code
// *|RSSITEMS:|* *|RSSITEM:CONTENT_FULL|* *|END:RSSITEMS|*
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_option('blog_charset'), true);
$html .= '<?xml version="1.0" encoding="UTF-8"?>';
$html .= '<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" version="2.0">';
$html .= '<channel>';
$html .= '<title>' . get_bloginfo('name') . '</title>';
$html .= '<atom:link href="' . get_bloginfo('url') . '/?wpproads-rss=' . $adzoneID . '" rel="self" type="application/rss+xml" />';
$html .= '<link>' . get_bloginfo('url') . '</link>';
$html .= '<description><![CDATA[' . get_bloginfo('description') . ']]></description>';
$html .= '<lastBuildDate>' . date('r', $pro_ads_main->time_by_timezone()) . '</lastBuildDate>';
$html .= '<language>' . get_bloginfo('language') . '</language>';
$html .= '<generator>http://wordpress-advertising.com/?v=' . WP_ADS_VERSION . '</generator>';
$html .= '<item>';
$html .= '<title>Adzone</title>';
$html .= '<link>' . get_bloginfo('url') . '</link>';
$html .= '<guid isPermaLink="false">' . get_bloginfo('url') . '/?wpproads-rss=' . $adzoneID . '</guid>';
$html .= '<description><![CDATA[ ' . get_the_title($adzoneID) . ' ]]></description>';
$html .= '<content:encoded><![CDATA[' . $pro_ads_adzones->display_adzone($adzoneID, $atts) . ']]></content:encoded>';
$html .= '<pubDate>' . date('r', $pro_ads_main->time_by_timezone()) . '</pubDate>';
$html .= '</item>';
$html .= '</channel>';
$html .= '</rss>';
echo $html;
exit;
}
}