| | |
| | | if ($inheritUser) { |
| | | global $post; |
| | | $inheritUser = $post->post_author; |
| | | }else { |
| | | $inheritUser = null; |
| | | } |
| | | try { |
| | | $gmb = JVB()->connect('gmb', $inheritUser); |
| | |
| | | ob_start(); |
| | | ?> |
| | | <div class="gmb-reviews"> |
| | | <div class="row btw"> |
| | | <div class="row x-mid"> |
| | | <?php |
| | | if ($showStats && !empty($average) && !empty($total)) { |
| | | ?> |
| | | <p> |
| | | <span class="stars" aria-label="<?= $average ?> out of 5 stars"> |
| | | <span class="stars" title="<?= $average ?> out of 5 stars"> |
| | | <?php |
| | | $fullStars = floor($average); |
| | | $hasHalfStar = ($average - $fullStars) >= 0.5; |
| | |
| | | } |
| | | ?> |
| | | |
| | | |
| | | </div> |
| | | <?php |
| | | if ($showReviewLink && !empty($reviewUrl)) { |
| | | ?> |
| | | <a href="<?=esc_url($reviewUrl)?>" |
| | | class="button" |
| | | target="_blank" |
| | | rel="noopener noreferrer"> |
| | | class="btn" |
| | | target="_blank" |
| | | rel="noopener noreferrer"> |
| | | <?= jvbIcon('star', ['style' => 'fill']) ?> |
| | | Leave Your Review |
| | | </a> |
| | | <?php |
| | | } |
| | | ?> |
| | | </div> |
| | | |
| | | <ul> |
| | | <?php |
| | | foreach ($reviews as $review) { |
| | | $reviewer = $review['reviewer']['displayName'] ?? 'Anonymous'; |
| | | $reviewer = strtok($reviewer, ' '); |
| | | $profilePhoto = $review['reviewer']['profilePhotoUrl'] ?? ''; |
| | | $rating = $review['starRating'] ?? 0; |
| | | $rating = match($rating) { |
| | |
| | | $date = $review['updateTime'] ?? ''; |
| | | ?> |
| | | <li> |
| | | <article class="review"> |
| | | <header class="row btw"> |
| | | <blockquote class="review"> |
| | | <?php |
| | | echo jvbIcon('quotes',['style' => 'fill']); |
| | | // Review text |
| | | if (!empty($comment)) { ?> |
| | | <div class="content review"> |
| | | <?= apply_filters('wpautop', $comment) ?> |
| | | </div> |
| | | <?php } ?> |
| | | <cite class="row left nowrap"> |
| | | <?php if (!empty($profilePhoto)) { ?> |
| | | <img src="<?=esc_url($profilePhoto)?>" |
| | | alt="<?=esc_attr($reviewer)?>" |
| | | 'loading="lazy"> |
| | | alt="<?=esc_attr($reviewer)?>" |
| | | 'loading="lazy"> |
| | | <?php } else { ?> |
| | | <div class="avatar"> |
| | | <?= jvbIcon('user-circle')?> |
| | | <?= jvbIcon('user-circle')?> |
| | | </div> |
| | | <?php } ?> |
| | | |
| | | <div class="col end"> |
| | | <h4><?= esc_html($reviewer)?></h4> |
| | | <div class="row left wrap"> |
| | | <?php if ($showRating && $rating > 0) { ?> |
| | | <div class="stars" title="<?= $rating ?> out of 5 stars"> |
| | | <?php |
| | | for ($i = 1; $i <= 5; $i++) { |
| | | echo ($i <= $rating) ? jvbIcon('star', ['style' => 'fill']) : jvbIcon('star', ['style' => 'light']); |
| | | } ?> |
| | | </div> |
| | | <?php } ?> |
| | | <p><?= esc_html($reviewer)?></p> |
| | | <?php |
| | | // Date |
| | | if ($showDate && !empty($date)) { |
| | |
| | | <?= esc_html($formatted_date) ?> |
| | | </time> |
| | | <?php } ?> |
| | | <?php if ($showRating && $rating > 0) { ?> |
| | | <div class="stars" aria-label="<?= $rating ?> out of 5 stars"> |
| | | <?php |
| | | for ($i = 1; $i <= 5; $i++) { |
| | | echo ($i <= $rating) ? jvbIcon('star', ['style' => 'fill']) : jvbIcon('star', ['style' => 'light']); |
| | | } ?> |
| | | </div> |
| | | <?php } ?> |
| | | </div> |
| | | |
| | | </header> |
| | | <?php |
| | | // Review text |
| | | if (!empty($comment)) { ?> |
| | | <div class="review"> |
| | | <?= apply_filters('the_content', $comment) ?> |
| | | </div> |
| | | <?php } ?> |
| | | </article> |
| | | </cite> |
| | | </blockquote> |
| | | </li> |
| | | <?php |
| | | } |
| | |
| | | ?> |
| | | <div class="footer"> |
| | | <a href=" <?= esc_url($viewAllUrl) ?>" |
| | | class="button" |
| | | class="btn" |
| | | target="_blank" |
| | | rel="noopener noreferrer"> |
| | | |