Soporte de qTranslate para el Plugin de WordPress Google (XML) Sitemaps Generator

wordpress-logo-notext-rgb[1]

Hace algún tiempo, Qian Qin, el autor de qTranslate, publicó qué debería ser modificado en el plugin de WordPress Google (XML) Sitemaps Generator para hacer que soporte qTranslate.

Sin embargo, esto nunca llegó a una release de este plugin. (Qian Qin dice que le envió un e-mail al autor yo también lo hecho, sin recibir respuesta alguna).

Por lo tanto, voy a publicar qué debería ser modificado en el plugin (para los que quieran hacerlo ellos mismos) y luego, dejar el link para descargar la versión modificada que preparé. Voy a actualizarla para cada nueva versión que salga.

Actualización: Hice algunas correcciones yo mismo en el código para incluir las diferentes traducciones de la página inicial y para no incluir las entradas no escritas en el idioma predeterminado (sólo incluir los lenguajes definidos). la descarga y los snippets de código fueron actualizados para reflejar los cambios. Si deseás más detalles, visitá el post de la actualización.

Actualización (2009-09-30): Actualicé la nomenclatura del plugin en el repositorio de WordPress y el soporte para blogs sin qTranslate instaldo. En versiones anteriores a la 3.1.6.3, podrías ser notificado de las actualizaciones de la versión original (y no de las de esta versión que soporta qTranslate), así que realmente recomiendo actualizar. If you wish more details, please go to the post of the update.

Primero, los cambios… Todos son en el archivo sitemap-core.php

Cambio 1

Versión original:

		//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"));
			}
		}

Versión modificada:

		//[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"));
			}
		}

Cambio 2

Versión original:

$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet

Versión modificada:

//[NeoEGM] Line removed
//$useQTransLate = false; //function_exists('qtrans_convertURL') && function_exists('qtrans_getEnabledLanguages'); Not really working yet

Cambio 3

Versión original:

//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);

Versión modificada:

//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);

Cambio 4

Versión original:

// 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);
		}
	}
}

Versión modificada:

//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);

Descargar la versión modificada del plugin

Ahora, finalmente, el 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:



71 Responses to “Soporte de qTranslate para el Plugin de WordPress Google (XML) Sitemaps Generator”


Leave a Reply to Foto