WP-Chatbot for Facebook Messenger Customer Chat - Version 4.2

Version Description

Introduce new Q&A feature

Download this release

Release Info

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

Code changes from version 4.1.5 to 4.2

admin/admin.php CHANGED
@@ -16,6 +16,8 @@ require_once(HTCC_PLUGIN_DIR . 'inc/MobileMonkeyApi.php');
16
 
17
  require_once('class-htcc-lang.php');
18
 
 
 
19
  require_once('class-htcc-admin.php');
20
 
21
 
@@ -29,13 +31,17 @@ add_action( 'admin_init', array( $admin, 'htcc_custom_settings' ) );
29
  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_email_section', array($admin,'email_section'));
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
 
16
 
17
  require_once('class-htcc-lang.php');
18
 
19
+ require_once('class-htcc-countries.php');
20
+
21
  require_once('class-htcc-admin.php');
22
 
23
 
31
  add_action( 'admin_init', array( $admin, 'htcc_incomplete_setup' ) );
32
  add_action('admin_init', 'htcc_admin_notice');
33
  add_action('admin_notices', array( $admin, 'example_admin_notice'));
34
+ add_action('admin_notices', array( $admin, 'new_leads'));
35
  add_action('wp_ajax_send_done', array($admin,'set_tab_done'));
36
  add_action('wp_ajax_email_section', array($admin,'email_section'));
37
  add_action('wp_ajax_get_done', array($admin,'get_tab_done'));
38
+ add_action('wp_ajax_main_notice', array($admin,'banner_off'));
39
+ add_action('wp_ajax_cg_notice', array($admin,'cg_off'));
40
  add_action('wp_ajax_set_current_tab', array($admin,'set_current_tab'));
41
  add_action('wp_ajax_create_subscribe', array($api,'create_subscribe'));
42
  add_action('wp_ajax_cancel_subscribe', array($api,'cancel_subscribe'));
43
  add_action('wp_ajax_csv', array($api,'csv'));
44
+ add_action('wp_ajax_notice', array($admin,'notice_off'));
45
 
46
 
47
 
admin/assets/css/admin-styles.css CHANGED
@@ -369,6 +369,7 @@ span.free{
369
  background-size: contain;
370
  height: 70px;
371
  max-width: 330px;
 
372
  }
373
 
374
  .options-subtitle {
@@ -497,7 +498,9 @@ body .toc-tab-box .button {
497
  .form-table{
498
  position: relative;
499
  }
500
-
 
 
501
  .mm_only_block h6 {
502
  line-height: 1.6rem;
503
  margin: 0 0 20px 0;
@@ -917,9 +920,9 @@ p.submit{
917
  align-items: center;
918
  top: -4px;
919
  width: 100%;
920
- height: 64px;
921
  padding: 0 1em;
922
- left: -15px;
923
  }
924
 
925
  .customization_button__wrapper .customization_button__link, .pro_button__wrapper .pro_button__link {
@@ -992,6 +995,7 @@ p.submit{
992
  font-size: 22px;
993
  font-weight: bold;
994
  line-height: 30px;
 
995
  }
996
 
997
  .customization_button__wrapper .customization_button__action, .pro_button__wrapper .pro_button__action{
@@ -1672,7 +1676,7 @@ p.submit{
1672
  }
1673
  .contact_head__wrap .download__wrap{
1674
  position: relative;
1675
- width: 60%;
1676
  height: 100%;
1677
  text-align: right;
1678
  }
@@ -1681,7 +1685,7 @@ p.submit{
1681
  align-items: center;
1682
  top: -35px;
1683
  width: 100%;
1684
- height: 73px;
1685
  left: 0;
1686
  position: absolute;
1687
  bottom: 0;
@@ -1874,7 +1878,10 @@ p.submit{
1874
  .mobilemonkey-settings p{
1875
  margin-top: 15px;
1876
  }
1877
- .tab-content .as_state .as_text{
 
 
 
1878
  font-size: 22px;
1879
  font-weight: 800;
1880
  line-height: 30px;
@@ -2650,6 +2657,14 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2650
  .tab-content .form-table td .tooltip.qa{
2651
  top: 113px;
2652
  }
 
 
 
 
 
 
 
 
2653
  .have_qa a{
2654
  display: block;
2655
  padding: 20px;
@@ -2727,12 +2742,13 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2727
  justify-content: center;
2728
  }
2729
  .tab-content .email__wrap input[type=text]:not(.browser-default){
2730
- width: 50%;
2731
  height: 32px;
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;
@@ -2771,7 +2787,12 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2771
  .as_item__wrap{
2772
  align-items: center;
2773
  display: flex;
 
 
 
 
2774
  }
 
2775
  .del_as{
2776
  margin-left: 20px;
2777
  width: 25px;
@@ -2782,7 +2803,8 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2782
  text-align: center;
2783
  line-height: 25px;
2784
  border-radius: 50%;
2785
- position: relative;
 
2786
  cursor: pointer;
2787
  }
2788
  .add_as{
@@ -2828,6 +2850,7 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2828
  top: 10px;
2829
  color: #0e71ff;
2830
  font-size: 20px;
 
2831
  }
2832
  .main-qa h6{
2833
  font-size: 14px;
@@ -2978,4 +3001,8 @@ span.qa-question-result {
2978
  justify-content: center;
2979
  cursor: pointer;
2980
  word-break: break-all;
 
 
 
 
2981
  }
369
  background-size: contain;
370
  height: 70px;
371
  max-width: 330px;
372
+ position: relative;
373
  }
374
 
375
  .options-subtitle {
498
  .form-table{
499
  position: relative;
500
  }
501
+ .mm_only_block{
502
+ margin-top: 20px;
503
+ }
504
  .mm_only_block h6 {
505
  line-height: 1.6rem;
506
  margin: 0 0 20px 0;
920
  align-items: center;
921
  top: -4px;
922
  width: 100%;
923
+ /* height: 64px;*/
924
  padding: 0 1em;
925
+ left: 0;
926
  }
927
 
928
  .customization_button__wrapper .customization_button__link, .pro_button__wrapper .pro_button__link {
995
  font-size: 22px;
996
  font-weight: bold;
997
  line-height: 30px;
998
+ justify-content: center;
999
  }
1000
 
1001
  .customization_button__wrapper .customization_button__action, .pro_button__wrapper .pro_button__action{
1676
  }
1677
  .contact_head__wrap .download__wrap{
1678
  position: relative;
1679
+ width: 71%;
1680
  height: 100%;
1681
  text-align: right;
1682
  }
1685
  align-items: center;
1686
  top: -35px;
1687
  width: 100%;
1688
+ height: 100px;
1689
  left: 0;
1690
  position: absolute;
1691
  bottom: 0;
1878
  .mobilemonkey-settings p{
1879
  margin-top: 15px;
1880
  }
1881
+ .tab-content .form-table td .welcome_text{
1882
+ margin: 5px 10px 20px 0;
1883
+ }
1884
+ .tab-content .form-table td .head_text{
1885
  font-size: 22px;
1886
  font-weight: 800;
1887
  line-height: 30px;
2657
  .tab-content .form-table td .tooltip.qa{
2658
  top: 113px;
2659
  }
2660
+ .tab-content .form-table td .tooltip.lq{
2661
+ top: 5%;
2662
+ left: 100%;
2663
+ }
2664
+ .tab-content .form-table td .tooltip.lq_answer{
2665
+ right: 0;
2666
+ top: 25px;
2667
+ }
2668
  .have_qa a{
2669
  display: block;
2670
  padding: 20px;
2742
  justify-content: center;
2743
  }
2744
  .tab-content .email__wrap input[type=text]:not(.browser-default){
2745
+ width: 40%;
2746
  height: 32px;
2747
  font-size: 14px;
2748
  }
2749
 
2750
  .add_question, .add_qa{
2751
+ user-select: none;
2752
  color: #324EF8;
2753
  box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2754
  padding: 10px 30px;
2787
  .as_item__wrap{
2788
  align-items: center;
2789
  display: flex;
2790
+ position: relative;
2791
+ }
2792
+ .wrap__pro input[type=text]:not(.browser-default){
2793
+ width: 50%;
2794
  }
2795
+
2796
  .del_as{
2797
  margin-left: 20px;
2798
  width: 25px;
2803
  text-align: center;
2804
  line-height: 25px;
2805
  border-radius: 50%;
2806
+ position: absolute;
2807
+ right: -40px;
2808
  cursor: pointer;
2809
  }
2810
  .add_as{
2850
  top: 10px;
2851
  color: #0e71ff;
2852
  font-size: 20px;
2853
+ cursor: pointer;
2854
  }
2855
  .main-qa h6{
2856
  font-size: 14px;
3001
  justify-content: center;
3002
  cursor: pointer;
3003
  word-break: break-all;
3004
+ }
3005
+ .disabled{
3006
+ pointer-events: none;
3007
+ opacity: 0.6;
3008
  }
admin/assets/img/phone.png ADDED
Binary file
admin/assets/js/admin.js CHANGED
@@ -706,9 +706,11 @@ jQuery(document).ready(function($){
706
  }
707
  link.addClass('done');
708
  $(".step-wrapper ul li.tab-link").each(function () {
709
- var index = $(this).attr("data-tab");
710
  if ($(this).hasClass('done')) {
711
  flag[index] = true;
 
 
712
  }
713
  });
714
 
@@ -731,7 +733,7 @@ jQuery(document).ready(function($){
731
  set_current_tab(next.attr('data-tab'));
732
  next.addClass('done');
733
  $(".step-wrapper ul li.tab-link").each(function () {
734
- var index = $(this).attr("data-tab");
735
  if ($(this).hasClass('done')) {
736
  flag[index] = true;
737
  }
@@ -754,25 +756,50 @@ jQuery(document).ready(function($){
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();
778
  if (next.attr('data-tab')!=='tab-3'){
@@ -786,7 +813,6 @@ jQuery(document).ready(function($){
786
  var cur = $(".step-wrapper ul li.tab-link.current");
787
  send_next(cur);
788
  }
789
-
790
  }
791
  });
792
 
@@ -841,17 +867,27 @@ jQuery(document).ready(function($){
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
  );
@@ -897,6 +933,26 @@ jQuery(document).ready(function($){
897
  }
898
 
899
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
900
  $('.button_cancel').on('click',function (e) {
901
  e.preventDefault();
902
  $('#cancel').show();
@@ -931,8 +987,7 @@ jQuery(document).ready(function($){
931
  let wit = current/max*$('.percentage-bar__bar').width()+'px';
932
  $('.percentage-bar__used-percentage').css({'width':wit})
933
 
934
-
935
- $('.pro_button__link,#button_update').on('click',function (e) {
936
  e.preventDefault();
937
  $('#pro_option').show();
938
  $('#modal-overlay').show();
@@ -1007,7 +1062,7 @@ jQuery(document).ready(function($){
1007
  },
1008
  dataType: 'json',
1009
  error: function (data,response) {
1010
- $('#errors').stop( true, false ).fadeIn( "fast" )
1011
  $('#pay_plan').removeClass('opacity-button');
1012
  $("#pay_plan").attr("disabled", false);
1013
  $('#pay_plan div.lazyload').css('display', 'none');
@@ -1062,7 +1117,32 @@ jQuery(document).ready(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");
@@ -1129,10 +1209,25 @@ jQuery(document).ready(function($){
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'});
@@ -1140,6 +1235,10 @@ jQuery(document).ready(function($){
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
  }
@@ -1147,6 +1246,10 @@ jQuery(document).ready(function($){
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();
@@ -1262,6 +1365,9 @@ jQuery(document).ready(function($){
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 {
@@ -1331,17 +1437,27 @@ jQuery(document).ready(function($){
1331
  event.preventDefault();
1332
  var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1333
  var answerValue = $(this).parents(".main-question").find("#answer-state").val();
1334
- var dataIndex = $(this).parents(".main-question").find("#answer-state").attr("data-index");
1335
- var answerQualified = 0;
1336
- if($(this).parents(".main-question").find("#qualified").is(':checked')){
1337
- answerQualified = 1;
 
 
 
 
1338
  }else {
1339
- answerQualified = 0;
 
 
 
 
 
 
 
 
 
 
1340
  }
1341
- $(this).parents(".main-question").find("#qualified_answer_"+mainId+"_"+dataIndex).val(answerQualified);
1342
- $("#htcc-answer_"+mainId+"_"+dataIndex).val(answerValue);
1343
- $(this).parents(".main-question").find(".answer-input__wrapper").hide();
1344
- $(this).parents(".main-question").find(".answer__result[data-index='"+dataIndex+"']").text(answerValue);
1345
  });
1346
 
1347
  $(document).on("click", ".question_submit", function() {
706
  }
707
  link.addClass('done');
708
  $(".step-wrapper ul li.tab-link").each(function () {
709
+ var index = $(this).attr("data-tab").replace(/[^0-9]/gi, '');
710
  if ($(this).hasClass('done')) {
711
  flag[index] = true;
712
+ }else {
713
+ flag[index] = false;
714
  }
715
  });
716
 
733
  set_current_tab(next.attr('data-tab'));
734
  next.addClass('done');
735
  $(".step-wrapper ul li.tab-link").each(function () {
736
+ var index = $(this).attr("data-tab").replace(/[^0-9]/gi, '');
737
  if ($(this).hasClass('done')) {
738
  flag[index] = true;
739
  }
756
 
757
  let scroll = false;
758
  $('.main-qa').each(function () {
759
+ 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){
760
  $('<p class="tooltip qa"></p>')
761
  .text(" At least 1 keyword and 1 answer is required for each Q&A")
762
  .appendTo($(this).find('.qa-response'))
763
  .fadeIn('fast');
764
+ $(this).find('.qa-response').find(".tooltip").delay(2000).fadeOut(300, function(){ $(this).remove();});
765
  scroll = $(this).find('.qa-response');
766
  }
767
  });
768
+ $('.main-question').each(function () {
769
+ if ($(this).find('.question-input__item').find('input').val() == '' || $(this).find('.question-input__item').find('input').val().replace(/\s/g, '').length < 1) {
770
+ $('<p class="tooltip lq"></p>')
771
+ .text("The question cannot be empty")
772
+ .appendTo($(this).find('.question-input__wrapper'))
773
+ .fadeIn('fast');
774
+ $(this).find('.question-input__wrapper').find(".tooltip").delay(2000).fadeOut(300, function(){ $(this).remove();});
775
+ scroll = $(this).find('.question-input__wrapper');
776
+ }
777
+ });
778
+
779
  if (scroll){
780
  $([document.documentElement, document.body]).animate({
781
  scrollTop: scroll.offset().top-250
782
  }, 1000);
783
  return false;
784
  }else{
785
+ if (!save_from_form){
786
+ var next = $(".step-wrapper ul li.tab-link.current").next();
787
+ if (next.attr('data-tab')!=='tab-3'){
788
+ var second_next = next.next();
789
+ }
790
+ if (!next.hasClass('done')){
791
+ send_next(next)
792
+ }else if (second_next && !second_next.hasClass('done')){
793
+ send_next(second_next)
794
+ }else {
795
+ var cur = $(".step-wrapper ul li.tab-link.current");
796
+ send_next(cur);
797
+ }
798
+ }
799
  return true;
800
  }
801
  });
802
+ $(document).on("click", "#tab-2 #submit,#tab-3 #submit", function() {
803
  if (!save_from_form){
804
  var next = $(".step-wrapper ul li.tab-link.current").next();
805
  if (next.attr('data-tab')!=='tab-3'){
813
  var cur = $(".step-wrapper ul li.tab-link.current");
814
  send_next(cur);
815
  }
 
816
  }
817
  });
818
 
867
  function (event) {
868
  event.preventDefault();
869
  let page = $('.connected-page');
870
+ let have_qa = $(this).siblings('.have_qa');
871
  if (!page.hasClass('pro')&&$('.main-qa').length!==0){
872
  $(this).find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
873
  $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
874
+ }else
875
+ if (!page.hasClass('pro')&&have_qa.length>0) {
876
+ $(this).find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
877
+ $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
878
  }
879
  },
880
  function (event) {
881
  event.preventDefault();
882
  let page = $('.connected-page');
883
+ let have_qa = $(this).siblings('.have_qa');
884
  if (!page.hasClass('pro')&&$('.main-qa').length!==0){
885
  $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
886
  $(this).find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
887
+ }else
888
+ if (!page.hasClass('pro')&&have_qa.length>0) {
889
+ $(this).find('.add_qa').css({'pointer-events':'none','opacity':'0.6'});
890
+ $(this).find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
891
  }
892
  }
893
  );
933
  }
934
 
935
  );
936
+ $('.new_leads').on('click',function (e) {
937
+ set_current_tab('tab-1');
938
+ });
939
+
940
+ $('.dismiss_but').on('click',function (e) {
941
+ $.ajax({
942
+ type: 'POST',
943
+ url: ajaxurl,
944
+ data: {
945
+ action: 'notice'
946
+ },
947
+ dataType: 'json',
948
+ success: function (data,response) {
949
+ $('.dismiss_but').parents('.main_notice__wrap').fadeOut(300, function(){ $(this).remove();});;
950
+
951
+ }
952
+ });
953
+ });
954
+
955
+
956
  $('.button_cancel').on('click',function (e) {
957
  e.preventDefault();
958
  $('#cancel').show();
987
  let wit = current/max*$('.percentage-bar__bar').width()+'px';
988
  $('.percentage-bar__used-percentage').css({'width':wit})
989
 
990
+ $(document).on("click",".pro_button__link,#button_update", function(e) {
 
991
  e.preventDefault();
992
  $('#pro_option').show();
993
  $('#modal-overlay').show();
1062
  },
1063
  dataType: 'json',
1064
  error: function (data,response) {
1065
+ $('#errors').stop( true, false ).fadeIn( "fast" );
1066
  $('#pay_plan').removeClass('opacity-button');
1067
  $("#pay_plan").attr("disabled", false);
1068
  $('#pay_plan div.lazyload').css('display', 'none');
1117
  $(this).find(".tooltip").fadeOut(300, function(){ $(this).remove();});
1118
  });
1119
 
1120
+ $('.main_banner_button').on('click',function (e) {
1121
+ $.ajax({
1122
+ type: 'POST',
1123
+ url: ajaxurl,
1124
+ data: {
1125
+ action: 'main_notice'
1126
+ },
1127
+ dataType: 'json',
1128
+ success: function (data,response) {
1129
+ $('.main_banner_button').parents('.banner_main__wrap').fadeOut(300, function(){ $(this).remove();});
1130
+ }
1131
+ });
1132
+ });
1133
+ $(document).on("click",".close-guard-notify", function( event ) {
1134
+ $.ajax({
1135
+ type: 'POST',
1136
+ url: ajaxurl,
1137
+ data: {
1138
+ action: 'cg_notice'
1139
+ },
1140
+ dataType: 'json',
1141
+ success: function (data,response) {
1142
+ $('.comment-guard-notify').fadeOut(1000, function(){ $(this).remove();});
1143
+ }
1144
+ });
1145
+ });
1146
  $(document).on("click",".add_qa_question", function( event ) {
1147
  event.preventDefault();
1148
  let fieldsetId = $(this).parents(".main-qa").find(".qa-question-result").last().attr("data-index");
1209
  });
1210
  $(document).on("click", ".del_qa", function() {
1211
  let wrapper = $(this).parents('.qa_new-wrapper');
1212
+ let isempt = false;
1213
+ wrapper.find('input').each(function () {
1214
+ if ($(this).val() != ""){
1215
+ isempt = true;
1216
+ }
1217
+ });
1218
+ if (isempt == false){
1219
+ $.ajax({
1220
+ type: 'POST',
1221
+ url: ajaxurl,
1222
+ data: {
1223
+ action: 'set_pre_val',
1224
+ }
1225
+ });
1226
+ }
1227
  $(this).parents(".main-qa").prev('h3').remove();
1228
  $(this).parents(".main-qa").remove();
1229
  wrapper.find('h3').each(function (index,value) {
1230
+ let number = index+1;
1231
  $(this).text('Q&A '+number);
1232
  });
1233
  $('.add_qa').css({'pointer-events':'all','opacity':'1'});
1235
  $(".add_qa").on("click", function() {
1236
  var fieldsetId = $(".qa_new-wrapper").find(".main-qa").last().attr("id");
1237
  let page = $('.connected-page');
1238
+ let have_qa = $(this).parents('.qa-button__add').siblings('.have_qa');
1239
+ if (!page.hasClass('pro')&&have_qa.length>0){
1240
+ return;
1241
+ }
1242
  if (!page.hasClass('pro')&&$('.main-qa').length!==0){
1243
  return;
1244
  }
1246
  fieldsetId=fieldsetId.replace(/[^0-9]/gi, '');
1247
  var copyBlock = $(".qa_new-wrapper").find(".main-qa").last().clone();
1248
  var count = Number(fieldsetId) + 1;
1249
+ if (copyBlock.find(".qa-question_value").children("input").length == 0 ){
1250
+ copyBlock.find(".qa-question_value").append('<input type="hidden" name="htcc_as_options[qa_1][phrases][]" value="Q&A 1 Keyword#1" id="htcc_qa_1_1">');
1251
+ copyBlock.find(".qa-question-block").append('<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>');
1252
+ }
1253
  copyBlock.find(".qa-response").children("input").attr("id", "htcc_qa_"+count+"_answer").attr("name", "htcc_as_options[qa_"+count+"][bot_responses]").val("");
1254
  copyBlock.find(".qa-question-block-item").find(".qa-question-result").text("Q&A "+count+" Keyword#1");
1255
  copyBlock.find(".qa-question-block-item").not(':first').remove();
1365
  var count = Number(fieldsetId) + 1;
1366
  var block_as = $('.as_main__wrap').children().last().clone();
1367
  block_as.find('.fb_answer').attr('id', 'fb_answer'+count);
1368
+ if (count>3&&block_as.find('.del_as').length==0){
1369
+ block_as.append('<div class="del_as"><i class="fa fa-trash-o" aria-hidden="true"></i></div>');
1370
+ }
1371
  $(".as_main__wrap").append(block_as);
1372
  $(".answer_server").find('.fb_answer').last().attr('value', 'Question '+count);
1373
  }else {
1437
  event.preventDefault();
1438
  var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1439
  var answerValue = $(this).parents(".main-question").find("#answer-state").val();
1440
+ if (!answerValue.replace(/\s/g, '').length){
1441
+ if($(this).find('.tooltip').length==0){
1442
+ $('<p class="tooltip lq_answer"></p>')
1443
+ .text("The answer cannot be empty")
1444
+ .appendTo($(this).parents(".main-question").find('.answer-input__item'))
1445
+ .fadeIn('fast');
1446
+ }
1447
+ $(this).parents(".main-question").find('.answer-input__item').find(".tooltip").delay(2000).fadeOut(300, function(){ $(this).remove();})
1448
  }else {
1449
+ var dataIndex = $(this).parents(".main-question").find("#answer-state").attr("data-index");
1450
+ var answerQualified = 0;
1451
+ if($(this).parents(".main-question").find("#qualified").is(':checked')){
1452
+ answerQualified = 1;
1453
+ }else {
1454
+ answerQualified = 0;
1455
+ }
1456
+ $(this).parents(".main-question").find("#qualified_answer_"+mainId+"_"+dataIndex).val(answerQualified);
1457
+ $("#htcc-answer_"+mainId+"_"+dataIndex).val(answerValue);
1458
+ $(this).parents(".main-question").find(".answer-input__wrapper").hide();
1459
+ $(this).parents(".main-question").find(".answer__result[data-index='"+dataIndex+"']").text(answerValue);
1460
  }
 
 
 
 
1461
  });
1462
 
1463
  $(document).on("click", ".question_submit", function() {
admin/class-htcc-admin.php CHANGED
@@ -30,8 +30,8 @@ if (!class_exists('HTCC_Admin')) :
30
  {
31
  $this->api = new MobileMonkeyApi();
32
  $this->token = $this->api->connectMobileMonkey();
33
- $this->options = get_option('htcc_options');
34
- $this->fb_page_id = $this->options['fb_page_id'];
35
  $this->botid = $this->api->getActiveBotId();
36
  $this->internal = $this->api->getActivePage();
37
  $this->stepdis = "close";
@@ -126,8 +126,38 @@ if (!class_exists('HTCC_Admin')) :
126
 
127
  }
128
  public function example_admin_notice() {
 
129
  if (!$this->fb_page_id || !$this->token || !$this->internal){
130
- HT_CC::view('ht-cc-admin-notice-not-connected');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  }
132
  }
133
  /**
@@ -152,45 +182,50 @@ if (!class_exists('HTCC_Admin')) :
152
 
153
  public function get_tab_done(){
154
  $response= array('done'=>true);
155
- if (isset($_SESSION['tab'])){
156
- $response = array(
157
- 'tab-1' => isset($_SESSION['tab']['tab1'])?$_SESSION['tab']['tab1']:true,
158
- 'tab-2' => isset($_SESSION['tab']['tab2'])?$_SESSION['tab']['tab2']:false,
159
- 'tab-3' => isset($_SESSION['tab']['tab3'])?$_SESSION['tab']['tab3']:false,
160
- );
161
- }
162
  wp_send_json_success ($response);
163
  }
164
 
165
- public function set_tab_done(){
166
- $data = $_GET;
 
 
 
 
 
 
 
167
  $response= array('done'=>true);
168
- if (isset($data['state'])){
169
- $renameMap = [
170
- 'tab-1' => 'tab1',
171
- 'tab-2' => 'tab2',
172
- 'tab-3' => 'tab3'
173
- ];
174
- $data['state'] = array_combine(array_map(function($el) use ($renameMap) {
175
- return $renameMap[$el];
176
- }, array_keys($data['state'])), array_values($data['state']));
177
- $_SESSION['tab'] = array_merge($_SESSION['tab'],$data['state']);
178
- $response = array(
179
- 'success' => true,
180
- 'tab-1' => isset($_SESSION['tab']['tab1'])?$_SESSION['tab']['tab1']:true,
181
- 'tab-2' => isset($_SESSION['tab']['tab2'])?$_SESSION['tab']['tab2']:false,
182
- 'tab-3' => isset($_SESSION['tab']['tab3'])?$_SESSION['tab']['tab3']:false,
183
- );
184
- }
185
  wp_send_json_success ( $response);
186
  }
187
 
188
  public function set_current_tab(){
189
- $data = $_POST;
190
- $_SESSION['current'] = $data['current'];
191
  wp_send_json_success ();
192
  }
193
 
 
 
 
 
 
 
 
 
 
 
 
 
 
194
  /**
195
  * Options page - Regsiter, add section and add setting fields
196
  *
@@ -204,7 +239,7 @@ if (!class_exists('HTCC_Admin')) :
204
 
205
  add_settings_section('htcc_settings_as', '', array($this, 'htcc_section_as_render'), 'htcc-as-setting-section');
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');
@@ -290,11 +325,16 @@ if (!class_exists('HTCC_Admin')) :
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']){?>
@@ -303,46 +343,46 @@ if (!class_exists('HTCC_Admin')) :
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='';
311
- $i=1;
312
- $this->email_block = false;
313
- foreach ($htcc_as_options as $key=>$value){
314
- $span='';
315
- $inp='';
316
- $y=1;
317
- if (strpos($key, 'lq_')!==false){
318
- $this->email_block = true;
319
- $html.= '<div class="main-question" id="main_question_'.$i.'"><h3>QUESTION '.$i.'</h3><div class="question-block__wrapper"><div class="question-block__header"><div class="header__close"></div></div><div class="question-block_content">';
320
- foreach ($value as $k=>$v){
321
- if ($k=='question'){
322
- $html.= ' <div class="question-input__wrapper">
323
- <div class="edit"><i class="fa fa-pencil" aria-hidden="true"></i></div><div class="question-input__item"><input id="htcc-q'.$i.'" name="htcc_as_options[lq_'.$i.'][question]" value="'.$htcc_as_options['lq_'.$i.'']['question'].'" type="text"></div>
 
324
  <div class="question-input__state">
325
  <span class="question_cancel">Cancel</span><span class="question_submit">OK</span>
326
  </div>
327
  </div>';
328
- }else{
329
- $span.= '<div class="answer-item__result"><span class="answer__result" data-index="'.$y.'">'.$htcc_as_options['lq_'.$i.'']['answers'.$y.'']['answer'].'</span><div class="edit_answer" data-index="'.$y.'"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="answer__bin" data-index="'.$y.'"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div>';
330
- $inp.= '<input id="htcc-answer_'.$i.'_'.$y.'" name="htcc_as_options[lq_'.$i.'][answers'.$y.'][answer]" value="'.$htcc_as_options['lq_'.$i.'']['answers'.$y]['answer'].'" type="hidden">';
331
- $val = isset($htcc_as_options['lq_'.$i]['answers'.$y]['qualified']) ? 1 : 0;
332
- $inp.= '<input id="qualified_answer_'.$i.'_'.$y.'" name="htcc_as_options[lq_'.$i.'][answers'.$y.'][qualified]" value="'.$val.'" type="hidden">';
333
- $y++;
334
- }
335
 
336
- }
337
- $i++;
338
- $html.='<div class="answer-input__block">
339
  <div class="answer-input__button">
340
- '.$span.'
341
  </div>
342
  <div class="answer-input__add">
343
  <span class="add__answer" data-index="1"><b>+</b> Add answer</span>
344
  </div>
345
- <div class="answer-input__value">'.$inp.'</div>
346
  <div class="answer-input__wrapper">
347
  <span class="triangle"></span>
348
  <div class="answer-input__item">
@@ -357,22 +397,23 @@ if (!class_exists('HTCC_Admin')) :
357
  </div>
358
  </div>
359
  </div>';
360
- $html.= '</div>';
 
361
  }
362
- }
363
 
364
- ?>
365
- <div class="input-field col s12 questions-wrapper">
366
- <h3><?php _e('Lead Qualifier', 'wp-chatbot') ?></h3>
367
- <p class="qual_p"><?php _e('Add a lead qualifying questions with multiple choice answers, and we`ll notify you as soon as qualified lead is detected', 'wp-chatbot') ?></p>
368
- <div class="question_new-wrapper">
369
- <?php echo $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
  }
377
 
378
  // color - next new version added ..
@@ -426,181 +467,220 @@ if (!class_exists('HTCC_Admin')) :
426
  $htcc_fb_welcome_message = get_option('htcc_as_options');
427
  $ref = get_option('htcc_fb_ref');
428
  $htcc_fb_app_id = get_option('mobilemonkey_environment');
429
- ?>
430
- <div class="row">
431
- <div class="test_button__wrap">
432
- <div class="test-bot-button" style="display: <?php echo $this->test; ?>">
433
- <div class="test-bot-button__button-wrapper">
434
- <div class="test-bot-button__messenger">
435
- <div class="fb-send-to-messenger"
436
- messenger_app_id="<?php echo $htcc_fb_app_id->fb_app_id; ?>"
437
- page_id="<?php echo $this->fb_page_id; ?>"
438
- data-ref="<?php echo $ref;?>"
439
- color="blue"
440
- size="large">
 
 
 
441
  </div>
442
  </div>
443
  </div>
 
 
 
 
 
 
 
 
444
  </div>
445
- <a target="_blank" rel="noopener noreferrer" style="display: none" href="https://www.m.me/<?php echo $this->fb_page_id?>" id="messanger" class="button testchat">Open Messenger</a>
446
- </div>
447
- <div class="input-field col s12">
448
- <label for="fb_welcome_message"><?php _e('Welcome message - WP-Chatbot will greet your chat users with this message.', 'wp-chatbot') ?></label>
449
- <textarea rows="2" style="width:100%" name="htcc_as_options[fb_welcome_message]" id="fb_welcome_message"> <?php echo esc_attr($htcc_fb_welcome_message['fb_welcome_message'])?></textarea>
450
  </div>
451
- </div>
452
- <?php
453
  }
454
  public function htcc_fb_as_state_cb()
455
  {
456
  $htcc_fb_as_state = get_option('htcc_as_options');
457
- ?>
458
- <div class="row">
459
- <div class="input-field as_state col s12">
460
- <p class="as_text"><?php _e('Answering Service', 'wp-chatbot') ?></p>
461
- <div class="switch__wrap">
462
- <label class="switch">
463
- <input id="htcc_fb_as_state" name="htcc_as_options[fb_as_state]" type="checkbox" value="1" <?php isset($htcc_fb_as_state['fb_as_state']) ? checked($htcc_fb_as_state['fb_as_state'], 1) : checked(0); ?>/>
464
- <span class="slider round"></span>
465
- </label>
 
 
 
 
 
 
 
 
 
 
 
466
  </div>
467
  </div>
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
497
  }
498
  public function email_section(){
499
  $htcc_fb_email_trans = get_option('htcc_as_options');
500
- $html='';
501
- $email = isset($htcc_fb_email_trans['email'])?$htcc_fb_email_trans['email']:'';
502
- $state = json_decode($_GET['has_lq']);
503
- if(isset($state)&&!$state){
504
- $html.='<div class="input-field col l12 m12"><h3>Email to send transcripts to<span class="pro">PRO</span></h3>';
505
- $html.='<label class="gray" for="htcc_fb_email_trans">When people answer all of the questions below, we can send the answers to an email address of your choice!</label>';
506
- $html.='<div class="wrap__pro"><input type="text" name="htcc_as_options[email]" id="email" value='.$email.'><div class="pro_button__wrapper" style="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></div></div>';
507
- }else{
508
- $html.='<div class="input-field col l12 m12"><p class="notify_mode">Notify me when a user sends a qualifying answer<span class="pro">PRO</span></p>';
509
- $html.='<div class="wrap__pro email_block">';
510
- $html.='<div class="notify__wrap">';
511
- $html.='<div class="notify_radio__wrap">';
512
- $all = $htcc_fb_email_trans['notify_mode']=='all' ? "checked" : '';
513
- $html.='<input id="htcc_as_options[notify_mode]_1" name="htcc_as_options[notify_mode]" type="radio" value="all" '.$all.'/>';
514
- $html.='<label for="htcc_as_options[notify_mode]_1">For all lead qualifiers</label>';
515
- $html.='</div>';
516
- $html.='<div class="notify_radio__wrap">';
517
- $any = $htcc_fb_email_trans['notify_mode']=='any' ? "checked" : '';
518
- $html.='<input id="htcc_as_options[notify_mode]_2" name="htcc_as_options[notify_mode]" type="radio" value="any" '.$any.'/>';
519
- $html.='<label for="htcc_as_options[notify_mode]_2">For at least one lead qualifier</label>';
520
- $html.='</div>';
521
- $html.='</div>';
522
- $html.='<div class="email__wrap"><label for="email">My email</label><input type="text" name="htcc_as_options[email]" id="email" value="'.$email.'"></div><div class="pro_button__wrapper" style="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></div>';
 
 
 
523
  }
524
- wp_send_json_success($html);
525
  }
526
  public function htcc_fb_email_trans_cb()
527
  {
528
  $htcc_fb_email_trans = get_option('htcc_as_options');
529
- ?>
530
- <div class="row as pro" id="email_test">
531
- <div class="input-field col l12 m12">
532
- <?php if(!$this->email_block){ ?>
533
- <?php _e('<h3>Email to send transcripts to<span class="pro">PRO</span></h3>') ?>
534
- <label class="gray" for="htcc_fb_email_trans"><?php _e('When people answer all of the questions below, we can send the answers to an email address of your choice!', 'wp-chatbot') ?></label>
535
- <div class="wrap__pro">
536
- <input type="text" name="htcc_as_options[email]" id="email"
537
- value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
538
- <div class="pro_button__wrapper" style="display: none">
539
- <a href="#" class="pro_button__link">
540
- <div class="pro_button">
541
- <div class="pro_button__content">
542
- <p><?php _e('Upgrade to unlock this feature') ?></p>
543
- <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
544
- </div>
545
- <div class="pro_button__action">
546
- <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
 
 
 
547
  </div>
548
- </div>
549
- </a>
550
  </div>
551
- </div>
552
 
553
- <?php }else{ ?>
554
- <?php _e('<p class="notify_mode">Notify me when a user sends a qualifying answer<span class="pro">PRO</span></p>') ?>
555
- <div class="wrap__pro email_block">
556
- <div class="notify__wrap">
557
- <div class="notify_radio__wrap">
558
- <input id="htcc_as_options[notify_mode]_1" name="htcc_as_options[notify_mode]" type="radio" value="all" <?php $htcc_fb_email_trans['notify_mode']=='all' ? checked(1) : checked(0); ?>/>
559
- <label for="htcc_as_options[notify_mode]_1"><?php _e('For all lead qualifiers') ?></label>
 
 
 
 
 
 
 
 
 
560
  </div>
561
- <div class="notify_radio__wrap">
562
- <input id="htcc_as_options[notify_mode]_2" name="htcc_as_options[notify_mode]" type="radio" value="any" <?php $htcc_fb_email_trans['notify_mode']=='any' ? checked(1) : checked(0); ?>/>
563
- <label for="htcc_as_options[notify_mode]_2"><?php _e('For at least one lead qualifier') ?></label>
 
564
  </div>
565
- </div>
566
- <div class="email__wrap">
567
- <label for="email"><?php _e('My email') ?></label>
568
- <input type="text" name="htcc_as_options[email]" id="email" value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
569
- </div>
570
- <div class="pro_button__wrapper" style="display: none">
571
- <a href="#" class="pro_button__link">
572
- <div class="pro_button">
573
- <div class="pro_button__content">
574
- <p><?php _e('Upgrade to unlock this feature') ?></p>
575
- <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
576
  </div>
577
- <div class="pro_button__action">
578
- <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
579
- </div>
580
- </div>
581
- </a>
582
  </div>
583
- </div>
584
- <?php } ?>
585
  </div>
586
- </div>
587
 
588
- <?php
 
589
  }
590
 
591
  public function htcc_fb_thank_answer_cb()
592
  {
593
  $htcc_fb_thank_answer = get_option('htcc_as_options');
594
- ?>
595
- <div class="row as">
596
- <div class="input-field col l12 m12">
597
- <h3><?php _e('Thank you Message') ?></h3>
598
- <label class="gray" for="fb_answer1"><?php _e('Thank your users for answering your questions, and let them know you\'ll get back to them.', 'wp-chatbot') ?></label>
599
- <input type="text" name="htcc_as_options[thank_message]" id="thank_message"
600
- value="<?php echo esc_attr($htcc_fb_thank_answer['thank_message']) ?>">
 
 
 
601
  </div>
602
- </div>
603
- <?php
604
  }
605
 
606
 
@@ -1096,10 +1176,11 @@ if (!class_exists('HTCC_Admin')) :
1096
 
1097
  $new_input = array();
1098
  if(isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1099
- $_SESSION['tab-2'] = true;
 
 
1100
  }
1101
  foreach ($input as $key => $value) {
1102
-
1103
  if($key == 'fb_greeting_dialog_delay'&& isset($_REQUEST['action']) && $_REQUEST['action']== 'update'){
1104
  if (strlen($value) > 9){
1105
  $new_input[$key] = $option[$key];
@@ -1131,50 +1212,75 @@ if (!class_exists('HTCC_Admin')) :
1131
  $error_welcome=false;
1132
  $error_email=false;
1133
  $option = get_option('htcc_as_options');
1134
-
1135
-
1136
  if (!current_user_can('manage_options')) {
1137
  wp_die('not allowed to modify - please contact admin ');
1138
  }
1139
  if ($input){
1140
- $new_input = array();
1141
- if(isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1142
- $_SESSION['tab1'] = true;
1143
- }
1144
- foreach ($input as $key => $value) {
1145
- if ($key == 'fb_welcome_message' && isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1146
- if ($value == '' || ctype_space($value)) {
1147
- $new_input[$key] = $option[$key];
1148
- $error_welcome = true;
1149
- } else {
1150
- $_SESSION['tab1'] = true;
1151
- $new_input[$key] = sanitize_text_field($input[$key]);
1152
- }
1153
- }
1154
- if ($value == '' || ctype_space($value)){
1155
- if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'update' && !$this->getApi()->mmOnlyCheck($this->fb_page_id)){
1156
- if($key == 'email'&&!$this->api->getCurrentSubscription()){
1157
- $new_input[$key] = '';
1158
- }else{
1159
  $new_input[$key] = $option[$key];
1160
- $error = true;
 
 
 
 
 
1161
  }
1162
- }
1163
- }elseif (isset($input[$key])) {
1164
- if ($key == 'email' && !is_email($value)){
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]);
1172
- }
1173
- }
1174
- }
1175
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1176
 
1177
  }
 
 
1178
  if ($error_welcome){
1179
  $this->api->settingSaveError("welcome_message");
1180
  }
@@ -1182,6 +1288,7 @@ if (!class_exists('HTCC_Admin')) :
1182
  $this->api->settingSaveError("AS");
1183
  }
1184
  if ($error_email){
 
1185
  $this->api->settingSaveError("email");
1186
  }
1187
  return $new_input;
30
  {
31
  $this->api = new MobileMonkeyApi();
32
  $this->token = $this->api->connectMobileMonkey();
33
+ $this->options_as = get_option('htcc_as_options');
34
+ $this->fb_page_id = $this->api->getActiveRemotePageId();
35
  $this->botid = $this->api->getActiveBotId();
36
  $this->internal = $this->api->getActivePage();
37
  $this->stepdis = "close";
126
 
127
  }
128
  public function example_admin_notice() {
129
+ $delay = get_transient( 'banner_notice_off' );
130
  if (!$this->fb_page_id || !$this->token || !$this->internal){
131
+ if ($delay!=true){
132
+ HT_CC::view('ht-cc-admin-notice-not-connected');
133
+ }
134
+ }
135
+ }
136
+ public function new_leads() {
137
+ if ($this->fb_page_id && $this->token && $this->internal){
138
+ $notice = get_transient( 'notice_off' );
139
+ $contacts = $this->api->getContacts();
140
+ $count = 0;
141
+ if (isset($contacts)){
142
+ foreach ($contacts as $contact){
143
+ $date = new DateTime();
144
+ $match_date = new DateTime($contact->created_at);
145
+ $interval = $match_date->diff($date);
146
+ $day = $interval->format('%r%a');
147
+ if ($day<=3&&$day>=0){
148
+ $count +=1;
149
+ }
150
+ }
151
+
152
+ }
153
+ if ($count>=2&&!$this->options_as['email']){
154
+ if ($notice != true ){
155
+ $leads_info = [
156
+ 'leads_count'=> $count
157
+ ];
158
+ HT_CC::view('ht-cc-admin-new-leads',$leads_info);
159
+ }
160
+ }
161
  }
162
  }
163
  /**
182
 
183
  public function get_tab_done(){
184
  $response= array('done'=>true);
185
+ $tab = get_transient( 'done-tab' );
186
+ $response = $tab;
 
 
 
 
 
187
  wp_send_json_success ($response);
188
  }
189
 
190
+ public function notice_off()
191
+ {
192
+ $response= array('done'=>true);
193
+ set_transient( 'notice_off', true, WEEK_IN_SECONDS*2);
194
+ wp_send_json_success ($response);
195
+ }
196
+
197
+ public function pre_val(){
198
+ set_transient( 'pre_value', false, YEAR_IN_SECONDS );
199
  $response= array('done'=>true);
200
+ wp_send_json_success ($response);
201
+ }
202
+
203
+ public function set_tab_done(){
204
+ $tab = get_transient( 'done-tab' );
205
+ $resp_tab = $_GET['state']+$tab;
206
+ $response = $resp_tab;
207
+ set_transient( 'done-tab', $resp_tab, YEAR_IN_SECONDS );
 
 
 
 
 
 
 
 
 
208
  wp_send_json_success ( $response);
209
  }
210
 
211
  public function set_current_tab(){
212
+ set_transient( 'current-tab', preg_replace('/[^0-9]/', '', $_POST['current']),YEAR_IN_SECONDS );
 
213
  wp_send_json_success ();
214
  }
215
 
216
+ public function banner_off(){
217
+ $response= array('done'=>true);
218
+ set_transient( 'banner_notice_off', true, WEEK_IN_SECONDS*2);
219
+ wp_send_json_success ($response);
220
+ }
221
+
222
+ public function cg_off(){
223
+ $response= array('done'=>true);
224
+ set_transient( 'cg_notice_off', true, WEEK_IN_SECONDS*2);
225
+ wp_send_json_success ($response);
226
+ }
227
+
228
+
229
  /**
230
  * Options page - Regsiter, add section and add setting fields
231
  *
239
 
240
  add_settings_section('htcc_settings_as', '', array($this, 'htcc_section_as_render'), 'htcc-as-setting-section');
241
 
242
+ add_settings_field('htcc_fb_welcome_message', '', array($this, 'htcc_fb_welcome_message_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
243
  add_settings_field('htcc_fb_as_state', '', array($this, 'htcc_fb_as_state_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
244
  add_settings_field('htcc_fb_answer','', array($this, 'htcc_fb_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
245
  add_settings_field('htcc_fb_question','', array($this, 'htcc_fb_question_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
325
  <h3 class="qa_head"><?php _e('Q&A', 'wp-chatbot') ?></h3>
326
  <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>
327
  <div class="qa_new-wrapper">
328
+ <?php
329
+ if (!$htcc_as_options['advanced_triggers_present']||$this->api->getCurrentSubscription()) {
330
+ echo $html;
331
+ }
332
+ ?>
333
  </div>
334
  </div>
335
+ <?php $trigger = $htcc_as_options['advanced_triggers_present']&&!$this->api->getCurrentSubscription()? "disabled":""; ?>
336
  <div class="qa-button__add">
337
+ <span class="add_qa <?php echo $trigger?>" ><b>+</b> Add Q&A</span>
338
  <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>
339
  </div>
340
  <?php if ($htcc_as_options['advanced_triggers_present']){?>
343
  </div>
344
  <?php
345
  }
 
346
  }
347
  public function htcc_fb_question_cb(){
348
  $htcc_as_options = get_option('htcc_as_options');
349
+ if ($htcc_as_options['answering_service_mm_only_mode']==false) {
350
+ $html = '';
351
+ $i = 1;
352
+ $this->email_block = false;
353
+ foreach ($htcc_as_options as $key => $value) {
354
+ $span = '';
355
+ $inp = '';
356
+ $y = 1;
357
+ if (strpos($key, 'lq_') !== false) {
358
+ $this->email_block = true;
359
+ $html .= '<div class="main-question" id="main_question_' . $i . '"><h3>QUESTION ' . $i . '</h3><div class="question-block__wrapper"><div class="question-block__header"><div class="header__close"></div></div><div class="question-block_content">';
360
+ foreach ($value as $k => $v) {
361
+ if ($k == 'question') {
362
+ $html .= ' <div class="question-input__wrapper">
363
+ <div class="edit"><i class="fa fa-pencil" aria-hidden="true"></i></div><div class="question-input__item"><input id="htcc-q' . $i . '" name="htcc_as_options[lq_' . $i . '][question]" value="' . $htcc_as_options['lq_' . $i . '']['question'] . '" type="text"></div>
364
  <div class="question-input__state">
365
  <span class="question_cancel">Cancel</span><span class="question_submit">OK</span>
366
  </div>
367
  </div>';
368
+ } else {
369
+ $span .= '<div class="answer-item__result"><span class="answer__result" data-index="' . $y . '">' . $htcc_as_options['lq_' . $i . '']['answers' . $y . '']['answer'] . '</span><div class="edit_answer" data-index="' . $y . '"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="answer__bin" data-index="' . $y . '"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div>';
370
+ $inp .= '<input id="htcc-answer_' . $i . '_' . $y . '" name="htcc_as_options[lq_' . $i . '][answers' . $y . '][answer]" value="' . $htcc_as_options['lq_' . $i . '']['answers' . $y]['answer'] . '" type="hidden">';
371
+ $val = isset($htcc_as_options['lq_' . $i]['answers' . $y]['qualified']) ? 1 : 0;
372
+ $inp .= '<input id="qualified_answer_' . $i . '_' . $y . '" name="htcc_as_options[lq_' . $i . '][answers' . $y . '][qualified]" value="' . $val . '" type="hidden">';
373
+ $y++;
374
+ }
375
 
376
+ }
377
+ $i++;
378
+ $html .= '<div class="answer-input__block">
379
  <div class="answer-input__button">
380
+ ' . $span . '
381
  </div>
382
  <div class="answer-input__add">
383
  <span class="add__answer" data-index="1"><b>+</b> Add answer</span>
384
  </div>
385
+ <div class="answer-input__value">' . $inp . '</div>
386
  <div class="answer-input__wrapper">
387
  <span class="triangle"></span>
388
  <div class="answer-input__item">
397
  </div>
398
  </div>
399
  </div>';
400
+ $html .= '</div>';
401
+ }
402
  }
 
403
 
404
+ ?>
405
+ <div class="input-field col s12 questions-wrapper">
406
+ <h3><?php _e('Lead Qualifier', 'wp-chatbot') ?></h3>
407
+ <p class="qual_p"><?php _e('Add a lead qualifying questions with multiple choice answers, and we`ll notify you as soon as qualified lead is detected', 'wp-chatbot') ?></p>
408
+ <div class="question_new-wrapper">
409
+ <?php echo $html; ?>
410
+ </div>
411
  </div>
412
+ <div class="question-button__add">
413
+ <span class="add_question"><b>+</b> Add Question</span>
414
+ </div>
415
+ <?php
416
+ }
417
  }
418
 
419
  // color - next new version added ..
467
  $htcc_fb_welcome_message = get_option('htcc_as_options');
468
  $ref = get_option('htcc_fb_ref');
469
  $htcc_fb_app_id = get_option('mobilemonkey_environment');
470
+ if ($htcc_fb_welcome_message['answering_service_mm_only_mode']==false) {
471
+ ?>
472
+ <p class="head_text welcome_text"><?php _e('WELCOME MESSAGE', 'wp-chatbot') ?></p>
473
+ <div class="row">
474
+ <div class="test_button__wrap">
475
+ <div class="test-bot-button" style="display: <?php echo $this->test; ?>">
476
+ <div class="test-bot-button__button-wrapper">
477
+ <div class="test-bot-button__messenger">
478
+ <div class="fb-send-to-messenger"
479
+ messenger_app_id="<?php echo $htcc_fb_app_id->fb_app_id; ?>"
480
+ page_id="<?php echo $this->fb_page_id; ?>"
481
+ data-ref="<?php echo $ref; ?>"
482
+ color="blue"
483
+ size="large">
484
+ </div>
485
  </div>
486
  </div>
487
  </div>
488
+ <a target="_blank" rel="noopener noreferrer" style="display: none"
489
+ href="https://www.m.me/<?php echo $this->fb_page_id ?>" id="messanger"
490
+ class="button testchat">Open Messenger</a>
491
+ </div>
492
+ <div class="input-field col s12">
493
+ <label for="fb_welcome_message"><?php _e('Welcome message - WP-Chatbot will greet your chat users with this message.', 'wp-chatbot') ?></label>
494
+ <textarea rows="2" style="width:100%" name="htcc_as_options[fb_welcome_message]"
495
+ id="fb_welcome_message"> <?php echo esc_attr($htcc_fb_welcome_message['fb_welcome_message']) ?></textarea>
496
  </div>
 
 
 
 
 
497
  </div>
498
+ <?php
499
+ }
500
  }
501
  public function htcc_fb_as_state_cb()
502
  {
503
  $htcc_fb_as_state = get_option('htcc_as_options');
504
+
505
+ ?>
506
+ <div class="row">
507
+ <div class="input-field as_state col s12">
508
+ <p class="head_text"><?php _e('Answering Service', 'wp-chatbot') ?></p> <?php
509
+ if ($htcc_fb_as_state['answering_service_mm_only_mode']==false) { ?>
510
+ <div class="switch__wrap">
511
+ <label class="switch">
512
+ <input id="htcc_fb_as_state" name="htcc_as_options[fb_as_state]" type="checkbox"
513
+ value="1" <?php isset($htcc_fb_as_state['fb_as_state']) ? checked($htcc_fb_as_state['fb_as_state'], 1) : checked(0); ?>/>
514
+ <span class="slider round"></span>
515
+ </label>
516
+ </div>
517
+ <?php }else{ ?>
518
+ <div class="mm_only_block">
519
+ <h6><?php _e('Looks like you made changes to the Answering Service in MobileMonkey. Please go to MobileMonkey to continue editing.', 'wp-chatbot') ?></h6>
520
+ <div class="but__wrap">
521
+ <a target="_blank" rel="noopener noreferrer"
522
+ href='https://app.mobilemonkey.com/chatbot-editor/<?php echo $this->internal['bot_id'] ?>/build/'
523
+ class="go_mm"><?php _e('Go to MobileMonkey') ?></a>
524
  </div>
525
  </div>
526
+ <?php } ?>
527
+ </div>
528
+ </div>
529
+ <?php
530
+
531
  }
532
  public function htcc_fb_answer_cb()
533
  {
534
  $htcc_fb_answer = get_option('htcc_as_options');
535
+ if ($htcc_fb_answer['answering_service_mm_only_mode']==false) {
536
+ ?>
537
+ <div class="row as">
538
+ <div class="input-field col l12 m12 answer_server"> <?php
539
+ $html = '';
540
+ $i = 1;
541
+ if (isset($htcc_fb_answer['fb_answer'])){
542
+ foreach ($htcc_fb_answer['fb_answer'] as $key => $value) {
543
+
544
+ $html .= '<div class="as_item__wrap"><input type="text" id="fb_answer' . $i . '" name="htcc_as_options[fb_answer][]" class="fb_answer"
545
+ value="' . $value . '">';
546
+ $html .= $i>3 ?'<div class="del_as"><i class="fa fa-trash-o" aria-hidden="true"></i></div></div>': '</div>';
547
+ $i++;
548
+ }
549
+ }
550
+ ?>
551
+ <h3 class="qq_label"><?php _e('Quick Questions', 'wp-chatbot') ?></h3>
552
+ <label class="gray"
553
+ for="fb_answer1"><?php _e('WP-Chatbot will ask your chat users a few questions.', 'wp-chatbot') ?></label>
554
+ <div class="as_main__wrap">
555
+ <?php echo $html; ?>
556
+ </div>
557
+ </div>
558
+ <div class="add_as_button">
559
+ <span class="add_as"><b>+</b> Add Question</span>
560
  </div>
561
  </div>
562
+ <?php
563
+ }
 
 
 
564
  }
565
  public function email_section(){
566
  $htcc_fb_email_trans = get_option('htcc_as_options');
567
+ if ($htcc_fb_email_trans['answering_service_mm_only_mode']==false) {
568
+ $html = '';
569
+ $email = isset($htcc_fb_email_trans['email']) ? $htcc_fb_email_trans['email'] : '';
570
+ $state = json_decode($_GET['has_lq']);
571
+ if (isset($state) && !$state) {
572
+ $html .= '<div class="input-field col l12 m12"><h3>Email to send transcripts to<span class="pro">PRO</span></h3>';
573
+ $html .= '<label class="gray" for="htcc_fb_email_trans">When people answer all of the questions below, we can send the answers to an email address of your choice!</label>';
574
+ $html .= '<div class="wrap__pro"><input type="text" name="htcc_as_options[email]" id="email" value=' . $email . '><div class="pro_button__wrapper" style="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></div></div>';
575
+ } else {
576
+ $html .= '<div class="input-field col l12 m12"><p class="notify_mode">Notify me when a user sends a qualifying answer<span class="pro">PRO</span></p>';
577
+ $html .= '<div class="wrap__pro email_block">';
578
+ $html .= '<div class="notify__wrap">';
579
+ $html .= '<div class="notify_radio__wrap">';
580
+ $all = $htcc_fb_email_trans['notify_mode'] == 'all' ? "checked" : '';
581
+ $html .= '<input id="htcc_as_options[notify_mode]_1" name="htcc_as_options[notify_mode]" type="radio" value="all" ' . $all . '/>';
582
+ $html .= '<label for="htcc_as_options[notify_mode]_1">For all lead qualifiers</label>';
583
+ $html .= '</div>';
584
+ $html .= '<div class="notify_radio__wrap">';
585
+ $any = $htcc_fb_email_trans['notify_mode'] == 'any' ? "checked" : '';
586
+ $html .= '<input id="htcc_as_options[notify_mode]_2" name="htcc_as_options[notify_mode]" type="radio" value="any" ' . $any . '/>';
587
+ $html .= '<label for="htcc_as_options[notify_mode]_2">For at least one lead qualifier</label>';
588
+ $html .= '</div>';
589
+ $html .= '</div>';
590
+ $html .= '<div class="email__wrap"><label for="email">My email</label><input type="text" name="htcc_as_options[email]" id="email" value="' . $email . '"></div><div class="pro_button__wrapper" style="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></div>';
591
+ }
592
+ wp_send_json_success($html);
593
  }
 
594
  }
595
  public function htcc_fb_email_trans_cb()
596
  {
597
  $htcc_fb_email_trans = get_option('htcc_as_options');
598
+ if ($htcc_fb_email_trans['answering_service_mm_only_mode']==false) {
599
+ ?>
600
+ <div class="row as pro" id="email_test">
601
+ <div class="input-field col l12 m12">
602
+ <?php if (!$this->email_block) { ?>
603
+ <?php _e('<h3>Email to send transcripts to<span class="pro">PRO</span></h3>') ?>
604
+ <label class="gray"
605
+ for="htcc_fb_email_trans"><?php _e('When people answer all of the questions below, we can send the answers to an email address of your choice!', 'wp-chatbot') ?></label>
606
+ <div class="wrap__pro">
607
+ <input type="text" name="htcc_as_options[email]" id="email"
608
+ value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
609
+ <div class="pro_button__wrapper" style="display: none">
610
+ <a href="#" class="pro_button__link">
611
+ <div class="pro_button">
612
+ <div class="pro_button__content">
613
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
614
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
615
+ </div>
616
+ <div class="pro_button__action">
617
+ <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
618
+ </div>
619
  </div>
620
+ </a>
621
+ </div>
622
  </div>
 
623
 
624
+ <?php } else { ?>
625
+ <?php _e('<p class="notify_mode">Notify me when a user sends a qualifying answer<span class="pro">PRO</span></p>') ?>
626
+ <div class="wrap__pro email_block">
627
+ <div class="notify__wrap">
628
+ <div class="notify_radio__wrap">
629
+ <input id="htcc_as_options[notify_mode]_1" name="htcc_as_options[notify_mode]"
630
+ type="radio"
631
+ value="all" <?php $htcc_fb_email_trans['notify_mode'] == 'all' ? checked(1) : checked(0); ?>/>
632
+ <label for="htcc_as_options[notify_mode]_1"><?php _e('For all lead qualifiers') ?></label>
633
+ </div>
634
+ <div class="notify_radio__wrap">
635
+ <input id="htcc_as_options[notify_mode]_2" name="htcc_as_options[notify_mode]"
636
+ type="radio"
637
+ value="any" <?php $htcc_fb_email_trans['notify_mode'] == 'any' ? checked(1) : checked(0); ?>/>
638
+ <label for="htcc_as_options[notify_mode]_2"><?php _e('For at least one lead qualifier') ?></label>
639
+ </div>
640
  </div>
641
+ <div class="email__wrap">
642
+ <label for="email"><?php _e('My email') ?></label>
643
+ <input type="text" name="htcc_as_options[email]" id="email"
644
+ value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
645
  </div>
646
+ <div class="pro_button__wrapper" style="display: none">
647
+ <a href="#" class="pro_button__link">
648
+ <div class="pro_button">
649
+ <div class="pro_button__content">
650
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
651
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
652
+ </div>
653
+ <div class="pro_button__action">
654
+ <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
655
+ </div>
 
656
  </div>
657
+ </a>
658
+ </div>
 
 
 
659
  </div>
660
+ <?php } ?>
661
+ </div>
662
  </div>
 
663
 
664
+ <?php
665
+ }
666
  }
667
 
668
  public function htcc_fb_thank_answer_cb()
669
  {
670
  $htcc_fb_thank_answer = get_option('htcc_as_options');
671
+ if ($htcc_fb_thank_answer['answering_service_mm_only_mode']==false) {
672
+ ?>
673
+ <div class="row as">
674
+ <div class="input-field col l12 m12">
675
+ <h3><?php _e('Thank you Message') ?></h3>
676
+ <label class="gray"
677
+ for="fb_answer1"><?php _e('Thank your users for answering your questions, and let them know you\'ll get back to them.', 'wp-chatbot') ?></label>
678
+ <input type="text" name="htcc_as_options[thank_message]" id="thank_message"
679
+ value="<?php echo esc_attr($htcc_fb_thank_answer['thank_message']) ?>">
680
+ </div>
681
  </div>
682
+ <?php
683
+ }
684
  }
685
 
686
 
1176
 
1177
  $new_input = array();
1178
  if(isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1179
+ $tab = get_transient( 'done-tab' );
1180
+ $tab[2] = 'true';
1181
+ set_transient('done-tab',$tab,YEAR_IN_SECONDS);
1182
  }
1183
  foreach ($input as $key => $value) {
 
1184
  if($key == 'fb_greeting_dialog_delay'&& isset($_REQUEST['action']) && $_REQUEST['action']== 'update'){
1185
  if (strlen($value) > 9){
1186
  $new_input[$key] = $option[$key];
1212
  $error_welcome=false;
1213
  $error_email=false;
1214
  $option = get_option('htcc_as_options');
1215
+ $as_mm = $this->getApi()->getWidgets($this->fb_page_id);
 
1216
  if (!current_user_can('manage_options')) {
1217
  wp_die('not allowed to modify - please contact admin ');
1218
  }
1219
  if ($input){
1220
+ if (!empty($as_mm)&&$as_mm['answering_service_mm_only_mode']==false){
1221
+ $new_input = array();
1222
+ if(isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1223
+ $tab = get_transient( 'done-tab' );
1224
+ $tab[1] = 'true';
1225
+ set_transient('done-tab',$tab,YEAR_IN_SECONDS);
1226
+ }
1227
+ foreach ($input as $key => $value) {
1228
+ if ($key == 'fb_welcome_message' && isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1229
+ if ($value == '' || ctype_space($value)) {
 
 
 
 
 
 
 
 
 
1230
  $new_input[$key] = $option[$key];
1231
+ $error_welcome = true;
1232
+ } else {
1233
+ $tab = get_transient( 'done-tab' );
1234
+ $tab[1] = 'true';
1235
+ set_transient('done-tab',$tab,YEAR_IN_SECONDS);
1236
+ $new_input[$key] = sanitize_text_field($input[$key]);
1237
  }
1238
+ }
1239
+ if ($value == '' || ctype_space($value)){
1240
+ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'update'){
1241
+ if($key == 'email'){
1242
+ $new_input[$key] = '';
1243
+ }else{
1244
+ $new_input[$key] = $option[$key];
1245
+ $error = true;
1246
+ }
1247
+ }
1248
+ }elseif (isset($input[$key])) {
1249
+ if ($key == 'email' && !is_email($value)){
1250
+ $new_input[$key] = $option[$key];
1251
+ $error_email = true;
1252
+ }else {
1253
+ if (strpos($key, 'lq_')!==false||strpos($key, 'qa_')!==false || $key =='fb_answer'){
1254
+ $new_input[$key] = $value;
1255
+ }else{
1256
+ $new_input[$key] = sanitize_text_field($input[$key]);
1257
+ }
1258
+ }
1259
+ }
1260
+ }
1261
+ $new_input['answering_service_mm_only_mode'] = !empty($as_mm)?false:true;
1262
+ }else {
1263
+
1264
+ if(isset($_REQUEST['action']) && $_REQUEST['action']== 'update') {
1265
+ foreach ($input as $key => $value) {
1266
+ if (strpos($key, 'qa_')!==false) {
1267
+ $new_input[$key] = $value;
1268
+ }
1269
+ }
1270
+ }else{
1271
+ foreach ($input as $key => $value) {
1272
+ if (strpos($key, 'qa_')!==false) {
1273
+ $new_input[$key] = $value;
1274
+ }
1275
+ }
1276
+ }
1277
+ $new_input['answering_service_mm_only_mode'] = !empty($as_mm)?false:true;
1278
+
1279
+ }
1280
 
1281
  }
1282
+
1283
+ $new_input['answering_service_mm_only_mode'] = !empty($as_mm)?false:true;
1284
  if ($error_welcome){
1285
  $this->api->settingSaveError("welcome_message");
1286
  }
1288
  $this->api->settingSaveError("AS");
1289
  }
1290
  if ($error_email){
1291
+ set_transient( 'current-tab', '1',YEAR_IN_SECONDS );
1292
  $this->api->settingSaveError("email");
1293
  }
1294
  return $new_input;
admin/class-htcc-countries.php ADDED
@@ -0,0 +1,987 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Countries list for payment form
4
+ *
5
+ */
6
+
7
+ if (!defined('ABSPATH')) exit;
8
+
9
+ if (!class_exists('HTCC_Countries')) :
10
+
11
+ class HTCC_Countries
12
+ {
13
+ static $contries = array(
14
+ [
15
+ "AF",
16
+ "Afghanistan (‫افغانستان‬‎)"
17
+ ],
18
+ [
19
+ "AX",
20
+ "Åland Islands"
21
+ ],
22
+ [
23
+ "AL",
24
+ "Albania (Shqipëri)"
25
+ ],
26
+ [
27
+ "DZ",
28
+ "Algeria (‫الجزائر‬‎)"
29
+ ],
30
+ [
31
+ "AS",
32
+ "American Samoa (Amerika Sāmoa)"
33
+ ],
34
+ [
35
+ "AD",
36
+ "Andorra"
37
+ ],
38
+ [
39
+ "AO",
40
+ "Angola"
41
+ ],
42
+ [
43
+ "AI",
44
+ "Anguilla"
45
+ ],
46
+ [
47
+ "AG",
48
+ "Antigua and Barbuda"
49
+ ],
50
+ [
51
+ "AR",
52
+ "Argentina"
53
+ ],
54
+ [
55
+ "AM",
56
+ "Armenia (Հայաստան)"
57
+ ],
58
+ [
59
+ "AW",
60
+ "Aruba"
61
+ ],
62
+ [
63
+ "AU",
64
+ "Australia"
65
+ ],
66
+ [
67
+ "AT",
68
+ "Austria (Österreich)"
69
+ ],
70
+ [
71
+ "AZ",
72
+ "Azerbaijan (Azərbaycan)"
73
+ ],
74
+ [
75
+ "BS",
76
+ "Bahamas"
77
+ ],
78
+ [
79
+ "BH",
80
+ "Bahrain (‫البحرين‬‎)"
81
+ ],
82
+ [
83
+ "BD",
84
+ "Bangladesh (বাংলাদেশ)"
85
+ ],
86
+ [
87
+ "BB",
88
+ "Barbados"
89
+ ],
90
+ [
91
+ "BY",
92
+ "Belarus (Беларусь)"
93
+ ],
94
+ [
95
+ "BE",
96
+ "Belgium (België)"
97
+ ],
98
+ [
99
+ "BZ",
100
+ "Belize"
101
+ ],
102
+ [
103
+ "BJ",
104
+ "Benin (Bénin)"
105
+ ],
106
+ [
107
+ "BM",
108
+ "Bermuda"
109
+ ],
110
+ [
111
+ "BT",
112
+ "Bhutan (འབྲུག)"
113
+ ],
114
+ [
115
+ "BO",
116
+ "Bolivia"
117
+ ],
118
+ [
119
+ "BA",
120
+ "Bosnia and Herzegovina"
121
+ ],
122
+ [
123
+ "BW",
124
+ "Botswana"
125
+ ],
126
+ [
127
+ "BR",
128
+ "Brazil (Brasil)"
129
+ ],
130
+ [
131
+ "IO",
132
+ "British Indian Ocean Territory"
133
+ ],
134
+ [
135
+ "VG",
136
+ "British Virgin Islands"
137
+ ],
138
+ [
139
+ "BN",
140
+ "Brunei (Negara Brunei Darussalam)"
141
+ ],
142
+ [
143
+ "BG",
144
+ "Bulgaria (България)"
145
+ ],
146
+ [
147
+ "BF",
148
+ "Burkina Faso"
149
+ ],
150
+ [
151
+ "BI",
152
+ "Burundi (Uburundi)"
153
+ ],
154
+ [
155
+ "KH",
156
+ "Cambodia (កម្ពុជា)"
157
+ ],
158
+ [
159
+ "CM",
160
+ "Cameroon (Cameroun)"
161
+ ],
162
+ [
163
+ "CA",
164
+ "Canada"
165
+ ],
166
+ [
167
+ "CV",
168
+ "Cape Verde (Kabu Verdi)"
169
+ ],
170
+ [
171
+ "BQ",
172
+ "Caribbean Netherlands"
173
+ ],
174
+ [
175
+ "KY",
176
+ "Cayman Islands"
177
+ ],
178
+ [
179
+ "CF",
180
+ "Central African Republic"
181
+ ],
182
+ [
183
+ "TD",
184
+ "Chad (Tchad)"
185
+ ],
186
+ [
187
+ "CL",
188
+ "Chile"
189
+ ],
190
+ [
191
+ "CN",
192
+ "China (中国)"
193
+ ],
194
+ [
195
+ "CX",
196
+ "Christmas Island"
197
+ ],
198
+ [
199
+ "CC",
200
+ "Cocos (Keeling) Islands"
201
+ ],
202
+ [
203
+ "CO",
204
+ "Colombia"
205
+ ],
206
+ [
207
+ "KM",
208
+ "Comoros (‫جزر القمر‬‎)"
209
+ ],
210
+ [
211
+ "CD",
212
+ "Congo (DRC) (Kongo)"
213
+ ],
214
+ [
215
+ "CG",
216
+ "Congo (Republic) (Congo-Brazzaville)"
217
+ ],
218
+ [
219
+ "CK",
220
+ "Cook Islands"
221
+ ],
222
+ [
223
+ "CR",
224
+ "Costa Rica"
225
+ ],
226
+ [
227
+ "CI",
228
+ "Côte d’Ivoire"
229
+ ],
230
+ [
231
+ "HR",
232
+ "Croatia (Hrvatska)"
233
+ ],
234
+ [
235
+ "CU",
236
+ "Cuba"
237
+ ],
238
+ [
239
+ "CW",
240
+ "Curaçao"
241
+ ],
242
+ [
243
+ "CY",
244
+ "Cyprus (Κύπρος)"
245
+ ],
246
+ [
247
+ "CZ",
248
+ "Czech Republic (Česká republika)"
249
+ ],
250
+ [
251
+ "DK",
252
+ "Denmark (Danmark)"
253
+ ],
254
+ [
255
+ "DJ",
256
+ "Djibouti"
257
+ ],
258
+ [
259
+ "DM",
260
+ "Dominica"
261
+ ],
262
+ [
263
+ "DO",
264
+ "Dominican Republic"
265
+ ],
266
+ [
267
+ "EC",
268
+ "Ecuador"
269
+ ],
270
+ [
271
+ "EG",
272
+ "Egypt (‫مصر‬‎)"
273
+ ],
274
+ [
275
+ "SV",
276
+ "El Salvador"
277
+ ],
278
+ [
279
+ "GQ",
280
+ "Equatorial Guinea (Guinea Ecuatorial)"
281
+ ],
282
+ [
283
+ "ER",
284
+ "Eritrea"
285
+ ],
286
+ [
287
+ "EE",
288
+ "Estonia (Eesti)"
289
+ ],
290
+ [
291
+ "ET",
292
+ "Ethiopia"
293
+ ],
294
+ [
295
+ "FK",
296
+ "Falkland Islands (Islas Malvinas)"
297
+ ],
298
+ [
299
+ "FO",
300
+ "Faroe Islands (Føroyar)"
301
+ ],
302
+ [
303
+ "FJ",
304
+ "Fiji (Matanitu Tugalala o Viti)"
305
+ ],
306
+ [
307
+ "FI",
308
+ "Finland (Suomi)"
309
+ ],
310
+ [
311
+ "FR",
312
+ "France (République française)"
313
+ ],
314
+ [
315
+ "GF",
316
+ "French Guiana (Guyane française)"
317
+ ],
318
+ [
319
+ "PF",
320
+ "French Polynesia (Polynésie française)"
321
+ ],
322
+ [
323
+ "GA",
324
+ "Gabon (République gabonaise)"
325
+ ],
326
+ [
327
+ "GM",
328
+ "Gambia"
329
+ ],
330
+ [
331
+ "GE",
332
+ "Georgia (საქართველო)"
333
+ ],
334
+ [
335
+ "DE",
336
+ "Germany (Deutschland)"
337
+ ],
338
+ [
339
+ "GH",
340
+ "Ghana (Gaana)"
341
+ ],
342
+ [
343
+ "GI",
344
+ "Gibraltar"
345
+ ],
346
+ [
347
+ "GR",
348
+ "Greece (Ελλάδα)"
349
+ ],
350
+ [
351
+ "GL",
352
+ "Greenland (Kalaallit Nunaat)"
353
+ ],
354
+ [
355
+ "GD",
356
+ "Grenada"
357
+ ],
358
+ [
359
+ "GP",
360
+ "Guadeloupe"
361
+ ],
362
+ [
363
+ "GU",
364
+ "Guam (Guåhån)"
365
+ ],
366
+ [
367
+ "GT",
368
+ "Guatemala"
369
+ ],
370
+ [
371
+ "GG",
372
+ "Guernsey"
373
+ ],
374
+ [
375
+ "GN",
376
+ "Guinea (Guinée)"
377
+ ],
378
+ [
379
+ "GW",
380
+ "Guinea-Bissau (Guiné Bissau)"
381
+ ],
382
+ [
383
+ "GY",
384
+ "Guyana"
385
+ ],
386
+ [
387
+ "HT",
388
+ "Haiti (République d'Haïti)"
389
+ ],
390
+ [
391
+ "HN",
392
+ "Honduras"
393
+ ],
394
+ [
395
+ "HK",
396
+ "Hong Kong (香港)"
397
+ ],
398
+ [
399
+ "HU",
400
+ "Hungary (Magyarország)"
401
+ ],
402
+ [
403
+ "IS",
404
+ "Iceland (Ísland)"
405
+ ],
406
+ [
407
+ "IN",
408
+ "India (भारत)"
409
+ ],
410
+ [
411
+ "ID",
412
+ "Indonesia"
413
+ ],
414
+ [
415
+ "IR",
416
+ "Iran (‫ایران‬‎)"
417
+ ],
418
+ [
419
+ "IQ",
420
+ "Iraq (‫العراق‬‎)"
421
+ ],
422
+ [
423
+ "IE",
424
+ "Ireland"
425
+ ],
426
+ [
427
+ "IM",
428
+ "Isle of Man"
429
+ ],
430
+ [
431
+ "IL",
432
+ "Israel (‫ישראל‬‎)"
433
+ ],
434
+ [
435
+ "IT",
436
+ "Italy (Italia)"
437
+ ],
438
+ [
439
+ "JM",
440
+ "Jamaica"
441
+ ],
442
+ [
443
+ "JP",
444
+ "Japan (日本)"
445
+ ],
446
+ [
447
+ "JE",
448
+ "Jersey"
449
+ ],
450
+ [
451
+ "JO",
452
+ "Jordan (‫الأردن‬‎)"
453
+ ],
454
+ [
455
+ "KZ",
456
+ "Kazakhstan (Казахстан)"
457
+ ],
458
+ [
459
+ "KE",
460
+ "Kenya"
461
+ ],
462
+ [
463
+ "KI",
464
+ "Kiribati"
465
+ ],
466
+ [
467
+ "KW",
468
+ "Kuwait (‫الكويت‬‎)"
469
+ ],
470
+ [
471
+ "KG",
472
+ "Kyrgyzstan (Кыргызстан)"
473
+ ],
474
+ [
475
+ "LA",
476
+ "Laos (ລາວ)"
477
+ ],
478
+ [
479
+ "LV",
480
+ "Latvia (Latvija)"
481
+ ],
482
+ [
483
+ "LB",
484
+ "Lebanon (‫لبنان‬‎)"
485
+ ],
486
+ [
487
+ "LS",
488
+ "Lesotho"
489
+ ],
490
+ [
491
+ "LR",
492
+ "Liberia"
493
+ ],
494
+ [
495
+ "LY",
496
+ "Libya (‫ليبيا‬‎)"
497
+ ],
498
+ [
499
+ "LI",
500
+ "Liechtenstein"
501
+ ],
502
+ [
503
+ "LT",
504
+ "Lithuania (Lietuva)"
505
+ ],
506
+ [
507
+ "LU",
508
+ "Luxembourg (Lëtzebuerg)"
509
+ ],
510
+ [
511
+ "MO",
512
+ "Macau (澳門)"
513
+ ],
514
+ [
515
+ "MK",
516
+ "Macedonia (FYROM) (Македонија)"
517
+ ],
518
+ [
519
+ "MG",
520
+ "Madagascar (Madagasikara)"
521
+ ],
522
+ [
523
+ "MW",
524
+ "Malawi (Malaŵi)"
525
+ ],
526
+ [
527
+ "MY",
528
+ "Malaysia"
529
+ ],
530
+ [
531
+ "MV",
532
+ "Maldives"
533
+ ],
534
+ [
535
+ "ML",
536
+ "Mali"
537
+ ],
538
+ [
539
+ "MT",
540
+ "Malta"
541
+ ],
542
+ [
543
+ "MH",
544
+ "Marshall Islands"
545
+ ],
546
+ [
547
+ "MQ",
548
+ "Martinique"
549
+ ],
550
+ [
551
+ "MR",
552
+ "Mauritania (‫موريتانيا‬‎)"
553
+ ],
554
+ [
555
+ "MU",
556
+ "Mauritius (Moris)"
557
+ ],
558
+ [
559
+ "YT",
560
+ "Mayotte"
561
+ ],
562
+ [
563
+ "MX",
564
+ "Mexico (México)"
565
+ ],
566
+ [
567
+ "FM",
568
+ "Micronesia"
569
+ ],
570
+ [
571
+ "MD",
572
+ "Moldova (Republica Moldova)"
573
+ ],
574
+ [
575
+ "MC",
576
+ "Monaco"
577
+ ],
578
+ [
579
+ "MN",
580
+ "Mongolia (Монгол)"
581
+ ],
582
+ [
583
+ "ME",
584
+ "Montenegro (Crna Gora)"
585
+ ],
586
+ [
587
+ "MS",
588
+ "Montserrat"
589
+ ],
590
+ [
591
+ "MA",
592
+ "Morocco (‫المغرب‬‎)"
593
+ ],
594
+ [
595
+ "MZ",
596
+ "Mozambique (Moçambique)"
597
+ ],
598
+ [
599
+ "MM",
600
+ "Myanmar (Burma) (မြန်မာ)"
601
+ ],
602
+ [
603
+ "NA",
604
+ "Namibia (Namibië)"
605
+ ],
606
+ [
607
+ "NR",
608
+ "Nauru (Repubrikin Naoero)"
609
+ ],
610
+ [
611
+ "NP",
612
+ "Nepal (नेपाल)"
613
+ ],
614
+ [
615
+ "NL",
616
+ "Netherlands (Nederland)"
617
+ ],
618
+ [
619
+ "NC",
620
+ "New Caledonia (Nouvelle-Calédonie)"
621
+ ],
622
+ [
623
+ "NZ",
624
+ "New Zealand"
625
+ ],
626
+ [
627
+ "NI",
628
+ "Nicaragua"
629
+ ],
630
+ [
631
+ "NE",
632
+ "Niger (Nijar)"
633
+ ],
634
+ [
635
+ "NG",
636
+ "Nigeria"
637
+ ],
638
+ [
639
+ "NU",
640
+ "Niue (Niuē)"
641
+ ],
642
+ [
643
+ "NF",
644
+ "Norfolk Island"
645
+ ],
646
+ [
647
+ "KP",
648
+ "North Korea (조선 민주주의 인민 공화국)"
649
+ ],
650
+ [
651
+ "MP",
652
+ "Northern Mariana Islands"
653
+ ],
654
+ [
655
+ "NO",
656
+ "Norway (Norge)"
657
+ ],
658
+ [
659
+ "OM",
660
+ "Oman (‫عُمان‬‎)"
661
+ ],
662
+ [
663
+ "PK",
664
+ "Pakistan (‫پاکستان‬‎)"
665
+ ],
666
+ [
667
+ "PW",
668
+ "Palau (Beluu er a Belau)"
669
+ ],
670
+ [
671
+ "PS",
672
+ "Palestine (‫فلسطين‬‎)"
673
+ ],
674
+ [
675
+ "PA",
676
+ "Panama (Panamá)"
677
+ ],
678
+ [
679
+ "PG",
680
+ "Papua New Guinea"
681
+ ],
682
+ [
683
+ "PY",
684
+ "Paraguay (Tetã Paraguái)"
685
+ ],
686
+ [
687
+ "PE",
688
+ "Peru (Perú)"
689
+ ],
690
+ [
691
+ "PH",
692
+ "Philippines (Republika ng Pilipinas)"
693
+ ],
694
+ [
695
+ "PL",
696
+ "Poland (Polska)"
697
+ ],
698
+ [
699
+ "PT",
700
+ "Portugal (República Portuguesa)"
701
+ ],
702
+ [
703
+ "PR",
704
+ "Puerto Rico"
705
+ ],
706
+ [
707
+ "QA",
708
+ "Qatar (‫قطر‬‎)"
709
+ ],
710
+ [
711
+ "RE",
712
+ "Réunion (La Réunion)"
713
+ ],
714
+ [
715
+ "RO",
716
+ "Romania (România)"
717
+ ],
718
+ [
719
+ "RU",
720
+ "Russia (Россия)"
721
+ ],
722
+ [
723
+ "RW",
724
+ "Rwanda"
725
+ ],
726
+ [
727
+ "BL",
728
+ "Saint Barthélemy (Saint-Barthélemy)"
729
+ ],
730
+ [
731
+ "SH",
732
+ "Saint Helena"
733
+ ],
734
+ [
735
+ "KN",
736
+ "Saint Kitts and Nevis"
737
+ ],
738
+ [
739
+ "LC",
740
+ "Saint Lucia"
741
+ ],
742
+ [
743
+ "MF",
744
+ "Saint Martin (Saint-Martin)"
745
+ ],
746
+ [
747
+ "PM",
748
+ "Saint Pierre and Miquelon"
749
+ ],
750
+ [
751
+ "VC",
752
+ "Saint Vincent and the Grenadines"
753
+ ],
754
+ [
755
+ "WS",
756
+ "Samoa (Sāmoa)"
757
+ ],
758
+ [
759
+ "SM",
760
+ "San Marino"
761
+ ],
762
+ [
763
+ "ST",
764
+ "São Tomé and Príncipe"
765
+ ],
766
+ [
767
+ "SA",
768
+ "Saudi Arabia (‫المملكة العربية السعودية‬‎)"
769
+ ],
770
+ [
771
+ "SN",
772
+ "Senegal (Sénégal)"
773
+ ],
774
+ [
775
+ "RS",
776
+ "Serbia (Србија)"
777
+ ],
778
+ [
779
+ "SC",
780
+ "Seychelles (Repiblik Sesel)"
781
+ ],
782
+ [
783
+ "SL",
784
+ "Sierra Leone"
785
+ ],
786
+ [
787
+ "SG",
788
+ "Singapore (Singapura) (新加坡共和国)"
789
+ ],
790
+ [
791
+ "SX",
792
+ "Sint Maarten"
793
+ ],
794
+ [
795
+ "SK",
796
+ "Slovakia (Slovensko)"
797
+ ],
798
+ [
799
+ "SI",
800
+ "Slovenia (Slovenija)"
801
+ ],
802
+ [
803
+ "SB",
804
+ "Solomon Islands"
805
+ ],
806
+ [
807
+ "SO",
808
+ "Somalia (Soomaaliya)"
809
+ ],
810
+ [
811
+ "ZA",
812
+ "South Africa"
813
+ ],
814
+ [
815
+ "KR",
816
+ "South Korea (대한민국)"
817
+ ],
818
+ [
819
+ "SS",
820
+ "South Sudan (‫جنوب السودان‬‎)"
821
+ ],
822
+ [
823
+ "ES",
824
+ "Spain (España)"
825
+ ],
826
+ [
827
+ "LK",
828
+ "Sri Lanka (ශ්‍රී ලංකාව)"
829
+ ],
830
+ [
831
+ "SD",
832
+ "Sudan (‫السودان‬‎)"
833
+ ],
834
+ [
835
+ "SR",
836
+ "Suriname"
837
+ ],
838
+ [
839
+ "SJ",
840
+ "Svalbard and Jan Mayen"
841
+ ],
842
+ [
843
+ "SZ",
844
+ "Swaziland (Umbuso weSwatini)"
845
+ ],
846
+ [
847
+ "SE",
848
+ "Sweden (Sverige)"
849
+ ],
850
+ [
851
+ "CH",
852
+ "Switzerland (Schweiz)"
853
+ ],
854
+ [
855
+ "SY",
856
+ "Syria (‫سوريا‬‎)"
857
+ ],
858
+ [
859
+ "TW",
860
+ "Taiwan (台灣)"
861
+ ],
862
+ [
863
+ "TJ",
864
+ "Tajikistan (Ҷумҳурии Тоҷикистон)"
865
+ ],
866
+ [
867
+ "TZ",
868
+ "Tanzania"
869
+ ],
870
+ [
871
+ "TH",
872
+ "Thailand (ไทย)"
873
+ ],
874
+ [
875
+ "TL",
876
+ "Timor-Leste (Timór-Leste)"
877
+ ],
878
+ [
879
+ "TG",
880
+ "Togo (République togolaise)"
881
+ ],
882
+ [
883
+ "TK",
884
+ "Tokelau"
885
+ ],
886
+ [
887
+ "TO",
888
+ "Tonga"
889
+ ],
890
+ [
891
+ "TT",
892
+ "Trinidad and Tobago"
893
+ ],
894
+ [
895
+ "TN",
896
+ "Tunisia (‫تونس‬‎)"
897
+ ],
898
+ [
899
+ "TR",
900
+ "Turkey (Türkiye)"
901
+ ],
902
+ [
903
+ "TM",
904
+ "Turkmenistan (Türkmenistan)"
905
+ ],
906
+ [
907
+ "TC",
908
+ "Turks and Caicos Islands"
909
+ ],
910
+ [
911
+ "TV",
912
+ "Tuvalu"
913
+ ],
914
+ [
915
+ "VI",
916
+ "U.S. Virgin Islands"
917
+ ],
918
+ [
919
+ "UG",
920
+ "Uganda"
921
+ ],
922
+ [
923
+ "UA",
924
+ "Ukraine (Україна)"
925
+ ],
926
+ [
927
+ "AE",
928
+ "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)"
929
+ ],
930
+ [
931
+ "GB",
932
+ "United Kingdom"
933
+ ],
934
+ [
935
+ "US",
936
+ "United States"
937
+ ],
938
+ [
939
+ "UY",
940
+ "Uruguay"
941
+ ],
942
+ [
943
+ "UZ",
944
+ "Uzbekistan (Oʻzbekiston)"
945
+ ],
946
+ [
947
+ "VU",
948
+ "Vanuatu"
949
+ ],
950
+ [
951
+ "VA",
952
+ "Vatican City (Città del Vaticano)"
953
+ ],
954
+ [
955
+ "VE",
956
+ "Venezuela"
957
+ ],
958
+ [
959
+ "VN",
960
+ "Vietnam (Việt Nam)"
961
+ ],
962
+ [
963
+ "WF",
964
+ "Wallis and Futuna (Wallis-et-Futuna)"
965
+ ],
966
+ [
967
+ "EH",
968
+ "Western Sahara (‫الصحراء الغربية‬‎)"
969
+ ],
970
+ [
971
+ "YE",
972
+ "Yemen (‫اليمن‬‎)"
973
+ ],
974
+ [
975
+ "ZM",
976
+ "Zambia"
977
+ ],
978
+ [
979
+ "ZW",
980
+ "Zimbabwe"
981
+ ]
982
+ );
983
+
984
+
985
+ }
986
+
987
+ endif; // END class_exists check
admin/class-htcc-enqueue.php CHANGED
@@ -26,6 +26,7 @@ class HTCC_Enqueue {
26
  wp_enqueue_style( 'font_awesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', '', HTCC_VERSION );
27
  wp_enqueue_style( 'recurly_css', 'https://js.recurly.com/v4/recurly.css', '', HTCC_VERSION );
28
  wp_enqueue_style( 'Fredoka One', 'https://fonts.googleapis.com/css?family=Fredoka+One', '', HTCC_VERSION );
 
29
  wp_enqueue_script( 'htcc_admin_color_picker_js', 'https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.min.js', array( 'jquery' ), HTCC_VERSION, true );
30
 
31
 
26
  wp_enqueue_style( 'font_awesome', 'https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css', '', HTCC_VERSION );
27
  wp_enqueue_style( 'recurly_css', 'https://js.recurly.com/v4/recurly.css', '', HTCC_VERSION );
28
  wp_enqueue_style( 'Fredoka One', 'https://fonts.googleapis.com/css?family=Fredoka+One', '', HTCC_VERSION );
29
+ wp_enqueue_style( 'Open Sans', 'https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800&display=swap', '', HTCC_VERSION );
30
  wp_enqueue_script( 'htcc_admin_color_picker_js', 'https://cdnjs.cloudflare.com/ajax/libs/spectrum/1.8.0/spectrum.min.js', array( 'jquery' ), HTCC_VERSION, true );
31
 
32
 
admin/commons/ht-cc-admin-comment-guard.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Show notify if user don't have Comment Guard.
5
+ *
6
+ * @uses at class-htcc-admin.php
7
+ */
8
+
9
+ if (!defined('ABSPATH')) exit;
10
+ ?>
11
+
12
+ <style>
13
+ .comment-guard-notify {
14
+ background: linear-gradient(0, #A7F18C -41.44%, #19C9B7 121.33%);
15
+ box-shadow: 0px 2px 6px rgba(0, 0, 0, 0.25);
16
+ border-radius: 0 5px 5px;
17
+ min-width: 200px;
18
+ top: 105%;
19
+ left: 7%;
20
+ padding: 10px 20px;
21
+ color: #444444;
22
+ font-weight: normal;
23
+ font-size: 13px;
24
+ position: absolute;
25
+ z-index: 99999999;
26
+ box-sizing: border-box;
27
+ opacity: 1;
28
+ transition: all 0.5s ease;
29
+ }
30
+
31
+ .comment-guard-notify p {
32
+ font-family: 'Open Sans', sans-serif;
33
+ font-style: normal;
34
+ font-weight: normal;
35
+ font-size: 12px;
36
+ line-height: 15px;
37
+ color: #165F47;
38
+ }
39
+ .comment-guard-notify .trn {
40
+ position:absolute;
41
+ bottom: 100%;
42
+ left: 0;
43
+ border-bottom: 14px solid #2DCFB1;
44
+ border-right: 14px solid transparent;
45
+ }
46
+ .close-guard-notify {
47
+ position: absolute;
48
+ right: 5px;
49
+ top: 5px;
50
+ width: 15px;
51
+ height: 14px;
52
+ opacity: 0.5;
53
+ cursor: pointer;
54
+ }
55
+ .close-guard-notify:hover {
56
+ opacity: 1;
57
+ }
58
+ .close-guard-notify:before, .close-guard-notify:after {
59
+ position: absolute;
60
+ content: ' ';
61
+ right: 6px;
62
+ height: 15px;
63
+ width: 2px;
64
+ background-color: #333;
65
+ }
66
+ .close-guard-notify:before {
67
+ transform: rotate(45deg);
68
+ }
69
+ .close-guard-notify:after {
70
+ transform: rotate(-45deg);
71
+ }
72
+ .btn-lets_go{
73
+ margin-left: auto;
74
+ margin-right: auto;
75
+ justify-content: center;
76
+ align-items: center;
77
+ font-size: 13px;
78
+ font-family: 'Open Sans', sans-serif;
79
+ line-height: 18px;
80
+ color: #525252;
81
+ width: 187px;
82
+ display: flex;
83
+ height: 32px;
84
+ background: #FFFFFF;
85
+ box-shadow: 0px 1px 4px rgba(74, 84, 234, 0.6);
86
+ border-radius: 5px;
87
+ cursor: pointer;
88
+ }
89
+ .btn-lets_go:hover,.btn-lets_go:active,.btn-lets_go:focus{
90
+ box-shadow: none;
91
+ }
92
+
93
+
94
+ .comment-guard-notify{
95
+ opacity: 0;
96
+ animation: fadeIn 0.5s;
97
+ animation-delay: 2s;
98
+ animation-fill-mode: forwards;
99
+ }
100
+ @keyframes fadeIn {
101
+ from { opacity: 0; }
102
+ to { opacity: 1; }
103
+ }
104
+ </style>
105
+ <div class="comment-guard-notify">
106
+ <div class="close-guard-notify"></div>
107
+ <p>Looking for more ways to generate leads? Try putting a Comment Guard on your Facebook post. We'll automatically message any user who comments on your posts to get their opt-ins.</p>
108
+ <div class="trn"></div>
109
+ <a class="btn-lets_go" target="_blank" href="https://app.mobilemonkey.com/chatbot-editor/<?php echo $bot_id ?>/comment-guards">Let's Go</a>
110
+ </div>
111
+
112
+
113
+
admin/commons/ht-cc-admin-fb-subscription.php CHANGED
@@ -17,7 +17,7 @@ if ($message_statistic->count){
17
  $message = $message_statistic->count;
18
  }
19
  }else{
20
- $message_statistic= (object)array();
21
  $message_statistic->count=0;
22
  $message = 0;
23
  }
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-new-leads.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ *
6
+ * This file is used to markup the admin-facing aspects of the plugin.
7
+ *
8
+ *
9
+ */
10
+ ?>
11
+ <link href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap" rel="stylesheet">
12
+ <style>
13
+ .mobile-button {
14
+ background: linear-gradient(180deg, #3952FA 0%, #945DF8 100%);
15
+ border-radius: 6px;
16
+ text-decoration: none;
17
+ height: 80px;
18
+ width: 100%;
19
+ }
20
+ h3, p {
21
+ margin-bottom: 10px;
22
+ margin-top: 0;
23
+ }
24
+ .main_notice__wrap{
25
+ position: relative;
26
+ width: 98%;
27
+ margin-top: 54px;
28
+ display: flex;
29
+ }
30
+ .notification__wrapper {
31
+ display: flex;
32
+ width: 100%;
33
+ justify-content: space-between;
34
+ color: #fff;
35
+ align-items: center;
36
+ }
37
+ .notification__button {
38
+ margin-left: auto;
39
+ padding: 0;
40
+ font-weight: 900;
41
+ font-size: 18px;
42
+ flex-basis: 30%;
43
+ text-align: center;
44
+ flex-direction: column;
45
+ display: flex;
46
+ align-items: flex-end;
47
+ margin-right: 55px;
48
+ }
49
+
50
+ .notification__info {
51
+ padding: 0;
52
+ }
53
+ .info__heading{
54
+ color: #FFFFFF;
55
+ font-family: "Open-Sans",sans-serif;
56
+ font-style: normal;
57
+ font-weight: normal;
58
+ font-size: 17px;
59
+ line-height: 31px;
60
+ margin-bottom: 5px;
61
+ }
62
+ .info__heading b{
63
+ display: flex;
64
+ line-height: 19px;
65
+ margin-top: 1px;
66
+ }
67
+ .complete__button{
68
+ width: 121px;
69
+ padding: 5px;
70
+ line-height: 16px;
71
+ background: #FFFFFF;
72
+ border-radius: 5px;
73
+ }
74
+ .complete__button span{
75
+ font-family: "Open-Sans",sans-serif;
76
+ font-style: normal;
77
+ font-weight: normal;
78
+ font-size: 13px;
79
+ line-height: 18px;
80
+ color: #525252;
81
+ }
82
+ .dismiss__button{
83
+ position: absolute;
84
+ top: 3px;
85
+ right: 5px;
86
+ display: flex;
87
+ align-self: flex-end;
88
+ cursor: pointer;
89
+ }
90
+ .dismiss__button .button__wrapper_text{
91
+ color: #F1F1F1;
92
+ font-family: "Open-Sans",sans-serif;
93
+ font-weight: 900;
94
+ line-height: 32px;
95
+ display: flex;
96
+ font-size: 15px;
97
+ }
98
+ @media (max-width: 720px) {
99
+ .notification__wrapper{
100
+ flex-direction: column;
101
+ }
102
+ }
103
+
104
+ @media (max-width: 992px) {
105
+
106
+ }
107
+
108
+ @media (max-width: 1200px) {
109
+
110
+
111
+ }
112
+ .notification__images{
113
+ background-image: url(<?php echo plugins_url('admin/assets/img/phone.png',HTCC_PLUGIN_FILE)?>)!important;
114
+ background-repeat: no-repeat;
115
+ background-size: cover;
116
+ background-position: center center;
117
+ height: 80px;
118
+ width: 125px;
119
+ position: relative;
120
+ margin: 0 30px;
121
+ }
122
+ </style>
123
+ <div class="main_notice__wrap">
124
+ <div class="dismiss__button">
125
+ <span class="button__wrapper_text dismiss_but"><i class="fa fa-times" aria-hidden="true"></i></span>
126
+ </div>
127
+ <a class="mobile-button new_leads" href="<?php echo admin_url( 'admin.php?page=wp-chatbot' )?>">
128
+ <div class="notification__wrapper">
129
+ <div class="notification__images">
130
+ </div>
131
+ <div class="notification__info">
132
+ <h3 class="info__heading">You had <?php echo $leads_count ?> new leads on your website in the last 3 days. <b>Set up notifications in WP-Chatbot to get an email each time a new lead is detected!</b></h3>
133
+ </div>
134
+ <div class="notification__button">
135
+ <div class="complete__button">
136
+ <span class="button__wrapper_text">SET UP NOTIFICATION</span>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </a>
141
+ </div>
142
+
admin/commons/ht-cc-admin-notice-not-connected.php CHANGED
@@ -9,6 +9,7 @@
9
  */
10
  ?>
11
  <link href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap" rel="stylesheet">
 
12
  <style>
13
  .main {
14
  width: 1200px;
@@ -46,7 +47,7 @@
46
  text-align: center;
47
  }
48
  .notification__info {
49
- padding: 1rem;
50
  }
51
  .info-heading {
52
  font-size: 26px;
@@ -86,7 +87,7 @@
86
  height: 110%;
87
  }
88
  .notification__images{
89
- height: 100%;
90
  width: 300px;
91
  position: relative;
92
  }
@@ -102,6 +103,20 @@
102
  align-self: center;
103
  display: flex;
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  @media (max-width: 720px) {
106
  .notification__wrapper{
107
  flex-direction: column;
@@ -169,23 +184,45 @@
169
  }
170
  }
171
  </style>
172
- <a class="mobile-button" href="<?php echo admin_url( 'admin.php?page=wp-chatbot' )?>">
173
- <div class="notification__wrapper">
174
- <div class="notification__images">
175
- <img src="<?php echo plugins_url('admin/assets/img/monkey.png',HTCC_PLUGIN_FILE)?>" class="images__item image-monkey">
176
- </div>
177
- <div class="notification__info">
178
- <h3 class="info__heading">Uh oh. Your WP-Chatbot setup is incomplete!</h3>
179
- <p class="info__text">Click to resolve as soon as possible</p>
180
- <div class="info__text--bottom">
181
- <img src="<?php echo plugins_url('admin/assets/img/logo.png',HTCC_PLUGIN_FILE)?>" alt="test" class="info__image">
182
- </div>
183
- </div>
184
- <div class="notification__button">
185
- <div class="button__wrapper">
186
- <span class="button__wrapper_text">Complete setup</span>
187
- <span class="dashicons button__wrapper_arrow dashicons-arrow-right-alt"></span>
188
- </div>
189
- </div>
190
- </div>
191
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  */
10
  ?>
11
  <link href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap" rel="stylesheet">
12
+ <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
13
  <style>
14
  .main {
15
  width: 1200px;
47
  text-align: center;
48
  }
49
  .notification__info {
50
+ padding: 1rem 0;
51
  }
52
  .info-heading {
53
  font-size: 26px;
87
  height: 110%;
88
  }
89
  .notification__images{
90
+ height: 155px;
91
  width: 300px;
92
  position: relative;
93
  }
103
  align-self: center;
104
  display: flex;
105
  }
106
+ .dis_main_banner{
107
+ position: absolute;
108
+ top: 5%;
109
+ right: 3%;
110
+ display: flex;
111
+ align-self: flex-end;
112
+ cursor: pointer;
113
+ color: #fff;
114
+ font-size: 18px;
115
+ line-height: 10px;
116
+ }
117
+ .banner_main__wrap{
118
+ position: relative;
119
+ }
120
  @media (max-width: 720px) {
121
  .notification__wrapper{
122
  flex-direction: column;
184
  }
185
  }
186
  </style>
187
+ <script>
188
+ jQuery(document).ready(function($){
189
+ $('.main_banner_button').on('click',function (e) {
190
+ $.ajax({
191
+ type: 'POST',
192
+ url: ajaxurl,
193
+ data: {
194
+ action: 'main_notice'
195
+ },
196
+ dataType: 'json',
197
+ success: function (data,response) {
198
+ $('.main_banner_button').parents('.banner_main__wrap').fadeOut(300, function(){ $(this).remove();});;
199
+ }
200
+ });
201
+ });
202
+ });
203
+ </script>
204
+ <div class="banner_main__wrap">
205
+ <div class="dis_main_banner">
206
+ <span class="main_banner_button"><i class="fa fa-times" aria-hidden="true"></i></span>
207
+ </div>
208
+ <a class="mobile-button" href="<?php echo admin_url( 'admin.php?page=wp-chatbot' )?>">
209
+ <div class="notification__wrapper">
210
+ <div class="notification__images">
211
+ <img src="<?php echo plugins_url('admin/assets/img/monkey.png',HTCC_PLUGIN_FILE)?>" class="images__item image-monkey">
212
+ </div>
213
+ <div class="notification__info">
214
+ <h3 class="info__heading">Uh oh. Your WP-Chatbot setup is incomplete!</h3>
215
+ <p class="info__text">Click to resolve as soon as possible</p>
216
+ <div class="info__text--bottom">
217
+ <img src="<?php echo plugins_url('admin/assets/img/logo.png',HTCC_PLUGIN_FILE)?>" alt="test" class="info__image">
218
+ </div>
219
+ </div>
220
+ <div class="notification__button">
221
+ <div class="button__wrapper">
222
+ <span class="button__wrapper_text">Complete setup</span>
223
+ <span class="dashicons button__wrapper_arrow dashicons-arrow-right-alt"></span>
224
+ </div>
225
+ </div>
226
+ </div>
227
+ </a>
228
+ </div>
admin/commons/ht-cc-admin-settings-form.php CHANGED
@@ -10,35 +10,35 @@ if (!defined('ABSPATH')) exit;
10
  include(HTCC_PLUGIN_DIR . 'admin/contact_page.php');
11
  $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
- $current = str_replace('-', "", $_SESSION['current']);
16
- foreach ($_SESSION['tab'] as $key => $value) {
17
- if ($value) {
18
- $$key = 'done';
19
  } else {
20
- $$key = '';
21
  }
22
  }
23
- $$current .= ' current';
 
24
  ?>
25
  <div class="step-wrapper">
26
  <div class="tab_header">
27
  <ul class="tabs_wrapper">
28
- <li class="tab-link <?php echo $tab1 ?>" data-tab="tab-1">
29
  <span class="tab_number">1</span>
30
  <span class="tab_header">Setup</span>
31
  </li>
32
- <li class="tab-link <?php echo $tab2 ?>" data-tab="tab-2">
33
  <span class="tab_number">2</span>
34
  <span class="tab_header">Customize</span>
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">
42
  <span class="tab_header">Your Subscription</span>
43
  </li>
44
 
@@ -50,17 +50,9 @@ $$current .= ' current';
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 target="_blank" rel="noopener noreferrer"
59
- href='https://app.mobilemonkey.com/chatbot-editor/<?php echo $connected_page['id'] ?>/configure/chatbot'
60
- class="go_mm"><?php _e('Go to MobileMonkey') ?></a>
61
- </div>
62
- </div>
63
- <form method="post" action="options.php" style="display: <?php echo $state ?>">
64
  <?php
65
  settings_fields('htcc_as_setting_group');
66
  do_settings_sections('htcc-as-setting-section');
@@ -75,7 +67,7 @@ $$current .= ' current';
75
  HT_CC::view('ht-cc-admin-form-bottom-connect', $fb_connected_area_active_page_settings); ?>
76
  </div>
77
  </div>
78
- <div id="tab-2" class="tab-content customize_section <?php echo $tab2 ?>">
79
  <div class="tab-content__wrapper">
80
  <h1><?php _e('Customize') ?></h1>
81
  <form method="post" action="options.php">
@@ -88,7 +80,7 @@ $$current .= ' current';
88
 
89
  </div>
90
  </div>
91
- <div id="tab-3" class="tab-content contact_tab <?php echo $tab3 ?>">
92
  <h1><?php _e('Leads') ?></h1>
93
 
94
  <div class="contact_head__wrap">
@@ -135,7 +127,7 @@ $$current .= ' current';
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">
140
  <?php
141
  $plan = json_decode(json_encode($wp_plan_info), True);
@@ -265,9 +257,9 @@ $$current .= ' current';
265
  </div>
266
  <label for="country"><?php _e('COUNTRY')?></label>
267
  <select name="country" id="country" data-recurly="country" required>
268
- <option value="US">US</option>
269
- <option value="AD">AD</option>
270
- <option value="AE">AE</option>
271
  </select>
272
  <label for="card_number"><?php _e('CARD INFO') ?></label>
273
  <div class="card__wrap">
10
  include(HTCC_PLUGIN_DIR . 'admin/contact_page.php');
11
  $table = new MobileMonkey_Contacts_List_Table();
12
  $table->prepare_items();
13
+ $curren = get_transient( 'current-tab' );
14
+ $tab = get_transient( 'done-tab' );
15
+ foreach ($tab as $key => $value) {
16
+ if ($value == "true") {
17
+ $tabs[$key] = 'done';
 
18
  } else {
19
+ $tabs[$key]= '';
20
  }
21
  }
22
+ $tabs[$curren] .= ' current';
23
+
24
  ?>
25
  <div class="step-wrapper">
26
  <div class="tab_header">
27
  <ul class="tabs_wrapper">
28
+ <li class="tab-link <?php echo $tabs[1] ?>" data-tab="tab-1">
29
  <span class="tab_number">1</span>
30
  <span class="tab_header">Setup</span>
31
  </li>
32
+ <li class="tab-link <?php echo $tabs[2] ?>" data-tab="tab-2">
33
  <span class="tab_number">2</span>
34
  <span class="tab_header">Customize</span>
35
  </li>
36
+ <li class="tab-link <?php echo $tabs[3] ?>" 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 $tabs[4] ?>" data-tab="tab-4">
42
  <span class="tab_header">Your Subscription</span>
43
  </li>
44
 
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 $tabs[1] ?> setup_section">
54
  <div class="tab-content__wrapper">
55
+ <form method="post" action="options.php" style="display: block">
 
 
 
 
 
 
 
 
56
  <?php
57
  settings_fields('htcc_as_setting_group');
58
  do_settings_sections('htcc-as-setting-section');
67
  HT_CC::view('ht-cc-admin-form-bottom-connect', $fb_connected_area_active_page_settings); ?>
68
  </div>
69
  </div>
70
+ <div id="tab-2" class="tab-content customize_section <?php echo $tabs[2] ?>">
71
  <div class="tab-content__wrapper">
72
  <h1><?php _e('Customize') ?></h1>
73
  <form method="post" action="options.php">
80
 
81
  </div>
82
  </div>
83
+ <div id="tab-3" class="tab-content contact_tab <?php echo $tabs[3] ?>">
84
  <h1><?php _e('Leads') ?></h1>
85
 
86
  <div class="contact_head__wrap">
127
  </a>
128
  </div>
129
  </div>
130
+ <div id="tab-4" class="tab-content subscribe_section <?php echo $tabs[4] ?>">
131
  <div class="tab-content__wrapper">
132
  <?php
133
  $plan = json_decode(json_encode($wp_plan_info), True);
257
  </div>
258
  <label for="country"><?php _e('COUNTRY')?></label>
259
  <select name="country" id="country" data-recurly="country" required>
260
+ <?php foreach (HTCC_Countries::$contries as $k=>$v){
261
+ echo "<option value=".$v[0].">".$v[1]."</option>";
262
+ } ?>
263
  </select>
264
  <label for="card_number"><?php _e('CARD INFO') ?></label>
265
  <div class="card__wrap">
admin/commons/th-cc-admin-notice-not-connected.php DELETED
@@ -1,191 +0,0 @@
1
- <?php
2
-
3
- /**
4
- *
5
- *
6
- * This file is used to markup the admin-facing aspects of the plugin.
7
- *
8
- *
9
- */
10
- ?>
11
- <link href="https://fonts.googleapis.com/css?family=Nunito+Sans&display=swap" rel="stylesheet">
12
- <style>
13
- .main {
14
- width: 1200px;
15
- margin: 0 auto;
16
- }
17
- .mobile-button {
18
- width: 98%;
19
- margin-top: 54px;
20
- display: flex;
21
- background: linear-gradient(to right, rgba(191,0,146,1) 0%, rgba(224,0,75,1) 100%);
22
- border-radius: 30px;
23
- box-shadow: 0px 0px 5px 0px rgba(0,0,0,0.75);
24
- text-decoration: none;
25
- }
26
- h3, p {
27
- margin-bottom: 10px;
28
- margin-top: 0;
29
- }
30
- .notification__wrapper {
31
- display: flex;
32
- width: 100%;
33
- justify-content: space-between;
34
- color: #fff;
35
- align-items: center;
36
- }
37
- .notification__button {
38
- margin-left: auto;
39
- padding: 15px 24px;
40
- border: 2px solid #fff;
41
- border-radius: 10px;
42
- text-transform: uppercase;
43
- font-weight: 900;
44
- font-size: 18px;
45
- margin-right: 2em;
46
- text-align: center;
47
- }
48
- .notification__info {
49
- padding: 1rem;
50
- }
51
- .info-heading {
52
- font-size: 26px;
53
- }
54
- .info__text--bottom {
55
- display: flex;
56
- }
57
- .info__heading{
58
- color: #FFFFFF;
59
- font-family: "Nunito Sans";
60
- font-size: 28px;
61
- font-weight: 800;
62
- line-height: 38px;
63
- }
64
- .info__text{
65
- color: #FFFFFF;
66
- font-family: "Nunito Sans";
67
- font-size: 18px;
68
- font-weight: bold;
69
- line-height: 24px;
70
- }
71
- .button__wrapper{
72
- display: flex;
73
- }
74
- .button__wrapper_text{
75
- color: #F1F1F1;
76
- font-family: "Nunito Sans";
77
- font-size: 24px;
78
- font-weight: 900;
79
- line-height: 32px;
80
- display: flex;
81
- }
82
- .image-monkey{
83
- margin: -10px 0 0 0;
84
- z-index: 10;
85
- position: relative;
86
- height: 110%;
87
- }
88
- .notification__images{
89
- height: 100%;
90
- width: 300px;
91
- position: relative;
92
- }
93
- .button__wrapper_arrow{
94
- display: flex;
95
- align-self: center;
96
- margin-left: 10px;
97
- width: auto;
98
- height: auto;
99
- font-size: 35px;
100
- }
101
- .button__wrapper_text{
102
- align-self: center;
103
- display: flex;
104
- }
105
- @media (max-width: 720px) {
106
- .notification__wrapper{
107
- flex-direction: column;
108
- }
109
- .notification__button{
110
- margin-left: 0;
111
- margin-bottom: 20px;
112
- margin-right: 0;
113
- }
114
- .notification__images{
115
- width: auto;
116
- }
117
- .mobile-button{
118
- margin: 20px;
119
- width: 87%;
120
- }
121
- }
122
-
123
- @media (max-width: 992px) {
124
- .button__wrapper_text{
125
- font-size: 16px;
126
- line-height: 16px;
127
- }
128
- .notification__images{
129
- height: auto;
130
- }
131
- }
132
-
133
- @media (max-width: 1200px) {
134
- .info__heading{
135
- font-size: 24px;
136
- }
137
- .info__text{
138
- font-size: 16px;
139
- }
140
- .button__wrapper_text{
141
- font-size: 17px;
142
- line-height: 17px;
143
- }
144
- .button__wrapper_arrow{
145
- font-size: 22px;
146
- }
147
- .notification__button{
148
- padding: 15px 15px;
149
- }
150
- }
151
- #wpadminbar .chat-bot{
152
- background-image: url(<?php echo plugins_url('admin/assets/img/notice_icon_new.png',HTCC_PLUGIN_FILE)?>)!important;
153
- height: 100%;
154
- background-size: contain;
155
- background-repeat: no-repeat;
156
- width: 52px;
157
- padding: 0px;
158
- margin: 0px;
159
- }
160
- #wpadminbar .quicklinks>ul>li#wp-admin-bar-wp-chatbot a{
161
- padding: 0;
162
- }
163
- @media (max-width: 782px) {
164
- #wp-toolbar #wp-admin-bar-wp-chatbot{
165
- display: block;
166
- }
167
- #wpadminbar li#wp-admin-bar-wp-chatbot .chat-bot{
168
- width: 75px;
169
- }
170
- }
171
- </style>
172
- <a class="mobile-button" href="<?php echo admin_url( 'admin.php?page=wp-chatbot' )?>">
173
- <div class="notification__wrapper">
174
- <div class="notification__images">
175
- <img src="<?php echo plugins_url('admin/assets/img/monkey.png',HTCC_PLUGIN_FILE)?>" class="images__item image-monkey">
176
- </div>
177
- <div class="notification__info">
178
- <h3 class="info__heading">Uh oh. Your WP-Chatbot setup is incomplete!</h3>
179
- <p class="info__text">Click to resolve as soon as possible</p>
180
- <div class="info__text--bottom">
181
- <img src="<?php echo plugins_url('admin/assets/img/logo.png',HTCC_PLUGIN_FILE)?>" alt="test" class="info__image">
182
- </div>
183
- </div>
184
- <div class="notification__button">
185
- <div class="button__wrapper">
186
- <span class="button__wrapper_text">Complete setup</span>
187
- <span class="dashicons button__wrapper_arrow dashicons-arrow-right-alt"></span>
188
- </div>
189
- </div>
190
- </div>
191
- </a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/settings_page.php CHANGED
@@ -7,63 +7,61 @@
7
 
8
  if (!defined('ABSPATH')) exit;
9
  $options = get_option('htcc_options');
 
 
 
 
 
 
 
 
10
  ?>
11
 
12
- <!-- style="display: flex; flex-wrap: wrap;" -->
13
-
14
  <div class="wrap">
15
  <div class="row mobile_wrap">
16
  <div class="col s12 m9 x9 options">
17
- <div class="mobilemonkey-logo"></div>
 
 
 
 
 
 
 
 
 
 
 
18
  <h6 class="options-subtitle"><?php _e('WP-Chatbot is ') ?><a href="https://mobilemonkey.com/" target="_blank"><?php _e('powered by MobileMonkey') ?></a><?php _e(': an Official Facebook Messenger Solutions Provider Partner') ?></h6>
19
  <?php
20
- $options = get_option('htcc_options');
21
- $options_as = get_option('htcc_as_options');
22
- $options_custom = get_option('htcc_custom_options');
23
- $api = $this->getApi();
24
- $this->api->logoutMobilemonkey();
25
- $token = $this->api->connectMobileMonkey();
26
- $internal = get_option('mobilemonkey_active_page_id');
27
- $update = false;
28
  if ($token) {
29
  $reset = FALSE;
30
  if ($this->api->connectPage() || $this->api->disconnectPage()) {
31
  $reset = TRUE;
 
32
  }
33
- $pages = $this->api->getPages();
34
  $activePage = $this->api->getActivePage($reset);
35
- if ($activePage) {
36
- if ($activePage['bot_id']){
37
- $mm_state = $this->api->mmOnlyCheck($this->fb_page_id);
38
  if ( isset($_REQUEST['settings-updated']) && $_REQUEST['settings-updated']){
39
  $update = true;
40
- $current_language = $this->api->getLanguage($activePage['remote_id']);
41
  if (!empty($options_custom['fb_sdk_lang']) && $options_custom['fb_sdk_lang'] !== $current_language) {
42
- $this->api->updateLanguage($options_custom['fb_sdk_lang'], $activePage['remote_id']);
43
- }
44
- if ($mm_state){
45
- echo "<style>.settings-error{display: none}</style>";
46
- }
47
- }
48
- if (!$mm_state){
49
- $current_welcome_message = $this->api->getWelcomeMessage($activePage['remote_id']);
50
- if ($options_as['fb_welcome_message'] !== $current_welcome_message && isset($options_as['fb_welcome_message'])) {
51
- $this->api->updateWelcomeMessage($options_as['fb_welcome_message'], $activePage['remote_id']);
52
  }
53
- }else {
54
- delete_option('htcc_as_options');
55
  }
56
- $this->api->setWidgets($options_as,$activePage['remote_id'],$update);
57
- $this->api->setCustomChatSettings($activePage['remote_id'],$options_custom,$update);
58
  }else {
59
  echo "<style>.settings-error{display: none}</style>";
60
  $this->api->renderNotice('<p class="bot_disabled">Your chatbot has been disabled in MobileMonkey. Please reactivate it before making additional edits. Go <a target="_blank" rel="noopener noreferrer" href="https://app.mobilemonkey.com/chatbot-editor/">here</a> to reactivate your chatbot</p>');
61
 
62
  }
63
- $this->api->getSubscribeInfo();
64
  $is_pro = $this->api->GetCurrentSubscription()? true : false;
65
  $fb_connected_area_active_page_settings = [
66
- 'connected_page' => $activePage,
67
  'is_pro' => $is_pro
68
  ];
69
  $page_subscribe_info = [
@@ -72,13 +70,13 @@ $options = get_option('htcc_options');
72
  'subscribe_info'=> $this->api->getCurrentSubscription(),
73
  'wp_plan_info'=> $this->api->getWpPlan(),
74
  'message_statistic'=> $this->api->getMessageStatistic(),
75
- 'connected_page' => $activePage,
76
- 'mm_only' => $mm_state
77
  ];
78
  HT_CC::view('ht-cc-admin-fb-button-connected', $fb_connected_area_active_page_settings);
79
  HT_CC::view('ht-cc-admin-settings-form',$page_subscribe_info);
80
 
81
  } else {
 
82
  if ($internal){
83
  echo "<style>.settings-error{display: none}</style>";
84
  $this->api->renderNotice('Your Facebook page has been disconnected in MobileMonkey. Please connect to a page to reactivate your chatbot.');
7
 
8
  if (!defined('ABSPATH')) exit;
9
  $options = get_option('htcc_options');
10
+ $options_as = get_option('htcc_as_options');
11
+ $options_custom = get_option('htcc_custom_options');
12
+ $api = $this->getApi();
13
+ $this->api->logoutMobilemonkey();
14
+ $token = $this->api->connectMobileMonkey();
15
+ $internal = $this->api->getActivePageId();
16
+ $update = false;
17
+ $cg_notice = get_transient( 'cg_notice_off' );
18
  ?>
19
 
 
 
20
  <div class="wrap">
21
  <div class="row mobile_wrap">
22
  <div class="col s12 m9 x9 options">
23
+ <div class="mobilemonkey-logo">
24
+ <?php
25
+ if ($api->getActiveBotId()){
26
+ $data_cg = [
27
+ 'bot_id'=> $api->getActiveBotId()
28
+ ];
29
+ if (!$api->isCommentGuard()&&$cg_notice!=true){
30
+ HT_CC::view('ht-cc-admin-comment-guard',$data_cg);
31
+ }
32
+ }
33
+ ?>
34
+ </div>
35
  <h6 class="options-subtitle"><?php _e('WP-Chatbot is ') ?><a href="https://mobilemonkey.com/" target="_blank"><?php _e('powered by MobileMonkey') ?></a><?php _e(': an Official Facebook Messenger Solutions Provider Partner') ?></h6>
36
  <?php
 
 
 
 
 
 
 
 
37
  if ($token) {
38
  $reset = FALSE;
39
  if ($this->api->connectPage() || $this->api->disconnectPage()) {
40
  $reset = TRUE;
41
+ exit;
42
  }
43
+ $this->api->getSubscribeInfo();
44
  $activePage = $this->api->getActivePage($reset);
45
+ $actpage = get_option("mobilemonkey_active_page_info");
46
+ if ($actpage) {
47
+ if ($actpage['bot_id']){
48
  if ( isset($_REQUEST['settings-updated']) && $_REQUEST['settings-updated']){
49
  $update = true;
50
+ $current_language = $this->api->getLanguage($actpage['remote_id']);
51
  if (!empty($options_custom['fb_sdk_lang']) && $options_custom['fb_sdk_lang'] !== $current_language) {
52
+ $this->api->updateLanguage($options_custom['fb_sdk_lang'], $actpage['remote_id']);
 
 
 
 
 
 
 
 
 
53
  }
 
 
54
  }
55
+ $this->api->setWidgets($options_as,$actpage['remote_id'],$update);
56
+ $this->api->setCustomChatSettings($actpage['remote_id'],$options_custom,$update);
57
  }else {
58
  echo "<style>.settings-error{display: none}</style>";
59
  $this->api->renderNotice('<p class="bot_disabled">Your chatbot has been disabled in MobileMonkey. Please reactivate it before making additional edits. Go <a target="_blank" rel="noopener noreferrer" href="https://app.mobilemonkey.com/chatbot-editor/">here</a> to reactivate your chatbot</p>');
60
 
61
  }
 
62
  $is_pro = $this->api->GetCurrentSubscription()? true : false;
63
  $fb_connected_area_active_page_settings = [
64
+ 'connected_page' => $actpage,
65
  'is_pro' => $is_pro
66
  ];
67
  $page_subscribe_info = [
70
  'subscribe_info'=> $this->api->getCurrentSubscription(),
71
  'wp_plan_info'=> $this->api->getWpPlan(),
72
  'message_statistic'=> $this->api->getMessageStatistic(),
73
+ 'connected_page' => $actpage,
 
74
  ];
75
  HT_CC::view('ht-cc-admin-fb-button-connected', $fb_connected_area_active_page_settings);
76
  HT_CC::view('ht-cc-admin-settings-form',$page_subscribe_info);
77
 
78
  } else {
79
+ $pages = $this->api->getPages();
80
  if ($internal){
81
  echo "<style>.settings-error{display: none}</style>";
82
  $this->api->renderNotice('Your Facebook page has been disconnected in MobileMonkey. Please connect to a page to reactivate your chatbot.');
inc/MobileMonkeyApi.php CHANGED
@@ -8,14 +8,14 @@ class MobileMonkeyApi
8
  private $src = 'wordpress';
9
  private $pages = [];
10
  private $active_page = false;
11
- private $promoters = [];
12
- private $landing_page;
13
  private $env = true;
14
  private $pagination;
15
  private $contacts;
16
  private $plugin_name = 'wp-chatbot';
17
  private $page_info;
 
18
  public $available_company;
 
19
 
20
  private function getApiDomain()
21
  {
@@ -61,8 +61,7 @@ class MobileMonkeyApi
61
  {
62
 
63
  if ($connection_page_id) {
64
-
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)){
@@ -73,9 +72,123 @@ class MobileMonkeyApi
73
  return get_option($this->option_prefix . 'company_id');
74
  }
75
  }
76
- private function getActiveRemotePageId(){
77
- return get_option($this->option_prefix . 'active_page_remote_id');
78
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
 
80
  public function getSubscribeInfo()
81
  {
@@ -99,6 +212,29 @@ class MobileMonkeyApi
99
  }
100
  }
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  public function setPageInfo($info){
103
  $data = [
104
  'pageName'=> $info->name,
@@ -153,20 +289,7 @@ class MobileMonkeyApi
153
  return get_option($this->option_prefix . 'wp_plan');
154
  }
155
 
156
- private function getInternalPageId($connection_page_id)
157
- {
158
 
159
- if ($connection_page_id) {
160
-
161
- $pages = $this->getPages();
162
- foreach ($pages as $page) {
163
- if ($page['id'] && $connection_page_id == $page['remote_id']) {
164
- return $page['id'];
165
- }
166
- }
167
- return get_option($this->option_prefix . 'fb_internal_page_id');
168
- }
169
- }
170
  private function default_custom_setting(){
171
  $data = array();
172
  $data['fb_logged_in_greeting'] = 'Hi! How can we help you?';
@@ -237,25 +360,6 @@ class MobileMonkeyApi
237
  }
238
  }
239
 
240
- private function setActiveBotId($bot_id)
241
- {
242
- update_option($this->option_prefix . 'active_bot', $bot_id);
243
- }
244
-
245
- public function getActiveBotId()
246
- {
247
- return get_option($this->option_prefix . 'active_bot');
248
- }
249
-
250
- private function setActivePageId($page_id)
251
- {
252
- update_option($this->option_prefix . 'active_page_id', $page_id);
253
- }
254
-
255
- private function getActivePageId()
256
- {
257
- return get_option($this->option_prefix . 'active_page_id');
258
- }
259
 
260
  private function setEnvironment($environment)
261
  {
@@ -305,13 +409,9 @@ class MobileMonkeyApi
305
  {
306
  $logout = filter_input(INPUT_GET, "logout", FILTER_SANITIZE_STRING);
307
  if ($logout || $reset) {
308
- $this->disconnectPage(get_option($this->option_prefix . 'active_page_id'));
309
  delete_option('htcc_fb_js_src');
310
  delete_option($this->option_prefix . 'token');
311
- delete_option($this->option_prefix . 'company_id');
312
- delete_option($this->option_prefix . 'active_page_id');
313
- delete_option($this->option_prefix . 'active_page_remote_id');
314
- delete_option($this->option_prefix . 'active_bot');
315
  $this->refreshSettingsPage();
316
  }
317
  }
@@ -335,29 +435,6 @@ class MobileMonkeyApi
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
  {
@@ -392,12 +469,18 @@ class MobileMonkeyApi
392
  } elseif (!empty($connect_response->success)) {
393
  if ($connect_response->facebook_page->remote_id) {
394
  $options = get_option('htcc_options', array());
395
- $options['fb_page_id'] = $connect_response->facebook_page->remote_id;
396
- $this->setActivePageId($connect_response->facebook_page->remote_id);
397
- $options['fb_internal_page_id'] = $connect_response->facebook_page->id;
398
- update_option('htcc_options', $options);
 
 
 
 
 
399
  if ($connect_response->facebook_page->active_bot_id) {
400
- $custom_settings = $this->getCustomChatSettings($options['fb_page_id']);
 
401
  $default_setting = $this->default_custom_setting();
402
  foreach ($custom_settings as $key=>$value){
403
  if ($value == '' || !isset($value)){
@@ -414,10 +497,15 @@ class MobileMonkeyApi
414
  update_option('htcc_custom_options', $custom_options);
415
  $options['fb_sdk_lang'] = $this->getLanguage($connect_response->facebook_page->remote_id);
416
  update_option('htcc_options', $options);
417
- $_SESSION['tab']['tab1'] = true;
418
- $_SESSION['tab']['tab2'] = false;
419
- $_SESSION['tab']['tab3'] = false;
420
- $_SESSION['current'] = 'tab-1';
 
 
 
 
 
421
  $this->refreshSettingsPage();
422
  return true;
423
  }
@@ -484,24 +572,15 @@ class MobileMonkeyApi
484
  $content = wp_remote_retrieve_body($response);
485
  $connect_response = json_decode($content);
486
  if (empty($content)) {
487
-
488
  $this->active_page = false;
489
-
490
- $options = get_option('htcc_options', array());
491
- $options['fb_page_id'] = '';
492
- $options['fb_welcome_message'] = '';
493
- update_option('htcc_options', $options);
494
  delete_option('htcc_as_options');
495
  delete_option($this->option_prefix . 'page_info');
496
  delete_option($this->option_prefix . 'account_info');
497
  delete_option($this->option_prefix . 'current_subscribe');
498
  delete_option($this->option_prefix . 'message_statistic');
499
  delete_option($this->option_prefix . 'wp_plan');
500
- delete_option($this->option_prefix . 'active_page_id');
501
- delete_option($this->option_prefix . 'active_page_remote_id');
502
- delete_option($this->option_prefix . 'active_bot');
503
  delete_option('htcc_fb_js_src');
504
- unset($_SESSION['tab'],$_SESSION['current']);
505
  $this->refreshSettingsPage();
506
 
507
  return true;
@@ -526,88 +605,6 @@ class MobileMonkeyApi
526
  }
527
  }
528
 
529
- public function getPages()
530
- {
531
- $args = [
532
- 'timeout' => 10,
533
- 'headers' => [
534
- 'Authorization' => $this->getToken()
535
- ],
536
- 'body' =>[
537
- 'src' => $this->getSrc()
538
- ]
539
- ];
540
- $pagesObj = NULL;
541
- $pages = [];
542
- $response = wp_remote_get($this->getApiDomain() . '/api/facebook_pages/available_options?src=' . $this->getSrc().'&v=' . HTCC_VERSION.'.2', $args);
543
- $content = wp_remote_retrieve_body($response);
544
- if (!empty($content)) {
545
- $pagesObj = json_decode($content);
546
-
547
- if (empty($pagesObj->errors)) {
548
- if(is_array($pagesObj->data)) {
549
- foreach ($pagesObj->data as $page) {
550
- $p = [
551
- 'name' => $page->name,
552
- 'remote_id' => $page->remote_id,
553
- 'id' => $page->facebook_page_id,
554
- 'bot_id' => $page->bot_id,
555
- 'bot_kind' => $page->bot_kind,
556
- 'company_id' => $page->company_id,
557
- 'path' => add_query_arg([
558
- 'page' => $this->plugin_name,
559
- 'connect' => $page->remote_id,
560
- 'page_name' => $page->name
561
- ], admin_url('admin.php')),
562
- ];
563
-
564
- $pages[] = $p;
565
- }
566
- }
567
- }
568
- }
569
- $this->pages = $pages;
570
- return $pages;
571
- }
572
-
573
- public function getActivePage($reset = false)
574
- {
575
-
576
- if (!$reset && !empty($this->active_page)) {
577
- return $this->active_page;
578
- }
579
-
580
- $activePage = [];
581
- $pages = $this->getPages();
582
-
583
- $options = get_option('htcc_options', array());
584
- $active_remote_page_id = $options['fb_page_id'];
585
-
586
- foreach ($pages as $page) {
587
- if ($active_remote_page_id == $page['remote_id']) {
588
- $activePage['remote_id'] = $page['remote_id'];
589
- $activePage['bot_id'] = $page['bot_id'];
590
- $activePage['name'] = $page['name'];
591
- $activePage['id'] = $page['id'];
592
- if ($page['id']){
593
- $activePage['path'] = add_query_arg([
594
- 'page' => $this->plugin_name,
595
- 'disconnect' => $page['id'],
596
- ], admin_url('admin.php'));
597
- }else {
598
- return false;
599
- break;
600
- }
601
- update_option($this->option_prefix . 'active_page_remote_id', $page['remote_id']);
602
- $this->setActivePageId($page['id']);
603
- $this->setActiveBotId($page['bot_id']);
604
- break;
605
- }
606
- }
607
-
608
- $this->active_page = $activePage;
609
- return $activePage;
610
- }
611
 
612
  public function sendUserEmail()
613
  {
@@ -736,11 +733,13 @@ class MobileMonkeyApi
736
  'src' => $this->getSrc()
737
  ]
738
  ];
739
-
740
  $response = wp_remote_get($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2?fb_page_remote_id=' . $remote_id . '&v=' . HTCC_VERSION.'.2', $args);
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){
@@ -767,7 +766,7 @@ class MobileMonkeyApi
767
  $value_new['fb_welcome_message'] = $this->getWelcomeMessage($remote_id);
768
  $value_new['thank_message'] = $connect_response->thank_you_message;
769
  $value_new['email'] = $connect_response->notify_email;
770
- $value_new['fb_as_state'] = 0;
771
  return $value_new;
772
  } else {
773
  return false;
@@ -817,120 +816,201 @@ class MobileMonkeyApi
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';
840
- $data_widget['lq_1']['answers2']['answer'] = '$1-$99';
841
- $data_widget['lq_1']['answers3']['answer'] = '$100-$500';
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{
864
- $data_widget = $this->getWidgets($page_id);
865
- if (!$data_widget){
866
- return false;
867
- }
868
- if ($options['fb_as_state']== null || $options['fb_as_state']==0){
869
- $value_new['enabled'] = false;
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();
877
- $question = '';
878
- foreach ($value as $k=>$v){
879
- if ($k=='question'&&!empty($v)){
880
- $question = $v;
881
- }else{
882
- if(!empty($v['answer'])){
883
- if (!ctype_space($v['answer'])){
884
- $answer[]=array('answer'=>$v['answer'],'qualified'=> (bool)$v['qualified']);
885
- }
886
- }else{
887
- $error_lenght = true;
888
- }
889
  }
890
  }
891
- $value_new["qualifiers"][]=[
892
- "question"=>$question,
893
- "answers"=>$answer
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");
922
- echo "<style>.settings-error{display: none}</style>";
923
- }
924
- if (!isset($value_new["qualifiers"])){
925
- $value_new["qualifiers"]=[];
926
- }
927
- $value_new["notify_email"]= $options["email"];
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
 
@@ -969,7 +1049,7 @@ class MobileMonkeyApi
969
  $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2', $args);
970
  $error = ($this->ErrorHandler($response,'Widget','put'));
971
  if ($error) {
972
- return $response;
973
  }
974
  }
975
 
@@ -1076,10 +1156,6 @@ class MobileMonkeyApi
1076
  {
1077
  $options = [];
1078
  $options['token'] = get_option($this->option_prefix . 'token');
1079
- $options['company_id'] = get_option($this->option_prefix . 'company_id');
1080
- $options['active_page_id'] = get_option($this->option_prefix . 'active_page_id');
1081
- $options['active_page_remote_id'] = get_option($this->option_prefix . 'active_page_remote_id');
1082
- $options['active_bot'] = get_option($this->option_prefix . 'active_bot');
1083
  $options['environment'] = get_option($this->option_prefix . 'environment');
1084
  $options['htcc_options'] = get_option('htcc_options');
1085
  return var_dump($options);
@@ -1241,7 +1317,10 @@ class MobileMonkeyApi
1241
  }
1242
  } elseif (!empty($connect_response->errors)) {
1243
  foreach ($connect_response->errors as $error) {
1244
- $this->renderError('Error: ' . $error);
 
 
 
1245
  }
1246
  } else {
1247
  if ($point=="Welcome Message" && $code==422){
8
  private $src = 'wordpress';
9
  private $pages = [];
10
  private $active_page = false;
 
 
11
  private $env = true;
12
  private $pagination;
13
  private $contacts;
14
  private $plugin_name = 'wp-chatbot';
15
  private $page_info;
16
+ private $bot_id;
17
  public $available_company;
18
+ public $as_mm = false;
19
 
20
  private function getApiDomain()
21
  {
61
  {
62
 
63
  if ($connection_page_id) {
64
+ $pages = $this->pages;
 
65
  foreach ($pages as $page) {
66
  if ($page['id'] && $connection_page_id == $page['remote_id']) {
67
  if (in_array($page['company_id'], $this->available_company)){
72
  return get_option($this->option_prefix . 'company_id');
73
  }
74
  }
75
+ public function getActiveRemotePageId(){
76
+ $data = get_option($this->option_prefix . 'active_page_info');
77
+ return $data['remote_id'];
78
+ }
79
+
80
+
81
+ private function getInternalPageId($connection_page_id)
82
+ {
83
+
84
+ if ($connection_page_id) {
85
+
86
+ $pages = $this->pages;
87
+ foreach ($pages as $page) {
88
+ if ($page['id'] && $connection_page_id == $page['remote_id']) {
89
+ return $page['id'];
90
+ }
91
+ }
92
+ return get_option($this->option_prefix . 'fb_internal_page_id');
93
+ }
94
+ }
95
+
96
+
97
+ public function getActiveBotId()
98
+ {
99
+ $data = get_option($this->option_prefix . 'active_page_info');
100
+ return $data['bot_id'];
101
+ }
102
+
103
+
104
+ public function getActivePageId()
105
+ {
106
+ $data = get_option($this->option_prefix . 'active_page_info');
107
+ return $data['id'];
108
+ }
109
+
110
+ public function getAvailableCompany(){
111
+ $args = [
112
+ 'timeout' => 10,
113
+ 'headers' => [
114
+ 'Authorization' => $this->getToken(),
115
+ 'Content-Type' => 'application/json; charset=utf-8',
116
+ ],
117
+ 'method' => 'GET',
118
+ ];
119
+ $response = wp_remote_post($this->getApiDomain() . 'api/wordpress_settings/my_company_ids?v=' . HTCC_VERSION.'.2', $args);
120
+ $error = $this->ErrorHandler($response,'Available Company','get');
121
+ if ($error) {
122
+ $connect_response = json_decode($error);
123
+ return $connect_response;
124
+ }
125
+ }
126
+
127
+ public function setAvailableCompany(){
128
+ $company = $this->getAvailableCompany();
129
+ update_option($this->option_prefix . 'available_company', $company);
130
+ $this->available_company = $company;
131
+ }
132
+
133
+ public function getPages()
134
+ {
135
+ $args = [
136
+ 'timeout' => 30,
137
+ 'headers' => [
138
+ 'Authorization' => $this->getToken()
139
+ ],
140
+ 'body' =>[
141
+ 'src' => $this->getSrc()
142
+ ]
143
+ ];
144
+ $pagesObj = NULL;
145
+ $pages = [];
146
+ $response = wp_remote_get($this->getApiDomain() . 'api/facebook_pages/available_options?src=' . $this->getSrc().'&v=' . HTCC_VERSION.'.3', $args);
147
+ $content = wp_remote_retrieve_body($response);
148
+ if (!empty($content)) {
149
+ $pagesObj = json_decode($content);
150
+
151
+ if (empty($pagesObj->errors)) {
152
+ if(is_array($pagesObj->data)) {
153
+ foreach ($pagesObj->data as $page) {
154
+ $p = [
155
+ 'name' => $page->name,
156
+ 'remote_id' => $page->remote_id,
157
+ 'id' => $page->facebook_page_id,
158
+ 'bot_id' => $page->bot_id,
159
+ 'bot_kind' => $page->bot_kind,
160
+ 'company_id' => $page->company_id,
161
+ 'path' => add_query_arg([
162
+ 'page' => $this->plugin_name,
163
+ 'connect' => $page->remote_id,
164
+ 'page_name' => $page->name
165
+ ], admin_url('admin.php')),
166
+ ];
167
+
168
+ $pages[] = $p;
169
+ }
170
+ }
171
+ }
172
+ }
173
+ $this->pages = $pages;
174
+ return $pages;
175
+ }
176
+
177
+ public function getActivePage($reset = false)
178
+ {
179
+
180
+ if (!$reset && !empty($this->active_page)) {
181
+ return $this->active_page;
182
+ }
183
+
184
+ $actpage = get_option("mobilemonkey_active_page_info");
185
+ if ($actpage){
186
+ $this->active_page = $actpage;
187
+ return $actpage;
188
+ }else
189
+ return false;
190
+ }
191
+
192
 
193
  public function getSubscribeInfo()
194
  {
212
  }
213
  }
214
 
215
+ public function isCommentGuard(){
216
+ $args = [
217
+ 'timeout' => 10,
218
+ 'headers' => [
219
+ 'Authorization' => $this->getToken(),
220
+ 'Content-Type' => 'application/json; charset=utf-8',
221
+ ],
222
+ 'method' => 'GET',
223
+ ];
224
+ $bot_id = $this->getActiveBotId();
225
+ if ($bot_id){
226
+ $response = wp_remote_post($this->getApiDomain() . 'api/bots/'.$bot_id.'/start_bots?page=1&per_page=25&kind=comment_guard&v=' . HTCC_VERSION.'.2', $args);
227
+ $content = wp_remote_retrieve_body($response);
228
+ if ($content){
229
+ $data = json_decode($content);
230
+ if ($data->start_bots){
231
+ return true;
232
+ }
233
+ else return false;
234
+ }
235
+ }
236
+ }
237
+
238
  public function setPageInfo($info){
239
  $data = [
240
  'pageName'=> $info->name,
289
  return get_option($this->option_prefix . 'wp_plan');
290
  }
291
 
 
 
292
 
 
 
 
 
 
 
 
 
 
 
 
293
  private function default_custom_setting(){
294
  $data = array();
295
  $data['fb_logged_in_greeting'] = 'Hi! How can we help you?';
360
  }
361
  }
362
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
363
 
364
  private function setEnvironment($environment)
365
  {
409
  {
410
  $logout = filter_input(INPUT_GET, "logout", FILTER_SANITIZE_STRING);
411
  if ($logout || $reset) {
412
+ $this->disconnectPage(get_option($this->active_page['page_id']));
413
  delete_option('htcc_fb_js_src');
414
  delete_option($this->option_prefix . 'token');
 
 
 
 
415
  $this->refreshSettingsPage();
416
  }
417
  }
435
 
436
  }
437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
438
 
439
  public function connectPage()
440
  {
469
  } elseif (!empty($connect_response->success)) {
470
  if ($connect_response->facebook_page->remote_id) {
471
  $options = get_option('htcc_options', array());
472
+ $new_opt['remote_id'] = $connect_response->facebook_page->remote_id;
473
+ $new_opt['bot_id'] = $connect_response->facebook_page->active_bot_id;
474
+ $new_opt['name'] = $connect_response->facebook_page->name;
475
+ $new_opt['id'] = $connect_response->facebook_page->id;
476
+ $new_opt['path'] =add_query_arg([
477
+ 'page' => $this->plugin_name,
478
+ 'disconnect' => $connect_response->facebook_page->id,
479
+ ], admin_url('admin.php'));
480
+ update_option($this->option_prefix.'active_page_info', $new_opt);
481
  if ($connect_response->facebook_page->active_bot_id) {
482
+ set_transient( 'pre_value', true, YEAR_IN_SECONDS );
483
+ $custom_settings = $this->getCustomChatSettings($connect_response->facebook_page->remote_id);
484
  $default_setting = $this->default_custom_setting();
485
  foreach ($custom_settings as $key=>$value){
486
  if ($value == '' || !isset($value)){
497
  update_option('htcc_custom_options', $custom_options);
498
  $options['fb_sdk_lang'] = $this->getLanguage($connect_response->facebook_page->remote_id);
499
  update_option('htcc_options', $options);
500
+ delete_transient( 'done-tab' );
501
+ delete_transient( 'current-tab' );
502
+ $done_tab = array(
503
+ '1'=>"true",
504
+ '2'=>"false",
505
+ '3'=>"false",
506
+ );
507
+ set_transient( 'done-tab', $done_tab, YEAR_IN_SECONDS );
508
+ set_transient( 'current-tab', '1', YEAR_IN_SECONDS );
509
  $this->refreshSettingsPage();
510
  return true;
511
  }
572
  $content = wp_remote_retrieve_body($response);
573
  $connect_response = json_decode($content);
574
  if (empty($content)) {
 
575
  $this->active_page = false;
 
 
 
 
 
576
  delete_option('htcc_as_options');
577
  delete_option($this->option_prefix . 'page_info');
578
  delete_option($this->option_prefix . 'account_info');
579
  delete_option($this->option_prefix . 'current_subscribe');
580
  delete_option($this->option_prefix . 'message_statistic');
581
  delete_option($this->option_prefix . 'wp_plan');
582
+ delete_option($this->option_prefix . 'active_page_info');
 
 
583
  delete_option('htcc_fb_js_src');
 
584
  $this->refreshSettingsPage();
585
 
586
  return true;
605
  }
606
  }
607
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
608
 
609
  public function sendUserEmail()
610
  {
733
  'src' => $this->getSrc()
734
  ]
735
  ];
 
736
  $response = wp_remote_get($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2?fb_page_remote_id=' . $remote_id . '&v=' . HTCC_VERSION.'.2', $args);
737
  $error = $this->ErrorHandler($response,'Widget','get');
738
  if ($error) {
739
  $connect_response = json_decode($error);
740
+ if (isset($connect_response->answering_service_mm_only_mode)||isset($connect_response->answering_service_not_available)){
741
+ return [];
742
+ }
743
  $value_new['fb_answer'] = $connect_response->questions;
744
  $i=1;
745
  foreach ($connect_response->qualifiers as $key=>$value){
766
  $value_new['fb_welcome_message'] = $this->getWelcomeMessage($remote_id);
767
  $value_new['thank_message'] = $connect_response->thank_you_message;
768
  $value_new['email'] = $connect_response->notify_email;
769
+ $value_new['fb_as_state'] = $connect_response->enabled;
770
  return $value_new;
771
  } else {
772
  return false;
816
  {
817
  $var = true;
818
  $trig = true;
819
+
820
  if (!$update){
821
+ $triggers = $this->getTriggers($page_id);
822
+ $data_widget = $this->getWidgets($page_id);
823
+ $this->as_mm = empty($data_widget)?true:false;
824
+ $current_welcome_message = $this->getWelcomeMessage($page_id);
825
+ $pre_val = get_transient( 'pre_value' );
826
  if (count($options,COUNT_NORMAL)==1 && $options['fb_welcome_message']||!$options) {
827
+ if ($this->as_mm == false) {
828
+ $data_widget = array_merge($data_widget, $triggers);
829
+ foreach ($data_widget as $key=>$value){
830
+ if (strpos($key, 'lq_')!==false){
831
+ $var=false;
832
+ }
833
+ }
834
 
835
+ if ($var){
836
+ $data_widget['lq_1']['question'] = 'What is your budget?';
837
+ $data_widget['lq_1']['answers1']['answer'] = '$0';
838
+ $data_widget['lq_1']['answers2']['answer'] = '$1-$99';
839
+ $data_widget['lq_1']['answers3']['answer'] = '$100-$500';
840
+ $data_widget['lq_1']['answers4']['answer'] = '$500+';
841
+ $data_widget['lq_1']['answers4']['qualified'] = '1';
842
  }
843
+ if ($pre_val==true) {
844
+ foreach ($data_widget as $k => $v) {
845
+ if (strpos($k, 'qa_') !== false) {
846
+ $trig = false;
847
+ }
848
+ }
849
+ if ($trig) {
850
+ $data_widget['qa_1']['phrases'] = '';
851
+ $data_widget['qa_1']['bot_responses'] = '';
852
+ }
853
  }
854
+ $data_widget['answering_service_mm_only_mode'] = false;
855
+ $data_widget['fb_welcome_message'] = $current_welcome_message;
856
+ $data_widget['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
857
+ $data_widget['fb_as_state'] = 0;
858
+ update_option('htcc_as_options', $data_widget);
859
+ }else {
860
+ foreach ($options as $key => $value) {
861
+ if (strpos($key, 'qa_') !== false) {
862
+ if (!empty($value['phrases']) && !empty($value['bot_responses'])) {
863
+ unset($options[$key]);
864
+ }
 
 
 
 
 
 
 
 
 
 
865
  }
866
  }
867
+ $data_widget = array_merge($options, $triggers);
868
+ if (!$options) {
869
+ foreach ($data_widget as $k => $v) {
870
+ if (strpos($k, 'qa_') !== false) {
871
+ $trig = false;
872
+ }
873
+ }
874
+ if ($trig) {
875
+ $data_widget['qa_1']['phrases'] = '';
876
+ $data_widget['qa_1']['bot_responses'] = '';
877
+ }
878
+ }
879
+ $data_widget['fb_welcome_message'] = $current_welcome_message;
880
+ $data_widget['answering_service_mm_only_mode'] = true;
881
+ $data_widget['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
882
+ update_option('htcc_as_options', $data_widget);
883
  }
884
+ }
885
+ if ($this->as_mm == false) {
886
+ $data_widget = array_merge($data_widget, $triggers);
887
+ $pre_val = get_transient( 'pre_value' );
888
+ foreach ($data_widget as $key=>$value){
889
+ if (strpos($key, 'lq_')!==false){
890
+ $var=false;
891
+ }
892
+ }
893
+
894
+ if ($var){
895
+ $data_widget['lq_1']['question'] = 'What is your budget?';
896
+ $data_widget['lq_1']['answers1']['answer'] = '$0';
897
+ $data_widget['lq_1']['answers2']['answer'] = '$1-$99';
898
+ $data_widget['lq_1']['answers3']['answer'] = '$100-$500';
899
+ $data_widget['lq_1']['answers4']['answer'] = '$500+';
900
+ $data_widget['lq_1']['answers4']['qualified'] = '1';
901
+ }
902
+ if ($pre_val==true) {
903
+ foreach ($data_widget as $k => $v) {
904
+ if (strpos($k, 'qa_') !== false) {
905
+ $trig = false;
906
+ }
907
+ }
908
+ if ($trig) {
909
+ $data_widget['qa_1']['phrases'] = '';
910
+ $data_widget['qa_1']['bot_responses'] = '';
911
+ }
912
+ }
913
+ $data_widget['answering_service_mm_only_mode'] = false;
914
+ $data_widget['fb_welcome_message'] = $current_welcome_message;
915
  $data_widget['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
916
  update_option('htcc_as_options', $data_widget);
917
+ }else {
918
+ foreach ($options as $key => $value) {
919
+ if (strpos($key, 'qa_') !== false) {
920
+ if (!empty($value['phrases']) && !empty($value['bot_responses'])) {
921
+ unset($options[$key]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
922
  }
923
  }
 
 
 
 
 
924
  }
925
+ $data_widget['answering_service_mm_only_mode'] = empty($data_widget) ? true : '';
926
+ $data_widget = array_merge($options, $triggers);
927
+ if (!$options) {
928
+ foreach ($data_widget as $k => $v) {
929
+ if (strpos($k, 'qa_') !== false) {
930
+ $trig = false;
 
 
 
 
 
 
 
 
931
  }
 
932
  }
933
+ if ($trig) {
934
+ $data_widget['qa_1']['phrases'] = '';
935
+ $data_widget['qa_1']['bot_responses'] = '';
936
+ }
937
  }
938
+ $data_widget['answering_service_mm_only_mode'] = true;
939
+ $data_widget['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
940
+ update_option('htcc_as_options', $data_widget);
941
  }
942
+ }else{
943
+ $data_widget = $this->getWidgets($page_id);
944
+ $triggers = $this->getTriggers($page_id);
945
+ $this->as_mm = empty($data_widget)?true:false;
946
+ $state=empty($data_widget)?true:false;
947
+ if ($state==false){
948
+ if ($options['fb_as_state']== null || $options['fb_as_state']==0){
949
+ $value_new['enabled'] = false;
950
+ } else {
951
+ $value_new['enabled'] = true;
952
+ }
953
+
954
+ $value_new['questions'] = $options['fb_answer'];
955
+ foreach ($options as $key=>$value){
956
+ if (strpos($key, 'lq_')!==false){
957
+ $answer = array();
958
+ $question = '';
959
+ foreach ($value as $k=>$v){
960
+ if ($k=='question'){
961
+ $question = $v;
962
+ }else{
963
+ if(isset($v['answer'])){
964
+ if (!ctype_space($v['answer'])){
965
+ $answer[]=array('answer'=>$v['answer'],'qualified'=> (bool)$v['qualified']);
966
+ }
967
+ }
968
+ }
969
+ }
970
+ $value_new["qualifiers"][]=[
971
+ "question"=>$question,
972
+ "answers"=>$answer
973
+ ];
974
+
975
+ }
976
+ }
977
+ if (!isset($value_new["qualifiers"])){
978
+ $value_new["qualifiers"]=[];
979
+ }
980
+ $value_new["notify_email"]= $options["email"];
981
+ $value_new["notify_mode"]= $options['notify_mode'];
982
+ $value_new['thank_you_message'] = $options['thank_message'];
983
+ $value_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
984
+ $this->updateWelcomeMessage($options['fb_welcome_message'],$page_id);
985
+ $this->updateWidgets($value_new);
986
+
987
+ }
988
+ foreach ($options as $key=>$value){
989
+ if (strpos($key, 'qa_')!==false){
990
+ $phrases = array();
991
+ $bot_responses = array();
992
+ foreach ($value as $k=>$v){
993
+ if ($k=='bot_responses'&&!empty($v)){
994
+ $bot_responses[] = $v;
995
+ }else{
996
+ if(!empty($v)){
997
+ if (!ctype_space($v)){
998
+ $phrases=$v;
999
+ }
1000
+ }
1001
+ }
1002
+
1003
+ }
1004
+ $trigger_new["triggers"][]=[
1005
+ "phrases"=>$phrases,
1006
+ "bot_responses"=>$bot_responses
1007
+ ];
1008
+ }
1009
+ }
1010
+ $options['advanced_triggers_present'] = $triggers['advanced_triggers_present'];
1011
+ update_option('htcc_as_options', $options);
1012
+ $trigger_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
1013
+ $this->updateTriggers($trigger_new);
1014
  }
1015
  return true;
1016
 
1049
  $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2', $args);
1050
  $error = ($this->ErrorHandler($response,'Widget','put'));
1051
  if ($error) {
1052
+ return $error;
1053
  }
1054
  }
1055
 
1156
  {
1157
  $options = [];
1158
  $options['token'] = get_option($this->option_prefix . 'token');
 
 
 
 
1159
  $options['environment'] = get_option($this->option_prefix . 'environment');
1160
  $options['htcc_options'] = get_option('htcc_options');
1161
  return var_dump($options);
1317
  }
1318
  } elseif (!empty($connect_response->errors)) {
1319
  foreach ($connect_response->errors as $error) {
1320
+ if ($code==422||$code==401||$code==404){
1321
+ delete_option('mobilemonkey_active_page_info');
1322
+ break;
1323
+ }
1324
  }
1325
  } else {
1326
  if ($point=="Welcome Message" && $code==422){
inc/class-ht-cc.php CHANGED
@@ -208,12 +208,6 @@ class HT_CC {
208
  register_deactivation_hook( HTCC_PLUGIN_FILE, array( 'HTCC_Register', 'deactivate' ) );
209
  register_uninstall_hook(HTCC_PLUGIN_FILE, array( 'HTCC_Register', 'uninstall' ) );
210
  add_action( 'activated_plugin', array( 'HTCC_Register', 'activate_plugin' ) );
211
- add_action('init', 'start_session', 1);
212
- function start_session() {
213
- if(!session_id()) {
214
- session_start();
215
- }
216
- }
217
  // initilaze classes
218
  if ( ! is_admin() ) {
219
  add_action( 'init', array( $this, 'init' ), 0 );
208
  register_deactivation_hook( HTCC_PLUGIN_FILE, array( 'HTCC_Register', 'deactivate' ) );
209
  register_uninstall_hook(HTCC_PLUGIN_FILE, array( 'HTCC_Register', 'uninstall' ) );
210
  add_action( 'activated_plugin', array( 'HTCC_Register', 'activate_plugin' ) );
 
 
 
 
 
 
211
  // initilaze classes
212
  if ( ! is_admin() ) {
213
  add_action( 'init', array( $this, 'init' ), 0 );
inc/class-htcc-chatbot.php CHANGED
@@ -32,7 +32,7 @@ class HTCC_Chatbot {
32
  public function chatbot() {
33
 
34
  $htcc_options = ht_cc()->variables->get_option;
35
- $shortcode_name = esc_attr( $htcc_options['shortcode'] );
36
 
37
  $is_mobile = ht_cc()->device_type->is_mobile;
38
 
@@ -120,7 +120,7 @@ class HTCC_Chatbot {
120
 
121
 
122
  $this_page_id = get_the_ID();
123
- $pages_list_tohide = $htcc_options['list_hideon_pages'];
124
  $pages_list_tohide_array = explode(',', $pages_list_tohide);
125
 
126
  if( ( is_single() || is_page() ) && in_array( $this_page_id, $pages_list_tohide_array ) ) {
@@ -128,7 +128,8 @@ class HTCC_Chatbot {
128
  }
129
 
130
  // Hide styles on this catergorys - list
131
- $list_hideon_cat = $htcc_options['list_hideon_cat'];
 
132
 
133
  $activePage = $this->api->getActivePage();
134
  if (!$activePage) {
32
  public function chatbot() {
33
 
34
  $htcc_options = ht_cc()->variables->get_option;
35
+ $shortcode_name = isset($htcc_options['shortcode'])?esc_attr( $htcc_options['shortcode'] ):'';
36
 
37
  $is_mobile = ht_cc()->device_type->is_mobile;
38
 
120
 
121
 
122
  $this_page_id = get_the_ID();
123
+ $pages_list_tohide = isset($htcc_options['list_hideon_pages'])?esc_attr( $htcc_options['list_hideon_pages'] ):'';
124
  $pages_list_tohide_array = explode(',', $pages_list_tohide);
125
 
126
  if( ( is_single() || is_page() ) && in_array( $this_page_id, $pages_list_tohide_array ) ) {
128
  }
129
 
130
  // Hide styles on this catergorys - list
131
+ $list_hideon_cat = isset($htcc_options['list_hideon_cat'])?esc_attr( $htcc_options['list_hideon_cat'] ):'';;
132
+
133
 
134
  $activePage = $this->api->getActivePage();
135
  if (!$activePage) {
inc/class-htcc-db.php CHANGED
@@ -57,10 +57,6 @@ class HTCC_db {
57
  * is_sdk_4_seconds - if both checked - after page loaded, load sdk after 4 seconds
58
  */
59
  $defpage_value =array (
60
- 'mobilemonkey_company_id' =>'',
61
- 'mobilemonkey_active_page_remote_id' =>'',
62
- 'mobilemonkey_active_page_id' =>'',
63
- 'mobilemonkey_active_bot' =>'',
64
  'mobilemonkey_token' =>'',
65
  'htcc_fb_js_src' =>''
66
  );
57
  * is_sdk_4_seconds - if both checked - after page loaded, load sdk after 4 seconds
58
  */
59
  $defpage_value =array (
 
 
 
 
60
  'mobilemonkey_token' =>'',
61
  'htcc_fb_js_src' =>''
62
  );
inc/class-htcc-register.php CHANGED
@@ -67,14 +67,11 @@ class HTCC_Register {
67
  * @return void
68
  */
69
  public static function deactivate() {
70
- $pageid = get_option('mobilemonkey_active_page_id');
71
  $test = new MobileMonkeyApi();
72
- $test->disconnectPage($pageid);
73
  delete_option('mobilemonkey_token');
74
- delete_option('mobilemonkey_company_id');
75
- delete_option('mobilemonkey_active_page_id');
76
- delete_option('mobilemonkey_active_page_remote_id');
77
- delete_option('mobilemonkey_active_bot');
78
  }
79
 
80
  /**
@@ -84,14 +81,11 @@ class HTCC_Register {
84
  * @return void
85
  */
86
  public static function uninstall() {
87
- $pageid = get_option('mobilemonkey_active_page_id');
88
  $test = new MobileMonkeyApi();
89
- $test->disconnectPage($pageid);
90
  delete_option('mobilemonkey_token');
91
- delete_option('mobilemonkey_company_id');
92
- delete_option('mobilemonkey_active_page_id');
93
- delete_option('mobilemonkey_active_page_remote_id');
94
- delete_option('mobilemonkey_active_bot');
95
  }
96
 
97
 
67
  * @return void
68
  */
69
  public static function deactivate() {
70
+ $data = get_option('mobilemonkey_active_page_info');
71
  $test = new MobileMonkeyApi();
72
+ $test->disconnectPage($data['page_id']);
73
  delete_option('mobilemonkey_token');
74
+ delete_option('mobilemonkey_active_page_info');
 
 
 
75
  }
76
 
77
  /**
81
  * @return void
82
  */
83
  public static function uninstall() {
84
+ $data = get_option('mobilemonkey_active_page_info');
85
  $test = new MobileMonkeyApi();
86
+ $test->disconnectPage($data['page_id']);
87
  delete_option('mobilemonkey_token');
88
+ delete_option('mobilemonkey_active_page_info');
 
 
 
89
  }
90
 
91
 
readme.txt CHANGED
@@ -3,11 +3,12 @@ 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.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
10
 
 
11
 
12
  == Description ==
13
 
@@ -128,7 +129,7 @@ In the setup process, you’ll also need to add your website to the whitelisted
128
 
129
  **Is WP-Chatbot compliant with GDPR?**
130
 
131
- Yes. Consent, a requisite component of GDPR, takes place when the user clicks the button to “continue as [name].” It’s important that any chatbot dialogues you create should inform subscribers how they can unsubscribe at any time. For example, you can tell users “Just type STOP at any time to unsubscribe.” If you are using MobileMonkey, then MobileMonkey will automatically handle the unsubscribe request by deleting the contact from your database.
132
 
133
  **Does WP-Chatbot come with any analytics?**
134
 
@@ -578,6 +579,12 @@ WP-Chatbot is extremely flexible, versatile, and compatible. Because it works se
578
 
579
  == Changelog ==
580
 
 
 
 
 
 
 
581
  = 4.1.4 =
582
  Added the ability to use Lead Qualifier
583
 
3
  Tested up to: 5.2
4
  Requires PHP: 5.6
5
  Contributors: larrykim, yankovski
6
+ Stable tag: 4.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
10
 
11
+ WP-Chatbot is the fastest, simplest way to add live chat to your website. Convert hot leads and engage your customers using the Messenger chat widget.
12
 
13
  == Description ==
14
 
129
 
130
  **Is WP-Chatbot compliant with GDPR?**
131
 
132
+ Yes. Consent, a requisite component of GDPR, takes place when the user clicks the button to “continue as [name].” It’s important that any chatbot dialogues you create should inform subscribers how they can unsubscribe at any time. For example, you can tell users “Just type STOP at any time to unsubscribe.” If you are using MobileMonkey, then MobileMonkey will automatically handle the unsubscribe request. If the contact wishes to have their data deleted from MobileMonkey, they can always send a message via Messenger or via email to make the request,. Once the page owner receives the deletion request, they can easily honor the request by using the delete contact action in MobileMokey.
133
 
134
  **Does WP-Chatbot come with any analytics?**
135
 
579
 
580
  == Changelog ==
581
 
582
+ = 4.3 =
583
+ Enhance usability on notifications
584
+
585
+ = 4.2 =
586
+ Introduce new Q&A feature
587
+
588
  = 4.1.4 =
589
  Added the ability to use Lead Qualifier
590
 
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.5
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.5' );
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.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.3' );
21
  }
22
 
23