Ratings
-
Hi Mark,
Looking to extend this fantastic plugin a bit further, I’d like to share my mod to pull those shiny golden rating stars ??
In
function shortcode()
I added:case 'imp_rating' : return isset( $this->readme->rating ) ? round( (float)$this->readme->rating / 20, 1 ) : ''; break; case 'imp_rating_100' : return isset( $this->readme->rating ) ? round( (float)$this->readme->rating , 1 ) : ''; break; case 'imp_num_ratings' : return isset( $this->readme->num_ratings ) ? $this->readme->num_ratings : ''; break;
In the
$shortcodes array
infunction plugin()
I added:'imp_rating', 'imp_rating_100', 'imp_num_ratings',
That is really all that is needed!
This allows me to use in the template for example:
<div style="height:17px;width:92px;background:url('https://www.ads-software.com/extend/plugins-plugins/bb-ratings/stars.png?19') repeat-x bottom left;"><div style="height:17px;width:[imp_rating_100]%;float:left;text-indent:100%;overflow:hidden;white-space:nowrap;background:url('https://www.ads-software.com/extend/plugins-plugins/bb-ratings/stars.png?19') repeat-x top left;" title="Rated [imp_rating] out of 5 stars">[imp_rating] out of 5 stars</div> </div> <p itemprop="aggregateRating" itemscope itemtype="https://schema.org/AggregateRating"><strong>Rating:</strong> [imp_rating] out of 5 stars <strong># Votes:</strong> [imp_num_ratings]<meta itemprop="ratingValue" content="[imp_rating]"><meta itemprop="reviewCount" content="[imp_num_ratings]"><span itemprop="offers" itemscope itemtype="https://schema.org/Offer"><meta itemprop="price" content="0" /><meta itemprop="url" content="[imp_url]" /></p>
This not only puts it into words but also creates the stars visual plus allows some fancy microdata to let Google know about it too!
If you’ve got this plugin on Github just let me know and I’ll go and create a pull request ??
- The topic ‘Ratings’ is closed to new replies.