Skip to content

Commit

Permalink
Correct schema.org for AggregateRating legend
Browse files Browse the repository at this point in the history
  • Loading branch information
manooweb committed Mar 27, 2017
1 parent b5a0e9f commit b7e2528
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions index.php
Expand Up @@ -657,18 +657,16 @@ public function grs_legend($legend, $id)
$avg = $score ? round((float)(($score/$votes)*($best/5)), 2) : 0;
$per = $score ? round((float)((($score/$votes)/5)*100), 2) : 0;

$leg = str_replace('[total]', '<span property="ratingCount">'.$votes.'</span>', $legend);
$leg = str_replace('[avg]', '<span property="ratingValue">'.$avg.'</span>', $leg);
$leg = str_replace('[total]', '<span itemprop="ratingCount">'.$votes.'</span>', $legend);
$leg = str_replace('[avg]', '<span itemprop="ratingValue">'.$avg.'</span>', $leg);
$leg = str_replace('[per]', $per .'%', $leg);
$leg = str_replace('[s]', $votes == 1 ? '' : 's', $leg);

$snippet = '<div vocab="http://schema.org/" typeof="Blog">';
$snippet .= ' <div property="name" class="kksr-title">' . $title . '</div>';
$snippet .= ' <div property="aggregateRating" typeof="AggregateRating">';
$snippet .= $leg;
$snippet .= ' <meta property="bestRating" content="'. $best . '"/>';
$snippet .= ' <meta property="worstRating" content="1"/>';
$snippet .= ' </div>';
$snippet = '<div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';
$snippet .= ' <div itemprop="name" class="kksr-title">' . $title . '</div>';
$snippet .= $leg;
$snippet .= ' <meta itemprop="bestRating" content="'. $best . '"/>';
$snippet .= ' <meta itemprop="worstRating" content="1"/>';
$snippet .= '</div>';
}
else
Expand Down

0 comments on commit b7e2528

Please sign in to comment.