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
xml-sitemap.php
91 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 with the XML Sitemap protocol to aid Google, Yahoo, MSN, Ask.com indexing your blog. Based on the Standard XML Sitemap Generator by Patrick Chia. |
| 6 | Version: 3.2 |
| 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 | /* -------------------- |
| 30 | VALUES |
| 31 | -------------------- */ |
| 32 | |
| 33 | // set version |
| 34 | define('XMLSFVERSION','3.2'); |
| 35 | |
| 36 | // check if xml-sitemap.php was moved one dir up to mu-plugins in wpmu |
| 37 | $xmlsf_dir = dirname(__FILE__); |
| 38 | if (file_exists($xmlsf_dir.'/xml-sitemap-feed')) |
| 39 | $xmlsf_dir = $xmlsf_dir . '/xml-sitemap-feed'; |
| 40 | |
| 41 | /* -------------------- |
| 42 | FUNCTIONS |
| 43 | -------------------- */ |
| 44 | |
| 45 | // FEEDS // |
| 46 | // set the XML feeds up |
| 47 | function xml_sitemap_add_feeds() { |
| 48 | global $wp_rewrite; |
| 49 | add_feed('sitemap.xml','xml_sitemap_do_feed'); |
| 50 | add_feed('sitemap.xsl','xml_sitemap_xsl_do_feed'); |
| 51 | add_action('generate_rewrite_rules', 'xml_sitemap_feed_rewrite'); |
| 52 | $wp_rewrite->flush_rules(); |
| 53 | } |
| 54 | // load XML template |
| 55 | function xml_sitemap_do_feed() { |
| 56 | global $xmlsf_dir; |
| 57 | load_template( $xmlsf_dir . '/feed-xml.php' ); |
| 58 | } |
| 59 | // load XSL (style) template |
| 60 | function xml_sitemap_xsl_do_feed() { |
| 61 | global $xmlsf_dir; |
| 62 | load_template( $xmlsf_dir . '/feed-xsl.php' ); |
| 63 | } |
| 64 | // add the rewrite rules |
| 65 | function xml_sitemap_feed_rewrite($wp_rewrite) { |
| 66 | $feed_rules = array( |
| 67 | //'feed/(.+)' => 'index.php?feed='.$wp_rewrite->preg_index(1), |
| 68 | //'^feed/sitemap$' => 'index.php?feed=sitemap', |
| 69 | '^sitemap.xml$' => 'index.php?feed=sitemap.xml', |
| 70 | '^sitemap.xsl$' => 'index.php?feed=sitemap.xsl' |
| 71 | ); |
| 72 | $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules; |
| 73 | } |
| 74 | |
| 75 | // ROBOTSTXT // |
| 76 | // get sitemap location in robots.txt generated by WP |
| 77 | function xml_sitemap_robots() { |
| 78 | echo "\nSitemap: ".get_option('siteurl')."/sitemap.xml\n\n"; |
| 79 | } |
| 80 | |
| 81 | /* -------------------- |
| 82 | HOOKS |
| 83 | -------------------- */ |
| 84 | |
| 85 | // FEEDS |
| 86 | add_action('init', 'xml_sitemap_add_feeds'); |
| 87 | |
| 88 | // ROBOTSTXT |
| 89 | add_action('do_robotstxt', 'xml_sitemap_robots'); |
| 90 | ?> |
| 91 |