PluginProbe ʕ •ᴥ•ʔ
XML Sitemap & Google News / 3.2
XML Sitemap & Google News v3.2
5.7.7 5.7.5 5.7.6 5.7.4 trunk 1.0 2.0 2.1 3.0 3.2 3.3 3.4 3.5 3.6.1 3.7.4 3.8.8 3.9.3 4.0.1 4.1.4 4.2.3 4.3.2 4.4.1 4.5.1 4.6.3 4.7.5 4.8.3 4.9.4 5.0.7 5.1.2 5.2.7 5.3.6 5.4.6 5.4.9 5.5.1 5.5.2 5.5.3 5.5.4 5.5.5 5.5.6 5.5.7 5.5.8 5.5.9 5.6 5.6.1 5.6.2 5.6.3 5.7 5.7.1 5.7.2 5.7.3
xml-sitemap-feed / feed-xml.php
xml-sitemap-feed Last commit date
feed-xml.php 16 years ago feed-xsl.php 16 years ago readme.txt 16 years ago xml-sitemap.php 16 years ago
feed-xml.php
88 lines
1 <?php
2 /* ---------------------------
3 XML Sitemap Feed Template
4 --------------------------- */
5
6 if (!empty($_SERVER['SCRIPT_FILENAME']) && 'feed-xml.php' == basename($_SERVER['SCRIPT_FILENAME']))
7 die ('Please do not load this page directly. Thanks!');
8
9
10 // priority presets
11 $post_priority = 0.7;
12 $minpost_priority = 0.3;
13 $maxpost_priority = 0.9;
14 $page_priority = 0.6;
15 $frontpage_priority = 1.0;
16
17 $lastpostmodified = get_lastpostmodified('GMT');
18
19 // start the xml output
20 @header('Content-Type: text/xml; charset=' . get_option('blog_charset'));
21
22 echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?>
23 <?xml-stylesheet type="text/xsl" href="'.get_option('siteurl').'/?feed=sitemap.xsl"?>
24 <!-- generated-on="'.date('Y-m-d\TH:i:s+00:00').'" -->
25 <!-- generator="XML Sitemap Feed plugin for WordPress" -->
26 <!-- generator-url="http://4visions.nl/en/index.php?section=57" -->
27 <!-- generator-version="'.XMLSFVERSION.'" -->
28 '; ?>
29 <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
30 xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"
31 xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
32 <url>
33 <loc><?php bloginfo_rss('url') ?>/</loc>
34 <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $lastpostmodified, false); ?></lastmod>
35 <changefreq>daily</changefreq>
36 <priority>1.0</priority>
37 </url>
38 <?php
39 // first check if there is a static page set as frontpage and exclude it to avoid double url
40 $has_page_as_front = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'show_on_front'");
41 if ($has_page_as_front[0]->option_value == "page") {
42 $frontpage = $wpdb->get_results("SELECT option_value FROM $wpdb->options WHERE option_name = 'page_on_front'");
43 $frontpage_id = $frontpage[0]->option_value;
44 } else {
45 $frontpage_id = -1;
46
47 }
48
49 // get all posts and pages
50 $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND ID != $frontpage_id ORDER BY post_date_gmt DESC LIMIT 1000");
51
52 // and loop away!
53 if ($post_ids) {
54 global $wp_query;
55 $wp_query->in_the_loop = true;
56
57 while ( $next_posts = array_splice($post_ids, 0, 20) ) {
58 $where = "WHERE ID IN (".join(',', $next_posts).")";
59 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt DESC");
60 foreach ($posts as $post) {
61 setup_postdata($post);
62 $post_modified_time = get_post_modified_time('Y-m-d H:i:s', true);
63 $priority_down = (($lastpostmodified - $post_modified_time) > 0) ? ($lastpostmodified - $post_modified_time)/10 : 0;
64 $priority_up = ($post->comment_count > 0) ? $post->comment_count/10 : 0;
65 $priority = $post_priority - $priority_down + $priority_up;
66 $priority = ($priority > $maxpost_priority) ? $maxpost_priority : $priority;
67 $priority = ($priority < $minpost_priority) ? $minpost_priority : $priority;
68 ?>
69 <url>
70 <loc><?php the_permalink_rss() ?></loc>
71 <lastmod><?php echo mysql2date('Y-m-d\TH:i:s+00:00', $post_modified_time, false) ?></lastmod>
72 <?php if($post->post_type == "page") { ?>
73 <changefreq>monthly</changefreq>
74 <priority><?php echo $page_priority ?></priority>
75 <?php } else {
76 if($post->comment_count > 0) { ?>
77 <changefreq>weekly</changefreq>
78 <?php } else { ?>
79 <changefreq>monthly</changefreq>
80 <?php } ?>
81 <priority><?php echo $priority ?></priority>
82 <?php } ?>
83 </url>
84 <?php }
85 }
86 } ?>
87 </urlset>
88