PluginProbe
RabbitLoader / trunk
RabbitLoader vtrunk
4.0.2 4.0.1 4.0 3.2.0 3.1.1 3.1.0 3.0.5 3.0.3 3.0.4 2.17.1 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.7 2.18.0 2.18.1 2.18.2 2.18.3 2.18.4 2.18.5 2.18.6 2.18.7 2.18.8 All 129 releases
rabbit-loader / admin / views / dashboard.php

dashboard.php in RabbitLoader trunk, at admin/views/dashboard.php

146 lines 5.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (!defined('ABSPATH')) {
3 exit;
4 }
5
6 $dashboard = isset($dashboard) && is_array($dashboard) ? $dashboard : [];
7 $ok = !empty($dashboard['ok']);
8
9 if (!function_exists('rl6_fmt_number')) {
10 function rl6_fmt_number($value)
11 {
12 if (!is_numeric($value)) {
13 return '';
14 }
15
16 $value = (float) $value;
17
18 if ($value >= 1000000) {
19 return number_format_i18n($value / 1000000, 1) . 'M';
20 }
21
22 if ($value >= 1000) {
23 return number_format_i18n($value / 1000, 1) . 'K';
24 }
25
26 return number_format_i18n($value, $value == floor($value) ? 0 : 1);
27 }
28 }
29
30 $pageviews_used = $ok ? $dashboard['pageviews_used'] : 0;
31 $pageviews_quota = $ok ? $dashboard['pageviews_quota'] : 0;
32 $pageviews_percent = $ok ? $dashboard['pageviews_percent'] : 0;
33 ?>
34 <section class="rl6-page-heading">
35 <div>
36 <span class="rl6-eyebrow">Overview</span>
37 <h1>Dashboard</h1>
38 <p>Performance, usage and the controls you need most often.</p>
39 </div>
40
41 <button type="button" id="rl5-refresh-dashboard" class="rl6-button rl6-button-secondary">
42 Refresh data
43 </button>
44 </section>
45
46 <?php if (!$ok) : ?>
47 <div class="rl6-alert rl6-alert-error">
48 <strong>RabbitLoader is connected, but dashboard data could not be loaded.</strong>
49 <span><?php echo esc_html(!empty($dashboard['error']) ? $dashboard['error'] : 'Unknown API error.'); ?></span>
50 </div>
51 <?php endif; ?>
52
53 <div class="rl6-metric-grid">
54 <article class="rl6-card rl6-metric-card">
55 <span class="rl6-metric-label">Current plan</span>
56 <strong class="rl6-metric-value"><?php echo esc_html($ok ? $dashboard['plan_title'] : ''); ?></strong>
57 <div class="rl6-plan-benefit">
58 <span class="dashicons dashicons-yes-alt"></span>
59 <span><strong>Unlimited bandwidth</strong><small>Included with every RabbitLoader plan</small></span>
60 </div>
61 </article>
62
63 <article class="rl6-card rl6-metric-card">
64 <span class="rl6-metric-label">Page views</span>
65 <strong class="rl6-metric-value">
66 <?php echo esc_html(rl6_fmt_number($pageviews_used)); ?>
67 <small>/ <?php echo esc_html(rl6_fmt_number($pageviews_quota)); ?></small>
68 </strong>
69 <div class="rl6-progress"><span style="width:<?php echo esc_attr($pageviews_percent); ?>%"></span></div>
70 <span class="rl6-metric-note"><?php echo esc_html($pageviews_percent); ?>% of current allowance</span>
71 </article>
72
73 <article class="rl6-card rl6-metric-card">
74 <span class="rl6-metric-label">Home Page Score</span>
75 <strong class="rl6-metric-value"><?php echo esc_html($ok ? (string) $dashboard['best_score'] : ''); ?></strong>
76 <span class="rl6-metric-note">
77 Average score <?php echo esc_html($ok ? (string) $dashboard['average_score'] : ''); ?>
78 </span>
79 </article>
80
81 <article class="rl6-card rl6-metric-card">
82 <span class="rl6-metric-label">Unique pages</span>
83 <strong class="rl6-metric-value"><?php echo esc_html($ok ? number_format_i18n($dashboard['canonical_url_count']) : ''); ?></strong>
84 <span class="rl6-metric-note">Pages detected by RabbitLoader</span>
85 </article>
86
87 <article class="rl6-card rl6-metric-card">
88 <span class="rl6-metric-label">CSS reduction</span>
89 <strong class="rl6-metric-value"><?php echo esc_html($ok ? rl6_fmt_number($dashboard['css_reduction']) . '%' : ''); ?></strong>
90 <span class="rl6-metric-note">Optimization overview</span>
91 </article>
92
93 <article class="rl6-card rl6-metric-card">
94 <span class="rl6-metric-label">Image reduction</span>
95 <strong class="rl6-metric-value"><?php echo esc_html($ok ? rl6_fmt_number($dashboard['image_compression']) . '%' : ''); ?></strong>
96 <span class="rl6-metric-note">Average image compression</span>
97 </article>
98 </div>
99
100 <div class="rl6-dashboard-lower">
101 <section class="rl6-card rl6-control-card">
102 <div class="rl6-section-title-row">
103 <div>
104 <span class="rl6-eyebrow">Visibility control</span>
105 <h2>ME Mode</h2>
106 </div>
107 <span class="rl6-status-pill rl6-status-neutral">Status not loaded yet</span>
108 </div>
109
110 <p>
111 Use ME Mode for testing and debugging. Regular visitors continue to see the original pages;
112 you can inspect RabbitLoader-optimized pages with <code>?rltest=1</code>.
113 </p>
114
115 <button
116 type="button"
117 class="rl6-button rl6-button-primary rl6-ui-preview"
118 data-message="ME Mode is placed in the finished UI. Backend mode-state and toggle wiring comes after the UI is approved."
119 >
120 Enable ME Mode
121 </button>
122 </section>
123
124 <section class="rl6-card rl6-control-card">
125 <div class="rl6-section-title-row">
126 <div>
127 <span class="rl6-eyebrow">Cache control</span>
128 <h2>Purge All Pages</h2>
129 </div>
130 </div>
131
132 <p>
133 Clear RabbitLoader's optimized page cache. The existing plugin flow warms pages again after a purge.
134 </p>
135
136 <button
137 type="button"
138 id="rl5-purge-all"
139 class="rl6-button rl6-button-outline-danger"
140 >
141 Purge All Pages
142 </button>
143 <span id="rl5-purge-status" class="rl6-inline-status" role="status" aria-live="polite"></span>
144 </section>
145 </div>
146