ajax
3 years ago
databases
3 years ago
migrations
3 years ago
models
3 years ago
queries
3 years ago
utils
3 years ago
chart.php
3 years ago
chart_geo.php
3 years ago
dashboard_widget.php
3 years ago
db.php
3 years ago
filters.php
3 years ago
freemius.php
3 years ago
independent_analytics.php
3 years ago
known_referrers.php
3 years ago
quick_stats.php
3 years ago
rest_api.php
3 years ago
settings.php
3 years ago
table.php
3 years ago
table_geo.php
3 years ago
table_referrers.php
3 years ago
table_views.php
3 years ago
track_resource_changes.php
3 years ago
view_counter.php
3 years ago
dashboard_widget.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | namespace IAWP; |
| 4 | |
| 5 | class Dashboard_Widget |
| 6 | { |
| 7 | public function __construct() |
| 8 | { |
| 9 | if (!Migration::is_migrating()) { |
| 10 | add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']); |
| 11 | } |
| 12 | } |
| 13 | |
| 14 | public function add_dashboard_widget() |
| 15 | { |
| 16 | $url = add_query_arg([ |
| 17 | 'page' => 'independent-analytics', |
| 18 | ], admin_url('admin.php')); |
| 19 | ob_start(); ?> |
| 20 | <span><?php esc_html_e('Analytics', 'iawp') ?></span> |
| 21 | <span> |
| 22 | <a href="<?php echo esc_url($url) ?>" class="iawp-button purple"> |
| 23 | <?php esc_html_e('Open Dashboard') ?> |
| 24 | </a> |
| 25 | </span> |
| 26 | <?php |
| 27 | $title = ob_get_contents(); |
| 28 | ob_end_clean(); |
| 29 | wp_add_dashboard_widget('iawp', $title, [$this, 'dashboard_widget']); |
| 30 | } |
| 31 | |
| 32 | public function dashboard_widget() |
| 33 | { |
| 34 | $views = new Views(Views::RESOURCES); |
| 35 | $chart = new Chart($views); |
| 36 | $stats = new Quick_Stats($views); |
| 37 | |
| 38 | echo $chart->get_html(); |
| 39 | echo $stats->get_html(); |
| 40 | } |
| 41 | } |
| 42 |