| 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 |
|