public function GetRatingDataByRatingID($pRatingID, $pAccuracy = false) { if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence('GetRatingDataByRatingID', $params); } // API only supported in the Professional plan, so no reason to make calls that will return errors. if (!$this->fs->is_plan_or_trial('professional') || !$this->is_api_supported()) { return false; } $rating = rwapi()->get('/ratings/' . $pRatingID . '.json?is_external=true&fields=id,approved_count,avg_rate', false, WP_RW__CACHE_TIMEOUT_RICH_SNIPPETS); if (isset($rating->error)) { return false; } $avg_rate = (double) $rating->avg_rate; $votes = (int) $rating->approved_count; $rate = $votes * $avg_rate; if (is_numeric($pAccuracy)) { $pAccuracy = (int) $pAccuracy; $avg_rate = (double) sprintf("%.{$pAccuracy}f", $avg_rate); $rate = (double) sprintf("%.{$pAccuracy}f", $rate); } return array('votes' => $votes, 'totalRate' => $rate, 'rate' => $avg_rate); }
function GetRatingDataByRatingID($pRatingID, $pAccuracy = false) { if (RWLogger::IsOn()) { $params = func_get_args(); RWLogger::LogEnterence('GetRatingDataByRatingID', $params); } if (!$this->_rw_is_running() || false === rwapi()) { return false; } $rating = $this->ApiCall('/ratings/' . $pRatingID . '.json?is_external=true&fields=id,approved_count,avg_rate', 'GET', array(), WP_RW__CACHE_TIMEOUT_RICH_SNIPPETS); if (isset($rating->error)) { return false; } $avg_rate = (double) $rating->avg_rate; $votes = (int) $rating->approved_count; $rate = $votes * $avg_rate; if (is_numeric($pAccuracy)) { $pAccuracy = (int) $pAccuracy; $avg_rate = (double) sprintf("%.{$pAccuracy}f", $avg_rate); $rate = (double) sprintf("%.{$pAccuracy}f", $rate); } return array('votes' => $votes, 'totalRate' => $rate, 'rate' => $avg_rate); }