Jake Vanderwerf
4 days ago 747d741293e064a979d7bf6c143ef969ea6d7629
build/gmbreviews/render.php
@@ -17,6 +17,8 @@
   if ($inheritUser) {
      global $post;
      $inheritUser = $post->post_author;
   }else {
      $inheritUser = null;
   }
   try {
      $gmb = JVB()->connect('gmb', $inheritUser);
@@ -55,12 +57,12 @@
      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;
@@ -89,25 +91,27 @@
         }
         ?>
      </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) {
@@ -122,20 +126,36 @@
            $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)) {
@@ -145,25 +165,10 @@
                              <?= 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
         }
@@ -175,7 +180,7 @@
         ?>
         <div class="footer">
            <a href=" <?= esc_url($viewAllUrl) ?>"
               class="button"
               class="btn"
               target="_blank"
               rel="noopener noreferrer">