-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrss.php
More file actions
43 lines (42 loc) · 1.37 KB
/
rss.php
File metadata and controls
43 lines (42 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?php
function em_rss() {
if ( !empty( $_REQUEST ['dbem_rss'] ) ) {
header ( "Content-type: text/xml" );
echo "<?xml version='1.0'?>\n";
$events_page_id = get_option ( 'dbem_events_page' );
$events_page_link = get_permalink ( $events_page_id );
$joiner = ( stristr($events_page_link, "?") ) ? "&":"?";
?>
<rss version="2.0">
<channel>
<title><?php echo get_option ( 'dbem_rss_main_title' ); ?></title>
<link><?php echo $events_page_link; ?></link>
<description><?php echo get_option ( 'dbem_rss_main_description' ); ?></description>
<docs>
http://blogs.law.harvard.edu/tech/rss
</docs>
<generator>
Weblog Editor 2.0
</generator>
<?php
$title_format = get_option ( 'dbem_rss_title_format' );
$description_format = str_replace ( ">", ">", str_replace ( "<", "<", get_option ( 'dbem_rss_description_format' ) ) );
$events = EM_Events::get( array('limit'=>5) );
foreach ( $events as $event ) {
$title = $event->output( $title_format, "rss" );
$description = $event->output( $description_format, "rss");
echo "<item>";
echo "<title>$title</title>\n";
echo "<link>$events_page_link" . $joiner . "event_id=" . $event->id . "</link>\n ";
echo "<description>$description </description>\n";
echo "</item>";
}
?>
</channel>
</rss>
<?php
die ();
}
}
add_action ( 'init', 'em_rss' );
?>