PHP Class wpengine\GeoIp

Show file Open project: wpengine/geoip

Public Properties

Property Type Description
$countries A list of countries and their continents
$geos The geographical data loaded from the environment

Public Methods

Method Description
action_admin_init_check_plugin_dependencies ( ) Checks if environment variable depencies are available on the server
action_admin_notices ( ) Displays notice in the admin area if the dependent environment variables are not present
action_init_register_shortcodes ( ) : null Register the shortcode(s)
city ( ) : mixed Get City
compare_location_type ( $a, $b ) Compare the location types
continent ( $country = '' ) : string Get Continent
country ( ) : string Get Country
distance_to ( $lat, $lng, $metric = false ) : float Utility function: Calculate distance to point
do_shortcode_city ( $atts ) : string Output the current city
do_shortcode_content ( $atts, $content = null ) : string Output the content filtered by region
do_shortcode_continent ( $atts ) : string Output the current continent
do_shortcode_country ( $atts ) : string Output the current country
do_shortcode_latitude ( $atts ) : string Output the current latitude
do_shortcode_location ( $atts ) : string Output the current human readable location, in a smart way.
do_shortcode_longitude ( $atts ) : string Output the current longitude
do_shortcode_postal_code ( $atts ) : string Output the current postal code
do_shortcode_region ( $atts ) : string Output the current region
get_actuals ( ) : array Here we extract the data from headers set by nginx -- lets only send them if they are part of the cache key
get_test_parameters ( $geos ) : array We want people to be able to test the plugin, so we'll include some url parameters that will spoof a location
init ( ) Initialize hooks and setup environment variables
instance ( ) Register singleton
latitude ( ) : mixed Get Latitude
longitude ( ) : mixed Get Longitude
postal_code ( ) : mixed Get Postal Code
region ( ) : string Get Region
setup ( ) Setup environment variables

Private Methods

Method Description
match_label_synonyms ( $label ) : string As a favor to users, let's match some common synonyms

Method Details

action_admin_init_check_plugin_dependencies() public method

Checks if environment variable depencies are available on the server
Since: 0.5.0

action_admin_notices() public method

Displays notice in the admin area if the dependent environment variables are not present
Since: 0.5.0

action_init_register_shortcodes() public method

Register the shortcode(s)
Since: 0.5.0

city() public method

Get City
Since: 0.5.0
public city ( ) : mixed
return mixed Description

compare_location_type() public method

Used for sorting location types from largest area to smallest area
Since: 1.1.2
public compare_location_type ( $a, $b )

continent() public method

Get Continent
Since: 1.1.0
public continent ( $country = '' ) : string
return string Two-letter continent code, e.g. EU for Europe

country() public method

Get Country
Since: 0.5.0
public country ( ) : string
return string Two-letter country code, e.g.) US for the United States of America

distance_to() public method

Provided a lat/lng, calculate the distance from visitor's location Uses the Haversine Formula, accurate for short distance but not over poles or the equator Note: Test against a return value of false to make sure you got a calculated distance. Example: $geo = WPEngine\GeoIp::instance(); if ( false !== $geo->distance_to( $latitude, $longitude ) ) { Do something }
public distance_to ( $lat, $lng, $metric = false ) : float
return float distance in miles

do_shortcode_city() public method

Output the current city
Since: 0.5.0
public do_shortcode_city ( $atts ) : string
return string City name

do_shortcode_content() public method

Output the content filtered by region
Since: 1.1.0
public do_shortcode_content ( $atts, $content = null ) : string
return string HTML

do_shortcode_continent() public method

Output the current continent
Since: 1.1.0
public do_shortcode_continent ( $atts ) : string
return string Two-letter continent code

do_shortcode_country() public method

Output the current country
Since: 0.5.0
public do_shortcode_country ( $atts ) : string
return string Two-letter country code

do_shortcode_latitude() public method

Output the current latitude
Since: 0.6.0
public do_shortcode_latitude ( $atts ) : string
return string latitude

do_shortcode_location() public method

Output the current human readable location, in a smart way.
Since: 0.5.0
public do_shortcode_location ( $atts ) : string
return string $html

do_shortcode_longitude() public method

Output the current longitude
Since: 0.6.0
public do_shortcode_longitude ( $atts ) : string
return string longitude

do_shortcode_postal_code() public method

Output the current postal code
Since: 0.6.0
public do_shortcode_postal_code ( $atts ) : string
return string postal code

do_shortcode_region() public method

Output the current region
Since: 0.5.0
public do_shortcode_region ( $atts ) : string
return string Two-letter region code

get_actuals() public method

Here we extract the data from headers set by nginx -- lets only send them if they are part of the cache key
Since: 0.1.0
public get_actuals ( ) : array
return array All of the GeoIP related environment variables available on the current server instance

get_test_parameters() public method

We want people to be able to test the plugin, so we'll include some url parameters that will spoof a location
Since: 1.1.0
public get_test_parameters ( $geos ) : array
return array modified version of the GeoIP location array based on url parameters

init() public static method

Initialize hooks and setup environment variables
Since: 0.1.0
public static init ( )

instance() public static method

Register singleton
Since: 0.1.0
public static instance ( )

latitude() public method

Get Latitude
Since: 0.6.0
public latitude ( ) : mixed
return mixed Description

longitude() public method

Get Longitude
Since: 0.6.0
public longitude ( ) : mixed
return mixed Description

postal_code() public method

Get Postal Code
Since: 0.6.0
public postal_code ( ) : mixed
return mixed Description

region() public method

Get Region
Since: 0.5.0
public region ( ) : string
return string Two-letter region code. e.g.) CA for California

setup() public method

Setup environment variables
Since: 0.1.0
public setup ( )

Property Details

$countries public property

A list of countries and their continents
public $countries

$geos public property

The geographical data loaded from the environment
public $geos