From aeb5a13bfa203281aaa5573e19fe5aa6ac012152 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 02 Jan 2026 06:03:55 +0000
Subject: [PATCH] Merge branch 'main' of https://github.com/jakevdwerf/jvb

---
 inc/integrations/GoogleMyBusiness.php |   58 +++++-----------------------------------------------------
 1 files changed, 5 insertions(+), 53 deletions(-)

diff --git a/inc/integrations/GoogleMyBusiness.php b/inc/integrations/GoogleMyBusiness.php
index 6ac8ed5..e818d5b 100644
--- a/inc/integrations/GoogleMyBusiness.php
+++ b/inc/integrations/GoogleMyBusiness.php
@@ -203,7 +203,6 @@
 		$type = $settings['content_type']??'post'; //can be 'post', 'offer', 'event', 'hours', 'info',
 		$initial = $settings['initial']?? false;
 		$syncOnUpdate = $settings['update']??false;
-		error_log('Handling GMB Save Post with settings: '.print_r($settings, true));
 		if ($update && !$syncOnUpdate) {
 			return;
 		}
@@ -211,7 +210,6 @@
 			return;
 		}
 
-		error_log('Continuing on...');
 		$options = $data = [];
 		switch ($type) {
 			case 'menu_item':
@@ -223,8 +221,7 @@
 		}
 		$data['post_id'] = $postID;
 		$operation = ($update) ? 'update_' : 'create_';
-		error_log('[GMB]Queuing sync to service:'.print_r($data, true));
-		error_log('Options: '.print_r($options, true));
+
 		$this->queueOperation(
 			$operation.$type,
 			$data,
@@ -473,8 +470,6 @@
 			// Build the complete menu structure
 			$menu_data = $gmb->collectMenu($menu_items);
 
-			error_log('Menu Data: '.print_r($menu_data, true));
-
 			// Send to Google My Business API
 			$result = $this->updateFoodMenus($menu_data);
 			return [
@@ -512,7 +507,6 @@
 				$locations = $this->getLocations($account['name']);
 
 				foreach ($locations as $location) {
-					error_log('Fetched Location: '.print_r($location, true));
 					if ($location['storeCode'] === $this->credentials['location']) {
 						// Auto-migrate: update stored location to use full resource name
 						$this->setSelectedLocation($location['name']);
@@ -699,7 +693,6 @@
 
 			// Filter to only allowed fields
 			$patch_data = array_intersect_key($updates,$allowed_fields);
-			error_log('Updates: '.print_r($updates, true));
 
 			$location_name = $this->getSelectedLocationResourceName();
 			if (empty($patch_data)) {
@@ -1044,7 +1037,6 @@
 		if(!$this->isSetUp()) {
 			return [];
 		}
-		error_log('[GMB] updateBusinessHours called with hours: ' . print_r($hours, true));
 		$location_name = $this->credentials['location'];
 
 		if (empty($location_name)) {
@@ -1067,11 +1059,7 @@
 				]
 			];
 
-			error_log('[GMB] Complete update data: ' . print_r($update_data, true));
-
 			$endpoint = "/v1/{$location_name}?updateMask=regularHours";
-			error_log('[GMB] API endpoint: ' . $endpoint);
-			error_log('[GMB] Using API base: ' . 'base');
 
 			// Make the API request
 			$response = $this->makeRequest(
@@ -1081,18 +1069,15 @@
 				'base'
 			);
 
-			error_log('[GMB] API response: ' . print_r($response, true));
-
 			$success = $response !== null;
-			error_log('[GMB] updateBusinessHours result: ' . ($success ? 'SUCCESS' : 'FAILED'));
 
 			// Additional validation - check if the response contains the updated hours
 			if ($success && $response) {
 				if (isset($response['regularHours'])) {
-					error_log('[GMB] SUCCESS: Updated hours confirmed in response: ' . print_r($response['regularHours'], true));
+//					error_log('[GMB] SUCCESS: Updated hours confirmed in response: ' . print_r($response['regularHours'], true));
 				} else {
-					error_log('[GMB] WARNING: No regularHours in response, but API call succeeded');
-					error_log('[GMB] Full response keys: ' . implode(', ', array_keys($response)));
+//					error_log('[GMB] WARNING: No regularHours in response, but API call succeeded');
+//					error_log('[GMB] Full response keys: ' . implode(', ', array_keys($response)));
 				}
 			}
 
@@ -1102,9 +1087,6 @@
 			];
 
 		} catch (\Exception $e) {
-			error_log('[GMB] Exception in updateBusinessHours: ' . $e->getMessage());
-			error_log('[GMB] Exception trace: ' . $e->getTraceAsString());
-
 			$this->logError($e->getMessage(), [
 				'method'	=> 'updateBusinessHours'
 			]);
@@ -1117,8 +1099,6 @@
 
 	private function validateAndFormatHours(array $hours): array
 	{
-		error_log('[GMB] Validating hours format...');
-
 		$valid_days = ['MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY', 'SUNDAY'];
 		$periods = [];
 
@@ -1148,8 +1128,6 @@
 				continue;
 			}
 
-			error_log('[GMB] Processing ' . $formatted_day . ' - times data: ' . print_r($times, true));
-
 			// Check if day is open with flexible comparison
 			$is_open = false;
 			if (isset($times['open'])) {
@@ -1181,10 +1159,7 @@
 			];
 
 			$periods[] = $period;
-			error_log('[GMB] Valid period for ' . $formatted_day . ': ' . print_r($period, true));
 		}
-
-		error_log('[GMB] Total valid periods: ' . count($periods));
 		return $periods;
 	}
 
@@ -1263,8 +1238,6 @@
 				]
 			];
 
-			error_log('[GMB] Updating special hours with corrected structure: ' . json_encode($update_data, JSON_PRETTY_PRINT));
-
 			// Try the PATCH request
 			$response = $this->makeRequest(
 				'PATCH',
@@ -1279,8 +1252,6 @@
 			];
 
 		} catch (\Exception $e) {
-			error_log('[GMB] setSpecialHours Exception: ' . $e->getMessage());
-
 			$this->logError($e->getMessage(), [
 				'method'	=> 'setSpecialHours'
 			]);
@@ -1432,9 +1403,6 @@
 		$ttl = 7 * 24 * 60 * 60; // week in seconds
 		$response = $this->getRequest('/v1/accounts', [], 'accounts', $ttl, $force)??[];
 
-		// Log the raw response for debugging
-		error_log('[GMB] Raw accounts response: ' . print_r($response, true));
-
 		if (isset($response['accounts']) && is_array($response['accounts'])) {
 			return $response['accounts'];
 		}
@@ -1482,7 +1450,6 @@
 				'v4'
 			);
 
-			error_log('Review response: '.print_r($response, true));
 			$reviews = $response ?? [];
 
 			// Cache for 1 week (604800 seconds)
@@ -1583,7 +1550,6 @@
 		if (empty($account_name) || !str_starts_with($account_name, 'accounts/')) {
 			return [];
 		}
-		error_log('[GMB] getLocations() called for: ' . $account_name . ' (force: ' . ($force ? 'true' : 'false') . ')');
 		$params = ['readMask' => $this->readMask];
 		$ttl = 7 * 24 * 60 * 60; // Week in seconds
 
@@ -1613,8 +1579,6 @@
 	 */
 	public function refreshStoredData(): array
 	{
-		error_log('[GMB] Manually refreshing accounts and locations data');
-
 		try {
 			// Fetch fresh accounts data from API
 			$accounts = $this->getAccounts(true);
@@ -1674,7 +1638,6 @@
 		];
 		$endpoint = "/v1/{$location_name}?".http_build_query($params);
 
-		error_log('[GMB] Fetching location: ' . $location_name);
 		$location = $this->getRequest($endpoint, [], 'base', 'moderate', $force);
 
 		return $location??null;
@@ -1821,8 +1784,6 @@
 					'hours' => $hour,
 					'minutes' => $minute
 				];
-
-				error_log('[GMB] Converted time "' . $time . '" to Google format: ' . print_r($result, true));
 				return $result;
 			}
 		}
@@ -2237,8 +2198,6 @@
 	public function handleGetAllLocations():WP_Error|array
 	{
 		try {
-			error_log('[GMB] AJAX getAllLocations called');
-
 			// Check if we should force refresh
 			$force = isset($_POST['force']) && $_POST['force'] === 'true';
 
@@ -2252,7 +2211,6 @@
 				$all_locations = array_merge($all_locations, $locations);
 			}
 
-			error_log('[GMB] AJAX returning ' . count($all_locations) . ' locations');
 			return [
 				'success'	=> true,
 				'locations' => $all_locations,
@@ -2260,7 +2218,6 @@
 			];
 
 		} catch (\Exception $e) {
-			error_log('[GMB] AJAX getAllLocations exception: ' . $e->getMessage());
 			return new WP_Error('failure', 'Something went wrong: '.$e->getMessage());
 		}
 	}
@@ -2274,15 +2231,12 @@
 			// Handle both AJAX and REST API calls
 			$selected_account = null;
 
-			error_log('handle Update Location: '.print_r($data, true));
 			if (is_array($data)) {
 				$selected_account = $data['account'] ?? $data['location'] ?? null;
 			} elseif (isset($_POST['account'])) {
 				$selected_account = sanitize_text_field($_POST['account']);
 			}
 
-			error_log('[GMB] updateLocation received: ' . print_r($selected_account, true));
-
 			if (empty($selected_account)) {
 				throw new \Exception('No account selected');
 			}
@@ -2325,9 +2279,7 @@
 	{
 		try {
 			// Use the static method to clear the entire cache group
-			CacheManager::invalidateGroup('integrations_'.$this->cacheName);
-
-			error_log('[GMB] Cleared all stored data for cache group: ' . $this->cacheName);
+			$this->cache->clear();
 			return true;
 
 		} catch (\Exception $e) {

--
Gitblit v1.10.0