Twilio WordPress Plugin - SDK Required
The Twilio PHP SDK is required for this plugin to work.
Recommended: Install SDK to external location (survives plugin updates):
chmod +x install-twilio-sdk-external.sh && ./install-twilio-sdk-external.sh
Alternative: Install SDK inside plugin folder:
chmod +x install-twilio-sdk.sh && ./install-twilio-sdk.sh
Plugin path:
External SDK path:
60, // Every 60 seconds
'display' => esc_html__('Every Minute (TWP)', 'twilio-wp-plugin')
);
return $schedules;
}
/**
* Plugin deactivation hook
*/
function twp_deactivate() {
require_once TWP_PLUGIN_DIR . 'includes/class-twp-deactivator.php';
TWP_Deactivator::deactivate();
}
register_activation_hook(__FILE__, 'twp_activate');
register_deactivation_hook(__FILE__, 'twp_deactivate');
/**
* Check SDK status after plugin updates
* Shows warning if SDK was deleted during update and external SDK not available
*/
function twp_check_sdk_after_update($upgrader_object, $options) {
// Only run for plugin updates
if ($options['action'] !== 'update' || $options['type'] !== 'plugin') {
return;
}
// Check if this plugin was updated
$updated_plugins = isset($options['plugins']) ? $options['plugins'] : array();
if (!in_array(TWP_PLUGIN_BASENAME, $updated_plugins)) {
return;
}
// Check if SDK is available
$external_sdk = file_exists(TWP_EXTERNAL_SDK_DIR . 'autoload.php');
$internal_sdk = file_exists(TWP_PLUGIN_DIR . 'vendor/autoload.php');
if (!$external_sdk && !$internal_sdk) {
// Set a transient to show warning on next admin page load
set_transient('twp_sdk_update_warning', true, 60 * 5);
}
}
add_action('upgrader_process_complete', 'twp_check_sdk_after_update', 10, 2);
/**
* Show SDK update warning
*/
function twp_show_sdk_update_warning() {
if (get_transient('twp_sdk_update_warning')) {
delete_transient('twp_sdk_update_warning');
?>
Twilio WordPress Plugin - SDK Reinstall Required
The plugin was updated and the Twilio SDK needs to be reinstalled.
To prevent this in the future, install the SDK to the external location:
cd && ./install-twilio-sdk-external.sh
The external SDK at survives plugin updates.
run();
}
run_twilio_wp_plugin();