Beee

rss.php

Jan 26th, 2015
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. <?php
  2. /*
  3.  * RSS Page
  4.  * This page handles the event RSS feed.
  5.  * You can override this file by and copying it to yourthemefolder/plugins/events-manager/templates/ and modifying as necessary.
  6.  *
  7.  */
  8. header ( "Content-type: application/rss+xml; charset=UTF-8" );
  9. echo '<?xml version="1.0" encoding="UTF-8" ?>'."\n";
  10. ?>
  11. <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  12.     <channel>
  13.         <title><?php echo esc_html(get_option ( 'dbem_rss_main_title' )); ?></title>
  14.         <link><?php echo EM_URI; ?></link>
  15.         <description><?php echo esc_html(get_option('dbem_rss_main_description')); ?></description>
  16.         <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  17.         <pubDate><?php echo date('D, d M Y H:i:s +0000', get_option('em_last_modified', current_time('timestamp',true))); ?></pubDate>
  18.         <atom:link href="<?php echo esc_attr(EM_RSS_URI); ?>" rel="self" type="application/rss+xml" />
  19.         <?php
  20.         $description_format     = str_replace ( ">", "&gt;", str_replace ( "<", "&lt;", get_option ( 'dbem_rss_description_format' ) ) );
  21.     $rss_limit                      = get_option('dbem_rss_limit');
  22.     $page_limit                     = $rss_limit > 50 || !$rss_limit ? 50 : $rss_limit; // set a limit of 50 to output at a time, unless overall limit is lower    
  23.         $args                               = !empty($args) ? $args:array(); /* @var $args array */
  24.         $args                               = array_merge(array('scope'=>get_option('dbem_rss_scope'), 'owner'=>false, 'limit'=>$page_limit, 'page'=>1, 'order'=>get_option('dbem_rss_order'), 'orderby'=>get_option('dbem_rss_orderby')), $args);
  25.         $args                               = apply_filters('em_rss_template_args',$args);
  26.         $EM_Events                      = EM_Events::get( $args );
  27.         $count                              = 0;
  28.         while ( count($EM_Events) > 0 ) {
  29.             foreach ( $EM_Events as $EM_Event ) {
  30.                 /* @var $EM_Event EM_Event */
  31.                 $description            = $EM_Event->output( get_option ( 'dbem_rss_description_format' ), "rss");
  32.                 $description            = ent2ncr(convert_chars($description)); // Some RSS filtering
  33.                 $event_url              = $EM_Event->output('#_EVENTURL');
  34.                 $eventname              = $EM_Event->output( get_option('dbem_rss_title_format'), "rss" );
  35.                 ?>
  36.                
  37.                 <item>
  38.                     <title><?php echo $eventname; ?></title>
  39.                     <link><?php echo $event_url; ?></link>
  40.                     <guid><?php echo $event_url; ?></guid>
  41.                     <pubDate><?php echo get_gmt_from_date(date('Y-m-d H:i:s', $EM_Event->start), 'D, d M Y H:i:s +0000'); ?></pubDate>
  42.                     <description><![CDATA[<?php echo $description; ?>]]></description>
  43.                     <content:endoded>
  44.                         <![CDATA[
  45.                             <hgroup>
  46.                               <h1><?php echo $eventname; ?></h1>
  47.                             </hgroup>                      
  48.                             <figure>
  49.                                 <?php echo get_the_post_thumbnail(); ?>
  50.                             </figure>
  51.                             <?php the_content(); ?>
  52.                         ]]>
  53.                     </content:endoded>
  54.                 </item>
  55.                 <?php
  56.                 $count++;
  57.             }
  58.         if ( $rss_limit != 0 && $count >= $rss_limit ) {
  59.         // we've reached our limit, or showing one event only
  60.         break;
  61.         } else {
  62.         // get next page of results
  63.         $args['page']++;
  64.             $EM_Events = EM_Events::get( $args );
  65.         }
  66.         }
  67.         ?>
  68.        
  69.     </channel>
  70. </rss>
Advertisement
Add Comment
Please, Sign In to add comment