| 1 |
<?php |
| 2 |
defined('ABSPATH') or die('Unauthorized Access'); |
| 3 |
|
| 4 |
$loaded = get_loaded_extensions(); |
| 5 |
sort($loaded, SORT_STRING | SORT_FLAG_CASE); |
| 6 |
|
| 7 |
// Extensions WordPress/WooCommerce officially requires or recommends |
| 8 |
$recommended = [ |
| 9 |
'curl', 'dom', 'exif', 'fileinfo', 'gd', 'hash', 'iconv', |
| 10 |
'imagick', 'intl', 'json', 'mbstring', 'mysqli', 'openssl', |
| 11 |
'pcre', 'pdo_mysql', 'SimpleXML', 'sodium', 'xml', 'xmlreader', 'zip', 'zlib', |
| 12 |
]; |
| 13 |
|
| 14 |
$missing = array_filter($recommended, function ($e) use ($loaded) { |
| 15 |
return !in_array($e, $loaded, true) && !in_array(strtolower($e), array_map('strtolower', $loaded), true); |
| 16 |
}); |
| 17 |
sort($missing); |
| 18 |
?> |
| 19 |
|
| 20 |
<div class="phpinfowp-ext-page"> |
| 21 |
|
| 22 |
<div class="phpinfowp-page-header"> |
| 23 |
<div> |
| 24 |
<h1><?php _e('PHP Extensions', 'phpinfo-wp'); ?></h1> |
| 25 |
<p class="phpinfowp-page-subtitle"> |
| 26 |
<strong><?php echo count($loaded); ?></strong> <?php _e('loaded', 'phpinfo-wp'); ?> |
| 27 |
<?php if ($missing): ?> · |
| 28 |
<strong style="color:#d63638"><?php echo count($missing); ?></strong> <?php _e('recommended not loaded', 'phpinfo-wp'); ?> |
| 29 |
<?php endif; ?> |
| 30 |
· PHP <?php echo esc_html(PHP_VERSION); ?> |
| 31 |
</p> |
| 32 |
</div> |
| 33 |
<div style="position:relative"> |
| 34 |
<input type="text" id="phpinfowp-ext-search" placeholder="<?php echo esc_attr__('Filter extensions…', 'phpinfo-wp'); ?>" |
| 35 |
class="regular-text" autocomplete="off" oninput="phpinfowpExtFilter(this.value)" |
| 36 |
style="padding-right:30px"> |
| 37 |
<button type="button" onclick="document.getElementById('phpinfowp-ext-search').value='';phpinfowpExtFilter('')" |
| 38 |
style="display:none;position:absolute;right:6px;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:#999;font-size:16px" |
| 39 |
id="phpinfowp-ext-clear">×</button> |
| 40 |
</div> |
| 41 |
</div> |
| 42 |
|
| 43 |
<?php if ($missing): ?> |
| 44 |
<div class="phpinfowp-ext-section" id="phpinfowp-missing-section"> |
| 45 |
<h3 class="phpinfowp-ext-heading phpinfowp-ext-heading-missing"> |
| 46 |
<span class="dashicons dashicons-warning" style="color:#d63638;vertical-align:middle;margin-right:4px"></span> |
| 47 |
<?php _e('Recommended — Not Loaded', 'phpinfo-wp'); ?> <span class="phpinfowp-ext-heading-count"><?php echo count($missing); ?></span> |
| 48 |
</h3> |
| 49 |
<div class="phpinfowp-ext-grid" id="phpinfowp-missing-grid"> |
| 50 |
<?php foreach ($missing as $ext): ?> |
| 51 |
<div class="phpinfowp-ext-item phpinfowp-ext-missing" data-name="<?php echo esc_attr(strtolower($ext)); ?>"> |
| 52 |
<span class="phpinfowp-ext-dot phpinfowp-ext-dot-missing"></span> |
| 53 |
<span class="phpinfowp-ext-name"><?php echo esc_html($ext); ?></span> |
| 54 |
</div> |
| 55 |
<?php endforeach; ?> |
| 56 |
</div> |
| 57 |
</div> |
| 58 |
<?php endif; ?> |
| 59 |
|
| 60 |
<div class="phpinfowp-ext-section"> |
| 61 |
<h3 class="phpinfowp-ext-heading phpinfowp-ext-heading-loaded"> |
| 62 |
<span class="dashicons dashicons-yes-alt" style="color:#00a32a;vertical-align:middle;margin-right:4px"></span> |
| 63 |
<?php _e('Loaded Extensions', 'phpinfo-wp'); ?> <span class="phpinfowp-ext-heading-count"><?php echo count($loaded); ?></span> |
| 64 |
</h3> |
| 65 |
<div class="phpinfowp-ext-grid" id="phpinfowp-loaded-grid"> |
| 66 |
<?php foreach ($loaded as $ext): |
| 67 |
$ver = phpversion($ext); |
| 68 |
?> |
| 69 |
<div class="phpinfowp-ext-item phpinfowp-ext-loaded" data-name="<?php echo esc_attr(strtolower($ext)); ?>"> |
| 70 |
<span class="phpinfowp-ext-dot phpinfowp-ext-dot-loaded"></span> |
| 71 |
<span class="phpinfowp-ext-name"><?php echo esc_html($ext); ?></span> |
| 72 |
<?php if ($ver && $ver !== PHP_VERSION): ?> |
| 73 |
<span class="phpinfowp-ext-ver"><?php echo esc_html($ver); ?></span> |
| 74 |
<?php endif; ?> |
| 75 |
</div> |
| 76 |
<?php endforeach; ?> |
| 77 |
</div> |
| 78 |
</div> |
| 79 |
|
| 80 |
</div> |
| 81 |
|
| 82 |
<script> |
| 83 |
function phpinfowpExtFilter(q) { |
| 84 |
q = q.toLowerCase().trim(); |
| 85 |
document.getElementById('phpinfowp-ext-clear').style.display = q ? '' : 'none'; |
| 86 |
var items = document.querySelectorAll('.phpinfowp-ext-item'); |
| 87 |
items.forEach(function(el) { |
| 88 |
el.style.display = (!q || el.dataset.name.includes(q)) ? '' : 'none'; |
| 89 |
}); |
| 90 |
['phpinfowp-missing-grid', 'phpinfowp-loaded-grid'].forEach(function(id) { |
| 91 |
var grid = document.getElementById(id); |
| 92 |
if (!grid) return; |
| 93 |
var section = grid.closest('.phpinfowp-ext-section'); |
| 94 |
var visible = grid.querySelectorAll('.phpinfowp-ext-item:not([style*="none"])').length; |
| 95 |
if (section) section.style.display = visible ? '' : 'none'; |
| 96 |
}); |
| 97 |
} |
| 98 |
</script> |