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 / advanced.php

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

82 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Advanced Tab - Custom JavaScript API
4 */
5
6 if (!defined('ABSPATH')) {
7 exit;
8 }
9
10 function onwebchat_advanced_tab() {
11
12 // Handle form submissions
13 onwebchat_handle_advanced_actions();
14
15 $options = get_option('onwebchat_plugin_option');
16 $chatId = isset($options['text_string']) ? $options['text_string'] : '';
17 $onwebchatApi = get_option('onwebchat_plugin_option_api_code');
18 $onwebchatApi = str_replace('\\', '', $onwebchatApi);
19
20 ?>
21 <form action="admin.php?page=onwebchat_settings&tab=advanced" method="post">
22 <input type="hidden" name="action" value="save_advanced_settings">
23 <input type="hidden" name="chatId" value="<?php echo esc_attr($chatId); ?>">
24 <?php wp_nonce_field('on_web_chat_nonce'); ?>
25
26 <h2>Advanced Settings</h2>
27 <p>For advanced users. Add custom JavaScript to extend onWebChat functionality.</p>
28
29 <table class="form-table">
30 <tr>
31 <th scope="row">
32 <label for="onwebchat-api">Custom JavaScript API</label>
33 </th>
34 <td>
35 <textarea id="onwebchat-api" name="onwebchat-api" rows="12" class="large-text code"><?php echo esc_html($onwebchatApi); ?></textarea>
36 <p class="description">
37 Add custom JavaScript code to interact with the onWebChat API.<br>
38 Example: <code>onWebChat.set('name', 'John Doe');</code><br>
39 <a href="https://www.onwebchat.com/live-chat-api.php" target="_blank">View API Documentation</a>
40 </p>
41 </td>
42 </tr>
43 </table>
44
45 <div class="notice notice-info inline">
46 <p>
47 <strong>Note:</strong> Only add code here if you know what you're doing.
48 Incorrect JavaScript may break the chat widget.
49 </p>
50 </div>
51
52 <p class="submit">
53 <input type="submit" class="button button-primary" value="Save Advanced Settings">
54 </p>
55 </form>
56 <?php
57 }
58
59 /**
60 * Handle form submissions for advanced tab
61 */
62 function onwebchat_handle_advanced_actions() {
63
64 if (isset($_POST["action"]) && $_POST["action"] == "save_advanced_settings") {
65
66 if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'on_web_chat_nonce')) {
67 wp_die('Sorry, your nonce did not verify.');
68 }
69
70 if (!current_user_can('manage_options')) {
71 wp_die('Insufficient permissions.');
72 }
73
74 $onwebchatApi = isset($_POST["onwebchat-api"]) ? wp_kses_post($_POST["onwebchat-api"]) : '';
75
76 update_option('onwebchat_plugin_option_api_code', $onwebchatApi);
77
78 echo '<div class="notice notice-success"><p>Advanced settings saved successfully!</p></div>';
79 }
80 }
81
82