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
+ ],