This is what I did in case anyone has similar problems
add_action('plugins_loaded', 'replace_index', 999);
function replace_index (){
include_once(WP_PLUGIN_DIR . "/google-sitemap-generator/sitemap-builder.php");
if ( class_exists( 'GoogleSitemapGeneratorStandardBuilder' ) ) {
Class sfGoogleSitemapGeneratorStandardBuilder extends GoogleSitemapGeneratorStandardBuilder {
function __construct() {
$this->unregister_parent_hook();
add_action('sm_build_index',array($this,'Index'), 10, 1);
}
function unregister_parent_hook() {
global $wp_filter;
if (!empty($wp_filter['sm_build_index'])) {
foreach($wp_filter['sm_build_index'] as $cb) {
foreach ($cb as $k => $v) {
if (
isset($v['function'])
&& is_a($v['function'][0],'GoogleSitemapGeneratorStandardBuilder')
&& isset($v['function'][1])
&& 'Index' == $v['function'][1]
) {
remove_action('sm_build_index',$k);
}
}
}
}
}
/**
* Generates the sitemap index
*
* @param $gsg GoogleSitemapGenerator
*/
public function Index($gsg) {
/**
* @var $wpdb wpdb
*/
global $wpdb;
$blogUpdate = strtotime(get_lastpostmodified('gmt'));
$gsg->AddSitemap("misc", null, $blogUpdate);
$taxonomies = $this->GetEnabledTaxonomies($gsg);
foreach($taxonomies AS $tax) {
$gsg->AddSitemap("tax", $tax, $blogUpdate);
}
$pages = $gsg->GetPages();
if(count($pages) > 0) {
foreach($pages AS $page) {
if($page instanceof GoogleSitemapGeneratorPage && $page->GetUrl()) {
$gsg->AddSitemap("externals", null, $blogUpdate);
break;
}
}
}
$enabledPostTypes = $gsg->GetActivePostTypes();
$hasEnabledPostTypesPosts = false;
$hasPosts = false;
if(count($enabledPostTypes) > 0) {
$excludedPostIDs = $gsg->GetExcludedPostIDs($gsg);
$exPostSQL = "";
if(count($excludedPostIDs) > 0) {
$exPostSQL = "AND p.ID NOT IN (" . implode(",", $excludedPostIDs) . ")";
}
$excludedCategoryIDs = $gsg->GetExcludedCategoryIDs($gsg);
$exCatSQL = "";
if(count($excludedCategoryIDs) > 0) {
$exCatSQL = "AND ( p.ID NOT IN ( SELECT object_id FROM {$wpdb->term_relationships} WHERE term_taxonomy_id IN (" . implode(",", $excludedCategoryIDs) . ")))";
}
$lang = ICL_LANGUAGE_CODE;
foreach($enabledPostTypes AS $postType) {
$q = "
SELECT
YEAR(p.post_date_gmt) AS <code>year</code>,
MONTH(p.post_date_gmt) AS <code>month</code>,
COUNT(p.ID) AS <code>numposts</code>,
MAX(p.post_modified_gmt) as <code>last_mod</code>,
ID
FROM
{$wpdb->posts} p, {$wpdb->prefix}icl_translations wicl_translations
WHERE
p.post_password = ''
AND p.post_type = '" . esc_sql($postType) . "'
AND p.post_status = 'publish'
AND p.ID = wicl_translations.element_id
AND wicl_translations.language_code = '$lang'
$exPostSQL
$exCatSQL
GROUP BY
YEAR(p.post_date_gmt),
MONTH(p.post_date_gmt)
ORDER BY
p.post_date_gmt DESC";
$posts = $wpdb->get_results($q);
if($posts) {
if($postType=="post") $hasPosts = true;
$hasEnabledPostTypesPosts = true;
foreach($posts as $post) {
//print_r($post);
$gsg->AddSitemap("pt", $postType . "-" . sprintf("%04d-%02d", $post->year, $post->month), $gsg->GetTimestampFromMySql($post->last_mod));
}
}
}
//Only include authors if there is a public post with a enabled post type
if($gsg->GetOption("in_auth") && $hasEnabledPostTypesPosts) $gsg->AddSitemap("authors", null, $blogUpdate);
//Only include archived if there are posts with postType post
if($gsg->GetOption("in_arch") && $hasPosts) $gsg->AddSitemap("archives", null, $blogUpdate);
}
}
new sfGoogleSitemapGeneratorStandardBuilder();
}
}