Fix fatal "TWP_Activator not found" on voicemail webhook callback

The activator class was only loaded during plugin activation, on admin_init
when the DB version differed, and in a few explicit admin handlers. Twilio
webhook callbacks (voicemail in particular, but also any non-admin caller of
TWP_Activator::force_table_updates() / ::ensure_tables_exist()) hit the public
REST endpoint where none of those load paths fire, so the static call fataled.

Load class-twp-activator.php in TWP_Core::load_dependencies() so every plugin
context — webhook, REST, cron, admin — has the class available. The activator
file is a pure class definition with no load-time side effects.

This single change covers all 9 runtime call sites (webhook, scheduler, and
six admin sites) that previously assumed the class would already be loaded.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Claude
2026-05-05 08:48:30 -07:00
parent 3407f4c705
commit bc091dd69d

View File

@@ -29,7 +29,12 @@ class TWP_Core {
private function load_dependencies() { private function load_dependencies() {
// Loader class // Loader class
require_once TWP_PLUGIN_DIR . 'includes/class-twp-loader.php'; require_once TWP_PLUGIN_DIR . 'includes/class-twp-loader.php';
// Activator (defines TWP_Activator). Loaded here so runtime callers in
// webhook/REST/cron contexts can use ::ensure_tables_exist() and
// ::force_table_updates() without each site needing its own require_once.
require_once TWP_PLUGIN_DIR . 'includes/class-twp-activator.php';
// API classes // API classes
require_once TWP_PLUGIN_DIR . 'includes/class-twp-twilio-api.php'; require_once TWP_PLUGIN_DIR . 'includes/class-twp-twilio-api.php';
require_once TWP_PLUGIN_DIR . 'includes/class-twp-elevenlabs-api.php'; require_once TWP_PLUGIN_DIR . 'includes/class-twp-elevenlabs-api.php';