Skip to content

Commit

Permalink
debug errorlogging
Browse files Browse the repository at this point in the history
  • Loading branch information
tamw-wnet committed Jun 27, 2024
1 parent 0dd11ab commit a7368ac
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions classes/class-pbs-check-dma.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function use_custom_template($template) {
public function get_location_from_ip($client_ip) {
#possibly manually override the zipcode
$override_zipcode = $this->manually_override_zipcode_from_ip($client_ip);
error_log("override_zipcode is $override_zipcode");
$zip_url = 'https://services.pbs.org/zipcodes/ip/';
$combined_url = $zip_url . $client_ip . '.json';
$response = wp_remote_get($combined_url, array());
Expand All @@ -73,12 +74,14 @@ public function get_location_from_ip($client_ip) {
$parsed = json_decode($body, TRUE);
$item = !empty($parsed['$items'][0]) ? $parsed['$items'][0] : false;
if (!$item && !$override_zipcode) {
error_log("parse error");
return array('errors' => $response);
}
$zipcode = $override_zipcode ? $override_zipcode : $zipcode;
$state = '';
$county = '';
if (!$override_zipcode && (empty($item['$links']) || !is_array($item['$links']))) {
error_log("links error");
return array('errors' => $response);
}
if (isset($item['$links'])) {
Expand Down

0 comments on commit a7368ac

Please sign in to comment.