Tawk.To Live Chat - Version 0.4.0

Version Description

  • Added support for wildcard url match for include URL and exclude URL

Frequently Asked Questions

Download this release

Release Info

Developer tawkto
Plugin Icon 128x128 Tawk.To Live Chat
Version 0.4.0
Comparing to
See all releases

Version 0.4.0

assets/tawk.admin.css ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .form-table th.tawksetting {
2
+ width: 350px;
3
+ }
4
+
5
+ .tawknotice{
6
+ font-size:14px;
7
+ }
8
+
9
+ .tawkheader{
10
+ overflow: hidden;
11
+ border-style: solid;
12
+ border-color: #ccc;
13
+ border-width:1px 1px 0 1px;
14
+ background-color: #ffffff;
15
+ width:95%;
16
+ margin-top:20px;
17
+ padding: 6px 12px 0;
18
+ font-size:2em;
19
+ }
20
+
21
+ div.tawkmel{
22
+ float:left;
23
+ width:10%;
24
+ min-width: 75px;
25
+ min-height: 80px;
26
+ text-align: center;
27
+ }
28
+
29
+ div.tawkheadtext{
30
+ float:left;
31
+ line-height: 86px;
32
+ }
33
+
34
+ div.tawkfootaction{
35
+ float:left;
36
+ width:10%;
37
+ min-width: 75px;
38
+ }
39
+
40
+ div.tawkfoottext{
41
+ float:right;
42
+ text-align: right;
43
+ }
44
+
45
+ a.tawklink{
46
+ color:#7FB06F;
47
+ text-decoration: none;
48
+ }
49
+
50
+ a.tawklink:hover{
51
+ text-decoration: underline;
52
+ }
53
+
54
+
55
+ div.tawkaction{
56
+ overflow: hidden;
57
+ border: 1px solid #ccc;
58
+ background-color: #ffffff;
59
+ width:95%;
60
+ padding: 6px 12px;
61
+ }
62
+
63
+ div.tawkaction p{
64
+ margin:0;
65
+ padding:0;
66
+ }
67
+
68
+ .tawksettingsbody{
69
+ overflow: hidden;
70
+ border-style: solid;
71
+ border-color: #ccc;
72
+ border-width:0 1px 0 1px;
73
+ background-color: #ffffff;
74
+ width:95%;
75
+ padding: 0 24px 0 0;
76
+ }
77
+
78
+ div.tawktabs {
79
+ float:left;
80
+ overflow: hidden;
81
+ background-color: #ffffff;
82
+ width:10%;
83
+ min-width: 75px;
84
+ }
85
+
86
+
87
+ div.tawktabs button {
88
+ background-color: inherit;
89
+ float: left;
90
+ border: none;
91
+ outline: none;
92
+ cursor: pointer;
93
+ padding: 14px 0;
94
+ transition: 0.3s;
95
+ width:100%;
96
+ }
97
+
98
+ div.tawktabs button:hover {
99
+ background-color: #ddd;
100
+ color:#0085BA;
101
+ }
102
+
103
+ div.tawktabs button.active {
104
+ background-color: #f1f1f1;
105
+ }
106
+
107
+ .tawktabcontent {
108
+ float:left;
109
+ display: none;
110
+ padding: 6px 12px;
111
+ background-color: #ffffff;
112
+
113
+ border-style: solid;
114
+ border-color: #ccc;
115
+ border-width:0 0 0 1px;
116
+
117
+ border-top: none;
118
+ width:85%;
119
+ min-width: 240px;
120
+ }
121
+
122
+
123
+ .switch {
124
+ position: relative;
125
+ display: inline-block;
126
+ width: 60px;
127
+ height: 34px;
128
+ }
129
+
130
+ .switch input {display:none;}
131
+
132
+
133
+ .slider {
134
+ position: absolute;
135
+ cursor: pointer;
136
+ top: 0;
137
+ left: 0;
138
+ right: 0;
139
+ bottom: 0;
140
+ background-color: #ccc;
141
+ -webkit-transition: .4s;
142
+ transition: .4s;
143
+ }
144
+
145
+ .slider:before {
146
+ position: absolute;
147
+ content: "";
148
+ height: 26px;
149
+ width: 26px;
150
+ left: 4px;
151
+ bottom: 4px;
152
+ background-color: white;
153
+ -webkit-transition: .4s;
154
+ transition: .4s;
155
+ }
156
+
157
+ input:checked + .slider {
158
+ background-color: #2196F3;
159
+ }
160
+
161
+ input:focus + .slider {
162
+ box-shadow: 0 0 1px #2196F3;
163
+ }
164
+
165
+ input:checked + .slider:before {
166
+ -webkit-transform: translateX(26px);
167
+ -ms-transform: translateX(26px);
168
+ transform: translateX(26px);
169
+ }
170
+
171
+ .slider.round {
172
+ border-radius: 34px;
173
+ }
174
+
175
+ .slider.round:before {
176
+ border-radius: 50%;
177
+ }
178
+
179
+ #exlucded_urls_container,
180
+ #included_urls_container{
181
+ padding:15px;
182
+ }
assets/tawk.admin.js ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function() {
2
+ document.getElementById("defaultOpen").click();
3
+
4
+ console.log(jQuery("#always_display").prop("checked"));
5
+ if(jQuery("#always_display").prop("checked")){
6
+ jQuery('.twk_selected_display').hide();
7
+ jQuery('#show_onfrontpage').prop('disabled', true);
8
+ jQuery('#show_oncategory').prop('disabled', true);
9
+ jQuery('#show_ontagpage').prop('disabled', true);
10
+ jQuery('#show_onarticlepages').prop('disabled', true);
11
+ jQuery('#include_url').prop('disabled', true);
12
+ }else{
13
+ jQuery('.twk_selected_display').show();
14
+
15
+ }
16
+
17
+ jQuery("#always_display").change(function() {
18
+ if(this.checked){
19
+ jQuery('.twk_selected_display').fadeOut();
20
+ jQuery('#show_onfrontpage').prop('disabled', true);
21
+ jQuery('#show_oncategory').prop('disabled', true);
22
+ jQuery('#show_ontagpage').prop('disabled', true);
23
+ jQuery('#show_onarticlepages').prop('disabled', true);
24
+ jQuery('#include_url').prop('disabled', true);
25
+ }else{
26
+ jQuery('.twk_selected_display').fadeIn();
27
+ jQuery('#show_onfrontpage').prop('disabled', false);
28
+ jQuery('#show_oncategory').prop('disabled', false);
29
+ jQuery('#show_ontagpage').prop('disabled', false);
30
+ jQuery('#show_onarticlepages').prop('disabled', false);
31
+ jQuery('#include_url').prop('disabled', false);
32
+ }
33
+ });
34
+
35
+
36
+ jQuery("#exclude_url").change(function() {
37
+ if(this.checked){
38
+ jQuery("#exlucded_urls_container").fadeIn();
39
+ }else{
40
+ jQuery("#exlucded_urls_container").fadeOut();
41
+ }
42
+ });
43
+
44
+ if(jQuery("#include_url").prop("checked")){
45
+ jQuery("#included_urls_container").show();
46
+ }
47
+
48
+ jQuery("#include_url").change(function() {
49
+ if(this.checked){
50
+ jQuery("#included_urls_container").fadeIn();
51
+ }else{
52
+ jQuery("#included_urls_container").fadeOut();
53
+ }
54
+ });
55
+
56
+ if(jQuery("#exclude_url").prop("checked")){
57
+ jQuery("#exlucded_urls_container").fadeIn();
58
+ }
59
+
60
+ });
61
+
62
+
63
+ function opentab(evt, tabName) {
64
+ // Declare all variables
65
+ var i, tabcontent, tablinks;
66
+
67
+ tabcontent = document.getElementsByClassName("tawktabcontent");
68
+ for (i = 0; i < tabcontent.length; i++) {
69
+ tabcontent[i].style.display = "none";
70
+ }
71
+
72
+ tablinks = document.getElementsByClassName("tawktablinks");
73
+ for (i = 0; i < tablinks.length; i++) {
74
+ tablinks[i].className = tablinks[i].className.replace(" active", "");
75
+ }
76
+
77
+ document.getElementById(tabName).style.display = "block";
78
+ evt.currentTarget.className += " active";
79
+ }
assets/tawky_big.png ADDED
Binary file
index.php ADDED
File without changes
readme.txt ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === Tawk.To Live Chat ===
2
+ Contributors: tawkto
3
+ Tags: tawk,tawk.to,tawkto,chat,free chat,livechat,chat widget,plugin,chat for web,chat online,chat software,free live chat,IM Chat,,live chat,live support,live web chat,online chat,online support,snapengage,wordpress chat,wordpress live chat
4
+ Requires at least: 2.7
5
+ Tested up to: 5.2.2
6
+ Stable tag: 0.4.0
7
+
8
+ (OFFICIAL tawk.to plugin) Instantly chat with visitors on your website with the free tawk.to chat widget.
9
+ Website: [http://tawk.to](http://tawk.to)
10
+ == Description ==
11
+
12
+ Over 2,200,000+ business users use the tawk.to FREE live chat app that lets you monitor and chat with visitors on your Wordpress site. No catch. No spam. No Ads. It's truly free and always will be.
13
+
14
+ * Gain valuable insight when you monitor your website visitors in real time.
15
+ * Stay connected anywhere, be in touch with your customers from your computer, or your mobile.
16
+ * Live Chat is convenient for your customers, helping them through pain points and as a result helping you generate better customer support and higher conversions.
17
+
18
+ [youtube https://www.youtube.com/watch?v=G7o8x5gj2ww]
19
+
20
+ tawk.to is designed to increase the effectiveness in managing the online customer engagement experience, enabling multiple websites and agents in a single dashboard interface to chat with the visitors on your website.
21
+
22
+ Compatible with all modern browsers, tawk.to is free live chat software created out of the growing need for businesses to respond in real time, with real people.
23
+
24
+ Tawk.to offers free iOS, Android, Windows and Mac OSX apps to stay connected, or you can log in via any modern browser.
25
+
26
+ = Why use tawk.to? =
27
+
28
+ tawk.to is a free live chat app which integrates seamlessly with Wordpress! More than 250000 companies use tawk.to to provide real time support and service to their customers. Never lose another lead or sale again, with tawk.to you can monitor and chat with your website visitors when they need it most.
29
+
30
+ = How much does this cost? =
31
+
32
+ This tawk.to app is completely free.
33
+
34
+ = Support =
35
+
36
+ tawk.to offers 24x7-365 live support, visit https://www.tawk.to and initiate a chat or send us an email at support@tawk.to.
37
+
38
+ Don't have a tawk.to account ? [Create one for free here!](https://www.tawk.to/?utm_source=wpdirectory&utm_medium=link&utm_campaign=signup)
39
+
40
+ == Installation ==
41
+
42
+ Adding tawk.to live chat widget to your Wordpress site is really easy, follow these steps :
43
+
44
+ * Clone this repository into your plugins directory or download the zip file and unzip on your plugins directory
45
+ * or Install the Free plugin from the WordPress directory and activate it.
46
+ * Go to `Settings`, then to the `Tawk.to` sub menu, and login to your tawk.to account to select a widget.
47
+ * Customize the chat widget from within the [tawk.to dashboard](https://dashboard.tawk.to) to your preference.
48
+ * Start chatting with your visitors! :)
49
+
50
+ Note: You will need a free tawk.to account : [Create one for free here!](https://tawk.to/?utm_source=wpdirectory&utm_medium=link&utm_campaign=signup)
51
+
52
+ == Changelog ==
53
+
54
+ = 0.1.0 =
55
+ * Add the tawk.to live chat widget to your site!
56
+
57
+ = 0.1.1 =
58
+ * No more manual embed code copying, choose desired widget and it will be inserted in your site
59
+
60
+ = 0.1.2 =
61
+ * Supported version bump
62
+
63
+ = 0.1.3 =
64
+ * Supported version bump
65
+
66
+ = 0.1.4 =
67
+ * Supported version bump
68
+
69
+ = 0.1.5 =
70
+ * Implemented visibility options, you can now choose to Always show the script, show it only on the front page, only on category pages or only on pages tagged with a shortcode.
71
+
72
+ = 0.1.6 =
73
+ * Modified visibility options to fix a bug, and implemented a better shortcode.
74
+
75
+ = 0.1.7 =
76
+ * Fixed naming convention causing a conflict with another plugin
77
+
78
+ = 0.1.8 =
79
+ * Fixed bug causing conflict with another plugin, and tested on 4.5
80
+
81
+ = 0.1.9 =
82
+ * Added the ability to exclude a specific url slug
83
+
84
+ = 0.2.0 =
85
+ * Added multisite support *
86
+
87
+ = 0.2.1 =
88
+ * Supported version bump
89
+
90
+ = 0.2.2 =
91
+ * Supported version bump to 4.7
92
+
93
+ = 0.2.3 =
94
+ * Updating widget code due to known conflict
95
+
96
+ = 0.2.4 =
97
+ * updated session handling
98
+ * Added the ability to include a specific url slug
99
+ * modified plugin settings page interface
100
+
101
+ = 0.2.5 =
102
+ * Fixed include url warning message thrown
103
+
104
+ = 0.2.6 =
105
+ * wrapped all hard-coded text in plugin settings with gettext functions
106
+
107
+ = 0.2.7 =
108
+ * added woocommerce support
109
+
110
+ = 0.2.8 =
111
+ * added updated plugin admin interface
112
+
113
+ = 0.2.9 =
114
+ * fixed issue with assets folder
115
+
116
+ = 0.3.0 =
117
+ * fixed issues with visibility filters
118
+
119
+ = 0.3.0 =
120
+ * fixed issues with visibility filters
121
+
122
+ = 0.3.1 =
123
+ * plugin notifications update
124
+ * logged in user recognition
125
+ If user is logged in, the widget will fill the pre-chat form automatically
126
+
127
+ = 0.3.2 =
128
+ * fixed issues on widget settings on fresh install
129
+
130
+ = 0.3.3 =
131
+ * fixed user recognition vulnerability
132
+ * updated admin page texts
133
+ * moved wp_footer hook to last item
134
+
135
+ = 0.3.4 =
136
+ * supported version bump
137
+
138
+ = 0.3.5 =
139
+ * supported version bump
140
+
141
+ = 0.3.6 =
142
+ * supported version bump 5.1
143
+
144
+ = 0.3.7 =
145
+ * supported version bump 5.2.1
146
+
147
+ = 0.3.8 =
148
+ * supported version bump 5.2.2
149
+
150
+ = 0.4.0 =
151
+ * Added support for wildcard url match for include URL and exclude URL
152
+
153
+ ## Frequently Asked Questions
154
+
155
+ = How much does this cost? =
156
+
157
+ This tawk.to app is completely free.
158
+
159
+ = Do you provide support? =
160
+
161
+ Yes, we provide 24x7-365 real time support via both live chat and email. We never close.
162
+
163
+ = Can I choose which pages to put the widget on? =
164
+
165
+ Yes, you can use the visibility options in the Plugin settings to select specific pages, or you can show the tawk.to widget on any page independent of the visibility options by simply using the [tawkto] shortcode in the post or page.
166
+
167
+ = Can I customize the widget design =
168
+
169
+ Yes, you can customize colors, content, border radius, position etc. You can even select one of 27 different languages, add Attention Grabbing bubbles etc.
170
+
171
+ = Can I schedule when the widget will be shown? =
172
+
173
+ Yes, there is a complete widget scheduler.
174
+
175
+ = Do you have any documentation or support articles? =
176
+
177
+ Yes, we have a very detailed Knowledge Base, which includes videos & tutorials on all the features of tawk.to [https://www.tawk.to/knowledgebase/](https://www.tawk.to/knowledgebase/)
178
+
179
+ = Can multiple users chat at one time? =
180
+
181
+ Yes, you can add an unlimited number of Agents to your account so that your entire team can chat with your website visitors. Tawk.to also has a Departments feature, to group your agents. Eg: Sales, Support etc.
182
+
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
tawkto.php ADDED
@@ -0,0 +1,384 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Tawk.to Live Chat
4
+ Plugin URI: https://www.tawk.to
5
+ Description: Embeds Tawk.to live chat widget to your site
6
+ Version: 0.3.8
7
+ Author: Tawkto
8
+ Text Domain: tawk-to-live-chat
9
+ */
10
+ if(!class_exists('TawkTo_Settings')){
11
+
12
+ class TawkTo_Settings{
13
+ const TAWK_WIDGET_ID_VARIABLE = 'tawkto-embed-widget-widget-id';
14
+ const TAWK_PAGE_ID_VARIABLE = 'tawkto-embed-widget-page-id';
15
+ const TAWK_VISIBILITY_OPTIONS = 'tawkto-visibility-options';
16
+
17
+ public function __construct(){
18
+
19
+ if(!get_option('tawkto-visibility-options',false))
20
+ {
21
+ $visibility = array (
22
+ 'always_display' => 1,
23
+ 'show_onfrontpage' => 0,
24
+ 'show_oncategory' => 0,
25
+ 'show_ontagpage' => 0,
26
+ 'show_onarticlepages' => 0,
27
+ 'exclude_url' => 0,
28
+ 'excluded_url_list' => '',
29
+ 'include_url' => 0,
30
+ 'included_url_list' => '',
31
+ 'display_on_shop' => 0,
32
+ 'display_on_productcategory' => 0,
33
+ 'display_on_productpage' => 0,
34
+ 'display_on_producttag' => 0
35
+ );
36
+ update_option( 'tawkto-visibility-options', $visibility);
37
+ }
38
+
39
+ add_action('admin_init', array(&$this, 'admin_init'));
40
+ add_action('admin_menu', array(&$this, 'add_menu'));
41
+ add_action('wp_ajax_tawkto_setwidget', array(&$this, 'action_setwidget'));
42
+ add_action('wp_ajax_tawkto_removewidget', array(&$this, 'action_removewidget'));
43
+ #add_action('admin_head', array(&$this,'tawk_custom_admin_style') );
44
+
45
+ add_action('admin_enqueue_scripts', array($this,'tawk_settings_assets') );
46
+ add_action( 'admin_notices', array($this,'tawk_admin_notice') );
47
+ }
48
+
49
+ public function tawk_settings_assets($hook)
50
+ {
51
+ if($hook != 'settings_page_tawkto_plugin')
52
+ return;
53
+
54
+ wp_register_style( 'tawk_admin_style', plugins_url( 'assets/tawk.admin.css' , __FILE__ ) );
55
+ wp_enqueue_style( 'tawk_admin_style' );
56
+
57
+ wp_enqueue_script( 'tawk_admin_script', plugins_url( 'assets/tawk.admin.js' , __FILE__ ) );
58
+
59
+ }
60
+
61
+ public function admin_init(){
62
+ register_setting( 'tawk_options', 'tawkto-visibility-options', array(&$this,'validate_options') );
63
+ }
64
+
65
+ public function action_setwidget() {
66
+ header('Content-Type: application/json');
67
+
68
+ if (!isset($_POST['pageId']) || !isset($_POST['widgetId'])) {
69
+ echo json_encode(array('success' => FALSE));
70
+ die();
71
+ }
72
+
73
+ if (!self::ids_are_correct($_POST['pageId'], $_POST['widgetId'])) {
74
+ echo json_encode(array('success' => FALSE));
75
+ die();
76
+ }
77
+
78
+ update_option(self::TAWK_PAGE_ID_VARIABLE, $_POST['pageId']);
79
+ update_option(self::TAWK_WIDGET_ID_VARIABLE, $_POST['widgetId']);
80
+
81
+
82
+ echo json_encode(array('success' => TRUE));
83
+ die();
84
+ }
85
+
86
+ function tawk_admin_notice() {
87
+
88
+ if( isset($_GET["settings-updated"]) )
89
+ {
90
+ ?>
91
+ <div class="notice notice-warning is-dismissible">
92
+ <p><?php _e( 'You might need to clear cache if your using a cache plugin to see your updates', 'tawk-to-live-chat' ); ?></p>
93
+ </div>
94
+ <?php
95
+ }
96
+ }
97
+
98
+ public function action_removewidget() {
99
+ header('Content-Type: application/json');
100
+
101
+ update_option(self::TAWK_PAGE_ID_VARIABLE, '');
102
+ update_option(self::TAWK_WIDGET_ID_VARIABLE, '');
103
+
104
+ echo json_encode(array('success' => TRUE));
105
+ die();
106
+ }
107
+
108
+ public function validate_options($input){
109
+
110
+ $input['always_display'] = ($input['always_display'] != '1')? 0 : 1;
111
+ $input['show_onfrontpage'] = ($input['show_onfrontpage'] != '1')? 0 : 1;
112
+ $input['show_oncategory'] = ($input['show_oncategory'] != '1')? 0 : 1;
113
+ $input['show_ontagpage'] = ($input['show_ontagpage'] != '1')? 0 : 1;
114
+ $input['show_onarticlepages'] = ($input['show_onarticlepages'] != '1')? 0 : 1;
115
+ $input['exclude_url'] = ($input['exclude_url'] != '1')? 0 : 1;
116
+ $input['excluded_url_list'] = sanitize_text_field($input['excluded_url_list']);
117
+ $input['include_url'] = ($input['include_url'] != '1')? 0 : 1;
118
+ $input['included_url_list'] = sanitize_text_field($input['included_url_list']);
119
+ $input['display_on_shop'] = ($input['display_on_shop'] != '1')? 0 : 1;
120
+ $input['display_on_productcategory'] = ($input['display_on_productcategory'] != '1')? 0 : 1;
121
+ $input['display_on_productpage'] = ($input['display_on_productpage'] != '1')? 0 : 1;
122
+ $input['display_on_producttag'] = ($input['display_on_producttag'] != '1')? 0 : 1;
123
+
124
+ return $input;
125
+ }
126
+
127
+ public function add_menu(){
128
+ add_options_page(
129
+ __('Tawk.to Settings','tawk-to-live-chat'),
130
+ __('Tawk.to','tawk-to-live-chat'),
131
+ 'manage_options',
132
+ 'tawkto_plugin',
133
+ array(&$this, 'create_plugin_settings_page')
134
+ );
135
+ }
136
+
137
+ public function tawk_custom_admin_style(){
138
+ echo '<style>
139
+ .form-table th.tawksetting {
140
+ width: 350px;
141
+ }
142
+ .tawknotice{
143
+ font-size:14px;
144
+ }
145
+ </style>';
146
+ }
147
+
148
+ public function create_plugin_settings_page(){
149
+
150
+ global $wpdb;
151
+
152
+ if(!current_user_can('manage_options')) {
153
+ wp_die(__('You do not have sufficient permissions to access this page.'));
154
+ }
155
+
156
+ $page_id = get_option(self::TAWK_PAGE_ID_VARIABLE);
157
+ $widget_id = get_option(self::TAWK_WIDGET_ID_VARIABLE);
158
+ $base_url = 'https://plugins.tawk.to';
159
+
160
+ $iframe_url = $base_url.'/generic/widgets'
161
+ .'?currentWidgetId='.$widget_id
162
+ .'&currentPageId='.$page_id
163
+ .'&transparentBackground=1';
164
+
165
+
166
+ include(sprintf("%s/templates/settings.php", dirname(__FILE__)));
167
+ }
168
+
169
+ public static function ids_are_correct($page_id, $widget_id) {
170
+ return preg_match('/^[0-9A-Fa-f]{24}$/', $page_id) === 1 && preg_match('/^[a-z0-9]{1,50}$/i', $widget_id) === 1;
171
+ }
172
+ }
173
+ }
174
+
175
+ if(!class_exists('TawkTo')){
176
+ class TawkTo{
177
+ public function __construct(){
178
+ $tawkto_settings = new TawkTo_Settings();
179
+ add_shortcode( 'tawkto', array($this,'shortcode_print_embed_code') );
180
+
181
+ }
182
+
183
+ public static function activate(){
184
+
185
+ $visibility = array (
186
+ 'always_display' => 1,
187
+ 'show_onfrontpage' => 0,
188
+ 'show_oncategory' => 0,
189
+ 'show_ontagpage' => 0,
190
+ 'show_onarticlepages' => 0,
191
+ 'exclude_url' => 0,
192
+ 'excluded_url_list' => '',
193
+ 'include_url' => 0,
194
+ 'included_url_list' => '',
195
+ 'display_on_shop' => 0,
196
+ 'display_on_productcategory' => 0,
197
+ 'display_on_productpage' => 0,
198
+ 'display_on_producttag' => 0
199
+ );
200
+
201
+ add_option(TawkTo_Settings::TAWK_PAGE_ID_VARIABLE, '', '', 'yes');
202
+ add_option(TawkTo_Settings::TAWK_WIDGET_ID_VARIABLE, '', '', 'yes');
203
+ add_option(TawkTo_Settings::TAWK_VISIBILITY_OPTIONS, $visibility, '', 'yes');
204
+ }
205
+
206
+ public static function deactivate(){
207
+ delete_option(TawkTo_Settings::TAWK_PAGE_ID_VARIABLE);
208
+ delete_option(TawkTo_Settings::TAWK_WIDGET_ID_VARIABLE);
209
+ delete_option(TawkTo_Settings::TAWK_VISIBILITY_OPTIONS);
210
+ }
211
+
212
+ public function shortcode_print_embed_code(){
213
+ add_action('wp_footer', array($this, 'embed_code'),100);
214
+ }
215
+
216
+ public function getCurrentCustomerDetails () {
217
+ if(is_user_logged_in() ){
218
+ $current_user = wp_get_current_user();
219
+ $user_info = array(
220
+ 'name' => $current_user->display_name,
221
+ 'email' => $current_user->user_email
222
+ );
223
+ return json_encode($user_info);
224
+ }
225
+ return NULL;
226
+ }
227
+
228
+ public function embed_code() {
229
+ $page_id = get_option('tawkto-embed-widget-page-id');
230
+ $widget_id = get_option('tawkto-embed-widget-widget-id');
231
+
232
+ $customer_details = $this->getCurrentCustomerDetails();
233
+
234
+ if (!empty($page_id) && !empty($widget_id)) {
235
+ include(sprintf("%s/templates/widget.php", dirname(__FILE__)));
236
+ }
237
+ }
238
+
239
+ private function get_current_url() {
240
+ $current_url = $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
241
+ $current_url = urldecode($current_url);
242
+
243
+ $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://';
244
+
245
+ return strtolower($protocol . $current_url);
246
+ }
247
+
248
+ private function match_url($url, $url_pattern) {
249
+ // do partial match if wildcard character matched at the end pattern
250
+ if (substr($url_pattern, -1) === '*') {
251
+ $url_pattern = substr($url_pattern, 0, -1);
252
+
253
+ return (strpos($url, $url_pattern) === 0);
254
+ }
255
+
256
+ // do extact match if wildcard character not matched at the end pattern
257
+ return (strcmp($url, $url_pattern) === 0);
258
+ }
259
+
260
+ public function print_embed_code() {
261
+ $vsibility = get_option('tawkto-visibility-options');
262
+ $display = false;
263
+
264
+ if ($vsibility['always_display'] == 1) {
265
+ $display = true;
266
+ }
267
+
268
+ if (($vsibility['show_onfrontpage'] == 1) && (is_home() || is_front_page())) {
269
+ $display = true;
270
+ }
271
+
272
+ if (($vsibility['show_oncategory'] == 1) && is_category()) {
273
+ $display = true;
274
+ }
275
+
276
+ if (($vsibility['show_ontagpage'] == 1) && is_tag()) {
277
+ $display = true;
278
+ }
279
+
280
+ if (($vsibility['show_onarticlepages'] == 1) && is_single()) {
281
+ $display = true;
282
+ }
283
+
284
+ if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
285
+ if (($vsibility['display_on_shop'] == 1) && is_shop()) {
286
+ $display = true;
287
+ }
288
+
289
+ if (($vsibility['display_on_productcategory'] == 1) && is_product_category()) {
290
+ $display = true;
291
+ }
292
+
293
+ if (($vsibility['display_on_productpage'] == 1) && is_product()) {
294
+ $display = true;
295
+ }
296
+
297
+ if (($vsibility['display_on_producttag'] == 1) && is_product_tag()) {
298
+ $display = true;
299
+ }
300
+ }
301
+
302
+ if (isset($vsibility['include_url']) && $vsibility['include_url'] == 1) {
303
+ $current_url = $this->get_current_url();
304
+
305
+ $included_url_list = $vsibility['included_url_list'];
306
+ $included_url_list = preg_split("/,/", $included_url_list);
307
+
308
+ foreach ($included_url_list as $include_url) {
309
+ $include_url = strtolower(urldecode(trim($include_url)));
310
+
311
+ if (!empty($include_url) && $this->match_url($current_url, $include_url)) {
312
+ $display = true;
313
+ }
314
+ }
315
+ }
316
+
317
+ if (isset($vsibility['exclude_url']) && ($vsibility['exclude_url'] == 1)) {
318
+ $current_url = $this->get_current_url();
319
+
320
+ $excluded_url_list = $vsibility['excluded_url_list'];
321
+ $excluded_url_list = preg_split("/,/", $excluded_url_list);
322
+
323
+ foreach ($excluded_url_list as $exclude_url) {
324
+ $exclude_url = strtolower(urldecode(trim($exclude_url)));
325
+
326
+ if (!empty($exclude_url) && $this->match_url($current_url, $exclude_url)) {
327
+ $display = false;
328
+ }
329
+ }
330
+ }
331
+
332
+ if ($display) {
333
+ $this->embed_code();
334
+ }
335
+ }
336
+
337
+ /**
338
+ * migrate old tawk to embed code to new version.
339
+ *
340
+ * old version contained embed code script, from that
341
+ * markup we need only page id and widget id
342
+ */
343
+ public function migrate_embed_code() {
344
+
345
+ $old_tawkto_embed_code = get_option('tawkto-embed-code');
346
+
347
+ if(empty($old_tawkto_embed_code)) {
348
+ return;
349
+ }
350
+
351
+ $matches = array();
352
+ preg_match('/https:\/\/embed.tawk.to\/([0-9A-Fa-f]{24})\/([a-z0-9]{1,50})/', $old_tawkto_embed_code, $matches);
353
+
354
+ if(isset($matches[1]) && isset($matches[2]) && TawkTo_Settings::ids_are_correct($matches[1], $matches[2])) {
355
+ update_option(TawkTo_Settings::TAWK_PAGE_ID_VARIABLE, $matches[1]);
356
+ update_option(TawkTo_Settings::TAWK_WIDGET_ID_VARIABLE, $matches[2]);
357
+ }
358
+
359
+ delete_option('tawkto-embed-code');
360
+ }
361
+ }
362
+ }
363
+
364
+ if(class_exists('TawkTo')){
365
+ register_activation_hook(__FILE__, array('TawkTo', 'activate'));
366
+ register_deactivation_hook(__FILE__, array('TawkTo', 'deactivate'));
367
+
368
+ $tawkto = new TawkTo();
369
+
370
+ if(isset($tawkto)){
371
+ $tawkto->migrate_embed_code();
372
+
373
+ function tawkto_plugin_settings_link($links){
374
+ $settings_link = '<a href="options-general.php?page=tawkto_plugin">Settings</a>';
375
+ array_unshift($links, $settings_link);
376
+ return $links;
377
+ }
378
+
379
+ $plugin = plugin_basename(__FILE__);
380
+ add_filter("plugin_action_links_$plugin", 'tawkto_plugin_settings_link');
381
+ }
382
+
383
+ add_action('wp_footer', array($tawkto, 'print_embed_code'));
384
+ }
templates/settings.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @package Tawk.to Widget for Wordpress
5
+ * @author Tawk.to
6
+ * @copyright (C) 2014- Tawk.to
7
+ * @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
8
+ **/
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit; // Exit if accessed directly
11
+ }
12
+ ?>
13
+
14
+ <div class="tawkheader">
15
+ <div class="tawkmel">
16
+ <img src="<?php echo plugins_url( 'assets/tawky_big.png' , dirname(__FILE__) ) ?>">
17
+ </div>
18
+ <div class="tawkheadtext">
19
+ <?php _e('tawk.to Plugin Settings','tawk-to-live-chat'); ?>
20
+ </div>
21
+ </div>
22
+ <div class="tawkaction">
23
+ <?php submit_button(); ?>
24
+ </div>
25
+ <div class="tawksettingsbody">
26
+ <div class="tawktabs">
27
+ <button class="tawktablinks" onclick="opentab(event, 'account')" id="defaultOpen">Account Settings</button>
28
+ <button class="tawktablinks" onclick="opentab(event, 'visibility')">Visibility Options</button>
29
+ <?php
30
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
31
+ {
32
+ ?>
33
+ <button class="tawktablinks" onclick="opentab(event, 'woocommerce')">Woocomerce Options</button>
34
+ <?php } ?>
35
+ </div>
36
+
37
+ <div id="account" class="tawktabcontent" >
38
+ <?php
39
+ $page_id = get_option(self::TAWK_PAGE_ID_VARIABLE);
40
+ $widget_id = get_option(self::TAWK_WIDGET_ID_VARIABLE);
41
+ if(isset($_GET["override"]) && $_GET["override"] == 1){
42
+ $override = TRUE;
43
+ }else{
44
+ $override = false;
45
+ }
46
+ $display_widgetsettings = false;
47
+ if(($page_id == NULL) || ($widget_id == NULL)){
48
+ $display_widgetsettings = true;
49
+ }
50
+ if($override == TRUE){
51
+ $display_widgetsettings = true;
52
+ }
53
+ if ($display_widgetsettings == TRUE){
54
+ ?>
55
+ <iframe
56
+ id="tawkIframe"
57
+ src=""
58
+ style="min-height: 295px; width : 100%; border: none; margin-top: 20px">
59
+ </iframe>
60
+ <script>
61
+ var currentHost = window.location.protocol + "//" + window.location.host;
62
+ var url = "<?php echo $iframe_url ?>&parentDomain=" + currentHost;
63
+ jQuery('#tawkIframe').attr('src', url);
64
+ var iframe = jQuery('#tawk_widget_customization')[0];
65
+
66
+ window.addEventListener('message', function(e) {
67
+ if(e.origin === '<?php echo $base_url ?>') {
68
+
69
+ if(e.data.action === 'setWidget') {
70
+ setWidget(e);
71
+ }
72
+
73
+ if(e.data.action === 'removeWidget') {
74
+ removeWidget(e);
75
+ }
76
+ }
77
+ });
78
+
79
+ function setWidget(e) {
80
+ jQuery.post(ajaxurl, {
81
+ action : 'tawkto_setwidget',
82
+ pageId : e.data.pageId,
83
+ widgetId : e.data.widgetId
84
+ }, function(r) {
85
+ if(r.success) {
86
+ e.source.postMessage({action: 'setDone'}, '<?php echo $base_url ?>');
87
+ } else {
88
+ e.source.postMessage({action: 'setFail'}, '<?php echo $base_url ?>');
89
+ }
90
+
91
+ });
92
+ }
93
+
94
+ function removeWidget(e) {
95
+ jQuery.post(ajaxurl, {action: 'tawkto_removewidget'}, function(r) {
96
+ if(r.success) {
97
+ e.source.postMessage({action: 'removeDone'}, '<?php echo $base_url ?>');
98
+ } else {
99
+ e.source.postMessage({action: 'removeFail'}, '<?php echo $base_url ?>');
100
+ }
101
+ });
102
+ }
103
+ </script>
104
+ <?php
105
+ }else{
106
+ echo "<h2>Property and widget is already set.</h2>";
107
+ $tawk_admin_url = admin_url('options-general.php?page=tawkto_plugin&override=1');
108
+ echo 'if you wish to reselect property or widget <a href="'.$tawk_admin_url.'">click here</a>';
109
+ }
110
+ ?>
111
+ </div>
112
+ <form method="post" action="options.php">
113
+ <?php
114
+ settings_fields( 'tawk_options' );
115
+ do_settings_sections( 'tawk_options' );
116
+
117
+ $visibility = get_option( 'tawkto-visibility-options',FALSE );
118
+ if($visibility == FALSE){
119
+ $visibility = array (
120
+ 'always_display' => 1,
121
+ 'show_onfrontpage' => 0,
122
+ 'show_oncategory' => 0,
123
+ 'show_ontagpage' => 0,
124
+ 'show_onarticlepages' => 0,
125
+ 'exclude_url' => 0,
126
+ 'excluded_url_list' => '',
127
+ 'include_url' => 0,
128
+ 'included_url_list' => '',
129
+ 'display_on_shop' => 0,
130
+ 'display_on_productcategory' => 0,
131
+ 'display_on_productpage' => 0,
132
+ 'display_on_producttag' => 0
133
+ );
134
+ }
135
+ ?>
136
+ <div id="visibility" class="tawktabcontent">
137
+ <div id="tawkvisibilitysettings">
138
+ <h2><?php _e('Visibility Options','tawk-to-live-chat'); ?></h2>
139
+ <p class='tawknotice'>
140
+ <?php _e('Please Note: that you can use the visibility options below, or you can show the tawk.to widget','tawk-to-live-chat'); ?>
141
+ <BR>
142
+ <?php _e('on any page independent of these visibility options by simply using the <b>[tawkto]</b> shortcode in','tawk-to-live-chat'); ?>
143
+ <BR>
144
+ <?php _e('the post or page.','tawk-to-live-chat'); ?>
145
+ </p>
146
+ <table class="form-table">
147
+ <tr valign="top">
148
+ <th class="tawksetting" scope="row"><?php _e('Always show Tawk.To widget on every page','tawk-to-live-chat'); ?></th>
149
+ <td>
150
+ <label class="switch">
151
+ <input type="checkbox" class="slider round" id="always_display" name="tawkto-visibility-options[always_display]" value="1" <?php echo checked( 1, $visibility['always_display'], false ); ?> />
152
+ <div class="slider round"></div>
153
+ </label>
154
+ </td>
155
+ </tr>
156
+ <tr valign="top" class="twk_selected_display">
157
+ <th class="tawksetting" scope="row"><?php _e('Show on front page','tawk-to-live-chat'); ?></th>
158
+ <td>
159
+ <label class="switch">
160
+ <input type="checkbox" class="slider round" id="show_onfrontpage" name="tawkto-visibility-options[show_onfrontpage]" value="1" <?php echo checked( 1, $visibility['show_onfrontpage'], false ); ?> />
161
+ <div class="slider round"></div>
162
+ </label>
163
+ </td>
164
+ </tr>
165
+ <tr valign="top" class="twk_selected_display">
166
+ <th class="tawksetting" scope="row"><?php _e('Show on Category pages','tawk-to-live-chat'); ?></th>
167
+ <td>
168
+ <label class="switch">
169
+ <input type="checkbox" class="slider round" id="show_oncategory" name="tawkto-visibility-options[show_oncategory]" value="1" <?php echo checked( 1, $visibility['show_oncategory'], false ); ?> />
170
+ <div class="slider round"></div>
171
+ </label>
172
+ </td>
173
+ </tr>
174
+ <tr valign="top" class="twk_selected_display">
175
+ <th class="tawksetting" scope="row"><?php _e('Show on Tag pages','tawk-to-live-chat'); ?></th>
176
+ <td>
177
+ <label class="switch">
178
+ <input type="checkbox" class="slider round" id="show_ontagpage" name="tawkto-visibility-options[show_ontagpage]" value="1" <?php echo checked( 1, $visibility['show_ontagpage'], false ); ?> />
179
+ <div class="slider round"></div>
180
+ </label>
181
+ </td>
182
+ </tr>
183
+ <tr valign="top" class="twk_selected_display">
184
+ <th class="tawksetting" scope="row"><?php _e('Show on Single Post Pages','tawk-to-live-chat'); ?></th>
185
+ <td>
186
+ <label class="switch">
187
+ <input type="checkbox" class="slider round" id="show_onarticlepages" name="tawkto-visibility-options[show_onarticlepages]" value="1" <?php echo checked( 1, $visibility['show_onarticlepages'], false ); ?> />
188
+ <div class="slider round"></div>
189
+ </label>
190
+ </td>
191
+ </tr>
192
+ <tr valign="top">
193
+ <th class="tawksetting" scope="row"><?php _e('Exclude on specific url','tawk-to-live-chat'); ?></th>
194
+ <td>
195
+ <label class="switch">
196
+ <input type="checkbox" class="slider round" id="exclude_url" name="tawkto-visibility-options[exclude_url]" value="1" <?php echo checked( 1, $visibility['exclude_url'], false ); ?> />
197
+ <div class="slider round"></div>
198
+ </label>
199
+ <div id="exlucded_urls_container" style="display:none;">
200
+ <textarea id="excluded_url_list" name="tawkto-visibility-options[excluded_url_list]" cols="50" rows="10"><?php echo $visibility['excluded_url_list']; ?></textarea><BR>
201
+ <?php _e('Enter the url where you <b>DO NOT</b> want the widget to display.','tawk-to-live-chat'); ?><BR>
202
+ <?php _e('Separate entries with comma','tawk-to-live-chat'); ?>(,).<BR>
203
+ <?php _e('Add (*) at the end of the entry to match wildcard url.','tawk-to-live-chat'); ?><BR>
204
+ </div>
205
+ </td>
206
+ </tr>
207
+ <tr valign="top" class="twk_selected_display">
208
+ <th class="tawksetting" scope="row"><?php _e('Include on specific url','tawk-to-live-chat'); ?></th>
209
+ <td>
210
+ <label class="switch">
211
+ <input type="checkbox" class="slider round" id="include_url" name="tawkto-visibility-options[include_url]" value="1" <?php echo checked( 1, $visibility['include_url'], false ); ?> />
212
+ <div class="slider round"></div>
213
+ </label>
214
+ <div id="included_urls_container" style="display:none;">
215
+ <textarea id="included_url_list" name="tawkto-visibility-options[included_url_list]" cols="50" rows="10"><?php echo $visibility['included_url_list']; ?></textarea><BR>
216
+ <?php _e('Enter the url where you <b>WANT</b> the widget to display.','tawk-to-live-chat'); ?><BR>
217
+ <?php _e('Separate entries with comma ','tawk-to-live-chat'); ?>(,).<BR>
218
+ <?php _e('Add (*) at the end of the entry to match wildcard url.','tawk-to-live-chat'); ?><BR>
219
+ </div>
220
+ </td>
221
+ </tr>
222
+ </table>
223
+ </div>
224
+ </div>
225
+
226
+ <div id="woocommerce" class="tawktabcontent">
227
+ <?php
228
+ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) )
229
+ {
230
+
231
+ if(!isset($visibility['display_on_shop']))
232
+ {
233
+ $visibility['display_on_shop'] = 0;
234
+ $visibility['display_on_productcategory'] = 0;
235
+ $visibility['display_on_productpage'] = 0;
236
+ $visibility['display_on_producttag'] = 0;
237
+ }
238
+ ?>
239
+ <div id="tawkvisibilitysettings woocommerce">
240
+ <h2><?php _e('Woocommerce visibility Options','tawk-to-live-chat'); ?></h2>
241
+ <table class="form-table">
242
+ <tr valign="top">
243
+ <th class="tawksetting" scope="row"><?php _e('Display on Shop main page','tawk-to-live-chat'); ?></th>
244
+ <td>
245
+ <label class="switch">
246
+ <input type="checkbox" class="slider round" id="display_on_shop" name="tawkto-visibility-options[display_on_shop]" value="1" <?php echo checked( 1, $visibility['display_on_shop'], false ); ?> />
247
+ <div class="slider round"></div>
248
+ </label>
249
+ </td>
250
+ </tr>
251
+ <tr valign="top">
252
+ <th class="tawksetting" scope="row"><?php _e('Display on product category pages','tawk-to-live-chat'); ?></th>
253
+ <td>
254
+ <label class="switch">
255
+ <input type="checkbox" class="slider round" id="display_on_productcategory" name="tawkto-visibility-options[display_on_productcategory]" value="1" <?php echo checked( 1, $visibility['display_on_productcategory'], false ); ?> />
256
+ <div class="slider round"></div>
257
+ </label>
258
+ </td>
259
+ </tr>
260
+
261
+ <tr valign="top">
262
+ <th class="tawksetting" scope="row"><?php _e('Display on single product page','tawk-to-live-chat'); ?></th>
263
+ <td>
264
+ <label class="switch">
265
+ <input type="checkbox" class="slider round" id="display_on_productpage" name="tawkto-visibility-options[display_on_productpage]" value="1" <?php echo checked( 1, $visibility['display_on_productpage'], false ); ?> />
266
+ <div class="slider round"></div>
267
+ </label>
268
+ </td>
269
+ </tr>
270
+ <tr valign="top">
271
+ <th class="tawksetting" scope="row"><?php _e('Display on product tag pages','tawk-to-live-chat'); ?></th>
272
+ <td>
273
+ <label class="switch">
274
+ <input type="checkbox" class="slider round" id="display_on_producttag" name="tawkto-visibility-options[display_on_producttag]" value="1" <?php echo checked( 1, $visibility['display_on_producttag'], false ); ?> />
275
+ <div class="slider round"></div>
276
+ </label>
277
+ </td>
278
+ </tr>
279
+ </table>
280
+ </div>
281
+ <?php
282
+ }
283
+ ?>
284
+ </div>
285
+
286
+ </div>
287
+ <div class="tawkaction">
288
+ <div class="tawkfootaction">
289
+ <?php submit_button(); ?>
290
+ </div>
291
+ <div class="tawkfoottext">
292
+ Having trouble and need some help? Check out our <a class="tawklink" href="https://www.tawk.to/knowledgebase/" target="_blank">Knowledge Base</a>.
293
+ </div>
294
+ </div>
295
+
296
+ </form>
templates/widget.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!--Start of Tawk.to Script (0.3.3)-->
2
+ <script type="text/javascript">
3
+ var Tawk_API=Tawk_API||{};
4
+ <?php
5
+ if(!is_null($customer_details)) {
6
+ echo 'Tawk_API.visitor = '. $customer_details.';';
7
+ }
8
+ ?>
9
+ var Tawk_LoadStart=new Date();
10
+ (function(){
11
+ var s1=document.createElement("script"),s0=document.getElementsByTagName("script")[0];
12
+ s1.async=true;
13
+ s1.src='https://embed.tawk.to/<?php echo $page_id ?>/<?php echo $widget_id ?>';
14
+ s1.charset='UTF-8';
15
+ s1.setAttribute('crossorigin','*');
16
+ s0.parentNode.insertBefore(s1,s0);
17
+ })();
18
+ </script>
19
+ <!--End of Tawk.to Script (0.3.3)-->