function dsq_qtrans_translate($text)
{
    if (function_exists('qtranxf_useCurrentLanguageIfNotFoundShowEmpty')) {
        return qtranxf_useCurrentLanguageIfNotFoundShowEmpty($text);
    } else {
        return qtrans_useCurrentLanguageIfNotFoundShowEmpty($text);
    }
}
function qtranxf_esc_html($text)
{
    //qtranxf_dbg_echo('qtranxf_esc_html:text=',$text,true);
    //return qtranxf_useDefaultLanguage($text);//this does not make sense, does it? - original code
    //return qtranxf_useCurrentLanguageIfNotFoundUseDefaultLanguage($text);
    /**
     * since 3.1-b1
     * used to return qtranxf_useDefaultLanguage($text)
     */
    return qtranxf_useCurrentLanguageIfNotFoundShowEmpty($text);
}
 public function getProductList($parent, $remote_category)
 {
     global $wpdb;
     global $pfcore;
     $parent->logActivity('Retrieving product list from database');
     if ($this->products == null) {
         $this->loadProducts($parent);
     }
     $master_product_list = array();
     $this->woocommerce_manage_stock = get_option('woocommerce_manage_stock');
     $this->woocommerce_notify_no_stock_amount = get_option('woocommerce_notify_no_stock_amount');
     //********************************************************************
     //Convert the WP_Product List into a Cart-Product Master List (ListItems)
     //********************************************************************
     foreach ($this->products as $index => $prod) {
         if ($index % 100 == 0) {
             $parent->logActivity('Converting master product list...' . round($index / count($this->products) * 100) . '%');
         }
         //if skip product with non-matching category
         $category_ids = explode(',', $prod->category_ids);
         $skip = true;
         foreach ($category_ids as $id) {
             if ($parent->categories->containsCategory($id)) {
                 $skip = false;
                 break;
             }
         }
         if ($parent->force_all_categories) {
             $skip = false;
         }
         if ($skip) {
             continue;
         }
         $category_names = explode(',', $prod->category_names);
         //if parent has variations, do we need it?
         if ($parent->categories->containsCategory($prod->variation_ids)) {
             continue;
         }
         //Duplicate check
         if ($parent->ignoreDuplicates) {
             $skip_this_item = isset($master_product_list[$prod->ID]);
             $master_product_list[$prod->ID] = 1;
             if ($skip_this_item) {
                 continue;
             }
         }
         //Prepare the item
         $item = new PAProductW();
         //extends PAProduct (basicfeed.php)
         //Basics
         $item->id = $prod->ID;
         $item->attributes['id'] = $prod->ID;
         if (function_exists(qtranxf_use)) {
             $item->attributes['title'] = qtranxf_useCurrentLanguageIfNotFoundShowEmpty($prod->post_title);
         } else {
             $item->attributes['title'] = $prod->post_title;
         }
         $item->taxonomy = $category_names;
         $item->attributes['isVariable'] = $prod->product_type == 'variable';
         $item->attributes['isVariation'] = false;
         $item->description_short = substr(strip_shortcodes(strip_tags($prod->post_excerpt)), 0, 5000);
         if (isset($item->description_short)) {
             if (function_exists(qtranxf_use)) {
                 $item->attributes['description_short'] = qtranxf_useCurrentLanguageIfNotFoundShowEmpty($item->description_short);
             } else {
                 $item->attributes['description_short'] = $item->description_short;
             }
         }
         if (function_exists(qtranxf_use)) {
             $item->description_long = qtranxf_useCurrentLanguageIfNotFoundShowEmpty(substr(strip_shortcodes(strip_tags($prod->post_content)), 0, 5000));
         } else {
             $item->description_long = substr(strip_shortcodes(strip_tags($prod->post_content)), 0, 5000);
         }
         if (isset($item->description_long)) {
             $item->attributes['description_long'] = $item->description_long;
         }
         $item->attributes['valid'] = true;
         //Fetch any default attributes Stage 0 (Mapping 3.0)
         foreach ($parent->attributeDefaults as $thisDefault) {
             if ($thisDefault->stage == 0 && !$thisDefault->isRuled && !isset($item->attributes[$thisDefault->attributeName])) {
                 $item->attributes[$thisDefault->attributeName] = $thisDefault->getValue($item);
             }
         }
         //Assign related data (like brands and tags)
         foreach ($this->relatedData as $index => $relation) {
             $relation->check($index, $item);
         }
         $item->attributes['currency'] = $parent->currency;
         $item->attributes['weight_unit'] = $parent->weight_unit;
         $item->attributes['dimension_unit'] = $parent->dimension_unit;
         $item->attributes['category'] = str_replace(".and.", " & ", str_replace(".in.", " > ", $remote_category));
         $item->attributes['product_type'] = str_replace(".and.", " & ", str_replace(".in.", " > ", $remote_category));
         $item->attributes['localCategory'] = str_replace(".and.", " & ", str_replace(".in.", " > ", $category_names[0]));
         $item->attributes['localCategory'] = str_replace("|", ">", $item->attributes['localCategory']);
         $item->attributes['category_id'] = $category_ids[0];
         $item->attributes['category_ids'] = $category_ids;
         $item->attributes['link'] = get_permalink($prod->ID);
         $item->attributes['thumb_ID'] = get_post_thumbnail_id($prod->ID);
         $thumb = wp_get_attachment_image_src($item->attributes['thumb_ID'], 'small-feature');
         $item->attributes['feature_imgurl'] = $thumb['0'];
         $item->attributes['condition'] = 'New';
         $item->attributes['regular_price'] = 0;
         $item->attributes['has_sale_price'] = false;
         $item->attributes['stock_status'] = 1;
         $item->attributes['stock_quantity'] = 0;
         //needs a non-zero-length -K
         $item->attributes['weight'] = null;
         //should not be 0
         //API calls now optional... disabled by default
         if ($parent->force_wc_api) {
             $product = get_product($prod->ID);
             //WooCommerce - get product by id
             $attachments = $product->get_gallery_attachment_ids();
             $attachments = array_diff($attachments, array($thumb_ID));
             if ($attachments) {
                 foreach ($attachments as $attachment) {
                     $thumb = wp_get_attachment_image_src($attachment, 'small-feature');
                     $imgurl = $thumb['0'];
                     if (strlen($imgurl) > 0) {
                         $item->imgurls[] = $imgurl;
                     }
                 }
             }
             $this->loadProductFromWCAPI($parent, $item, $product);
         }
         //Attributes (General) (Deprecated)
         if (!$parent->allow_attribute_details || strlen($prod->attribute_list) == 0) {
             $attributes = array();
         } else {
             $attributes = unserialize($prod->attribute_list);
         }
         foreach ($attributes as $attindex => $this_attribute) {
             if (isset($this_attribute['name']) && strlen($this_attribute['name']) > 0 && strpos($this_attribute['name'], 'pa_') === false) {
                 $item->attributes[$this_attribute['name']] = $this_attribute['value'];
             }
         }
         /*
         			//Attributes (Detailed)
         			//The attribute_details in the form:
         			//  pa_attribute=slug=example,pa_attribute2=slug2=example2,pa_attribute3=slug3=example3
         			//convert to:
         			//  item->attributes[attribute]=example; item->attributes[attribute2]=example2; etc
         			if ($parent->allow_attributes)
         				$item->attribute_details = explode(',', $prod->attribute_details);
         			else
         				$item->attribute_details = array();
         
         			foreach($item->attribute_details as $this_attribute) {
         				$this_attribute = explode('=', $this_attribute);
         				if (count($this_attribute) > 1) {
         					$item->attributes[substr($this_attribute[0], 3)] = $this_attribute[2];
         					//if ($parent->create_attribute_slugs) 
         						$item->attributes['_' . $this_attribute[0]] = $this_attribute[1];
         				}
         			}*/
         if ($parent->allow_attributes) {
             $item->attribute_details = explode(',', $prod->attribute_details);
         } else {
             $item->attribute_details = array();
         }
         $item->taxonomies = new PTaxonomyList();
         foreach ($item->attribute_details as $this_attribute) {
             $this_attribute = explode('=', $this_attribute);
             if (count($this_attribute) > 1) {
                 $taxonomy = new stdClass();
                 $taxonomy->name = substr($this_attribute[0], 3);
                 $taxonomy->slug = $this_attribute[1];
                 $taxonomy->value = $this_attribute[2];
                 $item->taxonomies->add($taxonomy);
             }
         }
         $this->postmetaLookup($item, $parent);
         $item->variation_ids = $prod->variation_ids;
         //$item->fetch_meta_attributes(); //Old
         foreach ($this->custom_fields as $custom_field) {
             if ($custom_field->post_id == $item->id) {
                 $item->attributes[$custom_field->meta_key] = $custom_field->meta_value;
             }
         }
         //If woocommerce-google-merchant-center, we have to do extra work to extract data
         if ($this->gmc_active && strlen($prod->gmc_value) > 0) {
             $gmc_attributes = unserialize($prod->gmc_value);
             foreach ($gmc_attributes as $key => $this_attribute) {
                 //Use this_attribute if no overrides force us to use any attributes OR if there are overrides and in_array()
                 if (count($parent->gmc_attributes) == 0 || in_array($key, $parent->gmc_attributes)) {
                     switch ($key) {
                         case 'description':
                             if (strlen($item->description_short) == 0) {
                                 $item->description_short = $this_attribute;
                             }
                             if (strlen($item->description_long) == 0) {
                                 $item->description_long = $this_attribute;
                             }
                             break;
                         case 'product_type':
                             $item->attributes['product_type'] = $this_attribute;
                             break;
                         case 'category':
                             $item->attributes['localCategory'] = $this_attribute;
                             break;
                         case 'condition':
                             $item->attributes['condition'] = $this_attribute;
                             break;
                         case 'shipping_weight':
                             $item->attributes['weight'] = $this_attribute;
                             break;
                         default:
                             $item->attributes[$key] = $this_attribute;
                     }
                 }
             }
         }
         //Fetch any default attributes Stage 5 (Mapping 3.1)
         if ($parent->attributeDefaultStages[5] > 0) {
             foreach ($parent->attributeDefaults as $thisDefault) {
                 if ($thisDefault->stage == 5 && !$thisDefault->isRuled) {
                     $item->attributes[$thisDefault->attributeName] = $thisDefault->getValue($item);
                 }
             }
         }
         if ($item->attributes['isVariable']) {
             $this->applyWCAttributes($item);
             $this->expandProduct($item, $parent);
         } else {
             $item->parent_manage_stock = 'no';
             $this->applyWCAttributes($item);
             $parent->handleProduct($item);
             foreach ($item->attributes as &$x) {
                 unset($x);
             }
             unset($item);
         }
     }
     $parent->logActivity('ProductList successfully generated.');
 }