PluginProbe
Live Chat & AI Chatbot – onWebChat / 3.5.1
Live Chat & AI Chatbot – onWebChat v3.5.1
3.9.2 3.9.3 3.9.1 3.9.0 3.8.4 3.8.2 3.8.1 3.8.0 3.7.2 3.7.1 3.7.0 3.6.0 3.5.5 trunk 1.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 All 48 releases
onwebchat / admin / tabs / chat.php

chat.php in Live Chat & AI Chatbot – onWebChat 3.5.1, at admin/tabs/chat.php

143 lines 5.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Chat Widget Tab - Display & Visibility Settings
4 */
5
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 function onwebchat_chat_tab() {
11
12 // Handle form submissions
13 onwebchat_handle_chat_actions();
14
15 $options = get_option('onwebchat_plugin_option');
16 $chatId = isset($options['text_string']) ? $options['text_string'] : '';
17 $pagesSelect = get_option('onwebchat_plugin_option_pages_select', 1);
18
19 ?>
20 <form action="admin.php?page=onwebchat_settings&tab=chat" method="post">
21 <input type="hidden" name="action" value="save_chat_settings">
22 <input type="hidden" name="chatId" value="<?php echo esc_attr($chatId); ?>">
23 <?php wp_nonce_field('on_web_chat_nonce'); ?>
24
25 <h2>Chat Widget Visibility</h2>
26 <p>Control where the chat widget appears on your website.</p>
27
28 <table class="form-table">
29 <tr>
30 <th scope="row">
31 <label for="pages-select">Display Options</label>
32 </th>
33 <td>
34 <select id="pages-select" name="pages-select" onchange="onwc_select_change()" style="width: 400px;">
35 <option value="1" <?php selected($pagesSelect, 1); ?>>
36 Show the chat widget on all pages
37 </option>
38 <option value="2" <?php selected($pagesSelect, 2); ?>>
39 Show the chat widget only on selected pages
40 </option>
41 <option value="3" <?php selected($pagesSelect, 3); ?>>
42 Hide the chat widget on selected pages
43 </option>
44 <option value="4" <?php selected($pagesSelect, 4); ?>>
45 Hide the chat widget on all pages
46 </option>
47 </select>
48 </td>
49 </tr>
50
51 <tr id="onwc_show_on_pages_row" style="display:none;">
52 <th scope="row">
53 <label for="showonpages">Show Only On</label>
54 </th>
55 <td>
56 <input id="showonpages" name="showonpages" type="text" class="regular-text"
57 value="<?php echo esc_attr(get_option('onwebchat_plugin_option_show_pages')); ?>" />
58 <p class="description">
59 Add multiple pages by separating them with a space. You can enter a full URL or just part of it.<br>
60 Example: <code>index price contact.php blog/</code>
61 </p>
62 </td>
63 </tr>
64
65 <tr id="onwc_hide_on_pages_row" style="display:none;">
66 <th scope="row">
67 <label for="hideonpages">Hide On</label>
68 </th>
69 <td>
70 <input id="hideonpages" name="hideonpages" type="text" class="regular-text"
71 value="<?php echo esc_attr(get_option('onwebchat_plugin_option_hide_pages')); ?>" />
72 <p class="description">
73 Add multiple pages by separating them with a space. You can enter a full URL or just part of it.<br>
74 Example: <code>index price contact.php blog/</code>
75 </p>
76 </td>
77 </tr>
78 </table>
79
80 <p class="submit">
81 <input type="submit" class="button button-primary" value="Save Chat Settings">
82 </p>
83 </form>
84
85 <script type="text/javascript">
86 function onwc_select_change() {
87 var e = document.getElementById("pages-select");
88 if (!e) return;
89
90 var selected = e.options[e.selectedIndex].value;
91 var showRow = document.getElementById("onwc_show_on_pages_row");
92 var hideRow = document.getElementById("onwc_hide_on_pages_row");
93
94 showRow.style.display = "none";
95 hideRow.style.display = "none";
96
97 if (selected == 2) {
98 showRow.style.display = "table-row";
99 } else if (selected == 3) {
100 hideRow.style.display = "table-row";
101 }
102 }
103
104 // Run on page load
105 document.addEventListener('DOMContentLoaded', function() {
106 onwc_select_change();
107 });
108 </script>
109 <?php
110 }
111
112 /**
113 * Handle form submissions for chat tab
114 */
115 function onwebchat_handle_chat_actions() {
116
117 if (isset($_POST["action"]) && $_POST["action"] == "save_chat_settings") {
118
119 if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'on_web_chat_nonce')) {
120 wp_die('Sorry, your nonce did not verify.');
121 }
122
123 if (!current_user_can('manage_options')) {
124 wp_die('Insufficient permissions.');
125 }
126
127 $pagesSelect = isset($_POST["pages-select"]) ? absint($_POST["pages-select"]) : 1;
128 $showOnPages = isset($_POST["showonpages"]) ? sanitize_text_field($_POST["showonpages"]) : '';
129 $hideOnPages = isset($_POST["hideonpages"]) ? sanitize_text_field($_POST["hideonpages"]) : '';
130
131 update_option('onwebchat_plugin_option_pages_select', $pagesSelect);
132
133 if ($pagesSelect == 2) {
134 update_option('onwebchat_plugin_option_show_pages', $showOnPages);
135 } else if ($pagesSelect == 3) {
136 update_option('onwebchat_plugin_option_hide_pages', $hideOnPages);
137 }
138
139 echo '<div class="notice notice-success"><p>Chat settings saved successfully!</p></div>';
140 }
141 }
142
143