campaign.php
3 years ago
current_traffic.php
3 years ago
geo.php
3 years ago
page.php
3 years ago
page_author_archive.php
3 years ago
page_date_archive.php
3 years ago
page_home.php
3 years ago
page_not_found.php
3 years ago
page_post_type_archive.php
3 years ago
page_search.php
3 years ago
page_singular.php
3 years ago
page_term_archive.php
3 years ago
referrer.php
3 years ago
view_stats.php
3 years ago
visitor.php
3 years ago
wc_stats.php
3 years ago
geo.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | class Geo |
| 6 | { |
| 7 | use View_Stats; |
| 8 | use WC_Stats; |
| 9 | |
| 10 | private $continent; |
| 11 | private $country; |
| 12 | private $country_code; |
| 13 | private $subdivision; |
| 14 | private $city; |
| 15 | private $visitor_ids; |
| 16 | |
| 17 | public function __construct($row) |
| 18 | { |
| 19 | $this->continent = $row->continent; |
| 20 | $this->country = $row->country; |
| 21 | $this->country_code = $row->country_code; |
| 22 | $this->subdivision = $row->subdivision; |
| 23 | $this->city = $row->city; |
| 24 | $this->visitor_ids = $row->visitor_ids; |
| 25 | $this->set_view_stats($row); |
| 26 | $this->set_wc_stats($row); |
| 27 | } |
| 28 | |
| 29 | protected function ids() |
| 30 | { |
| 31 | return $this->visitor_ids; |
| 32 | } |
| 33 | |
| 34 | public function continent() |
| 35 | { |
| 36 | return $this->continent; |
| 37 | } |
| 38 | |
| 39 | public function country() |
| 40 | { |
| 41 | return $this->country; |
| 42 | } |
| 43 | |
| 44 | public function flag() |
| 45 | { |
| 46 | $img_name = strtolower($this->country_code); |
| 47 | |
| 48 | return url_to("img/flags/$img_name.svg"); |
| 49 | } |
| 50 | |
| 51 | public function subdivision() |
| 52 | { |
| 53 | return $this->subdivision; |
| 54 | } |
| 55 | |
| 56 | public function city() |
| 57 | { |
| 58 | return $this->city; |
| 59 | } |
| 60 | |
| 61 | public static function geo_ids(array $geos): array |
| 62 | { |
| 63 | if (count($geos) === 0) { |
| 64 | return []; |
| 65 | } |
| 66 | |
| 67 | $array_of_arrays = array_map(function ($geo) { |
| 68 | return $geo->ids(); |
| 69 | }, $geos); |
| 70 | |
| 71 | return array_merge(...$array_of_arrays); |
| 72 | } |
| 73 | } |
| 74 |