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 / pro / compat.php

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

192 lines 11.9 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 // PHP Compatibility Scanner is FREE — the WP-Engine and Eli scanners are
5 // abandoned or only work in dev environments, so this captures real demand.
6 // Pro adds scheduled scans, more files per run, and email alerts when new
7 // compat issues appear after a plugin/theme update.
8 $is_pro = Phpinfo_WP_License::is_valid();
9
10 $target = isset($_GET['target']) && in_array($_GET['target'], Phpinfo_WP_Compat::targets(), true)
11 ? $_GET['target'] : '8.2';
12
13 if (isset($_POST['phpinfowp_scan']) && check_admin_referer('phpinfowp_compat_nonce')) {
14 $target = sanitize_text_field($_POST['target'] ?? '8.2');
15 Phpinfo_WP_Compat::scan($target);
16 }
17 if (isset($_POST['phpinfowp_clear']) && check_admin_referer('phpinfowp_compat_nonce')) {
18 Phpinfo_WP_Compat::clear();
19 }
20
21 $result = Phpinfo_WP_Compat::get_result();
22 ?>
23
24 <div class="phpinfowp-pro-page">
25
26 <div class="phpinfowp-page-header">
27 <div>
28 <h1><?php _e('PHP Compatibility Scanner', 'phpinfo-wp'); ?></h1>
29 <p class="phpinfowp-page-subtitle">Find deprecated/removed PHP functions in your plugins and themes before upgrading. Works on managed hosts (no <code>exec()</code> required).</p>
30 </div>
31 </div>
32
33 <?php if (!$is_pro): ?>
34 <div style="background:linear-gradient(135deg,#f3f7ff,#eaf4ff);border:1px solid #c8d8f5;border-radius:8px;padding:12px 16px;margin:0 0 18px;display:flex;gap:14px;align-items:center;flex-wrap:wrap">
35 <span style="font-size:13px;color:#1a3a72">
36 <strong><?php _e('Free scanner:', 'phpinfo-wp'); ?></strong> up to <?php echo Phpinfo_WP_Compat::FREE_MAX_FILES; ?> files per run. Pro raises the cap to <?php echo Phpinfo_WP_Compat::MAX_FILES_PER_RUN; ?>, adds scheduled weekly scans, and emails you when an updated plugin introduces a new compat issue.
37 </span>
38 <a href="https://exeebit.com/phpinfo-wp#pricing" target="_blank" class="button button-primary" style="margin-left:auto"><?php _e('Get Pro →', 'phpinfo-wp'); ?></a>
39 </div>
40 <?php endif; ?>
41
42 <form method="post" class="phpinfowp-compat-controls">
43 <?php wp_nonce_field('phpinfowp_compat_nonce'); ?>
44 <label>
45 <strong><?php _e('Target PHP version:', 'phpinfo-wp'); ?></strong>
46 <select name="target">
47 <?php foreach (Phpinfo_WP_Compat::targets() as $t): ?>
48 <option value="<?php echo esc_attr($t); ?>" <?php selected($target, $t); ?>>PHP <?php echo esc_html($t); ?></option>
49 <?php endforeach; ?>
50 </select>
51 </label>
52 <button type="submit" name="phpinfowp_scan" value="1" class="button button-primary">
53 <span class="dashicons dashicons-search"></span>Run Scan
54 </button>
55 <?php if ($result): ?>
56 <button type="submit" name="phpinfowp_clear" value="1" class="button button-secondary"><?php _e('Clear results', 'phpinfo-wp'); ?></button>
57 <?php endif; ?>
58 </form>
59
60 <?php if (isset($result['error'])): ?>
61 <div class="notice notice-error inline"><p><?php echo esc_html($result['error']); ?></p></div>
62 <?php elseif (!$result): ?>
63 <div class="phpinfowp-compat-empty">
64 <span class="dashicons dashicons-search"></span>
65 <h3><?php _e('No scan yet', 'phpinfo-wp'); ?></h3>
66 <p><?php _e('Pick a target PHP version above and click "Run Scan" to analyze your installed plugins and themes.', 'phpinfo-wp'); ?></p>
67 <p style="font-size:12px;color:#888">Scans up to <?php echo $is_pro ? Phpinfo_WP_Compat::MAX_FILES_PER_RUN : Phpinfo_WP_Compat::FREE_MAX_FILES; ?> PHP files. Takes 10–60 seconds.</p>
68 </div>
69 <?php else:
70 $sev_color = ['removed' => '#d63638', 'deprecated' => '#dba617'];
71 $sev_label = ['removed' => 'REMOVED', 'deprecated' => 'DEPRECATED'];
72 $issues = $result['issues'] ?? [];
73 uksort($issues, function ($a, $b) use ($issues) {
74 return count($issues[$b]) - count($issues[$a]);
75 });
76 ?>
77
78 <!-- Score card -->
79 <div class="phpinfowp-score-card" style="margin-bottom:24px">
80 <div class="phpinfowp-grade-circle <?php echo $result['total'] === 0 ? 'grade-aplus' : ($result['total'] < 10 ? 'grade-b' : ($result['total'] < 50 ? 'grade-c' : 'grade-f')); ?>">
81 <?php echo $result['total'] === 0 ? '' : (int)$result['total']; ?>
82 </div>
83 <div class="phpinfowp-score-card-body">
84 <div class="phpinfowp-score-card-value">
85 <?php if ($result['total'] === 0): ?>
86 Compatible<span> with PHP <?php echo esc_html($result['target']); ?></span>
87 <?php else: ?>
88 <?php echo (int)$result['total']; ?> issue<?php echo $result['total'] !== 1 ? 's' : ''; ?>
89 <span>against PHP <?php echo esc_html($result['target']); ?></span>
90 <?php endif; ?>
91 </div>
92 <div class="phpinfowp-score-card-meta">
93 <strong><?php echo (int)$result['with_issues']; ?></strong> of <strong><?php echo (int)$result['owners']; ?></strong> plugins/themes affected
94 &nbsp;&middot;&nbsp;
95 <?php echo number_format($result['files']); ?> files scanned in <?php echo esc_html($result['duration']); ?>s
96 &nbsp;&middot;&nbsp;
97 <?php echo esc_html(human_time_diff($result['scanned_at']) . ' ago'); ?>
98 </div>
99 </div>
100 </div>
101
102 <?php
103 $current_php = phpversion();
104 $is_already_on_target = version_compare($current_php, $result['target'], '>=');
105
106 $total_removed = 0;
107 $total_deprecated = 0;
108 foreach ($issues as $list) {
109 foreach ($list as $issue) {
110 if ($issue['severity'] === 'removed') $total_removed++;
111 else $total_deprecated++;
112 }
113 }
114 ?>
115
116 <?php if ($result['total'] === 0): ?>
117 <div class="notice notice-success inline" style="margin:0 0 24px">
118 <p><strong><?php _e('Safe to upgrade!', 'phpinfo-wp'); ?></strong> No deprecated or removed function calls were detected for PHP <?php echo esc_html($result['target']); ?>. Your site should continue working normally after the upgrade.</p>
119 </div>
120 <?php else: ?>
121 <?php if ($is_already_on_target): ?>
122 <div class="notice notice-info inline" style="margin:0 0 24px; border-left-color: #2271b1;">
123 <p style="font-size: 15px;"><strong>ℹ️ You are already running PHP <?php echo esc_html(explode('-', $current_php)[0]); ?></strong></p>
124 <p>We found <strong><?php echo $total_removed + $total_deprecated; ?> potential issues</strong> against PHP <?php echo esc_html($result['target']); ?>. However, since your site is currently running fine, these are almost certainly <strong><?php _e('false positives', 'phpinfo-wp'); ?></strong> (e.g., legacy fallback code that never runs, or function names inside comments). No action is required unless you are experiencing actual errors in your logs.</p>
125 </div>
126 <?php elseif ($total_removed > 0): ?>
127 <div class="notice notice-error inline" style="margin:0 0 24px; border-left-color: #d63638;">
128 <p style="font-size: 15px;"><strong>🚨 HIGH RISK: Check before upgrading</strong></p>
129 <p>Your plugins contain <strong><?php echo $total_removed; ?> removed functions</strong>. Removed functions cause <strong><?php _e('fatal errors', 'phpinfo-wp'); ?></strong> in PHP <?php echo esc_html($result['target']); ?>. Unless these are false positives, your website will likely crash if you upgrade your server right now. Please verify the red items below or update those plugins first.</p>
130 </div>
131 <?php else: ?>
132 <div class="notice notice-warning inline" style="margin:0 0 24px; border-left-color: #dba617;">
133 <p style="font-size: 15px;"><strong>⚠️ Proceed with Caution</strong></p>
134 <p>We found <strong><?php echo $total_deprecated; ?> deprecated functions</strong>. If you upgrade to PHP <?php echo esc_html($result['target']); ?>, your site should not crash, but you may see PHP warnings or minor bugs. You should look for updates for the plugins highlighted in yellow below.</p>
135 </div>
136 <?php endif; ?>
137
138 <p class="description" style="margin:0 0 16px"><?php _e('Regex-based scan — some matches may be false positives (e.g., function names in comments or strings). Always verify before changing third-party code.', 'phpinfo-wp'); ?></p>
139
140 <?php foreach ($issues as $owner => $list):
141 [$type, $name] = explode('/', $owner, 2);
142 $type_label = ['plugin' => 'Plugin', 'theme' => 'Theme', 'mu-plugin' => 'Must-Use'][$type] ?? $type;
143 $type_color = ['plugin' => '#777BB3', 'theme' => '#2271b1', 'mu-plugin' => '#996800'][$type] ?? '#666';
144 $removed_count = count(array_filter($list, function ($i) {
145 return $i['severity'] === 'removed';
146 }));
147 $deprecated_count = count($list) - $removed_count;
148 ?>
149 <details class="phpinfowp-compat-owner">
150 <summary>
151 <span class="phpinfowp-compat-owner-type" style="background:<?php echo $type_color; ?>"><?php echo esc_html($type_label); ?></span>
152 <strong class="phpinfowp-compat-owner-name"><?php echo esc_html($name); ?></strong>
153 <span class="phpinfowp-compat-owner-counts">
154 <?php if ($removed_count): ?>
155 <span style="color:#d63638"><strong><?php echo $removed_count; ?></strong> removed</span>
156 <?php endif; ?>
157 <?php if ($deprecated_count): ?>
158 <?php if ($removed_count) echo '&middot;'; ?>
159 <span style="color:#dba617"><strong><?php echo $deprecated_count; ?></strong> deprecated</span>
160 <?php endif; ?>
161 </span>
162 </summary>
163 <div class="phpinfowp-compat-issues">
164 <?php foreach ($list as $issue): ?>
165 <div class="phpinfowp-compat-issue" style="border-left-color:<?php echo $sev_color[$issue['severity']]; ?>">
166 <div class="phpinfowp-compat-issue-head">
167 <span class="phpinfowp-compat-sev" style="background:<?php echo $sev_color[$issue['severity']]; ?>">
168 <?php echo $sev_label[$issue['severity']]; ?>
169 </span>
170 <code class="phpinfowp-compat-name"><?php echo esc_html($issue['name']); ?></code>
171 <span class="phpinfowp-compat-where"><?php echo esc_html($issue['file']); ?>:<?php echo (int)$issue['line']; ?></span>
172 </div>
173 <div class="phpinfowp-compat-issue-meta">
174 <?php if ($issue['severity'] === 'removed'): ?>
175 Removed in PHP <?php echo esc_html($issue['out']); ?> &middot;
176 <?php else: ?>
177 Deprecated in PHP <?php echo esc_html($issue['in']); ?> &middot;
178 <?php endif; ?>
179 <span class="phpinfowp-compat-fix"><?php echo esc_html($issue['fix']); ?></span>
180 </div>
181 </div>
182 <?php endforeach; ?>
183 </div>
184 </details>
185 <?php endforeach; ?>
186
187 <?php endif; ?>
188
189 <?php endif; ?>
190
191 </div>
192