feat: add Central API clients, bot rate limiting, and admin API UI

- Add ITK_HP_API and ITK_Bot_API static classes with queue/flush/cron
- Add WP-Cron (5 min) + shutdown flush for both API queues
- Bot Blocker and Honeypot now queue events to their respective APIs
- Admin: Bot Blocker tab gains Central Bot API settings panel
  (enable, URL, token, test connection, flush queue, historical sync)
- Admin: Honeypot tab gains Central Honeypot API settings panel
- Admin JS: AJAX handlers for Test Connection and Flush Now buttons
- Admin CSS: API card styles (status badge, notices, footer controls)
- Add .gitignore (excludes bot-api/ which lives in CloudHost/bot-api)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-09 18:32:27 +02:00
parent 6d4349ff7b
commit a8d7972ad7
9 changed files with 906 additions and 8 deletions

View File

@@ -43,6 +43,64 @@
setTimeout(function () { $fb.fadeOut(400, function () { $(this).remove(); }); }, 2000);
}
/* ── API: Test connection ─────────────────────────────────── */
$(document).on('click', '.itk-btn-test-api', function () {
var $btn = $(this);
var api = $btn.data('api');
var $result = $btn.closest('form').find('.itk-api-ajax-result');
$btn.prop('disabled', true).text('Testing…');
$result.hide();
$.post(itkAdmin.ajaxUrl, {
action: 'itk_test_api',
nonce: itkAdmin.nonce,
api: api
})
.done(function (res) {
var ok = res && res.ok;
var msg = (res && res.message) ? res.message : (ok ? 'Connected.' : 'Test failed.');
$result.text(msg).css('color', ok ? '#00a32a' : '#b32d2e').show();
setTimeout(function () { $result.fadeOut(); }, 5000);
})
.fail(function () {
$result.text('Request failed.').css('color', '#b32d2e').show();
setTimeout(function () { $result.fadeOut(); }, 4000);
})
.always(function () {
$btn.prop('disabled', false).text('Test Connection');
});
});
/* ── API: Flush queue ─────────────────────────────────────── */
$(document).on('click', '.itk-btn-flush-api', function () {
var $btn = $(this);
var api = $btn.data('api');
var $result = $btn.siblings('.itk-api-flush-result');
$btn.prop('disabled', true).text('Flushing…');
$result.hide();
$.post(itkAdmin.ajaxUrl, {
action: 'itk_flush_api_queue',
nonce: itkAdmin.nonce,
api: api
})
.done(function (res) {
var ok = res && res.success;
var msg = ok ? 'Queue flushed.' : 'Flush failed.';
$result.text(msg).css('color', ok ? '#00a32a' : '#b32d2e').show();
setTimeout(function () { $result.fadeOut(); }, 3000);
})
.fail(function () {
$result.text('Request failed.').css('color', '#b32d2e').show();
setTimeout(function () { $result.fadeOut(); }, 3000);
})
.always(function () {
$btn.prop('disabled', false).text('Flush Now');
});
});
/* ── Config file editor (AJAX) ────────────────────────────── */
$('#itk-save-config').on('click', function (e) {
e.preventDefault();