WhatsApp Chat WP - Version 5.0.6

Version Description

  • New. WhatsApp chat message vars
Download this release

Release Info

Developer quadlayers
Plugin Icon 128x128 WhatsApp Chat WP
Version 5.0.6
Comparing to
See all releases

Code changes from version 5.0.5 to 5.0.6

includes/helpers.php CHANGED
@@ -1,47 +1,69 @@
1
  <?php
2
 
3
- function qlwapp_format_phone($phone) {
4
 
5
- $phone = preg_replace('/[^0-9]/', '', $phone);
6
 
7
- $phone = ltrim($phone, '0');
8
 
9
- return $phone;
10
  }
11
 
12
- function qlwapp_get_timezone_offset($timezone) {
13
- if (strpos($timezone, 'UTC') !== false) {
14
- $offset = preg_replace('/UTC\+?/', '', $timezone) * 60;
15
- } else {
16
- $current = timezone_open($timezone);
17
- $utc = new \DateTime('now', new \DateTimeZone('UTC'));
18
- $offset = $current->getOffset($utc) / 3600 * 60;
19
- }
20
- return $offset;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  }
22
 
23
  function qlwapp_get_current_timezone() {
24
- // Get user settings
25
- $current_offset = get_option('gmt_offset');
26
- $tzstring = get_option('timezone_string');
27
-
28
- $check_zone_info = true;
29
-
30
- // Remove old Etc mappings. Fallback to gmt_offset.
31
- if (false !== strpos($tzstring, 'Etc/GMT')) {
32
- $tzstring = '';
33
- }
34
-
35
- if (empty($tzstring)) {
36
- // Create a UTC+- zone if no timezone string exists
37
- $check_zone_info = false;
38
- if (0 == $current_offset) {
39
- $tzstring = 'UTC+0';
40
- } elseif ($current_offset < 0) {
41
- $tzstring = 'UTC' . $current_offset;
42
- } else {
43
- $tzstring = 'UTC+' . $current_offset;
44
- }
45
- }
46
- return $tzstring;
47
  }
1
  <?php
2
 
3
+ function qlwapp_format_phone( $phone ) {
4
 
5
+ $phone = preg_replace( '/[^0-9]/', '', $phone );
6
 
7
+ $phone = ltrim( $phone, '0' );
8
 
9
+ return $phone;
10
  }
11
 
12
+ function qlwapp_vars_replacements( $text ) {
13
+
14
+ global $wp;
15
+
16
+ $remove = function () {
17
+ return '/';
18
+ };
19
+
20
+ add_filter( 'document_title_separator', $remove );
21
+ $title = wp_get_document_title();
22
+ remove_filter( 'document_title_separator', $remove );
23
+
24
+ $replace = array(
25
+ '{SITE_TITLE}' => get_bloginfo( 'name' ),
26
+ '{SITE_URL}' => home_url( '/' ),
27
+ '{CURRENT_URL}' => home_url( $wp->request ),
28
+ '{CURRENT_TITLE}' => $title,
29
+ );
30
+
31
+ return str_replace( array_keys( $replace ), array_values( $replace ), $text );
32
+ }
33
+
34
+ function qlwapp_get_timezone_offset( $timezone ) {
35
+ if ( strpos( $timezone, 'UTC' ) !== false ) {
36
+ $offset = preg_replace( '/UTC\+?/', '', $timezone ) * 60;
37
+ } else {
38
+ $current = timezone_open( $timezone );
39
+ $utc = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) );
40
+ $offset = $current->getOffset( $utc ) / 3600 * 60;
41
+ }
42
+ return $offset;
43
  }
44
 
45
  function qlwapp_get_current_timezone() {
46
+ // Get user settings
47
+ $current_offset = get_option( 'gmt_offset' );
48
+ $tzstring = get_option( 'timezone_string' );
49
+
50
+ $check_zone_info = true;
51
+
52
+ // Remove old Etc mappings. Fallback to gmt_offset.
53
+ if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
54
+ $tzstring = '';
55
+ }
56
+
57
+ if ( empty( $tzstring ) ) {
58
+ // Create a UTC+- zone if no timezone string exists
59
+ $check_zone_info = false;
60
+ if ( 0 == $current_offset ) {
61
+ $tzstring = 'UTC+0';
62
+ } elseif ( $current_offset < 0 ) {
63
+ $tzstring = 'UTC' . $current_offset;
64
+ } else {
65
+ $tzstring = 'UTC+' . $current_offset;
66
+ }
67
+ }
68
+ return $tzstring;
69
  }
includes/models/Box.php CHANGED
@@ -1,46 +1,56 @@
1
  <?php
2
 
3
- include_once(QLWAPP_PLUGIN_DIR . 'includes/models/QLWAPP_Model.php');
4
-
5
- class QLWAPP_Box extends QLWAPP_Model
6
- {
7
-
8
- protected $table = 'box';
9
-
10
- function get_args()
11
- {
12
- $args = array(
13
- 'enable' => 'yes',
14
- 'auto_open' => 'no',
15
- 'auto_delay_open' => 1000,
16
- 'header' => '<p><span style="font-size: 12px;line-height: 34px;vertical-align: bottom;letter-spacing: -0.2px">Powered by</span> <a href="' . QLWAPP_LANDING_URL . '" target="_blank" rel="noopener" style="font-size: 24px;line-height: 34px;font-family: Calibri;font-weight: bold;text-decoration: none;color: white">WhatsApp Chat</a></p>',
17
- 'footer' => '<p style="text-align: start;">WhatsApp Chat is free, download and try it now <a target="_blank" href="' . QLWAPP_LANDING_URL . '">here!</a></p>',
18
- 'response' => esc_html__('Write a response', 'wp-whatsapp-chat')
19
- // ,'contactstimeout' => 'no'
20
- );
21
- return $args;
22
- }
23
-
24
- function sanitize($settings)
25
- {
26
-
27
- if (isset($settings['header'])) {
28
- $settings['header'] = wp_kses_post($settings['header']);
29
- }
30
- if (isset($settings['auto_open'])) {
31
- $settings['auto_open'] = wp_kses_post($settings['auto_open']);
32
- }
33
- if (isset($settings['auto_delay_open'])) {
34
- $settings['auto_delay_open'] = wp_kses_post($settings['auto_delay_open']);
35
- }
36
- if (isset($settings['footer'])) {
37
- $settings['footer'] = wp_kses_post($settings['footer']);
38
- }
39
- return $settings;
40
- }
41
-
42
- function save($box_data = NULL)
43
- {
44
- return parent::save_data($this->table, $this->sanitize($box_data));
45
- }
 
 
 
 
 
 
 
 
 
 
46
  }
1
  <?php
2
 
3
+ require_once QLWAPP_PLUGIN_DIR . 'includes/models/QLWAPP_Model.php';
4
+
5
+ class QLWAPP_Box extends QLWAPP_Model {
6
+
7
+
8
+ protected $table = 'box';
9
+
10
+ function get_args() {
11
+ $args = array(
12
+ 'enable' => 'yes',
13
+ 'auto_open' => 'no',
14
+ 'auto_delay_open' => 1000,
15
+ 'header' => '<p><span style="font-size: 12px;line-height: 34px;vertical-align: bottom;letter-spacing: -0.2px">Powered by</span> <a href="' . QLWAPP_LANDING_URL . '" target="_blank" rel="noopener" style="font-size: 24px;line-height: 34px;font-family: Calibri;font-weight: bold;text-decoration: none;color: white">WhatsApp Chat</a></p>',
16
+ 'footer' => '<p style="text-align: start;">WhatsApp Chat is free, download and try it now <a target="_blank" href="' . QLWAPP_LANDING_URL . '">here!</a></p>',
17
+ 'response' => esc_html__( 'Write a response', 'wp-whatsapp-chat' ),
18
+ // ,'contactstimeout' => 'no'
19
+ );
20
+ return $args;
21
+ }
22
+
23
+ function sanitize( $settings ) {
24
+ if ( isset( $settings['header'] ) ) {
25
+ $settings['header'] = wp_kses_post( $settings['header'] );
26
+ }
27
+ if ( isset( $settings['auto_open'] ) ) {
28
+ $settings['auto_open'] = wp_kses_post( $settings['auto_open'] );
29
+ }
30
+ if ( isset( $settings['auto_delay_open'] ) ) {
31
+ $settings['auto_delay_open'] = wp_kses_post( $settings['auto_delay_open'] );
32
+ }
33
+ if ( isset( $settings['footer'] ) ) {
34
+ $settings['footer'] = wp_kses_post( $settings['footer'] );
35
+ }
36
+ return $settings;
37
+ }
38
+
39
+ function get() {
40
+
41
+ $result = $this->get_all( $this->table );
42
+
43
+ $result = wp_parse_args( $result, $this->get_args() );
44
+
45
+ if ( ! is_admin() ) {
46
+ $result['header'] = qlwapp_vars_replacements( $result['header'] );
47
+ $result['footer'] = qlwapp_vars_replacements( $result['footer'] );
48
+ }
49
+
50
+ return $result;
51
+ }
52
+
53
+ function save( $box_data = null ) {
54
+ return parent::save_data( $this->table, $this->sanitize( $box_data ) );
55
+ }
56
  }
includes/models/Button.php CHANGED
@@ -1,64 +1,73 @@
1
  <?php
2
 
3
- include_once(QLWAPP_PLUGIN_DIR . 'includes/models/QLWAPP_Model.php');
4
 
5
- class QLWAPP_Button extends QLWAPP_Model
6
- {
7
 
8
- protected $table = 'button';
9
 
10
- function get_args()
11
- {
12
 
13
- $args = array(
14
- 'layout' => 'button',
15
- 'box' => 'no',
16
- 'position' => 'bottom-right',
17
- 'text' => esc_html__('How can I help you?', 'wp-whatsapp-chat'),
18
- 'message' => sprintf(esc_html__('Hello! I\'m testing the %s plugin %s', 'wp-whatsapp-chat'), QLWAPP_PLUGIN_NAME, QLWAPP_LANDING_URL),
19
- 'icon' => 'qlwapp-whatsapp-icon',
20
- 'phone' => QLWAPP_PHONE_NUMBER,
21
- 'developer' => 'no',
22
- 'rounded' => 'yes',
23
- 'timefrom' => '00:00',
24
- 'timeto' => '00:00',
25
- 'timedays' => [],
26
- 'timezone' => qlwapp_get_current_timezone(),
27
- 'timeout' => 'readonly'
28
- );
29
- return $args;
30
- }
 
31
 
32
- function sanitize($settings)
33
- {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- if (isset($settings['layout'])) {
36
- $settings['layout'] = sanitize_html_class($settings['layout']);
37
- }
38
- if (isset($settings['position'])) {
39
- $settings['position'] = sanitize_html_class($settings['position']);
40
- }
41
- if (isset($settings['text'])) {
42
- $settings['text'] = sanitize_text_field($settings['text']);
43
- }
44
- if (isset($settings['message'])) {
45
- $settings['message'] = sanitize_text_field($settings['message']);
46
- }
47
- // if (isset($settings['contactstimeout'])) {
48
- // $settings['box']['contactstimeout'] = sanitize_text_field($settings['box']['contactstimeout']);
49
- // }
50
- if (isset($settings['icon'])) {
51
- $settings['icon'] = sanitize_html_class($settings['icon']);
52
- }
53
- if (isset($settings['phone'])) {
54
- $settings['phone'] = qlwapp_format_phone($settings['phone']);
55
- }
56
 
57
- return $settings;
58
- }
 
59
 
60
- function save($button_data = NULL)
61
- {
62
- return parent::save_data($this->table, $this->sanitize($button_data));
63
- }
 
 
 
 
 
 
 
 
 
64
  }
1
  <?php
2
 
3
+ require_once QLWAPP_PLUGIN_DIR . 'includes/models/QLWAPP_Model.php';
4
 
5
+ class QLWAPP_Button extends QLWAPP_Model {
 
6
 
 
7
 
8
+ protected $table = 'button';
 
9
 
10
+ function get_args() {
11
+ $args = array(
12
+ 'layout' => 'button',
13
+ 'box' => 'no',
14
+ 'position' => 'bottom-right',
15
+ 'text' => esc_html__( 'How can I help you?', 'wp-whatsapp-chat' ),
16
+ 'message' => sprintf( esc_html__( 'Hello! I\'m testing the %1$s plugin %2$s', 'wp-whatsapp-chat' ), QLWAPP_PLUGIN_NAME, QLWAPP_LANDING_URL ),
17
+ 'icon' => 'qlwapp-whatsapp-icon',
18
+ 'phone' => QLWAPP_PHONE_NUMBER,
19
+ 'developer' => 'no',
20
+ 'rounded' => 'yes',
21
+ 'timefrom' => '00:00',
22
+ 'timeto' => '00:00',
23
+ 'timedays' => array(),
24
+ 'timezone' => qlwapp_get_current_timezone(),
25
+ 'timeout' => 'readonly',
26
+ );
27
+ return $args;
28
+ }
29
 
30
+ function sanitize( $settings ) {
31
+ if ( isset( $settings['layout'] ) ) {
32
+ $settings['layout'] = sanitize_html_class( $settings['layout'] );
33
+ }
34
+ if ( isset( $settings['position'] ) ) {
35
+ $settings['position'] = sanitize_html_class( $settings['position'] );
36
+ }
37
+ if ( isset( $settings['text'] ) ) {
38
+ $settings['text'] = sanitize_text_field( $settings['text'] );
39
+ }
40
+ if ( isset( $settings['message'] ) ) {
41
+ $settings['message'] = sanitize_text_field( $settings['message'] );
42
+ }
43
+ // if (isset($settings['contactstimeout'])) {
44
+ // $settings['box']['contactstimeout'] = sanitize_text_field($settings['box']['contactstimeout']);
45
+ // }
46
+ if ( isset( $settings['icon'] ) ) {
47
+ $settings['icon'] = sanitize_html_class( $settings['icon'] );
48
+ }
49
+ if ( isset( $settings['phone'] ) ) {
50
+ $settings['phone'] = qlwapp_format_phone( $settings['phone'] );
51
+ }
52
 
53
+ return $settings;
54
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
+ function save( $button_data = null ) {
57
+ return parent::save_data( $this->table, $this->sanitize( $button_data ) );
58
+ }
59
 
60
+ function get() {
61
+
62
+ $result = $this->get_all( $this->table );
63
+
64
+ $result = wp_parse_args( $result, $this->get_args() );
65
+
66
+ if ( ! is_admin() ) {
67
+ $result['text'] = qlwapp_vars_replacements( $result['text'] );
68
+ $result['message'] = qlwapp_vars_replacements( $result['message'] );
69
+ }
70
+
71
+ return $result;
72
+ }
73
  }
includes/models/Contact.php CHANGED
@@ -1,169 +1,175 @@
1
  <?php
2
 
3
- include_once(QLWAPP_PLUGIN_DIR . 'includes/helpers.php');
4
- include_once QLWAPP_PLUGIN_DIR . 'includes/models/Button.php';
5
- include_once(QLWAPP_PLUGIN_DIR . 'includes/models/Display_Component.php');
6
 
7
  class QLWAPP_Contact extends QLWAPP_Model {
8
 
9
- protected $table = 'contacts';
10
-
11
- function get_args() {
12
-
13
- $display_component_model = new Display_Component();
14
- $args = array(
15
- 'id' => null,
16
- 'order' => 1,
17
- 'active' => 1,
18
- // Defaults
19
- // -----------------------------------------------------------------
20
- 'chat' => true,
21
- 'auto_open' => false,
22
- 'avatar' => 'https://www.gravatar.com/avatar/00000000000000000000000000000000',
23
- 'phone' => '',
24
- 'firstname' => 'John',
25
- 'lastname' => 'Doe',
26
- 'label' => esc_html__('Support', 'wp-whatsapp-chat'),
27
- 'message' => sprintf(esc_html__('Hello! I\'m testing the %s plugin %s', 'wp-whatsapp-chat'), QLWAPP_PLUGIN_NAME, QLWAPP_LANDING_URL),
28
- 'timefrom' => '00:00',
29
- 'timeto' => '00:00',
30
- 'timezone' => qlwapp_get_current_timezone(),
31
- 'timeout' => 'readonly',
32
- 'timedays' => [],
33
- 'display' => $display_component_model->get_args(),
34
- );
35
-
36
- return $args;
37
- }
38
-
39
- function get_next_id() {
40
- $contactos = $this->get_contacts();
41
- if (count($contactos)) {
42
- return max(array_keys($contactos)) + 1;
43
- }
44
- return 0;
45
- }
46
-
47
- function add_contact($contact_data) {
48
- $contact_id = $this->get_next_id();
49
- $contact_data['id'] = $contact_id;
50
- return $this->save($contact_data);
51
- }
52
-
53
- function update_contact($contact_data) {
54
- return $this->save($contact_data);
55
- }
56
-
57
- function update_contacts($contacts, $order=0) {
58
- return $this->save_with_reorder($contacts);
59
- }
60
-
61
- function save($contact_data = NULL) {
62
- $contacts = $this->get_contacts();
63
- $contacts[$contact_data['id']] = wp_parse_args($contact_data, $this->get_args());
64
-
65
- return $this->save_with_reorder($contacts,1);
66
- }
67
-
68
- function save_with_reorder($contacts, $with = 0) {
69
- if($with) {
70
- $loop = 1;
71
- foreach ($contacts as $key => $value) {
72
- $contacts[$key]['order'] = $loop;
73
- $loop++;
74
- }
75
- }
76
- return $this->save_data($this->table, $this->sanitize_value_data($contacts));
77
- }
78
-
79
- function delete($id = NULL) {
80
- $contacts = parent::get_all($this->table);
81
- if ($contacts) {
82
- if (count($contacts) > 0) {
83
- unset($contacts[$id]);
84
- return $this->save_with_reorder($contacts, 1);
85
- }
86
- }
87
- return false;
88
- }
89
-
90
- function settings_sanitize($settings) {
91
-
92
- if (isset($settings['contacts'])) {
93
- if (count($settings['contacts'])) {
94
- foreach ($settings['contacts'] as $id => $c) {
95
- $settings['contacts'][$id]['id'] = $id;
96
- $settings['contacts'][$id]['auto_open'] = $settings['contacts'][$id]['auto_open'];
97
- $settings['contacts'][$id]['chat'] = (bool) $settings['contacts'][$id]['chat'];
98
- $settings['contacts'][$id]['avatar'] = sanitize_text_field($settings['contacts'][$id]['avatar']);
99
- $settings['contacts'][$id]['phone'] = sanitize_text_field($settings['contacts'][$id]['phone']);
100
- $settings['contacts'][$id]['firstname'] = sanitize_text_field($settings['contacts'][$id]['firstname']);
101
- $settings['contacts'][$id]['lastname'] = sanitize_text_field($settings['contacts'][$id]['lastname']);
102
- $settings['contacts'][$id]['label'] = sanitize_text_field($settings['contacts'][$id]['label']);
103
- $settings['contacts'][$id]['message'] = wp_kses_post($settings['contacts'][$id]['message']);
104
- $settings['contacts'][$id]['timeto'] = wp_kses_post($settings['contacts'][$id]['timeto']);
105
- $settings['contacts'][$id]['phone'] = qlwapp_format_phone($settings['contacts'][$id]['phone']);
106
- $settings['contacts'][$id]['timefrom'] = qlwapp_format_phone($settings['contacts'][$id]['timefrom']);
107
- $settings['contacts'][$id]['timedays'] = $settings['contacts'][$id]['timedays'];
108
- }
109
- }
110
- }
111
- return $settings;
112
- }
113
-
114
- function sanitize_value_data($contacts, $args = null) {
115
- foreach ($contacts as $key => $contact) {
116
- $contacts[$key] = parent::sanitize_value_data($contact, $this->get_args());
117
- }
118
- return $contacts;
119
- }
120
-
121
- function get_contact($id) {
122
- // $parent_id = @max(array_keys(array_column($contacts, 'id'), $id));
123
- $contacts = $this->get_contacts();
124
- return array_replace_recursive($this->get_args(), $contacts[$id]);
125
- }
126
- function get_contacts() {
127
-
128
  $button_model = new QLWAPP_Button();
129
  $button = $button_model->get();
130
- $result = parent::get_all($this->table);
131
- if ($result === NULL || count($result) === 0) {
132
- $default = array();
133
- $default[0] = $this->get_args();
134
- $default[0]['id'] = 0;
135
- $result = $default;
136
- } else {
137
- foreach ($result as $id => $c) {
138
- $result[$id] = wp_parse_args($c, $this->get_args());
139
- }
140
- }
141
-
142
- //Include the button phone number if the contact number is empty
143
- foreach ($result as $id => $contact) {
144
- if(!$contact['phone']) {
145
- $result[$id]['phone'] = $button['phone'];
146
  }
147
  }
148
 
149
- return $result;
150
- }
 
 
 
 
 
 
 
 
151
 
152
- function order_contact($a, $b) {
 
153
 
154
- if (!isset($a['order']) || !isset($b['order']))
155
- return 0;
 
 
 
 
 
 
 
156
 
157
- if ($a['order'] == $b['order'])
158
- return 0;
159
 
160
- return ( $a['order'] < $b['order'] ) ? -1 : 1;
161
- }
 
 
 
162
 
163
- function get_contacts_reorder() {
164
- $contacts = $this->get_contacts();
165
- uasort($contacts, array($this, 'order_contact'));
166
- return $contacts;
167
- }
168
-
169
  }
1
  <?php
2
 
3
+ require_once QLWAPP_PLUGIN_DIR . 'includes/helpers.php';
4
+ require_once QLWAPP_PLUGIN_DIR . 'includes/models/Button.php';
5
+ require_once QLWAPP_PLUGIN_DIR . 'includes/models/Display_Component.php';
6
 
7
  class QLWAPP_Contact extends QLWAPP_Model {
8
 
9
+ protected $table = 'contacts';
10
+
11
+ function get_args() {
12
+
13
+ $display_component_model = new Display_Component();
14
+ $args = array(
15
+ 'id' => null,
16
+ 'order' => 1,
17
+ 'active' => 1,
18
+ // Defaults
19
+ // -----------------------------------------------------------------
20
+ 'chat' => true,
21
+ 'auto_open' => false,
22
+ 'avatar' => 'https://www.gravatar.com/avatar/00000000000000000000000000000000',
23
+ 'phone' => '',
24
+ 'firstname' => 'John',
25
+ 'lastname' => 'Doe',
26
+ 'label' => esc_html__( 'Support', 'wp-whatsapp-chat' ),
27
+ 'message' => sprintf( esc_html__( 'Hello! I\'m testing the %1$s plugin %2$s', 'wp-whatsapp-chat' ), QLWAPP_PLUGIN_NAME, QLWAPP_LANDING_URL ),
28
+ 'timefrom' => '00:00',
29
+ 'timeto' => '00:00',
30
+ 'timezone' => qlwapp_get_current_timezone(),
31
+ 'timeout' => 'readonly',
32
+ 'timedays' => array(),
33
+ 'display' => $display_component_model->get_args(),
34
+ );
35
+
36
+ return $args;
37
+ }
38
+
39
+ function get_next_id() {
40
+ $contactos = $this->get_contacts();
41
+ if ( count( $contactos ) ) {
42
+ return max( array_keys( $contactos ) ) + 1;
43
+ }
44
+ return 0;
45
+ }
46
+
47
+ function add_contact( $contact_data ) {
48
+ $contact_id = $this->get_next_id();
49
+ $contact_data['id'] = $contact_id;
50
+ return $this->save( $contact_data );
51
+ }
52
+
53
+ function update_contact( $contact_data ) {
54
+ return $this->save( $contact_data );
55
+ }
56
+
57
+ function update_contacts( $contacts, $order = 0 ) {
58
+ return $this->save_with_reorder( $contacts );
59
+ }
60
+
61
+ function save( $contact_data = null ) {
62
+ $contacts = $this->get_contacts();
63
+ $contacts[ $contact_data['id'] ] = wp_parse_args( $contact_data, $this->get_args() );
64
+
65
+ return $this->save_with_reorder( $contacts, 1 );
66
+ }
67
+
68
+ function save_with_reorder( $contacts, $with = 0 ) {
69
+ if ( $with ) {
70
+ $loop = 1;
71
+ foreach ( $contacts as $key => $value ) {
72
+ $contacts[ $key ]['order'] = $loop;
73
+ $loop++;
74
+ }
75
+ }
76
+ return $this->save_data( $this->table, $this->sanitize_value_data( $contacts ) );
77
+ }
78
+
79
+ function delete( $id = null ) {
80
+ $contacts = parent::get_all( $this->table );
81
+ if ( $contacts ) {
82
+ if ( count( $contacts ) > 0 ) {
83
+ unset( $contacts[ $id ] );
84
+ return $this->save_with_reorder( $contacts, 1 );
85
+ }
86
+ }
87
+ return false;
88
+ }
89
+
90
+ function settings_sanitize( $settings ) {
91
+
92
+ if ( isset( $settings['contacts'] ) ) {
93
+ if ( count( $settings['contacts'] ) ) {
94
+ foreach ( $settings['contacts'] as $id => $c ) {
95
+ $settings['contacts'][ $id ]['id'] = $id;
96
+ $settings['contacts'][ $id ]['auto_open'] = $settings['contacts'][ $id ]['auto_open'];
97
+ $settings['contacts'][ $id ]['chat'] = (bool) $settings['contacts'][ $id ]['chat'];
98
+ $settings['contacts'][ $id ]['avatar'] = sanitize_text_field( $settings['contacts'][ $id ]['avatar'] );
99
+ $settings['contacts'][ $id ]['phone'] = sanitize_text_field( $settings['contacts'][ $id ]['phone'] );
100
+ $settings['contacts'][ $id ]['firstname'] = sanitize_text_field( $settings['contacts'][ $id ]['firstname'] );
101
+ $settings['contacts'][ $id ]['lastname'] = sanitize_text_field( $settings['contacts'][ $id ]['lastname'] );
102
+ $settings['contacts'][ $id ]['label'] = sanitize_text_field( $settings['contacts'][ $id ]['label'] );
103
+ $settings['contacts'][ $id ]['message'] = wp_kses_post( $settings['contacts'][ $id ]['message'] );
104
+ $settings['contacts'][ $id ]['timeto'] = wp_kses_post( $settings['contacts'][ $id ]['timeto'] );
105
+ $settings['contacts'][ $id ]['phone'] = qlwapp_format_phone( $settings['contacts'][ $id ]['phone'] );
106
+ $settings['contacts'][ $id ]['timefrom'] = qlwapp_format_phone( $settings['contacts'][ $id ]['timefrom'] );
107
+ $settings['contacts'][ $id ]['timedays'] = $settings['contacts'][ $id ]['timedays'];
108
+ }
109
+ }
110
+ }
111
+ return $settings;
112
+ }
113
+
114
+ function sanitize_value_data( $contacts, $args = null ) {
115
+ foreach ( $contacts as $key => $contact ) {
116
+ $contacts[ $key ] = parent::sanitize_value_data( $contact, $this->get_args() );
117
+ }
118
+ return $contacts;
119
+ }
120
+
121
+ function get_contact( $id ) {
122
+ // $parent_id = @max(array_keys(array_column($contacts, 'id'), $id));
123
+ $contacts = $this->get_contacts();
124
+ return array_replace_recursive( $this->get_args(), $contacts[ $id ] );
125
+ }
126
+ function get_contacts() {
127
+
128
  $button_model = new QLWAPP_Button();
129
  $button = $button_model->get();
130
+ $result = parent::get_all( $this->table );
131
+ if ( $result === null || count( $result ) === 0 ) {
132
+ $default = array();
133
+ $default[0] = $this->get_args();
134
+ $default[0]['id'] = 0;
135
+ $result = $default;
136
+ } else {
137
+ foreach ( $result as $id => $c ) {
138
+ $result[ $id ] = wp_parse_args( $c, $this->get_args() );
 
 
 
 
 
 
 
139
  }
140
  }
141
 
142
+ // Include the button phone number if the contact number is empty
143
+ foreach ( $result as $id => $contact ) {
144
+ if ( ! $contact['phone'] ) {
145
+ $result[ $id ]['phone'] = $button['phone'];
146
+ }
147
+ // Apply vars replacement
148
+ if ( ! is_admin() ) {
149
+ $result[ $id ]['message'] = qlwapp_vars_replacements( $contact['message'] );
150
+ }
151
+ }
152
 
153
+ return $result;
154
+ }
155
 
156
+ function order_contact( $a, $b ) {
157
+
158
+ if ( ! isset( $a['order'] ) || ! isset( $b['order'] ) ) {
159
+ return 0;
160
+ }
161
+
162
+ if ( $a['order'] == $b['order'] ) {
163
+ return 0;
164
+ }
165
 
166
+ return ( $a['order'] < $b['order'] ) ? -1 : 1;
167
+ }
168
 
169
+ function get_contacts_reorder() {
170
+ $contacts = $this->get_contacts();
171
+ uasort( $contacts, array( $this, 'order_contact' ) );
172
+ return $contacts;
173
+ }
174
 
 
 
 
 
 
 
175
  }
includes/models/QLWAPP_Model.php CHANGED
@@ -15,6 +15,7 @@ class QLWAPP_Model {
15
  $options['contacts'] = array();
16
  $options['display'] = array();
17
  $options['scheme'] = array();
 
18
  $options['license'] = array();
19
  return $options;
20
  }
15
  $options['contacts'] = array();
16
  $options['display'] = array();
17
  $options['scheme'] = array();
18
+ $options['woocommerce'] = array();
19
  $options['license'] = array();
20
  return $options;
21
  }
includes/view/backend/pages/box.php CHANGED
@@ -1,56 +1,79 @@
1
  <div class="wrap about-wrap full-width-layout qlwrap">
2
  <form id="qlwapp_box_form" method="post" action="options.php">
3
- <table class="form-table">
4
- <tbody>
5
- <tr>
6
- <th scope="row"><?php esc_html_e('Auto open', 'wp-whatsapp-chat'); ?></th>
7
- <td class="qlwapp-premium-field">
8
- <select name="auto_open" class="qlwapp-select2">
9
- <option value="yes" <?php selected($box['auto_open'], 'yes'); ?>><?php esc_html_e('Enable auto open', 'wp-whatsapp-chat'); ?></option>
10
- <option value="no" <?php selected($box['auto_open'], 'no'); ?>><?php esc_html_e('Disable auto open', 'wp-whatsapp-chat'); ?></option>
11
- </select>
12
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
13
- </td>
14
- </tr>
15
- <tr>
16
- <th scope="row"><?php esc_html_e('Delay', 'wp-whatsapp-chat'); ?></th>
17
- <td class="qlwapp-premium-field">
18
- <input type="number" step="100" name="auto_delay_open" placeholder="<?php echo esc_html($box['auto_delay_open']); ?>" value="<?php echo esc_attr( $box['auto_delay_open']) ;?>" />
19
- <p class="description"><?php esc_html_e('In miliseconds', 'wp-whatsapp-chat'); ?></p>
20
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
21
- </td>
22
- </tr>
23
- <tr>
24
- <th scope="row"><?php esc_html_e('Header', 'wp-whatsapp-chat'); ?></th>
25
- <td>
26
- <?php wp_editor($box['header'], 'qlwapp_box_header', array('editor_height' => 100, 'textarea_name' => 'header', 'tinymce' => array('init_instance_callback' => 'function(editor) { editor.on("change", function(e){jQuery(document).trigger("tinymce_change");}); }'))); ?>
27
- </td>
28
- </tr>
29
- <tr>
30
- <th scope="row"><?php esc_html_e('Footer', 'wp-whatsapp-chat'); ?></th>
31
- <td>
32
- <?php //wp_editor($box['footer'], 'qlwapp_box_footer', array('editor_height' => 50, 'textarea_name' => 'footer'));
33
- ?>
34
- <?php wp_editor($box['footer'], 'qlwapp_box_footer', array('editor_height' => 50, 'textarea_name' => 'footer', 'tinymce' => array('init_instance_callback' => 'function(editor) { editor.on("change", function(){jQuery(document).trigger("tinymce_change");}); }'))); ?>
35
- </td>
36
- </tr>
37
- <tr>
38
- <th scope="row"><?php esc_html_e('Response', 'wp-whatsapp-chat'); ?></th>
39
- <td>
40
- <input type="text" name="response" placeholder="<?php echo esc_html($box['response']); ?>" value="<?php echo esc_attr($box['response']); ?>" class="qlwapp-input" />
41
- <p class="description hidden"><?php esc_html_e('Write a response text.', 'wp-whatsapp-chat'); ?></p>
42
- </td>
43
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
- </tbody>
46
- </table>
47
- <?php wp_nonce_field('qlwapp_save_box', 'qlwapp_box_form_nonce'); ?>
48
- <p class="submit">
49
- <?php submit_button(esc_html__('Save', 'wp-whatsapp-chat'), 'primary', 'submit', false); ?>
50
- <span class="settings-save-status">
51
- <span class="saved"><?php esc_html_e('Saved successfully!'); ?></span>
52
- <span class="spinner" style="float: none"></span>
53
- </span>
54
- </p>
55
  </form>
56
- </div>
1
  <div class="wrap about-wrap full-width-layout qlwrap">
2
  <form id="qlwapp_box_form" method="post" action="options.php">
3
+ <table class="form-table">
4
+ <tbody>
5
+ <tr>
6
+ <th scope="row"><?php esc_html_e( 'Auto open', 'wp-whatsapp-chat' ); ?></th>
7
+ <td class="qlwapp-premium-field">
8
+ <select name="auto_open" class="qlwapp-select2">
9
+ <option value="yes" <?php selected( $box['auto_open'], 'yes' ); ?>><?php esc_html_e( 'Enable auto open', 'wp-whatsapp-chat' ); ?></option>
10
+ <option value="no" <?php selected( $box['auto_open'], 'no' ); ?>><?php esc_html_e( 'Disable auto open', 'wp-whatsapp-chat' ); ?></option>
11
+ </select>
12
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <th scope="row"><?php esc_html_e( 'Delay', 'wp-whatsapp-chat' ); ?></th>
17
+ <td class="qlwapp-premium-field">
18
+ <input type="number" step="100" name="auto_delay_open" placeholder="<?php echo esc_html( $box['auto_delay_open'] ); ?>" value="<?php echo esc_attr( $box['auto_delay_open'] ); ?>" />
19
+ <p class="description"><?php esc_html_e( 'In miliseconds', 'wp-whatsapp-chat' ); ?></p>
20
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <th scope="row"><?php esc_html_e( 'Header', 'wp-whatsapp-chat' ); ?></th>
25
+ <td>
26
+ <?php
27
+ wp_editor(
28
+ $box['header'],
29
+ 'qlwapp_box_header',
30
+ array(
31
+ 'editor_height' => 100,
32
+ 'textarea_name' => 'header',
33
+ 'tinymce' => array( 'init_instance_callback' => 'function(editor) { editor.on("change", function(e){jQuery(document).trigger("tinymce_change");}); }' ),
34
+ )
35
+ );
36
+ ?>
37
+ <p class="description"><?php esc_html_e( 'You can use this vars:', 'wp-whatsapp-chat' ); ?><small><code>{SITE_TITLE} {SITE_URL} {CURRENT_URL} {CURRENT_TITLE}</code></small></p>
38
+ </td>
39
+ </tr>
40
+ <tr>
41
+ <th scope="row"><?php esc_html_e( 'Footer', 'wp-whatsapp-chat' ); ?></th>
42
+ <td>
43
+ <?php
44
+ // wp_editor($box['footer'], 'qlwapp_box_footer', array('editor_height' => 50, 'textarea_name' => 'footer'));
45
+ ?>
46
+ <?php
47
+ wp_editor(
48
+ $box['footer'],
49
+ 'qlwapp_box_footer',
50
+ array(
51
+ 'editor_height' => 50,
52
+ 'textarea_name' => 'footer',
53
+ 'tinymce' => array( 'init_instance_callback' => 'function(editor) { editor.on("change", function(){jQuery(document).trigger("tinymce_change");}); }' ),
54
+ )
55
+ );
56
+ ?>
57
+ <p class="description"><?php esc_html_e( 'You can use this vars:', 'wp-whatsapp-chat' ); ?><small><code>{SITE_TITLE} {SITE_URL} {CURRENT_URL} {CURRENT_TITLE}</code></small></p>
58
+ </td>
59
+ </tr>
60
+ <tr>
61
+ <th scope="row"><?php esc_html_e( 'Response', 'wp-whatsapp-chat' ); ?></th>
62
+ <td>
63
+ <input type="text" name="response" placeholder="<?php echo esc_html( $box['response'] ); ?>" value="<?php echo esc_attr( $box['response'] ); ?>" class="qlwapp-input" />
64
+ <p class="description hidden"><?php esc_html_e( 'Write a response text.', 'wp-whatsapp-chat' ); ?></p>
65
+ </td>
66
+ </tr>
67
 
68
+ </tbody>
69
+ </table>
70
+ <?php wp_nonce_field( 'qlwapp_save_box', 'qlwapp_box_form_nonce' ); ?>
71
+ <p class="submit">
72
+ <?php submit_button( esc_html__( 'Save', 'wp-whatsapp-chat' ), 'primary', 'submit', false ); ?>
73
+ <span class="settings-save-status">
74
+ <span class="saved"><?php esc_html_e( 'Saved successfully!' ); ?></span>
75
+ <span class="spinner" style="float: none"></span>
76
+ </span>
77
+ </p>
78
  </form>
79
+ </div>
includes/view/backend/pages/button.php CHANGED
@@ -1,158 +1,171 @@
1
  <div class="wrap about-wrap full-width-layout qlwrap">
2
  <form id="qlwapp_button_form" method="post" action="options.php">
3
- <table class="form-table">
4
- <tbody>
5
- <tr>
6
- <th scope="row"><?php esc_html_e('Layout', 'wp-whatsapp-chat'); ?></th>
7
- <td>
8
- <select name="layout" class="qlwapp-select2">
9
- <option value="button" <?php selected($button['layout'], 'button'); ?>><?php esc_html_e('Button', 'wp-whatsapp-chat'); ?></option>
10
- <option value="bubble" <?php selected($button['layout'], 'bubble'); ?>><?php esc_html_e('Bubble', 'wp-whatsapp-chat'); ?></option>
11
- </select>
12
- <p class="description hidden"><?php esc_html_e('Switch to change the button layout.', 'wp-whatsapp-chat'); ?></p>
13
- </td>
14
- </tr>
15
- <tr>
16
- <th scope="row"><?php esc_html_e('Box', 'wp-whatsapp-chat'); ?></th>
17
- <td>
18
- <select name="box" class="qlwapp-select2">
19
- <option value="yes" <?php selected($button['box'], 'yes'); ?>><?php esc_html_e('Enable contact box', 'wp-whatsapp-chat'); ?></option>
20
- <option value="no" <?php selected($button['box'], 'no'); ?>><?php esc_html_e('Disable contact box', 'wp-whatsapp-chat'); ?></option>
21
- </select>
22
- </td>
23
- </tr>
24
- <tr class="qlwapp-phone-alert <?php echo esc_attr($button['box'] == 'yes' ? '' : 'hidden'); ?>">
25
- <th scope="row"></th>
26
- <td>
27
- <span style="display:block!important;" class="notice notice-error">
28
- <p>
29
- <?php printf(__('Contact box is enabled. Please set the contact phone number in the <a href="%s">contacts tab</a>', 'wp-whatsapp-chat'), admin_url('admin.php?page=' . QLWAPP_DOMAIN . '_contacts')); ?>.
30
- </p>
31
- </span>
32
- </td>
33
- </tr>
34
- <tr>
35
- <th scope="row"><?php esc_html_e('Rounded', 'wp-whatsapp-chat'); ?></th>
36
- <td>
37
- <select name="rounded" class="qlwapp-select2">
38
- <option value="yes" <?php selected($button['rounded'], 'yes'); ?>><?php esc_html_e('Add rounded border', 'wp-whatsapp-chat'); ?></option>
39
- <option value="no" <?php selected($button['rounded'], 'no'); ?>><?php esc_html_e('Remove rounded border', 'wp-whatsapp-chat'); ?></option>
40
- </select>
41
- <p class="description hidden"><?php esc_html_e('Add rounded border to the button.', 'wp-whatsapp-chat'); ?></p>
42
- </td>
43
- </tr>
44
- <tr>
45
- <th scope="row"><?php esc_html_e('Position', 'wp-whatsapp-chat'); ?></th>
46
- <td>
47
- <select name="position" class="qlwapp-select2">
48
- <option value="middle-left" <?php selected($button['position'], 'middle-left'); ?>><?php esc_html_e('Middle Left', 'wp-whatsapp-chat'); ?></option>
49
- <option value="middle-right" <?php selected($button['position'], 'middle-right'); ?>><?php esc_html_e('Middle Right', 'wp-whatsapp-chat'); ?></option>
50
- <option value="bottom-left" <?php selected($button['position'], 'bottom-left'); ?>><?php esc_html_e('Bottom Left', 'wp-whatsapp-chat'); ?></option>
51
- <option value="bottom-right" <?php selected($button['position'], 'bottom-right'); ?>><?php esc_html_e('Bottom Right', 'wp-whatsapp-chat'); ?></option>
52
- </select>
53
- <p class="description hidden"><?php esc_html_e('Switch to change the button position.', 'wp-whatsapp-chat'); ?></p>
54
- </td>
55
- </tr>
56
- <tr>
57
- <th scope="row"><?php esc_html_e('Icon', 'wp-whatsapp-chat'); ?></th>
58
- <td>
59
- <div class="submit qlwapp-premium-field">
60
- <?php submit_button(esc_html__('Add Icon', 'wp-whatsapp-chat'), 'secondary', null, false, array('id' => 'qlwapp_icon_add')); ?>
61
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
62
- </div>
63
- <input type="text" name="icon" placeholder="<?php echo esc_html($button['icon']); ?>" value="<?php echo esc_attr($button['icon']); ?>" class="qlwapp-input" />
64
- </td>
65
- </tr>
66
- <!--<tr>
67
- <th scope="row"><?php esc_html_e('Discreet link', 'wp-whatsapp-chat'); ?></th>
68
- <td>
69
- <select name="developer" class="qlwapp-select2">
70
- <option value="yes" <?php selected($button['developer'], 'yes'); ?>><?php esc_html_e('Show developer link', 'wp-whatsapp-chat'); ?></option>
71
- <option value="no" <?php selected($button['developer'], 'no'); ?>><?php esc_html_e('Hide developer link', 'wp-whatsapp-chat'); ?></option>
72
- </select>
73
- <p class="description hidden"><?php esc_html_e('Leave a discrete link to developer to help and keep new updates and support.', 'wp-whatsapp-chat'); ?></p>
74
- </td>
75
- </tr>-->
76
- <tr>
77
- <th scope="row"><?php esc_html_e('Text', 'wp-whatsapp-chat'); ?></th>
78
- <td>
79
- <input type="text" name="text" placeholder="<?php echo esc_html($button['text']); ?>" value="<?php echo esc_attr($button['text']); ?>" class="qlwapp-input" />
80
- <p class="description"><?php esc_html_e('Customize your button text.', 'wp-whatsapp-chat'); ?></p>
81
- </td>
82
- </tr>
83
- <tr>
84
- <th scope="row"><?php esc_html_e('Phone', 'wp-whatsapp-chat'); ?></th>
85
- <td>
86
- <input type="text" name="phone" placeholder="" value="<?php echo esc_attr($button['phone']); ?>" class="qlwapp-input <?php echo esc_attr($button['box'] == 'yes' ? 'disabled' : ''); ?>" required="required" />
87
- <p class="description"><?php esc_html_e('Full phone number in international format. Only nnumbers.', 'wp-whatsapp-chat'); ?></p>
88
- </td>
89
- </tr>
90
- <tr>
91
- <th scope="row"><?php esc_html_e('Message', 'wp-whatsapp-chat'); ?></th>
92
- <td>
93
- <textarea maxlength="500" style="width:75%;height:50px;padding:8px;" name="message" placeholder="<?php echo esc_html($button['message']); ?>"><?php echo esc_html(trim($button['message'])); ?></textarea>
94
- <p class="description"><?php esc_html_e('Message that will automatically appear in the text field of a chat.', 'wp-whatsapp-chat'); ?></p>
95
- </td>
96
- </tr>
97
- <tr>
98
- <th scope="row"><?php esc_html_e('Schedule', 'wp-whatsapp-chat'); ?></th>
99
- <td class="qlwapp-premium-field">
100
- <b><?php esc_html_e('From', 'wp-whatsapp-chat'); ?></b>
101
- <input type="time" name="timefrom" placeholder="<?php echo esc_html($button['timefrom']); ?>" value="<?php echo esc_html($button['timefrom']); ?>" />
102
- <b><?php esc_html_e('To', 'wp-whatsapp-chat'); ?></b>
103
- <input type="time" name="timeto" placeholder="<?php echo esc_html($button['timeto']); ?>" value="<?php echo esc_html($button['timeto']); ?>" />
104
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
105
- </td>
106
- </tr>
107
- <tr>
108
- <th scope="row"><?php esc_html_e('Timezone', 'wp-whatsapp-chat'); ?></th>
109
- <td class="qlwapp-premium-field">
110
- <select name="timezone" aria-describedby="timezone-description" required="" class="qlwapp-select2">
111
- <?php echo wp_timezone_choice($button['timezone'], get_user_locale()); ?>
112
- </select>
113
- <p class="description"><small><?php esc_html_e('Hide button if the user is out of the available hours.', 'wp-whatsapp-chat'); ?></small></p>
114
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
115
- </td>
116
- </tr>
117
- <tr>
118
- <th scope="row"><?php esc_html_e('Available days', 'wp-whatsapp-chat'); ?></th>
119
- <td class="qlwapp-premium-field">
120
- <select name="timedays[]" multiple style="height:100px;">
121
- <option value="0" <?php echo in_array('0', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Sunday', 'wp-whatsapp-chat'); ?></option>
122
- <option value="1" <?php echo in_array('1', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Monday', 'wp-whatsapp-chat'); ?></option>
123
- <option value="2" <?php echo in_array('2', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Tuesday', 'wp-whatsapp-chat'); ?></option>
124
- <option value="3" <?php echo in_array('3', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Wednesday', 'wp-whatsapp-chat'); ?></option>
125
- <option value="4" <?php echo in_array('4', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Thursday', 'wp-whatsapp-chat'); ?></option>
126
- <option value="5" <?php echo in_array('5', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Friday', 'wp-whatsapp-chat'); ?></option>
127
- <option value="6" <?php echo in_array('6', $button['timedays']) ? 'selected="selected"' : ''; ?>><?php esc_html_e('Saturday', 'wp-whatsapp-chat'); ?></option>
128
- </select>
129
- <p class="description hidden"><small><?php esc_html_e('This is a premium feature', 'wp-whatsapp-chat'); ?></small></p>
130
- </td>
131
- </th>
132
- </tr>
133
- <!-- <tr>
134
- <th scope="row"><?php // esc_html_e('Timeout', 'wp-whatsapp-chat');
135
- ?></th>
136
- <td class="qlwapp-premium-field">
137
- <select name="timeout" class="qlwapp-select2">
138
- <option value="yes" <?php // selected($button['timeout'], 'yes');
139
- ?>><?php esc_html_e('Show the button as read only', 'wp-whatsapp-chat'); ?></option>
140
- <option value="no" <?php // selected($button['timeout'], 'no');
141
- ?>><?php esc_html_e('Do not show the button', 'wp-whatsapp-chat'); ?></option>
142
- </select>
143
- <p class="description hidden"><small><?php //esc_html_e('This is a premium feature', 'wp-whatsapp-chat');
144
- ?></small></p>
145
- </td>
146
- </tr> -->
147
- </tbody>
148
- </table>
149
- <?php wp_nonce_field('qlwapp_save_button', 'qlwapp_button_form_nonce'); ?>
150
- <p class="submit">
151
- <?php submit_button(esc_html__('Save', 'wp-whatsapp-chat'), 'primary', 'submit', false); ?>
152
- <span class="settings-save-status">
153
- <span class="saved"><?php esc_html_e('Saved successfully!'); ?></span>
154
- <span class="spinner" style="float: none"></span>
155
- </span>
156
- </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  </form>
158
- </div>
1
  <div class="wrap about-wrap full-width-layout qlwrap">
2
  <form id="qlwapp_button_form" method="post" action="options.php">
3
+ <table class="form-table">
4
+ <tbody>
5
+ <tr>
6
+ <th scope="row"><?php esc_html_e( 'Layout', 'wp-whatsapp-chat' ); ?></th>
7
+ <td>
8
+ <select name="layout" class="qlwapp-select2">
9
+ <option value="button" <?php selected( $button['layout'], 'button' ); ?>><?php esc_html_e( 'Button', 'wp-whatsapp-chat' ); ?></option>
10
+ <option value="bubble" <?php selected( $button['layout'], 'bubble' ); ?>><?php esc_html_e( 'Bubble', 'wp-whatsapp-chat' ); ?></option>
11
+ </select>
12
+ <p class="description hidden"><?php esc_html_e( 'Switch to change the button layout.', 'wp-whatsapp-chat' ); ?></p>
13
+ </td>
14
+ </tr>
15
+ <tr>
16
+ <th scope="row"><?php esc_html_e( 'Box', 'wp-whatsapp-chat' ); ?></th>
17
+ <td>
18
+ <select name="box" class="qlwapp-select2">
19
+ <option value="yes" <?php selected( $button['box'], 'yes' ); ?>><?php esc_html_e( 'Enable contact box', 'wp-whatsapp-chat' ); ?></option>
20
+ <option value="no" <?php selected( $button['box'], 'no' ); ?>><?php esc_html_e( 'Disable contact box', 'wp-whatsapp-chat' ); ?></option>
21
+ </select>
22
+ </td>
23
+ </tr>
24
+ <tr class="qlwapp-phone-alert <?php echo esc_attr( $button['box'] == 'yes' ? '' : 'hidden' ); ?>">
25
+ <th scope="row"></th>
26
+ <td>
27
+ <span style="display:block!important;" class="notice notice-error">
28
+ <p>
29
+ <?php printf( __( 'Contact box is enabled. Please set the contact phone number in the <a href="%s">contacts tab</a>', 'wp-whatsapp-chat' ), admin_url( 'admin.php?page=' . QLWAPP_DOMAIN . '_contacts' ) ); ?>.
30
+ </p>
31
+ </span>
32
+ </td>
33
+ </tr>
34
+ <tr>
35
+ <th scope="row"><?php esc_html_e( 'Rounded', 'wp-whatsapp-chat' ); ?></th>
36
+ <td>
37
+ <select name="rounded" class="qlwapp-select2">
38
+ <option value="yes" <?php selected( $button['rounded'], 'yes' ); ?>><?php esc_html_e( 'Add rounded border', 'wp-whatsapp-chat' ); ?></option>
39
+ <option value="no" <?php selected( $button['rounded'], 'no' ); ?>><?php esc_html_e( 'Remove rounded border', 'wp-whatsapp-chat' ); ?></option>
40
+ </select>
41
+ <p class="description hidden"><?php esc_html_e( 'Add rounded border to the button.', 'wp-whatsapp-chat' ); ?></p>
42
+ </td>
43
+ </tr>
44
+ <tr>
45
+ <th scope="row"><?php esc_html_e( 'Position', 'wp-whatsapp-chat' ); ?></th>
46
+ <td>
47
+ <select name="position" class="qlwapp-select2">
48
+ <option value="middle-left" <?php selected( $button['position'], 'middle-left' ); ?>><?php esc_html_e( 'Middle Left', 'wp-whatsapp-chat' ); ?></option>
49
+ <option value="middle-right" <?php selected( $button['position'], 'middle-right' ); ?>><?php esc_html_e( 'Middle Right', 'wp-whatsapp-chat' ); ?></option>
50
+ <option value="bottom-left" <?php selected( $button['position'], 'bottom-left' ); ?>><?php esc_html_e( 'Bottom Left', 'wp-whatsapp-chat' ); ?></option>
51
+ <option value="bottom-right" <?php selected( $button['position'], 'bottom-right' ); ?>><?php esc_html_e( 'Bottom Right', 'wp-whatsapp-chat' ); ?></option>
52
+ </select>
53
+ <p class="description hidden"><?php esc_html_e( 'Switch to change the button position.', 'wp-whatsapp-chat' ); ?></p>
54
+ </td>
55
+ </tr>
56
+ <tr>
57
+ <th scope="row"><?php esc_html_e( 'Icon', 'wp-whatsapp-chat' ); ?></th>
58
+ <td>
59
+ <div class="submit qlwapp-premium-field">
60
+ <?php submit_button( esc_html__( 'Add Icon', 'wp-whatsapp-chat' ), 'secondary', null, false, array( 'id' => 'qlwapp_icon_add' ) ); ?>
61
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
62
+ </div>
63
+ <input type="text" name="icon" placeholder="<?php echo esc_html( $button['icon'] ); ?>" value="<?php echo esc_attr( $button['icon'] ); ?>" class="qlwapp-input" />
64
+ </td>
65
+ </tr>
66
+ <!--<tr>
67
+ <th scope="row"><?php esc_html_e( 'Discreet link', 'wp-whatsapp-chat' ); ?></th>
68
+ <td>
69
+ <select name="developer" class="qlwapp-select2">
70
+ <option value="yes" <?php selected( $button['developer'], 'yes' ); ?>><?php esc_html_e( 'Show developer link', 'wp-whatsapp-chat' ); ?></option>
71
+ <option value="no" <?php selected( $button['developer'], 'no' ); ?>><?php esc_html_e( 'Hide developer link', 'wp-whatsapp-chat' ); ?></option>
72
+ </select>
73
+ <p class="description hidden"><?php esc_html_e( 'Leave a discrete link to developer to help and keep new updates and support.', 'wp-whatsapp-chat' ); ?></p>
74
+ </td>
75
+ </tr>-->
76
+ <tr>
77
+ <th scope="row"><?php esc_html_e( 'Text', 'wp-whatsapp-chat' ); ?></th>
78
+ <td>
79
+ <input type="text" name="text" placeholder="<?php echo esc_html( $button['text'] ); ?>" value="<?php echo esc_attr( $button['text'] ); ?>" class="qlwapp-input" />
80
+ <p class="description"><?php esc_html_e( 'Customize your button text.', 'wp-whatsapp-chat' ); ?></p>
81
+ </td>
82
+ </tr>
83
+ <tr>
84
+ <th scope="row"><?php esc_html_e( 'Phone', 'wp-whatsapp-chat' ); ?></th>
85
+ <td>
86
+ <input type="text" name="phone" placeholder="" value="<?php echo esc_attr( $button['phone'] ); ?>" class="qlwapp-input <?php echo esc_attr( $button['box'] == 'yes' ? 'disabled' : '' ); ?>" required="required" />
87
+ <p class="description"><?php esc_html_e( 'Full phone number in international format. Only nnumbers.', 'wp-whatsapp-chat' ); ?></p>
88
+ </td>
89
+ </tr>
90
+ <tr>
91
+ <th scope="row"><?php esc_html_e( 'Message', 'wp-whatsapp-chat' ); ?></th>
92
+ <td>
93
+ <textarea maxlength="500" style="width:75%;height:50px;padding:8px;" name="message" placeholder="<?php echo esc_html( $button['message'] ); ?>"><?php echo esc_html( trim( $button['message'] ) ); ?></textarea>
94
+ <p class="description"><?php esc_html_e( 'Message that will automatically appear in the text field of a chat.:', 'wp-whatsapp-chat' ); ?></p>
95
+ <p class="description"><?php esc_html_e( 'You can use this vars:', 'wp-whatsapp-chat' ); ?><small><code>{SITE_TITLE} {SITE_URL} {CURRENT_URL} {CURRENT_TITLE}</code></small></p>
96
+ </td>
97
+ </tr>
98
+ <tr>
99
+ <th scope="row"><?php esc_html_e( 'Schedule', 'wp-whatsapp-chat' ); ?></th>
100
+ <td class="qlwapp-premium-field">
101
+ <b><?php esc_html_e( 'From', 'wp-whatsapp-chat' ); ?></b>
102
+ <input type="time" name="timefrom" placeholder="<?php echo esc_html( $button['timefrom'] ); ?>" value="<?php echo esc_html( $button['timefrom'] ); ?>" />
103
+ <b><?php esc_html_e( 'To', 'wp-whatsapp-chat' ); ?></b>
104
+ <input type="time" name="timeto" placeholder="<?php echo esc_html( $button['timeto'] ); ?>" value="<?php echo esc_html( $button['timeto'] ); ?>" />
105
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
106
+ </td>
107
+ </tr>
108
+ <tr>
109
+ <th scope="row"><?php esc_html_e( 'Timezone', 'wp-whatsapp-chat' ); ?></th>
110
+ <td class="qlwapp-premium-field">
111
+ <select name="timezone" aria-describedby="timezone-description" required="" class="qlwapp-select2">
112
+ <?php echo wp_timezone_choice( $button['timezone'], get_user_locale() ); ?>
113
+ </select>
114
+ <p class="description"><small><?php esc_html_e( 'Hide button if the user is out of the available hours.', 'wp-whatsapp-chat' ); ?></small></p>
115
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
116
+ </td>
117
+ </tr>
118
+ <tr>
119
+ <th scope="row"><?php esc_html_e( 'Available days', 'wp-whatsapp-chat' ); ?></th>
120
+ <td class="qlwapp-premium-field">
121
+ <select name="timedays[]" multiple style="height:100px;">
122
+ <option value="0" <?php echo in_array( '0', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Sunday', 'wp-whatsapp-chat' ); ?></option>
123
+ <option value="1" <?php echo in_array( '1', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Monday', 'wp-whatsapp-chat' ); ?></option>
124
+ <option value="2" <?php echo in_array( '2', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Tuesday', 'wp-whatsapp-chat' ); ?></option>
125
+ <option value="3" <?php echo in_array( '3', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Wednesday', 'wp-whatsapp-chat' ); ?></option>
126
+ <option value="4" <?php echo in_array( '4', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Thursday', 'wp-whatsapp-chat' ); ?></option>
127
+ <option value="5" <?php echo in_array( '5', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Friday', 'wp-whatsapp-chat' ); ?></option>
128
+ <option value="6" <?php echo in_array( '6', $button['timedays'] ) ? 'selected="selected"' : ''; ?>><?php esc_html_e( 'Saturday', 'wp-whatsapp-chat' ); ?></option>
129
+ </select>
130
+ <p class="description hidden"><small><?php esc_html_e( 'This is a premium feature', 'wp-whatsapp-chat' ); ?></small></p>
131
+ </td>
132
+ </th>
133
+ </tr>
134
+ <!-- <tr>
135
+ <th scope="row">
136
+ <?php
137
+ // esc_html_e('Timeout', 'wp-whatsapp-chat');
138
+ ?>
139
+ </th>
140
+ <td class="qlwapp-premium-field">
141
+ <select name="timeout" class="qlwapp-select2">
142
+ <option value="yes"
143
+ <?php
144
+ // selected($button['timeout'], 'yes');
145
+ ?>
146
+ ><?php esc_html_e( 'Show the button as read only', 'wp-whatsapp-chat' ); ?></option>
147
+ <option value="no"
148
+ <?php
149
+ // selected($button['timeout'], 'no');
150
+ ?>
151
+ ><?php esc_html_e( 'Do not show the button', 'wp-whatsapp-chat' ); ?></option>
152
+ </select>
153
+ <p class="description hidden"><small>
154
+ <?php
155
+ // esc_html_e('This is a premium feature', 'wp-whatsapp-chat');
156
+ ?>
157
+ </small></p>
158
+ </td>
159
+ </tr> -->
160
+ </tbody>
161
+ </table>
162
+ <?php wp_nonce_field( 'qlwapp_save_button', 'qlwapp_button_form_nonce' ); ?>
163
+ <p class="submit">
164
+ <?php submit_button( esc_html__( 'Save', 'wp-whatsapp-chat' ), 'primary', 'submit', false ); ?>
165
+ <span class="settings-save-status">
166
+ <span class="saved"><?php esc_html_e( 'Saved successfully!' ); ?></span>
167
+ <span class="spinner" style="float: none"></span>
168
+ </span>
169
+ </p>
170
  </form>
171
+ </div>
includes/view/backend/pages/modals/contact/panel-contact-chat.php CHANGED
@@ -7,6 +7,8 @@
7
  <# } else { #>
8
  <span class="description"><small><?php esc_html_e('Default message sent to the contact number.', 'wp-whatsapp-chat'); ?></small></span>
9
  <# } #>
 
 
10
  </p>
11
  </div>
12
  <div class="options_group qlwapp-premium-field">
7
  <# } else { #>
8
  <span class="description"><small><?php esc_html_e('Default message sent to the contact number.', 'wp-whatsapp-chat'); ?></small></span>
9
  <# } #>
10
+ <br/>
11
+ <span class="description"><small><?php esc_html_e( 'You can use this vars:', 'wp-whatsapp-chat' ); ?><code>{SITE_TITLE} {SITE_URL} {CURRENT_URL} {CURRENT_TITLE}</code></small></span>
12
  </p>
13
  </div>
14
  <div class="options_group qlwapp-premium-field">
readme.txt CHANGED
@@ -5,7 +5,7 @@ Tags: whatsapp, whatsapp business, click to chat, whatsapp chat, whatsapp suppor
5
  Requires at least: 4.6
6
  Requires PHP: 5.6
7
  Tested up to: 6.0.1
8
- Stable tag: 5.0.5
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -45,6 +45,14 @@ WhatsApp Chat also allows you to include a box to show some contact information
45
  > * Custom button text
46
  > * Custom user message
47
 
 
 
 
 
 
 
 
 
48
  == WhatsApp Premium ==
49
  The premium version of the WhatsApp Chat plugin allows you to include multiple team member agents, distinguishing their names and labels inside. The contact box helps to provide direct contacts to the different support areas of your site.
50
  A new option to display a chatbox for each agent is included. This box will be displayed when the user clicks on the WhatsApp contact, and you can define custom message to be shown from each contact. Your users will be able to type the message that will be sent to the WhatsApp contact phone.
@@ -109,6 +117,9 @@ Don't use: +001-(555)1234567
109
 
110
  == Changelog ==
111
 
 
 
 
112
  = 5.0.5 =
113
  * Fix. WordPress compatibility
114
 
5
  Requires at least: 4.6
6
  Requires PHP: 5.6
7
  Tested up to: 6.0.1
8
+ Stable tag: 5.0.6
9
  License: GPLv3
10
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
11
 
45
  > * Custom button text
46
  > * Custom user message
47
 
48
+ == WhatsApp Message Dynamic Variables ==
49
+ Synce version 5.0.6 you're able use variables in your WhatsApp Button or contact messages.
50
+
51
+ {SITE_TITLE} ➡ Is replaced by the current site title
52
+ {SITE_URL} ➡ Is replaced by the current site url
53
+ {CURRENT_TITLE} ➡ Is replaced by the current page title
54
+ {CURRENT_URL} ➡ Is replaced by the current page url
55
+
56
  == WhatsApp Premium ==
57
  The premium version of the WhatsApp Chat plugin allows you to include multiple team member agents, distinguishing their names and labels inside. The contact box helps to provide direct contacts to the different support areas of your site.
58
  A new option to display a chatbox for each agent is included. This box will be displayed when the user clicks on the WhatsApp contact, and you can define custom message to be shown from each contact. Your users will be able to type the message that will be sent to the WhatsApp contact phone.
117
 
118
  == Changelog ==
119
 
120
+ = 5.0.6 =
121
+ * New. WhatsApp chat message vars
122
+
123
  = 5.0.5 =
124
  * Fix. WordPress compatibility
125
 
wp-whatsapp-chat.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Social Chat
5
  * Description: Social Chat allows your visitors to contact you or your team through WhatsApp chat with a single click.
6
  * Plugin URI: https://quadlayers.com/portfolio/whatsapp-chat/
7
- * Version: 5.0.5
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) {
17
  }
18
 
19
  define( 'QLWAPP_PLUGIN_NAME', 'Social Chat' );
20
- define( 'QLWAPP_PLUGIN_VERSION', '5.0.5' );
21
  define( 'QLWAPP_PLUGIN_FILE', __FILE__ );
22
  define( 'QLWAPP_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR );
23
  define( 'QLWAPP_PREFIX', 'qlwapp' );
4
  * Plugin Name: Social Chat
5
  * Description: Social Chat allows your visitors to contact you or your team through WhatsApp chat with a single click.
6
  * Plugin URI: https://quadlayers.com/portfolio/whatsapp-chat/
7
+ * Version: 5.0.6
8
  * Author: QuadLayers
9
  * Author URI: https://quadlayers.com
10
  * License: GPLv3
17
  }
18
 
19
  define( 'QLWAPP_PLUGIN_NAME', 'Social Chat' );
20
+ define( 'QLWAPP_PLUGIN_VERSION', '5.0.6' );
21
  define( 'QLWAPP_PLUGIN_FILE', __FILE__ );
22
  define( 'QLWAPP_PLUGIN_DIR', __DIR__ . DIRECTORY_SEPARATOR );
23
  define( 'QLWAPP_PREFIX', 'qlwapp' );