AJAX
3 years ago
Migrations
3 years ago
Models
3 years ago
Queries
3 years ago
Tables
3 years ago
Utils
3 years ago
Campaign_Builder.php
3 years ago
Capability_Manager.php
3 years ago
Chart.php
3 years ago
Chart_Geo.php
3 years ago
Chart_SVG.php
3 years ago
Current_Resource.php
3 years ago
Dashboard_Options.php
3 years ago
Dashboard_Widget.php
3 years ago
Email_Reports.php
3 years ago
Filters.php
3 years ago
Geo_Database.php
3 years ago
Geo_Database_Download_Job.php
3 years ago
Health_Check.php
3 years ago
Independent_Analytics.php
3 years ago
Known_Referrers.php
3 years ago
PDF.php
3 years ago
Query.php
3 years ago
Quick_Stats.php
3 years ago
REST_API.php
3 years ago
Real_Time.php
3 years ago
Settings.php
3 years ago
Track_Resource_Changes.php
3 years ago
View_Counter.php
3 years ago
WP_Option_Cache_Bust.php
3 years ago
Chart_Geo.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | class Chart_Geo |
| 6 | { |
| 7 | private $geos; |
| 8 | private $title; |
| 9 | |
| 10 | public function __construct($geos, $title = null) |
| 11 | { |
| 12 | $this->geos = $geos; |
| 13 | $this->title = $title; |
| 14 | } |
| 15 | |
| 16 | public function get_html() |
| 17 | { |
| 18 | $chart_data = array_map(function ($geo) { |
| 19 | return [$geo->country(), $geo->views(), $geo->visitors()]; |
| 20 | }, $this->geos); |
| 21 | |
| 22 | ob_start(); ?> |
| 23 | <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> |
| 24 | <div class="chart-container"> |
| 25 | <div class="chart-inner"> |
| 26 | <div class="legend-container"> |
| 27 | <h2 class="legend-title"><?php echo $this->title ?></h2> |
| 28 | </div> |
| 29 | <div id="myChart" |
| 30 | data-controller="chart-geo" |
| 31 | data-chart-geo-data-value="<?php esc_attr_e(json_encode($chart_data)) ?>" |
| 32 | data-chart-geo-dark-mode-value="<?php esc_attr_e((int) iawp()->get_option('iawp_dark_mode', false)) ?>"> |
| 33 | <div data-chart-geo-target="chart"></div> |
| 34 | </div> |
| 35 | </div> |
| 36 | </div><?php |
| 37 | |
| 38 | $html = ob_get_contents(); |
| 39 | ob_end_clean(); |
| 40 | |
| 41 | return $html; |
| 42 | } |
| 43 | } |
| 44 |