-
Notifications
You must be signed in to change notification settings - Fork 0
/
voyeurWP-feed.php
82 lines (76 loc) · 3.22 KB
/
voyeurWP-feed.php
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/*
Template Name: eVoyeur Tools Feed
*/
function vwp_rssDate($timestamp = NULL) {
$timestamp = ($timestamp==NULL) ? time() : $timestamp;
echo date(DATE_RSS, $timestamp);
}
global $wp_query; // Set the $wp_query instance so we can find $_GET vars.
$postFilter = 'post_status=publish'; // Makes sure we're only retrieving published posts.
if (isset($wp_query->query_vars)) {
if (!empty($wp_query->query_vars['p'])) { // Post ID of actual post. (If we're filtering individual post.)
$postFilter .= '&p=' . (int) wp_kses($wp_query->query_vars['p'], array());
}
if (!empty($wp_query->query_vars['name'])) { // Post slug of actual post. (If we're filtering individual post.)
$postFilter .= '&name=' . wp_kses($wp_query->query_vars['name'], array());
}
if (!empty($wp_query->query_vars['author'])) {
$postFilter .= '&author=' . (int) wp_kses($wp_query->query_vars['author'], array());
}
if (!empty($wp_query->query_vars['author_name'])) {
$postFilter .= '&author_name=' . wp_kses($wp_query->query_vars['author_name'], array());
}
if (!empty($wp_query->query_vars['cat'])) {
$postFilter .= '&cat=' . (int) wp_kses($wp_query->query_vars['cat'], array());
}
if (!empty($wp_query->query_vars['category_name'])) {
$postFilter .= '&category_name=' . wp_kses($wp_query->query_vars['category_name'], array());
}
if (!empty($wp_query->query_vars['tag'])) {
$postFilter .= '&tag=' . wp_kses($wp_query->query_vars['tag'], array());
}
if (!empty($wp_query->query_vars['second'])) {
$postFilter .= '&second=' . (int) wp_kses($wp_query->query_vars['second'], array());
}
if (!empty($wp_query->query_vars['minute'])) {
$postFilter .= '&minute=' . (int) wp_kses($wp_query->query_vars['minute'], array());
}
if (!empty($wp_query->query_vars['hour'])) {
$postFilter .= '&hour=' . (int) wp_kses($wp_query->query_vars['hour'], array());
}
if (!empty($wp_query->query_vars['day'])) {
$postFilter .= '&day=' . (int) wp_kses($wp_query->query_vars['day'], array());
}
if (!empty($wp_query->query_vars['monthnum'])) {
$postFilter .= '&monthnum=' . (int) wp_kses($wp_query->query_vars['monthnum'], array());
}
if (!empty($wp_query->query_vars['year'])) {
$postFilter .= '&year=' . (int) wp_kses($wp_query->query_vars['year'], array());
}
}
$posts = query_posts($postFilter);
header("Content-Type: application/rss+xml; charset=UTF-8");
echo '<?xml version="1.0"?>';
if (isset($posts)) {
?><rss version="2.0">
<channel>
<title>eVoyeur Tools Feed</title>
<link>http://voyeurtools.org/</link>
<description>The feed created for Voyeur.</description>
<language>en-us</language>
<pubDate><?php if(isset($posts[0])) { vwp_rssDate(strtotime($posts[0]->post_date_gmt)); } ?></pubDate>
<lastBuildDate><?php if(isset($posts[0])) { vwp_rssDate(strtotime($posts[0]->post_date_gmt)); } ?></lastBuildDate>
<?php foreach ($posts as $post) { ?>
<item>
<title><?php echo get_the_title($post->ID); ?></title>
<link><?php echo get_permalink($post->ID); ?></link>
<description><?php echo '<![CDATA['. $post->post_content .'<br/>' . ']]>'; ?></description>
<pubDate><?php vwp_rssDate(strtotime($post->post_date_gmt)); ?></pubDate>
<guid><?php echo get_permalink($post->ID); ?></guid>
</item>
<?php } // end foreach
} // end if
?>
</channel>
</rss>