PluginProbe
LWS Tools / 2.6
LWS Tools v2.6
trunk 1.0 1.0.1 2.0 2.1 2.1.5 2.2 2.2.1 2.3 2.3.1 2.4 2.4.1 2.4.2 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5 2.6 2.6.1 2.6.1.5 2.6.2 2.6.3 2.6.4
lws-tools / ia / ia_tab.php

ia_tab.php in LWS Tools 2.6, at ia/ia_tab.php

243 lines 10.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 $arr = array('strong' => array());
3 ?>
4
5 <!-- Beginning main content block -->
6 <div class="lws_tk_main_bloc">
7
8 <div class="lwstk_title_banner">
9 <div class="lwstk_top_banner">
10 <img src="<?php echo esc_url(plugins_url('images/plugin_lws_tools_logo.svg', __DIR__)) ?>" alt="LWS Tools Logo" width="80px" height="80px">
11 <div class="lwstk_top_banner_text">
12 <div class="lwstk_top_title_block">
13 <div style="display: flex; flex-direction: column; gap: 15px;">
14 <div class="lwstk_top_title">
15 <span><?php echo esc_html('LWS Tools'); ?></span>
16 <span><?php esc_html_e('by', 'lws-tools'); ?></span>
17 <span class="logo_lws"></span>
18 </div>
19
20 <div class="lwstk_top_description">
21 <?php echo esc_html_e('LWS Tools offer toolkits and shortcuts to manage your WordPress website. It lets you secure and optimize your websites easily and visualize several useful informations about your server, website and database.', 'lws-tools'); ?>
22 </div>
23 </div>
24 <div class="lwstk_rate_block">
25 <div class="lwstk_top_rateus">
26 <?php echo esc_html_e('You like this plugin ? ', 'lws-tools'); ?>
27 <?php echo wp_kses(__('A <a href="https://wordpress.org/support/plugin/lws-tools/reviews/#new-post" target="_blank" class="link_to_rating_with_stars"><div class="lwstk_stars">�
28 �
29 �
30 �
31 �
32 </div> rating</a> will motivate us a lot.', 'lws-tools'), ['a' => ['class' => [], 'href' => [], 'target' => []], 'div' => ['class' => []]]); ?>
33 </div>
34 <div class="lwstk_bottom_rateus">
35 <img src="<?php echo esc_url(plugins_url('images/flamme.svg', __DIR__)) ?>" alt="Flamme Logo" width="16px" height="20px" style="margin-right: 5px;">
36 <?php echo wp_kses(__('<b>-15%</b> on our <a href="https://www.lws.fr/support/" target="_blank" class="link_to_support">WordPress hostings</a> with the code', 'lws-tools'), ['b' => [], 'a' => ['class' => [], 'href' => [], 'target' => []]]); ?>
37 <div class="lwstk_top_code">
38 WPEXT15
39 <img src="<?php echo esc_url(plugins_url('images/copier_new.svg', __DIR__)) ?>" alt="Logo Copy Element" width="15px" height="18px" onclick="lwstktimize_copy_clipboard(this)" readonly text="WPEXT15">
40 </div>
41 </div>
42 </div>
43 </div>
44 </div>
45 </div>
46 </div>
47
48 <!-- Home to the tabs + content + ads -->
49 <div class="lws_tk_main_content">
50 <!-- tabs + content -->
51 <div class="lws_tk_list_block_content">
52 <!-- Tabs -->
53 <div class="tab-pane main-tab-pane">
54 <div id="post-body" class="lws_tk_configpage">
55 <div class="lws_tk_div_title_plugins">
56 <h3 class="lws_tk_title_plugins"> <?php esc_html_e('IA Management', 'lws-tools'); ?></h3>
57 <p class="lws_tk_text_base">
58 <?php esc_html_e('', 'lws-tools'); ?>
59 </p>
60 </div>
61 <div class="lws_tk_tab_line">
62 <div class="lws_tk_tab" style="width: 100%;">
63 <label class="lws_tk_ia_label" for=''>
64 <?php esc_html_e('Activate the IA Chatbot', 'lws-tools'); ?>
65 <label class="mab_mml_ttbt_td_switch">
66 <input class="mab_mml_ttbt_input" name="ia_chatbot_state" id="ia_chatbot_state" type="checkbox" <?php echo (get_option('lws_tk_ia_chatbot_state', false) ? '' : 'checked'); ?>>
67 <span class="mab_mml_ttbt_td_s_slider round"></span>
68 </label>
69 </label>
70 </div>
71 </div>
72 </div>
73 </div>
74 </div>
75 </div>
76
77 <div id="lws_tk_popup_alerting"></div>
78
79 <script>
80 // Execute the function callback after ms milliseconds unless delay() is called again
81 function delay(callback, ms) {
82 var timer = 0;
83 return function() {
84 var context = this,
85 args = arguments;
86 clearTimeout(timer);
87 timer = setTimeout(function() {
88 callback.apply(context, args);
89 }, ms || 0);
90 };
91 }
92
93 function callPopup(type, content) {
94 // Get the element containing all popups
95 let alerting = document.getElementById('lws_tk_popup_alerting');
96 if (alerting == null) {
97 console.log(JSON.stringify({
98 'code': "POPUP_FAIL",
99 'data': "Failed to find alerting"
100 }));
101 return -1;
102 }
103
104 if (content == null) {
105 console.log(JSON.stringify({
106 'code': "POPUP_FAIL",
107 'data': "Failed to find content"
108 }));
109 return -1;
110 }
111
112 if (type == null) {
113 console.log(JSON.stringify({
114 'code': "POPUP_FAIL",
115 'data': "Failed to find type"
116 }));
117 return -1;
118 }
119
120 // No more than 4 popups at a time. Remove the oldest one
121 if (alerting.children.length > 4) {
122 let amount_popups = alerting.children;
123 let last = amount_popups.item(amount_popups.length - 1);
124 if (last != null) {
125 jQuery(last).animate({
126 'left': '150%'
127 }, 500, function() {
128 last.remove();
129 });
130 }
131 }
132
133 let number = alerting.children.length ?? 5;
134
135 alerting.insertAdjacentHTML('afterbegin', `<div class="lws_tk_information_popup" style="left: 150%;" id="lws_tk_information_popup_` + number + `"></div>`);
136 let popup = document.getElementById('lws_tk_information_popup_' + number);
137
138 if (popup == null) {
139 console.log(JSON.stringify({
140 'code': "POPUP_NOT_CREATED",
141 'data': "Failed to create the popup"
142 }));
143 return -1;
144 }
145
146 animation = ``;
147 switch (type) {
148 case 'success':
149 animation = `<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" /><path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" /></svg>`;
150 break;
151 case 'error':
152 animation = `
153 <svg class="crossmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"> <circle class="crossmark__circle" cx="26" cy="26" r="25" fill="none" stroke="red" stroke-width="2"></circle> <path class="crossmark__cross" fill="none" stroke="red" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" stroke-dasharray="36" stroke-dashoffset="36" d="M16 16 36 36 M36 16 16 36"> <animate attributeName="stroke-dashoffset" from="36" to="0" dur="0.5s" fill="freeze" /> </path></svg>`
154 break;
155 case 'warning':
156 animation = `<svg class="exclamation" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"> <circle class="exclamation__circle" cx="26" cy="26" r="25" fill="none" stroke="#FFD700" stroke-width="2"></circle> <text class="exclamation__mark" x="26" y="30" font-size="26" font-family="Arial" text-anchor="middle" fill="#FFD700" dominant-baseline="middle">!</text> <style> .exclamation__mark { animation: blink 1s ease-in-out 3; } @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } } </style> </svg>`;
157 break;
158 default:
159 animation = `<svg class="checkmark" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 52 52"><circle class="checkmark__circle" cx="26" cy="26" r="25" fill="none" /><path class="checkmark__check" fill="none" d="M14.1 27.2l7.1 7.2 16.7-16.8" /></svg>`;
160 break;
161 }
162
163 popup.insertAdjacentHTML('beforeend', `
164 <div class="lws_tk_information_popup_animation">` + animation + `</div>
165 <div class="lws_tk_information_popup_content">` + content + `</div>
166 <div id="lws_tk_close_popup_` + number + `" class="lws_tk_information_popup_close"><img src="<?php echo esc_url(plugins_url('images/fermer.svg', __DIR__)) ?>" alt="close button" width="10px" height="10px">
167 `)
168
169 jQuery(popup).animate({
170 'left': '0%'
171 }, 500);
172
173 popup.classList.add('popup_' + type);
174
175 let popup_button = document.getElementById('lws_tk_close_popup_' + number);
176 if (popup_button != null) {
177 popup_button.addEventListener('click', function() {
178 this.parentNode.remove();
179 })
180 }
181
182 popup.addEventListener('mouseover', delay(function() {
183 if (popup.matches(':hover')) {
184 return 0;
185 }
186 jQuery(this).animate({
187 'left': '150%'
188 }, 500, function() {
189 this.remove();
190 });
191 }, 5000));
192
193 popup.dispatchEvent(new Event('mouseover'));
194 }
195 </script>
196
197 <script>
198 document.getElementById('ia_chatbot_state').addEventListener('change', function() {
199 var isChecked = this.checked;
200
201 let ajaxRequest = jQuery.ajax({
202 url: ajaxurl,
203 type: "POST",
204 timeout: 120000,
205 context: document.body,
206 data: {
207 _ajax_nonce: "<?php echo esc_html(wp_create_nonce("ia_chatbot_nonce")); ?>",
208 action: 'update_ia_chatbot_state',
209 state: isChecked ? 1 : 0,
210 },
211
212 success: function(data) {
213 if (data === null || typeof data != 'string') {
214 return 0;
215 }
216
217 try {
218 var returnData = JSON.parse(data);
219 } catch (e) {
220 console.log(e);
221 returnData = {
222 'code': "NOT_JSON",
223 'data': "FAIL"
224 };
225 }
226
227 switch (returnData['code']) {
228 case 'SUCCESS':
229 callPopup('success', '<?php echo esc_html__('IA Chatbot state updated successfully.', 'lws-tools'); ?>');
230 break;
231 default:
232 callPopup('error', '<?php echo esc_html__('Error updating IA Chatbot state.', 'lws-tools'); ?>');
233 break;
234 }
235 },
236 error: function(error) {
237 callPopup('error', '<?php echo esc_html__('AJAX request failed.', 'lws-tools'); ?>');
238 console.log(error);
239 return 1;
240 }
241 });
242 });
243 </script>