PluginProbe
Independent Analytics – WordPress Analytics Plugin / 1.23.1
Independent Analytics – WordPress Analytics Plugin v1.23.1
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 All 120 releases
independent-analytics / IAWP / Dashboard_Widget.php
Dashboard_Widget.php
48 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IAWP_SCOPED\IAWP;
4
5 use IAWP_SCOPED\IAWP\Date_Range\Relative_Date_Range;
6 use IAWP_SCOPED\IAWP\Statistics\Page_Statistics;
7 class Dashboard_Widget
8 {
9 public function __construct()
10 {
11 \add_action('wp_dashboard_setup', [$this, 'add_dashboard_widget']);
12 }
13 public function add_dashboard_widget()
14 {
15 if (Migrations\Migration::is_migrating() || !Capability_Manager::can_view()) {
16 return;
17 }
18 $url = \add_query_arg(['page' => 'independent-analytics'], \admin_url('admin.php'));
19 \ob_start();
20 ?>
21 <span><?php
22 \esc_html_e('Analytics', 'iawp');
23 ?></span>
24 <span>
25 <a href="<?php
26 echo \esc_url($url);
27 ?>" class="iawp-button purple">
28 <?php
29 \esc_html_e('Open Dashboard');
30 ?>
31 </a>
32 </span>
33 <?php
34 $title = \ob_get_contents();
35 \ob_end_clean();
36 \wp_add_dashboard_widget('iawp', $title, [$this, 'dashboard_widget']);
37 }
38 public function dashboard_widget()
39 {
40 $date_range = new Relative_Date_Range('LAST_THIRTY');
41 $statistics = new Page_Statistics($date_range);
42 $chart = new Chart($statistics, null, \true);
43 $stats = new Quick_Stats($statistics, null, \true);
44 echo $chart->get_html();
45 echo $stats->get_html();
46 }
47 }
48