Skip to content

Commit

Permalink
Merge pull request #24 from manooweb/test-bis
Browse files Browse the repository at this point in the history
Update google rich snippets to use https://schema.org/AggregateRating
  • Loading branch information
kamalkhan committed Mar 27, 2017
2 parents 7d980c6 + b7e2528 commit c0d3dd3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
/nbproject/
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 c0d3dd3

Please sign in to comment.