diff --git a/au.php b/au.php index fb15f44..cfde0ba 100644 --- a/au.php +++ b/au.php @@ -19,6 +19,38 @@ class BAU { add_action('wp_enqueue_scripts', array($this, 'register_js_css'), 99); $this->ajax_hook('is_admin'); $this->ajax_hook('is_logged_in'); + add_action('wp', array($this, 'check_au')); + } + + public function check_au() + { + $ip = \geoip_detect2_get_client_ip(); + $ipinfo = \geoip_detect2_get_info_from_current_ip(); + if ($this->is_au($ipinfo)){ + if (!$this->is_user_admin()) { + if($this->is_url_wp_admin()){ + //wp-admin, we stay + }else{ + wp_redirect("https://supertraderfx.com.au/", 307); + } + } + } + } + + + private function is_au ($ipinfo) + { + return $ipinfo->country->isoCode == "AU"; + } + + private function is_url_wp_admin() + { + $url = $_SERVER['REQUEST_URI']; + if ($url == "/wp-admin/"){ + return true; + }else{ + return false; + } } private function ajax_hook($code, $admin_only = false)