- Created TWP_Shortcodes class with [twp_browser_phone] shortcode - Mobile-first responsive CSS design with touch-friendly interface - Frontend JavaScript integration with Twilio Voice SDK v2 - Permission checks for logged-in users with twp_access_browser_phone capability - Haptic feedback and dark mode support - Configurable shortcode parameters (title, show_title, compact) - Updated plugin version to 2.1.0 in main file - Added comprehensive documentation to README.md Features: - Visual dialpad with DTMF support - Real-time connection status indicators - Call timer and queue management - Auto-scaling for mobile devices (320px+) - Optimized for both desktop and mobile use 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
109 lines
3.1 KiB
PHP
109 lines
3.1 KiB
PHP
<?php
|
|
/**
|
|
* Plugin Name: Twilio WP Plugin
|
|
* Plugin URI: https://repo.anhonesthost.net/wp-plugins/twilio-wp-plugin
|
|
* Description: WordPress plugin for Twilio integration with phone scheduling, call forwarding, queue management, and Eleven Labs TTS
|
|
* Version: 2.1.0
|
|
* Author: Josh Knapp
|
|
* License: GPL v2 or later
|
|
* Text Domain: twilio-wp-plugin
|
|
*/
|
|
|
|
// If this file is called directly, abort.
|
|
if (!defined('WPINC')) {
|
|
die;
|
|
}
|
|
|
|
// Plugin constants
|
|
define('TWP_VERSION', '2.1.0');
|
|
define('TWP_DB_VERSION', '1.1.0'); // Track database version separately
|
|
define('TWP_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
|
define('TWP_PLUGIN_URL', plugin_dir_url(__FILE__));
|
|
define('TWP_PLUGIN_BASENAME', plugin_basename(__FILE__));
|
|
|
|
/**
|
|
* Plugin activation hook
|
|
*/
|
|
function twp_activate() {
|
|
require_once TWP_PLUGIN_DIR . 'includes/class-twp-activator.php';
|
|
TWP_Activator::activate();
|
|
}
|
|
|
|
/**
|
|
* Check if Twilio SDK is installed and show admin notice if not
|
|
*/
|
|
function twp_check_sdk_installation() {
|
|
$autoloader_path = TWP_PLUGIN_DIR . 'vendor/autoload.php';
|
|
$sdk_installed = false;
|
|
|
|
if (file_exists($autoloader_path)) {
|
|
// Try to load autoloader and check for classes
|
|
require_once $autoloader_path;
|
|
$sdk_installed = class_exists('Twilio\Rest\Client');
|
|
}
|
|
|
|
if (!$sdk_installed) {
|
|
add_action('admin_notices', 'twp_sdk_missing_notice');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Display admin notice for missing SDK
|
|
*/
|
|
function twp_sdk_missing_notice() {
|
|
?>
|
|
<div class="notice notice-error is-dismissible">
|
|
<h3>Twilio WordPress Plugin - SDK Required</h3>
|
|
<p><strong>The Twilio PHP SDK is required for this plugin to work.</strong></p>
|
|
<p>To install the SDK, run this command in your plugin directory:</p>
|
|
<code>chmod +x install-twilio-sdk.sh && ./install-twilio-sdk.sh</code>
|
|
<p>Or install via Composer: <code>composer install</code></p>
|
|
<p><em>Plugin path: <?php echo TWP_PLUGIN_DIR; ?></em></p>
|
|
</div>
|
|
<?php
|
|
}
|
|
|
|
// Check SDK installation and database updates on admin pages
|
|
if (is_admin()) {
|
|
add_action('admin_init', 'twp_check_sdk_installation');
|
|
add_action('admin_init', 'twp_check_database_updates');
|
|
}
|
|
|
|
/**
|
|
* Check and perform database updates if needed
|
|
*/
|
|
function twp_check_database_updates() {
|
|
$current_db_version = get_option('twp_db_version', '1.0.0');
|
|
|
|
if (version_compare($current_db_version, TWP_DB_VERSION, '<')) {
|
|
require_once TWP_PLUGIN_DIR . 'includes/class-twp-activator.php';
|
|
TWP_Activator::ensure_tables_exist();
|
|
update_option('twp_db_version', TWP_DB_VERSION);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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');
|
|
|
|
/**
|
|
* Core plugin class
|
|
*/
|
|
require plugin_dir_path(__FILE__) . 'includes/class-twp-core.php';
|
|
|
|
/**
|
|
* Begin execution of the plugin
|
|
*/
|
|
function run_twilio_wp_plugin() {
|
|
$plugin = new TWP_Core();
|
|
$plugin->run();
|
|
}
|
|
|
|
run_twilio_wp_plugin();
|