WP-Chatbot for Facebook Messenger Customer Chat - Version 1.2.0

Version Description

  • Shortcode - beta
  • Hide Messenger based on Devices
Download this release

Release Info

Developer bhvreddy
Plugin Icon 128x128 WP-Chatbot for Facebook Messenger Customer Chat
Version 1.2.0
Comparing to
See all releases

Code changes from version 1.1.1 to 1.2.0

admin/class-htcc-admin.php CHANGED
@@ -73,11 +73,13 @@ class HTCC_Admin {
73
add_settings_field( 'enable', 'Enable', array( $this, 'htcc_enable_cb' ), 'htcc_options_settings', 'htcc_settings' );
74
add_settings_field( 'htcc_fb_app_id', 'Facebook App ID', array( $this, 'htcc_fb_app_id_cb' ), 'htcc_options_settings', 'htcc_settings' );
75
add_settings_field( 'htcc_fb_page_id', 'Facebook Page ID', array( $this, 'htcc_fb_page_id_cb' ), 'htcc_options_settings', 'htcc_settings' );
76
-
77
- add_settings_field( 'htcc_show_hide', 'Hide on', array( $this, 'htcc_show_hide_post_types_cb' ), 'htcc_options_settings', 'htcc_settings' );
78
-
79
add_settings_field( 'htcc_list_id_tohide', 'Post, Page Id\'s to Hide', array( $this, 'htcc_list_id_tohide_cb' ), 'htcc_options_settings', 'htcc_settings' );
80
add_settings_field( 'htcc_list_cat_tohide', 'Categorys to Hide', array( $this, 'htcc_list_cat_tohide_cb' ), 'htcc_options_settings', 'htcc_settings' );
81
}
82
83
// section heading
@@ -283,6 +285,67 @@ class HTCC_Admin {
283
284
285
286
287
288
@@ -336,6 +399,15 @@ class HTCC_Admin {
336
if( isset( $input['list_hideon_cat'] ) )
337
$new_input['list_hideon_cat'] = sanitize_text_field( $input['list_hideon_cat'] );
338
339
return $new_input;
340
}
341
73
add_settings_field( 'enable', 'Enable', array( $this, 'htcc_enable_cb' ), 'htcc_options_settings', 'htcc_settings' );
74
add_settings_field( 'htcc_fb_app_id', 'Facebook App ID', array( $this, 'htcc_fb_app_id_cb' ), 'htcc_options_settings', 'htcc_settings' );
75
add_settings_field( 'htcc_fb_page_id', 'Facebook Page ID', array( $this, 'htcc_fb_page_id_cb' ), 'htcc_options_settings', 'htcc_settings' );
76
+ add_settings_field( 'htcc_show_hide', 'Hide Based on post type', array( $this, 'htcc_show_hide_post_types_cb' ), 'htcc_options_settings', 'htcc_settings' );
77
add_settings_field( 'htcc_list_id_tohide', 'Post, Page Id\'s to Hide', array( $this, 'htcc_list_id_tohide_cb' ), 'htcc_options_settings', 'htcc_settings' );
78
add_settings_field( 'htcc_list_cat_tohide', 'Categorys to Hide', array( $this, 'htcc_list_cat_tohide_cb' ), 'htcc_options_settings', 'htcc_settings' );
79
+ add_settings_field( 'htcc_devices_show_hide', 'Hide Based on Devices', array( $this, 'htcc_show_hide_devices_cb' ), 'htcc_options_settings', 'htcc_settings' );
80
+
81
+ add_settings_field( 'htcc_shortcode', 'Shortcode name', array( $this, 'htcc_custom_shortcode_cb' ), 'htcc_options_settings', 'htcc_settings' );
82
+
83
}
84
85
// section heading
285
286
287
288
+ // checkboxes - based on Type of posts ..
289
+ public function htcc_show_hide_devices_cb() {
290
+ $htcc_devices = get_option('htcc_options');
291
+
292
+ // Hide on Mobile Devices
293
+ if ( isset( $htcc_devices['hideon_mobile'] ) ) {
294
+ ?>
295
+ <p>
296
+ <input name="htcc_options[hideon_mobile]" type="checkbox" value="1" <?php checked( $htcc_devices['hideon_mobile'], 1 ); ?> id="hideon_mobile" />
297
+ <label for="hideon_mobile">Hide on - Mobile Devices</label>
298
+ </p>
299
+ <?php
300
+ } else {
301
+ ?>
302
+ <p>
303
+ <input name="htcc_options[hideon_mobile]" type="checkbox" value="1" id="hideon_mobile" />
304
+ <label for="hideon_mobile">Hide on - Mobile Devices</label>
305
+ </p>
306
+ <?php
307
+ }
308
+
309
+
310
+ // Hide on Desktop Devices
311
+ if ( isset( $htcc_devices['hideon_desktop'] ) ) {
312
+ ?>
313
+ <p>
314
+ <input name="htcc_options[hideon_desktop]" type="checkbox" value="1" <?php checked( $htcc_devices['hideon_desktop'], 1 ); ?> id="hideon_desktop" />
315
+ <label for="hideon_desktop">Hide on - Desktops</label>
316
+ </p>
317
+ <?php
318
+ } else {
319
+ ?>
320
+ <p>
321
+ <input name="htcc_options[hideon_desktop]" type="checkbox" value="1" id="hideon_desktop" />
322
+ <label for="hideon_desktop">Hide on - Desktops</label>
323
+ </p>
324
+ <?php
325
+ }
326
+ }
327
+
328
+
329
+ // Custom shortcode
330
+ function htcc_custom_shortcode_cb() {
331
+ $htcc_shortcode = get_option('htcc_options');
332
+ ?>
333
+ <div class="row">
334
+ <div class="input-field col s12">
335
+ <input name="htcc_options[shortcode]" value="<?php echo esc_attr( $htcc_shortcode['shortcode'] ) ?>" id="shortcode" type="text" class="validate input-margin">
336
+ <label for="shortcode">shortcode name</label>
337
+ <?php
338
+ $shorcode_list = '';
339
+ foreach ($GLOBALS['shortcode_tags'] AS $key => $value) {
340
+ $shorcode_list .= $key . ', ';
341
+ }
342
+ ?>
343
+ <p class="description"> Default values is 'chatbot', can customize shortcode name - <a target="_blank" href="https://holithemes.com/wp-chatbot/change-shortcode-name/">more info</a> </p>
344
+ <p class="description"> please dont add this already existing shorcode names - <?php echo $shorcode_list ?> </p>
345
+ </div>
346
+ </div>
347
+ <?php
348
+ }
349
350
351
399
if( isset( $input['list_hideon_cat'] ) )
400
$new_input['list_hideon_cat'] = sanitize_text_field( $input['list_hideon_cat'] );
401
402
+ if( isset( $input['hideon_mobile'] ) )
403
+ $new_input['hideon_mobile'] = sanitize_text_field( $input['hideon_mobile'] );
404
+
405
+ if( isset( $input['hideon_desktop'] ) )
406
+ $new_input['hideon_desktop'] = sanitize_text_field( $input['hideon_desktop'] );
407
+
408
+ if( isset( $input['shortcode'] ) )
409
+ $new_input['shortcode'] = sanitize_text_field( $input['shortcode'] );
410
+
411
return $new_input;
412
}
413
inc/class-htcc-chatbot.php CHANGED
@@ -1,5 +1,6 @@
1
<?php
2
/**
3
* get app id
4
* get page id
5
* and add it to script, div
@@ -17,8 +18,8 @@ class HTCC_Chatbot {
17
18
$htcc_fb_app_id = esc_attr( $htcc_options['fb_app_id'] );
19
$htcc_fb_page_id = esc_attr( $htcc_options['fb_page_id'] );
20
-
21
-
22
$enable = esc_attr( $htcc_options['enable'] );
23
24
/**
@@ -91,6 +92,27 @@ class HTCC_Chatbot {
91
}
92
}
93
94
95
?>
96
1
<?php
2
/**
3
+ * check condtions to display messenger or not
4
* get app id
5
* get page id
6
* and add it to script, div
18
19
$htcc_fb_app_id = esc_attr( $htcc_options['fb_app_id'] );
20
$htcc_fb_page_id = esc_attr( $htcc_options['fb_page_id'] );
21
+
22
+ $shortcode_name = esc_attr( $htcc_options['shortcode'] );
23
$enable = esc_attr( $htcc_options['enable'] );
24
25
/**
92
}
93
}
94
95
+ // if shortcode added in post, then dont add default one ( this one )
96
+ global $post;
97
+ if( is_a( $post, 'WP_Post' ) && has_shortcode( $post->post_content, $shortcode_name ) ) {
98
+ return;
99
+ }
100
+
101
+
102
+
103
+ // Hide based on Devices - Mobile, Desktop
104
+ $is_mobile = $GLOBALS["htcc_isMob"];
105
+
106
+ if ( 1 == $is_mobile ) {
107
+ if ( isset( $htcc_options['hideon_mobile'] ) ) {
108
+ return;
109
+ }
110
+ } else {
111
+ if ( isset( $htcc_options['hideon_desktop'] ) ) {
112
+ return;
113
+ }
114
+ }
115
+
116
117
?>
118
inc/class-htcc-db.php CHANGED
@@ -54,13 +54,7 @@ class HTCC_db {
54
'list_hideon_pages' => '',
55
'list_hideon_cat' => '',
56
57
- // 'showon_posts' => '1',
58
- // 'showon_page' => '1',
59
- // 'showon_homepage' => '1',
60
- // 'showon_frontpage' => '1',
61
- // 'showon_category' => '1',
62
- // 'showon_archive' => '1',
63
- // 'showon_404' => '1',
64
65
);
66
54
'list_hideon_pages' => '',
55
'list_hideon_cat' => '',
56
57
+ 'shortcode' => 'chatbot',
58
59
);
60
inc/class-htcc-shortcode.php ADDED
@@ -0,0 +1,86 @@
1
+ <?php
2
+ /**
3
+ * shortcodes
4
+ * base shorcode name is [chat]
5
+ * for list of attribute support check -> shortcode_atts ( $a )
6
+ *
7
+ * @package ccw
8
+ * @since 1.0
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) exit;
12
+
13
+ if ( ! class_exists( 'HTCC_Shortcode' ) ) :
14
+
15
+ class HTCC_Shortcode {
16
+
17
+ function shortcode($atts = [], $content = null, $shortcode = '') {
18
+
19
+ $global_app_id = $GLOBALS["htcc_app_id"];
20
+ $global_page_id = $GLOBALS["htcc_page_id"];
21
+
22
+ $htcc_options = get_option('htcc_options');
23
+
24
+ $a = shortcode_atts(
25
+ array(
26
+ 'app_id' => $global_app_id,
27
+ 'page_id' => $global_page_id,
28
+
29
+ ), $atts, $shortcode );
30
+
31
+
32
+ $app_id = $a["app_id"];
33
+ $page_id = $a["page_id"];
34
+
35
+ $is_mobile = $GLOBALS["htcc_isMob"];
36
+
37
+ $o = '';
38
+ $o .= "<script>
39
+ window.fbAsyncInit = function() {
40
+ FB.init({
41
+ appId : $app_id,
42
+ autoLogAppEvents : true,
43
+ xfbml : true,
44
+ version : 'v2.11'
45
+ });
46
+ };
47
+
48
+ (function(d, s, id){
49
+ var js, fjs = d.getElementsByTagName(s)[0];
50
+ if (d.getElementById(id)) {return;}
51
+ js = d.createElement(s); js.id = id;
52
+ js.src = 'https://connect.facebook.net/en_US/sdk.js';
53
+ fjs.parentNode.insertBefore(js, fjs);
54
+ }(document, 'script', 'facebook-jssdk'));
55
+ </script>";
56
+
57
+
58
+ $o .= '';
59
+ $o .= '<div class="htcc-messenger">
60
+ <div class="fb-customerchat"
61
+ page_id=" '.$page_id.' "
62
+ ref=""
63
+ minimized="true">
64
+ </div>
65
+ </div>';
66
+ $o .= '';
67
+
68
+
69
+ return $o;
70
+ }
71
+
72
+
73
+ // Register shortcode
74
+ function htcc_shortcodes_init() {
75
+ // add_shortcode('chatbot', array( $this, 'shortcode' ));
76
+ add_shortcode($GLOBALS["htcc_shortcode"], array( $this, 'shortcode' ) );
77
+ }
78
+
79
+
80
+ }
81
+
82
+ $shortcode = new HTCC_Shortcode();
83
+
84
+ add_action('init', array( $shortcode, 'htcc_shortcodes_init' ) );
85
+
86
+ endif; // END class_exists check
inc/commons/variables.php ADDED
@@ -0,0 +1,29 @@
1
+ <?php
2
+ /**
3
+ * Global Variables
4
+ *
5
+ * @since 1.0
6
+ */
7
+
8
+ if ( ! defined( 'ABSPATH' ) ) exit;
9
+
10
+
11
+ $htcc_options = get_option('htcc_options');
12
+
13
+ $GLOBALS["htcc_app_id"] = esc_attr( $htcc_options['fb_app_id'] );
14
+ $GLOBALS["htcc_page_id"] = esc_attr( $htcc_options['fb_page_id'] );
15
+
16
+ $GLOBALS["htcc_shortcode"] = esc_attr( $htcc_options['shortcode'] );
17
+
18
+
19
+
20
+
21
+
22
+ if ( wp_is_mobile() ) {
23
+ $isMob = 1;
24
+ } else {
25
+ $isMob = 2;
26
+ }
27
+
28
+ $GLOBALS["htcc_isMob"] = $isMob;
29
+
readme.txt CHANGED
@@ -1,30 +1,32 @@
1
- === WP CHATBOT ===
2
Requires at least: 4.0.0
3
Tested up to: 4.9.1
4
Requires PHP: 5.6
5
Contributors: bhvreddy, holithemes
6
Donate link: https://www.paypal.me/ugadi
7
Stable tag: trunk
8
- Tags: messenger, customer chat plugin, facebook customer chat, facebook chat, chatbot, messenger chatbot, messenger customer chat, facebook live chat, live chat ,messenger live chat, holithemes
9
License: GPLv2 or later
10
License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
12
13
== Description ==
14
- Add Messenger to your website. Chatbot or live chat to your Customers from your website using Facebook messenger.
15
16
== Documentation ==
17
18
- Live chat to your customers or integrate chatbot to messenger and that bot's will message to your customers.
19
20
[Documentation, Demo](https://holithemes.com/wp-chatbot/)
21
22
- This plugin is for integrate Facebook Messenger [Customer Chat plugin](https://developers.facebook.com/docs/messenger-platform/discovery/customer-chat-plugin)
23
24
= Tools to build Chatbots for messenger =
25
Chatfuel
26
Manychat
27
28
29
= Requires =
30
Facebook Developer account
@@ -38,14 +40,11 @@ Facebook Page ID
38
1. Create Facebook Page
39
1. Whitelisted Domains - Facebook page -> 'settings' -> 'Messenger Platform' tab and at 'Whitelisted Domains' add domain names.
40
41
- In plugin setting page
42
- add Facebook App ID, Facebook Page ID
43
44
- we create a bot which explain [settings](http://m.me/135269407170658)
45
46
- the same can check in Messenger from [Demo website](https://holithemes.com/wp-chatbot/) located at bottom right.
47
-
48
- and for creating automatic messages - use tools like Chatfuel or some other tools
49
50
51
== Installation ==
@@ -74,6 +73,10 @@ and for creating automatic messages - use tools like Chatfuel or some other tool
74
75
== Changelog ==
76
77
= 1.1.1 =
78
* Hide messenger based on page type ( now - check to hide )
79
1
+ === WP Chatbot for facebook Messenger ===
2
Requires at least: 4.0.0
3
Tested up to: 4.9.1
4
Requires PHP: 5.6
5
Contributors: bhvreddy, holithemes
6
Donate link: https://www.paypal.me/ugadi
7
Stable tag: trunk
8
+ Tags: messenger, customer chat plugin, customer chat, facebook customer chat, facebook chat, chatbot, messenger chatbot, messenger customer chat, facebook live chat, live chat, messenger live chat, holithemes
9
License: GPLv2 or later
10
License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
12
13
== Description ==
14
+ Add Messenger to your website. Chat bot or live chat to your Customers from your website Messenger. build for Facebook Messenger Customer Chat plugin.
15
16
== Documentation ==
17
18
+ Live chat to your customers or integrate chatbot to messenger and let bots chat to your customers.
19
20
[Documentation, Demo](https://holithemes.com/wp-chatbot/)
21
22
+ This plugin is for integrate Facebook Messenger [Customer Chat plugin](https://developers.facebook.com/docs/messenger-platform/discovery/customer-chat-plugin) in your Website.
23
24
= Tools to build Chatbots for messenger =
25
Chatfuel
26
Manychat
27
28
+ wit.ai
29
+ dialogflow
30
31
= Requires =
32
Facebook Developer account
40
1. Create Facebook Page
41
1. Whitelisted Domains - Facebook page -> 'settings' -> 'Messenger Platform' tab and at 'Whitelisted Domains' add domain names.
42
43
+ In plugin setting page - add Facebook App ID, Facebook Page ID
44
45
+ [settings page](https://holithemes.com/wp-chatbot/wp-chatbot-settings/), At the bottom-right corner, we can check the demo messenger, it can explain plugin Settings
46
47
+ And for creating automatic messages - use tools like Chatfuel or so..
48
49
50
== Installation ==
73
74
== Changelog ==
75
76
+ = 1.2.0 =
77
+ * Shortcode - beta
78
+ * Hide Messenger based on Devices
79
+
80
= 1.1.1 =
81
* Hide messenger based on page type ( now - check to hide )
82
wp-chatbot.php CHANGED
@@ -2,7 +2,7 @@
2
/*
3
Plugin Name: WP Chatbot for facebook Messenger
4
Description: Add Messenger to your website, Chatbot or live Chat using Facebook Messenger
5
- Version: 1.1.1
6
Author: bhvreddy
7
License: GPL2
8
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -12,7 +12,7 @@ Text Domain: htcc_text
12
13
if ( ! defined( 'ABSPATH' ) ) exit;
14
15
- define( 'HTCC_VERSION', '1.1.1' );
16
define( 'HTCC_WP_MIN_VERSION', '3.1.0' );
17
define( 'HTCC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
18
define( 'HTCC_PLUGIN_FILE', __FILE__ );
@@ -20,6 +20,7 @@ define( 'HTCC_PLUGIN_FILE', __FILE__ );
20
21
// include in admin and public pages ( non-admin )
22
require_once('inc/class-htcc-db.php');
23
require_once('inc/class-htcc-register.php');
24
25
@@ -32,6 +33,7 @@ if ( is_admin() ) {
32
require_once('admin/admin.php');
33
} else {
34
require_once('inc/class-htcc-chatbot.php');
35
36
}
37
2
/*
3
Plugin Name: WP Chatbot for facebook Messenger
4
Description: Add Messenger to your website, Chatbot or live Chat using Facebook Messenger
5
+ Version: 1.2.0
6
Author: bhvreddy
7
License: GPL2
8
License URI: https://www.gnu.org/licenses/gpl-2.0.html
12
13
if ( ! defined( 'ABSPATH' ) ) exit;
14
15
+ define( 'HTCC_VERSION', '1.2.0' );
16
define( 'HTCC_WP_MIN_VERSION', '3.1.0' );
17
define( 'HTCC_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
18
define( 'HTCC_PLUGIN_FILE', __FILE__ );
20
21
// include in admin and public pages ( non-admin )
22
require_once('inc/class-htcc-db.php');
23
+ require_once('inc/commons/variables.php');
24
require_once('inc/class-htcc-register.php');
25
26
33
require_once('admin/admin.php');
34
} else {
35
require_once('inc/class-htcc-chatbot.php');
36
+ require_once('inc/class-htcc-shortcode.php');
37
38
}
39