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