WP-Chatbot for Facebook Messenger Customer Chat - Version 4.1.3

Version Description

Added ability to upgrade to Pro

Download this release

Release Info

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

Code changes from version 4.1.2 to 4.1.3

admin/admin.php CHANGED
@@ -30,10 +30,12 @@ add_action( 'admin_init', array( $admin, 'htcc_incomplete_setup' ) );
30
  add_action('admin_init', 'htcc_admin_notice');
31
  add_action('admin_notices', array( $admin, 'example_admin_notice'));
32
  add_action('wp_ajax_send_done', array($admin,'set_tab_done'));
 
33
  add_action('wp_ajax_get_done', array($admin,'get_tab_done'));
34
  add_action('wp_ajax_set_current_tab', array($admin,'set_current_tab'));
35
  add_action('wp_ajax_create_subscribe', array($api,'create_subscribe'));
36
  add_action('wp_ajax_cancel_subscribe', array($api,'cancel_subscribe'));
 
37
 
38
 
39
 
30
  add_action('admin_init', 'htcc_admin_notice');
31
  add_action('admin_notices', array( $admin, 'example_admin_notice'));
32
  add_action('wp_ajax_send_done', array($admin,'set_tab_done'));
33
+ add_action('wp_ajax_create_bot', array($api,'create_bot'));
34
  add_action('wp_ajax_get_done', array($admin,'get_tab_done'));
35
  add_action('wp_ajax_set_current_tab', array($admin,'set_current_tab'));
36
  add_action('wp_ajax_create_subscribe', array($api,'create_subscribe'));
37
  add_action('wp_ajax_cancel_subscribe', array($api,'cancel_subscribe'));
38
+ add_action('wp_ajax_csv', array($api,'csv'));
39
 
40
 
41
 
admin/assets/css/admin-styles.css CHANGED
@@ -515,6 +515,25 @@ body .toc-tab-box .button {
515
  flex-direction: row;
516
  }
517
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
518
  .test-bot-button {
519
  position: absolute;
520
  right: 0;
@@ -601,15 +620,6 @@ body {
601
  .step-wrapper .tab-link.current span.tab_header{
602
  background-color: #ffffff;
603
  }
604
- .step-wrapper .tab_header .setup_statement {
605
- width: auto;
606
- margin-left: auto;
607
- margin-right: 2em;
608
- font-size: 18px;
609
- text-transform: uppercase;
610
- color: #ca4646;
611
- font-weight: 600;
612
- }
613
 
614
  .step-wrapper ul.tabs_wrapper {
615
  margin: 0px;
@@ -898,7 +908,8 @@ p.submit{
898
  align-items: center;
899
  top: -4px;
900
  width: 107%;
901
- height: 60px;
 
902
  left: -15px;
903
  }
904
 
@@ -907,10 +918,12 @@ p.submit{
907
  }
908
  .pro_button__wrapper .pro_button__link{
909
  width: 100%;
 
910
  }
911
  .pro_button__wrapper .pro_button__link:focus{
912
  border: 0;
913
  box-shadow: none;
 
914
  }
915
 
916
  .customization_button__wrapper .customization_button__image {
@@ -938,6 +951,25 @@ p.submit{
938
  .pro_button__wrapper .pro_button{
939
  display: flex;
940
  justify-content: space-between;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
941
  }
942
 
943
  .customization_button__wrapper .customization_button .customization_button__content,.pro_button__wrapper .pro_button .pro_button__content {
@@ -1010,7 +1042,7 @@ p.submit{
1010
  .form-table p.description{
1011
  font-style: normal;
1012
  }
1013
- #to_pro,#unsaved_option, #pro_option,#cancel {
1014
  z-index: 999;
1015
  transition: all 0.5s ease;
1016
  background-color: #FFFFFF;
@@ -1026,7 +1058,7 @@ p.submit{
1026
  border-radius: 10px;
1027
  }
1028
 
1029
- #to_pro .modal_close,#unsaved_option .modal_close,#pro_option .modal_close,#cancel .modal_close{
1030
  background-size: contain;
1031
  width: 15px;
1032
  height: 15px;
@@ -1039,19 +1071,19 @@ p.submit{
1039
  z-index: 999;
1040
  }
1041
 
1042
- #to_pro .upgrade__wrapper,#unsaved_option .unsaved__wrapper,#cancel .cancel__wrapper{
1043
  position: relative;
1044
  height: 302px;
1045
  padding-top: 1em;
1046
  }
1047
 
1048
- #to_pro .upgrade__content,#unsaved_option .unsaved__content,#cancel .cancel__content{
1049
  padding: 1.5em;
1050
  }
1051
 
1052
 
1053
 
1054
- #to_pro .upgrade__button, #unsaved_option .unsaved__button,#cancel .cancel__button{
1055
  padding: 1.5em 2em;
1056
  text-align: center;
1057
  position: absolute;
@@ -1122,6 +1154,21 @@ p.submit{
1122
  .modal .mm__content{
1123
  color: #525252;
1124
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1125
  .modal a.gray{
1126
  padding: 5px 15px;
1127
  border-radius: 5px;
@@ -1437,6 +1484,8 @@ p.submit{
1437
  }
1438
  .tab-content .form-table td p{
1439
  font-family: "Open Sans",sans-serif;
 
 
1440
  font-size: 16px;
1441
  }
1442
  .tab-content table label{
@@ -1493,6 +1542,7 @@ p.submit{
1493
  }
1494
  .options table td{
1495
  margin-bottom: 15px;
 
1496
  padding: 0;
1497
  width: 80%;
1498
  }
@@ -1518,14 +1568,65 @@ p.submit{
1518
  display: block!important;
1519
  width: auto;
1520
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1521
  .options .contact_tab table td{
1522
- display: table-cell!important;
1523
- padding: 0 20px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1524
  }
1525
  .options .contact_tab table{
1526
  border: none;
1527
- -webkit-filter: blur(2px);
1528
- filter: blur(2px);
1529
  }
1530
  .contact_tab{
1531
  padding: 20px;
@@ -1566,21 +1667,36 @@ p.submit{
1566
  }
1567
  .contact_head__wrap .download__wrap{
1568
  position: relative;
1569
- width: 60%;
1570
  height: 100%;
1571
  text-align: right;
1572
  }
 
 
 
 
 
 
 
 
1573
  .contact_head__wrap .pro_button__wrapper{
1574
  display: flex;
1575
  align-items: center;
1576
- top: -57px;
1577
  width: 100%;
1578
- height: fit-content;
1579
  left: 0;
 
 
1580
  padding: 0;
1581
  }
 
 
 
 
 
1582
  .contact_head__wrap .pro_button__wrapper a{
1583
- padding: 1em 1.5em;
1584
  }
1585
 
1586
  .contact_head__wrap .pro_button__wrapper a{
@@ -1597,13 +1713,8 @@ p.submit{
1597
  }
1598
  .table__wrap{
1599
  position: relative;
1600
- -moz-user-select: none; /* Firefox */
1601
- -ms-user-select: none; /* Internet Explorer/Edge */
1602
- user-select: none;
1603
- }
1604
- .table__wrap table{
1605
- pointer-events: none;
1606
  }
 
1607
  .connected-page .connect_check{
1608
  display: inline-block;
1609
  margin: 10px 0 0 0;
@@ -1901,11 +2012,18 @@ p.submit{
1901
  text-align: center;
1902
  }
1903
 
1904
- .billing-modal-header__plan-price {
 
1905
  font-size: 23px;
 
1906
  font-weight: 800;
 
 
 
 
 
 
1907
  }
1908
-
1909
  .billing-modal-header__logo div{
1910
  background-image: url("../img/monkey_head.png");
1911
  background-size: contain;
515
  flex-direction: row;
516
  }
517
 
518
+ .mm_only_block a.reset_chatbot{
519
+ background-color: gray;
520
+ margin-right: 2rem;
521
+ border-radius: 4px;
522
+ color: #fff;
523
+ padding: 5px 15px;
524
+ }
525
+
526
+
527
+ .mm_only_block a.go_mm{
528
+ background-color: #324ef8;
529
+ padding: 5px 15px;
530
+ }
531
+ .mm_only_block .but__wrap{
532
+ margin-top: 20px;
533
+ display: flex;
534
+ flex-direction: row;
535
+ }
536
+
537
  .test-bot-button {
538
  position: absolute;
539
  right: 0;
620
  .step-wrapper .tab-link.current span.tab_header{
621
  background-color: #ffffff;
622
  }
 
 
 
 
 
 
 
 
 
623
 
624
  .step-wrapper ul.tabs_wrapper {
625
  margin: 0px;
908
  align-items: center;
909
  top: -4px;
910
  width: 107%;
911
+ height: 64px;
912
+ padding: 0 1em;
913
  left: -15px;
914
  }
915
 
918
  }
919
  .pro_button__wrapper .pro_button__link{
920
  width: 100%;
921
+ height: 100%;
922
  }
923
  .pro_button__wrapper .pro_button__link:focus{
924
  border: 0;
925
  box-shadow: none;
926
+ height: 100%;
927
  }
928
 
929
  .customization_button__wrapper .customization_button__image {
951
  .pro_button__wrapper .pro_button{
952
  display: flex;
953
  justify-content: space-between;
954
+ height: 100%;
955
+ }
956
+
957
+ .pro_button__content{
958
+ flex-direction: column;
959
+ height: 100%;
960
+ }
961
+ .pro_button__content h3,.pro_button__content p{
962
+ color: #fff;
963
+ padding: 0;
964
+ margin: 0;
965
+ }
966
+ .tab-content .form-table .pro_button__content p{
967
+ margin-top: 5px;
968
+ margin-bottom: 7px;
969
+ }
970
+ .pro_button__content h3 b{
971
+ color: red;
972
+ text-decoration: underline;
973
  }
974
 
975
  .customization_button__wrapper .customization_button .customization_button__content,.pro_button__wrapper .pro_button .pro_button__content {
1042
  .form-table p.description{
1043
  font-style: normal;
1044
  }
1045
+ #to_pro,#unsaved_option, #pro_option,#cancel,#mm_option {
1046
  z-index: 999;
1047
  transition: all 0.5s ease;
1048
  background-color: #FFFFFF;
1058
  border-radius: 10px;
1059
  }
1060
 
1061
+ #to_pro .modal_close,#unsaved_option .modal_close,#pro_option .modal_close, #mm_option .modal_close,#cancel .modal_close {
1062
  background-size: contain;
1063
  width: 15px;
1064
  height: 15px;
1071
  z-index: 999;
1072
  }
1073
 
1074
+ #to_pro .upgrade__wrapper,#unsaved_option .unsaved__wrapper,#cancel .cancel__wrapper,#mm_option .mm__wrapper{
1075
  position: relative;
1076
  height: 302px;
1077
  padding-top: 1em;
1078
  }
1079
 
1080
+ #to_pro .upgrade__content,#unsaved_option .unsaved__content,#cancel .cancel__content,#mm_option .mm__content{
1081
  padding: 1.5em;
1082
  }
1083
 
1084
 
1085
 
1086
+ #to_pro .upgrade__button, #unsaved_option .unsaved__button, #mm_option .mm__button,#cancel .cancel__button{
1087
  padding: 1.5em 2em;
1088
  text-align: center;
1089
  position: absolute;
1154
  .modal .mm__content{
1155
  color: #525252;
1156
  }
1157
+ .modal a.gray{
1158
+ padding: 5px 15px;
1159
+ border-radius: 5px;
1160
+ background-color: gray;
1161
+ cursor: pointer;
1162
+ color: #fff;
1163
+ text-decoration: none;
1164
+ font-size: 16px;
1165
+ border: none;
1166
+ margin: 0 10px;
1167
+ position: relative;
1168
+ }
1169
+ .modal .mm__content{
1170
+ color: #525252;
1171
+ }
1172
  .modal a.gray{
1173
  padding: 5px 15px;
1174
  border-radius: 5px;
1484
  }
1485
  .tab-content .form-table td p{
1486
  font-family: "Open Sans",sans-serif;
1487
+ margin-bottom: 10px;
1488
+ margin-top: 0;
1489
  font-size: 16px;
1490
  }
1491
  .tab-content table label{
1542
  }
1543
  .options table td{
1544
  margin-bottom: 15px;
1545
+ vertical-align: middle;
1546
  padding: 0;
1547
  width: 80%;
1548
  }
1568
  display: block!important;
1569
  width: auto;
1570
  }
1571
+
1572
+ .options .contact_tab table th.sortable a,.options .contact_tab table th.sorted a,.options .contact_tab table th{
1573
+ display: inline-block;
1574
+ padding: 0;
1575
+ color: #A9A5A5;
1576
+ height: 100%;
1577
+ text-transform: capitalize;
1578
+ }
1579
+ .options .contact_tab table th.sortable a:focus,.options .contact_tab table th.sorted a:focus{
1580
+ box-shadow: none;
1581
+ }
1582
+
1583
+ .options .contact_tab table,.options .contact_tab table tbody{
1584
+ display: block;
1585
+ }
1586
+ .options .contact_tab table tr:first-child{
1587
+ padding-bottom: 15px;
1588
+ margin-bottom: 0;
1589
+ box-shadow: none;
1590
+ }
1591
+ .options .contact_tab table tr:hover:not(:first-child){
1592
+ cursor: pointer;
1593
+ background-color: #f9fafb;
1594
+ }
1595
+ .download__wrap .pro_button__content{
1596
+ text-align: center;
1597
+ }
1598
+ .options .contact_tab table tr{
1599
+ margin-bottom: 1em;
1600
+ display: grid;
1601
+ grid-column: 1 / -1;
1602
+ grid-template-columns: 10% 25% 10% 10% 12% 23% 10%;
1603
+ padding: 1rem 25px;
1604
+ box-shadow: 0 0 4px 3px rgba(242,239,237,1);
1605
+ vertical-align: middle;
1606
+ -ms-flex-align: center;
1607
+ align-items: center;
1608
+ }
1609
  .options .contact_tab table td{
1610
+ margin: 0;
1611
+ padding: 0;
1612
+ width: 100%;
1613
+ vertical-align: middle;
1614
+ font-family: "Open Sans",sans-serif;
1615
+ font-size: 14px;
1616
+ font-weight: bold;
1617
+ word-break: break-all;
1618
+ }
1619
+
1620
+ .options .contact_tab table td img{
1621
+ vertical-align: middle;
1622
+ border-radius: 50%;
1623
+ min-width: 3.5rem;
1624
+ }
1625
+ .options .contact_tab table td.gender{
1626
+ text-transform: capitalize;
1627
  }
1628
  .options .contact_tab table{
1629
  border: none;
 
 
1630
  }
1631
  .contact_tab{
1632
  padding: 20px;
1667
  }
1668
  .contact_head__wrap .download__wrap{
1669
  position: relative;
1670
+ width: 70%;
1671
  height: 100%;
1672
  text-align: right;
1673
  }
1674
+ .billing-modal-header__plan-price p:before {
1675
+ border-bottom: 3px solid red;
1676
+ position: absolute;
1677
+ content: "";
1678
+ width: 80%;
1679
+ left: 23px;
1680
+ height: 60%;
1681
+ }
1682
  .contact_head__wrap .pro_button__wrapper{
1683
  display: flex;
1684
  align-items: center;
1685
+ top: -35px;
1686
  width: 100%;
1687
+ height: 73px;
1688
  left: 0;
1689
+ position: absolute;
1690
+ bottom: 0;
1691
  padding: 0;
1692
  }
1693
+
1694
+ .contact_head__wrap .pro_button__wrapper .pro_button__content p{
1695
+ margin-bottom: 5px;
1696
+ }
1697
+
1698
  .contact_head__wrap .pro_button__wrapper a{
1699
+ padding: 0.5em 1em;
1700
  }
1701
 
1702
  .contact_head__wrap .pro_button__wrapper a{
1713
  }
1714
  .table__wrap{
1715
  position: relative;
 
 
 
 
 
 
1716
  }
1717
+
1718
  .connected-page .connect_check{
1719
  display: inline-block;
1720
  margin: 10px 0 0 0;
2012
  text-align: center;
2013
  }
2014
 
2015
+ .billing-modal-header__plan-price p{
2016
+ text-align: center;
2017
  font-size: 23px;
2018
+ position: relative;
2019
  font-weight: 800;
2020
+ margin: 0;
2021
+ }
2022
+ .billing-modal-header__plan-price h4{
2023
+ font-weight: 800;
2024
+ text-decoration: none;
2025
+ color: red;
2026
  }
 
2027
  .billing-modal-header__logo div{
2028
  background-image: url("../img/monkey_head.png");
2029
  background-size: contain;
admin/assets/img/contact_noimage.svg ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg width="42px" height="42px" viewBox="0 0 42 42" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
+ <!-- Generator: Sketch 52.4 (67378) - http://www.bohemiancoding.com/sketch -->
4
+ <title>contact_noimage</title>
5
+ <desc>Created with Sketch.</desc>
6
+ <defs>
7
+ <path d="M8,1.9 C9.16,1.9 10.1,2.84 10.1,4 C10.1,5.16 9.16,6.1 8,6.1 C6.84,6.1 5.9,5.16 5.9,4 C5.9,2.84 6.84,1.9 8,1.9 Z M8,10.9 C10.97,10.9 14.1,12.36 14.1,13 L14.1,14.1 L1.9,14.1 L1.9,13 C1.9,12.36 5.03,10.9 8,10.9 Z M8,0 C5.79,0 4,1.79 4,4 C4,6.21 5.79,8 8,8 C10.21,8 12,6.21 12,4 C12,1.79 10.21,0 8,0 Z M8,9 C5.33,9 0,10.34 0,13 L0,16 L16,16 L16,13 C16,10.34 10.67,9 8,9 Z" id="path-1"></path>
8
+ </defs>
9
+ <g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
10
+ <g id="ROW/contact" transform="translate(-63.000000, -20.000000)">
11
+ <g id="contact_noimage" transform="translate(64.000000, 21.000000)">
12
+ <circle id="Oval" stroke="#A6ADC6" fill="#FFFFFF" cx="20" cy="20" r="20"></circle>
13
+ <g id="ic/user_outlined" transform="translate(8.000000, 7.000000)">
14
+ <g id="baseline-person_outline-24px">
15
+ <g id="Color/On-secondary-Copy" transform="translate(4.000000, 4.000000)">
16
+ <mask id="mask-2" fill="white">
17
+ <use xlink:href="#path-1"></use>
18
+ </mask>
19
+ <use id="Mask" fill="#000000" fill-rule="nonzero" xlink:href="#path-1"></use>
20
+ <g mask="url(#mask-2)" fill="#A6ADC6" id="Color/Primary">
21
+ <g transform="translate(-4.000000, -4.000000)">
22
+ <polygon points="0 0 24 0 24 24 0 24"></polygon>
23
+ </g>
24
+ </g>
25
+ </g>
26
+ <polygon id="Path" points="0 0 24 0 24 24 0 24"></polygon>
27
+ </g>
28
+ </g>
29
+ </g>
30
+ </g>
31
+ </g>
32
+ </svg>
admin/assets/js/admin.js CHANGED
@@ -650,9 +650,6 @@ jQuery(document).ready(function($){
650
  second_flag = data.data;
651
  }
652
  });
653
- if($(".step-wrapper ul li.tab-link").length-1 == $(".step-wrapper ul li.tab-link.done").length) {
654
- $('.setup_statement').css({'display':'none'})
655
- }
656
 
657
  function set_current_tab(attr) {
658
  $.ajax({
@@ -667,7 +664,6 @@ jQuery(document).ready(function($){
667
  }
668
 
669
  function unsaved(cur_link,link,attr){
670
- var setup = false;
671
  if (!link.hasClass('current')){
672
  for (var key in datas[cur_link]) {
673
  if (datas[cur_link].hasOwnProperty(key)){
@@ -714,10 +710,6 @@ jQuery(document).ready(function($){
714
  }
715
  });
716
 
717
- if($(".step-wrapper ul li.tab-link").length-1 == $(".step-wrapper ul li.tab-link.done").length) {
718
- $('.setup_statement').css({'display':'none'});
719
- setup = true;
720
- }
721
  if (JSON.stringify(flag)!==JSON.stringify(second_flag)){
722
  $.extend(second_flag,flag);
723
  $.ajax({
@@ -726,7 +718,6 @@ jQuery(document).ready(function($){
726
  data: {
727
  action: 'send_done',
728
  state: flag,
729
- setup: setup
730
  },
731
  dataType: 'json',
732
  });
@@ -734,7 +725,7 @@ jQuery(document).ready(function($){
734
 
735
  }
736
 
737
- function send_next(next,setup){
738
  set_current_tab(next.attr('data-tab'));
739
  next.addClass('done');
740
  $(".step-wrapper ul li.tab-link").each(function () {
@@ -751,7 +742,6 @@ jQuery(document).ready(function($){
751
  data: {
752
  action: 'send_done',
753
  state: flag,
754
- setup: setup
755
  },
756
  dataType: 'json',
757
  });
@@ -764,17 +754,13 @@ jQuery(document).ready(function($){
764
  if (next.attr('data-tab')!=='tab-3'){
765
  var second_next = next.next();
766
  }
767
- var setup = false;
768
- if($(".step-wrapper ul li.tab-link").length-1 == $(".step-wrapper ul li.tab-link.done").length) {
769
- setup = true;
770
- }
771
  if (!next.hasClass('done')){
772
- send_next(next,setup)
773
  }else if (second_next && !second_next.hasClass('done')){
774
- send_next(second_next,setup)
775
  }else {
776
  var cur = $(".step-wrapper ul li.tab-link.current");
777
- send_next(cur,setup);
778
  }
779
 
780
  }
@@ -809,7 +795,66 @@ jQuery(document).ready(function($){
809
  error = false;
810
  });
811
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  $('.form-table tr').hover(
814
  function (event) {
815
  event.preventDefault();
650
  second_flag = data.data;
651
  }
652
  });
 
 
 
653
 
654
  function set_current_tab(attr) {
655
  $.ajax({
664
  }
665
 
666
  function unsaved(cur_link,link,attr){
 
667
  if (!link.hasClass('current')){
668
  for (var key in datas[cur_link]) {
669
  if (datas[cur_link].hasOwnProperty(key)){
710
  }
711
  });
712
 
 
 
 
 
713
  if (JSON.stringify(flag)!==JSON.stringify(second_flag)){
714
  $.extend(second_flag,flag);
715
  $.ajax({
718
  data: {
719
  action: 'send_done',
720
  state: flag,
 
721
  },
722
  dataType: 'json',
723
  });
725
 
726
  }
727
 
728
+ function send_next(next){
729
  set_current_tab(next.attr('data-tab'));
730
  next.addClass('done');
731
  $(".step-wrapper ul li.tab-link").each(function () {
742
  data: {
743
  action: 'send_done',
744
  state: flag,
 
745
  },
746
  dataType: 'json',
747
  });
754
  if (next.attr('data-tab')!=='tab-3'){
755
  var second_next = next.next();
756
  }
 
 
 
 
757
  if (!next.hasClass('done')){
758
+ send_next(next)
759
  }else if (second_next && !second_next.hasClass('done')){
760
+ send_next(second_next)
761
  }else {
762
  var cur = $(".step-wrapper ul li.tab-link.current");
763
+ send_next(cur);
764
  }
765
 
766
  }
795
  error = false;
796
  });
797
 
798
+ $("#reset_chatbot").on('click',function (e) {
799
+ e.preventDefault();
800
+ $("#mm_option").show();
801
+ $('#modal-overlay').show();
802
+ $('body').css({'overflow': 'hidden'});
803
+ })
804
+ $("#reset_bot_button").on('click',function (e) {
805
+ e.preventDefault();
806
+ $('div.modal_close').off('click');
807
+ $('#mm_cancel').off('click');
808
+ $.ajax({
809
+ type: 'GET',
810
+ url: ajaxurl,
811
+ data: {
812
+ action: 'create_bot',
813
+ },
814
+ dataType: 'json',
815
+ success: function (data,response) {
816
+ var path = location.protocol + '//' + location.host + location.pathname + '?page=wp-chatbot';
817
+ window.location = path;
818
+ }
819
+ });
820
 
821
+ })
822
+ $.ajax({
823
+ type: 'GET',
824
+ url: ajaxurl,
825
+ data: {
826
+ action: 'csv',
827
+ },
828
+ dataType: "text",
829
+ success: function (data) {
830
+ var blob = new Blob([data], { type: 'text/csv;charset=utf8' });
831
+ var csvUrl = URL.createObjectURL(blob);
832
+
833
+ $('#csv')
834
+ .attr({
835
+ 'download': 'test.csv',
836
+ 'href': csvUrl
837
+ });
838
+ }
839
+ });
840
+ $('.download__wrap').hover(
841
+ function (event) {
842
+ event.preventDefault();
843
+ let page = $('.connected-page');
844
+ let wrap = $('.contact_head__wrap');
845
+ if (!page.hasClass('pro')){
846
+ wrap.find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
847
+ }
848
+ },
849
+ function (event) {
850
+ event.preventDefault();
851
+ let page = $('.connected-page');
852
+ let wrap = $('.contact_head__wrap');
853
+ if (!page.hasClass('pro')){
854
+ wrap.find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
855
+ }
856
+ }
857
+ );
858
  $('.form-table tr').hover(
859
  function (event) {
860
  event.preventDefault();
admin/class-htcc-admin.php CHANGED
@@ -81,7 +81,7 @@ if (!class_exists('HTCC_Admin')) :
81
  add_submenu_page(
82
  'wp-chatbot',
83
  'Contacts',
84
- '<span data-tab="tab-3">Contacts</span>',
85
  8,
86
  '',
87
  ''
@@ -181,10 +181,7 @@ if (!class_exists('HTCC_Admin')) :
181
  'tab-3' => isset($_SESSION['tab']['tab3'])?$_SESSION['tab']['tab3']:false,
182
  );
183
  }
184
- if (isset($data['setup'])){
185
- $_SESSION['setup'] = $data['setup'];
186
- }
187
- wp_send_json_success ( $response,$_SESSION['setup']);
188
  }
189
 
190
  public function set_current_tab(){
@@ -400,7 +397,10 @@ if (!class_exists('HTCC_Admin')) :
400
  <div class="pro_button__wrapper" style="display: none">
401
  <a href="#" class="pro_button__link">
402
  <div class="pro_button">
403
- <div class="pro_button__content"><?php _e('Upgrade to unlock this feature') ?></div>
 
 
 
404
  <div class="pro_button__action">
405
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
406
  </div>
@@ -502,7 +502,10 @@ if (!class_exists('HTCC_Admin')) :
502
  <div class="pro_button__wrapper" style="display: none">
503
  <a href="#" class="pro_button__link">
504
  <div class="pro_button">
505
- <div class="pro_button__content"><?php _e('Upgrade to unlock this feature') ?></div>
 
 
 
506
  <div class="pro_button__action">
507
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
508
  </div>
@@ -534,7 +537,10 @@ if (!class_exists('HTCC_Admin')) :
534
  <div class="pro_button__wrapper" style="display: none">
535
  <a href="#" class="pro_button__link">
536
  <div class="pro_button">
537
- <div class="pro_button__content"><?php _e('Upgrade to unlock this feature') ?></div>
 
 
 
538
  <div class="pro_button__action">
539
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
540
  </div>
81
  add_submenu_page(
82
  'wp-chatbot',
83
  'Contacts',
84
+ '<span data-tab="tab-3">Leads</span>',
85
  8,
86
  '',
87
  ''
181
  'tab-3' => isset($_SESSION['tab']['tab3'])?$_SESSION['tab']['tab3']:false,
182
  );
183
  }
184
+ wp_send_json_success ( $response);
 
 
 
185
  }
186
 
187
  public function set_current_tab(){
397
  <div class="pro_button__wrapper" style="display: none">
398
  <a href="#" class="pro_button__link">
399
  <div class="pro_button">
400
+ <div class="pro_button__content">
401
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
402
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
403
+ </div>
404
  <div class="pro_button__action">
405
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
406
  </div>
502
  <div class="pro_button__wrapper" style="display: none">
503
  <a href="#" class="pro_button__link">
504
  <div class="pro_button">
505
+ <div class="pro_button__content">
506
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
507
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
508
+ </div>
509
  <div class="pro_button__action">
510
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
511
  </div>
537
  <div class="pro_button__wrapper" style="display: none">
538
  <a href="#" class="pro_button__link">
539
  <div class="pro_button">
540
+ <div class="pro_button__content">
541
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
542
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
543
+ </div>
544
  <div class="pro_button__action">
545
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
546
  </div>
admin/commons/ht-cc-admin-settings-form.php CHANGED
@@ -12,7 +12,6 @@ $table = new MobileMonkey_Contacts_List_Table();
12
  $table->prepare_items();
13
  !isset($_SESSION['current']) ? $_SESSION['current'] = 'tab-1' : $_SESSION['current'];
14
  $_SESSION['tab']['tab1'] = true;
15
- $mm_only?$setup='true':$setup = $_SESSION['setup'];
16
  $current = str_replace('-', "", $_SESSION['current']);
17
  foreach ($_SESSION['tab'] as $key => $value) {
18
  if ($value) {
@@ -36,7 +35,7 @@ $$current .= ' current';
36
  </li>
37
  <li class="tab-link <?php echo $tab3 ?>" data-tab="tab-3">
38
  <span class="tab_number">3</span>
39
- <span class="tab_header">Contacts</span>
40
  <span class="tab_contacts__count"><?php echo $table->totalItems ?></span>
41
  </li>
42
  <li class="tab-link <?php echo $tab4 ?>" data-tab="tab-4">
@@ -47,18 +46,20 @@ $$current .= ' current';
47
  <div class="list_tabs__button">
48
  <ul class="list_tabs"></ul>
49
  </div>
50
- <div class="setup_statement" style="<?php echo($setup=='true' ? "display:none" : "display:block") ?>">
51
- Setup Incomplete
52
- </div>
53
  </div>
54
  <?php
55
  $mm_only ? $state = 'none' : $state = 'block';
56
  !$mm_only ? $mm = 'none' : $mm = 'block'; ?>
57
  <div id="tab-1" class="tab-content <?php echo $tab1 ?> setup_section">
58
  <div class="tab-content__wrapper">
59
- <div class="mm_only_block" style="display: <?php echo $mm?>">
60
- <h6><?php _e('Looks like you\'ve already worked in MobileMonkey. Please use the MobileMonkey app to make additional edits to the \'Welcome message\' and \'Answering Service\'.', 'wp-chatbot') ?></h6>
61
- <a target="_blank" rel="noopener noreferrer" href='https://app.mobilemonkey.com/chatbot-editor/<?php echo$connected_page['id']?>/home' class="button_go">Go to MobileMonkey</a>
 
 
 
 
 
62
  </div>
63
  <form method="post" action="options.php" style="display: <?php echo $state ?>">
64
  <?php
@@ -89,22 +90,28 @@ $$current .= ' current';
89
  </div>
90
  </div>
91
  <div id="tab-3" class="tab-content contact_tab <?php echo $tab3 ?>">
92
- <h1><?php _e('Contacts') ?></h1>
93
 
94
  <div class="contact_head__wrap">
95
  <h4><?php
96
- $text = $table->totalItems > 1 ? 'contacts' : 'contact';
97
  if ($table->totalItems == 0) {
98
  $table->totalItems = '';
99
- $text = "No contacts ";
100
  }
101
  echo $table->totalItems
102
  ?> <p><?php _e($text) ?><?php _e(' generated') ?></p></h4>
 
 
103
  <div class="download__wrap">
 
104
  <div class="pro_button__wrapper" style="display: none">
105
  <a href="#" class="pro_button__link">
106
  <div class="pro_button">
107
- <div class="pro_button__content"><?php _e('Upgrade to unlock this feature') ?></div>
 
 
 
108
  <div class="pro_button__action">
109
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
110
  </div>
@@ -117,19 +124,6 @@ $$current .= ' current';
117
  <?php
118
  $table->display();
119
  ?>
120
- <a target="_blank" rel="noopener noreferrer"
121
- href="https://app.mobilemonkey.com/chatbot-editor/<?php echo $connected_page['bot_id'] ?>/contacts"
122
- id="contacts_modal">
123
- <div class="contact_modal__wrapper">
124
- <div class="contact_modal__content">
125
- <p><?php _e('View your contacts in') ?> </p><span class="customization_button__image"></span>
126
- <span class="logo_name"><?php _e('MobileMonkey') ?></span>
127
- </div>
128
- <div class="contact_modal__button">
129
- <div><?php _e('Let\'s go!') ?></div>
130
- </div>
131
- </div>
132
- </a>
133
  </div>
134
  </div>
135
  <div id="tab-4" class="tab-content subscribe_section <?php echo $tab4 ?>">
@@ -137,7 +131,6 @@ $$current .= ' current';
137
  <?php
138
  $plan = json_decode(json_encode($wp_plan_info), True);
139
  $fb_subscribe_info = [
140
- 'type' => 'pro',
141
  'account' => $account_info,
142
  'subscribe_info' => $subscribe_info,
143
  'message_statistic' => $message_statistic,
@@ -145,8 +138,6 @@ $$current .= ' current';
145
  'page_name'=>$page_info['pageName'],
146
  'since'=>$page_info['connected_at'],
147
  'is_wp' =>$page_info['is_wp_subscribe'],
148
- 'messages_sent'=>'822',
149
- 'max_messages' =>'1'
150
  ],
151
  'plan' => $wp_plan_info
152
  ];
@@ -203,6 +194,23 @@ $$current .= ' current';
203
  </div>
204
  </div>
205
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
206
  <div id="pro_option" class="modal">
207
  <div class="modal_close"><i class="fa fa-times" aria-hidden="true"></i></div>
208
  <div class="mm__wrapper">
@@ -213,7 +221,10 @@ $$current .= ' current';
213
  <div class="logo"></div>
214
  <span><?php _e('MobileMonkey') ?></span></div>
215
  <div class="billing-modal-header__plan-name">WP-CHATBOT PRO</div>
216
- <div class="billing-modal-header__plan-price">$<?php _e(number_format(($plan['unit_amount_in_cents'] /100), 2, '.', ' '))?>/<?php _e($plan['billing_period'])?></div>
 
 
 
217
 
218
  <div class="billing-page-details">
219
  <div class="billing-page-details__left-section">
12
  $table->prepare_items();
13
  !isset($_SESSION['current']) ? $_SESSION['current'] = 'tab-1' : $_SESSION['current'];
14
  $_SESSION['tab']['tab1'] = true;
 
15
  $current = str_replace('-', "", $_SESSION['current']);
16
  foreach ($_SESSION['tab'] as $key => $value) {
17
  if ($value) {
35
  </li>
36
  <li class="tab-link <?php echo $tab3 ?>" data-tab="tab-3">
37
  <span class="tab_number">3</span>
38
+ <span class="tab_header">Leads</span>
39
  <span class="tab_contacts__count"><?php echo $table->totalItems ?></span>
40
  </li>
41
  <li class="tab-link <?php echo $tab4 ?>" data-tab="tab-4">
46
  <div class="list_tabs__button">
47
  <ul class="list_tabs"></ul>
48
  </div>
 
 
 
49
  </div>
50
  <?php
51
  $mm_only ? $state = 'none' : $state = 'block';
52
  !$mm_only ? $mm = 'none' : $mm = 'block'; ?>
53
  <div id="tab-1" class="tab-content <?php echo $tab1 ?> setup_section">
54
  <div class="tab-content__wrapper">
55
+ <div class="mm_only_block" style="display: <?php echo $mm ?>">
56
+ <h6><?php _e('Changes were made to your chatbot in MobileMonkey, so the settings in WordPress are no longer up-to-date. Please go to MobileMonkey to continue making changes, or reset your chatbot in WordPress.', 'wp-chatbot') ?></h6>
57
+ <div class="but__wrap">
58
+ <a href="#" class="reset_chatbot" id="reset_chatbot"><?php _e('Reset my chatbot') ?></a>
59
+ <a target="_blank" rel="noopener noreferrer"
60
+ href='https://app.mobilemonkey.com/chatbot-editor/<?php echo $connected_page['id'] ?>/configure/chatbot'
61
+ class="go_mm"><?php _e('Go to MobileMonkey') ?></a>
62
+ </div>
63
  </div>
64
  <form method="post" action="options.php" style="display: <?php echo $state ?>">
65
  <?php
90
  </div>
91
  </div>
92
  <div id="tab-3" class="tab-content contact_tab <?php echo $tab3 ?>">
93
+ <h1><?php _e('Leads') ?></h1>
94
 
95
  <div class="contact_head__wrap">
96
  <h4><?php
97
+ $text = $table->totalItems > 1 ? 'Leads' : 'Lead';
98
  if ($table->totalItems == 0) {
99
  $table->totalItems = '';
100
+ $text = "No Leads ";
101
  }
102
  echo $table->totalItems
103
  ?> <p><?php _e($text) ?><?php _e(' generated') ?></p></h4>
104
+ <?php
105
+ ?>
106
  <div class="download__wrap">
107
+ <a id="csv" href="" style="pointer-events:<?php $subscribe_info?_e('all'):_e('none')?> "><i class="fa fa-download" aria-hidden="true"></i><?php _e("Download Leads");?></a>
108
  <div class="pro_button__wrapper" style="display: none">
109
  <a href="#" class="pro_button__link">
110
  <div class="pro_button">
111
+ <div class="pro_button__content">
112
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
113
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
114
+ </div>
115
  <div class="pro_button__action">
116
  <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
117
  </div>
124
  <?php
125
  $table->display();
126
  ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  </div>
128
  </div>
129
  <div id="tab-4" class="tab-content subscribe_section <?php echo $tab4 ?>">
131
  <?php
132
  $plan = json_decode(json_encode($wp_plan_info), True);
133
  $fb_subscribe_info = [
 
134
  'account' => $account_info,
135
  'subscribe_info' => $subscribe_info,
136
  'message_statistic' => $message_statistic,
138
  'page_name'=>$page_info['pageName'],
139
  'since'=>$page_info['connected_at'],
140
  'is_wp' =>$page_info['is_wp_subscribe'],
 
 
141
  ],
142
  'plan' => $wp_plan_info
143
  ];
194
  </div>
195
  </div>
196
  </div>
197
+ <div id="mm_option" class="modal">
198
+ <div class="modal_close">X</div>
199
+ <div class="mm__wrapper">
200
+ <div class="mm__content">
201
+ <h4><?php _e('Are you sure that you want to reset your chatbot?') ?></h4>
202
+ <p><?php _e('Changes made in MobileMonkey will be lost, with no undo option.') ?></p>
203
+ </div>
204
+ <div class="mm__button">
205
+ <a href="#" id="mm_cancel" class="gray button-close-modal"><?php _e('Cancel') ?></a>
206
+ <a href="#" id="reset_bot_button" class="blues button-lazy-load"><?php _e('Reset my chatbot') ?>
207
+ <div class="lazyload"></div>
208
+ </a>
209
+ </div>
210
+ </div>
211
+ </div>
212
+ <div class="modal-overlays" id="modal-overlay">
213
+ </div>
214
  <div id="pro_option" class="modal">
215
  <div class="modal_close"><i class="fa fa-times" aria-hidden="true"></i></div>
216
  <div class="mm__wrapper">
221
  <div class="logo"></div>
222
  <span><?php _e('MobileMonkey') ?></span></div>
223
  <div class="billing-modal-header__plan-name">WP-CHATBOT PRO</div>
224
+ <div class="billing-modal-header__plan-price">
225
+ <h4>$<?php _e(number_format(($plan['unit_amount_in_cents'] /100), 2, '.', ' '))?>/<?php _e($plan['billing_period'])?></h4>
226
+ <p><?php _e('$98/year') ?></p>
227
+ </div>
228
 
229
  <div class="billing-page-details">
230
  <div class="billing-page-details__left-section">
admin/contact_page.php CHANGED
@@ -53,11 +53,12 @@ class MobileMonkey_Contacts_List_Table extends WP_List_Table
53
  public function get_columns()
54
  {
55
  $columns = [
56
- 'first_name'=> __('First Name'),
57
- 'last_name' => __('Last Name'),
58
  'gender' => __('Gender'),
59
  'locale' => __('Locale'),
60
  'timezone' => __('Timezone'),
 
61
  'created_at'=> __('Created'),
62
  ];
63
  return $columns;
@@ -79,8 +80,7 @@ class MobileMonkey_Contacts_List_Table extends WP_List_Table
79
  public function get_sortable_columns()
80
  {
81
  return [
82
- 'first_name' => ['first_name', true],
83
- 'last_name' => ['last_name', true],
84
  'gender' => ['gender', true],
85
  'locale' => ['locale', true],
86
  'timezone' => ['timezone', true],
@@ -109,15 +109,17 @@ class MobileMonkey_Contacts_List_Table extends WP_List_Table
109
  } else {
110
  $timezone = 'GMT -'.$timezone;
111
  }
112
-
113
- $created = date('m/d/Y H:i', strtotime($contact->created_at));
 
114
 
115
  $data[] = [
116
- 'first_name' => $contact->first_name,
117
- 'last_name' => $contact->last_name,
118
  'gender' => $contact->gender,
119
  'locale' => $contact->locale,
120
  'timezone' => $timezone,
 
121
  'created_at' => $created,
122
  ];
123
  }
@@ -135,11 +137,12 @@ class MobileMonkey_Contacts_List_Table extends WP_List_Table
135
  public function column_default( $item, $column_name )
136
  {
137
  switch( $column_name ) {
138
- case 'first_name':
139
- case 'last_name':
140
  case 'gender':
141
  case 'locale':
142
  case 'timezone':
 
143
  case 'created_at':
144
  return $item[ $column_name ];
145
  }
@@ -156,29 +159,13 @@ class MobileMonkey_Contacts_List_Table extends WP_List_Table
156
 
157
  $this->screen->render_screen_reader_content( 'heading_list' );
158
  ?>
159
- <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
160
- <thead>
161
  <tr>
162
  <?php $this->print_column_headers(); ?>
163
  </tr>
164
- </thead>
165
 
166
- <tbody id="the-list"<?php
167
- if ( $singular ) {
168
- echo " data-wp-lists='list:$singular'";
169
- } ?>>
170
  <?php $this->display_rows_or_placeholder(); ?>
171
- </tbody>
172
 
173
- <?php
174
- if($this->totalItems > $this->count):
175
- ?>
176
- <tfoot>
177
- <tr>
178
- <?php $this->print_column_headers( false ); ?>
179
- </tr>
180
- </tfoot>
181
- <?php endif; ?>
182
 
183
  </table>
184
  <?php
53
  public function get_columns()
54
  {
55
  $columns = [
56
+ 'pic'=> __(''),
57
+ 'name'=> __('Name'),
58
  'gender' => __('Gender'),
59
  'locale' => __('Locale'),
60
  'timezone' => __('Timezone'),
61
+ 'email' => __('Email'),
62
  'created_at'=> __('Created'),
63
  ];
64
  return $columns;
80
  public function get_sortable_columns()
81
  {
82
  return [
83
+ 'name' => ['name', true],
 
84
  'gender' => ['gender', true],
85
  'locale' => ['locale', true],
86
  'timezone' => ['timezone', true],
109
  } else {
110
  $timezone = 'GMT -'.$timezone;
111
  }
112
+ $name = $contact->first_name." ".$contact->last_name;
113
+ $pic = '<img src='.$contact->profile_pic.' onerror="this.src=\''.plugin_dir_url( __FILE__ ).'assets/img/contact_noimage.svg\';this.onerror=\'\';">';
114
+ $created = date('m/d/Y', strtotime($contact->created_at));
115
 
116
  $data[] = [
117
+ 'pic' => $pic,
118
+ 'name' => $name,
119
  'gender' => $contact->gender,
120
  'locale' => $contact->locale,
121
  'timezone' => $timezone,
122
+ 'email' => $contact->email,
123
  'created_at' => $created,
124
  ];
125
  }
137
  public function column_default( $item, $column_name )
138
  {
139
  switch( $column_name ) {
140
+ case 'pic':
141
+ case 'name':
142
  case 'gender':
143
  case 'locale':
144
  case 'timezone':
145
+ case 'email':
146
  case 'created_at':
147
  return $item[ $column_name ];
148
  }
159
 
160
  $this->screen->render_screen_reader_content( 'heading_list' );
161
  ?>
162
+ <table class="wp-list-table">
 
163
  <tr>
164
  <?php $this->print_column_headers(); ?>
165
  </tr>
 
166
 
 
 
 
 
167
  <?php $this->display_rows_or_placeholder(); ?>
 
168
 
 
 
 
 
 
 
 
 
 
169
 
170
  </table>
171
  <?php
inc/MobileMonkeyApi.php CHANGED
@@ -15,6 +15,7 @@ class MobileMonkeyApi
15
  private $contacts;
16
  private $plugin_name = 'wp-chatbot';
17
  private $page_info;
 
18
 
19
  private function getApiDomain()
20
  {
@@ -64,7 +65,9 @@ class MobileMonkeyApi
64
  $pages = $this->getPages();
65
  foreach ($pages as $page) {
66
  if ($page['id'] && $connection_page_id == $page['remote_id']) {
67
- return $page['company_id'];
 
 
68
  }
69
  }
70
  return get_option($this->option_prefix . 'company_id');
@@ -73,7 +76,7 @@ class MobileMonkeyApi
73
  private function getActiveRemotePageId(){
74
  return get_option($this->option_prefix . 'active_page_remote_id');
75
  }
76
-
77
  public function getSubscribeInfo()
78
  {
79
  $args = [
@@ -332,12 +335,40 @@ class MobileMonkeyApi
332
 
333
  }
334
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
335
 
336
  public function connectPage()
337
  {
338
  $pageId = filter_input(INPUT_GET, "connect", FILTER_SANITIZE_STRING);
339
  $pageName = filter_input(INPUT_GET, "page_name", FILTER_SANITIZE_STRING);
340
  if ($pageId && $pageName) {
 
 
 
 
 
341
  $args = [
342
  'timeout' => 10,
343
  'body' => json_encode([
@@ -412,7 +443,6 @@ class MobileMonkeyApi
412
  $_SESSION['tab']['tab2'] = false;
413
  $_SESSION['tab']['tab3'] = false;
414
  $_SESSION['current'] = 'tab-1';
415
- $_SESSION['setup'] = false;
416
  $this->refreshSettingsPage();
417
  return true;
418
  }
@@ -494,7 +524,7 @@ class MobileMonkeyApi
494
  delete_option($this->option_prefix . 'active_page_remote_id');
495
  delete_option($this->option_prefix . 'active_bot');
496
  delete_option('htcc_fb_js_src');
497
- unset($_SESSION['tab'],$_SESSION['current'],$_SESSION['setup']);
498
  $this->refreshSettingsPage();
499
 
500
  return true;
@@ -743,12 +773,6 @@ class MobileMonkeyApi
743
  public function setWidgets($options,$widgets,$page_id,$update)
744
  {
745
  if (!$update){
746
- if (!$options['email']&&$this->getCurrentSubscription()){
747
- foreach ($widgets->widgets as $key=>$value){
748
- $value->type == 'email'?$options['email'] = $value->config->recipient:'';
749
- }
750
- update_option('htcc_as_options', $options);
751
- }
752
  if (!$options){
753
  $data_widget = $this->getWidgets($page_id);
754
  if (!$data_widget) {
@@ -764,14 +788,28 @@ class MobileMonkeyApi
764
  $value_new['thank_message'] = $value->config->body;
765
  break;
766
  case 'email':
767
- $value_new['email'] = $value->config->recipient;
 
 
768
  break;
769
  }
770
  }
 
 
 
 
771
  $value_new['fb_welcome_message'] = $this->getWelcomeMessage($page_id);
772
  $value_new['fb_as_state'] = 0;
773
  update_option('htcc_as_options', $value_new);
 
 
 
 
 
 
 
774
  }
 
775
  }else{
776
  if (!$widgets){
777
  return false;
@@ -871,6 +909,31 @@ class MobileMonkeyApi
871
  }
872
  }
873
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
874
  public function getEnv()
875
  {
876
 
@@ -1003,7 +1066,11 @@ class MobileMonkeyApi
1003
 
1004
  $orderby = filter_input(INPUT_GET, "orderby", FILTER_SANITIZE_STRING);
1005
  if (!empty($orderby)) {
1006
- $get['sort_column'] = $orderby;
 
 
 
 
1007
  }
1008
 
1009
  $order = filter_input(INPUT_GET, "order", FILTER_SANITIZE_STRING);
@@ -1124,7 +1191,41 @@ class MobileMonkeyApi
1124
  }
1125
  echo $type;
1126
  }
1127
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1128
  private function getData()
1129
  {
1130
  $get = $this->getArgs();
@@ -1136,9 +1237,9 @@ class MobileMonkeyApi
1136
  ],
1137
  ];
1138
 
1139
- $activePageId = $this->getActivePageId();
1140
 
1141
- $response = wp_remote_get($this->getApiDomain() . 'api/facebook_pages/' . $activePageId . '/contacts?page=' . $get['page'] . '&per_page=' . $get['pre_page'] . '&sort_column=' . $get['sort_column'] . '&sort_direction=' . $get['sort_direction'] . '&src=' . $this->getSrc(), $args);
1142
  $content = wp_remote_retrieve_body($response);
1143
  if (!empty($content)) {
1144
  $contacts = json_decode($content);
15
  private $contacts;
16
  private $plugin_name = 'wp-chatbot';
17
  private $page_info;
18
+ public $available_company;
19
 
20
  private function getApiDomain()
21
  {
65
  $pages = $this->getPages();
66
  foreach ($pages as $page) {
67
  if ($page['id'] && $connection_page_id == $page['remote_id']) {
68
+ if (in_array($page['company_id'], $this->available_company)){
69
+ return $page['company_id'];
70
+ }else return false;
71
  }
72
  }
73
  return get_option($this->option_prefix . 'company_id');
76
  private function getActiveRemotePageId(){
77
  return get_option($this->option_prefix . 'active_page_remote_id');
78
  }
79
+
80
  public function getSubscribeInfo()
81
  {
82
  $args = [
335
 
336
  }
337
 
338
+ public function getAvailableCompany(){
339
+ $args = [
340
+ 'timeout' => 10,
341
+ 'headers' => [
342
+ 'Authorization' => $this->getToken(),
343
+ 'Content-Type' => 'application/json; charset=utf-8',
344
+ ],
345
+ 'method' => 'GET',
346
+ ];
347
+ $response = wp_remote_post($this->getApiDomain() . 'api/wordpress_settings/my_company_ids?v=' . HTCC_VERSION.'.2', $args);
348
+ $error = $this->ErrorHandler($response,'Available Company','get');
349
+ if ($error) {
350
+ $connect_response = json_decode($error);
351
+ return $connect_response;
352
+ }
353
+ }
354
+
355
+ public function setAvailableCompany(){
356
+ $company = $this->getAvailableCompany();
357
+ update_option($this->option_prefix . 'available_company', $company);
358
+ $this->available_company = $company;
359
+ }
360
+
361
 
362
  public function connectPage()
363
  {
364
  $pageId = filter_input(INPUT_GET, "connect", FILTER_SANITIZE_STRING);
365
  $pageName = filter_input(INPUT_GET, "page_name", FILTER_SANITIZE_STRING);
366
  if ($pageId && $pageName) {
367
+ $this->setAvailableCompany();
368
+ if (!$this->getCompanyId($pageId)){
369
+ $this->renderError('This Facebook page has already been connected in MobileMonkey to a company that you don\'t have access to. Please contact support@mobilemonkey.com for more information on how to resolve this issue.');
370
+ return false;
371
+ }
372
  $args = [
373
  'timeout' => 10,
374
  'body' => json_encode([
443
  $_SESSION['tab']['tab2'] = false;
444
  $_SESSION['tab']['tab3'] = false;
445
  $_SESSION['current'] = 'tab-1';
 
446
  $this->refreshSettingsPage();
447
  return true;
448
  }
524
  delete_option($this->option_prefix . 'active_page_remote_id');
525
  delete_option($this->option_prefix . 'active_bot');
526
  delete_option('htcc_fb_js_src');
527
+ unset($_SESSION['tab'],$_SESSION['current']);
528
  $this->refreshSettingsPage();
529
 
530
  return true;
773
  public function setWidgets($options,$widgets,$page_id,$update)
774
  {
775
  if (!$update){
 
 
 
 
 
 
776
  if (!$options){
777
  $data_widget = $this->getWidgets($page_id);
778
  if (!$data_widget) {
788
  $value_new['thank_message'] = $value->config->body;
789
  break;
790
  case 'email':
791
+ if ($this->getCurrentSubscription()){
792
+ $value_new['email'] = $value->config->recipient;
793
+ }
794
  break;
795
  }
796
  }
797
+ $ref_cont = $this->getBotRef($this->getActiveBotId());
798
+ $ref = stristr($ref_cont->test_link, '=');
799
+ $ref_value = str_replace("=", "", $ref);
800
+ update_option('htcc_fb_ref', $ref_value);
801
  $value_new['fb_welcome_message'] = $this->getWelcomeMessage($page_id);
802
  $value_new['fb_as_state'] = 0;
803
  update_option('htcc_as_options', $value_new);
804
+ }else {
805
+ if (!$options['email']&&$this->getCurrentSubscription()){
806
+ foreach ($widgets->widgets as $key=>$value){
807
+ $value->type == 'email'?$options['email'] = $value->config->recipient:'';
808
+ }
809
+ update_option('htcc_as_options', $options);
810
+ }
811
  }
812
+
813
  }else{
814
  if (!$widgets){
815
  return false;
909
  }
910
  }
911
 
912
+ public function create_bot(){
913
+ $args = [
914
+ 'timeout' => 10,
915
+ 'headers' => [
916
+ 'Authorization' => $this->getToken(),
917
+ 'Content-Type' => 'application/json; charset=utf-8',
918
+ ],
919
+ 'body' => json_encode([
920
+ "fb_page_remote_id" => $this->getActiveRemotePageId(),
921
+ "kind" => 'default_bot',
922
+ "src" => $this->getSrc()
923
+ ]),
924
+ 'method' => 'POST',
925
+ ];
926
+ delete_option('htcc_custom_options');
927
+ unset($_SESSION['tab'],$_SESSION['current']);
928
+ $response = wp_remote_post($this->getApiDomain() . 'api/wordpress/bots?v=' . HTCC_VERSION.'.2', $args);
929
+ $error = ($this->ErrorHandler($response,'New bot','create'));
930
+ $return = array(
931
+ 'error' => $error,
932
+ 'response' => $response
933
+ );
934
+ wp_send_json_success($return);
935
+ }
936
+
937
  public function getEnv()
938
  {
939
 
1066
 
1067
  $orderby = filter_input(INPUT_GET, "orderby", FILTER_SANITIZE_STRING);
1068
  if (!empty($orderby)) {
1069
+ if($orderby=='name'){
1070
+ $get['sort_column'] = 'first_name';
1071
+ }else{
1072
+ $get['sort_column'] = $orderby;
1073
+ }
1074
  }
1075
 
1076
  $order = filter_input(INPUT_GET, "order", FILTER_SANITIZE_STRING);
1191
  }
1192
  echo $type;
1193
  }
1194
+ public function csv(){
1195
+ $contacts = $this->getContacts();
1196
+ $header_row = array(
1197
+ 'Name',
1198
+ 'Email',
1199
+ 'Gender',
1200
+ 'Locale',
1201
+ 'Time Zone',
1202
+ 'Created At'
1203
+ );
1204
+ $data_rows = array();
1205
+ foreach ( $contacts as $contact )
1206
+ {
1207
+ $row = array(
1208
+ $contact->first_name.$contact->last_name,
1209
+ $contact->email,
1210
+ $contact->gender,
1211
+ $contact->locale,
1212
+ $contact->timezone,
1213
+ $contact->created_at
1214
+ );
1215
+ $data_rows[] = $row;
1216
+ }
1217
+ header('Content-Description: File Transfer');
1218
+ header('Content-Type: application/csv');
1219
+ header('Content-Disposition: attachment; filename=contact.csv');
1220
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
1221
+ $fh = fopen( 'php://output', 'w' );
1222
+ fputcsv( $fh, $header_row );
1223
+ foreach ( $data_rows as $data_row ) {
1224
+ fputcsv( $fh, $data_row );
1225
+ }
1226
+ fclose($fh);
1227
+ die();
1228
+ }
1229
  private function getData()
1230
  {
1231
  $get = $this->getArgs();
1237
  ],
1238
  ];
1239
 
1240
+ $activePageId = $this->getActiveRemotePageId();
1241
 
1242
+ $response = wp_remote_get($this->getApiDomain() . 'api/wordpress/contacts?remote_page_id=' . $activePageId . '&page=' . $get['page'] . '&per_page=' . $get['pre_page'] . '&sort_column=' . $get['sort_column'] . '&sort_direction=' . $get['sort_direction'] . '&src=' . $this->getSrc(), $args);
1243
  $content = wp_remote_retrieve_body($response);
1244
  if (!empty($content)) {
1245
  $contacts = json_decode($content);
inc/class-htcc-chatbot.php CHANGED
@@ -201,10 +201,10 @@ class HTCC_Chatbot {
201
  return;
202
  }
203
  $activePage = $this->api->getActivePage();
204
- if (!$activePage) {
205
- delete_option('htcc_fb_js_src');
206
- $this->htcc_js_options = '';
207
- }
208
 
209
  if ( 'true' == HTCC_PRO ) {
210
  ?>
201
  return;
202
  }
203
  $activePage = $this->api->getActivePage();
204
+ if (!$activePage) {
205
+ delete_option('htcc_fb_js_src');
206
+ $this->htcc_js_options = '';
207
+ }
208
 
209
  if ( 'true' == HTCC_PRO ) {
210
  ?>
readme.txt CHANGED
@@ -3,7 +3,7 @@ Requires at least: 4.6
3
  Tested up to: 5.2
4
  Requires PHP: 5.6
5
  Contributors: larrykim, yankovski
6
- Stable tag: 4.1.2
7
  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, facebook, facebook messenger, mobilemonkey
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -578,6 +578,12 @@ WP-Chatbot is extremely flexible, versatile, and compatible. Because it works se
578
 
579
  == Changelog ==
580
 
 
 
 
 
 
 
581
  = 4.0.8 =
582
  Contacts page + new look & feel
583
 
3
  Tested up to: 5.2
4
  Requires PHP: 5.6
5
  Contributors: larrykim, yankovski
6
+ Stable tag: 4.1.3
7
  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, facebook, facebook messenger, mobilemonkey
8
  License: GPLv2 or later
9
  License URI: https://www.gnu.org/licenses/gpl-2.0.html
578
 
579
  == Changelog ==
580
 
581
+ = 4.1.3 =
582
+ Added ability to upgrade to Pro
583
+
584
+ = 4.1.2 =
585
+ New Horizontal Tab Design & Removing chat-widget on page disconnecting
586
+
587
  = 4.0.8 =
588
  Contacts page + new look & feel
589
 
wp-chatbot.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP Chatbot
4
  Plugin URI: https://mobilemonkey.com/wp-chatbot/
5
  Description: Add Messenger to your website, Chatbot or live Chat using Facebook Messenger
6
- Version: 4.1.2
7
  Author: MobileMonkey
8
  Author URI: https://mobilemonkey.com/wp-chatbot/
9
  License: GPL2
@@ -17,7 +17,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
17
 
18
  // Version - define HTCC_VERSION
19
  if ( ! defined( 'HTCC_VERSION' ) ) {
20
- define( 'HTCC_VERSION', '4.1.2' );
21
  }
22
 
23
 
3
  Plugin Name: WP Chatbot
4
  Plugin URI: https://mobilemonkey.com/wp-chatbot/
5
  Description: Add Messenger to your website, Chatbot or live Chat using Facebook Messenger
6
+ Version: 4.1.3
7
  Author: MobileMonkey
8
  Author URI: https://mobilemonkey.com/wp-chatbot/
9
  License: GPL2
17
 
18
  // Version - define HTCC_VERSION
19
  if ( ! defined( 'HTCC_VERSION' ) ) {
20
+ define( 'HTCC_VERSION', '4.1.3' );
21
  }
22
 
23