Add SDK persistence and configurable edge location
All checks were successful
Create Release / build (push) Successful in 4s

- Add external SDK installation (wp-content/twilio-sdk/) that survives
  WordPress plugin updates
- Add install-twilio-sdk-external.sh script for external SDK setup
- Update SDK loading to check external location first, internal fallback
- Add post-update detection hook to warn if SDK was deleted
- Add configurable Twilio Edge Location setting (default: roaming)
- Fix US calls failing due to hardcoded Sydney edge location

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-23 18:03:38 -08:00
parent f0806d7e67
commit 3e4dff5c4e
7 changed files with 392 additions and 26 deletions

View File

@@ -41,13 +41,28 @@ class TWP_Twilio_API {
* Initialize Twilio SDK client
*/
private function init_sdk_client() {
// Check if autoloader exists
$autoloader_path = TWP_PLUGIN_DIR . 'vendor/autoload.php';
if (!file_exists($autoloader_path)) {
error_log('TWP Plugin: Autoloader not found at: ' . $autoloader_path);
throw new Exception('Twilio SDK not found. Please run: ./install-twilio-sdk.sh');
// Check for SDK autoloader - external location first (survives plugin updates)
$autoloader_path = null;
// Priority 1: External SDK location (recommended)
$external_autoloader = TWP_EXTERNAL_SDK_DIR . 'autoload.php';
if (file_exists($external_autoloader)) {
$autoloader_path = $external_autoloader;
}
// Priority 2: Internal vendor directory (fallback)
if (!$autoloader_path) {
$internal_autoloader = TWP_PLUGIN_DIR . 'vendor/autoload.php';
if (file_exists($internal_autoloader)) {
$autoloader_path = $internal_autoloader;
}
}
if (!$autoloader_path) {
error_log('TWP Plugin: Autoloader not found. Checked: ' . $external_autoloader . ' and ' . TWP_PLUGIN_DIR . 'vendor/autoload.php');
throw new Exception('Twilio SDK not found. Please run: ./install-twilio-sdk-external.sh');
}
// Load the autoloader
require_once $autoloader_path;

View File

@@ -9,9 +9,25 @@ class TWP_Webhooks {
*/
public function __construct() {
// Load Twilio SDK if not already loaded
// Check external location first (survives plugin updates), then internal
if (!class_exists('\Twilio\Rest\Client')) {
$autoloader_path = plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php';
if (file_exists($autoloader_path)) {
$autoloader_path = null;
// Priority 1: External SDK location
$external_autoloader = dirname(dirname(plugin_dir_path(dirname(__FILE__)))) . '/twilio-sdk/autoload.php';
if (file_exists($external_autoloader)) {
$autoloader_path = $external_autoloader;
}
// Priority 2: Internal vendor directory
if (!$autoloader_path) {
$internal_autoloader = plugin_dir_path(dirname(__FILE__)) . 'vendor/autoload.php';
if (file_exists($internal_autoloader)) {
$autoloader_path = $internal_autoloader;
}
}
if ($autoloader_path) {
require_once $autoloader_path;
}
}