| 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/orders/'; |
| 27 |
|
| 28 |
// Mask the license key for display |
| 29 |
$masked_key = ''; |
| 30 |
if (!empty($license_key)) { |
| 31 |
$masked_key = str_repeat('•', max(0, strlen($license_key) - 4)) . substr($license_key, -4); |
| 32 |
} |
| 33 |
|
| 34 |
// Count addon statuses |
| 35 |
$active_count = 0; |
| 36 |
$installed_count = 0; |
| 37 |
foreach ($addons_config as $slug => $addon) { |
| 38 |
$status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']); |
| 39 |
if ($status['status'] === 'active') { |
| 40 |
$active_count++; |
| 41 |
$installed_count++; |
| 42 |
} elseif ($status['status'] === 'inactive') { |
| 43 |
$installed_count++; |
| 44 |
} |
| 45 |
} |
| 46 |
?> |
| 47 |
<div class="mxch-admin-wrapper mxch-pro-wrapper"> |
| 48 |
<!-- Mobile Header --> |
| 49 |
<header class="mxch-mobile-header"> |
| 50 |
<a href="#" class="mxch-mobile-logo"> |
| 51 |
<div class="mxch-mobile-logo-icon"> |
| 52 |
<img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat"> |
| 53 |
</div> |
| 54 |
<span class="mxch-mobile-logo-text">MxChat</span> |
| 55 |
</a> |
| 56 |
<button type="button" class="mxch-mobile-menu-btn" aria-label="<?php esc_attr_e('Open menu', 'mxchat'); ?>"> |
| 57 |
<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> |
| 58 |
</button> |
| 59 |
</header> |
| 60 |
|
| 61 |
<!-- Mobile Menu Overlay --> |
| 62 |
<div class="mxch-mobile-overlay"></div> |
| 63 |
|
| 64 |
<!-- Mobile Menu Modal --> |
| 65 |
<div class="mxch-mobile-menu"> |
| 66 |
<div class="mxch-mobile-menu-header"> |
| 67 |
<span class="mxch-mobile-menu-title"><?php esc_html_e('Pro & Extensions', 'mxchat'); ?></span> |
| 68 |
<button type="button" class="mxch-mobile-menu-close" aria-label="<?php esc_attr_e('Close menu', 'mxchat'); ?>"> |
| 69 |
<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> |
| 70 |
</button> |
| 71 |
</div> |
| 72 |
<nav class="mxch-mobile-menu-nav"> |
| 73 |
<!-- License Status (Mobile) --> |
| 74 |
<div class="mxch-mobile-nav-section"> |
| 75 |
<div class="mxch-mobile-nav-section-title"><?php esc_html_e('License', 'mxchat'); ?></div> |
| 76 |
<div class="mxch-mobile-license-status"> |
| 77 |
<span class="mxch-license-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>"> |
| 78 |
<?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?> |
| 79 |
</span> |
| 80 |
</div> |
| 81 |
</div> |
| 82 |
|
| 83 |
<!-- Extensions Section (Mobile) --> |
| 84 |
<div class="mxch-mobile-nav-section"> |
| 85 |
<div class="mxch-mobile-nav-section-title"><?php esc_html_e('Extensions', 'mxchat'); ?></div> |
| 86 |
<button class="mxch-mobile-nav-link active" data-target="overview"> |
| 87 |
<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> |
| 88 |
<span><?php esc_html_e('Overview', 'mxchat'); ?></span> |
| 89 |
</button> |
| 90 |
<?php foreach ($addons_config as $slug => $addon): |
| 91 |
$status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']); |
| 92 |
?> |
| 93 |
<button class="mxch-mobile-nav-link mxch-addon-nav-link" data-target="addon-<?php echo esc_attr($slug); ?>"> |
| 94 |
<span class="mxch-addon-status-dot <?php echo esc_attr($status['status']); ?>"></span> |
| 95 |
<span><?php echo esc_html(!empty($addon['sidebar_title']) ? $addon['sidebar_title'] : str_replace('MxChat ', '', $addon['title'])); ?></span> |
| 96 |
</button> |
| 97 |
<?php endforeach; ?> |
| 98 |
</div> |
| 99 |
</nav> |
| 100 |
</div> |
| 101 |
|
| 102 |
<!-- Sidebar Navigation --> |
| 103 |
<aside class="mxch-sidebar mxch-pro-sidebar"> |
| 104 |
<div class="mxch-sidebar-header"> |
| 105 |
<a href="#" class="mxch-sidebar-logo"> |
| 106 |
<div class="mxch-sidebar-logo-icon"> |
| 107 |
<img src="<?php echo esc_url($plugin_url . 'images/icon-128x128.png'); ?>" alt="MxChat"> |
| 108 |
</div> |
| 109 |
<span class="mxch-sidebar-logo-text">MxChat</span> |
| 110 |
<span class="mxch-sidebar-version">v<?php echo esc_html(MXCHAT_VERSION ?? '2.7.0'); ?></span> |
| 111 |
</a> |
| 112 |
</div> |
| 113 |
|
| 114 |
<nav class="mxch-sidebar-nav"> |
| 115 |
<!-- License Status - Simple Badge --> |
| 116 |
<div class="mxch-nav-section mxch-license-section"> |
| 117 |
<div class="mxch-nav-section-title"><?php esc_html_e('License', 'mxchat'); ?></div> |
| 118 |
<div class="mxch-sidebar-license-status"> |
| 119 |
<span class="mxch-license-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>"> |
| 120 |
<?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?> |
| 121 |
</span> |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
|
| 125 |
<!-- Extensions Section --> |
| 126 |
<div class="mxch-nav-section mxch-extensions-section"> |
| 127 |
<div class="mxch-nav-section-title"> |
| 128 |
<?php esc_html_e('Extensions', 'mxchat'); ?> |
| 129 |
<span class="mxch-nav-section-count"><?php echo esc_html(count($addons_config)); ?></span> |
| 130 |
</div> |
| 131 |
|
| 132 |
<div class="mxch-nav-item" data-section="overview"> |
| 133 |
<button class="mxch-nav-link active" data-target="overview"> |
| 134 |
<span class="mxch-nav-link-icon"> |
| 135 |
<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> |
| 136 |
</span> |
| 137 |
<span class="mxch-nav-link-text"><?php esc_html_e('Overview', 'mxchat'); ?></span> |
| 138 |
</button> |
| 139 |
</div> |
| 140 |
|
| 141 |
<?php foreach ($addons_config as $slug => $addon): |
| 142 |
$status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']); |
| 143 |
?> |
| 144 |
<div class="mxch-nav-item mxch-addon-item" data-section="addon-<?php echo esc_attr($slug); ?>"> |
| 145 |
<button class="mxch-nav-link mxch-addon-nav-link" data-target="addon-<?php echo esc_attr($slug); ?>"> |
| 146 |
<span class="mxch-addon-status-dot <?php echo esc_attr($status['status']); ?>"></span> |
| 147 |
<span class="mxch-nav-link-text"><?php echo esc_html(!empty($addon['sidebar_title']) ? $addon['sidebar_title'] : str_replace('MxChat ', '', $addon['title'])); ?></span> |
| 148 |
</button> |
| 149 |
</div> |
| 150 |
<?php endforeach; ?> |
| 151 |
</div> |
| 152 |
</nav> |
| 153 |
|
| 154 |
<?php if (!$is_activated): ?> |
| 155 |
<div class="mxch-sidebar-footer"> |
| 156 |
<a href="https://mxchat.ai/" target="_blank" class="mxch-sidebar-upgrade-v2"> |
| 157 |
<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> |
| 158 |
<?php esc_html_e('Pro Upgrade', 'mxchat'); ?> |
| 159 |
</a> |
| 160 |
</div> |
| 161 |
<?php endif; ?> |
| 162 |
</aside> |
| 163 |
|
| 164 |
<!-- Main Content Area --> |
| 165 |
<main class="mxch-content mxch-pro-content"> |
| 166 |
<?php if (!$is_activated): ?> |
| 167 |
<div class="mxch-pro-banner"> |
| 168 |
<div class="mxch-pro-banner-content"> |
| 169 |
<h3 class="mxch-pro-banner-title"><?php esc_html_e('Stop paying $50–200/month for AI chatbot tools.', 'mxchat'); ?></h3> |
| 170 |
<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> |
| 171 |
</div> |
| 172 |
<a href="https://mxchat.ai/" target="_blank" class="mxch-pro-banner-btn"><span><?php esc_html_e('Get Lifetime Access →', 'mxchat'); ?></span></a> |
| 173 |
</div> |
| 174 |
<?php endif; ?> |
| 175 |
|
| 176 |
<!-- Overview Section --> |
| 177 |
<div id="overview" class="mxch-section active"> |
| 178 |
<div class="mxch-content-header"> |
| 179 |
<h1 class="mxch-content-title"><?php esc_html_e('Pro & Extensions', 'mxchat'); ?></h1> |
| 180 |
<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> |
| 181 |
</div> |
| 182 |
|
| 183 |
<!-- License Management Card --> |
| 184 |
<div class="mxch-card mxch-license-mgmt-card"> |
| 185 |
<div class="mxch-card-header"> |
| 186 |
<h3 class="mxch-card-title"> |
| 187 |
<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> |
| 188 |
<?php esc_html_e('License Management', 'mxchat'); ?> |
| 189 |
</h3> |
| 190 |
<span class="mxch-license-main-badge <?php echo $license_status === 'active' ? 'active' : 'inactive'; ?>"> |
| 191 |
<?php echo $license_status === 'active' ? esc_html__('Active', 'mxchat') : esc_html__('Inactive', 'mxchat'); ?> |
| 192 |
</span> |
| 193 |
</div> |
| 194 |
<div class="mxch-card-body"> |
| 195 |
<?php if ($license_status === 'active'): ?> |
| 196 |
<!-- Active License Display --> |
| 197 |
<div class="mxch-license-info-grid"> |
| 198 |
<div class="mxch-license-info-item"> |
| 199 |
<span class="mxch-license-info-label"><?php esc_html_e('Domain', 'mxchat'); ?></span> |
| 200 |
<span class="mxch-license-info-value"> |
| 201 |
<?php echo esc_html($current_domain); ?> |
| 202 |
<?php if ($is_domain_linked): ?> |
| 203 |
<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> |
| 204 |
<?php else: ?> |
| 205 |
<button type="button" id="link-domain-button" class="mxch-link-domain-btn"><?php esc_html_e('Link Domain', 'mxchat'); ?></button> |
| 206 |
<span id="domain-link-status"></span> |
| 207 |
<?php endif; ?> |
| 208 |
</span> |
| 209 |
</div> |
| 210 |
<div class="mxch-license-info-item"> |
| 211 |
<span class="mxch-license-info-label"><?php esc_html_e('Email', 'mxchat'); ?></span> |
| 212 |
<span class="mxch-license-info-value"><?php echo esc_html($license_email); ?></span> |
| 213 |
</div> |
| 214 |
<div class="mxch-license-info-item"> |
| 215 |
<span class="mxch-license-info-label"><?php esc_html_e('License Key', 'mxchat'); ?></span> |
| 216 |
<span class="mxch-license-info-value"> |
| 217 |
<code class="mxch-license-key-code"><?php echo esc_html($license_key); ?></code> |
| 218 |
</span> |
| 219 |
</div> |
| 220 |
</div> |
| 221 |
|
| 222 |
<div class="mxch-license-footer-actions"> |
| 223 |
<a href="<?php echo esc_url($license_management_url); ?>" target="_blank" class="mxch-btn mxch-btn-secondary"> |
| 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"><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> |
| 225 |
<?php esc_html_e('Manage Account', 'mxchat'); ?> |
| 226 |
</a> |
| 227 |
<button type="button" id="deactivate-license-button" class="mxch-btn mxch-btn-danger"> |
| 228 |
<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> |
| 229 |
<?php esc_html_e('Deactivate License', 'mxchat'); ?> |
| 230 |
</button> |
| 231 |
<span id="deactivate-status"></span> |
| 232 |
</div> |
| 233 |
<?php else: ?> |
| 234 |
<!-- Activation Form --> |
| 235 |
<form id="mxchat-activation-form" class="mxch-activation-form"> |
| 236 |
<div class="mxch-form-row"> |
| 237 |
<div class="mxch-field"> |
| 238 |
<label class="mxch-field-label" for="mxchat_pro_email"><?php esc_html_e('Email Address', 'mxchat'); ?></label> |
| 239 |
<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="your@email.com" /> |
| 240 |
</div> |
| 241 |
<div class="mxch-field"> |
| 242 |
<label class="mxch-field-label" for="mxchat_activation_key"><?php esc_html_e('Activation Key', 'mxchat'); ?></label> |
| 243 |
<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" /> |
| 244 |
</div> |
| 245 |
</div> |
| 246 |
<input type="hidden" id="mxchat_domain" name="domain" value="<?php echo esc_attr($current_domain); ?>" /> |
| 247 |
<!-- Hidden license status element required by activation-script.js --> |
| 248 |
<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> |
| 249 |
<div class="mxch-form-actions"> |
| 250 |
<button type="submit" id="activate_license_button" class="mxch-btn mxch-btn-primary mxch-btn-lg"> |
| 251 |
<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> |
| 252 |
<?php esc_html_e('Activate License', 'mxchat'); ?> |
| 253 |
</button> |
| 254 |
<div id="mxchat-activation-spinner" class="mxch-spinner" style="display: none;"></div> |
| 255 |
</div> |
| 256 |
<p class="mxch-field-hint"> |
| 257 |
<?php esc_html_e("Don't have a license?", 'mxchat'); ?> |
| 258 |
<a href="https://mxchat.ai/" target="_blank"><?php esc_html_e('Get MxChat Pro', 'mxchat'); ?></a> |
| 259 |
</p> |
| 260 |
</form> |
| 261 |
<?php endif; ?> |
| 262 |
</div> |
| 263 |
</div> |
| 264 |
|
| 265 |
<!-- Extensions Overview Grid --> |
| 266 |
<div class="mxch-content-header mxch-mt-xl"> |
| 267 |
<h2 class="mxch-content-title mxch-h2"><?php esc_html_e('Available Extensions', 'mxchat'); ?></h2> |
| 268 |
<p class="mxch-content-subtitle"><?php esc_html_e('Click on any extension to learn more and get started.', 'mxchat'); ?></p> |
| 269 |
</div> |
| 270 |
|
| 271 |
<div class="mxch-extensions-grid"> |
| 272 |
<?php foreach ($addons_config as $slug => $addon): |
| 273 |
$status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']); |
| 274 |
?> |
| 275 |
<div class="mxch-extension-card" data-addon="<?php echo esc_attr($slug); ?>" style="--card-accent: <?php echo esc_attr($addon['accent']); ?>"> |
| 276 |
<div class="mxch-extension-card-header"> |
| 277 |
<h3 class="mxch-extension-title"><?php echo esc_html($addon['title']); ?></h3> |
| 278 |
<span class="mxch-extension-status <?php echo esc_attr($status['status']); ?>"> |
| 279 |
<?php echo esc_html(ucfirst(str_replace('-', ' ', $status['status']))); ?> |
| 280 |
</span> |
| 281 |
</div> |
| 282 |
<p class="mxch-extension-desc"><?php echo esc_html($addon['description']); ?></p> |
| 283 |
<div class="mxch-extension-card-footer"> |
| 284 |
<?php if ($status['status'] === 'active'): ?> |
| 285 |
<a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-sm"> |
| 286 |
<?php esc_html_e('Configure', 'mxchat'); ?> |
| 287 |
</a> |
| 288 |
<?php elseif ($status['status'] === 'inactive'): ?> |
| 289 |
<a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-secondary mxch-btn-sm"> |
| 290 |
<?php esc_html_e('Activate', 'mxchat'); ?> |
| 291 |
</a> |
| 292 |
<?php else: ?> |
| 293 |
<a href="<?php echo esc_url($addon['url']); ?>" target="_blank" class="mxch-btn mxch-btn-secondary mxch-btn-sm"> |
| 294 |
<?php esc_html_e('Get Extension', 'mxchat'); ?> |
| 295 |
</a> |
| 296 |
<?php endif; ?> |
| 297 |
<button type="button" class="mxch-btn mxch-btn-ghost mxch-btn-sm mxch-view-addon-btn" data-target="addon-<?php echo esc_attr($slug); ?>"> |
| 298 |
<?php esc_html_e('Learn More', 'mxchat'); ?> |
| 299 |
</button> |
| 300 |
</div> |
| 301 |
</div> |
| 302 |
<?php endforeach; ?> |
| 303 |
</div> |
| 304 |
</div> |
| 305 |
|
| 306 |
<!-- Individual Addon Detail Sections (Hero Style) --> |
| 307 |
<?php foreach ($addons_config as $slug => $addon): |
| 308 |
$status = mxchat_get_addon_status_info($addon['plugin_file'], $addon['config_page']); |
| 309 |
// Hero features are rendered via SVG showcase (no image files needed) |
| 310 |
?> |
| 311 |
<div id="addon-<?php echo esc_attr($slug); ?>" class="mxch-section mxch-addon-detail"> |
| 312 |
<!-- Back Link --> |
| 313 |
<div class="mxch-addon-page-header"> |
| 314 |
<button type="button" class="mxch-back-link" data-target="overview"> |
| 315 |
<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> |
| 316 |
<?php esc_html_e('Back to Extensions', 'mxchat'); ?> |
| 317 |
</button> |
| 318 |
</div> |
| 319 |
|
| 320 |
<!-- Hero Section --> |
| 321 |
<div class="mxch-addon-hero-section"> |
| 322 |
<!-- Left: Content --> |
| 323 |
<div class="mxch-addon-hero-content"> |
| 324 |
<h1 class="mxch-addon-hero-title"><?php echo esc_html($addon['title']); ?></h1> |
| 325 |
<p class="mxch-addon-hero-desc"><?php echo esc_html($addon['description']); ?></p> |
| 326 |
|
| 327 |
<!-- Feature highlights --> |
| 328 |
<?php if (!empty($addon['key_benefits'])): ?> |
| 329 |
<div class="mxch-addon-hero-features"> |
| 330 |
<?php foreach ($addon['key_benefits'] as $benefit): ?> |
| 331 |
<div class="mxch-addon-hero-feature"> |
| 332 |
<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> |
| 333 |
<span><?php echo esc_html($benefit); ?></span> |
| 334 |
</div> |
| 335 |
<?php endforeach; ?> |
| 336 |
</div> |
| 337 |
<?php endif; ?> |
| 338 |
|
| 339 |
<!-- Action Buttons - Context aware --> |
| 340 |
<div class="mxch-addon-hero-actions"> |
| 341 |
<?php if ($status['status'] === 'active'): ?> |
| 342 |
<!-- Already active - Configure button --> |
| 343 |
<a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-lg"> |
| 344 |
<?php esc_html_e('Configure Extension', 'mxchat'); ?> |
| 345 |
</a> |
| 346 |
<?php elseif ($status['status'] === 'inactive'): ?> |
| 347 |
<!-- Installed but inactive - Activate button --> |
| 348 |
<a href="<?php echo esc_url($status['action_url']); ?>" class="mxch-btn mxch-btn-primary mxch-btn-lg"> |
| 349 |
<?php esc_html_e('Activate Extension', 'mxchat'); ?> |
| 350 |
</a> |
| 351 |
<?php elseif ($is_activated): ?> |
| 352 |
<!-- Has Pro license but extension not installed - Download --> |
| 353 |
<?php $download_link = !empty($addon['download_url']) ? $addon['download_url'] : $addon['url']; ?> |
| 354 |
<a href="<?php echo esc_url($download_link); ?>" target="_blank" class="mxch-btn mxch-btn-primary mxch-btn-lg"> |
| 355 |
<?php esc_html_e('Download Add-on', 'mxchat'); ?> |
| 356 |
</a> |
| 357 |
<?php else: ?> |
| 358 |
<!-- No Pro license - Purchase --> |
| 359 |
<a href="https://mxchat.ai/" target="_blank" class="mxch-btn mxch-btn-primary mxch-btn-lg"> |
| 360 |
<?php esc_html_e('Purchase MxChat', 'mxchat'); ?> |
| 361 |
</a> |
| 362 |
<?php endif; ?> |
| 363 |
<a href="<?php echo esc_url($addon['url']); ?>" target="_blank" class="mxch-btn mxch-btn-outline mxch-btn-lg"> |
| 364 |
<?php esc_html_e('Documentation', 'mxchat'); ?> |
| 365 |
</a> |
| 366 |
</div> |
| 367 |
</div> |
| 368 |
|
| 369 |
<!-- Right: Feature Visual --> |
| 370 |
<div class="mxch-addon-hero-image"> |
| 371 |
<div class="mxch-addon-feature-showcase" style="--showcase-accent: <?php echo esc_attr($addon['accent']); ?>"> |
| 372 |
<?php foreach ($addon['hero_features'] as $hf): ?> |
| 373 |
<div class="mxch-addon-showcase-item"> |
| 374 |
<div class="mxch-addon-showcase-icon"><?php echo $hf['icon']; ?></div> |
| 375 |
<div class="mxch-addon-showcase-text"> |
| 376 |
<strong><?php echo esc_html($hf['title']); ?></strong> |
| 377 |
<span><?php echo esc_html($hf['desc']); ?></span> |
| 378 |
</div> |
| 379 |
</div> |
| 380 |
<?php endforeach; ?> |
| 381 |
</div> |
| 382 |
</div> |
| 383 |
</div> |
| 384 |
</div> |
| 385 |
<?php endforeach; ?> |
| 386 |
</main> |
| 387 |
</div> |
| 388 |
|
| 389 |
<!-- Hidden fields for JavaScript --> |
| 390 |
<input type="hidden" id="mxchat-ajax-url" value="<?php echo esc_url(admin_url('admin-ajax.php')); ?>" /> |
| 391 |
<input type="hidden" id="mxchat-nonce" value="<?php echo esc_attr(wp_create_nonce('mxchat_activate_license_nonce')); ?>" /> |
| 392 |
<input type="hidden" id="mxchat-api-url" value="https://mxchat.ai" /> |
| 393 |
<?php |
| 394 |
} |
| 395 |
|
| 396 |
/** |
| 397 |
* Get addon status information |
| 398 |
*/ |
| 399 |
function mxchat_get_addon_status_info($plugin_file, $config_page) { |
| 400 |
if (!function_exists('get_plugins')) { |
| 401 |
require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 402 |
} |
| 403 |
|
| 404 |
$all_plugins = get_plugins(); |
| 405 |
$active_plugins = get_option('active_plugins', array()); |
| 406 |
|
| 407 |
if (isset($all_plugins[$plugin_file])) { |
| 408 |
if (in_array($plugin_file, $active_plugins)) { |
| 409 |
return array( |
| 410 |
'status' => 'active', |
| 411 |
'action_url' => admin_url('admin.php?page=' . $config_page), |
| 412 |
'action_text' => __('Configure', 'mxchat') |
| 413 |
); |
| 414 |
} else { |
| 415 |
return array( |
| 416 |
'status' => 'inactive', |
| 417 |
'action_url' => wp_nonce_url( |
| 418 |
admin_url('plugins.php?action=activate&plugin=' . $plugin_file), |
| 419 |
'activate-plugin_' . $plugin_file |
| 420 |
), |
| 421 |
'action_text' => __('Activate', 'mxchat') |
| 422 |
); |
| 423 |
} |
| 424 |
} |
| 425 |
|
| 426 |
return array( |
| 427 |
'status' => 'not-installed', |
| 428 |
'action_url' => '', |
| 429 |
'action_text' => __('Get Extension', 'mxchat') |
| 430 |
); |
| 431 |
} |
| 432 |
|