PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 3.2.25
MxChat – AI Chatbot & Content Generation for WordPress v3.2.25
3.2.25 3.2.24 3.2.23 3.2.22 3.2.21 3.2.20 3.2.19 3.2.18 3.2.17 3.2.16 3.2.15 3.2.14 3.2.12 3.2.13 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 3.2.6 3.2.5 3.2.4 3.2.3 3.2.2 3.2.1 All 156 releases
mxchat-basic / includes / admin-pro-page.php

admin-pro-page.php in MxChat – AI Chatbot & Content Generation for WordPress 3.2.25, at includes/admin-pro-page.php

474 lines 32.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MxChat Pro & Extensions Page - Consolidated 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 consolidated Pro & Extensions page
15 */
16 function mxchat_render_pro_page($admin_instance, $addons_config) {
17 $is_activated = $admin_instance->is_activated();
18 $plugin_url = plugin_dir_url(dirname(__FILE__));
19
20 // License data
21 $license_status = get_option('mxchat_license_status', 'inactive');
22 $license_email = get_option('mxchat_pro_email', '');
23 $license_key = get_option('mxchat_activation_key', '');
24 $current_domain = parse_url(home_url(), PHP_URL_HOST);
25 $is_domain_linked = $admin_instance->is_current_activation_linked($current_domain);
26 $license_management_url = 'https://mxchat.ai/my-account/licenses/';
27
28 // Licence domain check (c93ede): what mxchat.ai last said about this domain,
29 // and whether Pro is paused because the licence holder switched it off.
30 $has_license_check = class_exists('MxChat_License_Check');
31 $license_check = $has_license_check ? MxChat_License_Check::view_model() : null;
32 $license_revoked = $has_license_check && MxChat_License_Check::is_revoked();
33
34 // Mask the license key for display
35 $masked_key = '';
36 if (!empty($license_key)) {
37 $masked_key = str_repeat('•', max(0, strlen($license_key) - 4)) . substr($license_key, -4);
38 }
39
40 // Count addon statuses
41 $active_count = 0;
42 $installed_count = 0;
43 foreach ($addons_config as $slug => $addon) {
44 $status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']);
45 if ($status['status'] === 'active') {
46 $active_count++;
47 $installed_count++;
48 } elseif ($status['status'] === 'inactive') {
49 $installed_count++;
50 }
51 }
52 ?>
53 <div class="mxch-admin-wrapper mxch-pro-wrapper">
54 <!-- Mobile Header -->
55 <header class="mxch-mobile-header">
56 <a href="#" class="mxch-mobile-logo">
57 <div class="mxch-mobile-logo-icon">
58 <img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat">
59 </div>
60 <span class="mxch-mobile-logo-text">MxChat</span>
61 </a>
62 <button type="button" class="mxch-mobile-menu-btn" aria-label="<?php esc_attr_e('Open menu', 'mxchat'); ?>">
63 <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>
64 </button>
65 </header>
66
67 <!-- Mobile Menu Overlay -->
68 <div class="mxch-mobile-overlay"></div>
69
70 <!-- Mobile Menu Modal -->
71 <div class="mxch-mobile-menu">
72 <div class="mxch-mobile-menu-header">
73 <span class="mxch-mobile-menu-title"><?php esc_html_e('Pro & Extensions', 'mxchat'); ?></span>
74 <button type="button" class="mxch-mobile-menu-close" aria-label="<?php esc_attr_e('Close menu', 'mxchat'); ?>">
75 <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>
76 </button>
77 </div>
78 <nav class="mxch-mobile-menu-nav">
79 <!-- License Status (Mobile) -->
80 <div class="mxch-mobile-nav-section">
81 <div class="mxch-mobile-nav-section-title"><?php esc_html_e('License', 'mxchat'); ?></div>
82 <div class="mxch-mobile-license-status">
83 <span class="mxch-license-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>">
84 <?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?>
85 </span>
86 </div>
87 </div>
88
89 <!-- Extensions Section (Mobile) -->
90 <div class="mxch-mobile-nav-section">
91 <div class="mxch-mobile-nav-section-title"><?php esc_html_e('Extensions', 'mxchat'); ?></div>
92 <button class="mxch-mobile-nav-link active" data-target="overview">
93 <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>
94 <span><?php esc_html_e('Overview', 'mxchat'); ?></span>
95 </button>
96 <?php foreach ($addons_config as $slug => $addon):
97 $status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']);
98 ?>
99 <button class="mxch-mobile-nav-link mxch-addon-nav-link" data-target="addon-<?php echo esc_attr($slug); ?>">
100 <span class="mxch-addon-status-dot <?php echo esc_attr($status['status']); ?>"></span>
101 <span><?php echo esc_html(!empty($addon['sidebar_title']) ? $addon['sidebar_title'] : str_replace('MxChat ', '', $addon['title'])); ?></span>
102 </button>
103 <?php endforeach; ?>
104 </div>
105 </nav>
106 </div>
107
108 <!-- Sidebar Navigation -->
109 <aside class="mxch-sidebar mxch-pro-sidebar">
110 <div class="mxch-sidebar-header">
111 <a href="#" class="mxch-sidebar-logo">
112 <div class="mxch-sidebar-logo-icon">
113 <img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat">
114 </div>
115 <span class="mxch-sidebar-logo-text">MxChat</span>
116 <span class="mxch-sidebar-version">v<?php echo esc_html(MXCHAT_VERSION ?? '2.7.0'); ?></span>
117 </a>
118 </div>
119
120 <nav class="mxch-sidebar-nav">
121 <!-- License Status - Simple Badge -->
122 <div class="mxch-nav-section mxch-license-section">
123 <div class="mxch-nav-section-title"><?php esc_html_e('License', 'mxchat'); ?></div>
124 <div class="mxch-sidebar-license-status">
125 <span class="mxch-license-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>">
126 <?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?>
127 </span>
128 </div>
129 </div>
130
131 <!-- Extensions Section -->
132 <div class="mxch-nav-section mxch-extensions-section">
133 <div class="mxch-nav-section-title">
134 <?php esc_html_e('Extensions', 'mxchat'); ?>
135 <span class="mxch-nav-section-count"><?php echo esc_html(count($addons_config)); ?></span>
136 </div>
137
138 <div class="mxch-nav-item" data-section="overview">
139 <button class="mxch-nav-link active" data-target="overview">
140 <span class="mxch-nav-link-icon">
141 <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>
142 </span>
143 <span class="mxch-nav-link-text"><?php esc_html_e('Overview', 'mxchat'); ?></span>
144 </button>
145 </div>
146
147 <?php foreach ($addons_config as $slug => $addon):
148 $status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']);
149 ?>
150 <div class="mxch-nav-item mxch-addon-item" data-section="addon-<?php echo esc_attr($slug); ?>">
151 <button class="mxch-nav-link mxch-addon-nav-link" data-target="addon-<?php echo esc_attr($slug); ?>">
152 <span class="mxch-addon-status-dot <?php echo esc_attr($status['status']); ?>"></span>
153 <span class="mxch-nav-link-text"><?php echo esc_html(!empty($addon['sidebar_title']) ? $addon['sidebar_title'] : str_replace('MxChat ', '', $addon['title'])); ?></span>
154 </button>
155 </div>
156 <?php endforeach; ?>
157 </div>
158 </nav>
159
160 <?php if (!$is_activated): ?>
161 <div class="mxch-sidebar-footer">
162 <a href="https://mxchat.ai/" target="_blank" class="mxch-sidebar-upgrade-v2">
163 <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>
164 <?php esc_html_e('Pro Upgrade', 'mxchat'); ?>
165 </a>
166 </div>
167 <?php endif; ?>
168 </aside>
169
170 <!-- Main Content Area -->
171 <main class="mxch-content mxch-pro-content">
172 <?php if (!$is_activated): ?>
173 <div class="mxch-pro-banner">
174 <div class="mxch-pro-banner-content">
175 <h3 class="mxch-pro-banner-title"><?php esc_html_e('Stop paying $50–200/month for AI chatbot tools.', 'mxchat'); ?></h3>
176 <p class="mxch-pro-banner-text"><?php esc_html_e('One payment unlocks every MxChat Pro add-on for life — MCP server access for Claude / ChatGPT / Claude Code, WooCommerce sales, Google Search Console insights, AI-generated chatbot themes, lead-capture forms, unlimited bots, image analysis, and more. No renewals. No surprise bills.', 'mxchat'); ?></p>
177 </div>
178 <a href="https://mxchat.ai/" target="_blank" class="mxch-pro-banner-btn"><span><?php esc_html_e('Get Lifetime Access →', 'mxchat'); ?></span></a>
179 </div>
180 <?php endif; ?>
181
182 <!-- Overview Section -->
183 <div id="overview" class="mxch-section active">
184 <div class="mxch-content-header">
185 <h1 class="mxch-content-title"><?php esc_html_e('Pro & Extensions', 'mxchat'); ?></h1>
186 <p class="mxch-content-subtitle"><?php esc_html_e('Manage your license and extend MxChat with powerful add-ons. All add-ons are available for download from the Downloads page in your MxChat account.', 'mxchat'); ?></p>
187 </div>
188
189 <!-- License Management Card -->
190 <div class="mxch-card mxch-license-mgmt-card">
191 <div class="mxch-card-header">
192 <h3 class="mxch-card-title">
193 <svg class="mxch-card-title-icon" 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"><path d="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/></svg>
194 <?php esc_html_e('License Management', 'mxchat'); ?>
195 </h3>
196 <span class="mxch-license-main-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>">
197 <?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?>
198 </span>
199 </div>
200 <div class="mxch-card-body">
201 <?php if ($license_status === 'active'): ?>
202 <!-- Active License Display -->
203 <div class="mxch-license-info-grid">
204 <div class="mxch-license-info-item">
205 <span class="mxch-license-info-label"><?php esc_html_e('Domain', 'mxchat'); ?></span>
206 <span class="mxch-license-info-value">
207 <?php echo esc_html($current_domain); ?>
208 <?php if ($is_domain_linked): ?>
209 <span class="mxch-domain-linked"><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="20 6 9 17 4 12"/></svg> <?php esc_html_e('Linked', 'mxchat'); ?></span>
210 <?php else: ?>
211 <button type="button" id="link-domain-button" class="mxch-link-domain-btn"><?php esc_html_e('Link Domain', 'mxchat'); ?></button>
212 <span id="domain-link-status"></span>
213 <?php endif; ?>
214 </span>
215 </div>
216 <div class="mxch-license-info-item">
217 <span class="mxch-license-info-label"><?php esc_html_e('Email', 'mxchat'); ?></span>
218 <span class="mxch-license-info-value"><?php echo esc_html($license_email); ?></span>
219 </div>
220 <div class="mxch-license-info-item">
221 <span class="mxch-license-info-label"><?php esc_html_e('License Key', 'mxchat'); ?></span>
222 <span class="mxch-license-info-value">
223 <code class="mxch-license-key-code"><?php echo esc_html($license_key); ?></code>
224 </span>
225 </div>
226 <?php if ($license_check) : ?>
227 <div class="mxch-license-info-item mxch-license-check-item">
228 <span class="mxch-license-info-label"><?php esc_html_e('Domain check', 'mxchat'); ?></span>
229 <span class="mxch-license-info-value">
230 <span id="mxchat-license-check-pill" class="mxch-status-pill <?php echo esc_attr($license_check['pill_class']); ?>"><span class="mxch-status-dot"></span><span class="mxchat-license-check-pill-text"><?php echo esc_html($license_check['pill_text']); ?></span></span>
231 <span id="mxchat-license-check-msg" class="mxch-license-check-sentence mxchat-license-check-msg" role="status"><?php echo esc_html($license_check['sentence']); ?></span>
232 </span>
233 </div>
234 <?php endif; ?>
235 </div>
236
237 <div class="mxch-license-footer-actions">
238 <a href="<?php echo esc_url($license_management_url); ?>" target="_blank" class="mxch-btn mxch-btn-secondary">
239 <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="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
240 <?php esc_html_e('Manage Account', 'mxchat'); ?>
241 </a>
242 <?php if ($license_check) : ?>
243 <button type="button" id="mxchat-license-check-button" class="mxch-btn mxch-btn-secondary mxchat-license-check-now">
244 <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"><polyline points="23 4 23 10 17 10"/><polyline points="1 20 1 14 7 14"/><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"/></svg>
245 <?php esc_html_e('Check license now', 'mxchat'); ?>
246 </button>
247 <?php endif; ?>
248 <button type="button" id="deactivate-license-button" class="mxch-btn mxch-btn-danger">
249 <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"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
250 <?php esc_html_e('Deactivate License', 'mxchat'); ?>
251 </button>
252 <span id="deactivate-status"></span>
253 </div>
254 <?php else: ?>
255 <?php if ($license_revoked && $license_check) : ?>
256 <!-- Pro paused by the licence domain check (c93ede): the licence holder switched this domain off -->
257 <div class="mxch-notice mxch-notice-warning mxch-notice-block mxch-license-check-panel">
258 <svg class="mxch-notice-icon" 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" aria-hidden="true"><path d="M10.29 3.86 1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
259 <div class="mxch-license-check-panel-body">
260 <strong><?php esc_html_e('Pro is paused on this site', 'mxchat'); ?></strong>
261 <p><?php echo esc_html($license_check['sentence']); ?></p>
262 <div class="mxch-license-check-panel-actions">
263 <button type="button" class="mxch-btn mxch-btn-secondary mxch-btn-sm mxchat-license-check-now"><?php esc_html_e('Check license now', 'mxchat'); ?></button>
264 <a href="<?php echo esc_url($license_management_url); ?>" target="_blank" class="mxch-btn mxch-btn-ghost mxch-btn-sm"><?php esc_html_e('Open My Account', 'mxchat'); ?></a>
265 <span class="mxchat-license-check-msg" role="status"></span>
266 </div>
267 </div>
268 </div>
269 <?php endif; ?>
270 <!-- Activation Form -->
271 <form id="mxchat-activation-form" class="mxch-activation-form">
272 <div class="mxch-form-row">
273 <div class="mxch-field">
274 <label class="mxch-field-label" for="mxchat_pro_email"><?php esc_html_e('Email Address', 'mxchat'); ?></label>
275 <input type="email" id="mxchat_pro_email" name="mxchat_pro_email" value="<?php echo esc_attr(get_option('mxchat_pro_email')); ?>" class="mxch-input" required placeholder="[email protected]" />
276 </div>
277 <div class="mxch-field">
278 <label class="mxch-field-label" for="mxchat_activation_key"><?php esc_html_e('Activation Key', 'mxchat'); ?></label>
279 <input type="text" id="mxchat_activation_key" name="mxchat_activation_key" value="<?php echo esc_attr(get_option('mxchat_activation_key')); ?>" class="mxch-input" required placeholder="XXXX-XXXX-XXXX-XXXX" />
280 </div>
281 </div>
282 <input type="hidden" id="mxchat_domain" name="domain" value="<?php echo esc_attr($current_domain); ?>" />
283 <!-- Hidden license status element required by activation-script.js -->
284 <span id="mxchat-license-status" class="<?php echo $license_status; ?>" style="display: none;"><?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?></span>
285 <div class="mxch-form-actions">
286 <button type="submit" id="activate_license_button" class="mxch-btn mxch-btn-primary mxch-btn-lg">
287 <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="M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"/></svg>
288 <?php esc_html_e('Activate License', 'mxchat'); ?>
289 </button>
290 <div id="mxchat-activation-spinner" class="mxch-spinner" style="display: none;"></div>
291 </div>
292 <?php if ($has_license_check && !$license_revoked && ($license_refusal = MxChat_License_Check::last_refusal()) !== '') : ?>
293 <!-- The last Activate click was refused by the licence owner (c93ede): say who controls it -->
294 <p class="mxch-field-hint mxch-license-refusal" data-mxchat-license-refusal="1">
295 <strong><?php esc_html_e('Managed by the licence owner.', 'mxchat'); ?></strong>
296 <?php echo esc_html($license_refusal); ?>
297 </p>
298 <?php endif; ?>
299 <p class="mxch-field-hint">
300 <?php esc_html_e("Don't have a license?", 'mxchat'); ?>
301 <a href="https://mxchat.ai/" target="_blank"><?php esc_html_e('Get MxChat Pro', 'mxchat'); ?></a>
302 </p>
303 </form>
304 <?php endif; ?>
305 </div>
306 </div>
307
308 <!-- Extensions Overview Grid -->
309 <div class="mxch-content-header mxch-mt-xl">
310 <h2 class="mxch-content-title mxch-h2"><?php esc_html_e('Available Extensions', 'mxchat'); ?></h2>
311 <p class="mxch-content-subtitle"><?php esc_html_e('Click on any extension to learn more and get started.', 'mxchat'); ?></p>
312 </div>
313
314 <div class="mxch-extensions-grid">
315 <?php foreach ($addons_config as $slug => $addon):
316 $status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']);
317 ?>
318 <div class="mxch-extension-card" data-addon="<?php echo esc_attr($slug); ?>" style="--card-accent: <?php echo esc_attr($addon['accent']); ?>">
319 <div class="mxch-extension-card-header">
320 <h3 class="mxch-extension-title"><?php echo esc_html($addon['title']); ?></h3>
321 <span class="mxch-extension-status <?php echo esc_attr($status['status']); ?>">
322 <?php echo esc_html(ucfirst(str_replace('-', ' ', $status['status']))); ?>
323 </span>
324 </div>
325 <p class="mxch-extension-desc"><?php echo esc_html($addon['description']); ?></p>
326 <div class="mxch-extension-card-footer">
327 <?php if ($status['status'] === 'active'): ?>
328 <a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-sm">
329 <?php esc_html_e('Configure', 'mxchat'); ?>
330 </a>
331 <?php elseif ($status['status'] === 'inactive'): ?>
332 <a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-secondary mxch-btn-sm">
333 <?php esc_html_e('Activate', 'mxchat'); ?>
334 </a>
335 <?php else: ?>
336 <a href="<?php echo esc_url($addon['url']); ?>" target="_blank" class="mxch-btn mxch-btn-secondary mxch-btn-sm">
337 <?php esc_html_e('Get Extension', 'mxchat'); ?>
338 </a>
339 <?php endif; ?>
340 <button type="button" class="mxch-btn mxch-btn-ghost mxch-btn-sm mxch-view-addon-btn" data-target="addon-<?php echo esc_attr($slug); ?>">
341 <?php esc_html_e('Learn More', 'mxchat'); ?>
342 </button>
343 </div>
344 </div>
345 <?php endforeach; ?>
346 </div>
347 </div>
348
349 <!-- Individual Addon Detail Sections (Hero Style) -->
350 <?php foreach ($addons_config as $slug => $addon):
351 $status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']);
352 // Hero features are rendered via SVG showcase (no image files needed)
353 ?>
354 <div id="addon-<?php echo esc_attr($slug); ?>" class="mxch-section mxch-addon-detail">
355 <!-- Back Link -->
356 <div class="mxch-addon-page-header">
357 <button type="button" class="mxch-back-link" data-target="overview">
358 <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>
359 <?php esc_html_e('Back to Extensions', 'mxchat'); ?>
360 </button>
361 </div>
362
363 <!-- Hero Section -->
364 <div class="mxch-addon-hero-section">
365 <!-- Left: Content -->
366 <div class="mxch-addon-hero-content">
367 <h1 class="mxch-addon-hero-title"><?php echo esc_html($addon['title']); ?></h1>
368 <p class="mxch-addon-hero-desc"><?php echo esc_html($addon['description']); ?></p>
369
370 <!-- Feature highlights -->
371 <?php if (!empty($addon['key_benefits'])): ?>
372 <div class="mxch-addon-hero-features">
373 <?php foreach ($addon['key_benefits'] as $benefit): ?>
374 <div class="mxch-addon-hero-feature">
375 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>
376 <span><?php echo esc_html($benefit); ?></span>
377 </div>
378 <?php endforeach; ?>
379 </div>
380 <?php endif; ?>
381
382 <!-- Action Buttons - Context aware -->
383 <div class="mxch-addon-hero-actions">
384 <?php if ($status['status'] === 'active'): ?>
385 <!-- Already active - Configure button -->
386 <a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-lg">
387 <?php esc_html_e('Configure Extension', 'mxchat'); ?>
388 </a>
389 <?php elseif ($status['status'] === 'inactive'): ?>
390 <!-- Installed but inactive - Activate button -->
391 <a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-lg">
392 <?php esc_html_e('Activate Extension', 'mxchat'); ?>
393 </a>
394 <?php elseif ($is_activated): ?>
395 <!-- Has Pro license but extension not installed - the installable ZIPs live on My Account > Downloads -->
396 <a href="https://mxchat.ai/my-account/downloads/" target="_blank" class="mxch-btn mxch-btn-primary mxch-btn-lg">
397 <?php esc_html_e('Get the ZIP from My Account', 'mxchat'); ?>
398 </a>
399 <?php else: ?>
400 <!-- No Pro license - Purchase -->
401 <a href="https://mxchat.ai/" target="_blank" class="mxch-btn mxch-btn-primary mxch-btn-lg">
402 <?php esc_html_e('Purchase MxChat', 'mxchat'); ?>
403 </a>
404 <?php endif; ?>
405 <a href="<?php echo esc_url($addon['url']); ?>" target="_blank" class="mxch-btn mxch-btn-outline mxch-btn-lg">
406 <?php esc_html_e('Documentation', 'mxchat'); ?>
407 </a>
408 </div>
409 </div>
410
411 <!-- Right: Feature Visual -->
412 <div class="mxch-addon-hero-image">
413 <div class="mxch-addon-feature-showcase" style="--showcase-accent: <?php echo esc_attr($addon['accent']); ?>">
414 <?php foreach ($addon['hero_features'] as $hf): ?>
415 <div class="mxch-addon-showcase-item">
416 <div class="mxch-addon-showcase-icon"><?php echo $hf['icon']; ?></div>
417 <div class="mxch-addon-showcase-text">
418 <strong><?php echo esc_html($hf['title']); ?></strong>
419 <span><?php echo esc_html($hf['desc']); ?></span>
420 </div>
421 </div>
422 <?php endforeach; ?>
423 </div>
424 </div>
425 </div>
426 </div>
427 <?php endforeach; ?>
428 </main>
429 </div>
430
431 <!-- Hidden fields for JavaScript -->
432 <input type="hidden" id="mxchat-ajax-url" value="<?php echo esc_url(admin_url('admin-ajax.php')); ?>" />
433 <input type="hidden" id="mxchat-nonce" value="<?php echo esc_attr(wp_create_nonce('mxchat_activate_license_nonce')); ?>" />
434 <input type="hidden" id="mxchat-api-url" value="https://mxchat.ai" />
435 <?php
436 }
437
438 /**
439 * Get addon status information
440 */
441 function mxchat_get_addon_status_info($plugin_file, $config_page) {
442 if (!function_exists('get_plugins')) {
443 require_once ABSPATH . 'wp-admin/includes/plugin.php';
444 }
445
446 $all_plugins = get_plugins();
447 $active_plugins = get_option('active_plugins', array());
448
449 if (isset($all_plugins[$plugin_file])) {
450 if (in_array($plugin_file, $active_plugins)) {
451 return array(
452 'status' => 'active',
453 'action_url' => admin_url('admin.php?page=' . $config_page),
454 'action_text' => __('Configure', 'mxchat')
455 );
456 } else {
457 return array(
458 'status' => 'inactive',
459 'action_url' => wp_nonce_url(
460 admin_url('plugins.php?action=activate&plugin=' . $plugin_file),
461 'activate-plugin_' . $plugin_file
462 ),
463 'action_text' => __('Activate', 'mxchat')
464 );
465 }
466 }
467
468 return array(
469 'status' => 'not-installed',
470 'action_url' => '',
471 'action_text' => __('Get Extension', 'mxchat')
472 );
473 }
474