Ejemplo n.º 1
0
function geoip_detect_shortcode($attr)
{
    $userInfo = geoip_detect_get_info_from_current_ip();
    if (!is_object($userInfo)) {
        return '<!-- GeoIP Detect: No info found for this IP. -->';
    }
    $propertyName = $attr['property'];
    if (property_exists($userInfo, $propertyName)) {
        return $userInfo->{$propertyName};
    }
    return '<!-- GeoIP Detect: Invalid property name. -->';
}
Ejemplo n.º 2
0
function geoip_add_body_classes($classes)
{
    if (!get_option('geoip-detect-set_css_country')) {
        return $classes;
    }
    $info = geoip_detect_get_info_from_current_ip();
    if (!$info) {
        return $classes;
    }
    $classes[] = 'geoip-country-' . $info->country_code;
    $classes[] = 'geoip-continent-' . $info->continent_code;
    return $classes;
}
Ejemplo n.º 3
0
/**
 * @deprecated 
 */
function geoip_detect_shortcode($attr)
{
    $userInfo = geoip_detect_get_info_from_current_ip();
    $defaultValue = isset($attr['default']) ? $attr['default'] : '';
    if (!is_object($userInfo)) {
        return $defaultValue . '<!-- GeoIP Detect: No info found for this IP. -->';
    }
    $propertyName = $attr['property'];
    if (property_exists($userInfo, $propertyName)) {
        if ($userInfo->{$propertyName}) {
            return $userInfo->{$propertyName};
        } else {
            return $defaultValue;
        }
    }
    return $defaultValue . '<!-- GeoIP Detect: Invalid property name. -->';
}