Skip to content

Commit

Permalink
[Locations Plugin] Add support for getting location ids from tags slubs
Browse files Browse the repository at this point in the history
Same as commit 675e91b. Forgot to add it when #165 was closed and #167 was merged.
  • Loading branch information
hesyifei committed Jun 13, 2019
1 parent 71f4e81 commit 04cec55
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions wp-content/plugins/tsd-locations/tsd-locations.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,22 @@ function tsd_locations_plugin_return_coordinates_search( $request ) {

return $results;
}


// For TSD Push Notification
function tsd_locations_plugin_get_location_ids_by_tags( $tag_slugs ) {
$results = [];
$locations = tsd_locations_plugin_get_locations();
foreach( $locations as $each_location_info ) {
$each_location_id = $each_location_info[ "id" ];
$each_location_tags = $each_location_info[ "tagSlug" ];
foreach( $tag_slugs as $tag_slug ) {
if ( in_array( $tag_slug, $each_location_tags ) ) {
$results[] = $each_location_id;
}
}
}
return array_unique( $results );
}
}
add_action('init', 'tsd_locations_plugin_enable_api');

0 comments on commit 04cec55

Please sign in to comment.