diff --git a/src/CustomPostType.php b/src/CustomPostType.php index ea44cf0..a23e0fc 100644 --- a/src/CustomPostType.php +++ b/src/CustomPostType.php @@ -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; } diff --git a/src/functions.php b/src/functions.php index 4265850..424c688 100644 --- a/src/functions.php +++ b/src/functions.php @@ -16,17 +16,17 @@ 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']; } } @@ -34,7 +34,7 @@ function layered_visitor_country_code_woocommerce(string $countryCode = ''): str 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'])) {