testing progress

This commit is contained in:
2025-08-12 10:36:32 -07:00
parent 1633eb46df
commit f6429110e5
3 changed files with 22 additions and 14 deletions

View File

@@ -31,6 +31,14 @@ class TWP_Admin {
return;
}
// Determine first available page for agents
$first_page = 'twilio-wp-browser-phone'; // Default to browser phone
if (current_user_can('twp_access_voicemails')) $first_page = 'twilio-wp-voicemails';
elseif (current_user_can('twp_access_call_log')) $first_page = 'twilio-wp-call-logs';
elseif (current_user_can('twp_access_agent_queue')) $first_page = 'twilio-wp-agent-queue';
elseif (current_user_can('twp_access_sms_inbox')) $first_page = 'twilio-wp-sms-inbox';
elseif (current_user_can('twp_access_browser_phone')) $first_page = 'twilio-wp-browser-phone';
// Main menu - show dashboard for admins, redirect to first available page for agents
if (current_user_can('manage_options')) {
add_menu_page(
@@ -52,14 +60,6 @@ class TWP_Admin {
array($this, 'display_plugin_dashboard')
);
} else {
// For agents, determine first available page
$first_page = 'twilio-wp-browser-phone'; // Default to browser phone
if (current_user_can('twp_access_voicemails')) $first_page = 'twilio-wp-voicemails';
elseif (current_user_can('twp_access_call_log')) $first_page = 'twilio-wp-call-logs';
elseif (current_user_can('twp_access_agent_queue')) $first_page = 'twilio-wp-agent-queue';
elseif (current_user_can('twp_access_sms_inbox')) $first_page = 'twilio-wp-sms-inbox';
elseif (current_user_can('twp_access_browser_phone')) $first_page = 'twilio-wp-browser-phone';
add_menu_page(
'Twilio Phone',
'Twilio Phone',
@@ -129,7 +129,7 @@ class TWP_Admin {
}
// Agent-accessible pages
$menu_parent = current_user_can('manage_options') ? 'twilio-wp-plugin' : null;
$menu_parent = current_user_can('manage_options') ? 'twilio-wp-plugin' : $first_page;
if (current_user_can('manage_options') || current_user_can('twp_access_voicemails')) {
add_submenu_page(
@@ -2999,7 +2999,7 @@ class TWP_Admin {
public function ajax_get_phone_numbers() {
check_ajax_referer('twp_ajax_nonce', 'nonce');
if (!current_user_can('manage_options')) {
if (!current_user_can('manage_options') && !current_user_can('twp_access_phone_numbers')) {
wp_die('Unauthorized');
}
@@ -4026,7 +4026,7 @@ class TWP_Admin {
public function ajax_generate_capability_token() {
check_ajax_referer('twp_ajax_nonce', 'nonce');
if (!current_user_can('manage_options')) {
if (!current_user_can('manage_options') && !current_user_can('twp_access_browser_phone')) {
wp_send_json_error('Insufficient permissions');
}
@@ -5246,7 +5246,7 @@ class TWP_Admin {
</div>
</div>
<?php if (!$smart_routing_configured): ?>
<?php if (!$smart_routing_configured && current_user_can('manage_options')): ?>
<div class="setup-info">
<h4>📋 Setup Required</h4>
<p>To enable mode switching, update your phone number webhook to:</p>