add_action('rest_api_init', function () {
register_rest_route('patch/v1', '/diagnostics', [
'methods' => 'GET',
'callback' => 'patch_site_diagnostics',
'permission_callback' => '__return_true'
]);
});
function patch_site_diagnostics() {
$active_plugins = get_option('active_plugins');
$plugins = array_map(function($plugin) {
$plugin_path = WP_PLUGIN_DIR . '/' . $plugin;
if (file_exists($plugin_path)) {
$data = get_plugin_data($plugin_path);
return [
'Name' => $data['Name'],
'Version' => $data['Version'],
'Author' => $data['Author'],
];
}
return [
'Name' => $plugin,
'Version' => 'Unknown',
'Author' => 'Unknown',
];
}, $active_plugins);
$theme = wp_get_theme();
return [
// Site Info
'site_url' => get_site_url(),
'site_title' => get_bloginfo('name'),
'site_description' => get_bloginfo('description'),
'site_language' => get_locale(),
'site_charset' => get_bloginfo('charset'),
'site_timezone' => get_option('timezone_string'),
'ssl_enabled' => is_ssl() ? 'Yes' : 'No',
'wp_version' => get_bloginfo('version'),
'php_version' => phpversion(),
'memory_limit' => ini_get('memory_limit'),
'server_software' => $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown',
'debug_mode' => (defined('WP_DEBUG') && WP_DEBUG) ? 'On' : 'Off',
// Theme Info
'theme' => [
'Name' => $theme->get('Name'),
'Version' => $theme->get('Version'),
'Parent' => $theme->parent() ? $theme->parent()->get('Name') : 'None',
'Template' => get_option('template'),
'Stylesheet' => get_option('stylesheet'),
],
// Plugin Info
'active_plugin_count' => count($active_plugins),
'plugins' => $plugins,
// SEO
'seo_plugin' => in_array('wordpress-seo/wp-seo.php', $active_plugins) ? '_
Skip to content