Skip to content

Commit

Permalink
Updated - renamed functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei Igna committed Oct 23, 2018
1 parent 02323bc commit 97bde8f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CustomPostType.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ function addMetaFields(array $metaFields): self {

function addMetaField(string $metaKey, array $args): self {

MetaFields::instance()->addPostMeta($this->postType, $metaKey, $args);
mf()->addPostMeta($this->postType, $metaKey, $args);

return $this;
}
Expand Down
12 changes: 6 additions & 6 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,25 @@ function mf() {

if (!function_exists('getVisitorCountryCode')) {
function getVisitorCountryCode(): string {
return strtoupper(apply_filters('visitor_country_code', ''));
return strtoupper(apply_filters('visitor_country_code', null));
}
}

add_filter('user_country_code', 'layered_visitor_country_code_woocommerce');
add_filter('user_country_code', 'layered_visitor_country_code_headers');
add_filter('visitor_country_code', 'layeredUserCountryCodeWooCommerce');
add_filter('visitor_country_code', 'layeredUserCountryCodeHeaders');

function layered_visitor_country_code_woocommerce(string $countryCode = ''): string {
function layeredUserCountryCodeWooCommerce(string $countryCode = null): ?string {
if (empty($countryCode) && class_exists('WC_Geolocation')) {
$location = WC_Geolocation::geolocate_ip();
if ($location['country'] && !in_array($location['country'], array('A1', 'A2', 'EU', 'AP'))) {
if ($location['country'] && !in_array($location['country'], ['A1', 'A2', 'EU', 'AP'])) {
$countryCode = $location['country'];
}
}

return $countryCode;
}

function if_menu_user_country_code_headers(string $countryCode = ''): string {
function layeredUserCountryCodeHeaders(string $countryCode = null): ?string {
if (empty($countryCode)) {
foreach (['HTTP_CF_IPCOUNTRY', 'X-AppEngine-country', 'CloudFront-Viewer-Country', 'GEOIP_COUNTRY_CODE', 'HTTP_X_COUNTRY_CODE', 'HTTP_X_GEO_COUNTRY'] as $key) {
if (isset($_SERVER[$key]) && $_SERVER[$key] && !in_array($_SERVER[$key], ['XX', 'ZZ', 'A1', 'A2', 'EU', 'AP'])) {
Expand Down

0 comments on commit 97bde8f

Please sign in to comment.