PluginProbe
404 Solution / trunk
404 Solution vtrunk
4.3.5 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.2.0 4.1.19 4.1.18 4.1.17 4.1.16 4.1.15 4.1.13 4.1.12 4.1.11 4.1.10 4.1.9 4.1.8 4.1.7 4.1.6 4.1.5 4.1.4 4.1.3 trunk 2.30.0 All 109 releases
404-solution / includes / feedback / FeedbackWordPressInventory.php

FeedbackWordPressInventory.php in 404 Solution trunk, at includes/feedback/FeedbackWordPressInventory.php

65 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if (!defined('ABSPATH')) {
4 exit;
5 }
6
7 /**
8 * Collects WordPress inventory fields for feedback payloads.
9 */
10 class ABJ_404_Solution_FeedbackWordPressInventory {
11
12 /**
13 * @param mixed $wpdb
14 * @return string
15 */
16 public function tablePrefix($wpdb): string {
17 if (isset($wpdb) && is_object($wpdb) && isset($wpdb->prefix) && is_string($wpdb->prefix)) {
18 return $wpdb->prefix;
19 }
20 return '';
21 }
22
23 public function objectCacheStatus(): string {
24 return (function_exists('wp_using_ext_object_cache') && wp_using_ext_object_cache()) ? 'external' : 'default';
25 }
26
27 /**
28 * @return array<int, string>
29 */
30 public function activePlugins(): array {
31 if (!function_exists('get_option')) {
32 return array();
33 }
34 $list = get_option('active_plugins', array());
35 if (!is_array($list)) {
36 return array();
37 }
38 $out = array();
39 foreach ($list as $entry) {
40 if (is_string($entry)) {
41 $out[] = $entry;
42 }
43 }
44 return $out;
45 }
46
47 public function activeTheme(): string {
48 if (!function_exists('wp_get_theme')) {
49 return '';
50 }
51 $theme = wp_get_theme();
52 if (!is_object($theme) || !method_exists($theme, 'get')) {
53 return '';
54 }
55 $rawName = $theme->get('Name');
56 $rawVer = $theme->get('Version');
57 $name = is_string($rawName) ? trim($rawName) : '';
58 $version = is_string($rawVer) ? trim($rawVer) : '';
59 if ($name === '' && $version === '') {
60 return '';
61 }
62 return $version === '' ? $name : trim($name . ' ' . $version);
63 }
64 }
65