Skip to content

Commit

Permalink
Merge branch 'preprod'
Browse files Browse the repository at this point in the history
  • Loading branch information
tamw-wnet committed Feb 1, 2024
2 parents 01ad558 + 78186af commit 3776a50
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions classes/class-pbs-check-dma.php
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,31 @@ public function list_available_station_ids_in_zipcode($zipcode) {
return $available_station_ids;
}

public function list_available_station_ids_in_state($state) {
if (empty($state) || !(preg_match('/^([A-Z]{2})?$/', $state))) {
// zipcode is either empty or isn't 2 letters
return false;
}
$callsign_url = "https://services.pbs.org/stations/state/";
$combined_url = $callsign_url . $state . '.json';
$response = wp_remote_get($combined_url, array());
if (! is_array( $response ) || empty($response['body'])) {
return array('errors' => $response);
}
$body = $response['body']; // use the content
$parsed = json_decode($body, TRUE);
$available_station_ids = [];
foreach($parsed['$items'] as $key) {
$link = $key['$links'][0];
if (isset($link['pbs_id'])) {
$station_id = $link['pbs_id'];
array_push($available_station_ids, $station_id);
}
}
return $available_station_ids;
}


public function list_localization_states() {
$services_endpoint = "https://services.pbs.org/states.json";
$response = wp_remote_get($services_endpoint, array());
Expand Down
2 changes: 1 addition & 1 deletion pbs-check-dma.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/*
* Plugin Name: PBS Check DMA
* Version: 0.93 - adding Google as a reverse geolocator
* Version: 0.94 - adding function to return list of station ids in a state
* Plugin URI: http://ieg.wnet.org/
* Description: Use geolocation to restrict content based on a PBS stations' DMA
* Author: William Tam
Expand Down

0 comments on commit 3776a50

Please sign in to comment.