gff_get_country_code

The Google Font Fix gff get country code function.

Description

gff_get_country_code( $remote_addr ); 

Parameters (1)

0. $remote_addr
The remote addr.

Usage

  1. if ( !function_exists( 'gff_get_country_code' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-font-fix/google-font-fix.php'; 
  3.  
  4. // The remote addr. 
  5. $remote_addr = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = gff_get_country_code($remote_addr); 
  9.  

Defined (1)

The function is defined in the following location(s).

/google-font-fix.php  
  1. function gff_get_country_code($remote_addr) { 
  2. $is_ipv6 = strpos($remote_addr, ':'); 
  3. $geoip_function = sprintf('geoip_country_code_by_addr%s', $is_ipv6 ? '_v6' : ''); 
  4. $geo_file_name = sprintf('GeoIP%s.dat', $is_ipv6 ? 'v6' : ''); 
  5. $geo_data = geoip_open(GFF_PLUGIN_PATH. "geo/{$geo_file_name}", GEOIP_STANDARD); 
  6. $country_code = $geoip_function($geo_data, $remote_addr); 
  7. geoip_close($geo_data); 
  8.  
  9. return $country_code;