You are here

function ip_geoloc_tokens in IP Geolocation Views & Maps 8

Same name and namespace in other branches
  1. 7 ip_geoloc.tokens.inc \ip_geoloc_tokens()

Implements hook_tokens().

File

./ip_geoloc.tokens.inc, line 42
Pending doc.

Code

function ip_geoloc_tokens($type, $tokens, array $data = [], array $options = []) {
  $replacements = [];
  if ($type == 'visitor-location') {
    $is_sanitize = !empty($options['sanitize']);
    $location = ip_geoloc_get_visitor_location();
    foreach ($tokens as $key => $original) {
      if (isset($location[$key])) {
        $replacements[$original] = $is_sanitize ? filter_xss_admin($location[$key]) : $location[$key];
      }
    }
  }
  return $replacements;
}