xml-sitemap-feed
Last commit date
readme.txt
16 years ago
template.php
16 years ago
xml-sitemap.php
16 years ago
xml-sitemap.php
58 lines
| 1 | <?php |
| 2 | /* |
| 3 | Plugin Name: XML Sitemap Feed |
| 4 | Plugin URI: http://4visions.nl/en/index.php?section=57 |
| 5 | Description: Creates a dynamic XML feed that complies to the XML Sitemap protocol ready be submitted to Google, Yahoo, MSN, Ask.com and others. Based on the Standard XML Sitemap Generator by Patrick Chia. |
| 6 | Version: 2.1 |
| 7 | Author: RavanH |
| 8 | Author URI: http://4visions.nl/ |
| 9 | Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=ravanhagen%40gmail%2ecom&item_name=XML%20Sitemap%20Feed&item_number=2%2e6%2e2%2e9&no_shipping=0&tax=0&bn=PP%2dDonationsBF&charset=UTF%2d8 |
| 10 | */ |
| 11 | |
| 12 | /* Copyright 2009 RavanH (http://4visions.nl/ email : ravanhagen@gmail.com) |
| 13 | |
| 14 | This program is free software; you can redistribute it and/or modify |
| 15 | it under the terms of the GNU General Public License as published by |
| 16 | the Free Software Foundation; either version 2 of the License, or |
| 17 | (at your option) any later version. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, |
| 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | GNU General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program; if not, write to the Free Software |
| 26 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 27 | */ |
| 28 | |
| 29 | function xml_sitemap_flush_rules() { |
| 30 | global $wp_rewrite; |
| 31 | $wp_rewrite->flush_rules(); |
| 32 | } |
| 33 | add_action('init', 'xml_sitemap_flush_rules'); |
| 34 | |
| 35 | function xml_sitemap_feed_rewrite($wp_rewrite) { |
| 36 | $feed_rules = array( |
| 37 | '^sitemap.xml$' => 'index.php?feed=sitemap', |
| 38 | '^feed/sitemap$' => 'index.php?feed=sitemap' |
| 39 | ); |
| 40 | $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; |
| 41 | } |
| 42 | add_filter('generate_rewrite_rules', 'xml_sitemap_feed_rewrite'); |
| 43 | |
| 44 | function xml_sitemap_do_feed() { |
| 45 | $dir = dirname(__FILE__); |
| 46 | if (file_exists($dir.'/xml-sitemap-feed')) // chech if xml-sitemap.php was moved one dir up (for mu-plugins in wpmu) |
| 47 | load_template( $dir . '/xml-sitemap-feed/template.php' ); |
| 48 | else |
| 49 | load_template( $dir . '/template.php' ); |
| 50 | } |
| 51 | add_action('do_feed_sitemap', 'xml_sitemap_do_feed', 10, 1); |
| 52 | |
| 53 | function xml_sitemap_robots() { |
| 54 | echo "\nSitemap: ".get_option('siteurl')."/sitemap.xml\n\n"; |
| 55 | } |
| 56 | add_action('do_robotstxt', 'xml_sitemap_robots'); |
| 57 | ?> |
| 58 |