Added support for mqTranslate
-
Hi, I added by myself the support for mqTranslate plugin.
Is it possibile to include it into an official release?
Here are the changes (please look at the <AP 16/12/2014> comments):
function replace_sitemap_content( $content ) {
global $post;
if ( $this->option[‘post_id’] && $post->ID == $this->option[‘post_id’] ) {
if ( isset( $_GET[‘category’] ) && $category = get_category( (int)$_GET[‘category’] ) ) {
$sitemap_content = $this->make_category_sitemap( $category );
} else {
// <AP 16/12/2014>/*$cache_dir = $this->check_cache_dir();
if ( $cache_dir && file_exists( $cache_dir . ‘/site_map_cache.html’ ) && $this->option[‘use_cache’] ) {
$sitemap_content = file_get_contents( $cache_dir . ‘/site_map_cache.html’ );
} else {
$sitemap_content = $this->create_sitemap_content();
}*/if (function_exists(‘qtrans_getLanguage’)) {
$cache_file_name = ‘/site_map_cache’ . qtrans_getLanguage() . ‘.html’;
} else {
$cache_file_name = ‘/site_map_cache.html’;
}$cache_dir = $this->check_cache_dir();
if ( $cache_dir && file_exists( $cache_dir . $cache_file_name ) && $this->option[‘use_cache’] ) {
$sitemap_content = file_get_contents( $cache_dir . $cache_file_name );
} else {
$sitemap_content = $this->create_sitemap_content();
}// </AP 16/12/2014>
}
$content = preg_replace( ‘/(<p><!– SITEMAP CONTENT REPLACE POINT –><\/p>|<!– SITEMAP CONTENT REPLACE POINT –>)/’, $sitemap_content, $content, 1 );
}
return $content;
}function make_posts_list_in_category( $ex_post_ids, $cat_id, $has_child ) {
global $wpdb;$post_list_in_category = ”;
$query = “
SELECTposts
.ID
,
posts
.post_title
FROM $wpdb->posts asposts
INNER JOIN $wpdb->term_relationships asrelation
ON (posts
.ID
=relation
.object_id
)
INNER JOIN $wpdb->term_taxonomy astaxonomy
ON (relation
.term_taxonomy_id
=taxonomy
.term_taxonomy_id
)
INNER JOIN $wpdb->terms asterms
ON (taxonomy
.term_id
=terms
.term_id
)
WHEREposts
.post_status
= ‘publish’
ANDposts
.post_type
= ‘post’
ANDposts
.ID
NOT IN ( $ex_post_ids )
ANDterms
.term_id
= ‘$cat_id’
GROUP BYposts
.ID
ORDER BYposts
.post_date
DESC”;
$category_posts = $wpdb->get_results( $query, ARRAY_A );
if ( $category_posts ) {
$post_list_in_category .= “\n- \n”;
foreach( $category_posts as $post ) {
// <AP 16/12/2014>if (function_exists(‘qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage’)) {
$post[‘post_title’] = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($post[‘post_title’]);
}// </AP 16/12/2014>
$post_list_in_category .= “\t” . ‘<li class=”post-item post-item-‘ . $post[‘ID’] . ‘”>‘ . esc_html( $post[‘post_title’] ) . “\n”;
}
if ( ! $has_child ) {
$post_list_in_category .= “\n”;
}
}
return $post_list_in_category;
}
- The topic ‘Added support for mqTranslate’ is closed to new replies.