Created
December 19, 2018 15:10
-
-
Save rwkyyy/f8997d3fdbea4bb36941ad7d4ef20064 to your computer and use it in GitHub Desktop.
Show empty stars onwards (CSSIgniter response)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Display the rating on a submitted comment. | |
add_filter( 'comment_text', 'ci_comment_rating_display_rating' ); | |
function ci_comment_rating_display_rating( $comment_text ) { | |
if ( $rating = get_comment_meta( get_comment_ID(), 'rating', true ) ) { | |
$stars = '<p class="stars">'; | |
for ( $i = 1; $i <= 5 ; $i ++ ) { | |
if ( $i <= $rating ) { | |
$stars .= '<span class="dashicons dashicons-star-filled"></span>'; | |
} else { | |
$stars .= '<span class="dashicons dashicons-star-empty"></span>'; | |
} | |
} | |
$stars .= '</p>'; | |
$comment_text = $comment_text . $stars; | |
return $comment_text; | |
} else { | |
return $comment_text; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The initial & updated post about this, you can find here
It also includes the half star rating.