Fix browser phone permission issues for phone agents

- Fixed error message display when browser phone initialization fails (now shows actual error instead of "undefined")
- Fixed ajax_get_phone_numbers to use wp_send_json_error instead of wp_die for proper error handling
- Added error handling for phone numbers loading in browser phone interface
- Updated phone_agent role to ensure all necessary capabilities are added to existing roles
- Added automatic capability updates for existing phone_agent roles on plugin load

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-08-13 10:14:20 -07:00
parent 7beb0aa4f3
commit 140a585085
2 changed files with 25 additions and 4 deletions

View File

@@ -89,8 +89,20 @@ class TWP_Core {
));
} else {
// Update existing role with any missing capabilities
if (!$role->has_cap('twp_access_phone_numbers')) {
$role->add_cap('twp_access_phone_numbers');
$capabilities = array(
'twp_access_voicemails',
'twp_access_call_log',
'twp_access_agent_queue',
'twp_access_outbound_calls',
'twp_access_sms_inbox',
'twp_access_browser_phone',
'twp_access_phone_numbers'
);
foreach ($capabilities as $cap) {
if (!$role->has_cap($cap)) {
$role->add_cap($cap);
}
}
}
}