Skip to content

Commit

Permalink
Merge pull request #11 from mahotilo/patch-3
Browse files Browse the repository at this point in the history
Add limit for number of reviews
  • Loading branch information
gaffling authored Apr 16, 2021
2 parents 88c282b + 3f3e1b6 commit 6582756
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions get-reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
'show_age_of_the_review' => true, // true = show the age of each review
'show_txt_of_the_review' => true, // true = show the text of each review
'show_author_of_reviews' => true, // true = show the author of each review
'show_not_more_than_max' => 0, // (0-8) only show first max reviews
);

/* -------------------- */
Expand Down Expand Up @@ -80,7 +81,9 @@ function getReviews($option) {
$return .= '<div class="quote">'; /* OPEN DIV */
if (isset($option['show_cname_as_headline']) and $option['show_cname_as_headline'] == true) $return .= '<strong>'.$customer.'</strong><br>'; /* CUSTOMER */
if (isset($option['show_rule_after_review']) and $option['show_rule_after_review'] == true) $return .= '<hr size="1">'; /* RULER */
$n = 0;
foreach ($reviews as $review) { /* START LOOP */
if (isset($option['show_not_more_than_max']) and $option['show_not_more_than_max'] > 0 and $n >= $option['show_not_more_than_max']) continue; /* CHECK MAX NUMBER */
if (isset($option['show_only_if_with_text']) and $option['show_only_if_with_text'] == true and empty($review[3])) continue; /* CHECK TEXT */
if (isset($option['show_only_if_greater_x']) and $review[4] <= $option['show_only_if_greater_x']) continue; /* CHECK RATING */
for ($i=1; $i <= $review[4]; ++$i) $return .= ''; /* RATING */
Expand All @@ -92,6 +95,7 @@ function getReviews($option) {
isset($option['show_age_of_the_review']) and $option['show_age_of_the_review'] == true) $return .= '<small> &mdash; </small>'; /* PRINT — */
if (isset($option['show_age_of_the_review']) and $option['show_age_of_the_review'] == true) $return .= '<small>'.$review[1].' </small>'; /* AGE */
if (isset($option['show_rule_after_review']) and $option['show_rule_after_review'] == true) $return .= '<hr size="1">'; /* RULER */
$n++;
} /* END LOOP */
$return .= '</div>'; /* CLOSE DIV */
} /* CHECK REVIEWS */
Expand Down

0 comments on commit 6582756

Please sign in to comment.