WP-Chatbot for Facebook Messenger Customer Chat - Version 4.1.4

Version Description

Added the ability to use Lead Qualifier

Download this release

Release Info

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

Code changes from version 4.1.3 to 4.1.4

admin/admin.php CHANGED
@@ -30,7 +30,7 @@ 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_create_bot', array($api,'create_bot'));
34
add_action('wp_ajax_get_done', array($admin,'get_tab_done'));
35
add_action('wp_ajax_set_current_tab', array($admin,'set_current_tab'));
36
add_action('wp_ajax_create_subscribe', array($api,'create_subscribe'));
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'));
admin/assets/css/admin-styles.css CHANGED
@@ -382,9 +382,10 @@ span.free{
382
.switch {
383
position: relative;
384
display: inline-block;
385
- width: 60px;
386
- height: 34px;
387
margin: 0;
388
}
389
390
/* Hide default HTML checkbox */
@@ -393,7 +394,9 @@ span.free{
393
width: 0;
394
height: 0;
395
}
396
-
397
/* The slider */
398
.slider {
399
position: absolute;
@@ -406,12 +409,18 @@ span.free{
406
-webkit-transition: .4s;
407
transition: .4s;
408
}
409
-
410
.slider:before {
411
position: absolute;
412
content: "";
413
- height: 26px;
414
- width: 26px;
415
left: 4px;
416
bottom: 4px;
417
background-color: white;
@@ -907,7 +916,7 @@ p.submit{
907
display: flex;
908
align-items: center;
909
top: -4px;
910
- width: 107%;
911
height: 64px;
912
padding: 0 1em;
913
left: -15px;
@@ -1447,9 +1456,12 @@ p.submit{
1447
border-radius: 0.7em;
1448
}
1449
.setup_section table tbody tr:first-child th{
1450
float: left;
1451
padding: 10px 0;
1452
- font-size: 16px;
1453
font-weight: 800;
1454
}
1455
.tab-content .tab-content__wrapper .testchat{
@@ -1501,16 +1513,9 @@ p.submit{
1501
}
1502
.tab-content .as_state{
1503
display: flex;
1504
- flex-direction: row;
1505
- }
1506
- .tab-content .as_state p {
1507
- color: #525252;
1508
- font-family: "Open Sans",sans-serif;
1509
- font-size: 14px;
1510
- font-weight: 600;
1511
- line-height: 19px;
1512
- padding-left: 20px;
1513
}
1514
.tab-content .as h6{
1515
font-size: 14px;
1516
font-weight: bold;
@@ -1667,18 +1672,10 @@ p.submit{
1667
}
1668
.contact_head__wrap .download__wrap{
1669
position: relative;
1670
- width: 70%;
1671
height: 100%;
1672
text-align: right;
1673
}
1674
- .billing-modal-header__plan-price p:before {
1675
- border-bottom: 3px solid red;
1676
- position: absolute;
1677
- content: "";
1678
- width: 80%;
1679
- left: 23px;
1680
- height: 60%;
1681
- }
1682
.contact_head__wrap .pro_button__wrapper{
1683
display: flex;
1684
align-items: center;
@@ -1878,11 +1875,17 @@ p.submit{
1878
margin-top: 15px;
1879
}
1880
.tab-content .as_state .as_text{
1881
- font-size: 16px;
1882
font-weight: 800;
1883
font-family: "Open Sans",sans-serif;
1884
letter-spacing: 0.15px;
1885
- line-height: 22px;
1886
}
1887
1888
@media (max-width: 575.98px) {
@@ -1977,8 +1980,10 @@ p.submit{
1977
}
1978
1979
1980
- @media (min-width: 1200px) {
1981
-
1982
}
1983
1984
@@ -2013,16 +2018,17 @@ p.submit{
2013
}
2014
2015
.billing-modal-header__plan-price p{
2016
- text-align: center;
2017
font-size: 23px;
2018
- position: relative;
2019
font-weight: 800;
2020
margin: 0;
2021
}
2022
.billing-modal-header__plan-price h4{
2023
font-weight: 800;
2024
text-decoration: none;
2025
- color: red;
2026
}
2027
.billing-modal-header__logo div{
2028
background-image: url("../img/monkey_head.png");
@@ -2391,4 +2397,324 @@ a.button_cancel:hover,a.button_cancel:focus,a.button_edit:focus,a.button_edit:ho
2391
align-items: center;
2392
margin-bottom: 30px;
2393
display: none;
2394
}
382
.switch {
383
position: relative;
384
display: inline-block;
385
+ width: 52px;
386
+ height: 25px;
387
margin: 0;
388
+ margin-right: 20px;
389
}
390
391
/* Hide default HTML checkbox */
394
width: 0;
395
height: 0;
396
}
397
+ .qq_label{
398
+ margin-top: 5px;
399
+ }
400
/* The slider */
401
.slider {
402
position: absolute;
409
-webkit-transition: .4s;
410
transition: .4s;
411
}
412
+ .switch__wrap{
413
+ display: flex;
414
+ margin-top: 15px;
415
+ }
416
+ .switch__wrap p{
417
+ color: #000;
418
+ }
419
.slider:before {
420
position: absolute;
421
content: "";
422
+ height: 18px;
423
+ width: 18px;
424
left: 4px;
425
bottom: 4px;
426
background-color: white;
916
display: flex;
917
align-items: center;
918
top: -4px;
919
+ width: 100%;
920
height: 64px;
921
padding: 0 1em;
922
left: -15px;
1456
border-radius: 0.7em;
1457
}
1458
.setup_section table tbody tr:first-child th{
1459
+ font-weight: 800;
1460
+ letter-spacing: 0.2px;
1461
+ line-height: 30px;
1462
float: left;
1463
padding: 10px 0;
1464
+ font-size: 22px;
1465
font-weight: 800;
1466
}
1467
.tab-content .tab-content__wrapper .testchat{
1513
}
1514
.tab-content .as_state{
1515
display: flex;
1516
+ flex-direction: column;
1517
}
1518
+
1519
.tab-content .as h6{
1520
font-size: 14px;
1521
font-weight: bold;
1672
}
1673
.contact_head__wrap .download__wrap{
1674
position: relative;
1675
+ width: 60%;
1676
height: 100%;
1677
text-align: right;
1678
}
1679
.contact_head__wrap .pro_button__wrapper{
1680
display: flex;
1681
align-items: center;
1875
margin-top: 15px;
1876
}
1877
.tab-content .as_state .as_text{
1878
+ font-size: 22px;
1879
font-weight: 800;
1880
+ line-height: 30px;
1881
font-family: "Open Sans",sans-serif;
1882
letter-spacing: 0.15px;
1883
+ color: #525252;
1884
+ text-transform: uppercase;
1885
+ }
1886
+
1887
+ .tab-content .form-table td .qual_p{
1888
+ margin: 20px 0 30px 0;
1889
}
1890
1891
@media (max-width: 575.98px) {
1980
}
1981
1982
1983
+ @media (min-width: 1800px) {
1984
+ .main-question{
1985
+ width: 800px!important;
1986
+ }
1987
}
1988
1989
2018
}
2019
2020
.billing-modal-header__plan-price p{
2021
font-size: 23px;
2022
+ text-decoration: line-through red;
2023
font-weight: 800;
2024
margin: 0;
2025
+ text-align: center;
2026
+ font-weight: 200;
2027
}
2028
.billing-modal-header__plan-price h4{
2029
font-weight: 800;
2030
text-decoration: none;
2031
+ color: #FF7140;
2032
}
2033
.billing-modal-header__logo div{
2034
background-image: url("../img/monkey_head.png");
2397
align-items: center;
2398
margin-bottom: 30px;
2399
display: none;
2400
+ }
2401
+ .row .col.s12 .questions-wrapper {
2402
+ width: 100%;
2403
+ margin: 0 auto;
2404
+ padding: 0;
2405
+ }
2406
+ .question-block__wrapper {
2407
+ float: left;
2408
+ width: 100%;
2409
+ box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2410
+ border-radius: 9px;
2411
+ margin: 0 0 20px auto;
2412
+ }
2413
+ .question-button__add{
2414
+ cursor: pointer;
2415
+ margin: 1rem 0 3rem 0;
2416
+ display: inline-block
2417
+ }
2418
+ .question-block__header {
2419
+ display: flex;
2420
+ justify-content: space-between;
2421
+ padding: 10px 20px;
2422
+ border-bottom: 1px solid #e4e4e4;
2423
+ align-items: center;
2424
+ }
2425
+ .question-block__header .header__title {
2426
+ display: flex;
2427
+ flex-direction: column;
2428
+ text-align: center;
2429
+ }
2430
+ .question-block_content .question-input__wrapper{
2431
+ padding: 0;
2432
+ }
2433
+ .question-block_content{
2434
+ display: flex;
2435
+ flex-direction: column;
2436
+ position: relative;
2437
+ }
2438
+ .question-input__wrapper,
2439
+ .answer-input__wrapper {
2440
+ background-color: #E5E5E5;
2441
+ padding: 20px 20px 0 20px;
2442
+ border-radius: 9px;
2443
+ }
2444
+ .question-input__wrapper{
2445
+ margin: 10px 10px 10px 55px;
2446
+ }
2447
+ .question-input__item input[type=text]:not(.browser-default):focus:not([readonly]),
2448
+ .answer-input__item input[type=text]:not(.browser-default):focus:not([readonly]){
2449
+ border: none;
2450
+ box-shadow: none;
2451
+ }
2452
+ .answer-input__wrapper{
2453
+ box-shadow: 0 0 8px -1px rgba(82,82,82,1);
2454
+ z-index: 9;
2455
+ }
2456
+ .answer-input__wrapper .answer-input__item input[type=text]:not(.browser-default){
2457
+ margin:10px 10px 10px 0 ;
2458
+ width: 100%;
2459
+ }
2460
+ .question-input__item input[type=text]:not(.browser-default),
2461
+ .answer-input__item input[type=text]:not(.browser-default) {
2462
+ margin: 10px 20px;
2463
+ box-sizing: border-box;
2464
+ padding: 10px 25px;
2465
+ width: calc(100% - 40px);
2466
+ border:none;
2467
+ border-radius: 9px;
2468
+ background: #FFFFFF;
2469
+ }
2470
+ .answer-input__item{
2471
+ display: inline-block;
2472
+ }
2473
+ .tab-content .form-table td .answer-input__item p {
2474
+ display: inline-block;
2475
+ color: #FFFFFF;
2476
+ font-family: "Open Sans",sans-serif;
2477
+ font-size: 13px;
2478
+ line-height: 18px;
2479
+ }
2480
+ .question_text {
2481
+ padding: 15px 25px;
2482
+ cursor: pointer;
2483
+ }
2484
+
2485
+ .question-input__state{
2486
+ color: #525252;
2487
+ }
2488
+
2489
+ .answer-input__wrapper .answer-input__state{
2490
+ padding: 10px 0 10px 20px;
2491
+ color: #fff;
2492
+ }
2493
+ .tab-content .answer-input__item input[type=checkbox] {
2494
+ background: transparent;
2495
+ border: 2px solid #fff;
2496
+ height: 20px;
2497
+ width: 20px;
2498
+ border-radius: 3px;
2499
+ }
2500
+ .tab-content .answer-input__item input[type=checkbox]:checked:before{
2501
+ margin: -2px 0 0 -3px;
2502
+ color: #fff;
2503
+ }
2504
+ .question_cancel,.answer_cancel{
2505
+ font-size: 14px;
2506
+ font-weight: 400;
2507
+ cursor: pointer;
2508
+ }
2509
+
2510
+ .question-input__state,
2511
+ .answer-input__state {
2512
+ display: flex;
2513
+ justify-content: flex-end;
2514
+ padding: 10px 20px;
2515
+ font-family: "Open Sans",sans-serif;
2516
+ font-size: 16px;
2517
+ font-weight: 800;
2518
+ line-height: 22px;
2519
+ cursor: pointer;
2520
+ }
2521
+
2522
+ .question-input__state span,
2523
+ .answer-input__state span {
2524
+ margin-left: 10px;
2525
+ }
2526
+ .answer-input__button {
2527
+ margin: 0 0 10px 20px;
2528
+ display: flex;
2529
+ flex-wrap: wrap;
2530
+ max-width: 70%;
2531
+ width: 70%;
2532
+ word-break: break-all;
2533
+ }
2534
+ .answer__bin {
2535
+ width: 25px;
2536
+ min-width: 25px;
2537
+ height: 25px;
2538
+ background-color: #e4e4e4;
2539
+ color: #9E9E9E;
2540
+ text-align: center;
2541
+ line-height: 25px;
2542
+ border-radius: 50%;
2543
+ margin-left: 5px;
2544
+ position: relative;
2545
+ }
2546
+ .main-question{
2547
+ padding: 5px;
2548
+ }
2549
+ .answer-input__block {
2550
+ display: flex;
2551
+ padding: 10px 0;
2552
+ position: relative;
2553
+ }
2554
+ .answer-item__result {
2555
+ display: block;
2556
+ color: #fff;
2557
+ border-radius: 30px;
2558
+ cursor: pointer;
2559
+ margin-right: 10px;
2560
+ margin-bottom: 20px;
2561
+ display: flex;
2562
+ justify-content: center;
2563
+ align-items: center;
2564
+ }
2565
+ .answer__result {
2566
+ padding: 10px 35px;
2567
+ display: block;
2568
+ align-self: center;
2569
+ background-color: #0e71ff;
2570
+ border-radius: 30px;
2571
+ }
2572
+ .add__answer {
2573
+ -moz-user-select: none;
2574
+ -khtml-user-select: none;
2575
+ user-select: none;
2576
+ cursor: pointer;
2577
+ padding: 10px 15px;
2578
+ display: block;
2579
+ border-radius: 30px;
2580
+ border: 1px solid #e4e4e4;
2581
+ color: #767676;
2582
+ font-family: "Open Sans", sans-serif;
2583
+ font-size: 16px;
2584
+ line-height: 22px;
2585
+ width: 150px;
2586
+ }
2587
+ .tab-content .form-table td .tooltip {
2588
+ display: none;
2589
+ position: absolute;
2590
+ background-color: #FF7140;
2591
+ border-radius: 5px;
2592
+ padding: 10px;
2593
+ font-size: 12px;
2594
+ color: #fff;
2595
+ top: 35px;
2596
+ width: 182px;
2597
+ word-break: keep-all;
2598
+ }
2599
+ .tab-content .main-question h3{
2600
+ margin: 0 1em 1em;
2601
+ }
2602
+ .answer-input__wrapper {
2603
+ display: none;
2604
+ position: absolute;
2605
+ width: 100%;
2606
+ top: 50px;
2607
+ background-color: #0e71ff;
2608
+ }
2609
+ .tab-content .notify_mode{
2610
+ color: #525252;
2611
+ font-weight: bold;
2612
+ }
2613
+
2614
+ .notify_radio__wrap input[type=radio]:checked:before {
2615
+ width: 12px;
2616
+ height: 12px;
2617
+ margin: 3px 2px 2px 2px;
2618
+ background-color: #324EF8;
2619
+ float: none;
2620
+ }
2621
+ .notify_radio__wrap {
2622
+ padding: 10px 0;
2623
+ }
2624
+ .notify_radio__wrap input[type=radio]{
2625
+ border: 2px solid #324EF8;
2626
+ height: 22px;
2627
+ width: 22px;
2628
+ vertical-align: bottom;
2629
+ }
2630
+ .email__wrap{
2631
+ display: flex;
2632
+ }
2633
+ .tab-content table .email__wrap label{
2634
+ width: 15%;
2635
+ align-self: center;
2636
+ padding: 0;
2637
+ font-weight: bold;
2638
+ }
2639
+ .question-input__wrapper .edit,.answer-item__result .edit_answer{
2640
+ display: flex;
2641
+ position: absolute;
2642
+ top: 21px;
2643
+ left: 10px;
2644
+ height: 25px;
2645
+ width: 25px;
2646
+ color: #9E9E9E;
2647
+ align-items: center;
2648
+ background-color: #E5E5E5;
2649
+ border-radius: 50px;
2650
+ justify-content: center;
2651
+ cursor: pointer;
2652
+ }
2653
+ .answer-item__result .edit_answer{
2654
+ position: static;
2655
+ margin-left: 5px;
2656
+ }
2657
+ .email_block .pro_button__wrapper{
2658
+ height: 100%;
2659
+ }
2660
+ .email_block .pro_button__wrapper .pro_button__content{
2661
+ justify-content: center;
2662
+ }
2663
+ .tab-content .email__wrap input[type=text]:not(.browser-default){
2664
+ width: 50%;
2665
+ height: 32px;
2666
+ font-size: 14px;
2667
+ }
2668
+
2669
+ .add_question{
2670
+ color: #324EF8;
2671
+ box-shadow: 0px 0px 9px -3px rgba(0,0,0,0.75);
2672
+ padding: 10px 30px;
2673
+ border-radius: 5px;
2674
+ font-family: "Open Sans",sans-serif;
2675
+ font-size: 15px;
2676
+ font-weight: 600;
2677
+ line-height: 22px;
2678
+ }
2679
+ .add_question b{
2680
+ font-size: 30px;
2681
+ vertical-align: sub;
2682
+ line-height: 0;
2683
+ font-weight: 400;
2684
+ }
2685
+ .add__answer b{
2686
+ font-size: 30px;
2687
+ font-weight: 400;
2688
+ line-height: 4px;
2689
+ vertical-align: sub;
2690
+ }
2691
+ .triangle {
2692
+ content: "";
2693
+ position: absolute;
2694
+ width: 0;
2695
+ height: 0;
2696
+ border-left: 25px solid transparent;
2697
+ border-right: 25px solid transparent;
2698
+ border-bottom: 25px solid #0e71ff;
2699
+ top: -19px;
2700
+ left: 30px;
2701
+ }
2702
+ .answer-input__add{
2703
+ margin-right: 15px;
2704
+ }
2705
+ .header__close{
2706
+ height: 25px;
2707
+ width: 25px;
2708
+ background-color: #D8D8D8;
2709
+ border-radius: 50px;
2710
+ position: relative;
2711
+ cursor: pointer;
2712
+ }
2713
+ .header__close:after {
2714
+ position: relative;
2715
+ content: "\d7";
2716
+ font-size: 27px;
2717
+ color: #525252;
2718
+ left: 5px;
2719
+ top: -5px;
2720
}
admin/assets/js/admin.js CHANGED
@@ -516,9 +516,8 @@ jQuery(document).ready(function($){
516
});
517
if (!$('#htcc_fb_as_state').prop('checked')){
518
$('.as').css({'pointer-events':'none','opacity':'0.6'});
519
if (!$('.connected-page').hasClass('pro')) {
520
- $('.as').last().find('label,input').css({'pointer-events': 'none', 'opacity': '0.6'});
521
- $('.as').last().css({'pointer-events':'all','opacity':'1'});
522
}
523
524
@@ -526,17 +525,15 @@ jQuery(document).ready(function($){
526
$('#htcc_fb_as_state').on('change', function (event) {
527
if(!$(this).prop('checked')){
528
$('.as').css({'pointer-events':'none','opacity':'0.6'});
529
- if (!$('.connected-page').hasClass('pro')) {
530
- $('.as').last().find('label,input').css({'pointer-events': 'none', 'opacity': '0.6'});
531
- $('.as').last().css({'pointer-events':'all','opacity':'1'});
532
- }
533
}else{
534
$('.as').css({'pointer-events':'all','opacity':'1'});
535
}
536
});
537
538
if ($('.bot_disabled').length>0){
539
- $('#tab-2,#tab-3,#tab-1 form').css({'pointer-events':'none','opacity':'0.6'})
540
}
541
$('h3.acc-title').on('click', function (event) {
542
if (!$(this).hasClass('open')) {
@@ -589,18 +586,21 @@ jQuery(document).ready(function($){
589
datas[id] = new Object();
590
$(this).find('input,textarea, select').each(function () {
591
var name = $(this).attr('name');
592
- if ($(this).attr('type') == 'checkbox'){
593
- datas[id][$(this).attr('id')] = $(this).prop('checked')
594
- }else if ($(this).attr('id') == "htcc-color-wp" ) {
595
- datas[id][$(this).attr('id')]=$(this).val().toUpperCase();
596
- } else {
597
- if (name.indexOf("htcc") >= 0 && name.indexOf("htcc_options") < 0){
598
- datas[id][$(this).attr('id')] = $(this).val();
599
- }
600
}
601
});
602
});
603
-
604
$('#toplevel_page_wp-chatbot ul li:not(:first-child)').each( function () {
605
$(this).on('click',function (event) {
606
event.preventDefault();
@@ -676,8 +676,10 @@ jQuery(document).ready(function($){
676
if (datas[cur_link][obj.attr('id')]!=obj.val().toUpperCase()){
677
error=true;
678
}
679
- }else {
680
if (datas[cur_link][obj.attr('id')]!=obj.val()){
681
error=true;
682
}
683
}
@@ -795,30 +797,6 @@ jQuery(document).ready(function($){
795
error = false;
796
});
797
798
- $("#reset_chatbot").on('click',function (e) {
799
- e.preventDefault();
800
- $("#mm_option").show();
801
- $('#modal-overlay').show();
802
- $('body').css({'overflow': 'hidden'});
803
- })
804
- $("#reset_bot_button").on('click',function (e) {
805
- e.preventDefault();
806
- $('div.modal_close').off('click');
807
- $('#mm_cancel').off('click');
808
- $.ajax({
809
- type: 'GET',
810
- url: ajaxurl,
811
- data: {
812
- action: 'create_bot',
813
- },
814
- dataType: 'json',
815
- success: function (data,response) {
816
- var path = location.protocol + '//' + location.host + location.pathname + '?page=wp-chatbot';
817
- window.location = path;
818
- }
819
- });
820
-
821
- })
822
$.ajax({
823
type: 'GET',
824
url: ajaxurl,
@@ -860,8 +838,11 @@ jQuery(document).ready(function($){
860
event.preventDefault();
861
let field = $(this).find('div.row');
862
let page = $('.connected-page');
863
- if (!page.hasClass('pro')){
864
- field.find('input,select').css({'pointer-event':'none'});
865
field.find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
866
}
867
},
@@ -869,8 +850,8 @@ jQuery(document).ready(function($){
869
event.preventDefault();
870
let field = $(this).find('div.row');
871
let page = $('.connected-page');
872
- if (!page.hasClass('pro')){
873
- field.find('input,select').css({'pointer-event':'none'});
874
field.find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
875
}
876
}
@@ -1004,6 +985,195 @@ jQuery(document).ready(function($){
1004
$('button').prop('disabled', false);
1005
}
1006
}
1007
1008
});
1009
516
});
517
if (!$('#htcc_fb_as_state').prop('checked')){
518
$('.as').css({'pointer-events':'none','opacity':'0.6'});
519
+ $('.questions-wrapper, .question-button__add').css({'pointer-events':'none','opacity':'0.6'});
520
if (!$('.connected-page').hasClass('pro')) {
521
}
522
523
525
$('#htcc_fb_as_state').on('change', function (event) {
526
if(!$(this).prop('checked')){
527
$('.as').css({'pointer-events':'none','opacity':'0.6'});
528
+ $('.questions-wrapper, .question-button__add').css({'pointer-events':'none','opacity':'0.6'});
529
}else{
530
+ $('.questions-wrapper, .question-button__add').css({'pointer-events':'all','opacity':'1'});
531
$('.as').css({'pointer-events':'all','opacity':'1'});
532
}
533
});
534
535
if ($('.bot_disabled').length>0){
536
+ $('#tab-2,#tab-3,#tab-1 form').css({'pointer-events':'none','opacity':'0.6'});
537
}
538
$('h3.acc-title').on('click', function (event) {
539
if (!$(this).hasClass('open')) {
586
datas[id] = new Object();
587
$(this).find('input,textarea, select').each(function () {
588
var name = $(this).attr('name');
589
+ if ($(this).attr('id') !== "qualified" ){
590
+ if ($(this).attr('type') == 'checkbox'){
591
+ datas[id][$(this).attr('id')] = $(this).prop('checked')
592
+ }else if ($(this).attr('id') == "htcc-color-wp" ) {
593
+ datas[id][$(this).attr('id')]=$(this).val().toUpperCase();
594
+ } else {
595
+ if (name){
596
+ if (name.indexOf("htcc") >= 0 && name.indexOf("htcc_options") < 0){
597
+ datas[id][$(this).attr('id')] = $(this).val();
598
+ }
599
+ }
600
+ }
601
}
602
});
603
});
604
$('#toplevel_page_wp-chatbot ul li:not(:first-child)').each( function () {
605
$(this).on('click',function (event) {
606
event.preventDefault();
676
if (datas[cur_link][obj.attr('id')]!=obj.val().toUpperCase()){
677
error=true;
678
}
679
+ }
680
+ else {
681
if (datas[cur_link][obj.attr('id')]!=obj.val()){
682
+
683
error=true;
684
}
685
}
797
error = false;
798
});
799
800
$.ajax({
801
type: 'GET',
802
url: ajaxurl,
838
event.preventDefault();
839
let field = $(this).find('div.row');
840
let page = $('.connected-page');
841
+ if (field.hasClass('as')&&!$("#htcc_fb_as_state").is(':checked')){
842
+ return;
843
+ }
844
+ if (!page.hasClass('pro')&&field.hasClass('pro')){
845
+ field.find('input,select').css({'pointer-event':'none','opacity':'0.6'});
846
field.find('.pro_button__wrapper').stop( true, false ).fadeIn( "fast" );
847
}
848
},
850
event.preventDefault();
851
let field = $(this).find('div.row');
852
let page = $('.connected-page');
853
+ if (!page.hasClass('pro')&&field.hasClass('pro')){
854
+ field.find('input,select').css({'pointer-event':'none','opacity':'0.6'});
855
field.find('.pro_button__wrapper').stop( true, false ).fadeOut('fast');
856
}
857
}
985
$('button').prop('disabled', false);
986
}
987
}
988
+ function email_recreate(lq){
989
+ $.ajax({
990
+ type: 'GET',
991
+ url: ajaxurl,
992
+ data: {
993
+ action: 'email_section',
994
+ has_lq: lq,
995
+ },
996
+ dataType: 'json',
997
+ success: function (data,response) {
998
+ $('#email_test').empty();
999
+ $('#email_test').append(data.data);
1000
+ }
1001
+ });
1002
+ }
1003
+
1004
+
1005
+ var questionState;
1006
+ $(document).on("click",".add__answer", function( event ) {
1007
+ event.preventDefault();
1008
+ var dataIndex = $(this).attr("data-index");
1009
+ var fieldsetId = $(this).parents(".main-question").find(".answer__result").last().attr("data-index");
1010
+ fieldsetId = fieldsetId?fieldsetId.replace(/[^0-9]/gi, ''):1;
1011
+ var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1012
+ if( fieldsetId == 10 ) {
1013
+ return;
1014
+ }
1015
+ var count = Number(fieldsetId) + 1;
1016
+ var newAnswer = '<div class="answer-item__result">'+
1017
+ '<span class="answer__result" data-index="'+count+'">Answer#'+count+'</span>'+
1018
+ '<div class="edit_answer" data-index="'+count+'"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="answer__bin" data-index="'+count+'"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div>';
1019
+ var newInput = '<input type="hidden" name="htcc_as_options[lq_'+mainId+'][answers'+count+'][answer]" value="Answer#'+count+'" id="htcc-answer_'+mainId+'_'+count+'">';
1020
+ var newQualified = '<input id="qualified_answer_'+mainId+'_'+count+'" name="htcc_as_options[lq_'+mainId+'][answers'+count+'][qualified]" value="0" type="hidden">';
1021
+ $(this).parents(".main-question").find(".answer-input__button").append(newAnswer);
1022
+ $(this).parents(".main-question").find(".answer-input__value").append(newInput,newQualified);
1023
+ });
1024
+
1025
+ $(document).on("click",".edit_answer, .answer__result", function( event ) {
1026
+ event.preventDefault();
1027
+ $(".answer-input__wrapper").hide();
1028
+ var dataIndex = $(this).attr("data-index");
1029
+ var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1030
+ var answerValue = $("#htcc-answer_"+mainId+"_"+dataIndex).val();
1031
+ var answerQualified = $("#main_question_"+mainId).find("#qualified_answer_"+mainId+"_"+dataIndex).val();
1032
+ if (answerQualified == 0){
1033
+ $("#main_question_"+mainId).find("#qualified").attr('checked', false).val(answerQualified);
1034
+ }else {
1035
+ $("#main_question_"+mainId).find("#qualified").attr('checked', true).val(answerQualified);
1036
+ }
1037
+ $("#main_question_"+mainId).find("#answer-state").attr("data-index", dataIndex).val(answerValue);
1038
+ if ($(this).hasClass("answer__result")){
1039
+ var left = $(this).position().left;
1040
+ var top = $(this).position().top;
1041
+ }else {
1042
+ var left = $(this).prev('.answer__result').position().left;
1043
+ var top = $(this).prev('.answer__result').position().top;
1044
+ }
1045
+ $(".answer-input__wrapper").css({top: top+58});
1046
+ $(".triangle").css({left: left+32});
1047
+ $("#main_question_"+mainId).find(".answer-input__wrapper").show();
1048
+ });
1049
+ $(document).on("click","body", function(e) {
1050
+ if(!$(event.target).closest(".answer__result,.answer-input__wrapper,.edit_answer").length){
1051
+ $(".answer-input__wrapper").hide();
1052
+ }
1053
+ });
1054
+
1055
+
1056
+
1057
+
1058
+ $(document).on("click",".answer__bin", function() {
1059
+ var dataIndex = $(this).attr("data-index");
1060
+ var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1061
+ var inputs = $(this).parents(".answer-input__block").find(".answer-input__value").find("input");
1062
+ if(inputs.length === 2) {
1063
+ if($(this).find('.tooltip').length==0){
1064
+ $('<p class="tooltip"></p>')
1065
+ .text("At least 1 answer is required for Lead Qualifier questions")
1066
+ .appendTo($(this))
1067
+ .fadeIn('fast');
1068
+ }
1069
+ return;
1070
+ }
1071
+ $(this).parents(".answer-input__block").find("#htcc-answer_"+mainId+'_'+dataIndex).remove();
1072
+ $(this).parents(".answer-input__block").find("#qualified_answer_"+mainId+'_'+dataIndex).remove();
1073
+ $(this).parent(".answer-item__result").remove();
1074
+ });
1075
+ $(document).on("mouseleave",".answer__bin", function() {
1076
+ $(this).find(".tooltip").fadeOut(300, function(){ $(this).remove();});
1077
+ });
1078
+
1079
+ $(document).on("click", ".answer_cancel", function( event ) {
1080
+ event.preventDefault();
1081
+ $(".answer-input__wrapper").hide();
1082
+ });
1083
+
1084
+ $(".add_question").on("click", function() {
1085
+ var fieldsetId = $(".question_new-wrapper").find(".main-question").last().attr("id");
1086
+ if (fieldsetId){
1087
+ fieldsetId=fieldsetId.replace(/[^0-9]/gi, '');
1088
+ var copyBlock = $(".question_new-wrapper").find(".main-question").last().clone();
1089
+ var count = Number(fieldsetId) + 1;
1090
+ copyBlock.find(".question-input__item").children("input").attr("id", "htcc-q"+count).attr("name", "htcc_as_options[lq_"+count+"][question]").val("");
1091
+ copyBlock.find(".question-input__item").children(".question_text").remove();
1092
+ copyBlock.find(".answer-input__block").find(".answer__result").text("Answer#1");
1093
+ copyBlock.find(".question-input__wrapper").css({"width":"auto"});
1094
+ copyBlock.find(".question-input__wrapper").children(".question-input__state").css({"display":"flex"});
1095
+ copyBlock.find(".answer-item__result").not(':first').remove();
1096
+ copyBlock.find(".answer-input__value").children("input").slice(2).remove();
1097
+ copyBlock.find(".answer-input__value").children("input").first().attr("id", "htcc-answer_"+count+"_1").attr('name',"htcc_as_options[lq_"+count+"][answers1][answer]").val("Answer#1");
1098
+ copyBlock.find(".answer-input__value").children("input:nth-child(2)").attr("id", "qualified_answer_"+count+"_1").attr('name',"htcc_as_options[lq_"+count+"][answers1][qualified]]").val("0");
1099
+ copyBlock.find(".question-input__wrapper").children(".question-input__item").children("#htcc-q"+count).show();
1100
+ var html = "";
1101
+ html += '<div class="main-question" id="main_question_'+count+'">';
1102
+ html += copyBlock.html();
1103
+ html += '</div>';
1104
+ $(".question_new-wrapper").append(html);
1105
+ $("#main_question_"+count).find(".question-input__item").children("#htcc-q"+count).val("New Question "+count);
1106
+ $("#main_question_"+count).children("h3").text("Question "+count);
1107
+ }else {
1108
+ fieldsetId=1;
1109
+ $(".question_new-wrapper").html('<div class="main-question" id="main_question_'+fieldsetId+'"><h3>QUESTION '+fieldsetId+'</h3><div class="question-block__wrapper"><div class="question-block__header"><div class="header__close"></div></div><div class="question-block_content"><div class="question-input__wrapper"><div class="edit"><i class="fa fa-pencil" aria-hidden="true"></i></div><div class="question-input__item"><input id="htcc-q'+fieldsetId+'" name="htcc_as_options[lq_'+fieldsetId+'][question]" value="New Question '+fieldsetId+'" type="text"></div><div class="question-input__state"><span class="question_cancel">Cancel</span><span class="question_submit">OK</span></div></div><div class="answer-input__block"><div class="answer-input__button"><div class="answer-item__result"><span class="answer__result" data-index="1">Answer#1</span><div class="edit_answer" data-index="1"><i class="fa fa-pencil" aria-hidden="true"></i></div><span class="answer__bin" data-index="1"><i class="fa fa-trash-o" aria-hidden="true"></i></span></div></div><div class="answer-input__add"><span class="add__answer" data-index="1"><b>+</b> Add answer</span></div><div class="answer-input__value"><input id="htcc-answer_'+fieldsetId+'_1" name="htcc_as_options[lq_'+fieldsetId+'][answers1][answer]" value="Answer#1" type="hidden"><input id="qualified_answer_'+fieldsetId+'_1" name="htcc_as_options[lq_'+fieldsetId+'][answers1][qualified]" value="0" type="hidden"></div><div class="answer-input__wrapper"><span class="triangle"></span><div class="answer-input__item"><input type="text" id="answer-state"><input type="checkbox" id="qualified"><p>Mark as qualified answer</p></div><div class="answer-input__state"><span class="answer_cancel">Cancel</span><span class="answer_submit">OK</span></div></div></div></div></div></div>');
1110
+ }
1111
+ email_recreate(true);
1112
+ });
1113
+
1114
+ $(document).on("click",".answer_submit", function( event ) {
1115
+ event.preventDefault();
1116
+ var mainId = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1117
+ var answerValue = $(this).parents(".main-question").find("#answer-state").val();
1118
+ var dataIndex = $(this).parents(".main-question").find("#answer-state").attr("data-index");
1119
+ var answerQualified = 0;
1120
+ if($(this).parents(".main-question").find("#qualified").is(':checked')){
1121
+ answerQualified = 1;
1122
+ }else {
1123
+ answerQualified = 0;
1124
+ }
1125
+ $(this).parents(".main-question").find("#qualified_answer_"+mainId+"_"+dataIndex).val(answerQualified);
1126
+ $("#htcc-answer_"+mainId+"_"+dataIndex).val(answerValue);
1127
+ $(this).parents(".main-question").find(".answer-input__wrapper").hide();
1128
+ $(this).parents(".main-question").find(".answer__result[data-index='"+dataIndex+"']").text(answerValue);
1129
+ });
1130
+
1131
+ $(document).on("click", ".question_submit", function() {
1132
+ var id = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1133
+ $("#htcc-q"+id).hide();
1134
+ var val = $("#htcc-q"+id).val();
1135
+ questionState = val;
1136
+ var question = '<div class="question_text">'+val+'</div>';
1137
+ $("#htcc-q"+id).parent(".question-input__item").append(question);
1138
+ $("#htcc-q"+id).parents(".question-input__wrapper").css({"width":"fit-content"});
1139
+ $(this).parents(".main-question").find(".question-input__state").hide();
1140
+ });
1141
+
1142
+ $(document).on("click", ".question_text, .edit", function() {
1143
+ var elem = $(this).parents('.question-input__wrapper').find('.question_text');
1144
+ var val = elem.text();
1145
+ questionState = val;
1146
+ elem.prev("input").val(val);
1147
+ elem.prev("input").show();
1148
+ elem.parents(".main-question").find(".question-input__wrapper").css({"width":"auto"});
1149
+ elem.parents(".main-question").find(".question-input__state").css({"display":"flex"});
1150
+ elem .parents(".main-question").find(".question_text").remove();
1151
+ });
1152
+
1153
+ $(document).on("click", ".question_cancel", function() {
1154
+ var id = $(this).parents(".main-question").attr("id").replace(/[^0-9]/gi, '');
1155
+ $("#htcc-q"+id).hide();
1156
+ questionState='';
1157
+ if (!questionState&&$("#htcc-q"+id).val()){
1158
+ questionState=$("#htcc-q"+id).val();
1159
+ }
1160
+ var question = '<div class="question_text">'+questionState+'</div>';
1161
+ $("#htcc-q"+id).parent(".question-input__item").append(question);
1162
+ $("#htcc-q"+id).parents(".question-input__wrapper").css({"width":"fit-content"});
1163
+ $("#htcc-q"+id).parents(".question-input__wrapper").find(".question-input__state").hide();
1164
+ });
1165
+
1166
+ $(document).on("click", ".header__close", function() {
1167
+ $(this).parents(".main-question").remove();
1168
+ if ($('.main-question').length){
1169
+ email_recreate(true);
1170
+ }else {
1171
+ email_recreate(false);
1172
+ }
1173
+ });
1174
+
1175
+
1176
+
1177
1178
});
1179
admin/class-htcc-admin.php CHANGED
@@ -24,6 +24,7 @@ if (!class_exists('HTCC_Admin')) :
24
private $test;
25
private $internal;
26
private $stepdis;
27
28
public function __construct()
29
{
@@ -208,8 +209,9 @@ if (!class_exists('HTCC_Admin')) :
208
add_settings_field('htcc_fb_answer1','', array($this, 'htcc_fb_answer1_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
209
add_settings_field('htcc_fb_answer2','', array($this, 'htcc_fb_answer2_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
210
add_settings_field('htcc_fb_answer3','', array($this, 'htcc_fb_answer3_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
211
- add_settings_field('htcc_fb_thank_answer', __('Thank you Message', 'wp-chatbot'), array($this, 'htcc_fb_thank_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
212
- add_settings_field('htcc_fb_email_trans', __('Email to send transcripts to<span class="pro">PRO</span>', 'wp-chatbot'), array($this, 'htcc_fb_email_trans_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
213
register_setting('htcc_as_setting_group', 'htcc_as_options', array($this, 'htcc_as_options_sanitize'));
214
215
@@ -240,7 +242,75 @@ if (!class_exists('HTCC_Admin')) :
240
?>
241
<?php
242
}
243
-
244
245
// color - next new version added ..
246
public function htcc_fb_color_cb_old()
@@ -324,11 +394,13 @@ if (!class_exists('HTCC_Admin')) :
324
?>
325
<div class="row">
326
<div class="input-field as_state col s12">
327
- <label class="switch">
328
- <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); ?>/>
329
- <span class="slider round"></span>
330
- </label>
331
<p class="as_text"><?php _e('Answering Service', 'wp-chatbot') ?></p>
332
</div>
333
</div>
334
<?php
@@ -339,7 +411,7 @@ if (!class_exists('HTCC_Admin')) :
339
?>
340
<div class="row as">
341
<div class="input-field col l12 m12">
342
- <h6><?php _e('Quick Questions', 'wp-chatbot') ?></h6>
343
<label class="gray" for="fb_answer1"><?php _e('WP-Chatbot will ask your chat users a few questions.', 'wp-chatbot') ?></label>
344
<input type="text" name="htcc_as_options[fb_answer1]" id="fb_answer1"
345
value="<?php echo esc_attr($htcc_fb_answer1['fb_answer1']) ?>">
@@ -371,49 +443,115 @@ if (!class_exists('HTCC_Admin')) :
371
</div>
372
<?php
373
}
374
- public function htcc_fb_thank_answer_cb()
375
- {
376
- $htcc_fb_thank_answer = get_option('htcc_as_options');
377
- ?>
378
- <div class="row as">
379
- <div class="input-field col l12 m12">
380
- <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>
381
- <input type="text" name="htcc_as_options[thank_message]" id="thank_message"
382
- value="<?php echo esc_attr($htcc_fb_thank_answer['thank_message']) ?>">
383
- </div>
384
- </div>
385
- <?php
386
}
387
public function htcc_fb_email_trans_cb()
388
{
389
$htcc_fb_email_trans = get_option('htcc_as_options');
390
?>
391
- <div class="row as pro">
392
<div class="input-field col l12 m12">
393
- <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>
394
- <div class="wrap__pro">
395
- <input type="text" name="htcc_as_options[email]" id="email"
396
- value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
397
- <div class="pro_button__wrapper" style="display: none">
398
- <a href="#" class="pro_button__link">
399
- <div class="pro_button">
400
- <div class="pro_button__content">
401
- <p><?php _e('Upgrade to unlock this feature') ?></p>
402
- <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
403
- </div>
404
- <div class="pro_button__action">
405
- <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
406
</div>
407
</div>
408
- </a>
409
</div>
410
- </div>
411
</div>
412
</div>
413
414
<?php
415
}
416
417
// Greeting for logged in user
418
public function htcc_fb_greeting_login_cb()
419
{
@@ -975,19 +1113,24 @@ if (!class_exists('HTCC_Admin')) :
975
$new_input[$key] = $option[$key];
976
$error_email = true;
977
}else {
978
- $new_input[$key] = sanitize_text_field($input[$key]);
979
}
980
}
981
}
982
}
983
if ($error_welcome){
984
- $this->getApi()->settingSaveError("welcome_message");
985
}
986
if ($error){
987
- $this->getApi()->settingSaveError("AS");
988
}
989
if ($error_email){
990
- $this->getApi()->settingSaveError("email");
991
}
992
return $new_input;
993
}
24
private $test;
25
private $internal;
26
private $stepdis;
27
+ private $email_block;
28
29
public function __construct()
30
{
209
add_settings_field('htcc_fb_answer1','', array($this, 'htcc_fb_answer1_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
210
add_settings_field('htcc_fb_answer2','', array($this, 'htcc_fb_answer2_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
211
add_settings_field('htcc_fb_answer3','', array($this, 'htcc_fb_answer3_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
212
+ add_settings_field('htcc_fb_question','', array($this, 'htcc_fb_question_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
213
+ add_settings_field('htcc_fb_email_trans', '', array($this, 'htcc_fb_email_trans_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
214
+ add_settings_field('htcc_fb_thank_answer', '', array($this, 'htcc_fb_thank_answer_cb'), 'htcc-as-setting-section', 'htcc_settings_as');
215
register_setting('htcc_as_setting_group', 'htcc_as_options', array($this, 'htcc_as_options_sanitize'));
216
217
242
?>
243
<?php
244
}
245
+ public function htcc_fb_question_cb(){
246
+ $htcc_as_options = get_option('htcc_as_options');
247
+ $html='';
248
+ $i=1;
249
+ $this->email_block = false;
250
+ foreach ($htcc_as_options as $key=>$value){
251
+ $span='';
252
+ $inp='';
253
+ $y=1;
254
+ if (strpos($key, 'lq_')!==false){
255
+ $this->email_block = true;
256
+ $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">';
257
+ foreach ($value as $k=>$v){
258
+ if ($k=='question'){
259
+ $html.= ' <div class="question-input__wrapper">
260
+ <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>
261
+ <div class="question-input__state">
262
+ <span class="question_cancel">Cancel</span><span class="question_submit">OK</span>
263
+ </div>
264
+ </div>';
265
+ }else{
266
+ $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>';
267
+ $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">';
268
+ $val = isset($htcc_as_options['lq_'.$i]['answers'.$y]['qualified']) ? 1 : 0;
269
+ $inp.= '<input id="qualified_answer_'.$i.'_'.$y.'" name="htcc_as_options[lq_'.$i.'][answers'.$y.'][qualified]" value="'.$val.'" type="hidden">';
270
+ $y++;
271
+ }
272
+
273
+ }
274
+ $i++;
275
+ $html.='<div class="answer-input__block">
276
+ <div class="answer-input__button">
277
+ '.$span.'
278
+ </div>
279
+ <div class="answer-input__add">
280
+ <span class="add__answer" data-index="1"><b>+</b> Add answer</span>
281
+ </div>
282
+ <div class="answer-input__value">'.$inp.'</div>
283
+ <div class="answer-input__wrapper">
284
+ <span class="triangle"></span>
285
+ <div class="answer-input__item">
286
+ <input type="text" id="answer-state">
287
+ <input type="checkbox" id="qualified">
288
+ <p>Mark as qualified answer</p>
289
+ </div>
290
+ <div class="answer-input__state">
291
+ <span class="answer_cancel">Cancel</span><span class="answer_submit">OK</span>
292
+ </div>
293
+ </div>
294
+ </div>
295
+ </div>
296
+ </div>';
297
+ $html.= '</div>';
298
+ }
299
+ }
300
+
301
+ ?>
302
+ <div class="input-field col s12 questions-wrapper">
303
+ <h3><?php _e('Lead Qualifier', 'wp-chatbot') ?></h3>
304
+ <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>
305
+ <div class="question_new-wrapper">
306
+ <?php echo $html;?>
307
+ </div>
308
+ </div>
309
+ <div class="question-button__add">
310
+ <span class="add_question"><b>+</b> Add question</span>
311
+ </div>
312
+ <?php
313
+ }
314
315
// color - next new version added ..
316
public function htcc_fb_color_cb_old()
394
?>
395
<div class="row">
396
<div class="input-field as_state col s12">
397
<p class="as_text"><?php _e('Answering Service', 'wp-chatbot') ?></p>
398
+ <div class="switch__wrap">
399
+ <label class="switch">
400
+ <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); ?>/>
401
+ <span class="slider round"></span>
402
+ </label>
403
+ </div>
404
</div>
405
</div>
406
<?php
411
?>
412
<div class="row as">
413
<div class="input-field col l12 m12">
414
+ <h3 class="qq_label"><?php _e('Quick Questions', 'wp-chatbot') ?></h3>
415
<label class="gray" for="fb_answer1"><?php _e('WP-Chatbot will ask your chat users a few questions.', 'wp-chatbot') ?></label>
416
<input type="text" name="htcc_as_options[fb_answer1]" id="fb_answer1"
417
value="<?php echo esc_attr($htcc_fb_answer1['fb_answer1']) ?>">
443
</div>
444
<?php
445
}
446
+ public function email_section(){
447
+ $htcc_fb_email_trans = get_option('htcc_as_options');
448
+ $html='';
449
+ $email = isset($htcc_fb_email_trans['email'])?$htcc_fb_email_trans['email']:'';
450
+ $state = json_decode($_GET['has_lq']);
451
+ if(isset($state)&&!$state){
452
+ $html.='<div class="input-field col l12 m12"><h3>Email to send transcripts to<span class="pro">PRO</span></h3>';
453
+ $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>';
454
+ $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>';
455
+ }else{
456
+ $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>';
457
+ $html.='<div class="wrap__pro email_block">';
458
+ $html.='<div class="notify__wrap">';
459
+ $html.='<div class="notify_radio__wrap">';
460
+ $all = $htcc_fb_email_trans['notify_mode']=='all' ? "checked" : '';
461
+ $html.='<input id="htcc_as_options[notify_mode]_1" name="htcc_as_options[notify_mode]" type="radio" value="all" '.$all.'/>';
462
+ $html.='<label for="htcc_as_options[notify_mode]_1">For all lead qualifiers</label>';
463
+ $html.='</div>';
464
+ $html.='<div class="notify_radio__wrap">';
465
+ $any = $htcc_fb_email_trans['notify_mode']=='any' ? "checked" : '';
466
+ $html.='<input id="htcc_as_options[notify_mode]_2" name="htcc_as_options[notify_mode]" type="radio" value="any" '.$any.'/>';
467
+ $html.='<label for="htcc_as_options[notify_mode]_2">For at least one lead qualifier</label>';
468
+ $html.='</div>';
469
+ $html.='</div>';
470
+ $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>';
471
+ }
472
+ wp_send_json_success($html);
473
}
474
public function htcc_fb_email_trans_cb()
475
{
476
$htcc_fb_email_trans = get_option('htcc_as_options');
477
?>
478
+ <div class="row as pro" id="email_test">
479
<div class="input-field col l12 m12">
480
+ <?php if(!$this->email_block){ ?>
481
+ <?php _e('<h3>Email to send transcripts to<span class="pro">PRO</span></h3>') ?>
482
+ <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>
483
+ <div class="wrap__pro">
484
+ <input type="text" name="htcc_as_options[email]" id="email"
485
+ value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
486
+ <div class="pro_button__wrapper" style="display: none">
487
+ <a href="#" class="pro_button__link">
488
+ <div class="pro_button">
489
+ <div class="pro_button__content">
490
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
491
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
492
+ </div>
493
+ <div class="pro_button__action">
494
+ <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
495
+ </div>
496
</div>
497
+ </a>
498
+ </div>
499
+ </div>
500
+
501
+ <?php }else{ ?>
502
+ <?php _e('<p class="notify_mode">Notify me when a user sends a qualifying answer<span class="pro">PRO</span></p>') ?>
503
+ <div class="wrap__pro email_block">
504
+ <div class="notify__wrap">
505
+ <div class="notify_radio__wrap">
506
+ <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); ?>/>
507
+ <label for="htcc_as_options[notify_mode]_1"><?php _e('For all lead qualifiers') ?></label>
508
</div>
509
+ <div class="notify_radio__wrap">
510
+ <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); ?>/>
511
+ <label for="htcc_as_options[notify_mode]_2"><?php _e('For at least one lead qualifier') ?></label>
512
+ </div>
513
+ </div>
514
+ <div class="email__wrap">
515
+ <label for="email"><?php _e('My email') ?></label>
516
+ <input type="text" name="htcc_as_options[email]" id="email" value="<?php echo esc_attr($htcc_fb_email_trans['email']) ?>">
517
+ </div>
518
+ <div class="pro_button__wrapper" style="display: none">
519
+ <a href="#" class="pro_button__link">
520
+ <div class="pro_button">
521
+ <div class="pro_button__content">
522
+ <p><?php _e('Upgrade to unlock this feature') ?></p>
523
+ <h3><?php _e('Get <b>50% off</b> when you upgrade today.') ?></h3>
524
+ </div>
525
+ <div class="pro_button__action">
526
+ <span class="pro_button_action__text"><?php _e('Upgrade') ?></span>
527
+ </div>
528
+ </div>
529
+ </a>
530
+ </div>
531
</div>
532
+ <?php } ?>
533
</div>
534
</div>
535
536
<?php
537
}
538
539
+ public function htcc_fb_thank_answer_cb()
540
+ {
541
+ $htcc_fb_thank_answer = get_option('htcc_as_options');
542
+ ?>
543
+ <div class="row as">
544
+ <div class="input-field col l12 m12">
545
+ <h3><?php _e('Thank you Message') ?></h3>
546
+ <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>
547
+ <input type="text" name="htcc_as_options[thank_message]" id="thank_message"
548
+ value="<?php echo esc_attr($htcc_fb_thank_answer['thank_message']) ?>">
549
+ </div>
550
+ </div>
551
+ <?php
552
+ }
553
+
554
+
555
// Greeting for logged in user
556
public function htcc_fb_greeting_login_cb()
557
{
1113
$new_input[$key] = $option[$key];
1114
$error_email = true;
1115
}else {
1116
+ if (strpos($key, 'lq_')!==false){
1117
+ $new_input[$key] = $value;
1118
+ }else{
1119
+ $new_input[$key] = sanitize_text_field($input[$key]);
1120
+ }
1121
}
1122
}
1123
}
1124
+
1125
}
1126
if ($error_welcome){
1127
+ $this->api->settingSaveError("welcome_message");
1128
}
1129
if ($error){
1130
+ $this->api->settingSaveError("AS");
1131
}
1132
if ($error_email){
1133
+ $this->api->settingSaveError("email");
1134
}
1135
return $new_input;
1136
}
admin/commons/ht-cc-admin-settings-form.php CHANGED
@@ -55,7 +55,6 @@ $current .= ' current';
55
<div class="mm_only_block" style="display: <?php echo $mm ?>">
56
<h6><?php _e('Changes were made to your chatbot in MobileMonkey, so the settings in WordPress are no longer up-to-date. Please go to MobileMonkey to continue making changes, or reset your chatbot in WordPress.', 'wp-chatbot') ?></h6>
57
<div class="but__wrap">
58
- <a href="#" class="reset_chatbot" id="reset_chatbot"><?php _e('Reset my chatbot') ?></a>
59
<a target="_blank" rel="noopener noreferrer"
60
href='https://app.mobilemonkey.com/chatbot-editor/<?php echo $connected_page['id'] ?>/configure/chatbot'
61
class="go_mm"><?php _e('Go to MobileMonkey') ?></a>
@@ -194,21 +193,6 @@ $current .= ' current';
194
</div>
195
</div>
196
</div>
197
- <div id="mm_option" class="modal">
198
- <div class="modal_close">X</div>
199
- <div class="mm__wrapper">
200
- <div class="mm__content">
201
- <h4><?php _e('Are you sure that you want to reset your chatbot?') ?></h4>
202
- <p><?php _e('Changes made in MobileMonkey will be lost, with no undo option.') ?></p>
203
- </div>
204
- <div class="mm__button">
205
- <a href="#" id="mm_cancel" class="gray button-close-modal"><?php _e('Cancel') ?></a>
206
- <a href="#" id="reset_bot_button" class="blues button-lazy-load"><?php _e('Reset my chatbot') ?>
207
- <div class="lazyload"></div>
208
- </a>
209
- </div>
210
- </div>
211
- </div>
212
<div class="modal-overlays" id="modal-overlay">
213
</div>
214
<div id="pro_option" class="modal">
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>
193
</div>
194
</div>
195
</div>
196
<div class="modal-overlays" id="modal-overlay">
197
</div>
198
<div id="pro_option" class="modal">
admin/settings_page.php CHANGED
@@ -46,7 +46,6 @@ $options = get_option('htcc_options');
46
}
47
}
48
if (!$mm_state){
49
- $widget = $this->api->getWidgets($activePage['remote_id']);
50
$current_welcome_message = $this->api->getWelcomeMessage($activePage['remote_id']);
51
if ($options_as['fb_welcome_message'] !== $current_welcome_message && isset($options_as['fb_welcome_message'])) {
52
$this->api->updateWelcomeMessage($options_as['fb_welcome_message'], $activePage['remote_id']);
@@ -54,7 +53,7 @@ $options = get_option('htcc_options');
54
}else {
55
delete_option('htcc_as_options');
56
}
57
- $this->api->setWidgets($options_as,$widget,$activePage['remote_id'],$update);
58
$this->api->setCustomChatSettings($activePage['remote_id'],$options_custom,$update);
59
}else {
60
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']);
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>";
inc/MobileMonkeyApi.php CHANGED
@@ -411,32 +411,7 @@ class MobileMonkeyApi
411
$ref_value = str_replace("=", "", $ref);
412
update_option('htcc_fb_ref', $ref_value);
413
update_option('htcc_fb_js_src', $custom_settings->js_src);
414
- if (!$this->mmOnlyCheck($options['fb_page_id'])){
415
- $test = $this->getWidgets($connect_response->facebook_page->remote_id);
416
- if ($test) {
417
- foreach ($test->widgets as $key => $value) {
418
- if ($value->type == "quick_question") {
419
- $key += 1;
420
- $value_new['fb_answer' . $key . ''] = $value->config->body;
421
- }
422
- if ($value->type == 'text') {
423
- $value_new['thank_message'] = $value->config->body;
424
- }
425
- if ($value->type == 'email'&&$this->getCurrentSubscription()) {
426
- $value_new['email'] = $value->config->recipient;
427
- }
428
- }
429
- }
430
- $value_new['fb_as_state'] = 0;
431
-
432
- }
433
- if ($connect_response->welcome_message||$connect_response->welcome_message=='0') {
434
- $value_new['fb_welcome_message'] = $connect_response->welcome_message;
435
- } else {
436
- $value_new['fb_welcome_message'] = '';
437
- }
438
update_option('htcc_custom_options', $custom_options);
439
- update_option('htcc_as_options', $value_new);
440
$options['fb_sdk_lang'] = $this->getLanguage($connect_response->facebook_page->remote_id);
441
update_option('htcc_options', $options);
442
$_SESSION['tab']['tab1'] = true;
@@ -446,7 +421,7 @@ class MobileMonkeyApi
446
$this->refreshSettingsPage();
447
return true;
448
}
449
-
450
}
451
452
} elseif ($connect_response->error_code) {
@@ -463,6 +438,7 @@ class MobileMonkeyApi
463
} else {
464
$this->renderNotice('API communication error. Unable to connect facebook page.');
465
}
466
}
467
return false;
468
}
@@ -483,7 +459,7 @@ class MobileMonkeyApi
483
]),
484
'method' => 'PUT',
485
];
486
- $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/answering_service?v=' . HTCC_VERSION.'.2', $args);
487
$this->ErrorHandler($response,'AS State Save','');
488
}
489
@@ -515,6 +491,7 @@ class MobileMonkeyApi
515
$options['fb_page_id'] = '';
516
$options['fb_welcome_message'] = '';
517
update_option('htcc_options', $options);
518
delete_option($this->option_prefix . 'page_info');
519
delete_option($this->option_prefix . 'account_info');
520
delete_option($this->option_prefix . 'current_subscribe');
@@ -761,109 +738,123 @@ class MobileMonkeyApi
761
]
762
];
763
764
- $response = wp_remote_get($this->getApiDomain() . 'api/wordpress_settings/answering_service?fb_page_remote_id=' . $remote_id . '&v=' . HTCC_VERSION.'.2', $args);
765
$error = $this->ErrorHandler($response,'Widget','get');
766
if ($error) {
767
$connect_response = json_decode($error);
768
- return $connect_response;
769
} else {
770
return false;
771
}
772
}
773
- public function setWidgets($options,$widgets,$page_id,$update)
774
{
775
if (!$update){
776
- if (!$options){
777
$data_widget = $this->getWidgets($page_id);
778
- if (!$data_widget) {
779
- return false;
780
- }
781
- foreach ($data_widget->widgets as $key => $value) {
782
- switch ($value->type){
783
- case 'quick_question':
784
- $key += 1;
785
- $value_new['fb_answer' . $key . ''] = $value->config->body;
786
- break;
787
- case 'text':
788
- $value_new['thank_message'] = $value->config->body;
789
- break;
790
- case 'email':
791
- if ($this->getCurrentSubscription()){
792
- $value_new['email'] = $value->config->recipient;
793
- }
794
- break;
795
}
796
}
797
- $ref_cont = $this->getBotRef($this->getActiveBotId());
798
- $ref = stristr($ref_cont->test_link, '=');
799
- $ref_value = str_replace("=", "", $ref);
800
- update_option('htcc_fb_ref', $ref_value);
801
- $value_new['fb_welcome_message'] = $this->getWelcomeMessage($page_id);
802
- $value_new['fb_as_state'] = 0;
803
- update_option('htcc_as_options', $value_new);
804
- }else {
805
- if (!$options['email']&&$this->getCurrentSubscription()){
806
- foreach ($widgets->widgets as $key=>$value){
807
- $value->type == 'email'?$options['email'] = $value->config->recipient:'';
808
- }
809
- update_option('htcc_as_options', $options);
810
}
811
}
812
-
813
}else{
814
- if (!$widgets){
815
return false;
816
}
817
-
818
- if ((float)$widgets->enabled!== (float)$options['fb_as_state']){
819
-
820
- if ($options['fb_as_state']== null || $options['fb_as_state']==0){
821
- $state = false;
822
- } else {
823
- $state = true;
824
}
825
- $this->AsStateSave($state,$page_id);
826
}
827
-
828
- foreach ($widgets->widgets as $key=>$value){
829
- switch ($value->type) {
830
- case 'quick_question':
831
- $key+=1;
832
- if ($options['fb_answer'.$key.'']!== $value->config->body){
833
- if (!isset($options['fb_answer'.$key.''])|| $options['fb_answer'.$key.''] == ''){
834
- $value_new['fb_answer' . $key . ''] = $value->config->body;
835
}
836
- $dump_value = $value;
837
- $dump_value->config->body = $options['fb_answer'.$key.''];
838
- $this->updateWidgets($dump_value);
839
}
840
- break;
841
- case 'text':
842
- if ($options['thank_message']!== $value->config->body) {
843
- if (!isset($options['thank_message'])|| $options['thank_message'] == ''){
844
- $value_new['thank_message'] = $value->config->body;
845
- }
846
- $dump_value = $value;
847
- $dump_value->config->body = $options['thank_message'];
848
- $this->updateWidgets($dump_value);
849
-
850
- }
851
- break;
852
- case 'email':
853
- if ($options['email']!== $value->config->recipient&&$this->getCurrentSubscription()) {
854
- if (!isset($options['email'])|| $options['email'] == '') {
855
- $value_new['email'] = $value->config->recipient;
856
- }
857
- $dump_value = $value;
858
- $dump_value->config->recipient = $options['email'];
859
- $this->updateWidgets($dump_value);
860
861
- }
862
- break;
863
- default:
864
- return false;
865
}
866
}
867
}
868
return true;
869
@@ -871,17 +862,17 @@ class MobileMonkeyApi
871
872
public function updateWidgets($object)
873
{
874
- $argsas = json_decode(json_encode($object->config), true);
875
$args = [
876
'timeout' => 10,
877
'headers' => [
878
'Authorization' => $this->getToken(),
879
'Content-Type' => 'application/json',
880
],
881
- 'body' => json_encode(['config' => $argsas, 'src' => $this->getSrc()]),
882
- 'method' => 'PATCH',
883
];
884
- $response = wp_remote_request($this->getApiDomain() . 'api/widgets/' . $object->id . '', $args);
885
$error = ($this->ErrorHandler($response,'Widget','put'));
886
if ($error) {
887
return $response;
@@ -909,30 +900,6 @@ class MobileMonkeyApi
909
}
910
}
911
912
- public function create_bot(){
913
- $args = [
914
- 'timeout' => 10,
915
- 'headers' => [
916
- 'Authorization' => $this->getToken(),
917
- 'Content-Type' => 'application/json; charset=utf-8',
918
- ],
919
- 'body' => json_encode([
920
- "fb_page_remote_id" => $this->getActiveRemotePageId(),
921
- "kind" => 'default_bot',
922
- "src" => $this->getSrc()
923
- ]),
924
- 'method' => 'POST',
925
- ];
926
- delete_option('htcc_custom_options');
927
- unset($_SESSION['tab'],$_SESSION['current']);
928
- $response = wp_remote_post($this->getApiDomain() . 'api/wordpress/bots?v=' . HTCC_VERSION.'.2', $args);
929
- $error = ($this->ErrorHandler($response,'New bot','create'));
930
- $return = array(
931
- 'error' => $error,
932
- 'response' => $response
933
- );
934
- wp_send_json_success($return);
935
- }
936
937
public function getEnv()
938
{
411
$ref_value = str_replace("=", "", $ref);
412
update_option('htcc_fb_ref', $ref_value);
413
update_option('htcc_fb_js_src', $custom_settings->js_src);
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;
421
$this->refreshSettingsPage();
422
return true;
423
}
424
+ return true;
425
}
426
427
} elseif ($connect_response->error_code) {
438
} else {
439
$this->renderNotice('API communication error. Unable to connect facebook page.');
440
}
441
+
442
}
443
return false;
444
}
459
]),
460
'method' => 'PUT',
461
];
462
+ $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2?v=' . HTCC_VERSION.'.2', $args);
463
$this->ErrorHandler($response,'AS State Save','');
464
}
465
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');
738
]
739
];
740
741
+ $response = wp_remote_get($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2?fb_page_remote_id=' . $remote_id . '&v=' . HTCC_VERSION.'.2', $args);
742
$error = $this->ErrorHandler($response,'Widget','get');
743
if ($error) {
744
$connect_response = json_decode($error);
745
+ foreach ($connect_response->questions as $key => $value) {
746
+ $key += 1;
747
+ $value_new['fb_answer' . $key . ''] = $value;
748
+ }
749
+ $i=1;
750
+ foreach ($connect_response->qualifiers as $key=>$value){
751
+ foreach ($value as $k=>$v){
752
+ $y=1;
753
+ if ($k == 'question'){
754
+ $value_new['lq_'.$i]['question'] = $v;
755
+ }else {
756
+ foreach ($v as $kr=>$an){
757
+ foreach ($an as $t=>$a){
758
+ if ($t == 'answer'){
759
+ $value_new['lq_'.$i]['answers'.$y]['answer'] = $a;
760
+ }else {
761
+ $value_new['lq_'.$i]['answers'.$y]['qualified'] = $a;
762
+ }
763
+ }
764
+ $y++;
765
+ }
766
+ }
767
+ }
768
+ $i++;
769
+ }
770
+ $value_new['notify_mode'] = $connect_response->notify_mode;
771
+ $value_new['fb_welcome_message'] = $this->getWelcomeMessage($remote_id);
772
+ $value_new['thank_message'] = $connect_response->thank_you_message;
773
+ $value_new['email'] = $connect_response->notify_email;
774
+ $value_new['fb_as_state'] = 0;
775
+ return $value_new;
776
} else {
777
return false;
778
}
779
}
780
+ public function setWidgets($options,$page_id,$update)
781
{
782
+ $var = true;
783
if (!$update){
784
+ if (count($options,COUNT_NORMAL)==1 && $options['fb_welcome_message']||!$options) {
785
$data_widget = $this->getWidgets($page_id);
786
+ foreach ($data_widget as $key=>$value){
787
+ if (strpos($key, 'lq_')!==false){
788
+ $var=false;
789
}
790
}
791
+ if ($var){
792
+ $data_widget['lq_1']['question'] = 'What is your budget?';
793
+ $data_widget['lq_1']['answers1']['answer'] = '$0';
794
+ $data_widget['lq_1']['answers2']['answer'] = '$1-$99';
795
+ $data_widget['lq_1']['answers3']['answer'] = '$100-$500';
796
+ $data_widget['lq_1']['answers4']['answer'] = '$500+';
797
+ $data_widget['lq_1']['answers4']['qualified'] = '1';
798
}
799
+ update_option('htcc_as_options', $data_widget);
800
}
801
}else{
802
+ $data_widget = $this->getWidgets($page_id);
803
+ if (!$data_widget){
804
return false;
805
}
806
+ if ($options['fb_as_state']== null || $options['fb_as_state']==0){
807
+ $value_new['enabled'] = false;
808
+ } else {
809
+ $value_new['enabled'] = true;
810
+ }
811
+ $i=0;
812
+ foreach ($data_widget as $key=>$value){
813
+ if (strpos($key, 'fb_answer')!==false){
814
+ $i += 1;
815
+ $value_new['questions'][] = $options['fb_answer'.$i.''];
816
}
817
}
818
+ foreach ($options as $key=>$value){
819
+ if (strpos($key, 'lq_')!==false){
820
+ $answer = array();
821
+ $question = '';
822
+ foreach ($value as $k=>$v){
823
+ if ($k=='question'&&!empty($v)){
824
+ $question = $v;
825
+ }else{
826
+ if(!empty($v['answer'])){
827
+ if (!ctype_space($v['answer'])){
828
+ $answer[]=array('answer'=>$v['answer'],'qualified'=> (bool)$v['qualified']);
829
+ }
830
+ }else{
831
+ $error_lenght = true;
832
}
833
}
834
+ }
835
+ $value_new["qualifiers"][]=[
836
+ "question"=>$question,
837
+ "answers"=>$answer
838
+ ];
839
840
}
841
}
842
+ if ($error_lenght){
843
+ $this->settingSaveError("AS");
844
+ echo "<style>.settings-error{display: none}</style>";
845
+ }
846
+ if (!isset($value_new["qualifiers"])){
847
+ $value_new["qualifiers"]=[];
848
+ }
849
+ $value_new["notify_email"]= $options["email"];
850
+ $value_new["notify_mode"]= $options['notify_mode'];
851
+ $value_new['thank_you_message'] = $options['thank_message'];
852
+ $value_new['fb_page_remote_id'] = $this->getActiveRemotePageId();
853
+ $this->updateWidgets($value_new);
854
+ $data_widget2 = $this->getWidgets($page_id);
855
+ $data_widget2['fb_as_state'] = $value_new['enabled'];
856
+ update_option('htcc_as_options', $data_widget2);
857
+
858
}
859
return true;
860
862
863
public function updateWidgets($object)
864
{
865
$args = [
866
'timeout' => 10,
867
'headers' => [
868
'Authorization' => $this->getToken(),
869
'Content-Type' => 'application/json',
870
],
871
+ 'body' => json_encode($object),
872
+
873
+ 'method' => 'PUT',
874
];
875
+ $response = wp_remote_request($this->getApiDomain() . 'api/wordpress_settings/answering_service_v2', $args);
876
$error = ($this->ErrorHandler($response,'Widget','put'));
877
if ($error) {
878
return $response;
900
}
901
}
902
903
904
public function getEnv()
905
{
readme.txt CHANGED
@@ -3,7 +3,7 @@ Requires at least: 4.6
3
Tested up to: 5.2
4
Requires PHP: 5.6
5
Contributors: larrykim, yankovski
6
- Stable tag: 4.1.3
7
Tags: messenger, customer chat plugin, customer chat, facebook customer chat, facebook chat, chatbot, messenger chatbot, messenger customer chat, facebook live chat, live chat, messenger live chat, facebook, facebook messenger, mobilemonkey
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
@@ -578,8 +578,11 @@ WP-Chatbot is extremely flexible, versatile, and compatible. Because it works se
578
579
== Changelog ==
580
581
= 4.1.3 =
582
- Added ability to upgrade to Pro
583
584
= 4.1.2 =
585
New Horizontal Tab Design & Removing chat-widget on page disconnecting
3
Tested up to: 5.2
4
Requires PHP: 5.6
5
Contributors: larrykim, yankovski
6
+ Stable tag: 4.1.4
7
Tags: messenger, customer chat plugin, customer chat, facebook customer chat, facebook chat, chatbot, messenger chatbot, messenger customer chat, facebook live chat, live chat, messenger live chat, facebook, facebook messenger, mobilemonkey
8
License: GPLv2 or later
9
License URI: https://www.gnu.org/licenses/gpl-2.0.html
578
579
== Changelog ==
580
581
+ = 4.1.4 =
582
+ Added the ability to use Lead Qualifier
583
+
584
= 4.1.3 =
585
+ Added Pro features
586
587
= 4.1.2 =
588
New Horizontal Tab Design & Removing chat-widget on page disconnecting
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.3
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.3' );
21
}
22
23
3
Plugin Name: WP Chatbot
4
Plugin URI: https://mobilemonkey.com/wp-chatbot/
5
Description: Add Messenger to your website, Chatbot or live Chat using Facebook Messenger
6
+ Version: 4.1.4
7
Author: MobileMonkey
8
Author URI: https://mobilemonkey.com/wp-chatbot/
9
License: GPL2
17
18
// Version - define HTCC_VERSION
19
if ( ! defined( 'HTCC_VERSION' ) ) {
20
+ define( 'HTCC_VERSION', '4.1.4' );
21
}
22
23