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
Dashboard_Widget.php
48 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | use IAWP\Queries\Views; |
| 6 | use IAWP\Utils\Relative_Range; |
| 7 | |
| 8 | class Dashboard_Widget |
| 9 | { |
| 10 | public function __construct() |
| 11 | { |
| 12 | add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']); |
| 13 | } |
| 14 | |
| 15 | public function add_dashboard_widget() |
| 16 | { |
| 17 | if (Migrations\Migration::is_migrating() || !Capability_Manager::can_view()) { |
| 18 | return; |
| 19 | } |
| 20 | |
| 21 | $url = add_query_arg([ |
| 22 | 'page' => 'independent-analytics', |
| 23 | ], admin_url('admin.php')); |
| 24 | ob_start(); ?> |
| 25 | <span><?php esc_html_e('Analytics', 'iawp') ?></span> |
| 26 | <span> |
| 27 | <a href="<?php echo esc_url($url) ?>" class="iawp-button purple"> |
| 28 | <?php esc_html_e('Open Dashboard') ?> |
| 29 | </a> |
| 30 | </span> |
| 31 | <?php |
| 32 | $title = ob_get_contents(); |
| 33 | ob_end_clean(); |
| 34 | wp_add_dashboard_widget('iawp', $title, [$this, 'dashboard_widget']); |
| 35 | } |
| 36 | |
| 37 | public function dashboard_widget() |
| 38 | { |
| 39 | $range = Relative_Range::range('LAST_THIRTY'); |
| 40 | $views = new Views(Views::RESOURCES, null, $range->start, $range->end); |
| 41 | $chart = new Chart($views, null, true); |
| 42 | $stats = new Quick_Stats($views, null, true); |
| 43 | |
| 44 | echo $chart->get_html(); |
| 45 | echo $stats->get_html(); |
| 46 | } |
| 47 | } |
| 48 |