Jake Vanderwerf
2026-08-25 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a
inc/blocks/GMBReviewBlock.php
@@ -1,13 +1,20 @@
<?php
namespace JVBase\blocks;
use JVBase\managers\Cache;
use JVBase\base\Site;
use JVBase\integrations\services\GoogleMyBusiness;
//use JVBase\managers\Cache;
use WP_Block;
if (!defined('ABSPATH')) {
   exit;
}
class GMBReviewBlock {
   protected Cache $cache;
// protected Cache $cache;
   public function __construct()
   {
      if (!Site::hasIntegration('gmb')){
         return;
      }
      add_action('init', [ $this, 'registerBlock' ]);
   }
@@ -34,6 +41,9 @@
    */
   public function render(array $attributes, string $content, WP_Block $block):string
   {
      if (!Site::hasIntegration('gmb')) {
         return '';
      }
      $count = $attributes['count'] ?? 5;
      $showRating = $attributes['showRating'] ?? true;
      $showDate = $attributes['showDate'] ?? true;
@@ -49,11 +59,16 @@
         $inheritUser = null;
      }
      try {
         $gmb = JVB()->connect('gmb', $inheritUser);
         if (!$gmb->isSetUp()) {
         $gmb = GoogleMyBusiness::getInstance();
         $gmb->switchUser($inheritUser);
         if (!$gmb->isSetUp()
            || !method_exists($gmb, 'getReviews')
            || !method_exists($gmb, 'getReviewsViewUrl')
            || !method_exists($gmb, 'getReviewUrl')) {
            error_log('GMB Not set up for: '.(int)$inheritUser);
            return '';
         }
         $gotReviews = $gmb->getReviews();
         // Get all data
         $allReviews = $gotReviews['reviews']??[];