WP-Chatbot for Facebook Messenger Customer Chat - Version 4.1.5

Version Description

= From Dashboard ( WordPress admin ) = * If plugin new version released - you can see 'update now' link at wp-admin -> plugins * click on 'update now'

= using FTP or similar = * Delete wp-chatbot folder - your setting will not lost. * unzip wp-chatbot file and * Upload "wp-chatbot" folder to the "/wp-content/plugins/" directory. * Activate the plugin through the "Plugins" menu in WordPress.

Download this release

Release Info

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

Code changes from version 4.1.4 to 4.1.5

admin/assets/css/admin-styles.css CHANGED
@@ -1634,7 +1634,7 @@ p.submit{
1634
  border: none;
1635
  }
1636
  .contact_tab{
1637
- padding: 20px;
1638
  }
1639
  .contact_tab .table__wrap .displaying-num{
1640
  display: none;
@@ -2016,19 +2016,64 @@ p.submit{
2016
  line-height: 45px;
2017
  text-align: center;
2018
  }
2019
-
 
 
2020
  .billing-modal-header__plan-price p{
2021
  font-size: 23px;
2022
- text-decoration: line-through red;
2023
- font-weight: 800;
2024
  margin: 0;
2025
  text-align: center;
2026
  font-weight: 200;
2027
  }
2028
- .billing-modal-header__plan-price h4{
2029
- font-weight: 800;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2030
  text-decoration: none;
2031
  color: #FF7140;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2032
  }
2033
  .billing-modal-header__logo div{
2034
  background-image: url("../img/monkey_head.png");
@@ -2410,10 +2455,15 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2410
  border-radius: 9px;
2411
  margin: 0 0 20px auto;
2412
  }
2413
- .question-button__add{
2414
  cursor: pointer;
 
2415
  margin: 1rem 0 3rem 0;
2416
- display: inline-block
 
 
 
 
2417
  }
2418
  .question-block__header {
2419
  display: flex;
@@ -2531,7 +2581,7 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2531
  width: 70%;
2532
  word-break: break-all;
2533
  }
2534
- .answer__bin {
2535
  width: 25px;
2536
  min-width: 25px;
2537
  height: 25px;
@@ -2595,11 +2645,27 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2595
  top: 35px;
2596
  width: 182px;
2597
  word-break: keep-all;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2598
  }
2599
  .tab-content .main-question h3{
2600
  margin: 0 1em 1em;
2601
  }
2602
- .answer-input__wrapper {
2603
  display: none;
2604
  position: absolute;
2605
  width: 100%;
@@ -2666,7 +2732,7 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2666
  font-size: 14px;
2667
  }
2668
 
2669
- .add_question{
2670
  color: #324EF8;
2671
  box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2672
  padding: 10px 30px;
@@ -2676,11 +2742,9 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2676
  font-weight: 600;
2677
  line-height: 22px;
2678
  }
2679
- .add_question b{
2680
- font-size: 30px;
2681
- vertical-align: sub;
2682
- line-height: 0;
2683
- font-weight: 400;
2684
  }
2685
  .add__answer b{
2686
  font-size: 30px;
@@ -2699,6 +2763,38 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2699
  top: -19px;
2700
  left: 30px;
2701
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2702
  .answer-input__add{
2703
  margin-right: 15px;
2704
  }
@@ -2717,4 +2813,169 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2717
  color: #525252;
2718
  left: 5px;
2719
  top: -5px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2720
  }
1634
  border: none;
1635
  }
1636
  .contact_tab{
1637
+ padding: 20px 20px 40px 20px;
1638
  }
1639
  .contact_tab .table__wrap .displaying-num{
1640
  display: none;
2016
  line-height: 45px;
2017
  text-align: center;
2018
  }
2019
+ .billing-modal-header__plan-price{
2020
+ text-align: center;
2021
+ }
2022
  .billing-modal-header__plan-price p{
2023
  font-size: 23px;
 
 
2024
  margin: 0;
2025
  text-align: center;
2026
  font-weight: 200;
2027
  }
2028
+ .billing-modal-header__plan-price .discount .disc_cross b{
2029
+ font-size: 1.4em;
2030
+ }
2031
+ .billing-modal-header__plan-price .discount .disc_cross{
2032
+ margin-right: 20px;
2033
+ position: relative;
2034
+ color: #fff;
2035
+ font-size: 20px;
2036
+ }
2037
+ .billing-modal-header__plan-price .discount{
2038
+ display: flex;
2039
+ margin-top: 5px;
2040
+ align-items: baseline;
2041
+ }
2042
+ .billing-modal-header__plan-price .discount p{
2043
+ color: #2FF2E1;
2044
+ text-decoration: none;
2045
+ font-size: 20px;
2046
+ }
2047
+ .modal .billing-modal-header__plan-price h4{
2048
+ font-weight: 600;
2049
  text-decoration: none;
2050
  color: #FF7140;
2051
+ line-height: 18px;
2052
+ margin: 15px 0 0;
2053
+ }
2054
+ .billing-modal-header__plan-price p.billed{
2055
+ text-decoration: none;
2056
+ color: #9095FF;
2057
+ font-weight: 200;
2058
+ font-size: 1.6em;
2059
+ }
2060
+
2061
+ .billing-modal-header__plan-price .discount .disc_cross:before {
2062
+ content: "";
2063
+ border-bottom: 2px solid #FF8761;
2064
+ position: absolute;
2065
+ height: 10px;
2066
+ width: 100%;
2067
+ bottom: 18px;
2068
+ }
2069
+ .billing-modal-header__plan-price h4 b{
2070
+ font-weight: 200;
2071
+ font-size: 0.7em;
2072
+ }
2073
+ p.billed{
2074
+ color: #9095FF;
2075
+ font-weight: 200;
2076
+ font-size: 0.6em;
2077
  }
2078
  .billing-modal-header__logo div{
2079
  background-image: url("../img/monkey_head.png");
2455
  border-radius: 9px;
2456
  margin: 0 0 20px auto;
2457
  }
2458
+ .question-button__add,.qa-button__add{
2459
  cursor: pointer;
2460
+ position: relative;
2461
  margin: 1rem 0 3rem 0;
2462
+ display: inline-block;
2463
+ width: 100%;
2464
+ }
2465
+ .qa-button__add .pro_button__wrapper{
2466
+ top: -15px;
2467
  }
2468
  .question-block__header {
2469
  display: flex;
2581
  width: 70%;
2582
  word-break: break-all;
2583
  }
2584
+ .answer__bin, .qa__bin {
2585
  width: 25px;
2586
  min-width: 25px;
2587
  height: 25px;
2645
  top: 35px;
2646
  width: 182px;
2647
  word-break: keep-all;
2648
+ z-index: 15;
2649
+ }
2650
+ .tab-content .form-table td .tooltip.qa{
2651
+ top: 113px;
2652
+ }
2653
+ .have_qa a{
2654
+ display: block;
2655
+ padding: 20px;
2656
+ font-size: 18px;
2657
+ font-weight: bolder;
2658
+ text-align: center;
2659
+ background-color: #0e71ff;
2660
+ font-family: "Open Sans",sans-serif;
2661
+ color: #fff;
2662
+ border-radius: 18px;
2663
+ margin-bottom: 40px;
2664
  }
2665
  .tab-content .main-question h3{
2666
  margin: 0 1em 1em;
2667
  }
2668
+ .answer-input__wrapper, .qa-input__wrapper {
2669
  display: none;
2670
  position: absolute;
2671
  width: 100%;
2732
  font-size: 14px;
2733
  }
2734
 
2735
+ .add_question, .add_qa{
2736
  color: #324EF8;
2737
  box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2738
  padding: 10px 30px;
2742
  font-weight: 600;
2743
  line-height: 22px;
2744
  }
2745
+ .add_question b, .add_qa b{
2746
+ vertical-align: baseline;
2747
+ font-weight: bold;
 
 
2748
  }
2749
  .add__answer b{
2750
  font-size: 30px;
2763
  top: -19px;
2764
  left: 30px;
2765
  }
2766
+ .add_as_button{
2767
+ cursor: pointer;
2768
+ margin: 2em 0 0 0.8em;
2769
+ display: inline-block;
2770
+ }
2771
+ .as_item__wrap{
2772
+ align-items: center;
2773
+ display: flex;
2774
+ }
2775
+ .del_as{
2776
+ margin-left: 20px;
2777
+ width: 25px;
2778
+ min-width: 25px;
2779
+ height: 25px;
2780
+ background-color: #e4e4e4;
2781
+ color: #9E9E9E;
2782
+ text-align: center;
2783
+ line-height: 25px;
2784
+ border-radius: 50%;
2785
+ position: relative;
2786
+ cursor: pointer;
2787
+ }
2788
+ .add_as{
2789
+ color: #324EF8;
2790
+ box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2791
+ padding: 10px 30px;
2792
+ border-radius: 5px;
2793
+ font-family: "Open Sans",sans-serif;
2794
+ font-size: 15px;
2795
+ font-weight: 600;
2796
+ line-height: 22px;
2797
+ }
2798
  .answer-input__add{
2799
  margin-right: 15px;
2800
  }
2813
  color: #525252;
2814
  left: 5px;
2815
  top: -5px;
2816
+ }
2817
+ .main-qa{
2818
+ display: flex;
2819
+ flex-direction: row;
2820
+ background-color: #F4F6FF;
2821
+ border-radius: 15px;
2822
+ position: relative;
2823
+ margin: 20px 0;
2824
+ }
2825
+ .main-qa .del_qa{
2826
+ position: absolute;
2827
+ right: 10px;
2828
+ top: 10px;
2829
+ color: #0e71ff;
2830
+ font-size: 20px;
2831
+ }
2832
+ .main-qa h6{
2833
+ font-size: 14px;
2834
+ font-weight: bold;
2835
+ text-transform: uppercase;
2836
+ color: #525252;
2837
+ font-family: "Open Sans", sans-serif;
2838
+ }
2839
+ .qa-question__wrap,.qa-response{
2840
+ display: flex;
2841
+ padding: 1em 2em;
2842
+ flex-direction: column;
2843
+ width: 50%;
2844
+ flex-basis: 50%;
2845
+ }
2846
+ .qa-question__wrap .qa-question_input,.qa-question__wrap .qa-question-block{
2847
+ margin: 1em;
2848
+ }
2849
+ .qa-question__wrap{
2850
+ padding: 0;
2851
+ }
2852
+ .add_qa_question{
2853
+ width: 30%;
2854
+ align-self: auto;
2855
+ justify-content: center;
2856
+ text-align: center;
2857
+ display: flex;
2858
+ margin: 9px;
2859
+ background-color: #0e71ff;
2860
+ align-items: center;
2861
+ border-radius: 8px;
2862
+ color: #fff;
2863
+ font-size: 16px;
2864
+ box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2865
+ cursor: pointer;
2866
+ user-select: none;
2867
+ }
2868
+ .add_qa_question:focus,.add_qa_question:active{
2869
+ box-shadow: none;
2870
+ }
2871
+ .fb-customerchat{
2872
+ display: none;
2873
+ }
2874
+ .tab-content .qa-wrapper .qa_head{
2875
+ font-size: 22px;
2876
+ margin-bottom: 15px;
2877
+ margin-top: 0;
2878
+ }
2879
+ .tab-content .input-field.qa-wrapper{
2880
+ padding: 0;
2881
+ }
2882
+ .qa-response input[type=text]:not(.browser-default)::placeholder, .question_button_wrap input[type=text]:not(.browser-default)::placeholder{
2883
+ color: #A7A7A7;
2884
+ }
2885
+ .qa-response input[type=text]:not(.browser-default), .question_button_wrap input[type=text]:not(.browser-default){
2886
+ background-color: #fff;
2887
+ }
2888
+ .tab-content .form-table td .qa_p{
2889
+ margin-bottom: 20px;
2890
+ margin-top: 10px;
2891
+ }
2892
+ .qa-question-block-item{
2893
+ color: #fff;
2894
+ border-radius: 30px;
2895
+ cursor: pointer;
2896
+ margin-right: 10px;
2897
+ margin-bottom: 20px;
2898
+ display: flex;
2899
+ justify-content: center;
2900
+ align-items: center;
2901
+ }
2902
+ .qa-question-block{
2903
+ margin: 10px 0 10px 0;
2904
+ display: flex;
2905
+ flex-wrap: wrap;
2906
+ }
2907
+ span.qa-question-result {
2908
+ padding: 10px 35px;
2909
+ display: block;
2910
+ align-self: center;
2911
+ background-color: #0e71ff;
2912
+ border-radius: 30px;
2913
+ }
2914
+ .question_button_wrap{
2915
+ display: flex;
2916
+ }
2917
+
2918
+ .qa-input__wrapper{
2919
+ padding: 20px 20px 0 20px;
2920
+ border-radius: 9px;
2921
+ z-index: 9;
2922
+ }
2923
+ .qa-response{
2924
+ position: relative;
2925
+ }
2926
+ .qa-input__state{
2927
+ color: #fff;
2928
+ display: flex;
2929
+ justify-content: flex-end;
2930
+ padding: 10px 0 20px;
2931
+ font-family: "Open Sans",sans-serif;
2932
+ font-size: 16px;
2933
+ font-weight: 800;
2934
+ line-height: 22px;
2935
+ cursor: pointer;
2936
+ }
2937
+ .qa_submit,.qa_cancel{
2938
+ margin-left: 10px;
2939
+ font-size: 14px;
2940
+ }
2941
+ .tab-content .qa-input__item input[type=text]:not(.browser-default){
2942
+ background-color: #fff;
2943
+ box-sizing: border-box;
2944
+ padding: 10px 25px;
2945
+ width: 80%;
2946
+ border: none;
2947
+ border-radius: 9px;
2948
+ }
2949
+ .qa_cancel{
2950
+ font-weight: 400;
2951
+ }
2952
+ .qa-response:before {
2953
+ position: absolute;
2954
+ left: 0;
2955
+ top: 10%;
2956
+ border-left: 1px solid #B0B6CD;
2957
+ content: "";
2958
+ height: 80%;
2959
+ }
2960
+ .qa_new-wrapper h3{
2961
+ margin-left: 20px;
2962
+ font-size: 16px;
2963
+ margin-top: 0;
2964
+ }
2965
+ .qa-question-block-item .edit_qa{
2966
+ position: static;
2967
+ margin-left: 5px;
2968
+ display: flex;
2969
+ top: 21px;
2970
+ left: 10px;
2971
+ height: 25px;
2972
+ width: 25px;
2973
+ min-width: 25px;
2974
+ color: #9E9E9E;
2975
+ align-items: center;
2976
+ background-color: #E5E5E5;
2977
+ border-radius: 50px;
2978
+ justify-content: center;
2979
+ cursor: pointer;
2980
+ word-break: break-all;
2981
  }
admin/assets/js/admin.js CHANGED
@@ -750,6 +750,28 @@ jQuery(document).ready(function($){
750
  }
751
  }
752
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
753
  $(document).on("click", "#submit", function() {
754
  if (!save_from_form){
755
  var next = $(".step-wrapper ul li.tab-link.current").next();
@@ -815,24 +837,42 @@ jQuery(document).ready(function($){
815
  });
816
  }
817
  });
818
- $('.download__wrap').hover(
819
  function (event) {
820
  event.preventDefault();
821
  let page = $('.connected-page');
822
- let wrap = $('.contact_head__wrap');
823
- if (!page.hasClass('pro')){
824
- wrap.find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
825
  }
826
  },
827
  function (event) {
828
  event.preventDefault();
829
  let page = $('.connected-page');
830
- let wrap = $('.contact_head__wrap');
831
- if (!page.hasClass('pro')){
832
- wrap.find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
833
  }
834
  }
835
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
836
  $('.form-table tr').hover(
837
  function (event) {
838
  event.preventDefault();
@@ -1002,10 +1042,153 @@ jQuery(document).ready(function($){
1002
  }
1003
 
1004
 
1005
- var questionState;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1006
  $(document).on("click",".add__answer", function( event ) {
1007
  event.preventDefault();
1008
- var dataIndex = $(this).attr("data-index");
1009
  var fieldsetId = $(this).parents(".main-question").find(".answer__result").last().attr("data-index");
1010
  fieldsetId = fieldsetId?fieldsetId.replace(/[^0-9]/gi, ''):1;
1011
  var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
@@ -1043,16 +1226,49 @@ jQuery(document).ready(function($){
1043
  var top = $(this).prev('.answer__result').position().top;
1044
  }
1045
  $(".answer-input__wrapper").css({top: top+58});
1046
- $(".triangle").css({left: left+32});
1047
  $("#main_question_"+mainId).find(".answer-input__wrapper").show();
1048
  });
1049
  $(document).on("click","body", function(e) {
1050
  if(!$(event.target).closest(".answer__result,.answer-input__wrapper,.edit_answer").length){
1051
  $(".answer-input__wrapper").hide();
1052
  }
 
 
 
1053
  });
1054
 
1055
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1056
 
1057
 
1058
  $(document).on("click",".answer__bin", function() {
750
  }
751
  }
752
 
753
+ $(document).on("click", "#tab-1 #submit", function(event) {
754
+
755
+ let scroll = false;
756
+ $('.main-qa').each(function () {
757
+ if ($(this).find('.qa-response').find('input').val() ==''||$(this).find('.qa-question_value').find('input').length ==0||!$(this).find('.qa-response').find('input').val().replace(/\s/g, '').length){
758
+ $('<p class="tooltip qa"></p>')
759
+ .text(" At least 1 keyword and 1 answer is required for each Q&A")
760
+ .appendTo($(this).find('.qa-response'))
761
+ .fadeIn('fast');
762
+ $(this).find('.qa-response').find(".tooltip").delay(2000).fadeOut(300, function(){ $(this).remove();})
763
+ scroll = $(this).find('.qa-response');
764
+ }
765
+ });
766
+ if (scroll){
767
+ $([document.documentElement, document.body]).animate({
768
+ scrollTop: scroll.offset().top-250
769
+ }, 1000);
770
+ return false;
771
+ }else{
772
+ return true;
773
+ }
774
+ });
775
  $(document).on("click", "#submit", function() {
776
  if (!save_from_form){
777
  var next = $(".step-wrapper ul li.tab-link.current").next();
837
  });
838
  }
839
  });
840
+ $('.qa-button__add').hover(
841
  function (event) {
842
  event.preventDefault();
843
  let page = $('.connected-page');
844
+ if (!page.hasClass('pro')&&$('.main-qa').length!==0){
845
+ $(this).find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
846
+ $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
847
  }
848
  },
849
  function (event) {
850
  event.preventDefault();
851
  let page = $('.connected-page');
852
+ if (!page.hasClass('pro')&&$('.main-qa').length!==0){
853
+ $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
854
+ $(this).find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
855
  }
856
  }
857
  );
858
+ $('.download__wrap').hover(
859
+ function (event) {
860
+ event.preventDefault();
861
+ let page = $('.connected-page');
862
+ let wrap = $('.contact_head__wrap');
863
+ if (!page.hasClass('pro')){
864
+ wrap.find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
865
+ }
866
+ },
867
+ function (event) {
868
+ event.preventDefault();
869
+ let page = $('.connected-page');
870
+ let wrap = $('.contact_head__wrap');
871
+ if (!page.hasClass('pro')){
872
+ wrap.find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
873
+ }
874
+ }
875
+ );
876
  $('.form-table tr').hover(
877
  function (event) {
878
  event.preventDefault();
1042
  }
1043
 
1044
 
1045
+ $(document).on("click",".qa__bin", function() {
1046
+ var dataIndex = $(this).attr("data-index");
1047
+ var mainId = $(this).parents(".main-qa").attr("id").replace(/[^0-9]/gi, '');
1048
+ var inputs = $(this).parents(".qa-question__wrap").find(".qa-question_value").find("input");
1049
+ if(inputs.length === 1) {
1050
+ if($(this).find('.tooltip').length==0){
1051
+ $('<p class="tooltip"></p>')
1052
+ .text(" At least 1 keyword and 1 answer is required for each Q&A")
1053
+ .appendTo($(this))
1054
+ .fadeIn('fast');
1055
+ }
1056
+ return;
1057
+ }
1058
+ $(this).parents(".qa-question__wrap").find("#htcc_qa_"+mainId+'_'+dataIndex).remove();
1059
+ $(this).parent(".qa-question-block-item").remove();
1060
+ });
1061
+ $(document).on("mouseleave",".qa__bin", function() {
1062
+ $(this).find(".tooltip").fadeOut(300, function(){ $(this).remove();});
1063
+ });
1064
+
1065
+
1066
+ $(document).on("click",".add_qa_question", function( event ) {
1067
+ event.preventDefault();
1068
+ let fieldsetId = $(this).parents(".main-qa").find(".qa-question-result").last().attr("data-index");
1069
+ fieldsetId = fieldsetId?fieldsetId.replace(/[^0-9]/gi, ''):0;
1070
+ const mainId = $(this).parents(".main-qa").attr("id").replace(/[^0-9]/gi, '');
1071
+ const elem = $(this).siblings('input');
1072
+ let value = elem.val();
1073
+ const length = $(this).parents(".main-qa").find(".qa-question-result").length;
1074
+ let flag;
1075
+ if( length === 10 ) {
1076
+ return;
1077
+ }
1078
+ const count = Number(fieldsetId) + 1;
1079
+ if (!value|| !value.replace(/\s/g, '').length){
1080
+ value = 'Q&A '+mainId+' Keyword#'+count;
1081
+ }
1082
+ const inputValues = $('.qa-question-result').map(function() {
1083
+ return $(this).text();
1084
+ }).toArray();
1085
+ flag = $.inArray(value, inputValues) !== -1?true:false;
1086
+ if (flag){
1087
+ elem.val("");
1088
+ }else {
1089
+ let newAnswer = '<div class="qa-question-block-item">'+
1090
+ '<span class="qa-question-result" data-index="'+count+'">'+value+'</span>'+
1091
+ '<div class="edit_qa" data-index="'+count+'"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="qa__bin" data-index="'+count+'"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div></div>';
1092
+ let newInput = '<input type="hidden" name="htcc_as_options[qa_'+mainId+'][phrases][]" value="'+value+'" id="htcc_qa_'+mainId+'_'+count+'">';
1093
+ $(this).siblings('input').val('');
1094
+ $(this).parents(".main-qa").find(".qa-question-block").append(newAnswer);
1095
+ $(this).parents(".main-qa").find(".qa-question_value").append(newInput);
1096
+ }
1097
+ });
1098
+
1099
+ $(document).on("click",".qa-question-result,.edit_qa", function( event ) {
1100
+ event.preventDefault();
1101
+ $(".qa-input__wrapper").hide();
1102
+ var dataIndex = $(this).attr("data-index");
1103
+ var mainId = $(this).parents(".main-qa").attr("id").replace(/[^0-9]/gi, '');
1104
+ var answerValue = $("#htcc_qa_"+mainId+"_"+dataIndex).val();
1105
+ $("#main_qa_"+mainId).find("#qa-state").attr("data-index", dataIndex).val(answerValue);
1106
+ if ($(this).hasClass("qa-question-result")){
1107
+ var left = $(this).position().left;
1108
+ var top = $(this).position().top;
1109
+ }else {
1110
+ var left = $(this).prev('.qa-question-result').position().left;
1111
+ var top = $(this).prev('.qa-question-result').position().top;
1112
+ }
1113
+ $(".qa-input__wrapper").css({top: top+58});
1114
+ $("#main_qa_"+mainId).find(".triangle").css({left: left+32});
1115
+ $("#main_qa_"+mainId).find(".qa-input__wrapper").show();
1116
+ });
1117
+ $(document).on("click", ".qa_cancel", function( event ) {
1118
+ event.preventDefault();
1119
+ $(".qa-input__wrapper").hide();
1120
+ });
1121
+ $(document).on("click",".qa_submit", function( event ) {
1122
+ event.preventDefault();
1123
+ var mainId = $(this).parents(".main-qa").attr("id").replace(/[^0-9]/gi, '');
1124
+ var answerValue = $(this).parents(".main-qa").find("#qa-state").val();
1125
+ var dataIndex = $(this).parents(".main-qa").find("#qa-state").attr("data-index");
1126
+ $("#htcc_qa_"+mainId+"_"+dataIndex).val(answerValue);
1127
+ $(this).parents(".main-qa").find(".qa-input__wrapper").hide();
1128
+ $(this).parents(".main-qa").find(".qa-question-result[data-index='"+dataIndex+"']").text(answerValue);
1129
+ });
1130
+ $(document).on("click", ".del_qa", function() {
1131
+ let wrapper = $(this).parents('.qa_new-wrapper');
1132
+ $(this).parents(".main-qa").prev('h3').remove();
1133
+ $(this).parents(".main-qa").remove();
1134
+ wrapper.find('h3').each(function (index,value) {
1135
+ let number = index+1
1136
+ $(this).text('Q&A '+number);
1137
+ });
1138
+ $('.add_qa').css({'pointer-events':'all','opacity':'1'});
1139
+ });
1140
+ $(".add_qa").on("click", function() {
1141
+ var fieldsetId = $(".qa_new-wrapper").find(".main-qa").last().attr("id");
1142
+ let page = $('.connected-page');
1143
+ if (!page.hasClass('pro')&&$('.main-qa').length!==0){
1144
+ return;
1145
+ }
1146
+ if (fieldsetId){
1147
+ fieldsetId=fieldsetId.replace(/[^0-9]/gi, '');
1148
+ var copyBlock = $(".qa_new-wrapper").find(".main-qa").last().clone();
1149
+ var count = Number(fieldsetId) + 1;
1150
+ copyBlock.find(".qa-response").children("input").attr("id", "htcc_qa_"+count+"_answer").attr("name", "htcc_as_options[qa_"+count+"][bot_responses]").val("");
1151
+ copyBlock.find(".qa-question-block-item").find(".qa-question-result").text("Q&A "+count+" Keyword#1");
1152
+ copyBlock.find(".qa-question-block-item").not(':first').remove();
1153
+ copyBlock.find(".qa-question_value").children("input").not(':first').remove();
1154
+ copyBlock.find(".qa-question_value").children("input").first().attr("id", "htcc_qa_"+count+"_1").attr("name", "htcc_as_options[qa_"+count+"][phrases][]").val("Q&A "+count+" Keyword#1");
1155
+ var html = "";
1156
+ html += '<div class="main-qa" id="main_qa_'+count+'">';
1157
+ html += copyBlock.html();
1158
+ html += '</div>';
1159
+ $(".qa_new-wrapper").append('<h3>Q&A '+count+'</h3>');
1160
+ $(".qa_new-wrapper").append(html);
1161
+ $("#main_qa_"+count).find(".qa-response").children("input").val("");
1162
+ }else {
1163
+ fieldsetId=1;
1164
+ $(".qa_new-wrapper").html('<h3>Q&A '+fieldsetId+'</h3><div class="main-qa" id="main_qa_'+fieldsetId+'"><div class="qa-question__wrap"><div class="qa-question_input"><h6>If user says something similar to</h6><div class="question_button_wrap"><input type="text" placeholder="e.g.&quot;Home&quot;,&quot;prices&quot;,etc." autocomplete="off"><div class="add_qa_question">Add</div></div></div><div class="qa-question-block"><div class="qa-question-block-item"><span class="qa-question-result" data-index="'+fieldsetId+'">Q&A '+fieldsetId+' Keyword#1</span><div class="edit_qa" data-index="'+fieldsetId+'"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="qa__bin" data-index="'+fieldsetId+'"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div></div><div class="qa-question_value"> <input type="hidden" name="htcc_as_options[qa_1][phrases][]" value="Q&A 1 Keyword#1" id="htcc_qa_1_1"></div><div class="qa-input__wrapper" style="display: none;"><span class="triangle"></span><div class="qa-input__item"><input type="text" id="qa-state"></div><div class="qa-input__state"><span class="qa_cancel">Cancel</span><span class="qa_submit">OK</span></div></div></div><div class="qa-response"><h6>Wp-chatbot will respond with</h6><input type="text" name="htcc_as_options[qa_1][bot_responses]" placeholder="Enter the answer here" id="htcc_qa_'+fieldsetId+'_answer" autocomplete="off"></div><div class="del_qa"> <i class="fa fa-trash-o" aria-hidden="true"></i></div></div>');
1165
+ }});
1166
+
1167
+ $('#qa-state').keypress(function(event){
1168
+ if(event.keyCode == 13){
1169
+ $('.qa_submit').click();
1170
+ }
1171
+ });
1172
+ $('body').on("keypress",'.question_button_wrap input', function(event){
1173
+ if(event.keyCode == 13){
1174
+ $(this).siblings('.add_qa_question').click();
1175
+ }
1176
+ });
1177
+ $(document).on("keypress", 'form', function (e) {
1178
+ var code = e.keyCode || e.which;
1179
+ if (code == 13) {
1180
+ e.preventDefault();
1181
+ return false;
1182
+ }
1183
+ });
1184
+
1185
+
1186
+
1187
+
1188
+ var questionState;
1189
+
1190
  $(document).on("click",".add__answer", function( event ) {
1191
  event.preventDefault();
 
1192
  var fieldsetId = $(this).parents(".main-question").find(".answer__result").last().attr("data-index");
1193
  fieldsetId = fieldsetId?fieldsetId.replace(/[^0-9]/gi, ''):1;
1194
  var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1226
  var top = $(this).prev('.answer__result').position().top;
1227
  }
1228
  $(".answer-input__wrapper").css({top: top+58});
1229
+ $("#main_question_"+mainId).find(".triangle").css({left: left+32});
1230
  $("#main_question_"+mainId).find(".answer-input__wrapper").show();
1231
  });
1232
  $(document).on("click","body", function(e) {
1233
  if(!$(event.target).closest(".answer__result,.answer-input__wrapper,.edit_answer").length){
1234
  $(".answer-input__wrapper").hide();
1235
  }
1236
+ if(!$(event.target).closest(".qa-question-result,.qa-input__wrapper,.edit_qa").length){
1237
+ $(".qa-input__wrapper").hide();
1238
+ }
1239
  });
1240
 
1241
 
1242
+ $(document).on("click",".del_as", function() {
1243
+ var inputs = $(this).parents(".as_main__wrap").find("input");
1244
+ if (inputs.length === 1){
1245
+ if($(this).find('.tooltip').length==0){
1246
+ $('<p class="tooltip"></p>')
1247
+ .text("At least 1 question is required for Answering Service")
1248
+ .appendTo($(this))
1249
+ .fadeIn('fast');
1250
+ }
1251
+ return;
1252
+ }
1253
+ $(this).parent('.as_item__wrap').remove();
1254
+ });
1255
+ $(document).on("mouseleave",".del_as", function() {
1256
+ $(this).find(".tooltip").fadeOut(300, function(){ $(this).remove();});
1257
+ });
1258
+ $(document).on("click",".add_as", function() {
1259
+ var fieldsetId = $('.as_main__wrap').find('.as_item__wrap').last().find('input').attr("id");
1260
+ if (fieldsetId){
1261
+ fieldsetId = fieldsetId.replace(/[^0-9]/gi, '');
1262
+ var count = Number(fieldsetId) + 1;
1263
+ var block_as = $('.as_main__wrap').children().last().clone();
1264
+ block_as.find('.fb_answer').attr('id', 'fb_answer'+count);
1265
+ $(".as_main__wrap").append(block_as);
1266
+ $(".answer_server").find('.fb_answer').last().attr('value', 'Question '+count);
1267
+ }else {
1268
+ $(".as_main__wrap").append('<div class="as_item__wrap"><input type="text" id="fb_answer1" name="htcc_as_options[fb_answer][]" class="fb_answer" value="Question 1"><div class="del_as"><i class="fa fa-trash-o" aria-hidden="true"></i></div></div>')
1269
+ }
1270
+ });
1271
+
1272
 
1273
 
1274
  $(document).on("click",".answer__bin", function() {
admin/class-htcc-admin.php CHANGED
@@ -75,7 +75,7 @@ if (!class_exists('HTCC_Admin')) :
75
  'wp-chatbot',
76
  'Customize',
77
  '<span data-tab="tab-2">Customize</span>',
78
- 8,
79
  '',
80
  ''
81
  );
@@ -83,7 +83,7 @@ if (!class_exists('HTCC_Admin')) :
83
  'wp-chatbot',
84
  'Contacts',
85
  '<span data-tab="tab-3">Leads</span>',
86
- 8,
87
  '',
88
  ''
89
  );
@@ -91,7 +91,7 @@ if (!class_exists('HTCC_Admin')) :
91
  'wp-chatbot',
92
  'Your Subscription',
93
  '<span data-tab="tab-4">Your Subscription</span>',
94
- 8,
95
  '',
96
  ''
97
  );
@@ -206,12 +206,11 @@ if (!class_exists('HTCC_Admin')) :
206
 
207
  add_settings_field('htcc_fb_welcome_message', __('Welcome Message', 'wp-chatbot'), array($this, 'htcc_fb_welcome_message_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
208
  add_settings_field('htcc_fb_as_state', '', array($this, 'htcc_fb_as_state_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
209
- add_settings_field('htcc_fb_answer1','', array($this, 'htcc_fb_answer1_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
210
- add_settings_field('htcc_fb_answer2','', array($this, 'htcc_fb_answer2_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
211
- add_settings_field('htcc_fb_answer3','', array($this, 'htcc_fb_answer3_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
212
  add_settings_field('htcc_fb_question','', array($this, 'htcc_fb_question_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
213
  add_settings_field('htcc_fb_email_trans', '', array($this, 'htcc_fb_email_trans_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
214
  add_settings_field('htcc_fb_thank_answer', '', array($this, 'htcc_fb_thank_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
 
215
  register_setting('htcc_as_setting_group', 'htcc_as_options', array($this, 'htcc_as_options_sanitize'));
216
 
217
 
@@ -242,6 +241,70 @@ if (!class_exists('HTCC_Admin')) :
242
  ?>
243
  <?php
244
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  public function htcc_fb_question_cb(){
246
  $htcc_as_options = get_option('htcc_as_options');
247
  $html='';
@@ -307,7 +370,7 @@ if (!class_exists('HTCC_Admin')) :
307
  </div>
308
  </div>
309
  <div class="question-button__add">
310
- <span class="add_question"><b>+</b> Add question</span>
311
  </div>
312
  <?php
313
  }
@@ -405,40 +468,29 @@ if (!class_exists('HTCC_Admin')) :
405
  </div>
406
  <?php
407
  }
408
- public function htcc_fb_answer1_cb()
409
- {
410
- $htcc_fb_answer1 = get_option('htcc_as_options');
411
- ?>
412
- <div class="row as">
413
- <div class="input-field col l12 m12">
414
- <h3 class="qq_label"><?php _e('Quick Questions', 'wp-chatbot') ?></h3>
415
- <label class="gray" for="fb_answer1"><?php _e('WP-Chatbot will ask your chat users a few questions.', 'wp-chatbot') ?></label>
416
- <input type="text" name="htcc_as_options[fb_answer1]" id="fb_answer1"
417
- value="<?php echo esc_attr($htcc_fb_answer1['fb_answer1']) ?>">
418
- </div>
419
- </div>
420
- <?php
421
- }
422
- public function htcc_fb_answer2_cb()
423
  {
424
- $htcc_fb_answer2 = get_option('htcc_as_options');
425
  ?>
426
  <div class="row as">
427
- <div class="input-field col l12 m12">
428
- <input type="text" name="htcc_as_options[fb_answer2]" id="fb_answer2"
429
- value="<?php echo esc_attr($htcc_fb_answer2['fb_answer2']) ?>">
 
 
 
 
 
 
 
 
 
 
 
 
430
  </div>
431
- </div>
432
- <?php
433
- }
434
- public function htcc_fb_answer3_cb()
435
- {
436
- $htcc_fb_answer3 = get_option('htcc_as_options');
437
- ?>
438
- <div class="row as">
439
- <div class="input-field col l12 m12">
440
- <input type="text" name="htcc_as_options[fb_answer3]" id="fb_answer3"
441
- value="<?php echo esc_attr($htcc_fb_answer3['fb_answer3']) ?>">
442
  </div>
443
  </div>
444
  <?php
@@ -1113,7 +1165,7 @@ if (!class_exists('HTCC_Admin')) :
1113
  $new_input[$key] = $option[$key];
1114
  $error_email = true;
1115
  }else {
1116
- if (strpos($key, 'lq_')!==false){
1117
  $new_input[$key] = $value;
1118
  }else{
1119
  $new_input[$key] = sanitize_text_field($input[$key]);
75
  'wp-chatbot',
76
  'Customize',
77
  '<span data-tab="tab-2">Customize</span>',
78
+ 'manage_options',
79
  '',
80
  ''
81
  );
83
  'wp-chatbot',
84
  'Contacts',
85
  '<span data-tab="tab-3">Leads</span>',
86
+ 'manage_options',
87
  '',
88
  ''
89
  );
91
  'wp-chatbot',
92
  'Your Subscription',
93
  '<span data-tab="tab-4">Your Subscription</span>',
94
+ 'manage_options',
95
  '',
96
  ''
97
  );
206
 
207
  add_settings_field('htcc_fb_welcome_message', __('Welcome Message', 'wp-chatbot'), array($this, 'htcc_fb_welcome_message_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
208
  add_settings_field('htcc_fb_as_state', '', array($this, 'htcc_fb_as_state_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
209
+ add_settings_field('htcc_fb_answer','', array($this, 'htcc_fb_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
 
 
210
  add_settings_field('htcc_fb_question','', array($this, 'htcc_fb_question_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
211
  add_settings_field('htcc_fb_email_trans', '', array($this, 'htcc_fb_email_trans_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
212
  add_settings_field('htcc_fb_thank_answer', '', array($this, 'htcc_fb_thank_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
213
+ add_settings_field('htcc_fb_qq','', array($this, 'htcc_fb_qa_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
214
  register_setting('htcc_as_setting_group', 'htcc_as_options', array($this, 'htcc_as_options_sanitize'));
215
 
216
 
241
  ?>
242
  <?php
243
  }
244
+ public function htcc_fb_qa_cb(){
245
+ $htcc_as_options = get_option('htcc_as_options');
246
+ $html='';
247
+ $i=1;
248
+ $this->email_block = false;
249
+ foreach ($htcc_as_options as $key=>$value){
250
+ $span='';
251
+ $inp='';
252
+ $ans='';
253
+ $y=1;
254
+ if (strpos($key, 'qa_')!==false){
255
+ $this->email_block = true;
256
+ $html.= ' <h3>Q&A '.$i.'</h3>
257
+ <div class="main-qa" id="main_qa_'.$i.'">
258
+ <div class="qa-question__wrap">
259
+ <div class="qa-question_input">
260
+ <h6>If user says something similar to</h6>
261
+ <div class="question_button_wrap">
262
+ <input type="text" placeholder="e.g.&quot;Home&quot;,&quot;prices&quot;,etc." autocomplete="off">
263
+ <div class="add_qa_question">Add</div>
264
+ </div>
265
+ </div>';
266
+ foreach ($value as $k=>$v){
267
+ if ($k=='phrases' && !empty($v)){
268
+ foreach ($v as $ke=>$va){
269
+ $span.= '<div class="qa-question-block-item"><span class="qa-question-result" data-index="'.$y.'">'.$va.'</span><div class="edit_qa" data-index="'.$y.'"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="qa__bin" data-index="'.$y.'"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div>';
270
+ $inp.= '<input type="hidden" name="htcc_as_options[qa_'.$i.'][phrases][]" value="'.$va.'" id="htcc_qa_'.$i.'_'.$y.'">';
271
+ $y++;
272
+ }
273
+ }elseif($k=='bot_responses'){
274
+ $ans.= '<input name="htcc_as_options[qa_'.$i.'][bot_responses]" value="'.$v.'" autocomplete="off" id="htcc_qa_'.$i.'_answer" type="text" placeholder="Enter the answer here">';
275
+ }
276
+ }
277
+ $i++;
278
+ $html.='<div class="qa-question-block">
279
+ '.$span.' </div> <div class="qa-question_value"> '.$inp.' </div> <div class="qa-input__wrapper" style="display: none;"> <span class="triangle"></span> <div class="qa-input__item"> <input type="text" id="qa-state"> </div> <div class="qa-input__state"> <span class="qa_cancel">Cancel</span> <span class="qa_submit">OK</span> </div> </div> </div> <div class="qa-response"> <h6>Wp-chatbot will respond with</h6> '.$ans.' </div>
280
+ <div class="del_qa">
281
+ <i class="fa fa-trash-o" aria-hidden="true"></i>
282
+ </div>
283
+ ';
284
+ $html.= '</div>';
285
+ }
286
+ }
287
+
288
+ ?>
289
+ <div class="input-field col s12 qa-wrapper">
290
+ <h3 class="qa_head"><?php _e('Q&A', 'wp-chatbot') ?></h3>
291
+ <p class="qa_p"><?php _e('WP-Chatbot will answer questions on your page based on keywords detected in the user’s question.', 'wp-chatbot') ?></p>
292
+ <div class="qa_new-wrapper">
293
+ <?php echo $html;?>
294
+ </div>
295
+ </div>
296
+ <div class="qa-button__add">
297
+ <span class="add_qa"><b>+</b> Add Q&A</span>
298
+ <div class="pro_button__wrapper" style="opacity: 1; display: none;"><a href="#" class="pro_button__link"><div class="pro_button"><div class="pro_button__content"><p>Upgrade to unlock this feature</p><h3>Get <b>50% off</b> when you upgrade today.</h3></div><div class="pro_button__action"><span class="pro_button_action__text">Upgrade</span></div></div></a></div>
299
+ </div>
300
+ <?php if ($htcc_as_options['advanced_triggers_present']){?>
301
+ <div class="have_qa">
302
+ <a target="_blank" href="https://app.mobilemonkey.com/chatbot-editor/" >You have more advanced Q&As created in MobileMonkey. Go to MobileMonkey to edit those Q&As</a>
303
+ </div>
304
+ <?php
305
+ }
306
+
307
+ }
308
  public function htcc_fb_question_cb(){
309
  $htcc_as_options = get_option('htcc_as_options');
310
  $html='';
370
  </div>
371
  </div>
372
  <div class="question-button__add">
373
+ <span class="add_question"><b>+</b> Add Question</span>
374
  </div>
375
  <?php
376
  }
468
  </div>
469
  <?php
470
  }
471
+ public function htcc_fb_answer_cb()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
472
  {
473
+ $htcc_fb_answer = get_option('htcc_as_options');
474
  ?>
475
  <div class="row as">
476
+ <div class="input-field col l12 m12 answer_server"> <?php
477
+ $html ='';
478
+ $i=1;
479
+ foreach ($htcc_fb_answer['fb_answer'] as $key=>$value){
480
+
481
+ $html.='<div class="as_item__wrap"><input type="text" id="fb_answer'.$i.'" name="htcc_as_options[fb_answer][]" class="fb_answer"
482
+ value="'.$value.'"><div class="del_as"><i class="fa fa-trash-o" aria-hidden="true"></i></div></div>';
483
+ $i++;
484
+ }
485
+ ?>
486
+ <h3 class="qq_label"><?php _e('Quick Questions', 'wp-chatbot') ?></h3>
487
+ <label class="gray" for="fb_answer1"><?php _e('WP-Chatbot will ask your chat users a few questions.', 'wp-chatbot') ?></label>
488
+ <div class="as_main__wrap">
489
+ <?php echo $html;?>
490
+ </div>
491
  </div>
492
+ <div class="add_as_button">
493
+ <span class="add_as"><b>+</b> Add Question</span>
 
 
 
 
 
 
 
 
 
494
  </div>
495
  </div>
496
  <?php
1165
  $new_input[$key] = $option[$key];
1166
  $error_email = true;
1167
  }else {
1168
+ if (strpos($key, 'lq_')!==false||strpos($key, 'qa_')!==false || $key =='fb_answer'){
1169
  $new_input[$key] = $value;
1170
  }else{
1171
  $new_input[$key] = sanitize_text_field($input[$key]);
admin/commons/ht-cc-admin-fb-subscription.php CHANGED
@@ -17,6 +17,7 @@ if ($message_statistic->count){
17
  $message = $message_statistic->count;
18
  }
19
  }else{
 
20
  $message_statistic->count=0;
21
  $message = 0;
22
  }
17
  $message = $message_statistic->count;
18
  }
19
  }else{
20
+ $message_statistic= (object)array();
21
  $message_statistic->count=0;
22
  $message = 0;
23
  }
admin/commons/ht-cc-admin-settings-form.php CHANGED
@@ -124,6 +124,16 @@ $$current .= ' current';
124
  $table->display();
125
  ?>
126
  </div>
 
 
 
 
 
 
 
 
 
 
127
  </div>
128
  <div id="tab-4" class="tab-content subscribe_section <?php echo $tab4 ?>">
129
  <div class="tab-content__wrapper">
@@ -206,8 +216,12 @@ $$current .= ' current';
206
  <span><?php _e('MobileMonkey') ?></span></div>
207
  <div class="billing-modal-header__plan-name">WP-CHATBOT PRO</div>
208
  <div class="billing-modal-header__plan-price">
209
- <h4>$<?php _e(number_format(($plan['unit_amount_in_cents'] /100), 2, '.', ' '))?>/<?php _e($plan['billing_period'])?></h4>
210
- <p><?php _e('$98/year') ?></p>
 
 
 
 
211
  </div>
212
 
213
  <div class="billing-page-details">
124
  $table->display();
125
  ?>
126
  </div>
127
+ <div class="customization_button__wrapper">
128
+ <a target="_blank" rel="noopener noreferrer" href="https://app.mobilemonkey.com/chatbot-editor/<?php echo $connected_page['bot_id']?>/bot-builder" class="customization_button__link">
129
+ <div class="customization_button">
130
+ <div class="customization_button__content">More chatbot customization in <span class="customization_button__image"></span> MobileMonkey</div>
131
+ <div class="customization_button__action">
132
+ <span class="button_action__text">LEt's go</span>
133
+ </div>
134
+ </div>
135
+ </a>
136
+ </div>
137
  </div>
138
  <div id="tab-4" class="tab-content subscribe_section <?php echo $tab4 ?>">
139
  <div class="tab-content__wrapper">
216
  <span><?php _e('MobileMonkey') ?></span></div>
217
  <div class="billing-modal-header__plan-name">WP-CHATBOT PRO</div>
218
  <div class="billing-modal-header__plan-price">
219
+ <h4>$<?php _e(round(number_format(($plan['unit_amount_in_cents'] /100), 2, '.', ' ')/12))?><b>/month</b></h4>
220
+ <p class="billed"><?php _e("billed annually")?></p>
221
+ <div class="discount">
222
+ <p class="disc_cross"><?php _e('<b>$8/</b>month') ?></p>
223
+ <p><?php _e('Save 50% today') ?></p>
224
+ </div>
225
  </div>
226
 
227
  <div class="billing-page-details">
inc/MobileMonkeyApi.php CHANGED
@@ -567,7 +567,6 @@ class MobileMonkeyApi
567
  }
568
  }
569
  $this->pages = $pages;
570
-
571
  return $pages;
572
  }
573
 
@@ -742,10 +741,7 @@ class MobileMonkeyApi
742
  $error = $this->ErrorHandler($response,'Widget','get');
743
  if ($error) {
744
  $connect_response = json_decode($error);
745
- foreach ($connect_response->questions as $key => $value) {
746
- $key += 1;
747
- $value_new['fb_answer' . $key . ''] = $value;
748
- }
749
  $i=1;
750
  foreach ($connect_response->qualifiers as $key=>$value){
751
  foreach ($value as $k=>$v){
@@ -777,17 +773,67 @@ class MobileMonkeyApi
777
  return false;
778
  }
779
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
  public function setWidgets($options,$page_id,$update)
781
  {
782
  $var = true;
 
783
  if (!$update){
 
784
  if (count($options,COUNT_NORMAL)==1 && $options['fb_welcome_message']||!$options) {
 
785
  $data_widget = $this->getWidgets($page_id);
 
786
  foreach ($data_widget as $key=>$value){
787
  if (strpos($key, 'lq_')!==false){
788
  $var=false;
789
  }
790
  }
 
 
 
 
 
 
791
  if ($var){
792
  $data_widget['lq_1']['question'] = 'What is your budget?';
793
  $data_widget['lq_1']['answers1']['answer'] = '$0';
@@ -796,6 +842,22 @@ class MobileMonkeyApi
796
  $data_widget['lq_1']['answers4']['answer'] = '$500+';
797
  $data_widget['lq_1']['answers4']['qualified'] = '1';
798
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
799
  update_option('htcc_as_options', $data_widget);
800
  }
801
  }else{
@@ -808,13 +870,7 @@ class MobileMonkeyApi
808
  } else {
809
  $value_new['enabled'] = true;
810
  }
811
- $i=0;
812
- foreach ($data_widget as $key=>$value){
813
- if (strpos($key, 'fb_answer')!==false){
814
- $i += 1;
815
- $value_new['questions'][] = $options['fb_answer'.$i.''];
816
- }
817
- }
818
  foreach ($options as $key=>$value){
819
  if (strpos($key, 'lq_')!==false){
820
  $answer = array();
@@ -838,6 +894,28 @@ class MobileMonkeyApi
838
  ];
839
 
840
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
841
  }
842
  if ($error_lenght){
843
  $this->settingSaveError("AS");
@@ -850,16 +928,32 @@ class MobileMonkeyApi
850
  $value_new["notify_mode"]= $options['notify_mode'];
851
  $value_new['thank_you_message'] = $options['thank_message'];
852
  $value_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
 
 
853
  $this->updateWidgets($value_new);
854
- $data_widget2 = $this->getWidgets($page_id);
855
- $data_widget2['fb_as_state'] = $value_new['enabled'];
856
- update_option('htcc_as_options', $data_widget2);
857
-
858
  }
859
  return true;
860
 
861
  }
862
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
863
  public function updateWidgets($object)
864
  {
865
  $args = [
567
  }
568
  }
569
  $this->pages = $pages;
 
570
  return $pages;
571
  }
572
 
741
  $error = $this->ErrorHandler($response,'Widget','get');
742
  if ($error) {
743
  $connect_response = json_decode($error);
744
+ $value_new['fb_answer'] = $connect_response->questions;
 
 
 
745
  $i=1;
746
  foreach ($connect_response->qualifiers as $key=>$value){
747
  foreach ($value as $k=>$v){
773
  return false;
774
  }
775
  }
776
+
777
+ public function getTriggers($remote_id)
778
+ {
779
+ $args = [
780
+ 'timeout' => 10,
781
+ 'headers' => [
782
+ 'Authorization' => $this->getToken(),
783
+ 'Content-Type' => 'application/json',
784
+ ],
785
+ 'body' => [
786
+ 'src' => $this->getSrc()
787
+ ]
788
+ ];
789
+
790
+ $response = wp_remote_get($this->getApiDomain() . 'api/wordpress_settings/triggers?fb_page_remote_id=' . $remote_id . '&v=' . HTCC_VERSION.'.2', $args);
791
+ $error = $this->ErrorHandler($response,'Q&A','get');
792
+ if ($error) {
793
+ $connect_response = json_decode($error);
794
+ $i=1;
795
+ $value_new['advanced_triggers_present'] = $connect_response->advanced_triggers_present;
796
+ foreach ($connect_response->triggers as $key=>$value){
797
+ foreach ($value as $k=>$v){
798
+ if ($k == 'bot_responses'){
799
+ $value_new['qa_'.$i][$k] = $v[0];
800
+ }else {
801
+ foreach ($v as $kr=>$an){
802
+ $value_new['qa_'.$i][$k][]=$an;
803
+ }
804
+ }
805
+ }
806
+ $i++;
807
+ }
808
+ return $value_new;
809
+ } else {
810
+ return false;
811
+ }
812
+ }
813
+
814
+
815
+
816
  public function setWidgets($options,$page_id,$update)
817
  {
818
  $var = true;
819
+ $trig = true;
820
  if (!$update){
821
+ $triggers = $this->getTriggers($page_id);
822
  if (count($options,COUNT_NORMAL)==1 && $options['fb_welcome_message']||!$options) {
823
+
824
  $data_widget = $this->getWidgets($page_id);
825
+ $data_widget = array_merge( $data_widget,$triggers);
826
  foreach ($data_widget as $key=>$value){
827
  if (strpos($key, 'lq_')!==false){
828
  $var=false;
829
  }
830
  }
831
+ foreach ($data_widget as $k=>$v){
832
+ if (strpos($k, 'qa_')!==false){
833
+ $trig=false;
834
+ }
835
+ }
836
+
837
  if ($var){
838
  $data_widget['lq_1']['question'] = 'What is your budget?';
839
  $data_widget['lq_1']['answers1']['answer'] = '$0';
842
  $data_widget['lq_1']['answers4']['answer'] = '$500+';
843
  $data_widget['lq_1']['answers4']['qualified'] = '1';
844
  }
845
+ if ($trig){
846
+ $data_widget['qa_1']['phrases'] ='';
847
+ $data_widget['qa_1']['bot_responses'] ='';
848
+ }
849
+ $data_widget['advanced_triggers_present']= $triggers['advanced_triggers_present'];
850
+ update_option('htcc_as_options', $data_widget);
851
+ }else {
852
+ foreach ($options as $key=>$value){
853
+ if (strpos($key, 'qa_')!==false){
854
+ if (!empty($value['phrases'])&&!empty($value['bot_responses'])){
855
+ unset($options[$key]);
856
+ }
857
+ }
858
+ }
859
+ $data_widget = array_merge( $options,$triggers);
860
+ $data_widget['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
861
  update_option('htcc_as_options', $data_widget);
862
  }
863
  }else{
870
  } else {
871
  $value_new['enabled'] = true;
872
  }
873
+ $value_new['questions'] = $options['fb_answer'];
 
 
 
 
 
 
874
  foreach ($options as $key=>$value){
875
  if (strpos($key, 'lq_')!==false){
876
  $answer = array();
894
  ];
895
 
896
  }
897
+ if (strpos($key, 'qa_')!==false){
898
+ $phrases = array();
899
+ $bot_responses = array();
900
+ foreach ($value as $k=>$v){
901
+ if ($k=='bot_responses'&&!empty($v)){
902
+ $bot_responses[] = $v;
903
+ }else{
904
+ if(!empty($v)){
905
+ if (!ctype_space($v)){
906
+ $phrases=$v;
907
+ }
908
+ }else{
909
+ $error_lenght = true;
910
+ }
911
+ }
912
+
913
+ }
914
+ $trigger_new["triggers"][]=[
915
+ "phrases"=>$phrases,
916
+ "bot_responses"=>$bot_responses
917
+ ];
918
+ }
919
  }
920
  if ($error_lenght){
921
  $this->settingSaveError("AS");
928
  $value_new["notify_mode"]= $options['notify_mode'];
929
  $value_new['thank_you_message'] = $options['thank_message'];
930
  $value_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
931
+ $trigger_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
932
+ $this->updateTriggers($trigger_new);
933
  $this->updateWidgets($value_new);
 
 
 
 
934
  }
935
  return true;
936
 
937
  }
938
 
939
+ public function updateTriggers($object)
940
+ {
941
+ $args = [
942
+ 'timeout' => 10,
943
+ 'headers' => [
944
+ 'Authorization' => $this->getToken(),
945
+ 'Content-Type' => 'application/json',
946
+ ],
947
+ 'body' => json_encode($object),
948
+ 'method' => 'PUT',
949
+ ];
950
+ $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/triggers', $args);
951
+ $error = ($this->ErrorHandler($response,'Triggers','put'));
952
+ if ($error) {
953
+ return $response;
954
+ }
955
+ }
956
+
957
  public function updateWidgets($object)
958
  {
959
  $args = [
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.4
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
3
  Tested up to: 5.2
4
  Requires PHP: 5.6
5
  Contributors: larrykim, yankovski
6
+ Stable tag: 4.1.5
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
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.4
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.4' );
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.5
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.5' );
21
  }
22
 
23