Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
51 lines
1.5 KiB
PHP
51 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Integrations\Core;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
/**
|
|
* Detects the themes/plugins LIT MCP integrates with: the components it is given (Divi, wired in Plugin) first, then
|
|
* Pods and The Events Calendar.
|
|
*/
|
|
class EnvironmentProbe
|
|
{
|
|
/** @param list<EnvironmentComponent> $components Components of integrations, reported in this order. */
|
|
public function __construct(private array $components = [])
|
|
{
|
|
}
|
|
|
|
/**
|
|
* @return list<array{id: string, active: bool, version: ?string, problems: list<string>,
|
|
* release: ?array<string, mixed>}>
|
|
*/
|
|
public function components(): array
|
|
{
|
|
$tecActive = class_exists('Tribe__Events__Main');
|
|
$described = array_map(
|
|
static fn (EnvironmentComponent $component): array => $component->describe(),
|
|
$this->components
|
|
);
|
|
|
|
return [
|
|
...$described,
|
|
[
|
|
'id' => 'pods',
|
|
'active' => defined('PODS_VERSION'),
|
|
'version' => defined('PODS_VERSION') ? (string) PODS_VERSION : null,
|
|
'problems' => [],
|
|
'release' => null,
|
|
],
|
|
[
|
|
'id' => 'the-events-calendar',
|
|
'active' => $tecActive,
|
|
'version' => $tecActive ? (string) constant('Tribe__Events__Main::VERSION') : null,
|
|
'problems' => [],
|
|
'release' => null,
|
|
],
|
|
];
|
|
}
|
|
}
|