PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 2.3.1
MxChat – AI Chatbot & Content Generation for WordPress v2.3.1
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 2.0.3 2.0.4 2.0.5 2.0.6 All 152 releases
mxchat-basic / includes / class-mxchat-addons.php

class-mxchat-addons.php in MxChat – AI Chatbot & Content Generation for WordPress 2.3.1, at includes/class-mxchat-addons.php

304 lines 14.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The admin-specific functionality for the Add Ons page.
4 *
5 * @package MxChat
6 * @subpackage MxChat/admin
7 */
8 class MxChat_Addons {
9 /**
10 * Store add-on configuration data
11 *
12 * @var array
13 */
14 private $addons_config;
15
16 /**
17 * Initialize the class and set its properties.
18 */
19 public function __construct() {
20 $this->addons_config = array(
21
22 'mxchat-theme' => array(
23 'title' => __('MxChat Theme Customizer', 'mxchat'),
24 'description' => __('Make your chatbot uniquely yours. Generate beautiful themes instantly using simple descriptions or customize manually with precise color controls—zero coding required. Perfect for matching your brand identity.', 'mxchat'),
25 'key_benefits' => array(
26 __('AI-powered theme generator', 'mxchat'),
27 __('Live preview customizer', 'mxchat'),
28 __('One-click theme application', 'mxchat')
29 ),
30 'license' => 'MxChat PRO',
31 'accent' => '#fa73e6',
32 'url' => 'https://quickdeploywp.com/plugin/mxchat-theme/',
33 'plugin_file' => 'mxchat-theme/mxchat-theme.php',
34 'config_page' => 'mxchat-theme-settings'
35 ),
36
37 'mxchat-admin-assistant' => array(
38 'title' => __('MxChat Admin Assistant', 'mxchat'),
39 'description' => __('Your AI powerhouse inside WordPress. Chat with multiple AI models, generate images, research the web, and boost productivity—all without leaving your dashboard.', 'mxchat'),
40 'key_benefits' => array(
41 __('ChatGPT-like admin interface', 'mxchat'),
42 __('Generate images & research web', 'mxchat'),
43 __('Searchable chat history', 'mxchat')
44 ),
45 'license' => 'MxChat PRO',
46 'accent' => '#fa73e6',
47 'url' => 'https://quickdeploywp.com/plugin/mxchat-admin-assistant/',
48 'plugin_file' => 'mxchat-admin-chat/mxchat-admin-chat.php',
49 'config_page' => 'mxchat-admin-chat'
50 ),
51
52 'mxchat-image-analysis' => array(
53 'title' => __('MxChat Image Analysis', 'mxchat'),
54 'description' => __('Enhance your chatbot with AI-powered image analysis. Users can upload images for intelligent descriptions, OCR text extraction, and get answers about visual content using OpenAI Vision and Grok APIs.', 'mxchat'),
55 'key_benefits' => array(
56 __('Multiple AI vision models', 'mxchat'),
57 __('Drag & drop image uploads', 'mxchat'),
58 __('Custom analysis prompts', 'mxchat')
59 ),
60 'license' => 'MxChat PRO',
61 'accent' => '#fa73e6',
62 'url' => 'https://quickdeploywp.com/plugin/mxchat-image-analysis/',
63 'plugin_file' => 'mxchat-vision/mxchat-vision.php',
64 'config_page' => 'mxchat-vision'
65 ),
66
67 'mxchat-forms' => array(
68 'title' => __('MxChat Forms', 'mxchat'),
69 'description' => __('Convert conversations into data collection. Create smart forms that trigger during chats, collect user information, and turn casual visitors into qualified leads.', 'mxchat'),
70 'key_benefits' => array(
71 __('No-code form builder', 'mxchat'),
72 __('Intent-triggered activation', 'mxchat'),
73 __('Export lead data easily', 'mxchat')
74 ),
75 'license' => 'MxChat PRO',
76 'accent' => '#fa73e6',
77 'url' => 'https://quickdeploywp.com/plugin/mxchat-forms/',
78 'plugin_file' => 'mxchat-forms/mxchat-forms.php',
79 'config_page' => 'mxchat-forms'
80 ),
81 'mxchat-woo' => array(
82 'title' => __('MxChat WooCommerce', 'mxchat'),
83 'description' => __('Boost sales with AI-powered shopping assistance. Help customers find products, manage carts, and complete purchases—all through natural conversation.', 'mxchat'),
84 'key_benefits' => array(
85 __('Smart product recommendations', 'mxchat'),
86 __('Cart & checkout assistance', 'mxchat'),
87 __('Order history access', 'mxchat')
88 ),
89 'license' => 'MxChat PRO',
90 'accent' => '#fa73e6',
91 'url' => 'https://quickdeploywp.com/plugin/mxchat-woo/',
92 'plugin_file' => 'mxchat-woo/mxchat-woo.php',
93 'config_page' => 'mxchat-woo'
94 ),
95 'mxchat-perplexity' => array(
96 'title' => __('MxChat Perplexity', 'mxchat'),
97 'description' => __('Give your chatbot real-time knowledge. Add powerful web search capabilities so your bot can answer questions about current events and time-sensitive information.', 'mxchat'),
98 'key_benefits' => array(
99 __('Real-time web search', 'mxchat'),
100 __('Intent-triggered research', 'mxchat'),
101 __('Up-to-date information', 'mxchat')
102 ),
103 'license' => 'MxChat PRO',
104 'accent' => '#fa73e6',
105 'url' => 'https://quickdeploywp.com/plugin/mxchat-perplexity/',
106 'plugin_file' => 'mxchat-perplexity/mxchat-perplexity.php',
107 'config_page' => 'mxchat-perplexity'
108 ),
109 'mxchat-moderation' => array(
110 'title' => __('MxChat Moderation', 'mxchat'),
111 'description' => __('Keep your chat clean and professional. Block unwanted users, filter inappropriate content, and ensure your chatbot represents your brand properly.', 'mxchat'),
112 'key_benefits' => array(
113 __('IP & email-based blocking', 'mxchat'),
114 __('Content filtering', 'mxchat'),
115 __('Spam protection', 'mxchat')
116 ),
117 'license' => 'MxChat PRO',
118 'accent' => '#fa73e6',
119 'url' => 'https://quickdeploywp.com/plugin/mxchat-moderation/',
120 'plugin_file' => 'mxchat-moderation/mx-chat-moderation.php',
121 'config_page' => 'mx-chat-moderation'
122 ),
123 'mxchat-smart-recommender' => array(
124 'title' => __('MxChat Smart Recommender', 'mxchat'),
125 'description' => __('Turn your chatbot into a sales machine. Build personalized recommendation flows that understand user preferences and suggest perfect products or services.', 'mxchat'),
126 'key_benefits' => array(
127 __('Increase conversion rates', 'mxchat'),
128 __('Custom recommendation flows', 'mxchat'),
129 __('No coding required', 'mxchat')
130 ),
131 'license' => 'MxChat PRO',
132 'accent' => '#fa73e6',
133 'url' => 'https://quickdeploywp.com/plugin/mxchat-smart-recommender/',
134 'plugin_file' => 'mxchat-smart-recommender/mxchat-smart-recommender.php',
135 'config_page' => 'mxchat-smart-recommender'
136 ),
137 );
138 }
139
140 /**
141 * Register the stylesheets for the admin area.
142 */
143 public function enqueue_styles() {
144 $plugin_version = '2.3.1';
145
146 wp_enqueue_style(
147 'mxchat-addons',
148 plugin_dir_url(__FILE__) . '../css/admin-add-ons.css',
149 array(),
150 $plugin_version,
151 'all'
152 );
153 }
154
155 /**
156 * Check if an addon is installed and active
157 *
158 * @param string $plugin_file The plugin's main file path
159 * @return array Status information
160 */
161 private function get_addon_status($plugin_file) {
162 if (!function_exists('get_plugins')) {
163 require_once ABSPATH . 'wp-admin/includes/plugin.php';
164 }
165
166 $all_plugins = get_plugins();
167 $active_plugins = get_option('active_plugins', array());
168
169 // Find the addon by iterating through configs
170 $config_page = '';
171 foreach ($this->addons_config as $slug => $addon) {
172 if ($addon['plugin_file'] === $plugin_file) {
173 $config_page = $addon['config_page'];
174 break;
175 }
176 }
177
178 if (isset($all_plugins[$plugin_file])) {
179 if (in_array($plugin_file, $active_plugins)) {
180 return array(
181 'status' => 'active',
182 'action_url' => admin_url('admin.php?page=' . $config_page),
183 'action_text' => __('Configure', 'mxchat')
184 );
185 } else {
186 return array(
187 'status' => 'inactive',
188 'action_url' => wp_nonce_url(
189 admin_url('plugins.php?action=activate&plugin=' . $plugin_file),
190 'activate-plugin_' . $plugin_file
191 ),
192 'action_text' => __('Activate', 'mxchat')
193 );
194 }
195 }
196
197 return array(
198 'status' => 'not-installed',
199 'action_url' => '',
200 'action_text' => __('Get Extension', 'mxchat')
201 );
202 }
203
204 /**
205 * Render the Add Ons page content.
206 */
207 public function render_page() {
208 $this->enqueue_styles();
209 // Remove the sorting logic and just use the original order
210 $sorted_addons = $this->addons_config;
211
212 ?>
213 <div class="wrap mxchat-addons-wrapper">
214 <div class="mxchat-addons-hero">
215 <h1 class="mxchat-main-title">
216 <span class="mxchat-gradient-text">Power Up</span> Your Chatbot
217 </h1>
218 <p class="mxchat-hero-subtitle">
219 <?php esc_html_e('Extend MxChat with these powerful extensions and unlock advanced features.', 'mxchat'); ?>
220 </p>
221 </div>
222
223 <div class="mxchat-addons-section">
224 <div class="mxchat-addons-grid">
225 <?php foreach ($sorted_addons as $slug => $addon): ?>
226 <?php $this->render_addon_card($slug, $addon); ?>
227 <?php endforeach; ?>
228 </div>
229 </div>
230
231 <div class="mxchat-cta-section">
232 <h2><?php esc_html_e('Ready to take your chatbot to the next level?', 'mxchat'); ?></h2>
233 <p><?php esc_html_e('Get MxChat PRO today and access all premium extensions at one low price.', 'mxchat'); ?></p>
234 <a href="https://mxchat.ai/" class="mxchat-cta-button" target="_blank"><?php esc_html_e('Learn More', 'mxchat'); ?></a>
235 </div>
236 </div>
237 <?php
238 }
239
240 /**
241 * Render individual add-on card
242 *
243 * @param string $slug The addon slug
244 * @param array $addon The addon configuration array
245 */
246 private function render_addon_card($slug, $addon) {
247 $status_info = $this->get_addon_status($addon['plugin_file']);
248 $button_url = $status_info['status'] === 'not-installed' ? $addon['url'] : $status_info['action_url'];
249 $button_target = $status_info['status'] === 'not-installed' ? '_blank' : '_self';
250
251 // Check if addon is deprecated
252 $is_deprecated = isset($addon['status']) && $addon['status'] === 'deprecated';
253 ?>
254 <div class="mxchat-addon-card <?php echo $is_deprecated ? 'deprecated' : ''; ?>" style="--card-accent: <?php echo esc_attr($addon['accent']); ?>">
255 <div class="mxchat-addon-badge">
256 <?php if ($is_deprecated): ?>
257 <?php esc_html_e('Deprecated', 'mxchat'); ?>
258 <?php else: ?>
259 <?php echo esc_html(ucfirst($addon['license'])); ?>
260 <?php endif; ?>
261 </div>
262 <div class="mxchat-addon-content">
263 <h3 class="mxchat-addon-title"><?php echo esc_html($addon['title']); ?></h3>
264 <p class="mxchat-addon-description"><?php echo esc_html($addon['description']); ?></p>
265
266 <?php if (!empty($addon['key_benefits'])): ?>
267 <div class="mxchat-benefits-list">
268 <?php foreach ($addon['key_benefits'] as $benefit): ?>
269 <div class="mxchat-benefit-item">
270 <span class="mxchat-benefit-icon"></span>
271 <?php echo esc_html($benefit); ?>
272 </div>
273 <?php endforeach; ?>
274 </div>
275 <?php endif; ?>
276
277 <div class="mxchat-addon-footer">
278 <?php if ($is_deprecated): ?>
279 <div class="mxchat-status-indicator deprecated">
280 <?php esc_html_e('Now Built-in', 'mxchat'); ?>
281 </div>
282 <a href="<?php echo esc_url(admin_url('admin.php?page=mxchat-prompts')); ?>"
283 class="mxchat-action-button deprecated"
284 target="_self">
285 <?php esc_html_e('Go to Knowledge Tab', 'mxchat'); ?>
286 </a>
287 <?php else: ?>
288 <div class="mxchat-status-indicator <?php echo esc_attr($status_info['status']); ?>">
289 <?php echo esc_html(ucfirst(str_replace('-', ' ', $status_info['status']))); ?>
290 </div>
291 <a href="<?php echo esc_url($button_url); ?>"
292 class="mxchat-action-button"
293 target="<?php echo esc_attr($button_target); ?>"
294 data-action="<?php echo esc_attr($status_info['status']); ?>">
295 <?php echo esc_html($status_info['action_text']); ?>
296 </a>
297 <?php endif; ?>
298 </div>
299 </div>
300 </div>
301 <?php
302 }
303
304 }