/** * Gets rating results * * @param unknown_type $params */ public static function get_rating_results($params = array()) { extract(wp_parse_args($params, array('taxonomy' => null, 'term_id' => 0, 'limit' => 10, 'result_type' => Multi_Rating::STAR_RATING_RESULT_TYPE, 'sort_by' => 'highest_rated', 'post_id' => null))); $order_by = array(); if ($sort_by == 'post_title_asc') { $order_by = array('post_title ASC'); } else { if ($sort_by == 'post_title_desc') { $order_by = array('post_title DESC'); } } $group_by = array('rie.post_id'); $rating_entries = Multi_Rating_API::get_rating_item_entries(array('taxonomy' => $taxonomy, 'term_id' => $term_id, 'post_id' => $post_id, 'order_by' => $order_by, 'group_by' => $group_by)); $rating_results = array(); foreach ($rating_entries as $rating_entry) { $temp_post_id = $rating_entry['post_id']; $rating_result = Multi_Rating_API::get_rating_result($temp_post_id); // WPML get adjusted post id for active language and override if (function_exists('icl_object_id')) { $rating_result['post_id'] = icl_object_id($temp_post_id, get_post_type($temp_post_id), true, ICL_LANGUAGE_CODE); } array_push($rating_results, $rating_result); } // TODO pagination $rating_results = array_slice(MR_Utils::sort_rating_results($rating_results, $sort_by, $result_type), 0, $limit); return $rating_results; }