Sometimes people want to have reviews mean ‘people leave reviews on my work.’ But the other kind of reviews are the ones where I review other peoples’ works. And for that, I found it helps to have some kind of standard.
Let’s say I’m reviewing a TV show for overall quality but also overall gayness. That is, I want to be able to write up a post and then, at the bottom, put up a shortcode to say “This show is really good but has no gay characters.” To do that, I made a list of the important factors to distill:
- Name: The name of the TV show
- Summary: A short, 140 character summary of the overall show.
- Queer: A 1-5 rating of how queer the show is
- Rating: A 1-3 scale (yes, meh, no) for how good the show is overall
- Warning: Is there a trigger warning (or CW) to be aware of
The intent is to make it easy for someone to scroll down and find what they want to watch. Right?
The Code
A bit of warning. There are two specific to my site bits of design in here. First are the icons. While I’ve generalized them for you as Emoji, keep in mind you probably want to have your own style here. Second, I’m using Bootstrap, so I’ve leveraged some of their default code. You’ll want to tweak the CSS.
class TV_Shortcodes { /** * Constructor */ public function __construct() { add_action( 'init', array( $this, 'init' ) ); add_filter( 'widget_text', 'do_shortcode' ); } /** * Init */ public function init() { add_shortcode( 'review', array( $this, 'review' ) ); } /** * Reviews. */ public function review( $atts ) { $attributes = shortcode_atts( array( 'title' => 'Coming Soon', 'summary' => 'Coming soon ...', 'queer' => '3', 'rating' => 'meh', 'warning' => 'none', ), $atts ); $queer = (float) $attributes['queer']; $queer = ( $queer < 0 )? 0 : $queer; $queer = ( $queer > 5 )? 5 : $queer; $worth = ( in_array( $attributes['worth'], array( 'yes', 'no', 'meh' ) ) )? $attributes['worth'] : 'meh'; switch ( $worth ) { case 'yes': $worth_icon = '??'; $worth_color = 'success'; break; case 'no': $worth_icon = '??'; $worth_color = 'danger'; break; case 'meh': $worth_icon = '?'; $worth_color = 'warning'; break; } // Get proper triger warning data $warning = ''; $trigger = ( in_array( $attributes['trigger'], array( 'high', 'medium', 'low' ) ) )? $attributes['trigger'] : 'none'; if ( $trigger != 'none' ) { $warn_image = '⚠️'; switch ( $trigger ) { case 'high': $warn_color = 'danger'; break; case 'medium': $warn_color = 'warning'; break; case 'low': $warn_color = 'info'; break; } $warning = '<span data-toggle="tooltip" aria-label="Warning - This show contains triggers" title="Warning - This show contains triggers"><button type="button" class="btn btn-' . $warn_color . '"><span class="screener screener-warn ' . $warn_color . '" role="img">' . $warn_image . '</span></button></span>'; } $output = '<div class="bd-callout"><h5 id="' . esc_attr( $attributes['title'] ) . '">Screener Review on <em>' . esc_html( $attributes['title'] ) . '</em></h5> <p>' . esc_html( $attributes['summary'] ) . '</p> <p><span data-toggle="tooltip" aria-label="How good is this show for queers?" title="How good is this show for queers?"><button type="button" class="btn btn-dark">Queer Score: ' . $queer . '</button></span> <span data-toggle="tooltip" aria-label="Is this show worth watching? ' . ucfirst( $worth ) . '" title="Is this show worth watching? ' . ucfirst( $worth ) . '"><button type="button" class="btn btn-' . $worth_color . '">Worth It? <span role="img" class="screener screener-worthit ' . lcfirst( $worth ) . '">' . $worth_icon . '</span></button></span> ' . $warning . '</p> </div>'; return $output; } } new TV_Shortcodes();
The Future
I’m thinking about changing the scores from numbers to stars, and adding in a link if the show has been added to the site. But it being a shortcode, it’s reasonably extensible.
Enjoy, and export to your own review sites.