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:
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | //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:
1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 | //[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:
1775 | $useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet |
Modified version:
1791 1792 | //[NeoEGM] Line removed //$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet |
Change 3
Original version:
1954 1955 | //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:
1971 1972 1973 1974 1975 | //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:
1970 1971 1972 1973 1974 1975 1976 1977 1978 | // 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:
1990 1991 1992 1993 1994 1995 | //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…
Support appreciated!
All the content offered in this website is, except noted otherwise, of free nature. This means you can share it wherever you want if you do it freely and stating its source.
If it was useful for you and you’d like to contribute, you can make a donation or, at least, visit one of our advertisers of your choice; they are all around the site.
Incoming search terms for the article:
- qTranslatesupportfortheGoogle(XML)SitemapsGeneratorWordpressPlugin|NeoEGM com
- qtranslate
- neoegm
- Please edit wp-db inc php in wp-includes and set SAVEQUERIES to true if you want to see the queries
- google xml sitemap
- Google XML Sitemaps with qTranslate Support
- wp-db inc php
- qtrans_convertURL
- wordpress sitemap qtranslate
- qtranslate google
0 Response to “qTranslate support for the Google (XML) Sitemaps Generator WordPress Plugin”