2a2844af6f
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Q8t9GEyyLZbUQu26na1JQg
49 lines
2.2 KiB
PHP
49 lines
2.2 KiB
PHP
<?php
|
|
/**
|
|
* Batch 56 — Kirki customizer framework tools. Net-new, GPL-2.0-or-later. See NOTICE.md.
|
|
* Inert unless Kirki (KIRKI_VERSION) is active.
|
|
*/
|
|
|
|
namespace AskTamMCP\Extensions;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
class Batch56 {
|
|
|
|
public static function register($registry): void {
|
|
if (!defined('KIRKI_VERSION')) return;
|
|
|
|
$def = function (string $name, string $desc, array $props, array $required, string $scope, string $method) {
|
|
$schema = ['type' => 'object', 'properties' => $props ?: new \stdClass()];
|
|
if ($required) $schema['required'] = $required;
|
|
return ['name' => $name, 'description' => $desc, 'scope' => $scope,
|
|
'handler' => 'AskTamMCP\\Extensions\\Batch56::' . $method, 'inputSchema' => $schema];
|
|
};
|
|
|
|
$registry->register($def('kirki_detect', 'Report whether Kirki is active and its version.', [], [], 'read', 'detect'));
|
|
$registry->register($def('kirki_list_fields', 'List Kirki-registered customizer fields (id, type, section) where the framework exposes them.',
|
|
['per_page' => ['type' => 'integer', 'default' => 200]], [], 'read', 'listFields'));
|
|
}
|
|
|
|
public static function detect(array $args): array {
|
|
return ['active' => defined('KIRKI_VERSION'), 'version' => defined('KIRKI_VERSION') ? KIRKI_VERSION : null];
|
|
}
|
|
|
|
public static function listFields(array $args): array {
|
|
$fields = [];
|
|
if (class_exists('Kirki') && isset(\Kirki::$all_fields) && is_array(\Kirki::$all_fields)) {
|
|
$fields = \Kirki::$all_fields;
|
|
} elseif (class_exists('Kirki\\Compatibility\\Kirki') && isset(\Kirki\Compatibility\Kirki::$all_fields)) {
|
|
$fields = \Kirki\Compatibility\Kirki::$all_fields;
|
|
} else {
|
|
return ['supported' => false, 'note' => 'Kirki field registry not accessible on this version.', 'fields' => []];
|
|
}
|
|
$per = max(1, (int) ($args['per_page'] ?? 200));
|
|
$out = [];
|
|
foreach (array_slice((array) $fields, 0, $per) as $f) {
|
|
$out[] = ['id' => $f['settings'] ?? ($f['id'] ?? ''), 'type' => $f['type'] ?? '', 'section' => $f['section'] ?? ''];
|
|
}
|
|
return ['supported' => true, 'count' => count($out), 'fields' => $out];
|
|
}
|
|
}
|