![wordpress-logo-notext-rgb[1] wordpress-logo-notext-rgb[1]](http://www.neoegm.com/wp-content/uploads/2009/09/wordpress-logo-notext-rgb1-150x150.png)
Some time ago, Qian Qin, the author of qTranslate, has published what should be modified on the Google (XML) Sitemaps Generator Wordpress Plugin to make it support qTranslate.
However, this has never reached any of the releases of this plugin. (Qian Qin says he sent an e-mail to the author and I’ve done it myself, with no response).
So, I’m going to publish what should be modified on the plugin (for the ones who may want to do them themselves) and then, leave the link to download the modified version I prepared. I’ll be updating it for each new release.
Update: I’ve made some code corrections myself to include the different translations of the home page and not to include the entries not written in the default language (just include the written languages). The download and the code snippets have been updated to reflect the changes. If you wish more details, please go to the post of the update.
Update (2009-09-30): I’ve updated the naming of the plugin at the Wordpress repository and the support for blogs without qTranslate installed. For releases before the 3.1.6.3, you may get notified for the original version updates (and not for this version supporting qTranslate), so I really recommend updating. If you wish more details, please go to the post of the update.
First, the changes… They are all made in the sitemap-core.php file…
Change 1
Original version:
//Add the home page (WITH a slash!)
if($this->GetOption("in_home")) {
if('page' == get_option('show_on_front') && get_option('page_on_front')) {
$pageOnFront = get_option('page_on_front');
$p = get_page($pageOnFront);
if($p) {
$homePid = $p->ID;
$this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
}
} else {
$this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
}
}
Modified version:
//[NeoEGM] Moved here for home page support for different languages
$useQTransLate = function_exists('qtrans_convertURL') && function_exists('qtrans_getAvailableLanguages');
global $q_config;
//Add the home page (WITH a slash!)
if($this->GetOption("in_home")) {
if('page' == get_option('show_on_front') && get_option('page_on_front')) {
$pageOnFront = get_option('page_on_front');
$p = get_page($pageOnFront);
if($p) {
$homePid = $p->ID;
$this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
//[NeoEGM] Home page support for different languages
if($useQTransLate)
foreach($q_config['enabled_languages'] as $language)
if($language != $q_config['default_language'])
$this->AddUrl(qtrans_convertURL( trailingslashit($home), $language, true), $this->GetTimestampFromMySql( ($p->post_modified_gmt && $p->post_modified_gmt != '0000-00-00 00:00:00' ? $p->post_modified_gmt : $p->post_date_gmt)), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
}
} else {
$this->AddUrl(trailingslashit($home), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
//[NeoEGM] Home page support for different languages
if($useQTransLate)
foreach($q_config['enabled_languages'] as $language)
if($language != $q_config['default_language'])
$this->AddUrl(qtrans_convertURL( trailingslashit($home), $language, true), $this->GetTimestampFromMySql( get_lastpostmodified('GMT')), $this->GetOption("cf_home"), $this->GetOption("pr_home"));
}
}
Change 2
Original version:
$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
Modified version:
//[NeoEGM] Line removed
//$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet
Change 3
Original version:
//Add it $this->AddUrl($permalink,$this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage?$cf_pages:$cf_posts), $prio);
Modified version:
//Add it //[NeoEGM] Add it only if the default language is defined, otherwise only add the defined languages $QTranslateLanguages = qtrans_getAvailableLanguages($post->post_content); if (in_array($q_config['default_language'], $QTranslateLanguages)) $this->AddUrl($permalink, $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage?$cf_pages:$cf_posts), $prio);
Change 4
Original version:
// Multilingual Support with qTranslate, thanks to Qian Qin
if ($useQTransLate) {
global $q_config;
foreach (qtrans_getEnabledLanguages($post->post_content) as $language) {
if ($language != $q_config['default_language']) {
$this->AddUrl(qtrans_convertURL($permalink, $language), $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage ? $cf_pages : $cf_posts), $prio);
}
}
}
Modified version:
//Multilingual Support with qTranslate, thanks to Qian Qin //[NeoEGM] Moved up the global variable scope line if ($useQTransLate) foreach (qtrans_getAvailableLanguages($post->post_content) as $language) if ($language != $q_config['default_language']) $this->AddUrl(qtrans_convertURL($permalink, $language, true), $this->GetTimestampFromMySql( ($post->post_modified_gmt && $post->post_modified_gmt != '0000-00-00 00:00:00' ? $post->post_modified_gmt : $post->post_date_gmt)), ($isPage ? $cf_pages : $cf_posts), $prio);
Download modified plugin version
Now, finally, the link…
Related posts:
- Updated: qTranslate support for the Google (XML) Sitemaps Generator Wordpress Plugin 3.1.6 (2nd Release)
- Google (XML) Sitemaps Generator with qTranslate support now available at the Wordpress Repository
- Important Update: Google (XML) Sitemaps Generator with qTranslate support (Version 3.1.6.3)
- WP-No-Format WordPress Plugin (Prevent HTML Code Formatting/Modification)
- Hide Wordpress Visual Editor Tab 1.01
Sorry but the plugin you have patched seems to have some problems:
if a post is published only in one language out of the default, the sitemap will contain two URLs, one pointing to the correct post version, one pointing to the wrong default language:
example, at mysite.com, default language EN (english) , and additional language DE (german), there’s a post with permalink “a-german-post”; in sitemap.xml you have:
http://mysite.com/de/a-german-post (CORRECT)
but also
http://mysite.com/a-german-post (WRONG)
Check it out
Hi Blutarsky!
Thanks for your comment!
First of all, just as I said in the post, I haven’t made the patch myself… I’ve only integrated it with the latest plugin version since its author was not taking care of the sent mails…
It’s completely logical what you’re saying and I hadn’t found it since I’ve always written every post in both languages…
I’ll check it and publish a new patched version soon!
I’ll make a new post to notify the availability of the new version, so if you’re subscribed to the RSS, you’ll know as soon as I release it… Otherwise, take a look to the site frequently…
Greetings!
NeoEGM.
Thanks for helping! Why not adding the “subscribe to comments” plugin to your blog?
You’re welcome
I will! But I have some things to configure on my mail server… That’s why I haven’t done it yet!
Thanks for the suggestion!
NeoEGM.
BTW, I’m stuck with sitemap generation
….do you have any scheduled date for the next release?
Don’t worry! I’ll prepare it within these days… I’ll release it this weekend! Probably today or tomorrow…
Greetings!
NeoEGM.
Done, I’ve just updated the plugin.
Now it works as you expected
Also, I added the support for the home page in different languages. It always get added in all the available languages.
Enjoy it!
NeoEGM.
Will be testing it now! Thanks mate!
Yes! You did it! Thumbs up!
Excellent!
Enjoy it
NeoEGM.
Two questions.
1) How do I know I have patched correctly the oroginal plugin? Is there any evidence in the admin panel?
2) Is there a comfortable way to upgrade the plugin? I think it basically depends on the plugin itself, if it performs some database operation while upgrading; if not it’s just an upload matter…. can you confirm?
Hi! I was just analyzing which was the best way to do that…
1- No, there is no evidence by now. I’ll add some kind of legend to the plugin description.
2- There is no database extra-work in the patched plugin, it’s just matter of replacing the plugin files. Anyway I’m thinking of publishing the patched plugin in the Wordpress repository in order to allow the automatic upgrading.
Greetings!
NeoEGM.
Great, because at the moment either you need to delete the plugin (maybe loosing settings) and install your patched version, or you can brute-force upload your plugin with an FTP-like program, rewriting current data….
No uninstall is needed, just overwritting the files via http://FTP...
No settings are lost…
Anyway, I’ll be easier to just have a patched plugin in the repository and be able to install it directly and upgrade it automatically!
I’ll tell you when I release it!
NeoEGM.
Just as I promised some time ago, I’ve just published the plugin in the Wordpress Repository.
You can now download the latest version from here and you’ll get notified by Wordpress when I release a newer version.
Enjoy it
NeoEGM.
Has anything changed for those who doesn’t use qTranslate? I mean should I update the plugin if I don’t use qtranslate?
Not by now… The only current difference beween this version and the original one is the qTranslate support…
Thanks for your question!
NeoEGM.
hi there. having a problem with your plugin and google webmaster tools. reported it here in the wordpress forums: http://wordpress.org/support/topic/314704?replies=0
any ideas? google is saying my links are broken but hey are jsut fine !?
Hi ovidiu!
Perhaps, when Google visited your site, it was down or busy and some of your links became “broken” because of that…
Check the “detection” date in Webmaster Tools…
I don’t think the plugin has anything to do with that… It just lists the URLs in your site…
Check something, open http://www.example.com/sitemap.xml (replacing “example” with your site’s domain) and click randomly your links. You’ll see they are not broken.
Other option is that Google is declaring as broken some links not on your sitemap. For example, bad external links or changed permalinks obtained from somewhere else.
That’s all!
Hope it helps!
NeoEGM.
the site was up, no problems there. I even resubmitted and got the same results
will give it one more try, and yes, I know the links inside the sitemap are working….
besides there are no broken external links either, and google specifically complained about the links inside the sitemap, decalred all 76 of the broken
Hi ovidiu!
I’ve just checked your robots.txt file…
This is its content:
# BEGIN XML-SITEMAP-PLUGINSitemap: http://pacura.ru/sitemap.xml.gz
# END XML-SITEMAP-PLUGIN
User-agent: *
Disallow: /error/
Disallow: /stats/
Disallow: /cgi-bin/
Disallow: /images/
Disallow: /wp-admin
Disallow: /wp-includes
Disallow: /wp-content
Try to remove the last two lines…
Perhaps thew were added by some plugin. But, for example, the uploaded media and the theme data is stored in /wp-content, and any link to them will get declared as broken.
On the other side, the /wp-includes directory contains lots of files, some of which are directly included in your pages (.js, .xml, etc.).
Try to do that and tell me your results!
Hope it helps!
NeoEGM.
Hi,
could you change the title of the plugin to something like “Google XML Sitemaps for qTranslate”? I just downloaded the plugin because I thought it was the normal one but got fatal errors because it didn’t find the qTranslate functions.
Thanks,
Theo
Hi Theo!
The name of the plugin should always have been “Google XML Sitemaps with qTranslate Support”. It was my mistake.
I’ve just fixed it and also added support for qTranslate not installed. (It now works without problems whether you have qTranslate installed or not).
Thanks for your comment!
NeoEGM.
Tnx ! Looks like a great plugin, going to install right now!
Thanks!
I’ve only published it in a qTranslate compatible version, based in the original “Google XML Sitemaps”…
Thanks for you comment!
NeoEGM.
Thank you so much, it seems to work straight off the bat. You are a legend!
Hi Nick!
Thanks for your comment!
Just as I told Fred, the original version of this plugin was not written by me… I’ve just made the adaptation to make it work correctly with qTranslate, based in the code published by Qian Qin…
Enjoy it
NeoEGM.
добавьте генерацию Sitemap в формате HTML для посетителей
Translation: add to generate a Sitemap in HTML format for visitors
Hi Foto,
You can use most of these plugins to perform the task you need:
http://wordpress.org/extend/plugins/search.php?q=sitemap+generator
Hope it helps!
NeoEGM.
Thanks a lot for your effort, this is a great time saver.
I’ve noticed some links are not referenced in the sitemap ; category, tag and author are only listed for the default language, I can’t see /alt_lang/category/, /alt_lang/tag/ and /alt_lang/author/ listed in the sitemap. Is this a problem on my end or a known limitation ?
Best,
Fred
Same for the archives as well, I forgot that one.
Hi Frederic!
I’ll check it out and reply you!
Thanks for your comment!
NeoEGM.
Hi NeoEGM,
Thanks for having a look at this, feel free to drop me a line should you need some more information.
Best,
Fred
It doesnt referenced Static page either…
Hi Nicolas!
Thanks for your comments…
I’ll take a look as soon as I have time and reply you…
Greetings!
NeoEGM.
Can’t install- says the header is missing. I have mac and am using safari. Thanks
Hi Sarita,
Could you please send me the exact message displayed and when does it get shown?
Also, I’d need a list of all your enabled plugins…
Thanks!
NeoEGM.
Other problem, if the name of your post is different for each language, it just show the name of the post of the default language.
If the post is called “test fr” for the french and “test en” for english” it show up like that in the sitemap.xml :
http://localhost/ze/blog/test-fr.html (CORRECT)
http://localhost/ze/en/blog/test-fr.html (WRONG)
The second should be : http://localhost/ze/en/blog/test-en.html
Very nice plug-in, thank you to share!
Hi tansuozhe!
Thanks for your comment!
I’m glad it’s useful for you!
Greetings!
NeoEGM.
hello my friends,
i have a problem look @this:
FIRST SITE:
# There was a problem writing your sitemap file. Make sure the file exists and is writable. Learn more
# There was a problem writing your zipped sitemap file. Make sure the file exists and is writable. Learn more
“but sitemap.xml and xitemap.xml.gz is on 777″ in the directory
DEBUG SITE:
Errors, Warnings, Notices
Warning: fopen(/www/htdocs/w00c2b7c/sitemap.xml) [function.fopen]: failed to open stream: Is a directory in /www/htdocs/w00c2b7c/wp-content/plugins/google-xml-sitemaps-with-qtranslate-support/sitemap-core.php on line 1698
Warning: gzopen(/www/htdocs/w00c2b7c/sitemap.xml.gz) [function.gzopen]: failed to open stream: Is a directory in /www/htdocs/w00c2b7c/wp-content/plugins/google-xml-sitemaps-with-qtranslate-support/sitemap-core.php on line 1711
MySQL Queries
Please edit wp-db.inc.php in wp-includes and set SAVEQUERIES to true if you want to see the queries.
greetings!
Hi Mario!
Sorry for the delay, I was on vacation…
I’ve just checked your site and it seems to have sitemap.xml and sitemap.xml.gz correctly created…
According to the info you sent me you had directories instead of files at those paths….
Greetings!
NeoEGM.