San Francisco / California
Dec 17, 2006 Concert
Posted by
admin
3 de Junio del 2007
San Francisco / California
/*
Plugin Name: Simple Google Sitemap XML
Version: 1.3.2
Plugin URI: http://itx-technologies.com/blog/simple-google-sitemap-xml-for-wordpress
Description: Generates a valid Google XML sitemap with a very simple admin interface
Author: iTx Technologies
Author URI: http://itx-technologies.com/
*/
if (!defined('ABSPATH')) die("Aren't you supposed to come here via WP-Admin?");
//Pre-2.6 compatibility
if ( ! defined( 'WP_CONTENT_URL' ) )
define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
if ( ! defined( 'WP_CONTENT_DIR' ) )
define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
if ( ! defined( 'WP_PLUGIN_URL' ) )
define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
if ( ! defined( 'WP_PLUGIN_DIR' ) )
define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
/*
Genarates the actual XML sitemap file on the server
*/
function generate_xmlsitemap() {
$filename = "sitemap.xml";
if (get_option('gsxml_store') == "1") { $file_handler = fopen(WP_PLUGIN_DIR.'/simple-google-sitemap-xml/'.$filename, "w+"); }
elseif (get_option('gsxml_store') == "2") { $file_handler = fopen(ABSPATH.$filename, "w+"); }
else { $file_handler = fopen(WP_PLUGIN_DIR.'/simple-google-sitemap-xml/'.$filename, "w+"); }
if (!$file_handler) {
die;
}
else {
$content = get_content();
fwrite($file_handler, $content);
fclose($file_handler);
}
}
/*
Gets the content of the database and formats it to form valid XML
*/
function get_content() {
global $wpdb;
$table_name = $wpdb->prefix . "posts";
/* Setting default values for the settings */
if (get_option('gsxml_hp')) { $home_p = get_option('gsxml_hp'); } else { $home_p = 0.5;}
if (get_option('gsxml_hf')) { $home_f = get_option('gsxml_hf'); } else { $home_f = 'weekly';}
if (get_option('gsxml_gp')) { $other_p = get_option('gsxml_gp'); } else { $other_p = 0.5;}
if (get_option('gsxml_gf')) { $other_f = get_option('gsxml_gf'); } else { $other_f = 'weekly';}
$query = "SELECT year(post_modified) AS y, month(post_modified) AS m, day(post_modified) AS d, ID,post_title, post_modified,post_name, post_type, post_parent FROM $table_name WHERE post_status = 'publish' AND (post_type = 'page' OR post_type = 'post') ORDER BY post_date DESC";
$myrows = $wpdb->get_results($query);
$xmlcontent = ''."\n";
$xmlcontent .= '
This is the absolute URL of your XML sitemap. You can copy/paste it in Google Webmaster Tools which greatly increases the speed at which Google indexes your website.
The XML sitemap is automatically regenerated when you publish or delete a new post/page.
Dec 17, 2006 Concert
Posted by
admin
3 de Junio del 2007
San Francisco / California
Leave a Reply
You must be logged in to post a comment.