Jake Vanderwerf
2026-08-28 a9654f00c8fbc9934289d761843ddd071025013f
inc/blocks/GMBReviewBlock.php
@@ -1,13 +1,21 @@
<?php
namespace JVBase\blocks;
use JVBase\managers\Cache;
use Exception;
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 +42,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 +60,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']??[];
@@ -231,7 +247,7 @@
         <?php
         return ob_get_clean();
      } catch (\Exception $e) {
      } catch (Exception $e) {
         error_log('[GMB Reviews Block] Error: ' . $e->getMessage());
         return '';
      }