Skip to content

Instantly share code, notes, and snippets.

@danielpowney
Created October 18, 2015 21:52
Show Gist options
  • Save danielpowney/0d949ea47a6466f33ee1 to your computer and use it in GitHub Desktop.
Save danielpowney/0d949ea47a6466f33ee1 to your computer and use it in GitHub Desktop.
<!-- Add the following JavaScript -->
<script>
jQuery(document).ready(function() {
jQuery(".mrp-read-more-comment").on("click", function(e) {
var btnId = e.currentTarget.id; // mrp-read-more-comment-X
var parts = btnId.split("-");
var entryId = parts[4];
jQuery("#mrp-comment-full-" + entryId).css( "display", "inline-block" );
jQuery("#mrp-comment-trim-" + entryId).css( "display", "none" );
e.preventDefault();
});
});
</script>
<!-- Modify the comment HTML in the rating-result-reviews.php template -->
<?php
/**
* Comment
*/
if ( strlen( $review_comment ) > 0 && $show_comment ) {
$read_more = '<a href="#" class="mrp-read-more-comment" id="mrp-read-more-comment-' . $rating_result['rating_entry_id'] . '"> ' . __( '[...]', 'multi-rating-pro' ) . '</a>';
?>
<p class="comment mrp" id="mrp-comment-trim-<?php echo $rating_result['rating_entry_id']; ?>"><?php echo "$before_comment" . wp_trim_words( wp_kses_post( nl2br( $review_comment ) ), 10, $read_more ) . "$after_comment"; ?></p>
<p class="comment mrp" id="mrp-comment-full-<?php echo $rating_result['rating_entry_id']; ?>" style="display: none;"><?php echo "$before_comment" . wp_kses_post( nl2br( $review_comment ) ) . "$after_comment"; ?></p>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment