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