Add default queue music setting and improve hold music fallback
## New Settings - Added "Default Queue Music URL" setting in admin settings - This setting provides fallback music for both queue waits and call hold - Hold Music URL field can now be left empty to use default queue music - Better organization of music settings with clear descriptions ## Hold Music Improvements - Hold music now falls back to default queue music if no specific hold music is set - Maintains backwards compatibility with existing hold music URLs - Provides consistent music experience across hold and queue functions ## Queue Music Enhancements - Queue wait music now uses default queue music as fallback - No more silent pauses when no queue-specific music is configured - Improved user experience with continuous music during waits ## Settings Organization - Default Queue Music is shown first as the primary setting - Hold Music field has placeholder text indicating it's optional - Clear descriptions explain the fallback behavior - Both settings properly registered in WordPress settings API This creates a more cohesive audio experience where: 1. Admin sets default queue music for system-wide use 2. Individual queues can override with their own music 3. Hold music can be customized or fall back to default 4. No more silent pauses during queue waits 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -400,13 +400,24 @@ class TWP_Admin {
|
||||
|
||||
<h2>Call Settings</h2>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th scope="row">Default Queue Music URL</th>
|
||||
<td>
|
||||
<input type="url" name="twp_default_queue_music_url"
|
||||
value="<?php echo esc_attr(get_option('twp_default_queue_music_url', 'https://api.twilio.com/cowbell.mp3')); ?>"
|
||||
class="regular-text" />
|
||||
<p class="description">Default music for queue wait times and call hold when no specific music is set. Must be publicly accessible MP3 or WAV file.</p>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th scope="row">Hold Music URL</th>
|
||||
<td>
|
||||
<input type="url" name="twp_hold_music_url"
|
||||
value="<?php echo esc_attr(get_option('twp_hold_music_url', 'https://api.twilio.com/cowbell.mp3')); ?>"
|
||||
class="regular-text" />
|
||||
<p class="description">URL to audio file to play when calls are placed on hold. Must be publicly accessible MP3 or WAV file.</p>
|
||||
value="<?php echo esc_attr(get_option('twp_hold_music_url', '')); ?>"
|
||||
class="regular-text"
|
||||
placeholder="Leave empty to use default queue music" />
|
||||
<p class="description">Specific music for when calls are placed on hold. Leave empty to use the default queue music above.</p>
|
||||
<p class="description"><strong>Suggested sources:</strong> Upload to your Media Library or use a service like Freesound.org for royalty-free music.</p>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -3019,6 +3030,7 @@ class TWP_Admin {
|
||||
register_setting('twilio-wp-settings-group', 'twp_elevenlabs_api_key');
|
||||
register_setting('twilio-wp-settings-group', 'twp_elevenlabs_voice_id');
|
||||
register_setting('twilio-wp-settings-group', 'twp_elevenlabs_model_id');
|
||||
register_setting('twilio-wp-settings-group', 'twp_default_queue_music_url');
|
||||
register_setting('twilio-wp-settings-group', 'twp_hold_music_url');
|
||||
register_setting('twilio-wp-settings-group', 'twp_default_queue_timeout');
|
||||
register_setting('twilio-wp-settings-group', 'twp_default_queue_size');
|
||||
@@ -6924,7 +6936,12 @@ class TWP_Admin {
|
||||
|
||||
if ($hold) {
|
||||
// Place call on hold with music
|
||||
$hold_music_url = get_option('twp_hold_music_url', 'https://api.twilio.com/cowbell.mp3');
|
||||
$hold_music_url = get_option('twp_hold_music_url', '');
|
||||
if (empty($hold_music_url)) {
|
||||
// Fall back to default queue music if no hold music is set
|
||||
$hold_music_url = get_option('twp_default_queue_music_url', 'https://api.twilio.com/cowbell.mp3');
|
||||
}
|
||||
|
||||
$twiml = new \Twilio\TwiML\VoiceResponse();
|
||||
$twiml->play($hold_music_url, ['loop' => 0]);
|
||||
|
||||
|
@@ -972,10 +972,16 @@ class TWP_Webhooks {
|
||||
$queue = TWP_Call_Queue::get_queue($queue_id);
|
||||
if ($queue && !empty($queue->wait_music_url)) {
|
||||
$play = $twiml->addChild('Play', $queue->wait_music_url);
|
||||
} else {
|
||||
// Fall back to default queue music if no queue-specific music is set
|
||||
$default_music_url = get_option('twp_default_queue_music_url', '');
|
||||
if (!empty($default_music_url)) {
|
||||
$play = $twiml->addChild('Play', $default_music_url);
|
||||
} else {
|
||||
$pause = $twiml->addChild('Pause');
|
||||
$pause->addAttribute('length', '30');
|
||||
}
|
||||
}
|
||||
|
||||
return $this->send_twiml_response($twiml->asXML());
|
||||
}
|
||||
@@ -995,11 +1001,17 @@ class TWP_Webhooks {
|
||||
$queue = TWP_Call_Queue::get_queue($queue_id);
|
||||
if ($queue && !empty($queue->wait_music_url)) {
|
||||
$play = $twiml->addChild('Play', $queue->wait_music_url);
|
||||
} else {
|
||||
// Fall back to default queue music if no queue-specific music is set
|
||||
$default_music_url = get_option('twp_default_queue_music_url', '');
|
||||
if (!empty($default_music_url)) {
|
||||
$play = $twiml->addChild('Play', $default_music_url);
|
||||
} else {
|
||||
// Add a pause to prevent rapid loops
|
||||
$pause = $twiml->addChild('Pause');
|
||||
$pause->addAttribute('length', '15'); // 15 second pause
|
||||
}
|
||||
}
|
||||
|
||||
// Redirect back to this same endpoint to create continuous loop
|
||||
$redirect_url = home_url('/wp-json/twilio-webhook/v1/queue-wait');
|
||||
|
Reference in New Issue
Block a user