Support » Plugin: PS Auto Sitemap » 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 = “
    SELECT posts.ID,
    posts.post_title
    FROM $wpdb->posts as posts
    INNER JOIN $wpdb->term_relationships as relation
    ON ( posts.ID = relation.object_id )
    INNER JOIN $wpdb->term_taxonomy as taxonomy
    ON (relation.term_taxonomy_id = taxonomy.term_taxonomy_id )
    INNER JOIN $wpdb->terms as terms
    ON ( taxonomy.term_id = terms.term_id )
    WHERE posts.post_status = ‘publish’
    AND posts.post_type = ‘post’
    AND posts.ID NOT IN ( $ex_post_ids )
    AND terms.term_id = ‘$cat_id’
    GROUP BY posts.ID
    ORDER BY posts.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;
    }

    https://wordpress.org/plugins/ps-auto-sitemap/

  • The topic ‘Added support for mqTranslate’ is closed to new replies.