PluginProbe
MxChat – AI Chatbot & Content Generation for WordPress / 2.2.9
MxChat – AI Chatbot & Content Generation for WordPress v2.2.9
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.2.9, at includes/class-mxchat-addons.php

319 lines 14.9 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. Customize colors, styles, and appearance with live previews—zero coding required. Perfect for matching your brand identity.', 'mxchat'),
25 'key_benefits' => array(
26 __('Live preview customizer', 'mxchat'),
27 __('Point-and-click simplicity', 'mxchat'),
28 __('Brand-perfect styling', '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 'mxchat-forms' => array(
52 'title' => __('MxChat Forms', 'mxchat'),
53 'description' => __('Convert conversations into data collection. Create smart forms that trigger during chats, collect user information, and turn casual visitors into qualified leads.', 'mxchat'),
54 'key_benefits' => array(
55 __('No-code form builder', 'mxchat'),
56 __('Intent-triggered activation', 'mxchat'),
57 __('Export lead data easily', 'mxchat')
58 ),
59 'license' => 'MxChat PRO',
60 'accent' => '#fa73e6',
61 'url' => 'https://quickdeploywp.com/plugin/mxchat-forms/',
62 'plugin_file' => 'mxchat-forms/mxchat-forms.php',
63 'config_page' => 'mxchat-forms'
64 ),
65 'mxchat-smart-recommender' => array(
66 'title' => __('MxChat Smart Recommender', 'mxchat'),
67 'description' => __('Turn your chatbot into a sales machine. Build personalized recommendation flows that understand user preferences and suggest perfect products or services.', 'mxchat'),
68 'key_benefits' => array(
69 __('Increase conversion rates', 'mxchat'),
70 __('Custom recommendation flows', 'mxchat'),
71 __('No coding required', 'mxchat')
72 ),
73 'license' => 'MxChat PRO',
74 'accent' => '#fa73e6',
75 'url' => 'https://quickdeploywp.com/plugin/mxchat-smart-recommender/',
76 'plugin_file' => 'mxchat-smart-recommender/mxchat-smart-recommender.php',
77 'config_page' => 'mxchat-smart-recommender'
78 ),
79 'mxchat-woo' => array(
80 'title' => __('MxChat WooCommerce', 'mxchat'),
81 'description' => __('Boost sales with AI-powered shopping assistance. Help customers find products, manage carts, and complete purchases—all through natural conversation.', 'mxchat'),
82 'key_benefits' => array(
83 __('Smart product recommendations', 'mxchat'),
84 __('Cart & checkout assistance', 'mxchat'),
85 __('Order history access', 'mxchat')
86 ),
87 'license' => 'MxChat PRO',
88 'accent' => '#fa73e6',
89 'url' => 'https://quickdeploywp.com/plugin/mxchat-woo/',
90 'plugin_file' => 'mxchat-woo/mxchat-woo.php',
91 'config_page' => 'mxchat-woo'
92 ),
93 'mxchat-perplexity' => array(
94 'title' => __('MxChat Perplexity', 'mxchat'),
95 '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'),
96 'key_benefits' => array(
97 __('Real-time web search', 'mxchat'),
98 __('Intent-triggered research', 'mxchat'),
99 __('Up-to-date information', 'mxchat')
100 ),
101 'license' => 'MxChat PRO',
102 'accent' => '#fa73e6',
103 'url' => 'https://quickdeploywp.com/plugin/mxchat-perplexity/',
104 'plugin_file' => 'mxchat-perplexity/mxchat-perplexity.php',
105 'config_page' => 'mxchat-perplexity'
106 ),
107 'mxchat-moderation' => array(
108 'title' => __('MxChat Moderation', 'mxchat'),
109 'description' => __('Keep your chat clean and professional. Block unwanted users, filter inappropriate content, and ensure your chatbot represents your brand properly.', 'mxchat'),
110 'key_benefits' => array(
111 __('IP & email-based blocking', 'mxchat'),
112 __('Content filtering', 'mxchat'),
113 __('Spam protection', 'mxchat')
114 ),
115 'license' => 'MxChat PRO',
116 'accent' => '#fa73e6',
117 'url' => 'https://quickdeploywp.com/plugin/mxchat-moderation/',
118 'plugin_file' => 'mxchat-moderation/mx-chat-moderation.php',
119 'config_page' => 'mx-chat-moderation'
120 ),
121
122 'mxchat-intent-tester' => array(
123 'title' => __('MxChat Similarity Tester', 'mxchat'),
124 'description' => __('See exactly how your chatbot thinks. Visualize intent matches and similarity scores to optimize accuracy and understand AI decision-making. Essential for fine-tuning your responses.', 'mxchat'),
125 'key_benefits' => array(
126 __('Reveal top 10 knowledge matches', 'mxchat'),
127 __('Optimize response accuracy', 'mxchat'),
128 __('Debug AI decision patterns', 'mxchat')
129 ),
130 'license' => 'free',
131 'accent' => '#fa73e6',
132 'url' => 'https://quickdeploywp.com/plugin/mxchat-intent-tester/',
133 'plugin_file' => 'mxchat-intent-tester/mxchat-intent-tester.php',
134 'config_page' => 'mxchat-intent-tester'
135 ),
136
137 'mxchat-pinecone' => array(
138 'title' => __('Pinecone DB Manager (Deprecated)', 'mxchat'),
139 'description' => __('This add-on has been sunsetted and is now included directly in the core MxChat plugin. Find Pinecone settings under the Knowledge tab in Pinecone Settings.', 'mxchat'),
140 'key_benefits' => array(
141 __('Now integrated into core plugin', 'mxchat'),
142 __('Access via Knowledge tab', 'mxchat'),
143 __('No separate installation needed', 'mxchat')
144 ),
145 'license' => 'free',
146 'accent' => '#fa73e6',
147 'url' => 'https://quickdeploywp.com/plugin/mxchat-pinecone/',
148 'plugin_file' => 'mxchat-pinecone/pinecone-manager.php',
149 'config_page' => 'mxchat-pinecone',
150 'status' => 'deprecated'
151 ),
152 );
153 }
154
155 /**
156 * Register the stylesheets for the admin area.
157 */
158 public function enqueue_styles() {
159 $plugin_version = '2.2.9';
160
161 wp_enqueue_style(
162 'mxchat-addons',
163 plugin_dir_url(__FILE__) . '../css/admin-add-ons.css',
164 array(),
165 $plugin_version,
166 'all'
167 );
168 }
169
170 /**
171 * Check if an addon is installed and active
172 *
173 * @param string $plugin_file The plugin's main file path
174 * @return array Status information
175 */
176 private function get_addon_status($plugin_file) {
177 if (!function_exists('get_plugins')) {
178 require_once ABSPATH . 'wp-admin/includes/plugin.php';
179 }
180
181 $all_plugins = get_plugins();
182 $active_plugins = get_option('active_plugins', array());
183
184 // Find the addon by iterating through configs
185 $config_page = '';
186 foreach ($this->addons_config as $slug => $addon) {
187 if ($addon['plugin_file'] === $plugin_file) {
188 $config_page = $addon['config_page'];
189 break;
190 }
191 }
192
193 if (isset($all_plugins[$plugin_file])) {
194 if (in_array($plugin_file, $active_plugins)) {
195 return array(
196 'status' => 'active',
197 'action_url' => admin_url('admin.php?page=' . $config_page),
198 'action_text' => __('Configure', 'mxchat')
199 );
200 } else {
201 return array(
202 'status' => 'inactive',
203 'action_url' => wp_nonce_url(
204 admin_url('plugins.php?action=activate&plugin=' . $plugin_file),
205 'activate-plugin_' . $plugin_file
206 ),
207 'action_text' => __('Activate', 'mxchat')
208 );
209 }
210 }
211
212 return array(
213 'status' => 'not-installed',
214 'action_url' => '',
215 'action_text' => __('Get Extension', 'mxchat')
216 );
217 }
218
219 /**
220 * Render the Add Ons page content.
221 */
222 public function render_page() {
223 $this->enqueue_styles();
224 // Remove the sorting logic and just use the original order
225 $sorted_addons = $this->addons_config;
226
227 ?>
228 <div class="wrap mxchat-addons-wrapper">
229 <div class="mxchat-addons-hero">
230 <h1 class="mxchat-main-title">
231 <span class="mxchat-gradient-text">Power Up</span> Your Chatbot
232 </h1>
233 <p class="mxchat-hero-subtitle">
234 <?php esc_html_e('Supercharge your WordPress AI chatbot with these powerful extensions. Start with our free add-ons or upgrade for premium features.', 'mxchat'); ?>
235 </p>
236 </div>
237
238 <div class="mxchat-addons-section">
239 <div class="mxchat-addons-grid">
240 <?php foreach ($sorted_addons as $slug => $addon): ?>
241 <?php $this->render_addon_card($slug, $addon); ?>
242 <?php endforeach; ?>
243 </div>
244 </div>
245
246 <div class="mxchat-cta-section">
247 <h2><?php esc_html_e('Ready to take your chatbot to the next level?', 'mxchat'); ?></h2>
248 <p><?php esc_html_e('Get MxChat PRO today and access all premium extensions at one low price.', 'mxchat'); ?></p>
249 <a href="https://mxchat.ai/" class="mxchat-cta-button" target="_blank"><?php esc_html_e('Learn More', 'mxchat'); ?></a>
250 </div>
251 </div>
252 <?php
253 }
254
255 /**
256 * Render individual add-on card
257 *
258 * @param string $slug The addon slug
259 * @param array $addon The addon configuration array
260 */
261 private function render_addon_card($slug, $addon) {
262 $status_info = $this->get_addon_status($addon['plugin_file']);
263 $button_url = $status_info['status'] === 'not-installed' ? $addon['url'] : $status_info['action_url'];
264 $button_target = $status_info['status'] === 'not-installed' ? '_blank' : '_self';
265
266 // Check if addon is deprecated
267 $is_deprecated = isset($addon['status']) && $addon['status'] === 'deprecated';
268 ?>
269 <div class="mxchat-addon-card <?php echo $is_deprecated ? 'deprecated' : ''; ?>" style="--card-accent: <?php echo esc_attr($addon['accent']); ?>">
270 <div class="mxchat-addon-badge">
271 <?php if ($is_deprecated): ?>
272 <?php esc_html_e('Deprecated', 'mxchat'); ?>
273 <?php else: ?>
274 <?php echo esc_html(ucfirst($addon['license'])); ?>
275 <?php endif; ?>
276 </div>
277 <div class="mxchat-addon-content">
278 <h3 class="mxchat-addon-title"><?php echo esc_html($addon['title']); ?></h3>
279 <p class="mxchat-addon-description"><?php echo esc_html($addon['description']); ?></p>
280
281 <?php if (!empty($addon['key_benefits'])): ?>
282 <div class="mxchat-benefits-list">
283 <?php foreach ($addon['key_benefits'] as $benefit): ?>
284 <div class="mxchat-benefit-item">
285 <span class="mxchat-benefit-icon"></span>
286 <?php echo esc_html($benefit); ?>
287 </div>
288 <?php endforeach; ?>
289 </div>
290 <?php endif; ?>
291
292 <div class="mxchat-addon-footer">
293 <?php if ($is_deprecated): ?>
294 <div class="mxchat-status-indicator deprecated">
295 <?php esc_html_e('Now Built-in', 'mxchat'); ?>
296 </div>
297 <a href="<?php echo esc_url(admin_url('admin.php?page=mxchat-prompts')); ?>"
298 class="mxchat-action-button deprecated"
299 target="_self">
300 <?php esc_html_e('Go to Knowledge Tab', 'mxchat'); ?>
301 </a>
302 <?php else: ?>
303 <div class="mxchat-status-indicator <?php echo esc_attr($status_info['status']); ?>">
304 <?php echo esc_html(ucfirst(str_replace('-', ' ', $status_info['status']))); ?>
305 </div>
306 <a href="<?php echo esc_url($button_url); ?>"
307 class="mxchat-action-button"
308 target="<?php echo esc_attr($button_target); ?>"
309 data-action="<?php echo esc_attr($status_info['status']); ?>">
310 <?php echo esc_html($status_info['action_text']); ?>
311 </a>
312 <?php endif; ?>
313 </div>
314 </div>
315 </div>
316 <?php
317 }
318
319 }