Exemplo n.º 1
0
/**
 * Filter to added content to the bottom of rss feeds
 *
 * @param string $content The content of the page/post in the rrs feed.
 *
 * @author Matt Rude <*****@*****.**>
 * @package Gus Theme
 * @subpackage Feed Footer
 * @since 0.2
 */
function mdr_postrss($content)
{
    if (is_feed()) {
        $site_name = get_bloginfo_rss('name');
        $post_title = get_the_title_rss();
        $home_url = home_url('/');
        $post_url = post_permalink();
        $content = $content . '<a href="' . $post_url . '">' . $post_title . '</a> is a post from; <a href="' . $home_url . '">' . $site_name . '</a> which is not allowed to be copied on other sites.';
    }
    return $content;
}
Exemplo n.º 2
0
function wp_json_check_url()
{
    if (preg_match('/\\/feed\\/json\\//', $_SERVER['REQUEST_URI']) || $_REQUEST['feed'] == 'json') {
        header('Content-Type: application/json; charset=' . get_option('blog_charset'), true);
        $items = array();
        query_posts("");
        while (have_posts()) {
            the_post();
            $item = array("title" => get_the_title_rss(), "link" => apply_filters('the_permalink_rss', get_permalink()), "description" => apply_filters('the_excerpt_rss', get_the_excerpt()));
            $items[] = $item;
        }
        $arr = array('title' => get_bloginfo_rss('name'), 'link' => get_bloginfo_rss('url'), 'description' => get_bloginfo_rss('description'), 'language' => get_option('rss_language'), 'items' => $items);
        if (function_exists('json_encode')) {
            die("" . $_REQUEST["callback"] . "(" . json_encode($arr) . ");");
        } else {
            //TODO: Add backwards compatibility to before PHP 5.2
            require_once "json.php";
            $json = new Services_JSON();
            die("" . $_REQUEST["callback"] . "(" . $json->encode($arr) . ");");
        }
    }
}
Exemplo n.º 3
0
Arquivo: feed.php Projeto: RA2WP/RA2WP
/**
 * Display the post title in the feed.
 *
 * @since 0.71
 */
function the_title_rss()
{
    echo get_the_title_rss();
}
Exemplo n.º 4
0
 * RSS2 Feed Template for displaying RSS2 Comments feed.
 *
 * @package WordPress
 */
header('Content-Type: text/xml;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:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title><?php 
if (is_singular()) {
    printf(__('Comments on: %s'), get_the_title_rss());
} elseif (is_search()) {
    printf(__('Comments for %s searching on %s'), get_bloginfo_rss('name'), attribute_escape($wp_query->query_vars['s']));
} else {
    printf(__('Comments for %s'), get_bloginfo_rss('name') . get_wp_title_rss());
}
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
is_single() ? the_permalink_rss() : bloginfo_rss("url");
?>
</link>
/**
 * Universal Feed Loader
 * hooked function
 * supports custom settings
 * NOTE uses just-in-time initialization
 * @see     functions.php, feed-links include module
 * @uses    Universal Feed Writer class
 */
function tLoadFeed()
{
    global $tFeeds, $tCurrentFeed, $wp_query, $post;
    $tCurrentFeed = get_query_var('feed');
    // FB::trace($tCurrentFeed);
    if (empty($tCurrentFeed) || $tCurrentFeed == 'feed') {
        $tCurrentFeed = get_default_feed();
        # rss2
    }
    $args =& $tFeeds[$tCurrentFeed];
    $defaults = array('num_entries' => get_option('posts_per_rss'), 'do_images' => true, 'size_image' => 'large', 'feed_type' => defined('TFEED') ? TFEED : 'atom', 'feed_title' => 'Recent Posts', 'feed_description' => 'An unfiltered list limited to ' . $num_entries . ' posts');
    $args = apply_filters('t_load_feed_args', $args);
    $args = wp_parse_args($args, $defaults);
    # customizing default info
    if (is_category()) {
        $category = t_get_term_name(get_query_var('cat'), 'category');
        $args['feed_title'] = 'Feed for ' . $category;
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' posts categorized under ' . $category;
    }
    if ($wp_query->is_comment_feed) {
        # comment feed
        if (is_singular()) {
            $args['feed_title'] = 'Recent comments on ' . get_the_title_rss();
        } elseif (is_search()) {
            $args['feed_title'] = 'Comments for search on ' . attribute_escape($wp_query->query_vars['s']);
        } else {
            $args['feed_title'] = 'Recent comments for ' . get_wp_title_rss();
        }
        $args['feed_title'] = ent2ncr($args['feed_title']);
        $args['feed_description'] = 'A list limited to ' . $args['num_entries'] . ' comments';
    }
    $args['query'] = tGetFeedQuery();
    if (is_array($args['query'])) {
        $args['query']['showposts'] =& $args['num_entries'];
    }
    if ($tCurrentFeed == 'rss' || $tCurrentFeed == 'rss2' || $tCurrentFeed == 'atom') {
        $args['feed_type'] = $tCurrentFeed;
    } else {
        $args['feed_title'] = ucwords(str_replace('_', ' ', $tCurrentFeed));
    }
    extract($args);
    # namespacing
    switch ($feed_type) {
        case 'rss2':
            $namespace = '
                 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/"
                ';
            $feedType = RSS2;
            break;
        case 'rss':
            $namespace = '
                 xmlns:dc="http://purl.org/dc/elements/1.1/"
                 xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
                 xmlns:admin="http://webns.net/mvcb/"
                 xmlns:content="http://purl.org/rss/1.0/modules/content/"
                ';
            $feedType = RSS1;
            break;
        case 'atom':
        default:
            $namespace = '
                 xmlns:thr="http://purl.org/syndication/thread/1.0"
                 xml:lang="' . get_option('rss_language') . '"
                 xml:base="' . get_bloginfo_rss('url') . '"
                 ';
            $feedType = ATOM;
            break;
    }
    $GLOBALS['t_feed_ns'] = $namespace;
    # for use in FeedWriter
    add_filter('t_feed_ns', create_function('$default', 'return $default . $GLOBALS["t_feed_ns"];'));
    # start
    $feedWriter = new FeedWriter($feedType);
    require TDIR . TMODINC . 'feed-head.php';
    require TDIR . TMODINC . 'feed-body.php';
    # output
    $out = ob_get_contents();
    $out = str_replace(array("\n", "\r", "\t", ' '), '', $input);
    ob_end_clean();
    $feedWriter->generateFeed();
    // lifestream_rss_feed();
    // FB::info($args);
}
Exemplo n.º 6
0
/**
 * Prints the news XML sitemap conforming to the Sitemaps.org protocol.
 * Outputs an XML list of up to 1000 posts published in the last 2 days.
 *
 * @module sitemaps
 *
 * @link http://sitemaps.org/protocol.php Sitemaps.org protocol.
 */
function jetpack_print_news_sitemap()
{
    $xml = get_transient('jetpack_news_sitemap');
    if ($xml) {
        header('Content-Type: application/xml');
        echo $xml;
        die;
    }
    global $wpdb, $post;
    /**
     * Filter post types to be included in news sitemap.
     *
     * @module sitemaps
     *
     * @since 3.9.0
     *
     * @param array $post_types Array with post types to include in news sitemap.
     */
    $post_types = apply_filters('jetpack_sitemap_news_sitemap_post_types', array('post'));
    if (empty($post_types)) {
        return;
    }
    $post_types_in = array();
    foreach ($post_types as $post_type) {
        $post_types_in[] = $wpdb->prepare('%s', $post_type);
    }
    $post_types_in_string = implode(', ', $post_types_in);
    /**
     * Filter limit of entries to include in news sitemap.
     *
     * @module sitemaps
     *
     * @since 3.9.0
     *
     * @param int $count Number of entries to include in news sitemap.
     */
    $limit = apply_filters('jetpack_sitemap_news_sitemap_count', 1000);
    $cur_datetime = current_time('mysql', true);
    $query = $wpdb->prepare("\n\t\tSELECT p.ID, p.post_title, p.post_type, p.post_date, p.post_name, p.post_date_gmt, GROUP_CONCAT(t.name SEPARATOR ', ') AS keywords\n\t\tFROM\n\t\t\t{$wpdb->posts} AS p LEFT JOIN {$wpdb->term_relationships} AS r ON p.ID = r.object_id\n\t\t\tLEFT JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'post_tag'\n\t\t\tLEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id\n\t\tWHERE\n\t\t\tpost_status='publish' AND post_type IN ( {$post_types_in_string} ) AND post_date_gmt > (%s - INTERVAL 2 DAY)\n\t\tGROUP BY p.ID\n\t\tORDER BY p.post_date_gmt DESC LIMIT %d", $cur_datetime, $limit);
    // URL to XSLT
    $xsl = get_option('permalink_structure') ? home_url('news-sitemap.xsl') : home_url('/?jetpack-news-sitemap-xsl=true');
    // Unless it's zh-cn for Simplified Chinese or zh-tw for Traditional Chinese,
    // trim national variety so an ISO 639 language code as required by Google.
    $language_code = strtolower(get_locale());
    if (in_array($language_code, array('zh_tw', 'zh_cn'))) {
        $language_code = str_replace('_', '-', $language_code);
    } else {
        $language_code = preg_replace('/(_.*)$/i', '', $language_code);
    }
    header('Content-Type: application/xml');
    ob_start();
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    echo '<?xml-stylesheet type="text/xsl" href="' . esc_url($xsl) . '"?>' . "\n";
    echo '<!-- generator="jetpack-' . JETPACK__VERSION . '" -->' . "\n";
    ?>
	<!-- generator="jetpack" -->
	<urlset 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"
	        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"
		>
		<?php 
    $posts = $wpdb->get_results($query);
    foreach ($posts as $post) {
        setup_postdata($post);
        /**
         * Filter condition to allow skipping specific posts in news sitemap.
         *
         * @module sitemaps
         *
         * @since 3.9.0
         *
         * @param bool $skip Current boolean. False by default, so no post is skipped.
         * @param WP_POST $post Current post object.
         */
        if (apply_filters('jetpack_sitemap_news_skip_post', false, $post)) {
            continue;
        }
        $GLOBALS['post'] = $post;
        $url = array();
        $url['loc'] = get_permalink($post->ID);
        $news = array();
        $news['news:publication']['news:name'] = get_bloginfo_rss('name');
        $news['news:publication']['news:language'] = $language_code;
        $news['news:publication_date'] = jetpack_w3cdate_from_mysql($post->post_date_gmt);
        $news['news:title'] = get_the_title_rss();
        if ($post->keywords) {
            $news['news:keywords'] = html_entity_decode(ent2ncr($post->keywords), ENT_HTML5);
        }
        $url['news:news'] = $news;
        // Add image to sitemap
        $post_thumbnail = Jetpack_PostImages::get_image($post->ID);
        if (isset($post_thumbnail['src'])) {
            $url['image:image'] = array('image:loc' => esc_url($post_thumbnail['src']));
        }
        /**
         * Filter associative array with data to build <url> node and its descendants for current post in news sitemap.
         *
         * @module sitemaps
         *
         * @since 3.9.0
         *
         * @param array $url Data to build parent and children nodes for current post.
         * @param int $post_id Current post ID.
         */
        $url = apply_filters('jetpack_sitemap_news_sitemap_item', $url, $post);
        if (empty($url)) {
            continue;
        }
        jetpack_print_sitemap_item($url);
    }
    wp_reset_postdata();
    ?>
	</urlset>
	<?php 
    $xml = ob_get_contents();
    ob_end_clean();
    if (!empty($xml)) {
        set_transient('jetpack_news_sitemap', $xml, DAY_IN_SECONDS);
        echo $xml;
    }
    die;
}
//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: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/"
	<?php 
do_action('rss2_ns');
do_action('rss2_comments_ns');
?>
>
<channel>
	<title><?php 
if (is_singular()) {
    printf(ent2ncr(__('Comments on: %s')), get_the_title_rss() . ' by ' . $user_print_name);
} elseif (is_search()) {
    printf(ent2ncr(__('Comments for %s searching on %s')), get_bloginfo_rss('name'), esc_attr($wp_query->query_vars['s']));
} else {
    printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss('name') . ' by ' . $user_print_name . get_wp_title_rss());
}
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
is_single() ? the_permalink_rss() : bloginfo_rss("url");
?>
</link>
global $digressit_commentbrowser, $wp_rewrite, $matches, $wp_query, $wpdb;
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: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/"
	<?php 
do_action('rss2_ns');
do_action('rss2_comments_ns');
?>
>
<channel>
	<title><?php 
echo get_the_title_rss();
?>
</title>
	<atom:link href="<?php 
self_link();
?>
" rel="self" type="application/rss+xml" />
	<link><?php 
is_single() ? the_permalink_rss() : bloginfo_rss("url");
?>
</link>
	<description><?php 
bloginfo_rss("description");
?>
</description>
	<lastBuildDate><?php 
Exemplo n.º 9
0
                } else {
                    $vdate = ';VALUE=DATE';
                    $include_strings[] = $include->format('Ymd');
                }
            }
            ?>
RDATE<?php 
            echo $vdate;
            ?>
:<?php 
            echo implode(',', $include_strings);
            ?>

<?php 
        }
        echo eventorganiser_escape_ical_text(html_entity_decode("SUMMARY: " . get_the_title_rss())) . "\n";
        $excerpt = get_the_excerpt();
        $excerpt = apply_filters('the_excerpt_rss', $excerpt);
        if (!empty($excerpt)) {
            echo eventorganiser_escape_ical_text(html_entity_decode("DESCRIPTION: {$excerpt}")) . "\n";
        }
        $cats = get_the_terms(get_the_ID(), 'event-category');
        if ($cats && !is_wp_error($cats)) {
            $cat_names = wp_list_pluck($cats, 'name');
            $cat_names = array_map('eventorganiser_escape_ical_text', $cat_names);
            ?>
CATEGORIES:<?php 
            echo implode(',', $cat_names);
            ?>

<?php 
function wpcom_print_news_sitemap($format)
{
    if (defined('WPCOM_SKIP_DEFAULT_NEWS_SITEMAP') && WPCOM_SKIP_DEFAULT_NEWS_SITEMAP) {
        return;
    }
    global $wpdb;
    $post_types = apply_filters('wpcom_sitemap_news_sitemap_post_types', array('post'));
    if (empty($post_types)) {
        return;
    }
    $post_types_in = array();
    foreach ($post_types as $post_type) {
        $post_types_in[] = $wpdb->prepare('%s', $post_type);
    }
    $post_types_in_string = implode(', ', $post_types_in);
    $limit = apply_filters('wpcom_sitemap_news_sitemap_count', 1000);
    $cur_datetime = current_time('mysql', true);
    $query = $wpdb->prepare("\n\t\tSELECT p.ID, p.post_title, p.post_type, p.post_date, p.post_name, p.post_date_gmt, GROUP_CONCAT(t.name SEPARATOR ', ') AS keywords\n\t\tFROM\n\t\t\t{$wpdb->posts} AS p LEFT JOIN {$wpdb->term_relationships} AS r ON p.ID = r.object_id\n\t\t\tLEFT JOIN {$wpdb->term_taxonomy} AS tt ON r.term_taxonomy_id = tt.term_taxonomy_id AND tt.taxonomy = 'post_tag'\n\t\t\tLEFT JOIN {$wpdb->terms} AS t ON tt.term_id = t.term_id\n\t\tWHERE\n\t\t\tpost_status='publish' AND post_type IN ( {$post_types_in_string} ) AND post_date_gmt > (%s - INTERVAL 2 DAY)\n\t\tGROUP BY p.ID\n\t\tORDER BY p.post_date_gmt DESC LIMIT %d", $cur_datetime, $limit);
    header('Content-Type: application/xml');
    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    ?>
<!-- generator="wordpress.com" -->
<urlset 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"
	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"
	>
<?php 
    $posts = $wpdb->get_results($query);
    foreach ($posts as $post) {
        // Add in filter to allow skipping specific posts
        if (apply_filters('wpcom_sitemap_news_skip_post', false, $post)) {
            continue;
        }
        $GLOBALS['post'] = $post;
        $url = array();
        $url['loc'] = get_permalink($post->ID);
        $news = array();
        $news['news:publication']['news:name'] = get_bloginfo_rss('name');
        if (function_exists('get_blog_lang_code')) {
            $news['news:publication']['news:language'] = get_blog_lang_code();
        }
        $news['news:publication_date'] = w3cdate_from_mysql($post->post_date_gmt);
        $news['news:title'] = get_the_title_rss();
        if ($post->keywords) {
            $news['news:keywords'] = html_entity_decode(ent2ncr($post->keywords), ENT_HTML5);
        }
        $url['news:news'] = $news;
        // Add image to sitemap
        if (current_theme_supports('post-thumbnails') && has_post_thumbnail($post->ID)) {
            $post_thumbnail_id = get_post_thumbnail_id($post->ID);
            $post_thumbnail_src = wp_get_attachment_image_src($post_thumbnail_id);
            if ($post_thumbnail_src) {
                $url['image:image'] = array('image:loc' => esc_url($post_thumbnail_src[0]));
            }
        }
        $url = apply_filters('wpcom_sitemap_news_sitemap_item', $url, $post);
        if (empty($url)) {
            continue;
        }
        wpcom_print_sitemap_item($url);
    }
    ?>
</urlset>
<?php 
    die;
}
Exemplo n.º 11
0
?>
&amp;t=<?php 
echo urlencode(get_the_title_rss());
?>
" title="<?php 
_e('Share this on Facebook', 'onemozilla');
?>
"><span><?php 
_e('Share this on Facebook', 'onemozilla');
?>
</span></a></li>
      <li><a class="twitter" href="https://twitter.com/intent/tweet?url=<?php 
echo wp_get_shortlink();
?>
&amp;text=<?php 
echo urlencode(get_the_title_rss() . ' - ');
?>
&amp;via=firefox" title="<?php 
_e('Share this on Twitter', 'onemozilla');
?>
"><span><?php 
_e('Share this on Twitter', 'onemozilla');
?>
</span></a></li>
    </ul>

  <?php 
if ('post' == get_post_type()) {
    // Hide category and tag text for pages on Search
    ?>
		<?php 
Exemplo n.º 12
0
 }
 if (!empty($schedule_data['include'])) {
     $include_strings = array();
     foreach ($schedule_data['include'] as $include) {
         if (!eo_is_all_day()) {
             $vdate = '';
             $include->setTimezone($UTC_tz);
             $include_strings[] = $include->format('Ymd\\THis\\Z');
         } else {
             $vdate = ';VALUE=DATE';
             $include_strings[] = $include->format('Ymd');
         }
     }
     echo "RDATE" . $vdate . ":" . implode(',', $include_strings) . "\r\n";
 }
 echo eventorganiser_fold_ical_text('SUMMARY: ' . eventorganiser_escape_ical_text(html_entity_decode(get_the_title_rss(), ENT_COMPAT, 'UTF-8'))) . "\r\n";
 $description = wp_strip_all_tags(html_entity_decode(get_the_excerpt(), ENT_COMPAT, 'UTF-8'));
 $description = ent2ncr(convert_chars($description));
 /**
  * Filters the description of the event as it appears in the iCal feed.
  *
  * @param string $description The event description
  */
 $description = apply_filters('eventorganiser_ical_description', $description);
 $description = eventorganiser_escape_ical_text($description);
 if (!empty($description)) {
     echo eventorganiser_fold_ical_text("DESCRIPTION: {$description}") . "\r\n";
 }
 $description = wpautop(html_entity_decode(get_the_content(), ENT_COMPAT, 'UTF-8'));
 $description = str_replace("\r\n", '', $description);
 //Remove new lines
 /**
  * Generate XML Sitemap with SimpleXMLElement
  * @return string
  * @todo Make number of posts configurable via querystring
  * @link http://support.google.com/webmasters/answer/183668 ()
  */
 function get_sitemap_xml($show_all = false)
 {
     $xml = new \SimpleXMLElement('<?xml version="1.0" encoding="utf-8" ?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" 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"></urlset>');
     // Setup Pagination
     $page = get_query_var('page', 0);
     // Get available public custom post types
     $custom_post_types = get_post_types(array('public' => true, 'exclude_from_search' => false, '_builtin' => false));
     // Limit/filter posts from last week
     $date_query = array(array('after' => '1 week ago'));
     // Generate base arguments for WP_Query
     $args = array('post_type' => array_merge(array('post', 'page'), $custom_post_types), 'orderby' => 'modified', 'order' => 'DESC');
     // Use Pagination if "?page=1" is passed
     if ($show_all) {
         $args['posts_per_page'] = -1;
     } elseif ($page) {
         $args['posts_per_page'] = $this->posts_per_page;
         $args['paged'] = $page;
     } else {
         $args['nopaging'] = true;
         $args['date_query'] = $date_query;
         // Don't use date-based query if pagination is enabled
     }
     // Run WP_Query
     $query = new \WP_Query($args);
     // Add attributes for debugging purposes
     $xml->addAttribute('generated', date(\DateTime::RSS));
     if ($page) {
         $xml->addAttribute('page', $page);
         $xml->addAttribute('maxpages', $query->max_num_pages);
     }
     // Just exit with 404 response if no posts returned
     if (!$query->have_posts()) {
         $this->return_404();
     }
     // Add site url to top of sitemap
     if ($page <= 1) {
         $home = $xml->addChild('url');
         $home->addChild('loc', get_site_url());
         $home->addChild('changefreq', 'always');
         $home->addChild('priority', '1.0');
     }
     // Iterate over all posts
     while ($query->have_posts()) {
         $query->the_post();
         $item = $xml->addChild('url');
         $item->addChild('loc', get_the_permalink());
         $item->addChild('lastmod', get_the_modified_date(DATE_W3C));
         // get get_the_modified_date from the first tiem for our Last Modified HTTP header
         if (!$this->last_modified_header) {
             $this->last_modified_header = get_the_modified_date($this::UTC_DATE_FORMAT);
         }
         if (has_post_thumbnail()) {
             $featured_image = get_post(get_post_thumbnail_id());
             if (isset($featured_image->ID)) {
                 $thumb = wp_get_attachment_image_src($featured_image->ID, 'large');
                 $thumb_url = $thumb['0'];
                 $image = $item->addChild('image:image', NULL, $this::ns_sitemap_image);
                 $image->addChild('image:loc', $thumb_url, $this::ns_sitemap_image);
                 $image->addChild('image:title', htmlspecialchars($featured_image->post_title), $this::ns_sitemap_image);
                 $image->addChild('image:caption', htmlspecialchars($featured_image->post_excerpt), $this::ns_sitemap_image);
                 // UTF8 Debug Test
                 // $utf8_sample = 'I am text with Ünicödé & HTML €ntities ©';
                 // $image->addChild('image:title', htmlspecialchars($utf8_sample), $this::ns_sitemap_image);
                 // $image->addChild('image:caption', htmlspecialchars($utf8_sample), $this::ns_sitemap_image);
             }
         }
         $news = $item->addChild('news:news', NULL, $this::ns_sitemap_news);
         $news->addChild('news:publication_date', get_the_date(DATE_W3C));
         $news->addChild('news:title', get_the_title_rss());
         // TODO: Not sure if news:genres should be included or not
         // $news->addChild('news:genres', 'PressRelease, Blog'); // https://support.google.com/news/publisher/answer/93992
         $publication = $news->addChild('news:publication');
         $publication->addChild('news:name', get_bloginfo_rss('name'));
         $publication->addChild('news:language', get_bloginfo_rss('language'));
     }
     wp_reset_query();
     // Advertise taxonomy terms on regular non-paginated sitemap
     if ($args['nopaging'] = true) {
         // Get all categories
         foreach (get_categories() as $category) {
             $item = $xml->addChild('url');
             $item->addChild('loc', get_category_link($category->term_id));
         }
         // Get all tags
         foreach (get_tags() as $tag) {
             $item = $xml->addChild('url');
             $item->addChild('loc', get_tag_link($tag->term_id));
         }
     }
     // Attach query details to attributes if debugging is enabled
     if (WP_DEBUG) {
         $xml->addAttribute('debug', get_num_queries() . ' queries in ' . timer_stop(0) . ' seconds');
     }
     return $xml->asXML();
 }
Exemplo n.º 14
0
    return apply_filters('bfox_plan_update_frequency_rss', (int) bfox_plan_meta('per_day', $post_id));
}
function bfox_plan_last_build_date_rss($format = 'D, d M Y H:i:s +0000', $post_id = 0)
{
    $last_reading_date = bfox_plan_reading_gmdate(bfox_plan_latest_reading(), $format);
    $last_reading_time = strtotime($last_reading_date);
    $post = get_post($post_id);
    $last_save_date = mysql2date($format, $post->post_modified_gmt, false);
    $last_save_time = strtotime($last_save_date);
    if ($last_save_time > $last_reading_time) {
        return $last_save_date;
    } else {
        return $last_reading_date;
    }
}
function bfox_plan_ical_print_array($arr)
{
    foreach ($arr as $key => $value) {
        echo "{$key}:{$value}\n";
    }
}
header('Content-Type: text/calendar; charset=' . get_option('blog_charset'), true);
bfox_plan_ical_print_array(array('BEGIN' => 'VCALENDAR', 'PRODID' => '-//Epicfox//Biblefox for WordPress//EN', 'VERSION' => '2.0', 'CALSCALE' => 'GREGORIAN', 'METHOD' => 'PUBLISH', 'X-WR-CALNAME' => get_the_title_rss(), 'X-WR-TIMEZONE' => get_option('timezone_string'), 'X-WR-CALDESC' => get_the_excerpt()));
while (have_posts()) {
    the_post();
    for ($reading_id = bfox_plan_reading_count() - 1; $reading_id >= 0; $reading_id--) {
        $arr = array('BEGIN' => 'VEVENT', 'DTSTART;VALUE=DATE' => bfox_plan_reading_date($reading_id, 'Ymd'), 'DTEND;VALUE=DATE' => date('Ymd', strtotime(bfox_plan_reading_date($reading_id, 'Ymd') . ' + 1 day')), 'DTSTAMP' => bfox_plan_reading_gmdate($reading_id, 'Ymd\\THis\\Z'), 'UID' => bfox_plan_reading_guid($reading_id), 'URL' => esc_url(bfox_plan_reading_url($reading_id)), 'CREATED' => bfox_plan_reading_gmdate($reading_id, 'Ymd\\THis\\Z'), 'SUMMARY' => sprintf(__('#%d: %s', 'bfox'), $reading_id + 1, bfox_plan_reading_ref_str($reading_id, 0, BibleMeta::name_short)), 'LAST-MODIFIED' => bfox_plan_reading_gmdate($reading_id, 'Ymd\\THis\\Z'), 'LOCATION' => '', 'SEQUENCE' => 0, 'STATUS' => 'CONFIRMED', 'TRANSP' => 'OPAQUE', 'END' => 'VEVENT');
        bfox_plan_ical_print_array($arr);
    }
}
echo "END:VCALENDAR\n";
function podPress_rss2_item()
{
    global $podPress, $post, $post_meta_cache, $blog_id, $wp_version;
    $enclosureTag = podPress_getEnclosureTags();
    if ($enclosureTag != '') {
        // if no enclosure tag, no need for iTunes tags
        $is_password_protected = podpress_post_is_password_protected();
        if (FALSE === $is_password_protected) {
            echo $enclosureTag;
        }
        if ($post->podPressPostSpecific['itunes:subtitle'] == '##PostExcerpt##') {
            if (TRUE === $is_password_protected) {
                $post->podPressPostSpecific['itunes:subtitle'] = __('This post is password protected.', 'podPress');
            } else {
                $post->podPressPostSpecific['itunes:subtitle'] = trim(podpress_get_excerpt_rss());
            }
        }
        if (TRUE == empty($post->podPressPostSpecific['itunes:subtitle'])) {
            $post->podPressPostSpecific['itunes:subtitle'] = get_the_title_rss();
        }
        echo '		<itunes:subtitle>' . podPress_strlimiter_end(podPress_feedSafeContent(stripslashes($post->podPressPostSpecific['itunes:subtitle']), FALSE, TRUE), 254, '[...]', TRUE) . '</itunes:subtitle>' . "\n";
        if (FALSE == isset($post->podPressPostSpecific['itunes:summary'])) {
            $post->podPressPostSpecific['itunes:summary'] = '##PostContentShortened##';
        }
        switch ($post->podPressPostSpecific['itunes:summary']) {
            case '##Global##':
                $post->podPressPostSpecific['itunes:summary'] = $podPress->settings['iTunes']['summary'];
                break;
            case '##PostExcerpt##':
                if (TRUE === $is_password_protected) {
                    $post->podPressPostSpecific['itunes:summary'] = __('This post is password protected.', 'podPress');
                } else {
                    $post->podPressPostSpecific['itunes:summary'] = trim(podpress_get_excerpt_rss());
                }
                break;
            case '##PostContentShortened##':
                if (post_password_required($post)) {
                    $post->podPressPostSpecific['itunes:summary'] = __('This post is password protected.', 'podPress');
                } else {
                    if (TRUE == version_compare($wp_version, '2.9', '>=')) {
                        $post->podPressPostSpecific['itunes:summary'] = get_the_content_feed();
                    } else {
                        $post->podPressPostSpecific['itunes:summary'] = trim(podpress_get_content_rss());
                    }
                }
                break;
        }
        if (FALSE == empty($post->podPressPostSpecific['itunes:summary'])) {
            echo '		<itunes:summary>' . podPress_strlimiter_end(podPress_feedSafeContent(stripslashes($post->podPressPostSpecific['itunes:summary']), FALSE, TRUE), 4000, '[...]', TRUE) . '</itunes:summary>' . "\n";
        }
        switch ($post->podPressPostSpecific['itunes:keywords']) {
            default:
            case '##WordPressCats##':
                $categories = get_the_category();
                $post->podPressPostSpecific['itunes:keywords'] = '';
                if (TRUE == is_array($categories) and FALSE == empty($categories)) {
                    $category_names = array();
                    $b = '';
                    foreach ($categories as $category) {
                        $result = preg_match('/\\S+\\s+\\S+/', $category->cat_name, $b);
                        // take the category name only if it does not contain inner white spaces (if it does not consist of more than one word)
                        if (TRUE == empty($b)) {
                            $category_names[] = $category->cat_name;
                        }
                    }
                    if (TRUE == is_array($category_names) and FALSE == empty($category_names)) {
                        $nr_category_names = count($category_names);
                        if ($nr_category_names > 1) {
                            for ($i = 0; $i < min($nr_category_names, 12); $i++) {
                                // max. 12 keywords are allowed
                                if (0 == $i) {
                                    $post->podPressPostSpecific['itunes:keywords'] = $category_names[$i];
                                } else {
                                    $post->podPressPostSpecific['itunes:keywords'] .= ', ' . $category_names[$i];
                                }
                            }
                        } elseif ($nr_category_names === 1) {
                            $post->podPressPostSpecific['itunes:keywords'] = $category_names[0];
                        }
                    }
                }
                break;
            case '##post_tags##':
                $posttags = get_the_tags();
                $post->podPressPostSpecific['itunes:keywords'] = '';
                if (is_array($posttags) and FALSE == empty($posttags)) {
                    $posttags_nr = count($posttags);
                    $i = 0;
                    foreach ($posttags as $tag) {
                        if ($i == $posttags_nr - 1) {
                            $post->podPressPostSpecific['itunes:keywords'] .= $tag->name;
                        } else {
                            $post->podPressPostSpecific['itunes:keywords'] .= $tag->name . ', ';
                        }
                        $i++;
                    }
                }
                break;
            case '##Global##':
                $post->podPressPostSpecific['itunes:keywords'] = $podPress->settings['iTunes']['keywords'];
                break;
        }
        if (FALSE == empty($post->podPressPostSpecific['itunes:keywords'])) {
            echo '		<itunes:keywords>' . podPress_feedSafeContent($podPress->cleanup_itunes_keywords(stripslashes($post->podPressPostSpecific['itunes:keywords']), '', FALSE)) . '</itunes:keywords>' . "\n";
        }
        if ($post->podPressPostSpecific['itunes:author'] == '##Global##') {
            $post->podPressPostSpecific['itunes:author'] = $podPress->settings['iTunes']['author'];
            if (empty($post->podPressPostSpecific['itunes:author'])) {
                $post->podPressPostSpecific['itunes:author'] = stripslashes(get_option('admin_email'));
            }
        }
        echo '		<itunes:author>' . podPress_feedSafeContent($post->podPressPostSpecific['itunes:author']) . '</itunes:author>' . "\n";
        if ($post->podPressPostSpecific['itunes:explicit'] == 'Default') {
            $post->podPressPostSpecific['itunes:explicit'] = $podPress->settings['iTunes']['explicit'];
        }
        if ('' == trim($post->podPressPostSpecific['itunes:explicit']) or '' != trim($post->podPressPostSpecific['itunes:explicit']) and 'no' != strtolower($post->podPressPostSpecific['itunes:explicit']) and 'yes' != strtolower($post->podPressPostSpecific['itunes:explicit']) and 'clean' != strtolower($post->podPressPostSpecific['itunes:explicit'])) {
            $post->podPressPostSpecific['itunes:explicit'] = 'No';
        }
        echo '		<itunes:explicit>' . podPress_feedSafeContent(strtolower($post->podPressPostSpecific['itunes:explicit'])) . '</itunes:explicit>' . "\n";
        if ($post->podPressPostSpecific['itunes:block'] == 'Default') {
            $post->podPressPostSpecific['itunes:block'] = $podPress->settings['iTunes']['block'];
        }
        if ('' == trim($post->podPressPostSpecific['itunes:block']) or '' != trim($post->podPressPostSpecific['itunes:block']) and 'no' != strtolower($post->podPressPostSpecific['itunes:block']) and 'yes' != strtolower($post->podPressPostSpecific['itunes:block'])) {
            $post->podPressPostSpecific['itunes:block'] = 'No';
        }
        echo '		<itunes:block>' . podPress_feedSafeContent(strtolower($post->podPressPostSpecific['itunes:block'])) . '</itunes:block>' . "\n";
        //echo '<comments>'. get_comments_link() .'</comments>'."\n";
        $episodeLicenseTags = podPress_getEpisodeLicenseTags();
        if ($episodeLicenseTags != '') {
            echo $episodeLicenseTags;
        }
    }
    if (isset($post_meta_cache[$blog_id][$post->ID]['enclosure_podPressHold'])) {
        $post_meta_cache[$blog_id][$post->ID]['enclosure'] = $post_meta_cache[$blog_id][$post->ID]['enclosure_podPressHold'];
        unset($post_meta_cache[$blog_id][$post->ID]['enclosure_podPressHold']);
    }
    // add the enclosures which are not added with podPress at last
    podPress_add_nonpodpress_enclosures('rss2');
}
echo '<?xml version="1.0" encoding="' . get_option('blog_charset') . '" ?' . '>';
?>
<feed
	xmlns="http://www.w3.org/2005/Atom"
	xml:lang="<?php 
echo get_option('rss_language');
?>
"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	<?php 
do_action('atom_ns');
?>
>
	<title type="text"><?php 
if (is_singular()) {
    printf(ent2ncr(__('Comments on: %s')), get_the_title_rss());
} elseif (is_search()) {
    printf(ent2ncr(__('Comments for %1$s searching on %2$s')), get_bloginfo_rss('name'), attribute_escape(get_search_query()));
} else {
    printf(ent2ncr(__('Comments for %s')), get_bloginfo_rss('name') . get_wp_title_rss());
}
?>
</title>
	<subtitle type="text"><?php 
bloginfo_rss('description');
?>
</subtitle>

	<updated><?php 
echo mysql2date('Y-m-d\\TH:i:s\\Z', get_lastcommentmodified('GMT'));
?>
Exemplo n.º 17
0
/**
 * Hook into the feed content
 * @param type $content
 * @param type $feed_type
 * @return $content
 * @see http://wp.smashingmagazine.com/2011/12/07/10-tips-optimize-wordpress-theme/
 */
function ts_feed_spruce_the_content_feed($content, $feed_type)
{
    global $post;
    /* if (has_post_thumbnail($post->ID) )
    		$content = '<p>' . get_the_post_thumbnail($post->ID, 'thumbnail') . '</p>' . $content; */
    $options = ts_feed_spruce_get_options();
    if ($options['sociallinks']) {
        $content .= '<p class="social-links">';
        $content .= ts_feed_spruce_get_social_links(get_permalink(), get_the_title_rss());
        $content .= '</p>';
    }
    if (!empty($options['append'])) {
        $content .= '<p class="appended">';
        $content .= str_ireplace(array('%id%', '%url%'), array(get_the_ID(), apply_filters('the_permalink_rss', get_permalink())), $options['append']);
        $content .= '</p>';
    }
    return $content;
}