PluginProbe
phpinfo() WP – Site Health, PHP Compatibility & Server Audit / 7.2.5
phpinfo() WP – Site Health, PHP Compatibility & Server Audit v7.2.5
7.2.7 7.2.6 7.2.5 7.2.4 7.2.3 7.2.0 7.2.1 7.2.2 7.1.0 7.0.3 7.0.4 7.0.5 trunk 6.0 7.0.0 7.0.1 7.0.2
phpinfo-wp / views / dashboard.php

dashboard.php in phpinfo() WP – Site Health, PHP Compatibility & Server Audit 7.2.5, at views/dashboard.php

222 lines 13.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') or die('Unauthorized Access');
3
4 $is_pro = Phpinfo_WP_License::is_valid();
5 $grader = Phpinfo_WP_Config_Grader::summary();
6 $bar = Phpinfo_WP_Admin_Bar::status();
7
8 // Fetch new stats for visual dashboard
9 $api_stats = class_exists('Phpinfo_WP_API_Monitor') ? Phpinfo_WP_API_Monitor::get_stats() : [];
10 if (!is_array($api_stats)) $api_stats = [];
11 $db_stats = class_exists('Phpinfo_WP_DB_Health') ? Phpinfo_WP_DB_Health::autoload_size() : ['total_kb' => 0];
12 if (!is_array($db_stats)) $db_stats = ['total_kb' => 0];
13
14 $grade = $grader['grade'];
15 $score = $grader['score'];
16 $mem = $bar['memory'] ?? ['peak_bytes' => 0, 'limit_label' => ini_get('memory_limit'), 'pct' => 0];
17
18 // Calculate Donut Chart (Memory)
19 $mem_pct = $mem['pct'];
20 $mem_color = $mem_pct > 85 ? '#d63638' : ($mem_pct > 65 ? '#dba617' : '#00a32a');
21 $dasharray = $mem_pct . ' ' . (100 - $mem_pct);
22
23 // Calculate API Chart
24 $slowest_apis = [];
25 foreach ($api_stats as $host => $data) {
26 $slowest_apis[$host] = $data['max_time'];
27 }
28 arsort($slowest_apis);
29 $top_apis = array_slice($slowest_apis, 0, 3, true);
30
31 // Calculate DB Autoload Bar
32 $db_bytes = $db_stats['bytes'] ?? 0;
33 $db_kb = round($db_bytes / 1024, 1);
34 // 800KB is danger zone. Max scale is 1200KB.
35 $db_pct = min(100, ($db_kb / 1200) * 100);
36 $db_color = $db_kb > 800 ? '#d63638' : ($db_kb > 400 ? '#dba617' : '#00a32a');
37
38 // Config Grade Bar
39 $grade_pct = $score;
40 $grade_color = $score < 60 ? '#d63638' : ($score < 80 ? '#dba617' : '#00a32a');
41
42 // Fetch the current nav arrays
43 $nav_cache = Phpinfo_WP_Admin_Nav::groups();
44
45 if (!function_exists('render_dash_grid')) {
46 function render_dash_grid($group_id, $nav_cache, $is_pro) {
47 if (!isset($nav_cache[$group_id])) return;
48 $group = $nav_cache[$group_id];
49 echo '<div class="phpinfowp-dash-section">';
50 echo '<h2 class="phpinfowp-dash-section-title">' . esc_html($group['label']) . '</h2>';
51 echo '<div class="phpinfowp-dash-grid">';
52 foreach ($group['tabs'] as $slug => $tab) {
53 $locked = $tab['pro'] && !$is_pro;
54 echo '<a href="' . esc_url(admin_url('admin.php?page=' . $slug)) . '" class="phpinfowp-dash-card' . ($locked ? ' is-locked' : '') . '">';
55 echo '<span class="dashicons ' . esc_attr($tab['icon']) . '"></span>';
56 echo '<div class="phpinfowp-dash-card-title">';
57 echo esc_html($tab['label']);
58 if ($tab['pro']) {
59 echo '<span class="phpinfowp-dash-card-pro">' . __('PRO', 'phpinfo-wp') . '</span>';
60 }
61 echo '</div>';
62 echo '</a>';
63 }
64 echo '</div></div>';
65 }
66 }
67 ?>
68
69 <div class="phpinfowp-pro-page phpinfowp-dashboard">
70
71 <div class="phpinfowp-page-header">
72 <div>
73 <h1><?php _e('Dashboard', 'phpinfo-wp'); ?></h1>
74 <p class="phpinfowp-page-subtitle"><?php _e('Visual health overview and system shortcuts', 'phpinfo-wp'); ?></p>
75 </div>
76 </div>
77
78 <?php if (!$is_pro): ?>
79 <div class="phpinfowp-price-alert-banner" style="position:relative; background:#fff3cd; border-left:4px solid #ffc107; padding:12px 40px 12px 16px; margin: 0 0 24px; border-radius: 0 4px 4px 0; font-size:13.5px; color:#664d03; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; box-shadow:0 1px 2px rgba(0,0,0,0.02);">
80 <button type="button" onclick="try{localStorage.setItem('phpinfowp_price_alert_dismissed','1')}catch(e){} this.closest('.phpinfowp-price-alert-banner').style.display='none';" aria-label="<?php esc_attr_e('Dismiss', 'phpinfo-wp'); ?>" style="position:absolute; top:6px; right:8px; background:none; border:none; cursor:pointer; color:#664d03; opacity:0.5; font-size:20px; line-height:1; padding:2px 4px;" onmouseover="this.style.opacity='1'" onmouseout="this.style.opacity='0.5'">&times;</button>
81 <span>
82 <strong> <?php _e('Price Increase Alert:', 'phpinfo-wp'); ?></strong>
83 <?php _e('On August 31st, the Single Site Pro license increases from $29 to $39/year. Upgrade today to secure the current $29/year rate before the price goes up.', 'phpinfo-wp'); ?>
84 </span>
85 <a href="https://exeebit.com/phpinfo-wp#pricing" target="_blank" rel="noopener" style="background:#777BB3; color:#fff; padding:6px 14px; border-radius:4px; font-size:12.5px; font-weight:600; text-decoration:none; display:inline-block;">
86 <?php _e('Lock in $29 Now →', 'phpinfo-wp'); ?>
87 </a>
88 </div>
89 <script>if(localStorage.getItem('phpinfowp_price_alert_dismissed')==='1'){document.querySelectorAll('.phpinfowp-price-alert-banner').forEach(function(e){e.style.display='none';});}</script>
90 <?php endif; ?>
91
92 <!-- VISUAL INSIGHTS WIDGETS -->
93 <div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(280px, 1fr)); gap:20px; margin-bottom:32px;">
94
95 <!-- 1. Config Grader Gauge -->
96 <a href="<?php echo esc_url(admin_url('admin.php?page=phpinfowp-config-grader')); ?>" style="background:#fff; border:1px solid #ccd0d4; border-radius:6px; padding:20px; text-decoration:none; color:inherit; box-shadow:0 1px 2px rgba(0,0,0,0.02); display:flex; flex-direction:column; justify-content:space-between;">
97 <div>
98 <h3 style="margin:0 0 12px 0; font-size:14px; color:#555; text-transform:uppercase; letter-spacing:0.5px;"><?php _e('Setup Optimization', 'phpinfo-wp'); ?></h3>
99 <div style="font-size:32px; font-weight:300; line-height:1; margin-bottom:8px; color:#1d2327;">
100 <?php printf(
101 /* translators: %s: score value */
102 __('%s / 100', 'phpinfo-wp'),
103 (int)$score
104 ); ?>
105 </div>
106 </div>
107 <div>
108 <div style="width:100%; height:8px; background:#f0f0f1; border-radius:4px; overflow:hidden; margin-bottom:6px;">
109 <div style="height:100%; width:<?php echo $grade_pct; ?>%; background:<?php echo $grade_color; ?>; border-radius:4px;"></div>
110 </div>
111 <div style="font-size:12px; color:#777;">
112 <?php _e('Current Grade:', 'phpinfo-wp'); ?> <strong class="grade-<?php echo esc_attr(strtolower(str_replace('+', 'plus', $grade))); ?>"><?php echo esc_html($grade); ?></strong>
113 </div>
114 </div>
115 </a>
116
117 <!-- 2. Memory Donut Chart -->
118 <a href="<?php echo esc_url(admin_url('admin.php?page=phpinfowp-info')); ?>" style="background:#fff; border:1px solid #ccd0d4; border-radius:6px; padding:20px; text-decoration:none; color:inherit; box-shadow:0 1px 2px rgba(0,0,0,0.02); display:flex; align-items:center; justify-content:space-between;">
119 <div>
120 <h3 style="margin:0 0 8px 0; font-size:14px; color:#555; text-transform:uppercase; letter-spacing:0.5px;"><?php _e('Memory Peak', 'phpinfo-wp'); ?></h3>
121 <div style="font-size:24px; font-weight:300; line-height:1.2; margin-bottom:4px; color:#1d2327;">
122 <?php echo esc_html(size_format($mem['peak_bytes'] > 0 ? $mem['peak_bytes'] : memory_get_usage(true))); ?>
123 </div>
124 <div style="font-size:12px; color:#777;">
125 <?php _e('Limit:', 'phpinfo-wp'); ?> <?php echo esc_html($mem['limit_label']); ?>
126 </div>
127 </div>
128 <svg width="80" height="80" viewBox="0 0 36 36" style="display:block;">
129 <path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="#f0f0f1" stroke-width="4"/>
130 <path d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831" fill="none" stroke="<?php echo $mem_color; ?>" stroke-width="4" stroke-dasharray="<?php echo $dasharray; ?>" />
131 <text x="18" y="20.5" font-family="sans-serif" font-size="9" font-weight="bold" fill="#555" text-anchor="middle"><?php echo $mem_pct; ?>%</text>
132 </svg>
133 </a>
134
135 <!-- 3. DB Autoload Progress -->
136 <a href="<?php echo esc_url(admin_url('admin.php?page=phpinfowp-db-health')); ?>" style="background:#fff; border:1px solid #ccd0d4; border-radius:6px; padding:20px; text-decoration:none; color:inherit; box-shadow:0 1px 2px rgba(0,0,0,0.02); display:flex; flex-direction:column; justify-content:space-between;">
137 <div>
138 <h3 style="margin:0 0 12px 0; font-size:14px; color:#555; text-transform:uppercase; letter-spacing:0.5px;"><?php _e('Autoload Bloat', 'phpinfo-wp'); ?></h3>
139 <div style="font-size:24px; font-weight:300; line-height:1; margin-bottom:8px; color:<?php echo $db_color; ?>;">
140 <?php echo $db_kb; ?> <span style="font-size:16px; color:#888;">KB</span>
141 </div>
142 </div>
143 <div>
144 <div style="width:100%; height:8px; background:#f0f0f1; border-radius:4px; overflow:hidden; margin-bottom:6px;">
145 <div style="height:100%; width:<?php echo $db_pct; ?>%; background:<?php echo $db_color; ?>; border-radius:4px;"></div>
146 </div>
147 <div style="font-size:12px; color:#777;">
148 <?php echo $db_kb > 800 ? __('Danger: High TTFB Impact', 'phpinfo-wp') : __('Healthy footprint', 'phpinfo-wp'); ?>
149 </div>
150 </div>
151 </a>
152
153 <!-- 4. API Monitor Bar Chart -->
154 <a href="<?php echo esc_url(admin_url('admin.php?page=phpinfowp-api-monitor')); ?>" style="background:#fff; border:1px solid #ccd0d4; border-radius:6px; padding:20px; text-decoration:none; color:inherit; box-shadow:0 1px 2px rgba(0,0,0,0.02); display:flex; flex-direction:column;">
155 <h3 style="margin:0 0 12px 0; font-size:14px; color:#555; text-transform:uppercase; letter-spacing:0.5px;"><?php _e('Slowest External APIs', 'phpinfo-wp'); ?></h3>
156 <?php if (empty($top_apis)): ?>
157 <div style="flex:1; display:flex; align-items:center; justify-content:center; color:#888; font-size:13px; font-style:italic;">
158 <?php _e('No slow API calls detected', 'phpinfo-wp'); ?>
159 </div>
160 <?php else: ?>
161 <div style="flex:1; display:flex; flex-direction:column; justify-content:space-around;">
162 <?php
163 $max_t = max(2.0, max($top_apis)); // base scale on 2.0s or highest
164 foreach($top_apis as $host => $time):
165 $w = min(100, ($time / $max_t) * 100);
166 $c = $time > 2.0 ? '#d63638' : ($time > 1.0 ? '#dba617' : '#00a32a');
167 ?>
168 <div style="margin-bottom:6px;">
169 <div style="display:flex; justify-content:space-between; font-size:11px; color:#555; margin-bottom:2px;">
170 <span style="white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:70%;"><?php echo esc_html($host); ?></span>
171 <strong><?php echo number_format($time, 1); ?>s</strong>
172 </div>
173 <div style="width:100%; height:4px; background:#f0f0f1; border-radius:2px;">
174 <div style="height:100%; width:<?php echo $w; ?>%; background:<?php echo $c; ?>; border-radius:2px;"></div>
175 </div>
176 </div>
177 <?php endforeach; ?>
178 </div>
179 <?php endif; ?>
180 </a>
181
182 </div>
183
184 <!-- Active issues panel -->
185 <?php if (!empty($bar['issues'])): ?>
186 <div class="phpinfowp-dash-section">
187 <h2 class="phpinfowp-dash-section-title"><?php _e('Active Issues', 'phpinfo-wp'); ?></h2>
188 <div class="phpinfowp-dash-issues">
189 <?php foreach ($bar['issues'] as $issue):
190 $c = $issue['level'] === 'critical' ? '#d63638' : '#dba617';
191 ?>
192 <a href="<?php echo esc_url($issue['href']); ?>" class="phpinfowp-dash-issue">
193 <span class="phpinfowp-dash-issue-dot" style="background:<?php echo $c; ?>"></span>
194 <strong><?php echo esc_html($issue['label']); ?></strong>
195 <span class="phpinfowp-dash-issue-detail"><?php echo esc_html($issue['detail']); ?></span>
196 </a>
197 <?php endforeach; ?>
198 </div>
199 </div>
200 <?php endif; ?>
201
202 <!-- Nav Grids -->
203 <?php
204 render_dash_grid('performance', $nav_cache, $is_pro);
205 render_dash_grid('audit', $nav_cache, $is_pro);
206 render_dash_grid('tools', $nav_cache, $is_pro);
207 render_dash_grid('reports', $nav_cache, $is_pro);
208 ?>
209
210 <?php if (!$is_pro): ?>
211 <div style="margin-top:24px;padding:14px 16px;background:#f6f7f7;border:1px solid #e5e7ea;border-radius:4px;display:flex;align-items:center;justify-content:space-between;">
212 <span style="font-size:13px;color:#555;">
213 <?php _e('🔒 Running <strong>Pro features</strong> in preview mode.', 'phpinfo-wp'); ?>
214 </span>
215 <a href="https://exeebit.com/phpinfo-wp#pricing" target="_blank" rel="noopener"
216 style="background:#777BB3;color:#fff;padding:6px 14px;border-radius:4px;font-size:12.5px;font-weight:600;text-decoration:none;">
217 <?php _e('Unlock full access →', 'phpinfo-wp'); ?>
218 </a>
219 </div>
220 <?php endif; ?>
221
222 </div>