| 1 |
<?php |
| 2 |
/** |
| 3 |
* MxChat Actions Page - Redesigned with Sidebar Navigation |
| 4 |
* |
| 5 |
* @package MxChat |
| 6 |
* @since 2.7.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
if (!defined('ABSPATH')) { |
| 10 |
exit; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* Render the new sidebar-based Actions page |
| 15 |
*/ |
| 16 |
function mxchat_render_actions_page($admin_instance, $page_data) { |
| 17 |
$is_activated = $admin_instance->is_activated(); |
| 18 |
$plugin_url = plugin_dir_url(dirname(__FILE__)); |
| 19 |
|
| 20 |
// Extract page data |
| 21 |
extract($page_data); |
| 22 |
?> |
| 23 |
<div class="mxch-admin-wrapper mxch-actions-wrapper"> |
| 24 |
<!-- Mobile Header --> |
| 25 |
<header class="mxch-mobile-header"> |
| 26 |
<a href="#" class="mxch-mobile-logo"> |
| 27 |
<div class="mxch-mobile-logo-icon"> |
| 28 |
<img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat"> |
| 29 |
</div> |
| 30 |
<span class="mxch-mobile-logo-text">MxChat</span> |
| 31 |
</a> |
| 32 |
<button type="button" class="mxch-mobile-menu-btn" aria-label="<?php esc_attr_e('Open menu', 'mxchat'); ?>"> |
| 33 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="1"/><circle cx="12" cy="5" r="1"/><circle cx="12" cy="19" r="1"/></svg> |
| 34 |
</button> |
| 35 |
</header> |
| 36 |
|
| 37 |
<!-- Mobile Menu Overlay --> |
| 38 |
<div class="mxch-mobile-overlay"></div> |
| 39 |
|
| 40 |
<!-- Mobile Menu Modal --> |
| 41 |
<div class="mxch-mobile-menu"> |
| 42 |
<div class="mxch-mobile-menu-header"> |
| 43 |
<span class="mxch-mobile-menu-title"><?php esc_html_e('Actions', 'mxchat'); ?></span> |
| 44 |
<button type="button" class="mxch-mobile-menu-close" aria-label="<?php esc_attr_e('Close menu', 'mxchat'); ?>"> |
| 45 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg> |
| 46 |
</button> |
| 47 |
</div> |
| 48 |
<nav class="mxch-mobile-menu-nav"> |
| 49 |
<!-- Overview Section --> |
| 50 |
<div class="mxch-mobile-nav-section"> |
| 51 |
<div class="mxch-mobile-nav-section-title"><?php esc_html_e('Overview', 'mxchat'); ?></div> |
| 52 |
<button class="mxch-mobile-nav-link active" data-target="dashboard"> |
| 53 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/></svg> |
| 54 |
<span><?php esc_html_e('Dashboard', 'mxchat'); ?></span> |
| 55 |
</button> |
| 56 |
</div> |
| 57 |
<!-- Actions Section --> |
| 58 |
<div class="mxch-mobile-nav-section"> |
| 59 |
<div class="mxch-mobile-nav-section-title"><?php esc_html_e('Manage', 'mxchat'); ?></div> |
| 60 |
<button class="mxch-mobile-nav-link" data-target="all-actions"> |
| 61 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> |
| 62 |
<span><?php esc_html_e('All Actions', 'mxchat'); ?></span> |
| 63 |
</button> |
| 64 |
</div> |
| 65 |
<?php if (!$is_activated): ?> |
| 66 |
<div class="mxch-mobile-menu-footer"> |
| 67 |
<a href="https://mxchat.ai/" target="_blank" class="mxch-mobile-upgrade-btn"> |
| 68 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9H4.5a2.5 2.5 0 0 1 0-5H6"/><path d="M18 9h1.5a2.5 2.5 0 0 0 0-5H18"/><path d="M4 22h16"/><path d="M10 14.66V17c0 .55-.47.98-.97 1.21C7.85 18.75 7 20.24 7 22"/><path d="M14 14.66V17c0 .55.47.98.97 1.21C16.15 18.75 17 20.24 17 22"/><path d="M18 2H6v7a6 6 0 0 0 12 0V2Z"/></svg> |
| 69 |
<?php esc_html_e('Upgrade to Pro', 'mxchat'); ?> |
| 70 |
</a> |
| 71 |
</div> |
| 72 |
<?php endif; ?> |
| 73 |
</nav> |
| 74 |
</div> |
| 75 |
|
| 76 |
<!-- Sidebar Navigation --> |
| 77 |
<aside class="mxch-sidebar"> |
| 78 |
<div class="mxch-sidebar-header"> |
| 79 |
<a href="#" class="mxch-sidebar-logo"> |
| 80 |
<div class="mxch-sidebar-logo-icon"> |
| 81 |
<img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat"> |
| 82 |
</div> |
| 83 |
<span class="mxch-sidebar-logo-text">MxChat</span> |
| 84 |
<span class="mxch-sidebar-version">v<?php echo esc_html(MXCHAT_VERSION ?? '2.7.0'); ?></span> |
| 85 |
</a> |
| 86 |
</div> |
| 87 |
|
| 88 |
<nav class="mxch-sidebar-nav"> |
| 89 |
<!-- Overview Section --> |
| 90 |
<div class="mxch-nav-section"> |
| 91 |
<div class="mxch-nav-section-title"><?php esc_html_e('Overview', 'mxchat'); ?></div> |
| 92 |
|
| 93 |
<div class="mxch-nav-item" data-section="dashboard"> |
| 94 |
<button class="mxch-nav-link active" data-target="dashboard"> |
| 95 |
<span class="mxch-nav-link-icon"> |
| 96 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="9"/><rect x="14" y="3" width="7" height="5"/><rect x="14" y="12" width="7" height="9"/><rect x="3" y="16" width="7" height="5"/></svg> |
| 97 |
</span> |
| 98 |
<span class="mxch-nav-link-text"><?php esc_html_e('Dashboard', 'mxchat'); ?></span> |
| 99 |
</button> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
|
| 103 |
<!-- Manage Section --> |
| 104 |
<div class="mxch-nav-section"> |
| 105 |
<div class="mxch-nav-section-title"><?php esc_html_e('Manage', 'mxchat'); ?></div> |
| 106 |
|
| 107 |
<div class="mxch-nav-item" data-section="all-actions"> |
| 108 |
<button class="mxch-nav-link" data-target="all-actions"> |
| 109 |
<span class="mxch-nav-link-icon"> |
| 110 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> |
| 111 |
</span> |
| 112 |
<span class="mxch-nav-link-text"><?php esc_html_e('All Actions', 'mxchat'); ?></span> |
| 113 |
<span class="mxch-nav-link-badge"><?php echo esc_html($total_actions); ?></span> |
| 114 |
</button> |
| 115 |
</div> |
| 116 |
</div> |
| 117 |
</nav> |
| 118 |
|
| 119 |
<?php if (!$is_activated): ?> |
| 120 |
<div class="mxch-sidebar-footer"> |
| 121 |
<a href="https://mxchat.ai/" target="_blank" class="mxch-sidebar-upgrade-v2"> |
| 122 |
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg> |
| 123 |
<?php esc_html_e('Pro Upgrade', 'mxchat'); ?> |
| 124 |
</a> |
| 125 |
</div> |
| 126 |
<?php endif; ?> |
| 127 |
</aside> |
| 128 |
|
| 129 |
<!-- Main Content Area --> |
| 130 |
<main class="mxch-content"> |
| 131 |
<!-- Dashboard Section --> |
| 132 |
<div id="dashboard" class="mxch-section active"> |
| 133 |
<div class="mxch-content-header"> |
| 134 |
<h1 class="mxch-content-title"><?php esc_html_e('Actions Dashboard', 'mxchat'); ?></h1> |
| 135 |
<p class="mxch-content-subtitle"><?php esc_html_e('Create and manage custom actions to enhance your chatbot\'s capabilities.', 'mxchat'); ?></p> |
| 136 |
</div> |
| 137 |
|
| 138 |
<!-- Quick Actions Card --> |
| 139 |
<div class="mxch-card"> |
| 140 |
<div class="mxch-card-header"> |
| 141 |
<h3 class="mxch-card-title"> |
| 142 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> |
| 143 |
<?php esc_html_e('Quick Actions', 'mxchat'); ?> |
| 144 |
</h3> |
| 145 |
</div> |
| 146 |
<div class="mxch-card-body"> |
| 147 |
<div class="mxch-quick-actions"> |
| 148 |
<button type="button" class="mxch-quick-action-btn" id="mxch-add-action-dashboard-btn"> |
| 149 |
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="16"/><line x1="8" y1="12" x2="16" y2="12"/></svg> |
| 150 |
<span><?php esc_html_e('Add New Action', 'mxchat'); ?></span> |
| 151 |
</button> |
| 152 |
<button type="button" class="mxch-quick-action-btn" data-action="view-actions"> |
| 153 |
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> |
| 154 |
<span><?php esc_html_e('View All Actions', 'mxchat'); ?></span> |
| 155 |
</button> |
| 156 |
</div> |
| 157 |
</div> |
| 158 |
</div> |
| 159 |
|
| 160 |
<!-- What are Actions - Info Section --> |
| 161 |
<div class="mxch-info-section"> |
| 162 |
<div class="mxch-info-section-header"> |
| 163 |
<div class="mxch-info-section-icon"> |
| 164 |
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg> |
| 165 |
</div> |
| 166 |
<h3 class="mxch-info-section-title"><?php esc_html_e('What are Actions?', 'mxchat'); ?></h3> |
| 167 |
</div> |
| 168 |
<p class="mxch-info-section-desc"> |
| 169 |
<?php esc_html_e('Actions let your chatbot do more than just chat. When a visitor\'s message is similar in meaning to your trigger phrase, the bot automatically performs the action - like sending emails, redirecting pages, or displaying content.', 'mxchat'); ?> |
| 170 |
</p> |
| 171 |
<div class="mxch-info-features"> |
| 172 |
<div class="mxch-info-feature"> |
| 173 |
<div class="mxch-info-feature-icon"> |
| 174 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg> |
| 175 |
</div> |
| 176 |
<div class="mxch-info-feature-content"> |
| 177 |
<span class="mxch-info-feature-title"><?php esc_html_e('Meaning-Based Matching', 'mxchat'); ?></span> |
| 178 |
<span class="mxch-info-feature-desc"><?php esc_html_e('Uses AI to understand intent, not just exact words. "I want to buy" matches "purchase" or "order"', 'mxchat'); ?></span> |
| 179 |
</div> |
| 180 |
</div> |
| 181 |
<div class="mxch-info-feature"> |
| 182 |
<div class="mxch-info-feature-icon"> |
| 183 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 20V10"/><path d="M18 20V4"/><path d="M6 20v-4"/></svg> |
| 184 |
</div> |
| 185 |
<div class="mxch-info-feature-content"> |
| 186 |
<span class="mxch-info-feature-title"><?php esc_html_e('Similarity Threshold', 'mxchat'); ?></span> |
| 187 |
<span class="mxch-info-feature-desc"><?php esc_html_e('Set how closely a message must match. Higher = more precise, Lower = more flexible', 'mxchat'); ?></span> |
| 188 |
</div> |
| 189 |
</div> |
| 190 |
<div class="mxch-info-feature"> |
| 191 |
<div class="mxch-info-feature-icon"> |
| 192 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"/><polyline points="14 2 14 8 20 8"/><path d="m9 15 2 2 4-4"/></svg> |
| 193 |
</div> |
| 194 |
<div class="mxch-info-feature-content"> |
| 195 |
<span class="mxch-info-feature-title"><?php esc_html_e('Best Practices', 'mxchat'); ?></span> |
| 196 |
<span class="mxch-info-feature-desc"><?php esc_html_e('Use natural phrases visitors would say. Make triggers distinct from each other to avoid overlap', 'mxchat'); ?></span> |
| 197 |
</div> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
</div> |
| 201 |
|
| 202 |
</div> |
| 203 |
|
| 204 |
<!-- All Actions Section - Split Panel Layout --> |
| 205 |
<div id="all-actions" class="mxch-section"> |
| 206 |
<div class="mxch-split-panel"> |
| 207 |
<!-- Left Panel - Action List --> |
| 208 |
<div class="mxch-action-list-panel"> |
| 209 |
<!-- Bulk Actions Toolbar --> |
| 210 |
<div class="mxch-bulk-toolbar"> |
| 211 |
<label class="mxch-bulk-select-all"> |
| 212 |
<input type="checkbox" id="mxch-select-all-actions"> |
| 213 |
<span><?php esc_html_e('All', 'mxchat'); ?></span> |
| 214 |
</label> |
| 215 |
<span class="mxch-selected-count" id="mxch-selected-action-count">0</span> |
| 216 |
<div class="mxch-bulk-actions"> |
| 217 |
<button type="button" class="mxch-bulk-btn mxch-bulk-delete" id="mxch-delete-selected-actions" disabled title="<?php esc_attr_e('Delete Selected', 'mxchat'); ?>"> |
| 218 |
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg> |
| 219 |
</button> |
| 220 |
</div> |
| 221 |
</div> |
| 222 |
<div class="mxch-panel-header"> |
| 223 |
<div class="mxch-search-wrapper"> |
| 224 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> |
| 225 |
<input type="text" id="mxch-search-actions" class="mxch-search-input" placeholder="<?php esc_attr_e('Search actions...', 'mxchat'); ?>"> |
| 226 |
</div> |
| 227 |
<div class="mxch-panel-title-row"> |
| 228 |
<span class="mxch-panel-count" id="mxch-action-count">0 / 0 actions</span> |
| 229 |
<div class="mxch-panel-actions"> |
| 230 |
<button type="button" id="mxch-add-action-btn" class="mxch-btn mxch-btn-primary mxch-btn-sm" title="<?php esc_attr_e('Add New Action', 'mxchat'); ?>"> |
| 231 |
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> |
| 232 |
<?php esc_html_e('Add', 'mxchat'); ?> |
| 233 |
</button> |
| 234 |
<button type="button" id="mxch-refresh-actions" class="mxch-icon-btn" title="<?php esc_attr_e('Refresh', 'mxchat'); ?>"> |
| 235 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"/><path d="M3 3v5h5"/><path d="M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16"/><path d="M16 16h5v5"/></svg> |
| 236 |
</button> |
| 237 |
</div> |
| 238 |
</div> |
| 239 |
</div> |
| 240 |
<div class="mxch-action-list" id="mxch-action-list"> |
| 241 |
<!-- Action list items loaded via AJAX --> |
| 242 |
</div> |
| 243 |
<div class="mxch-panel-footer"> |
| 244 |
<div class="mxch-pagination-simple" id="mxch-actions-pagination"> |
| 245 |
<!-- Pagination controls --> |
| 246 |
</div> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
|
| 250 |
<!-- Right Panel - Action Details/Editor --> |
| 251 |
<div class="mxch-action-detail-panel" id="mxch-action-detail-panel"> |
| 252 |
<!-- Empty State --> |
| 253 |
<div class="mxch-action-empty" id="mxch-action-empty"> |
| 254 |
<div class="mxch-empty-icon"> |
| 255 |
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2"/></svg> |
| 256 |
</div> |
| 257 |
<h3><?php esc_html_e('Select an action', 'mxchat'); ?></h3> |
| 258 |
<p><?php esc_html_e('Choose an action from the list to view details and edit, or create a new one.', 'mxchat'); ?></p> |
| 259 |
<button type="button" id="mxch-create-first-action-btn" class="mxch-btn mxch-btn-primary"> |
| 260 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg> |
| 261 |
<?php esc_html_e('Create New Action', 'mxchat'); ?> |
| 262 |
</button> |
| 263 |
</div> |
| 264 |
|
| 265 |
<!-- Action Editor (hidden initially) --> |
| 266 |
<div class="mxch-action-editor" id="mxch-action-editor" style="display: none;"> |
| 267 |
<!-- Step 1: Action Type Selection --> |
| 268 |
<div id="mxch-editor-step-1" class="mxch-editor-step active"> |
| 269 |
<div class="mxch-editor-header"> |
| 270 |
<button type="button" class="mxch-mobile-back-btn"> |
| 271 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg> |
| 272 |
<?php esc_html_e('Back', 'mxchat'); ?> |
| 273 |
</button> |
| 274 |
<h3 class="mxch-editor-title"><?php esc_html_e('Select Action Type', 'mxchat'); ?></h3> |
| 275 |
<button type="button" class="mxch-editor-close" id="mxch-close-editor"> |
| 276 |
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg> |
| 277 |
</button> |
| 278 |
</div> |
| 279 |
|
| 280 |
<div class="mxch-type-search"> |
| 281 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/></svg> |
| 282 |
<input type="text" id="mxch-type-search-input" placeholder="<?php esc_attr_e('Search action types...', 'mxchat'); ?>"> |
| 283 |
</div> |
| 284 |
|
| 285 |
<div class="mxch-type-categories"> |
| 286 |
<button type="button" class="mxch-category-btn active" data-category="all"><?php esc_html_e('All', 'mxchat'); ?></button> |
| 287 |
<?php foreach ($callback_groups as $group_label => $group_callbacks): ?> |
| 288 |
<button type="button" class="mxch-category-btn" data-category="<?php echo esc_attr(sanitize_title($group_label)); ?>"><?php echo esc_html($group_label); ?></button> |
| 289 |
<?php endforeach; ?> |
| 290 |
</div> |
| 291 |
|
| 292 |
<div class="mxch-types-grid" id="mxch-types-grid"> |
| 293 |
<?php foreach ($callback_groups as $group_label => $group_callbacks): |
| 294 |
$category_slug = sanitize_title($group_label); |
| 295 |
foreach ($group_callbacks as $function => $data): |
| 296 |
$label = $data['label']; |
| 297 |
$pro_only = $data['pro_only']; |
| 298 |
$icon = isset($data['icon']) ? $data['icon'] : 'admin-generic'; |
| 299 |
$description = isset($data['description']) ? $data['description'] : ''; |
| 300 |
$is_addon = isset($data['addon']) && $data['addon'] !== false; |
| 301 |
$addon_name = isset($data['addon_name']) ? $data['addon_name'] : ''; |
| 302 |
$is_installed = isset($data['installed']) ? $data['installed'] : true; |
| 303 |
?> |
| 304 |
<div class="mxch-type-card <?php echo (!$is_activated && $pro_only) ? 'mxch-type-pro' : ''; ?> <?php echo ($is_addon && !$is_installed) ? 'mxch-type-addon' : ''; ?>" |
| 305 |
data-category="<?php echo esc_attr($category_slug); ?>" |
| 306 |
data-value="<?php echo esc_attr($function); ?>" |
| 307 |
data-label="<?php echo esc_attr($label); ?>" |
| 308 |
data-pro="<?php echo $pro_only ? 'true' : 'false'; ?>" |
| 309 |
data-addon="<?php echo esc_attr($is_addon ? $data['addon'] : ''); ?>" |
| 310 |
data-installed="<?php echo $is_installed ? 'true' : 'false'; ?>"> |
| 311 |
<div class="mxch-type-icon"> |
| 312 |
<span class="dashicons dashicons-<?php echo esc_attr($icon); ?>"></span> |
| 313 |
</div> |
| 314 |
<div class="mxch-type-info"> |
| 315 |
<h4><?php echo esc_html($label); ?></h4> |
| 316 |
<p><?php echo esc_html($description ?: sprintf(__('Use the %s action', 'mxchat'), $label)); ?></p> |
| 317 |
<?php if ($pro_only && !$is_activated): ?> |
| 318 |
<span class="mxch-badge mxch-badge-pro"><?php esc_html_e('Pro', 'mxchat'); ?></span> |
| 319 |
<?php endif; ?> |
| 320 |
<?php if ($is_addon && !$is_installed): ?> |
| 321 |
<span class="mxch-badge mxch-badge-addon"><?php echo esc_html(sprintf(__('Requires %s', 'mxchat'), $addon_name)); ?></span> |
| 322 |
<?php endif; ?> |
| 323 |
</div> |
| 324 |
</div> |
| 325 |
<?php endforeach; endforeach; ?> |
| 326 |
</div> |
| 327 |
</div> |
| 328 |
|
| 329 |
<!-- Step 2: Action Configuration --> |
| 330 |
<div id="mxch-editor-step-2" class="mxch-editor-step"> |
| 331 |
<div class="mxch-editor-header"> |
| 332 |
<button type="button" class="mxch-back-btn" id="mxch-back-to-step-1"> |
| 333 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg> |
| 334 |
<?php esc_html_e('Back', 'mxchat'); ?> |
| 335 |
</button> |
| 336 |
<h3 class="mxch-editor-title" id="mxch-config-title"><?php esc_html_e('Configure Action', 'mxchat'); ?></h3> |
| 337 |
<button type="button" class="mxch-editor-close" id="mxch-close-editor-2"> |
| 338 |
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg> |
| 339 |
</button> |
| 340 |
</div> |
| 341 |
|
| 342 |
<div class="mxch-selected-type"> |
| 343 |
<div class="mxch-selected-type-icon" id="mxch-selected-type-icon"> |
| 344 |
<span class="dashicons dashicons-admin-generic"></span> |
| 345 |
</div> |
| 346 |
<div class="mxch-selected-type-info"> |
| 347 |
<h4 id="mxch-selected-type-label"><?php esc_html_e('Selected Action', 'mxchat'); ?></h4> |
| 348 |
<p id="mxch-selected-type-desc"><?php esc_html_e('Configure this action for your chatbot', 'mxchat'); ?></p> |
| 349 |
</div> |
| 350 |
</div> |
| 351 |
|
| 352 |
<form id="mxch-action-form" method="post"> |
| 353 |
<?php wp_nonce_field('mxchat_add_intent_nonce', 'mxch_action_nonce'); ?> |
| 354 |
<input type="hidden" name="action_id" id="mxch-action-id" value=""> |
| 355 |
<input type="hidden" name="callback_function" id="mxch-callback-function" value=""> |
| 356 |
<input type="hidden" name="form_mode" id="mxch-form-mode" value="add"> |
| 357 |
|
| 358 |
<div class="mxch-form-group"> |
| 359 |
<label for="mxch-action-label"><?php esc_html_e('Action Label', 'mxchat'); ?></label> |
| 360 |
<input type="text" id="mxch-action-label" name="intent_label" required placeholder="<?php esc_attr_e('e.g., Newsletter Signup', 'mxchat'); ?>"> |
| 361 |
<p class="mxch-form-hint"><?php esc_html_e('A descriptive name for this action (for your reference only).', 'mxchat'); ?></p> |
| 362 |
</div> |
| 363 |
|
| 364 |
<div class="mxch-form-group"> |
| 365 |
<label for="mxch-action-phrases"><?php esc_html_e('Trigger Phrases', 'mxchat'); ?></label> |
| 366 |
<textarea id="mxch-action-phrases" name="phrases" rows="4" required placeholder="<?php esc_attr_e('sign me up, subscribe me, I want to join, add me to the newsletter', 'mxchat'); ?>"></textarea> |
| 367 |
<p class="mxch-form-hint"><?php esc_html_e('Comma-separated phrases that will trigger this action.', 'mxchat'); ?></p> |
| 368 |
</div> |
| 369 |
|
| 370 |
<div class="mxch-form-group"> |
| 371 |
<label for="mxch-action-threshold"> |
| 372 |
<?php esc_html_e('Similarity Threshold', 'mxchat'); ?> |
| 373 |
<span class="mxch-threshold-value" id="mxch-threshold-value">85%</span> |
| 374 |
</label> |
| 375 |
<input type="range" id="mxch-action-threshold" name="similarity_threshold" min="10" max="95" value="85"> |
| 376 |
<p class="mxch-form-hint"><?php esc_html_e('Lower values (10-30) trigger more easily. Higher values (70-95) require more exact matches.', 'mxchat'); ?></p> |
| 377 |
</div> |
| 378 |
|
| 379 |
<div class="mxch-form-group"> |
| 380 |
<label><?php esc_html_e('Enabled Bots', 'mxchat'); ?></label> |
| 381 |
<div class="mxch-bot-selector" id="mxch-bot-selector"> |
| 382 |
<label class="mxch-checkbox-label"> |
| 383 |
<input type="checkbox" name="enabled_bots[]" value="default" checked> |
| 384 |
<span class="mxch-checkmark"></span> |
| 385 |
<?php esc_html_e('Default Bot', 'mxchat'); ?> |
| 386 |
</label> |
| 387 |
<?php if (class_exists('MxChat_Multi_Bot_Core_Manager')): |
| 388 |
$multi_bot_manager = MxChat_Multi_Bot_Core_Manager::get_instance(); |
| 389 |
$available_bots_list = $multi_bot_manager->get_available_bots(); |
| 390 |
foreach ($available_bots_list as $bot_id => $bot_name): |
| 391 |
if ($bot_id === 'default') continue; |
| 392 |
?> |
| 393 |
<label class="mxch-checkbox-label"> |
| 394 |
<input type="checkbox" name="enabled_bots[]" value="<?php echo esc_attr($bot_id); ?>"> |
| 395 |
<span class="mxch-checkmark"></span> |
| 396 |
<?php echo esc_html($bot_name); ?> |
| 397 |
</label> |
| 398 |
<?php endforeach; endif; ?> |
| 399 |
</div> |
| 400 |
</div> |
| 401 |
|
| 402 |
<div class="mxch-form-actions"> |
| 403 |
<button type="button" class="mxch-btn mxch-btn-secondary" id="mxch-cancel-action"> |
| 404 |
<?php esc_html_e('Cancel', 'mxchat'); ?> |
| 405 |
</button> |
| 406 |
<button type="submit" class="mxch-btn mxch-btn-primary" id="mxch-save-action"> |
| 407 |
<?php esc_html_e('Save Action', 'mxchat'); ?> |
| 408 |
</button> |
| 409 |
</div> |
| 410 |
</form> |
| 411 |
</div> |
| 412 |
|
| 413 |
<!-- Action View (for viewing existing action details) --> |
| 414 |
<div id="mxch-action-view" class="mxch-editor-step"> |
| 415 |
<div class="mxch-editor-header"> |
| 416 |
<button type="button" class="mxch-mobile-back-btn"> |
| 417 |
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="19" y1="12" x2="5" y2="12"/><polyline points="12 19 5 12 12 5"/></svg> |
| 418 |
<?php esc_html_e('Back', 'mxchat'); ?> |
| 419 |
</button> |
| 420 |
<h3 class="mxch-editor-title" id="mxch-view-title"><?php esc_html_e('Action Details', 'mxchat'); ?></h3> |
| 421 |
<div class="mxch-header-actions"> |
| 422 |
<label class="mxch-toggle-switch" title="<?php esc_attr_e('Toggle Enabled', 'mxchat'); ?>"> |
| 423 |
<input type="checkbox" id="mxch-action-enabled-toggle" checked> |
| 424 |
<span class="mxch-toggle-slider"></span> |
| 425 |
</label> |
| 426 |
<button type="button" class="mxch-icon-btn" id="mxch-edit-action-btn" title="<?php esc_attr_e('Edit', 'mxchat'); ?>"> |
| 427 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"/><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"/></svg> |
| 428 |
</button> |
| 429 |
<button type="button" class="mxch-icon-btn mxch-btn-danger-icon" id="mxch-delete-action-btn" title="<?php esc_attr_e('Delete', 'mxchat'); ?>"> |
| 430 |
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/></svg> |
| 431 |
</button> |
| 432 |
</div> |
| 433 |
</div> |
| 434 |
|
| 435 |
<div class="mxch-action-details"> |
| 436 |
<div class="mxch-detail-card"> |
| 437 |
<div class="mxch-detail-icon" id="mxch-view-icon"> |
| 438 |
<span class="dashicons dashicons-admin-generic"></span> |
| 439 |
</div> |
| 440 |
<div class="mxch-detail-content"> |
| 441 |
<h4 id="mxch-view-label"><?php esc_html_e('Action Label', 'mxchat'); ?></h4> |
| 442 |
<p class="mxch-detail-type" id="mxch-view-type"><?php esc_html_e('Action Type', 'mxchat'); ?></p> |
| 443 |
</div> |
| 444 |
</div> |
| 445 |
|
| 446 |
<div class="mxch-detail-section"> |
| 447 |
<h5><?php esc_html_e('Trigger Phrases', 'mxchat'); ?></h5> |
| 448 |
<div class="mxch-phrases-list" id="mxch-view-phrases"> |
| 449 |
<!-- Phrases loaded dynamically --> |
| 450 |
</div> |
| 451 |
</div> |
| 452 |
|
| 453 |
<div class="mxch-detail-section"> |
| 454 |
<h5><?php esc_html_e('Settings', 'mxchat'); ?></h5> |
| 455 |
<div class="mxch-settings-grid"> |
| 456 |
<div class="mxch-setting-item"> |
| 457 |
<span class="mxch-setting-label"><?php esc_html_e('Similarity Threshold', 'mxchat'); ?></span> |
| 458 |
<span class="mxch-setting-value" id="mxch-view-threshold">85%</span> |
| 459 |
</div> |
| 460 |
<div class="mxch-setting-item"> |
| 461 |
<span class="mxch-setting-label"><?php esc_html_e('Status', 'mxchat'); ?></span> |
| 462 |
<span class="mxch-setting-value mxch-status-badge" id="mxch-view-status"><?php esc_html_e('Enabled', 'mxchat'); ?></span> |
| 463 |
</div> |
| 464 |
</div> |
| 465 |
</div> |
| 466 |
|
| 467 |
<div class="mxch-detail-section"> |
| 468 |
<h5><?php esc_html_e('Assigned Bots', 'mxchat'); ?></h5> |
| 469 |
<div class="mxch-bots-list" id="mxch-view-bots"> |
| 470 |
<!-- Bots loaded dynamically --> |
| 471 |
</div> |
| 472 |
</div> |
| 473 |
</div> |
| 474 |
</div> |
| 475 |
</div> |
| 476 |
</div> |
| 477 |
</div> |
| 478 |
</div> |
| 479 |
</main> |
| 480 |
</div> |
| 481 |
|
| 482 |
<!-- Loading Overlay --> |
| 483 |
<div id="mxch-action-loading" class="mxch-loading-overlay" style="display: none;"> |
| 484 |
<div class="mxch-loading-spinner"></div> |
| 485 |
<div class="mxch-loading-text"><?php esc_html_e('Saving action, please wait...', 'mxchat'); ?></div> |
| 486 |
</div> |
| 487 |
|
| 488 |
<!-- Delete Confirmation Modal --> |
| 489 |
<div id="mxch-delete-modal" class="mxch-modal-overlay" style="display: none;"> |
| 490 |
<div class="mxch-modal-content mxch-modal-sm"> |
| 491 |
<div class="mxch-modal-header"> |
| 492 |
<h2><?php esc_html_e('Delete Action', 'mxchat'); ?></h2> |
| 493 |
<button type="button" class="mxch-modal-close">×</button> |
| 494 |
</div> |
| 495 |
<div class="mxch-modal-body"> |
| 496 |
<p><?php esc_html_e('Are you sure you want to delete this action? This cannot be undone.', 'mxchat'); ?></p> |
| 497 |
</div> |
| 498 |
<div class="mxch-modal-footer"> |
| 499 |
<button type="button" class="mxch-btn mxch-btn-secondary" id="mxch-cancel-delete"><?php esc_html_e('Cancel', 'mxchat'); ?></button> |
| 500 |
<button type="button" class="mxch-btn mxch-btn-danger" id="mxch-confirm-delete"><?php esc_html_e('Delete', 'mxchat'); ?></button> |
| 501 |
</div> |
| 502 |
</div> |
| 503 |
</div> |
| 504 |
|
| 505 |
<?php |
| 506 |
} |
| 507 |
|