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 / view / ia.php

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

68 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 <div class="lws_tk_div_title_plugins">
3 <h3 class="lws_tk_title_plugins"> <?php esc_html_e('AI Management', 'lws-tools'); ?></h3>
4 <p class="lws_tk_text_base" style="margin-bottom: 0;">
5 <?php esc_html_e('Ethan is your own virtual assistant, here to help you out while building your website. Ask him anything you want his help with, from creating a post to troubleshooting issues.', 'lws-tools'); ?>
6 </p>
7 </div>
8 <div class="lws_tk_tab_line lws_tk_tab_border lws_tk_tab_border_blue">
9 <div class="lws_tk_tab" style="width: 100%;">
10 <label class="lws_tk_ia_label" for=''>
11 <div>
12 <span><?php esc_html_e('Activate Ethan, the AI assistant', 'lws-tools'); ?></span>
13 </div>
14 <label class="mab_mml_ttbt_td_switch">
15 <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'); ?>>
16 <span class="mab_mml_ttbt_td_s_slider round"></span>
17 </label>
18 </label>
19 </div>
20 </div>
21
22 <script>
23 document.getElementById('ia_chatbot_state').addEventListener('change', function() {
24 var isChecked = this.checked;
25
26 let ajaxRequest = jQuery.ajax({
27 url: ajaxurl,
28 type: "POST",
29 timeout: 120000,
30 context: document.body,
31 data: {
32 _ajax_nonce: "<?php echo esc_html(wp_create_nonce("ia_chatbot_nonce")); ?>",
33 action: 'update_ia_chatbot_state',
34 state: isChecked ? 1 : 0,
35 },
36
37 success: function(data) {
38 if (data === null || typeof data != 'string') {
39 return 0;
40 }
41
42 try {
43 var returnData = JSON.parse(data);
44 } catch (e) {
45 console.log(e);
46 returnData = {
47 'code': "NOT_JSON",
48 'data': "FAIL"
49 };
50 }
51
52 switch (returnData['code']) {
53 case 'SUCCESS':
54 callPopup('success', '<?php echo esc_html__('IA Chatbot state updated successfully.', 'lws-tools'); ?>');
55 break;
56 default:
57 callPopup('error', '<?php echo esc_html__('Error updating IA Chatbot state.', 'lws-tools'); ?>');
58 break;
59 }
60 },
61 error: function(error) {
62 callPopup('error', '<?php echo esc_html__('Unknown error while updating IA Chatbot state.', 'lws-tools'); ?>');
63 console.log(error);
64 return 1;
65 }
66 });
67 });
68 </script>