Advanced Shipment Tracking for WooCommerce - Version 1.9.7

Version Description

  • Updated add and edit custom shipping provider design
  • Change shipping provider name from DHL Logistics to DHL Parcel
  • Bug fixed - Sorting companies by country instead of country code
  • Added option to search by country in providers dropdown in order page
  • Remove tracking info to display from processing order,cancel order, refund order and on hold order.
  • Added functionality for customize Delivered order status email into customizer
  • Removed WooCommerce default email fro Delivered order status email
  • Changed URL of StarTrack shipping provider
  • In tracking info display customizer change preview order defaut test from 'Mockup order' to 'Select order to preview'
  • Added functionality for remove white space from tracking number when added in order
Download this release

Release Info

Developer zorem
Plugin Icon 128x128 Advanced Shipment Tracking for WooCommerce
Version 1.9.7
Comparing to
See all releases

Code changes from version 1.9.5 to 1.9.7

assets/css/admin.css CHANGED
@@ -511,14 +511,7 @@ td.column-columnname.url-column {
511
  cursor: pointer;
512
  color: #777;
513
  text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
514
- font-size: 19px;
515
- /*background: #ffffff;
516
- background: -moz-linear-gradient(top, #ffffff 1%, #eaeaea 100%);
517
- background: -webkit-gradient(linear, left top, left bottom, color-stop(1%,#ffffff), color-stop(100%,#eaeaea));
518
- background: -webkit-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
519
- background: -o-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
520
- background: -ms-linear-gradient(top, #ffffff 1%,#eaeaea 100%);
521
- background: linear-gradient(top, #ffffff 1%,#eaeaea 100%);*/
522
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eaeaea',GradientType=0 );
523
  box-shadow:
524
  0px 0px 0px 1px rgba(155,155,155,0.3),
@@ -531,31 +524,7 @@ td.column-columnname.url-column {
531
  .ac-container label.headig_label.disable{
532
  background: #f9f9f9;
533
  }
534
- /*.ac-container label.headig_label:hover{
535
- background: #fff;
536
- }*/
537
- /*.ac-container input:checked + label.headig_label,
538
- .ac-container input:checked + label.headig_label:hover{
539
- background: #e5e5e5;
540
- color: #3e3c3c;
541
- text-shadow: 0px 1px 1px rgba(255,255,255, 0.6);
542
- box-shadow:
543
- 0px 0px 0px 1px rgba(155,155,155,0.3),
544
- 0px 2px 2px rgba(0,0,0,0.1);
545
- }*/
546
- .ac-container label.headig_label:hover:after,
547
- .ac-container input:checked + label.headig_label:hover:after{
548
- content: '';
549
- position: absolute;
550
- width: 24px;
551
- height: 24px;
552
- right: 13px;
553
- top: 15px;
554
- background: transparent url(../images/arrow_down.png) no-repeat center center;
555
- }
556
- .ac-container input:checked + label.headig_label:hover:after{
557
- background-image: url(../images/arrow_up.png);
558
- }
559
  .ac-container input.accordion-radio{
560
  display: none;
561
  }
@@ -563,7 +532,8 @@ td.column-columnname.url-column {
563
  background: rgba(255, 255, 255, 0.5);
564
  margin-top: -1px;
565
  overflow: hidden;
566
- height: 0px;
 
567
  position: relative;
568
  z-index: 10;
569
  -webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
@@ -572,14 +542,6 @@ td.column-columnname.url-column {
572
  -ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
573
  transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
574
  }
575
- .ac-container article table.form-table{
576
- width: 65%;
577
- float: left;
578
- }
579
- .ac-container article .variable_div {
580
- width: 30%;
581
- float: right;
582
- }
583
  .ac-container input:checked ~ article{
584
  -webkit-transition: height 0.5s ease-in-out, box-shadow 0.1s linear;
585
  -moz-transition: height 0.5s ease-in-out, box-shadow 0.1s linear;
@@ -589,8 +551,9 @@ td.column-columnname.url-column {
589
  box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3);
590
  }
591
  .ac-container input:checked ~ article.ac-small{
592
- height: 880px;
593
  overflow: auto;
 
594
  }
595
  .ac-container table.form-table td input[type=text]{
596
  width: 100%;
@@ -638,6 +601,7 @@ td.column-columnname.url-column {
638
  background: #f5f5f5;
639
  border-radius: 15px;
640
  font-size: 12px;
 
641
  }
642
  .variable_div div.variable_tag span.copy{
643
  color: #fff;
@@ -667,14 +631,6 @@ td.column-columnname.url-column {
667
  .hide_default,.wp-core-ui .button-primary.hide_default{
668
  display:none;
669
  }
670
- #add_new_status_email_form .form-table{
671
- width: 65%;
672
- float: left;
673
- }
674
- #add_new_status_email_form .variable_div{
675
- width: 30%;
676
- float: right;
677
- }
678
  .woocommerce #add_new_status_email_form table.form-table select{
679
  width:100%;
680
  }
@@ -718,45 +674,69 @@ span.email_status_span i.enable{
718
  .woocommerce .zorem_admin_layout table.form-table th{
719
  width: 30%;
720
  }
721
- .label_content{
722
- font-weight: 600;
723
- padding: 12px;
724
  }
725
- .ac-container article .variable_div.variable_before_content{
726
- display:none;
 
 
727
  }
728
- #add_new_status_email_form .variable_div.variable_before_content{
729
- display:none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  }
731
- @media screen and (max-width: 1260px) and (min-width: 1151px){
732
- .ac-container article .variable_div{
733
- display:none;
734
- }
735
- #add_new_status_email_form .variable_div{
736
- display:none !important;
737
- }
738
- .ac-container article .variable_div.variable_before_content{
739
- display:block;
740
- }
741
- #add_new_status_email_form .variable_div.variable_before_content{
742
- display:block !important;
743
- }
744
- .ac-container article .variable_div.variable_before_content{
745
- width: 625px;
746
- float: none;
747
- padding: 12px;
748
- }
749
- #add_new_status_email_form .variable_div.variable_before_content{
750
- width: 625px;
751
- float: none;
752
- }
753
- .ac-small .form-table .wp-editor-wrap,#add_new_status_email_form .form-table .wp-editor-wrap{
754
- width: 625px;
755
- }
756
- .ac-container input:checked ~ article.ac-small{
757
- height: 990px;
758
- }
759
- }
760
  @media screen and (max-width: 1150px) {
761
  .zorem_admin_layout {
762
  display: block;
@@ -764,26 +744,16 @@ span.email_status_span i.enable{
764
  .zorem_admin_sidebar {
765
  width: auto;
766
  display: block;
 
 
 
 
 
767
  }
768
- #add_new_status_email_form .variable_div{
769
- display:none !important;
770
- }
771
- #add_new_status_email_form .variable_div.variable_before_content{
772
- display:block !important;
773
- }
774
- .ac-container article .variable_div.variable_before_content{
775
- display:block;
776
- }
777
- .ac-container article .variable_div.variable_before_content,#add_new_status_email_form .variable_div.variable_before_content{
778
- width: 625px;
779
- float: none;
780
- padding: 12px;
781
- }
782
- .ac-small .form-table .wp-editor-wrap,#add_new_status_email_form .form-table .wp-editor-wrap{
783
- width: 625px;
784
  }
785
  }
786
-
787
  @media screen and (max-width: 650px) {
788
  label.tab_label:before {
789
  margin: 0;
@@ -795,4 +765,4 @@ span.email_status_span i.enable{
795
  label.tab_label {
796
  padding: 15px;
797
  }
798
- }
511
  cursor: pointer;
512
  color: #777;
513
  text-shadow: 1px 1px 1px rgba(255,255,255,0.8);
514
+ font-size: 16px;
 
 
 
 
 
 
 
515
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#eaeaea',GradientType=0 );
516
  box-shadow:
517
  0px 0px 0px 1px rgba(155,155,155,0.3),
524
  .ac-container label.headig_label.disable{
525
  background: #f9f9f9;
526
  }
527
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
528
  .ac-container input.accordion-radio{
529
  display: none;
530
  }
532
  background: rgba(255, 255, 255, 0.5);
533
  margin-top: -1px;
534
  overflow: hidden;
535
+ /*height: 0px;*/
536
+ display:none;
537
  position: relative;
538
  z-index: 10;
539
  -webkit-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
542
  -ms-transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
543
  transition: height 0.3s ease-in-out, box-shadow 0.6s linear;
544
  }
 
 
 
 
 
 
 
 
545
  .ac-container input:checked ~ article{
546
  -webkit-transition: height 0.5s ease-in-out, box-shadow 0.1s linear;
547
  -moz-transition: height 0.5s ease-in-out, box-shadow 0.1s linear;
551
  box-shadow: 0px 0px 0px 1px rgba(155,155,155,0.3);
552
  }
553
  .ac-container input:checked ~ article.ac-small{
554
+ /*height: 880px;*/
555
  overflow: auto;
556
+ display:block;
557
  }
558
  .ac-container table.form-table td input[type=text]{
559
  width: 100%;
601
  background: #f5f5f5;
602
  border-radius: 15px;
603
  font-size: 12px;
604
+ text-align:center;
605
  }
606
  .variable_div div.variable_tag span.copy{
607
  color: #fff;
631
  .hide_default,.wp-core-ui .button-primary.hide_default{
632
  display:none;
633
  }
 
 
 
 
 
 
 
 
634
  .woocommerce #add_new_status_email_form table.form-table select{
635
  width:100%;
636
  }
674
  .woocommerce .zorem_admin_layout table.form-table th{
675
  width: 30%;
676
  }
677
+ .woocommerce .zorem_admin_layout #content5 table.form-table th{
678
+ width:200px;
 
679
  }
680
+
681
+
682
+ .shipping_provider_table .tr_add input[type=text]{
683
+ width: 40%;
684
  }
685
+ .shipping_provider_table .tr_add .select2-container{
686
+ width: 40% !important;
687
+ }
688
+ .provider_tr.tr_add td:last-child{
689
+ text-align: left;
690
+ }
691
+ .shipping_provider_table a.remove{
692
+ line-height: 32px;
693
+ }
694
+ .custom_provider_table{
695
+ border-spacing: 0;
696
+ border: 0;
697
+ }
698
+ .custom_provider_table tr td{
699
+ border: 0 !important;
700
+ }
701
+ .provider_tr .on_edit_show td{
702
+ text-align: left;
703
+ }
704
+ .shipping_provider_table .on_edit_show input[type=text]{
705
+ width: 40%;
706
+ margin-bottom: 10px;
707
+ }
708
+ .shipping_provider_table .on_edit_show .select2-container{
709
+ width: 40% !important;
710
+ margin-bottom: 15px;
711
+ }
712
+ .shipping_provider_table .on_edit_show .custom_provider_country{
713
+ width: 40% !important;
714
+ margin-bottom: 10px;
715
+ }
716
+ .shipping_provider_table .on_edit_show{
717
+ text-align: left !important;
718
+ padding:16px 20px;
719
+ }
720
+ .select2-results .select2-results__group, .select2-results .select2-results__option{
721
+ padding: 4px;
722
+ }
723
+ a.cancel_edit {
724
+ line-height: 32px;
725
+ padding: 2px 4px;
726
+ }
727
+ .email_status_span{
728
+ float: right;
729
+ }
730
+ .edit_customizer_a{
731
+ float: right;
732
+ margin-right: 10px;
733
+ line-height: 20px;
734
+ }
735
+ @media screen and (max-width: 780px) {
736
+ .woocommerce .zorem_admin_layout #content5 table.form-table th{
737
+ width:100%;
738
+ }
739
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
740
  @media screen and (max-width: 1150px) {
741
  .zorem_admin_layout {
742
  display: block;
744
  .zorem_admin_sidebar {
745
  width: auto;
746
  display: block;
747
+ }
748
+ }
749
+ @media screen and (min-width: 1000px) {
750
+ .woocommerce #add_new_status_email_form table.form-table input[type=text],.ac-container table.form-table td input[type=text]{
751
+ width: 60%;
752
  }
753
+ .woocommerce #add_new_status_email_form table.form-table select,.ac-container table.form-table td select{
754
+ width: 60%;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
755
  }
756
  }
 
757
  @media screen and (max-width: 650px) {
758
  label.tab_label:before {
759
  margin: 0;
765
  label.tab_label {
766
  padding: 15px;
767
  }
768
+ }
assets/css/customizer-styles.css ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #accordion-section-default_controls_section>h3:before{
2
+ font-family: 'Dashicons';
3
+ font-size: 20px;
4
+ font-weight: thin !important;
5
+ position: relative;
6
+ line-height: 0;
7
+ vertical-align: middle;
8
+ opacity: .6;
9
+ top: -1px;
10
+ content: "\f230";
11
+ }
12
+
13
+ #accordion-section-email_controls_section>h3:before{
14
+ font-family: 'Dashicons';
15
+ font-size: 20px;
16
+ font-weight: thin !important;
17
+ position: relative;
18
+ line-height: 0;
19
+ vertical-align: middle;
20
+ opacity: .6;
21
+ top: -1px;
22
+ content: "\f465";
23
+ }
24
+
25
+ /* Mobile preview */
26
+ .preview-mobile #customize-preview iframe {
27
+ width:606px;
28
+ height: 1500px;
29
+ -ms-transform: scale(0.50);
30
+ -moz-transform: scale(0.50);
31
+ -o-transform: scale(0.50);
32
+ -webkit-transform: scale(0.50);
33
+ transform: scale(0.50);
34
+ -ms-transform-origin: 0 0;
35
+ -moz-transform-origin: 0 0;
36
+ -o-transform-origin: 0 0;
37
+ -webkit-transform-origin: 0 0;
38
+ transform-origin: 0 0;
39
+ }
40
+ .preview-mobile .wp-full-overlay-main {
41
+ overflow-y:scroll;
42
+ overflow-x:auto;
43
+ }
44
+
45
+ /* Template Control */
46
+ .customize-control-kwdtemplateload .image-radio-select label {
47
+ display: block;
48
+ height: auto;
49
+ float: none;
50
+ width: 100%;
51
+ margin-bottom: 8px;
52
+ padding: 8px 8px 0;
53
+ box-shadow: none;
54
+ box-sizing: border-box;
55
+ }
56
+ #customize-controls .customize-control-kwdtemplateload label img {
57
+ border: 4px solid #ccc;
58
+ box-sizing: border-box;
59
+ cursor: pointer;
60
+ height: auto;
61
+ max-width: 100%;
62
+ padding: 1px;
63
+ }
64
+ #customize-controls .customize-control-kwdtemplateload label.ktactive img {
65
+ border-color: #00a0d2;
66
+ }
67
+ .customize-control-kwdtemplateload .kt-template-woomail-load-controls:after {
68
+ clear: both;
69
+ display: table;
70
+ content: '';
71
+ }
72
+ .customize-control code {
73
+ padding: 10px;
74
+ display: block;
75
+ background: #f9f9f9;
76
+ color: #505050;
77
+ }
78
+ #customize-controls li.customize-control h3{
79
+ margin-top: 4px;
80
+ }
assets/css/customizer.css ADDED
@@ -0,0 +1,632 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ==========================================================================
2
+ CSS for Customizer Custom Controls
3
+ ========================================================================== */
4
+
5
+ /* ==========================================================================
6
+ Standard Selection
7
+ ========================================================================== */
8
+ .customize-control select,
9
+ .select2-container--default .selection .select2-selection--single {
10
+ border: none;
11
+ background: #fcfcff;
12
+ position: relative;
13
+ border-radius: 0;
14
+ height: 27px;
15
+ line-height: 27px;
16
+ outline: none;
17
+ -webkit-box-shadow: none;
18
+ box-shadow: none;
19
+ }
20
+
21
+ .wp-customizer .select2-container--default .selection .select2-selection--multiple {
22
+ border: none;
23
+ background: #fcfcff;
24
+ border-radius: 0;
25
+ height: auto;
26
+ outline: none;
27
+ -webkit-box-shadow: none;
28
+ box-shadow: none;
29
+ }
30
+
31
+ .wp-customizer .select2-container--default .select2-selection--multiple .select2-selection__rendered {
32
+ width: 95%;
33
+ }
34
+
35
+ .wp-customizer .select2-container--default .select2-selection--multiple .select2-selection__clear {
36
+ position: absolute;
37
+ right: 0;
38
+ }
39
+
40
+ .wp-customizer .select2-container .select2-dropdown {
41
+ z-index: 900000;
42
+ }
43
+
44
+ .customize-control select:active,
45
+ .customize-control select:focus {
46
+ outline: none;
47
+ -webkit-box-shadow: none;
48
+ box-shadow: none;
49
+ }
50
+
51
+ /* ==========================================================================
52
+ Standard Input
53
+ ========================================================================== */
54
+ input[type="text"],
55
+ input[type="number"],
56
+ input[type="url"],
57
+ input[type="email"],
58
+ input[type="date"] {
59
+ background: #fcfcff;
60
+ position: relative;
61
+ border-radius: 0;
62
+ border: 1px solid #eee;
63
+ height: 27px;
64
+ line-height: 27px;
65
+ outline: none;
66
+ -webkit-box-shadow: none;
67
+ box-shadow: none;
68
+ }
69
+
70
+ input[type="text"]:active,
71
+ input[type="text"]:focus,
72
+ input[type="number"]:active,
73
+ input[type="number"]:focus {
74
+ outline: none;
75
+ -webkit-box-shadow: none;
76
+ box-shadow: none;
77
+ }
78
+
79
+ /* ==========================================================================
80
+ Simple Notice
81
+ ========================================================================== */
82
+
83
+ .simple-notice-custom-control .customize-control-description {
84
+ line-height: 1.6
85
+ }
86
+
87
+ .simple-notice-custom-control code {
88
+ font-size: 90%;
89
+ padding: 2px 4px;
90
+ }
91
+
92
+ /* ==========================================================================
93
+ Textarea/TinyMCE
94
+ ========================================================================== */
95
+ .tinymce-control textarea {
96
+ width: 100%;
97
+ padding: 10px;
98
+ }
99
+
100
+ /* ==========================================================================
101
+ Text Radio Buttons
102
+ ========================================================================== */
103
+ .text_radio_button_control:after {
104
+ content: " ";
105
+ display: block;
106
+ clear: both;
107
+ }
108
+ .text_radio_button_control .radio-buttons {
109
+ display: inline-block;
110
+ border: 1px solid #f9f9fe;
111
+ }
112
+ .text_radio_button_control .radio-button-label {
113
+ cursor: pointer;
114
+ float: left;
115
+ }
116
+ .text_radio_button_control .radio-button-label > input {
117
+ display: none;
118
+ }
119
+ .text_radio_button_control .radio-button-label span {
120
+ cursor: pointer;
121
+ font-weight: 500;
122
+ border: 2px solid #f9f9fe;
123
+ margin: 0;
124
+ background-color: #eee;
125
+ padding: 5px 15px;
126
+ display: inline-block;
127
+ }
128
+ .text_radio_button_control .radio-button-label span:hover {
129
+ background-color: rgba(255, 255, 255, .2);
130
+ color: #2885bb;
131
+ }
132
+ .text_radio_button_control .radio-button-label > input:checked + span {
133
+ background-color: #2084bd;
134
+ color: #fff;
135
+ }
136
+ .text_radio_button_control .radio-button-label > input:checked + span:hover {
137
+ color: #fff;
138
+ }
139
+
140
+ /* ==========================================================================
141
+ Image Radio Buttons
142
+ ========================================================================== */
143
+ .image_radio_button_control .radio-button-label > input {
144
+ display: none;
145
+ }
146
+ .image_radio_button_control .radio-button-label > img {
147
+ cursor: pointer;
148
+ border: 3px solid #ddd;
149
+ }
150
+ .image_radio_button_control .radio-button-label > input:checked + img {
151
+ border: 3px solid #2885bb;
152
+ }
153
+
154
+ /* ==========================================================================
155
+ Image Checkboxes
156
+ ========================================================================== */
157
+ .image_checkbox_control .checkbox-label > input {
158
+ display: none;
159
+ }
160
+ .image_checkbox_control .checkbox-label > img {
161
+ cursor: pointer;
162
+ border: 3px solid #ddd;
163
+ }
164
+ .image_checkbox_control .checkbox-label > input:checked + img {
165
+ border: 3px solid #2885bb;
166
+ }
167
+
168
+ /* ==========================================================================
169
+ Slider
170
+ ========================================================================== */
171
+ .slider-custom-control {
172
+ margin-bottom: 30px;
173
+ }
174
+ .slider-custom-control input[type=number]::-webkit-inner-spin-button,
175
+ .slider-custom-control input[type=number]::-webkit-outer-spin-button {
176
+ -webkit-appearance: none;
177
+ margin: 0;
178
+ }
179
+ .slider-custom-control input[type=number] {
180
+ -moz-appearance: textfield;
181
+ }
182
+ .slider-custom-control .customize-control-title {
183
+ display: inline-block;
184
+ }
185
+ .slider-custom-control input[type=number] {
186
+ width: 45px;
187
+ float: right;
188
+ margin: 7px 5px 0px 5px;
189
+ }
190
+ .slider-custom-control .slider {
191
+ width: 70%;
192
+ float: left;
193
+ margin: 20px 0 10px;
194
+ }
195
+ .slider-custom-control .slider-reset {
196
+ float: right;
197
+ cursor: pointer;
198
+ }
199
+ .slider-custom-control .slider-value {
200
+ border: none;
201
+ text-align: right;
202
+ width: 50px;
203
+ margin-right: 5px;
204
+ }
205
+ .slider-custom-control .slider-value,
206
+ .slider-custom-control .slider-unit {
207
+ float: right;
208
+ }
209
+ .slider-custom-control .ui-widget.ui-widget-content {
210
+ border: 1px solid #bdc3c7;
211
+ }
212
+ .slider-custom-control .ui-corner-all,
213
+ .slider-custom-control .ui-corner-bottom,
214
+ .slider-custom-control .ui-corner-right,
215
+ .slider-custom-control .ui-corner-br {
216
+ border-bottom-right-radius: 3px;
217
+ }
218
+ .slider-custom-control .ui-corner-all,
219
+ .slider-custom-control .ui-corner-bottom,
220
+ .slider-custom-control .ui-corner-left,
221
+ .slider-custom-control .ui-corner-bl {
222
+ border-bottom-left-radius: 3px;
223
+ }
224
+ .slider-custom-control .ui-corner-all,
225
+ .slider-custom-control .ui-corner-top,
226
+ .slider-custom-control .ui-corner-right,
227
+ .slider-custom-control .ui-corner-tr {
228
+ border-top-right-radius: 3px;
229
+ }
230
+ .slider-custom-control .ui-corner-all,
231
+ .slider-custom-control .ui-corner-top,
232
+ .slider-custom-control .ui-corner-left,
233
+ .slider-custom-control .ui-corner-tl {
234
+ border-top-left-radius: 3px;
235
+ }
236
+ .slider-custom-control .ui-widget-content {
237
+ background: #bdc3c7 none repeat scroll 0 0;
238
+ color: #333;
239
+ }
240
+ .slider-custom-control .ui-slider-horizontal {
241
+ height: 5px;
242
+ }
243
+ .slider-custom-control .ui-slider {
244
+ position: relative;
245
+ text-align: left;
246
+ }
247
+ .slider-custom-control .ui-state-default,
248
+ .slider-custom-control .ui-widget-content .ui-state-default,
249
+ .slider-custom-control .ui-widget-header .ui-state-default,
250
+ .slider-custom-control .ui-button,
251
+ .slider-custom-control .ui-button.ui-state-disabled:hover,
252
+ .slider-custom-control .ui-button.ui-state-disabled:active {
253
+ background: #2885bb none repeat scroll 0 0;
254
+ border: 1px solid #2885bb;
255
+ color: #454545;
256
+ font-weight: normal;
257
+ }
258
+ .slider-custom-control .ui-slider-horizontal .ui-slider-handle {
259
+ margin-left: -7px;
260
+ top: -7px;
261
+ border-radius: 50%;
262
+ }
263
+ .slider-custom-control .ui-slider .ui-slider-handle {
264
+ cursor: pointer;
265
+ height: 18px;
266
+ position: absolute;
267
+ width: 18px;
268
+ z-index: 2;
269
+ }
270
+ .slider-custom-control .dashicons-image-rotate {
271
+ margin-top: 10px;
272
+ color: #d4d4d4;
273
+ size: 16px;
274
+ }
275
+ .slider-custom-control .dashicons-image-rotate:hover {
276
+ color: #a7a7a7;
277
+ }
278
+
279
+ /* ==========================================================================
280
+ Toggle Switch
281
+ ========================================================================== */
282
+ .toggle-switch-control .customize-control-title {
283
+ display: inline-block;
284
+ }
285
+
286
+ .toggle-switch {
287
+ position: relative;
288
+ width: 64px;
289
+ -webkit-user-select: none;
290
+ -moz-user-select: none;
291
+ -ms-user-select: none;
292
+ float: right;
293
+ }
294
+
295
+ .toggle-switch .toggle-switch-checkbox {
296
+ display: none;
297
+ }
298
+
299
+ .toggle-switch .toggle-switch-label {
300
+ display: block;
301
+ overflow: hidden;
302
+ cursor: pointer;
303
+ border: 2px solid #ddd;
304
+ border-radius: 20px;
305
+ padding: 0;
306
+ margin: 0;
307
+ }
308
+
309
+ .toggle-switch-inner {
310
+ display: block;
311
+ width: 200%;
312
+ margin-left: -100%;
313
+ transition: margin 0.3s ease-in 0s;
314
+ }
315
+
316
+ .toggle-switch-inner:before,
317
+ .toggle-switch-inner:after {
318
+ display: block;
319
+ float: left;
320
+ width: 50%;
321
+ height: 22px;
322
+ padding: 0;
323
+ line-height: 22px;
324
+ font-size: 14px;
325
+ color: white;
326
+ font-family: Trebuchet, Arial, sans-serif;
327
+ font-weight: bold;
328
+ box-sizing: border-box;
329
+ }
330
+
331
+ .toggle-switch-inner:before {
332
+ content: "ON";
333
+ padding-left: 8px;
334
+ background-color: #2885bb;
335
+ color: #FFFFFF;
336
+ }
337
+
338
+ .toggle-switch-inner:after {
339
+ content: "OFF";
340
+ padding-right: 8px;
341
+ background-color: #EEEEEE;
342
+ color: #999999;
343
+ text-align: right;
344
+ }
345
+
346
+ .toggle-switch-switch {
347
+ display: block;
348
+ width: 16px;
349
+ margin: 3px;
350
+ background: #FFFFFF;
351
+ position: absolute;
352
+ top: 0;
353
+ bottom: 0;
354
+ right: 38px;
355
+ border: 2px solid #ddd;
356
+ border-radius: 20px;
357
+ transition: all 0.3s ease-in 0s;
358
+ }
359
+
360
+ .toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-inner {
361
+ margin-left: 0;
362
+ }
363
+
364
+ .toggle-switch-checkbox:checked + .toggle-switch-label .toggle-switch-switch {
365
+ right: 0px;
366
+ }
367
+
368
+ /* ==========================================================================
369
+ Sortable Repeater
370
+ ========================================================================== */
371
+ .sortable {
372
+ list-style-type: none;
373
+ margin: 0;
374
+ padding: 0;
375
+ }
376
+ .sortable input[type="text"] {
377
+ margin: 5px 5px 5px 0;
378
+ width: 80%;
379
+ }
380
+ .sortable div {
381
+ cursor: move;
382
+ }
383
+ .customize-control-sortable-repeater-delete {
384
+ color: #d4d4d4;
385
+ }
386
+ .customize-control-sortable-repeater-delete:hover {
387
+ color: #f00;
388
+ }
389
+ .customize-control-sortable-repeater-delete .dashicons-no-alt {
390
+ text-decoration: none;
391
+ margin: 8px 0 0 0;
392
+ font-weight: 600;
393
+ }
394
+ .customize-control-sortable-repeater-delete:active,
395
+ .customize-control-sortable-repeater-delete:focus {
396
+ outline: none;
397
+ -webkit-box-shadow: none;
398
+ box-shadow: none;
399
+ }
400
+ .repeater .dashicons-sort {
401
+ margin: 8px 5px 0 5px;
402
+ color: #d4d4d4;
403
+ }
404
+ .repeater .dashicons-sort:hover {
405
+ color: #a7a7a7;
406
+ }
407
+
408
+ /* ==========================================================================
409
+ Single Accordion
410
+ ========================================================================== */
411
+ .single-accordion-toggle {
412
+ font-size: 14px;
413
+ font-weight: 600;
414
+ line-height: 24px;
415
+ padding: 10px 5px 5px 0;
416
+ cursor: pointer;
417
+ }
418
+ .accordion-icon-toggle {
419
+ font-size: 18px;
420
+ margin-left: 5px;
421
+ margin-top: 5px;
422
+ -webkit-transition: -webkit-transform 0.3s ease-in-out;
423
+ -moz-transition: -moz-transform 0.3s ease-in-out;
424
+ -o-transition: -o-transform 0.3s ease-in-out;
425
+ transition: transform 0.3s ease-in-out;
426
+ }
427
+ .single-accordion-toggle-rotate .accordion-icon-toggle {
428
+ filter: progid: DXImageTransform.Microsoft.BasicImage(rotation=-0.5);
429
+ -webkit-transform: rotate(-45deg);
430
+ -moz-transform: rotate(-45deg);
431
+ -ms-transform: rotate(-45deg);
432
+ -o-transform: rotate(-45deg);
433
+ transform: rotate(-45deg);
434
+ display: inline-block;
435
+ }
436
+ .single-accordion {
437
+ display: none;
438
+ }
439
+ .single-accordion ul {
440
+ margin: 0;
441
+ padding: 0;
442
+ }
443
+ .single-accordion li {
444
+ background-color: #e4e4e4;
445
+ color: #888;
446
+ width: 115px;
447
+ display: inline-block;
448
+ padding: 5px;
449
+ margin: 5px;
450
+ text-align: center;
451
+ }
452
+ .single-accordion li i {
453
+ margin-left: 5px;
454
+ }
455
+
456
+ /* ==========================================================================
457
+ Alpha Color Picker
458
+ ========================================================================== */
459
+ .customize-control-alpha-color .wp-picker-container .iris-picker {
460
+ border-bottom:none;
461
+ }
462
+
463
+ .customize-control-alpha-color .wp-picker-container {
464
+ max-width: 257px;
465
+ }
466
+
467
+ .customize-control-alpha-color .wp-picker-open + .wp-picker-input-wrap {
468
+ width: 100%;
469
+ }
470
+
471
+ .customize-control-alpha-color .wp-picker-input-wrap input[type="text"].wp-color-picker.alpha-color-control {
472
+ float: left;
473
+ width: 195px;
474
+ }
475
+
476
+ .customize-control-alpha-color .wp-picker-input-wrap .button {
477
+ margin-left: 0;
478
+ float: right;
479
+ }
480
+
481
+ .wp-picker-container .wp-picker-open ~ .wp-picker-holder .alpha-color-picker-container {
482
+ display: block;
483
+ }
484
+
485
+ .alpha-color-picker-container {
486
+ border: 1px solid #dfdfdf;
487
+ border-top: none;
488
+ display: none;
489
+ background: #FFF;
490
+ padding: 0 11px 10px;
491
+ position: relative;
492
+ }
493
+
494
+ .alpha-color-picker-container .ui-widget-content,
495
+ .alpha-color-picker-container .ui-widget-header,
496
+ .alpha-color-picker-wrap .ui-state-focus {
497
+ background: transparent;
498
+ border: none;
499
+ }
500
+
501
+ .alpha-color-picker-wrap a.iris-square-value:focus {
502
+ -webkit-box-shadow: none;
503
+ box-shadow: none;
504
+ }
505
+
506
+ .alpha-color-picker-container .ui-slider {
507
+ position: relative;
508
+ z-index: 1;
509
+ height: 24px;
510
+ text-align: center;
511
+ margin: 0 auto;
512
+ width: 88%;
513
+ width: calc( 100% - 28px );
514
+ }
515
+
516
+ .alpha-color-picker-container .ui-slider-handle,
517
+ .alpha-color-picker-container .ui-widget-content .ui-state-default {
518
+ color: #777;
519
+ background-color: #FFF;
520
+ text-shadow: 0 1px 0 #FFF;
521
+ text-decoration: none;
522
+ position: absolute;
523
+ z-index: 2;
524
+ box-shadow: 0 1px 2px rgba(0,0,0,0.2);
525
+ border: 1px solid #aaa;
526
+ -webkit-border-radius: 4px;
527
+ -moz-border-radius: 4px;
528
+ border-radius: 4px;
529
+ margin-top: -2px;
530
+ top: 0;
531
+ height: 26px;
532
+ width: 26px;
533
+ cursor: ew-resize;
534
+ font-size: 0;
535
+ padding: 0;
536
+ line-height: 27px;
537
+ margin-left: -14px;
538
+ }
539
+
540
+ .alpha-color-picker-container .ui-slider-handle.show-opacity {
541
+ font-size: 12px;
542
+ }
543
+
544
+ .alpha-color-picker-container .click-zone {
545
+ width: 14px;
546
+ height: 24px;
547
+ display: block;
548
+ position: absolute;
549
+ left: 10px;
550
+ }
551
+
552
+ .alpha-color-picker-container .max-click-zone {
553
+ right: 10px;
554
+ left: auto;
555
+ }
556
+
557
+ .alpha-color-picker-container .transparency {
558
+ height: 24px;
559
+ width: 100%;
560
+ background-color: #FFF;
561
+ background-image: url(../images/color-picker-transparency-grid.png);
562
+ box-shadow: 0 0 5px rgba(0,0,0,0.4) inset;
563
+ -webkit-border-radius: 3px;
564
+ -moz-border-radius: 3px;
565
+ border-radius: 3px;
566
+ padding: 0;
567
+ margin-top: -24px;
568
+ }
569
+
570
+ @media only screen and (max-width: 782px) {
571
+ .customize-control-alpha-color .wp-picker-input-wrap input[type="text"].wp-color-picker.alpha-color-control {
572
+ width: 184px;
573
+ }
574
+ }
575
+
576
+ @media only screen and (max-width: 640px) {
577
+ .customize-control-alpha-color .wp-picker-input-wrap input[type="text"].wp-color-picker.alpha-color-control {
578
+ width: 172px;
579
+ height: 33px;
580
+ }
581
+ }
582
+
583
+ /* ==========================================================================
584
+ Alpha Color Picker & Standard Color Picker
585
+ ========================================================================== */
586
+
587
+ .customize-control-color .wp-color-result:after,
588
+ .customize-control-alpha-color .wp-color-result:after {
589
+ border: none;
590
+ }
591
+
592
+ .customize-control-color .wp-color-result .wp-color-result-text,
593
+ .customize-control-alpha-color .wp-color-result .wp-color-result-text {
594
+ line-height: 24px;
595
+ border-left: none;
596
+ }
597
+
598
+ .wp-picker-holder .iris-picker .iris-palette {
599
+ box-shadow: none;
600
+ }
601
+
602
+ .wp-picker-container .iris-picker,
603
+ .wp-picker-container .alpha-color-picker-container {
604
+ border-radius: 0;
605
+ border: none;
606
+ }
607
+
608
+ .wp-picker-container .alpha-color-picker-container {
609
+ width: 233px;
610
+ }
611
+
612
+ /* ==========================================================================
613
+ Google Fonts Select
614
+ ========================================================================== */
615
+ .google_fonts_select_control .google-fonts,
616
+ .google_fonts_select_control .weight-style {
617
+ margin-bottom: 10px;
618
+ }
619
+
620
+ .control_heading{
621
+ background-color: #3D4C5A;
622
+ color: #FFF;
623
+ font-size: 120%;
624
+ font-weight: bolder;
625
+ margin-left: -20px;
626
+ margin-right: -20px;
627
+ padding: 8px 25px;
628
+ border-top: 2px solid #23282d;
629
+ text-shadow: 1px 1px 1px rgba(0,0,0,0.2);
630
+ font-size: 120%;
631
+ font-weight: bolder;
632
+ }
assets/js/admin.js CHANGED
@@ -141,4 +141,59 @@ function showerror(element){
141
  }
142
  function hideerror(element){
143
  element.css("border-color","");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  }
141
  }
142
  function hideerror(element){
143
  element.css("border-color","");
144
+ }
145
+ jQuery(document).ready(function() {
146
+ jQuery('#tracking_provider').select2({
147
+ matcher: modelMatcher
148
+ });
149
+ });
150
+ function modelMatcher (params, data) {
151
+ data.parentText = data.parentText || "";
152
+
153
+ // Always return the object if there is nothing to compare
154
+ if (jQuery.trim(params.term) === '') {
155
+ return data;
156
+ }
157
+
158
+ // Do a recursive check for options with children
159
+ if (data.children && data.children.length > 0) {
160
+ // Clone the data object if there are children
161
+ // This is required as we modify the object to remove any non-matches
162
+ var match = jQuery.extend(true, {}, data);
163
+
164
+ // Check each child of the option
165
+ for (var c = data.children.length - 1; c >= 0; c--) {
166
+ var child = data.children[c];
167
+ child.parentText += data.parentText + " " + data.text;
168
+
169
+ var matches = modelMatcher(params, child);
170
+
171
+ // If there wasn't a match, remove the object in the array
172
+ if (matches == null) {
173
+ match.children.splice(c, 1);
174
+ }
175
+ }
176
+
177
+ // If any children matched, return the new object
178
+ if (match.children.length > 0) {
179
+ return match;
180
+ }
181
+
182
+ // If there were no matching children, check just the plain object
183
+ return modelMatcher(params, match);
184
+ }
185
+
186
+ // If the typed-in term matches the text of this term, or the text from any
187
+ // parent term, then it's a match.
188
+ var original = (data.parentText + ' ' + data.text).toUpperCase();
189
+ var term = params.term.toUpperCase();
190
+
191
+
192
+ // Check if the text contains the term
193
+ if (original.indexOf(term) > -1) {
194
+ return data;
195
+ }
196
+
197
+ // If it doesn't contain the term, don't return anything
198
+ return null;
199
  }
assets/js/customizer-scripts.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Customizer Scripts
3
+ * Need to rewrite and clean up this file.
4
+ */
5
+
6
+ jQuery(document).ready(function() {
7
+
8
+ /**
9
+ * Change description
10
+ */
11
+ // jQuery('#customize-info .customize-panel-description').html(kt_woomail.labels.description);
12
+ jQuery('#accordion-section-default_controls_section h3').trigger( "click" );
13
+ jQuery('#customize-info .panel-title.site-title').html(wcast_customizer.labels.customtitle);
14
+ jQuery('#customize-theme-controls #accordion-section-themes').hide();
15
+
16
+ });
17
+ // Handle mobile button click
18
+ function custom_size_mobile() {
19
+ // get email width.
20
+ var email_width = '684';
21
+ var ratio = email_width/304;
22
+ var framescale = 100/ratio;
23
+ var framescale = framescale/100;
24
+ jQuery('#customize-preview iframe').width(email_width+'px');
25
+ jQuery('#customize-preview iframe').css({
26
+ '-webkit-transform' : 'scale(' + framescale + ')',
27
+ '-moz-transform' : 'scale(' + framescale + ')',
28
+ '-ms-transform' : 'scale(' + framescale + ')',
29
+ '-o-transform' : 'scale(' + framescale + ')',
30
+ 'transform' : 'scale(' + framescale + ')'
31
+ });
32
+ }
33
+ jQuery('#customize-footer-actions .preview-mobile').click(function(e) {
34
+ custom_size_mobile();
35
+ });
36
+ jQuery('#customize-footer-actions .preview-desktop').click(function(e) {
37
+ jQuery('#customize-preview iframe').width('100%');
38
+ jQuery('#customize-preview iframe').css({
39
+ '-webkit-transform' : 'scale(1)',
40
+ '-moz-transform' : 'scale(1)',
41
+ '-ms-transform' : 'scale(1)',
42
+ '-o-transform' : 'scale(1)',
43
+ 'transform' : 'scale(1)'
44
+ });
45
+ });
46
+ jQuery('#customize-footer-actions .preview-tablet').click(function(e) {
47
+ jQuery('#customize-preview iframe').width('100%');
48
+ jQuery('#customize-preview iframe').css({
49
+ '-webkit-transform' : 'scale(1)',
50
+ '-moz-transform' : 'scale(1)',
51
+ '-ms-transform' : 'scale(1)',
52
+ '-o-transform' : 'scale(1)',
53
+ 'transform' : 'scale(1)'
54
+ });
55
+ });
assets/js/customizer.js ADDED
@@ -0,0 +1,608 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery( document ).ready(function($) {
2
+ "use strict";
3
+
4
+ /**
5
+ * Sortable Repeater Custom Control
6
+ *
7
+ * @author Anthony Hortin <http://maddisondesigns.com>
8
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
9
+ * @link https://github.com/maddisondesigns
10
+ */
11
+
12
+ // Update the values for all our input fields and initialise the sortable repeater
13
+ $('.sortable_repeater_control').each(function() {
14
+ // If there is an existing customizer value, populate our rows
15
+ var defaultValuesArray = $(this).find('.customize-control-sortable-repeater').val().split(',');
16
+ var numRepeaterItems = defaultValuesArray.length;
17
+
18
+ if(numRepeaterItems > 0) {
19
+ // Add the first item to our existing input field
20
+ $(this).find('.repeater-input').val(defaultValuesArray[0]);
21
+ // Create a new row for each new value
22
+ if(numRepeaterItems > 1) {
23
+ var i;
24
+ for (i = 1; i < numRepeaterItems; ++i) {
25
+ skyrocketAppendRow($(this), defaultValuesArray[i]);
26
+ }
27
+ }
28
+ }
29
+ });
30
+
31
+ // Make our Repeater fields sortable
32
+ $(this).find('.sortable').sortable({
33
+ update: function(event, ui) {
34
+ skyrocketGetAllInputs($(this).parent());
35
+ }
36
+ });
37
+
38
+ // Remove item starting from it's parent element
39
+ $('.sortable').on('click', '.customize-control-sortable-repeater-delete', function(event) {
40
+ event.preventDefault();
41
+ var numItems = $(this).parent().parent().find('.repeater').length;
42
+
43
+ if(numItems > 1) {
44
+ $(this).parent().slideUp('fast', function() {
45
+ var parentContainer = $(this).parent().parent();
46
+ $(this).remove();
47
+ skyrocketGetAllInputs(parentContainer);
48
+ })
49
+ }
50
+ else {
51
+ $(this).parent().find('.repeater-input').val('');
52
+ skyrocketGetAllInputs($(this).parent().parent().parent());
53
+ }
54
+ });
55
+
56
+ // Add new item
57
+ $('.customize-control-sortable-repeater-add').click(function(event) {
58
+ event.preventDefault();
59
+ skyrocketAppendRow($(this).parent());
60
+ skyrocketGetAllInputs($(this).parent());
61
+ });
62
+
63
+ // Refresh our hidden field if any fields change
64
+ $('.sortable').change(function() {
65
+ skyrocketGetAllInputs($(this).parent());
66
+ })
67
+
68
+ // Add https:// to the start of the URL if it doesn't have it
69
+ $('.sortable').on('blur', '.repeater-input', function() {
70
+ var url = $(this);
71
+ var val = url.val();
72
+ if(val && !val.match(/^.+:\/\/.*/)) {
73
+ // Important! Make sure to trigger change event so Customizer knows it has to save the field
74
+ url.val('https://' + val).trigger('change');
75
+ }
76
+ });
77
+
78
+ // Append a new row to our list of elements
79
+ function skyrocketAppendRow($element, defaultValue = '') {
80
+ var newRow = '<div class="repeater" style="display:none"><input type="text" value="' + defaultValue + '" class="repeater-input" placeholder="https://" /><span class="dashicons dashicons-sort"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a></div>';
81
+
82
+ $element.find('.sortable').append(newRow);
83
+ $element.find('.sortable').find('.repeater:last').slideDown('slow', function(){
84
+ $(this).find('input').focus();
85
+ });
86
+ }
87
+
88
+ // Get the values from the repeater input fields and add to our hidden field
89
+ function skyrocketGetAllInputs($element) {
90
+ var inputValues = $element.find('.repeater-input').map(function() {
91
+ return $(this).val();
92
+ }).toArray();
93
+ // Add all the values from our repeater fields to the hidden field (which is the one that actually gets saved)
94
+ $element.find('.customize-control-sortable-repeater').val(inputValues);
95
+ // Important! Make sure to trigger change event so Customizer knows it has to save the field
96
+ $element.find('.customize-control-sortable-repeater').trigger('change');
97
+ }
98
+
99
+ /**
100
+ * Slider Custom Control
101
+ *
102
+ * @author Anthony Hortin <http://maddisondesigns.com>
103
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
104
+ * @link https://github.com/maddisondesigns
105
+ */
106
+
107
+ // Set our slider defaults and initialise the slider
108
+ $('.slider-custom-control').each(function(){
109
+ var sliderValue = $(this).find('.customize-control-slider-value').val();
110
+ var newSlider = $(this).find('.slider');
111
+ var sliderMinValue = parseFloat(newSlider.attr('slider-min-value'));
112
+ var sliderMaxValue = parseFloat(newSlider.attr('slider-max-value'));
113
+ var sliderStepValue = parseFloat(newSlider.attr('slider-step-value'));
114
+
115
+ newSlider.slider({
116
+ value: sliderValue,
117
+ min: sliderMinValue,
118
+ max: sliderMaxValue,
119
+ step: sliderStepValue,
120
+ change: function(e,ui){
121
+ // Important! When slider stops moving make sure to trigger change event so Customizer knows it has to save the field
122
+ $(this).parent().find('.customize-control-slider-value').trigger('change');
123
+ }
124
+ });
125
+ });
126
+
127
+ // Change the value of the input field as the slider is moved
128
+ $('.slider').on('slide', function(event, ui) {
129
+ $(this).parent().find('.customize-control-slider-value').val(ui.value);
130
+ });
131
+
132
+ // Reset slider and input field back to the default value
133
+ $('.slider-reset').on('click', function() {
134
+ var resetValue = $(this).attr('slider-reset-value');
135
+ $(this).parent().find('.customize-control-slider-value').val(resetValue);
136
+ $(this).parent().find('.slider').slider('value', resetValue);
137
+ });
138
+
139
+ // Update slider if the input field loses focus as it's most likely changed
140
+ $('.customize-control-slider-value').blur(function() {
141
+ var resetValue = $(this).val();
142
+ var slider = $(this).parent().find('.slider');
143
+ var sliderMinValue = parseInt(slider.attr('slider-min-value'));
144
+ var sliderMaxValue = parseInt(slider.attr('slider-max-value'));
145
+
146
+ // Make sure our manual input value doesn't exceed the minimum & maxmium values
147
+ if(resetValue < sliderMinValue) {
148
+ resetValue = sliderMinValue;
149
+ $(this).val(resetValue);
150
+ }
151
+ if(resetValue > sliderMaxValue) {
152
+ resetValue = sliderMaxValue;
153
+ $(this).val(resetValue);
154
+ }
155
+ $(this).parent().find('.slider').slider('value', resetValue);
156
+ });
157
+
158
+ /**
159
+ * Single Accordion Custom Control
160
+ *
161
+ * @author Anthony Hortin <http://maddisondesigns.com>
162
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
163
+ * @link https://github.com/maddisondesigns
164
+ */
165
+
166
+ $('.single-accordion-toggle').click(function() {
167
+ var $accordionToggle = $(this);
168
+ $(this).parent().find('.single-accordion').slideToggle('slow', function() {
169
+ $accordionToggle.toggleClass('single-accordion-toggle-rotate', $(this).is(':visible'));
170
+ });
171
+ });
172
+
173
+ /**
174
+ * Image Check Box Custom Control
175
+ *
176
+ * @author Anthony Hortin <http://maddisondesigns.com>
177
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
178
+ * @link https://github.com/maddisondesigns
179
+ */
180
+
181
+ $('.multi-image-checkbox').on('change', function () {
182
+ getAllCheckboxes($(this).parent().parent());
183
+ });
184
+
185
+ // Get the values from the checkboxes and add to our hidden field
186
+ function getAllCheckboxes($element) {
187
+ var inputValues = $element.find('.multi-image-checkbox').map(function() {
188
+ if( $(this).is(':checked') ) {
189
+ return $(this).val();
190
+ // } else {
191
+ // return '';
192
+ }
193
+ }).toArray();
194
+ // Important! Make sure to trigger change event so Customizer knows it has to save the field
195
+ $element.find('.customize-control-multi-image-checkbox').val(inputValues).trigger('change');
196
+ }
197
+
198
+ /**
199
+ * Dropdown Select2 Custom Control
200
+ *
201
+ * @author Anthony Hortin <http://maddisondesigns.com>
202
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
203
+ * @link https://github.com/maddisondesigns
204
+ */
205
+
206
+ $('.customize-control-dropdown-select2').each(function(){
207
+ $('.customize-control-select2').select2({
208
+ allowClear: true
209
+ });
210
+ });
211
+
212
+ $(".customize-control-select2").on("change", function() {
213
+ var select2Val = $(this).val();
214
+ $(this).parent().find('.customize-control-dropdown-select2').val(select2Val).trigger('change');
215
+ });
216
+
217
+ /**
218
+ * Googe Font Select Custom Control
219
+ *
220
+ * @author Anthony Hortin <http://maddisondesigns.com>
221
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
222
+ * @link https://github.com/maddisondesigns
223
+ */
224
+
225
+ $('.google-fonts-list').each(function (i, obj) {
226
+ if (!$(obj).hasClass('select2-hidden-accessible')) {
227
+ $(obj).select2();
228
+ }
229
+ });
230
+
231
+ $('.google-fonts-list').on('change', function() {
232
+ var elementRegularWeight = $(this).parent().parent().find('.google-fonts-regularweight-style');
233
+ var elementItalicWeight = $(this).parent().parent().find('.google-fonts-italicweight-style');
234
+ var elementBoldWeight = $(this).parent().parent().find('.google-fonts-boldweight-style');
235
+ var selectedFont = $(this).val();
236
+ var customizerControlName = $(this).attr('control-name');
237
+ var elementItalicWeightCount = 0;
238
+ var elementBoldWeightCount = 0;
239
+
240
+ // Clear Weight/Style dropdowns
241
+ elementRegularWeight.empty();
242
+ elementItalicWeight.empty();
243
+ elementBoldWeight.empty();
244
+ // Make sure Italic & Bold dropdowns are enabled
245
+ elementItalicWeight.prop('disabled', false);
246
+ elementBoldWeight.prop('disabled', false);
247
+
248
+ // Get the Google Fonts control object
249
+ var bodyfontcontrol = _wpCustomizeSettings.controls[customizerControlName];
250
+
251
+ // Find the index of the selected font
252
+ var indexes = $.map(bodyfontcontrol.skyrocketfontslist, function(obj, index) {
253
+ if(obj.family === selectedFont) {
254
+ return index;
255
+ }
256
+ });
257
+ var index = indexes[0];
258
+
259
+ // For the selected Google font show the available weight/style variants
260
+ $.each(bodyfontcontrol.skyrocketfontslist[index].variants, function(val, text) {
261
+ elementRegularWeight.append(
262
+ $('<option></option>').val(text).html(text)
263
+ );
264
+ if (text.indexOf("italic") >= 0) {
265
+ elementItalicWeight.append(
266
+ $('<option></option>').val(text).html(text)
267
+ );
268
+ elementItalicWeightCount++;
269
+ } else {
270
+ elementBoldWeight.append(
271
+ $('<option></option>').val(text).html(text)
272
+ );
273
+ elementBoldWeightCount++;
274
+ }
275
+ });
276
+
277
+ if(elementItalicWeightCount == 0) {
278
+ elementItalicWeight.append(
279
+ $('<option></option>').val('').html('Not Available for this font')
280
+ );
281
+ elementItalicWeight.prop('disabled', 'disabled');
282
+ }
283
+ if(elementBoldWeightCount == 0) {
284
+ elementBoldWeight.append(
285
+ $('<option></option>').val('').html('Not Available for this font')
286
+ );
287
+ elementBoldWeight.prop('disabled', 'disabled');
288
+ }
289
+
290
+ // Update the font category based on the selected font
291
+ $(this).parent().parent().find('.google-fonts-category').val(bodyfontcontrol.skyrocketfontslist[index].category);
292
+
293
+ skyrocketGetAllSelects($(this).parent().parent());
294
+ });
295
+
296
+ $('.google_fonts_select_control select').on('change', function() {
297
+ skyrocketGetAllSelects($(this).parent().parent());
298
+ });
299
+
300
+ function skyrocketGetAllSelects($element) {
301
+ var selectedFont = {
302
+ font: $element.find('.google-fonts-list').val(),
303
+ regularweight: $element.find('.google-fonts-regularweight-style').val(),
304
+ italicweight: $element.find('.google-fonts-italicweight-style').val(),
305
+ boldweight: $element.find('.google-fonts-boldweight-style').val(),
306
+ category: $element.find('.google-fonts-category').val()
307
+ };
308
+
309
+ // Important! Make sure to trigger change event so Customizer knows it has to save the field
310
+ $element.find('.customize-control-google-font-selection').val(JSON.stringify(selectedFont)).trigger('change');
311
+ }
312
+
313
+ /**
314
+ * TinyMCE Custom Control
315
+ *
316
+ * @author Anthony Hortin <http://maddisondesigns.com>
317
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
318
+ * @link https://github.com/maddisondesigns
319
+ */
320
+
321
+ $('.customize-control-tinymce-editor').each(function(){
322
+ // Get the toolbar strings that were passed from the PHP Class
323
+ var tinyMCEToolbar1String = _wpCustomizeSettings.controls[$(this).attr('id')].skyrockettinymcetoolbar1;
324
+ var tinyMCEToolbar2String = _wpCustomizeSettings.controls[$(this).attr('id')].skyrockettinymcetoolbar2;
325
+ var tinyMCEMediaButtons = _wpCustomizeSettings.controls[$(this).attr('id')].skyrocketmediabuttons;
326
+
327
+ wp.editor.initialize( $(this).attr('id'), {
328
+
329
+ tinymce: {
330
+ wpautop: true,
331
+ toolbar1: tinyMCEToolbar1String,
332
+ toolbar2: tinyMCEToolbar2String
333
+ },
334
+ quicktags: true,
335
+ mediaButtons: tinyMCEMediaButtons
336
+ });
337
+ });
338
+ $(document).on( 'tinymce-editor-init', function( event, editor ) {
339
+ editor.on('change', function(e) {
340
+ tinyMCE.triggerSave();
341
+ $('#'+editor.id).trigger('change');
342
+ });
343
+ });
344
+
345
+ /**
346
+ * Alpha Color Picker Custom Control
347
+ *
348
+ * @author Braad Martin <http://braadmartin.com>
349
+ * @license http://www.gnu.org/licenses/gpl-3.0.html
350
+ * @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
351
+ */
352
+
353
+ // Loop over each control and transform it into our color picker.
354
+ $( '.alpha-color-control' ).each( function() {
355
+
356
+ // Scope the vars.
357
+ var $control, startingColor, paletteInput, showOpacity, defaultColor, palette,
358
+ colorPickerOptions, $container, $alphaSlider, alphaVal, sliderOptions;
359
+
360
+ // Store the control instance.
361
+ $control = $( this );
362
+
363
+ // Get a clean starting value for the option.
364
+ startingColor = $control.val().replace( /\s+/g, '' );
365
+
366
+ // Get some data off the control.
367
+ paletteInput = $control.attr( 'data-palette' );
368
+ showOpacity = $control.attr( 'data-show-opacity' );
369
+ defaultColor = $control.attr( 'data-default-color' );
370
+
371
+ // Process the palette.
372
+ if ( paletteInput.indexOf( '|' ) !== -1 ) {
373
+ palette = paletteInput.split( '|' );
374
+ } else if ( 'false' == paletteInput ) {
375
+ palette = false;
376
+ } else {
377
+ palette = true;
378
+ }
379
+
380
+ // Set up the options that we'll pass to wpColorPicker().
381
+ colorPickerOptions = {
382
+ change: function( event, ui ) {
383
+ var key, value, alpha, $transparency;
384
+
385
+ key = $control.attr( 'data-customize-setting-link' );
386
+ value = $control.wpColorPicker( 'color' );
387
+
388
+ // Set the opacity value on the slider handle when the default color button is clicked.
389
+ if ( defaultColor == value ) {
390
+ alpha = acp_get_alpha_value_from_color( value );
391
+ $alphaSlider.find( '.ui-slider-handle' ).text( alpha );
392
+ }
393
+
394
+ // Send ajax request to wp.customize to trigger the Save action.
395
+ wp.customize( key, function( obj ) {
396
+ obj.set( value );
397
+ });
398
+
399
+ $transparency = $container.find( '.transparency' );
400
+
401
+ // Always show the background color of the opacity slider at 100% opacity.
402
+ $transparency.css( 'background-color', ui.color.toString( 'no-alpha' ) );
403
+ },
404
+ palettes: palette // Use the passed in palette.
405
+ };
406
+
407
+ // Create the colorpicker.
408
+ $control.wpColorPicker( colorPickerOptions );
409
+
410
+ $container = $control.parents( '.wp-picker-container:first' );
411
+
412
+ // Insert our opacity slider.
413
+ $( '<div class="alpha-color-picker-container">' +
414
+ '<div class="min-click-zone click-zone"></div>' +
415
+ '<div class="max-click-zone click-zone"></div>' +
416
+ '<div class="alpha-slider"></div>' +
417
+ '<div class="transparency"></div>' +
418
+ '</div>' ).appendTo( $container.find( '.wp-picker-holder' ) );
419
+
420
+ $alphaSlider = $container.find( '.alpha-slider' );
421
+
422
+ // If starting value is in format RGBa, grab the alpha channel.
423
+ alphaVal = acp_get_alpha_value_from_color( startingColor );
424
+
425
+ // Set up jQuery UI slider() options.
426
+ sliderOptions = {
427
+ create: function( event, ui ) {
428
+ var value = $( this ).slider( 'value' );
429
+
430
+ // Set up initial values.
431
+ $( this ).find( '.ui-slider-handle' ).text( value );
432
+ $( this ).siblings( '.transparency ').css( 'background-color', startingColor );
433
+ },
434
+ value: alphaVal,
435
+ range: 'max',
436
+ step: 1,
437
+ min: 0,
438
+ max: 100,
439
+ animate: 300
440
+ };
441
+
442
+ // Initialize jQuery UI slider with our options.
443
+ $alphaSlider.slider( sliderOptions );
444
+
445
+ // Maybe show the opacity on the handle.
446
+ if ( 'true' == showOpacity ) {
447
+ $alphaSlider.find( '.ui-slider-handle' ).addClass( 'show-opacity' );
448
+ }
449
+
450
+ // Bind event handlers for the click zones.
451
+ $container.find( '.min-click-zone' ).on( 'click', function() {
452
+ acp_update_alpha_value_on_color_control( 0, $control, $alphaSlider, true );
453
+ });
454
+ $container.find( '.max-click-zone' ).on( 'click', function() {
455
+ acp_update_alpha_value_on_color_control( 100, $control, $alphaSlider, true );
456
+ });
457
+
458
+ // Bind event handler for clicking on a palette color.
459
+ $container.find( '.iris-palette' ).on( 'click', function() {
460
+ var color, alpha;
461
+
462
+ color = $( this ).css( 'background-color' );
463
+ alpha = acp_get_alpha_value_from_color( color );
464
+
465
+ acp_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
466
+
467
+ // Sometimes Iris doesn't set a perfect background-color on the palette,
468
+ // for example rgba(20, 80, 100, 0.3) becomes rgba(20, 80, 100, 0.298039).
469
+ // To compensante for this we round the opacity value on RGBa colors here
470
+ // and save it a second time to the color picker object.
471
+ if ( alpha != 100 ) {
472
+ color = color.replace( /[^,]+(?=\))/, ( alpha / 100 ).toFixed( 2 ) );
473
+ }
474
+
475
+ $control.wpColorPicker( 'color', color );
476
+ });
477
+
478
+ // Bind event handler for clicking on the 'Clear' button.
479
+ $container.find( '.button.wp-picker-clear' ).on( 'click', function() {
480
+ var key = $control.attr( 'data-customize-setting-link' );
481
+
482
+ // The #fff color is delibrate here. This sets the color picker to white instead of the
483
+ // defult black, which puts the color picker in a better place to visually represent empty.
484
+ $control.wpColorPicker( 'color', '#ffffff' );
485
+
486
+ // Set the actual option value to empty string.
487
+ wp.customize( key, function( obj ) {
488
+ obj.set( '' );
489
+ });
490
+
491
+ acp_update_alpha_value_on_alpha_slider( 100, $alphaSlider );
492
+ });
493
+
494
+ // Bind event handler for clicking on the 'Default' button.
495
+ $container.find( '.button.wp-picker-default' ).on( 'click', function() {
496
+ var alpha = acp_get_alpha_value_from_color( defaultColor );
497
+
498
+ acp_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
499
+ });
500
+
501
+ // Bind event handler for typing or pasting into the input.
502
+ $control.on( 'input', function() {
503
+ var value = $( this ).val();
504
+ var alpha = acp_get_alpha_value_from_color( value );
505
+
506
+ acp_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
507
+ });
508
+
509
+ // Update all the things when the slider is interacted with.
510
+ $alphaSlider.slider().on( 'slide', function( event, ui ) {
511
+ var alpha = parseFloat( ui.value ) / 100.0;
512
+
513
+ acp_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, false );
514
+
515
+ // Change value shown on slider handle.
516
+ $( this ).find( '.ui-slider-handle' ).text( ui.value );
517
+ });
518
+
519
+ });
520
+
521
+ /**
522
+ * Override the stock color.js toString() method to add support for outputting RGBa or Hex.
523
+ */
524
+ Color.prototype.toString = function( flag ) {
525
+
526
+ // If our no-alpha flag has been passed in, output RGBa value with 100% opacity.
527
+ // This is used to set the background color on the opacity slider during color changes.
528
+ if ( 'no-alpha' == flag ) {
529
+ return this.toCSS( 'rgba', '1' ).replace( /\s+/g, '' );
530
+ }
531
+
532
+ // If we have a proper opacity value, output RGBa.
533
+ if ( 1 > this._alpha ) {
534
+ return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
535
+ }
536
+
537
+ // Proceed with stock color.js hex output.
538
+ var hex = parseInt( this._color, 10 ).toString( 16 );
539
+ if ( this.error ) { return ''; }
540
+ if ( hex.length < 6 ) {
541
+ for ( var i = 6 - hex.length - 1; i >= 0; i-- ) {
542
+ hex = '0' + hex;
543
+ }
544
+ }
545
+
546
+ return '#' + hex;
547
+ };
548
+
549
+ /**
550
+ * Given an RGBa, RGB, or hex color value, return the alpha channel value.
551
+ */
552
+ function acp_get_alpha_value_from_color( value ) {
553
+ var alphaVal;
554
+
555
+ // Remove all spaces from the passed in value to help our RGBa regex.
556
+ value = value.replace( / /g, '' );
557
+
558
+ if ( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ ) ) {
559
+ alphaVal = parseFloat( value.match( /rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/ )[1] ).toFixed(2) * 100;
560
+ alphaVal = parseInt( alphaVal );
561
+ } else {
562
+ alphaVal = 100;
563
+ }
564
+
565
+ return alphaVal;
566
+ }
567
+
568
+ /**
569
+ * Force update the alpha value of the color picker object and maybe the alpha slider.
570
+ */
571
+ function acp_update_alpha_value_on_color_control( alpha, $control, $alphaSlider, update_slider ) {
572
+ var iris, colorPicker, color;
573
+
574
+ iris = $control.data( 'a8cIris' );
575
+ colorPicker = $control.data( 'wpWpColorPicker' );
576
+
577
+ // Set the alpha value on the Iris object.
578
+ iris._color._alpha = alpha;
579
+
580
+ // Store the new color value.
581
+ color = iris._color.toString();
582
+
583
+ // Set the value of the input.
584
+ $control.val( color );
585
+
586
+ // Update the background color of the color picker.
587
+ colorPicker.toggler.css({
588
+ 'background-color': color
589
+ });
590
+
591
+ // Maybe update the alpha slider itself.
592
+ if ( update_slider ) {
593
+ acp_update_alpha_value_on_alpha_slider( alpha, $alphaSlider );
594
+ }
595
+
596
+ // Update the color value of the color picker object.
597
+ $control.wpColorPicker( 'color', color );
598
+ }
599
+
600
+ /**
601
+ * Update the slider handle position and label.
602
+ */
603
+ function acp_update_alpha_value_on_alpha_slider( alpha, $alphaSlider ) {
604
+ $alphaSlider.slider( 'value', alpha );
605
+ $alphaSlider.find( '.ui-slider-handle' ).text( alpha.toString() );
606
+ }
607
+
608
+ });
assets/js/email-customizer-scripts.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Customizer Scripts
3
+ * Need to rewrite and clean up this file.
4
+ */
5
+
6
+ jQuery(document).ready(function() {
7
+
8
+ /**
9
+ * Change description
10
+ */
11
+ jQuery('#accordion-section-email_controls_section h3').trigger( "click" );
12
+ jQuery('#customize-theme-controls #accordion-section-themes').hide();
13
+
14
+ });
15
+ // Handle mobile button click
16
+ function custom_size_mobile() {
17
+ // get email width.
18
+ var email_width = '684';
19
+ var ratio = email_width/304;
20
+ var framescale = 100/ratio;
21
+ var framescale = framescale/100;
22
+ jQuery('#customize-preview iframe').width(email_width+'px');
23
+ jQuery('#customize-preview iframe').css({
24
+ '-webkit-transform' : 'scale(' + framescale + ')',
25
+ '-moz-transform' : 'scale(' + framescale + ')',
26
+ '-ms-transform' : 'scale(' + framescale + ')',
27
+ '-o-transform' : 'scale(' + framescale + ')',
28
+ 'transform' : 'scale(' + framescale + ')'
29
+ });
30
+ }
31
+ jQuery('#customize-footer-actions .preview-mobile').click(function(e) {
32
+ custom_size_mobile();
33
+ });
34
+ jQuery('#customize-footer-actions .preview-desktop').click(function(e) {
35
+ jQuery('#customize-preview iframe').width('100%');
36
+ jQuery('#customize-preview iframe').css({
37
+ '-webkit-transform' : 'scale(1)',
38
+ '-moz-transform' : 'scale(1)',
39
+ '-ms-transform' : 'scale(1)',
40
+ '-o-transform' : 'scale(1)',
41
+ 'transform' : 'scale(1)'
42
+ });
43
+ });
44
+ jQuery('#customize-footer-actions .preview-tablet').click(function(e) {
45
+ jQuery('#customize-preview iframe').width('100%');
46
+ jQuery('#customize-preview iframe').css({
47
+ '-webkit-transform' : 'scale(1)',
48
+ '-moz-transform' : 'scale(1)',
49
+ '-ms-transform' : 'scale(1)',
50
+ '-o-transform' : 'scale(1)',
51
+ 'transform' : 'scale(1)'
52
+ });
53
+ });
54
+
55
+ (function ( api ) {
56
+ api.section( 'email_controls_section', function( section ) {
57
+ section.expanded.bind( function( isExpanded ) {
58
+
59
+ var url;
60
+ if ( isExpanded ) {
61
+ jQuery('#save').trigger('click');
62
+ url = wcast_customizer.email_preview_url;
63
+ api.previewer.previewUrl.set( url );
64
+ }
65
+ } );
66
+ } );
67
+ } ( wp.customize ) );
68
+ (function ( api ) {
69
+ api.section( 'default_controls_section', function( section ) {
70
+ section.expanded.bind( function( isExpanded ) {
71
+ var url;
72
+ if ( isExpanded ) {
73
+ jQuery('#save').trigger('click');
74
+ url = wcast_customizer.tracking_preview_url;
75
+ api.previewer.previewUrl.set( url );
76
+ }
77
+ } );
78
+ } );
79
+ } ( wp.customize ) );
80
+ jQuery(document).on("change", "#_customize-input-wcast_email_preview_order_id", function(){
81
+ var wcast_email_preview_order_id = jQuery(this).val();
82
+
83
+ var data = {
84
+ action: 'update_tracking_preview_order',
85
+ wcast_email_preview_order_id: wcast_email_preview_order_id,
86
+ };
87
+
88
+ jQuery.ajax({
89
+ url: ajaxurl,
90
+ data: data,
91
+ type: 'POST',
92
+ success: function(response) {
93
+ jQuery("#_customize-input-wcast_email_preview_order_id option[value="+wcast_email_preview_order_id+"]").attr('selected', 'selected');
94
+ jQuery("#_customize-input-wcast_preview_order_id option[value="+wcast_email_preview_order_id+"]").attr('selected', 'selected');
95
+ //jQuery('#save').trigger('click');
96
+ },
97
+ error: function(response) {
98
+ console.log(response);
99
+ }
100
+ });
101
+ });
102
+ jQuery(document).on("change", "#_customize-input-wcast_preview_order_id", function(){
103
+ var wcast_preview_order_id = jQuery(this).val();
104
+ var data = {
105
+ action: 'update_email_preview_order',
106
+ wcast_preview_order_id: wcast_preview_order_id,
107
+ };
108
+
109
+ jQuery.ajax({
110
+ url: ajaxurl,
111
+ data: data,
112
+ type: 'POST',
113
+ success: function(response) {
114
+ jQuery("#_customize-input-wcast_email_preview_order_id option[value="+wcast_preview_order_id+"]").attr('selected', 'selected');
115
+ jQuery("#_customize-input-wcast_preview_order_id option[value="+wcast_preview_order_id+"]").attr('selected', 'selected');
116
+ //jQuery('#save').trigger('click');
117
+ },
118
+ error: function(response) {
119
+ console.log(response);
120
+ }
121
+ });
122
+ });
assets/js/preview-scripts.js ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ( function( $ ) {
2
+ $('.hide').hide();
3
+ /* Hide/Show Header */
4
+ wp.customize( 'display_shipment_provider_image', function( value ) {
5
+ value.bind( function( to ) {
6
+ if( to ){
7
+ $( '.tracking-provider img' ).show();
8
+ }
9
+ else{
10
+ $( '.tracking-provider img' ).hide();
11
+ }
12
+ });
13
+ });
14
+ wp.customize( 'remove_date_from_tracking', function( value ) {
15
+ value.bind( function( remove_date_from_tracking ) {
16
+ if( remove_date_from_tracking ){
17
+ $( '.date-shipped' ).hide();
18
+ }
19
+ else{
20
+ $( '.date-shipped' ).show();
21
+ }
22
+ });
23
+ });
24
+ wp.customize( 'header_text_change', function( value ) {
25
+ value.bind( function( header_text ) {
26
+ if( header_text ){
27
+ $( '.header_text' ).text(header_text);
28
+ } else{
29
+ $( '.header_text' ).text('Tracking Information');
30
+ }
31
+ });
32
+ });
33
+ wp.customize( 'additional_header_text', function( value ) {
34
+ value.bind( function( additional_header_text ) {
35
+ if( additional_header_text ){
36
+ $( '.addition_header' ).text(additional_header_text);
37
+ } else{
38
+ $( '.addition_header' ).text('');
39
+ }
40
+ });
41
+ });
42
+ wp.customize( 'table_bg_color', function( setting ) {
43
+ /* Deferred callback for when setting exists */
44
+ setting.bind( function( newValue ) {
45
+ /* Update callback for setting change */
46
+ $( '.tracking_table' ).css( 'background-color',newValue );
47
+ } );
48
+ } );
49
+ wp.customize( 'table_border_color', function( setting ) {
50
+ /* Deferred callback for when setting exists */
51
+ setting.bind( function( table_border_color ) {
52
+ /* Update callback for setting change */
53
+ $( '.tracking_table th' ).css( 'border-color',table_border_color );
54
+ $( '.tracking_table td' ).css( 'border-color',table_border_color );
55
+ } );
56
+ } );
57
+ wp.customize( 'table_border_size', function( setting ) {
58
+ /* Deferred callback for when setting exists */
59
+ setting.bind( function( table_border_size ) {
60
+ /* Update callback for setting change */
61
+ $( '.tracking_table th' ).css( 'border-width',table_border_size+'px' );
62
+ $( '.tracking_table td' ).css( 'border-width',table_border_size+'px' );
63
+ } );
64
+ } );
65
+ wp.customize( 'table_header_font_size', function( setting ) {
66
+ /* Deferred callback for when setting exists */
67
+ setting.bind( function( table_header_font_size ) {
68
+ /* Update callback for setting change */
69
+ $( '.tracking_table th' ).css( 'font-size',table_header_font_size+'px' );
70
+ } );
71
+ } );
72
+ wp.customize( 'table_header_font_color', function( setting ) {
73
+ /* Deferred callback for when setting exists */
74
+ setting.bind( function( table_header_font_color ) {
75
+ /* Update callback for setting change */
76
+ $( '.tracking_table th' ).css( 'color',table_header_font_color );
77
+ } );
78
+ } );
79
+ wp.customize( 'table_content_font_size', function( setting ) {
80
+ /* Deferred callback for when setting exists */
81
+ setting.bind( function( table_content_font_size ) {
82
+ /* Update callback for setting change */
83
+ $( '.tracking_table td' ).css( 'font-size',table_content_font_size+'px' );
84
+ } );
85
+ } );
86
+ wp.customize( 'table_content_font_color', function( setting ) {
87
+ /* Deferred callback for when setting exists */
88
+ setting.bind( function( table_content_font_color ) {
89
+ /* Update callback for setting change */
90
+ $( '.tracking_table td' ).css( 'color',table_content_font_color );
91
+ } );
92
+ } );
93
+ wp.customize( 'tracking_link_font_color', function( setting ) {
94
+ /* Deferred callback for when setting exists */
95
+ setting.bind( function( tracking_link_font_color ) {
96
+ /* Update callback for setting change */
97
+ $( '.tracking_table td a' ).css( 'color',tracking_link_font_color );
98
+ } );
99
+ } );
100
+ wp.customize( 'tracking_link_bg_color', function( setting ) {
101
+ /* Deferred callback for when setting exists */
102
+ setting.bind( function( tracking_link_bg_color ) {
103
+ /* Update callback for setting change */
104
+ $( '.tracking_table td a' ).css( 'background-color',tracking_link_bg_color );
105
+ } );
106
+ } );
107
+ wp.customize( 'table_content_line_height', function( value ) {
108
+ value.bind( function( table_content_line_height ) {
109
+ $( '.tracking_table' ).css( 'line-height',table_content_line_height+'px' );
110
+ });
111
+ });
112
+ wp.customize( 'table_content_font_weight', function( value ) {
113
+ value.bind( function( table_content_font_weight ) {
114
+ $( '.tracking_table td' ).css( 'font-weight',table_content_font_weight );
115
+ });
116
+ });
117
+
118
+ wp.customize( 'wcast_delivered_email_heading', function( value ) {
119
+ value.bind( function( wcast_delivered_email_heading ) {
120
+ console.log(wcast_delivered_email_heading);
121
+ if( wcast_delivered_email_heading ){
122
+ $( '#header_wrapper h1' ).text(wcast_delivered_email_heading);
123
+ } else{
124
+ $( '#header_wrapper h1' ).text('');
125
+ }
126
+ });
127
+ });
128
+ } )( jQuery );
assets/js/settings.js CHANGED
@@ -66,14 +66,6 @@ jQuery( document ).ready(function() {
66
  jQuery('.status_label_color_th').hide();
67
  jQuery('label.tab_label[for="tab5"]').hide();
68
  }
69
- var email_type = jQuery('#wc_ast_select_email_type').val();
70
- if(email_type == 'wc_email'){
71
- jQuery('label.tab_label[for="tab5"]').hide();
72
- jQuery('.manage_delivered_order_email_link').show();
73
- } else{
74
- jQuery('label.tab_label[for="tab5"]').show();
75
- jQuery('.manage_delivered_order_email_link').hide();
76
- }
77
  jQuery('#wc_ast_status_label_color').wpColorPicker();
78
  jQuery('.color_field input').wpColorPicker();
79
  });
66
  jQuery('.status_label_color_th').hide();
67
  jQuery('label.tab_label[for="tab5"]').hide();
68
  }
 
 
 
 
 
 
 
 
69
  jQuery('#wc_ast_status_label_color').wpColorPicker();
70
  jQuery('.color_field input').wpColorPicker();
71
  });
assets/js/shipping_row.js CHANGED
@@ -1,5 +1,5 @@
1
  ( function( $, data, wp, ajaxurl ) {
2
-
3
  var wc_table_rate_rows_row_template = wp.template( 'shipping-provider-row-template' ),
4
  $rates_table = $( '#shipping_rates' ),
5
  $rates = $rates_table.find( 'tbody.table_rates' ),
@@ -86,7 +86,9 @@
86
  index: response.id,
87
  sort_id: (Number(sort_id) + 1),
88
  } ) );
89
- jQuery(".wcast_shipping_country").select2();
 
 
90
  },
91
  error: function(response) {
92
  console.log(response);
@@ -112,7 +114,8 @@
112
  return;
113
  }
114
 
115
- var provider_row = jQuery(this).parents("tr");
 
116
  var provider_id = jQuery(this).data("pid");
117
 
118
  var ajax_data = {
@@ -122,7 +125,9 @@
122
 
123
  $.post( ajaxurl, ajax_data, function(response) {
124
  provider_row.remove();
 
125
  update_default_shipping_provider();
 
126
  $(".shipping_provider_table ").unblock();
127
  });
128
  }
@@ -214,13 +219,24 @@ jQuery(".custom_provider_tr").hover(function() {
214
 
215
  jQuery(document).on("click", ".edit_provider", function(){
216
  jQuery(this).closest('tr').find('.on_edit_show').show();
217
- jQuery(this).closest('tr').find('.on_edit_hide').hide();
 
218
  jQuery(".custom_provider_tr").hover(function() {
219
  jQuery(this).find('.dashicons-edit').hide();
220
  jQuery(this).find('.dashicons-trash').hide();
221
  }, function() {
222
  });
223
  });
 
 
 
 
 
 
 
 
 
 
224
  jQuery(document).on("click", ".update_provider", function(){
225
  jQuery(".shipping_provider_table ").block({
226
  message: null,
@@ -235,7 +251,8 @@ jQuery(document).on("click", ".update_provider", function(){
235
  var provider_id = jQuery(this).closest('tr').find('.provider_id').val();
236
  var sort_order = jQuery(this).closest('tr').find('.sort_order').val();
237
  var image_id = jQuery(this).closest('tr').find('.image_id').val();
238
-
 
239
 
240
  var ajax_data = {
241
  action: 'update_shipping_provider',
@@ -321,6 +338,7 @@ jQuery(document).on("click", ".update_provider", function(){
321
 
322
  componentHandler.upgradeAllRegistered();
323
  update_default_shipping_provider();
 
324
  jQuery(".shipping_provider_table ").unblock();
325
  },
326
  error: function(response) {
@@ -414,6 +432,7 @@ jQuery(document).on("click", ".add_new", function(){
414
 
415
  update_default_shipping_provider();
416
  componentHandler.upgradeAllRegistered();
 
417
  jQuery(".shipping_provider_table ").unblock();
418
  },
419
  error: function(response) {
@@ -627,7 +646,8 @@ jQuery(document).on("submit", "#wc_ast_upload_csv_form", function(){
627
  tracking_number: tracking_number,
628
  date_shipped: date_shipped,
629
  status_shipped: status_shipped,
630
- replace_tracking_info: replace_tracking_info,
 
631
  };
632
 
633
  var option = {
@@ -918,4 +938,25 @@ function showerror(element){
918
  }
919
  function hideerror(element){
920
  element.css("border","none");
921
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ( function( $, data, wp, ajaxurl ) {
2
+ jQuery(".custom_provider_country").select2();
3
  var wc_table_rate_rows_row_template = wp.template( 'shipping-provider-row-template' ),
4
  $rates_table = $( '#shipping_rates' ),
5
  $rates = $rates_table.find( 'tbody.table_rates' ),
86
  index: response.id,
87
  sort_id: (Number(sort_id) + 1),
88
  } ) );
89
+ jQuery('.add-provider').attr("disabled", true);
90
+ jQuery(".wcast_shipping_country").select2();
91
+ jQuery(".custom_provider_country").select2();
92
  },
93
  error: function(response) {
94
  console.log(response);
114
  return;
115
  }
116
 
117
+ var provider_row1 = jQuery(this).parents("tr");
118
+ var provider_row = jQuery('.tr_add');
119
  var provider_id = jQuery(this).data("pid");
120
 
121
  var ajax_data = {
125
 
126
  $.post( ajaxurl, ajax_data, function(response) {
127
  provider_row.remove();
128
+ provider_row1.remove();
129
  update_default_shipping_provider();
130
+ jQuery('.add-provider').removeAttr("disabled");
131
  $(".shipping_provider_table ").unblock();
132
  });
133
  }
219
 
220
  jQuery(document).on("click", ".edit_provider", function(){
221
  jQuery(this).closest('tr').find('.on_edit_show').show();
222
+ jQuery(this).closest('tr').find('.on_edit_hide').hide();
223
+ jQuery('.add-provider').attr("disabled", true);
224
  jQuery(".custom_provider_tr").hover(function() {
225
  jQuery(this).find('.dashicons-edit').hide();
226
  jQuery(this).find('.dashicons-trash').hide();
227
  }, function() {
228
  });
229
  });
230
+ jQuery(document).on("click", ".cancel_edit", function(){
231
+ jQuery(this).closest('tr').find('.on_edit_show').hide();
232
+ jQuery(this).closest('tr').find('.on_edit_hide').show();
233
+ jQuery('.add-provider').removeAttr("disabled");
234
+ jQuery(".custom_provider_tr").hover(function() {
235
+ jQuery(this).find('.dashicons-edit').show();
236
+ jQuery(this).find('.dashicons-trash').show();
237
+ }, function() {
238
+ });
239
+ });
240
  jQuery(document).on("click", ".update_provider", function(){
241
  jQuery(".shipping_provider_table ").block({
242
  message: null,
251
  var provider_id = jQuery(this).closest('tr').find('.provider_id').val();
252
  var sort_order = jQuery(this).closest('tr').find('.sort_order').val();
253
  var image_id = jQuery(this).closest('tr').find('.image_id').val();
254
+
255
+ console.log(custom_provider_name);
256
 
257
  var ajax_data = {
258
  action: 'update_shipping_provider',
338
 
339
  componentHandler.upgradeAllRegistered();
340
  update_default_shipping_provider();
341
+ jQuery('.add-provider').removeAttr("disabled");
342
  jQuery(".shipping_provider_table ").unblock();
343
  },
344
  error: function(response) {
432
 
433
  update_default_shipping_provider();
434
  componentHandler.upgradeAllRegistered();
435
+ jQuery('.add-provider').removeAttr("disabled");
436
  jQuery(".shipping_provider_table ").unblock();
437
  },
438
  error: function(response) {
646
  tracking_number: tracking_number,
647
  date_shipped: date_shipped,
648
  status_shipped: status_shipped,
649
+ replace_tracking_info: replace_tracking_info,
650
+ trackings: trackings,
651
  };
652
 
653
  var option = {
938
  }
939
  function hideerror(element){
940
  element.css("border","none");
941
+ }
942
+
943
+ $.fn.textWidth = function(text, font) {
944
+
945
+ if (!$.fn.textWidth.fakeEl) $.fn.textWidth.fakeEl = $('<span>').hide().appendTo(document.body);
946
+
947
+ $.fn.textWidth.fakeEl.text(text || this.val() || this.text() || this.attr('placeholder')).css('font', font || this.css('font'));
948
+
949
+ return $.fn.textWidth.fakeEl.width();
950
+ };
951
+ jQuery(document).ready(function() {
952
+ jQuery(".site_title_tag").css('width',((jQuery(".site_title_tag").val().length + 1) * 8) + 'px');
953
+ jQuery(".customer_email_tag").css('width',((jQuery(".customer_email_tag").val().length + 1) * 8) + 'px');
954
+ jQuery(".first_name_tag").css('width',((jQuery(".first_name_tag").val().length + 1) * 8) + 'px');
955
+ jQuery(".last_name_tag").css('width',((jQuery(".last_name_tag").val().length + 1) * 8) + 'px');
956
+ jQuery(".username_tag").css('width',((jQuery(".username_tag").val().length + 1) * 8) + 'px');
957
+ jQuery(".order_number_tag").css('width',((jQuery(".order_number_tag").val().length + 1) * 8) + 'px');
958
+ jQuery(".order_details_tag").css('width',((jQuery(".order_details_tag").val().length + 1) * 8) + 'px');
959
+ jQuery(".tracking_details_tag").css('width',((jQuery(".tracking_details_tag").val().length + 1) * 8) + 'px');
960
+ jQuery(".shipping_address_tag").css('width',((jQuery(".shipping_address_tag").val().length + 1) * 8) + 'px');
961
+ jQuery(".billing_address_tag").css('width',((jQuery(".billing_address_tag").val().length + 1) * 8) + 'px');
962
+ });
assets/js/tracking-customizer-scripts.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Customizer Scripts
3
+ * Need to rewrite and clean up this file.
4
+ */
5
+
6
+ jQuery(document).ready(function() {
7
+
8
+ /**
9
+ * Change description
10
+ */
11
+ jQuery('#accordion-section-default_controls_section h3').trigger( "click" );
12
+ jQuery('#customize-theme-controls #accordion-section-themes').hide();
13
+
14
+ });
15
+ // Handle mobile button click
16
+ function custom_size_mobile() {
17
+ // get email width.
18
+ var email_width = '684';
19
+ var ratio = email_width/304;
20
+ var framescale = 100/ratio;
21
+ var framescale = framescale/100;
22
+ jQuery('#customize-preview iframe').width(email_width+'px');
23
+ jQuery('#customize-preview iframe').css({
24
+ '-webkit-transform' : 'scale(' + framescale + ')',
25
+ '-moz-transform' : 'scale(' + framescale + ')',
26
+ '-ms-transform' : 'scale(' + framescale + ')',
27
+ '-o-transform' : 'scale(' + framescale + ')',
28
+ 'transform' : 'scale(' + framescale + ')'
29
+ });
30
+ }
31
+ jQuery('#customize-footer-actions .preview-mobile').click(function(e) {
32
+ custom_size_mobile();
33
+ });
34
+ jQuery('#customize-footer-actions .preview-desktop').click(function(e) {
35
+ jQuery('#customize-preview iframe').width('100%');
36
+ jQuery('#customize-preview iframe').css({
37
+ '-webkit-transform' : 'scale(1)',
38
+ '-moz-transform' : 'scale(1)',
39
+ '-ms-transform' : 'scale(1)',
40
+ '-o-transform' : 'scale(1)',
41
+ 'transform' : 'scale(1)'
42
+ });
43
+ });
44
+ jQuery('#customize-footer-actions .preview-tablet').click(function(e) {
45
+ jQuery('#customize-preview iframe').width('100%');
46
+ jQuery('#customize-preview iframe').css({
47
+ '-webkit-transform' : 'scale(1)',
48
+ '-moz-transform' : 'scale(1)',
49
+ '-ms-transform' : 'scale(1)',
50
+ '-o-transform' : 'scale(1)',
51
+ 'transform' : 'scale(1)'
52
+ });
53
+ });
54
+
55
+ (function ( api ) {
56
+ api.section( 'email_controls_section', function( section ) {
57
+ section.expanded.bind( function( isExpanded ) {
58
+ var url;
59
+ if ( isExpanded ) {
60
+ jQuery('#save').trigger('click');
61
+ url = wcast_customizer.email_preview_url;
62
+ api.previewer.previewUrl.set( url );
63
+ }
64
+ } );
65
+ } );
66
+ } ( wp.customize ) );
67
+ (function ( api ) {
68
+ api.section( 'default_controls_section', function( section ) {
69
+ section.expanded.bind( function( isExpanded ) {
70
+ var url;
71
+ if ( isExpanded ) {
72
+ jQuery('#save').trigger('click');
73
+ url = wcast_customizer.tracking_preview_url;
74
+ api.previewer.previewUrl.set( url );
75
+ }
76
+ } );
77
+ } );
78
+ } ( wp.customize ) );
79
+ jQuery(document).on("change", "#_customize-input-wcast_email_preview_order_id", function(){
80
+ var wcast_email_preview_order_id = jQuery(this).val();
81
+
82
+ var data = {
83
+ action: 'update_tracking_preview_order',
84
+ wcast_email_preview_order_id: wcast_email_preview_order_id,
85
+ };
86
+
87
+ jQuery.ajax({
88
+ url: ajaxurl,
89
+ data: data,
90
+ type: 'POST',
91
+ success: function(response) {
92
+ jQuery("#_customize-input-wcast_email_preview_order_id option[value="+wcast_email_preview_order_id+"]").attr('selected', 'selected');
93
+ jQuery("#_customize-input-wcast_preview_order_id option[value="+wcast_email_preview_order_id+"]").attr('selected', 'selected');
94
+ //jQuery('#save').trigger('click');
95
+ },
96
+ error: function(response) {
97
+ console.log(response);
98
+ }
99
+ });
100
+ });
101
+ jQuery(document).on("change", "#_customize-input-wcast_preview_order_id", function(){
102
+ var wcast_preview_order_id = jQuery(this).val();
103
+
104
+ var data = {
105
+ action: 'update_email_preview_order',
106
+ wcast_preview_order_id: wcast_preview_order_id,
107
+ };
108
+
109
+ jQuery.ajax({
110
+ url: ajaxurl,
111
+ data: data,
112
+ type: 'POST',
113
+ success: function(response) {
114
+ jQuery("#_customize-input-wcast_email_preview_order_id option[value="+wcast_preview_order_id+"]").attr('selected', 'selected');
115
+ jQuery("#_customize-input-wcast_preview_order_id option[value="+wcast_preview_order_id+"]").attr('selected', 'selected');
116
+ //jQuery('#save').trigger('click');
117
+ },
118
+ error: function(response) {
119
+ console.log(response);
120
+ }
121
+ });
122
+ });
assets/shipment-provider-img/dhl-logistics.png ADDED
Binary file
assets/shipment-provider-img/dhl-parcel.png ADDED
Binary file
includes/class-wc-advanced-shipment-tracking-admin.php CHANGED
@@ -135,10 +135,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
135
  add_action( 'wp_ajax_delete_status_email', array( $this, 'delete_status_email_fun') );
136
 
137
  add_action( 'wp_ajax_update_email_type', array( $this, 'update_email_type_fun') );
 
 
 
 
138
 
139
- add_action( 'admin_footer', array( $this, 'footer_function') );
140
-
141
- add_action( 'admin_init', array( $this, 'preview_emails' ) );
142
  }
143
 
144
  /*
@@ -578,7 +580,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
578
  public function register_woocommerce_menu() {
579
  add_submenu_page( 'woocommerce', 'Shipment Tracking', 'Shipment Tracking', 'manage_options', 'woocommerce-advanced-shipment-tracking', array( $this, 'woocommerce_advanced_shipment_tracking_page_callback' ) );
580
  }
581
-
 
 
 
 
 
582
  /*
583
  * callback for Shipment Tracking page
584
  */
@@ -656,8 +663,22 @@ class WC_Advanced_Shipment_Tracking_Admin {
656
 
657
 
658
  $default_shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name ORDER BY `{$orderby}` {$order} " );
659
- //echo $main_blog_prefix;
660
- //echo '<pre>';print_r($site_list);echo '</pre>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
661
  wp_enqueue_script( 'shipment_tracking_table_rows' );
662
  ?>
663
  <h3><?php _e('Advanced Shipment Tracking for WooCommerce', 'woo-advanced-shipment-tracking'); ?></h3>
@@ -668,10 +689,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
668
  <label for="tab1" class="tab_label"><?php _e('Shipping Provider', 'woo-advanced-shipment-tracking'); ?></label>
669
 
670
  <input id="tab2" type="radio" name="tabs" class="tab_input">
671
- <label for="tab2" class="tab_label"><?php _e('Settings', 'woo-advanced-shipment-tracking'); ?></label>
672
-
673
- <?php /*?><input id="tab3" type="radio" name="tabs" class="tab_input">
674
- <label for="tab3" class="tab_label">API integration</label><?php */?>
675
 
676
  <input id="tab4" type="radio" name="tabs" class="tab_input">
677
  <label for="tab4" class="tab_label"><?php _e('Bulk Upload', 'woo-advanced-shipment-tracking'); ?></label>
@@ -730,81 +748,82 @@ class WC_Advanced_Shipment_Tracking_Admin {
730
  continue;
731
  }
732
  ?>
733
- <tr class="provider_tr <?php if($d_s_p->display_in_order != 1) { echo 'status_deactivate'; } ?> <?php if($d_s_p->shipping_default == 0) { echo 'custom_provider_tr'; } ?>">
734
- <td class="column-columnname thumb-column">
735
  <?php if( $d_s_p->shipping_default == 1 ){ ?>
736
- <img class="provider_thumbnail on_edit_hide" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/<?php echo sanitize_title($d_s_p->provider_name);?>.png">
737
  <?php } else{
738
  $custom_thumb_id = $d_s_p->custom_thumb_id;
739
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
740
  //echo '<pre>';print_r($custom_thumb_id);echo '</pre>';exit;
741
  if($custom_thumb_id != 0){ ?>
742
- <img class="provider_thumbnail on_edit_hide" src="<?php echo $image_attributes[0]; ?>">
743
  <?php } else{
744
  ?>
745
- <img class="provider_thumbnail on_edit_hide" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/icon-default.png">
746
  <?php } ?>
747
- <input type='text' name='data[<?php echo $d_s_p->id?>][thumb_url]' class='image_path on_edit_show' placeholder="Image" value='<?php echo $image_attributes[0]; ?>' id='image_path' style="">
748
- <input type='hidden' name='data[<?php echo $d_s_p->id?>][thumb_id]' class='image_id' placeholder="Image" value='<?php echo $custom_thumb_id; ?>' id='image_id' style="">
749
- <input id="upload_image_button" type="button" class="button on_edit_show" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
750
  <?php } ?>
751
- <span class="provider_name on_edit_hide">
752
- <?php
753
- echo $d_s_p->provider_name; ?>
754
- </span>
755
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
756
- <input type="text" class="text on_edit_show custom_provider_name" name="data[<?php echo $d_s_p->id?>][provider_name]" value="<?php echo $d_s_p->provider_name;?>" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>">
757
- <?php } ?>
758
  </td>
759
- <td class="column-columnname country_select_box">
760
- <span class="on_edit_hide">
761
- <?php
762
- $search = array('(US)', '(UK)');
763
- $replace = array('', '');
764
- echo str_replace($search, $replace, $WC_Countries->countries[$d_s_p->shipping_country]);
765
- ?>
766
- </span>
767
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
768
- <select class="on_edit_show custom_provider_country" name="data[<?php echo $d_s_p->id?>][shipping_country]" >
769
- <option value="" ><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
770
- <?php foreach($countries as $key=>$val){ ?>
771
- <option value="<?php echo $key; ?>" <?php if ( $key == $d_s_p->shipping_country ) echo 'selected'?>><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
772
- <?php } ?>
773
- </select>
774
- <?php } ?>
775
  </td>
776
- <td class="column-columnname url-column">
777
  <a href="<?php echo $d_s_p->provider_url; ?>" title="<?php echo $d_s_p->provider_url; ?>" target="_blank" class="on_edit_hide"><?php _e( 'Tracking Page','woo-advanced-shipment-tracking' ); ?>
778
- </a>
779
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
780
- <input type="text" class="text on_edit_show custom_provider_url" name="data[<?php echo $d_s_p->id?>][provider_url]" value="<?php echo $d_s_p->provider_url;?>" placeholder="<?php _e( 'Shipping URL', 'woo-advanced-shipment-tracking' ); ?>">
781
- <?php }?>
782
  </td>
783
- <td class="column-columnname status-column">
784
  <span class="mdl-list__item-secondary-action">
785
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="list-switch-<?php echo $d_s_p->id; ?>">
786
  <input type="checkbox" name="select_custom_provider[]" id="list-switch-<?php echo $d_s_p->id; ?>" class="mdl-switch__input status_slide" value="<?php echo $d_s_p->id; ?>" <?php if($d_s_p->display_in_order == 1) { echo 'checked'; } ?> />
787
  </label>
788
  </span>
789
  </td>
790
- <td class="column-columnname">
791
  <?php if( $d_s_p->shipping_default == 0 ){ ?>
792
- <span class="dashicons dashicons-edit edit_provider on_edit_hide" style="display:none"></span>
793
- <span class="dashicons dashicons-trash remove on_edit_hide" data-pid="<?php echo $d_s_p->id; ?>" style="display:none"></span>
794
- <button class="button button-primary on_edit_show update_provider btn_green" style="display:none;"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
795
  <?php } ?>
796
- <span class="dashicons dashicons-editor-justify sort-item ui-sortable-handle on_edit_hide"></span>
797
- <input type="hidden" name="provider_id" class="provider_id" value="<?php echo $d_s_p->id?>">
798
- <input type="hidden" name="sorting[<?php echo $d_s_p->id?>][sort_order]" class="sort_order" value="<?php echo $d_s_p->sort_order?>">
799
- <input type="hidden" name="data[<?php echo $d_s_p->id?>][sort_order]" class="" value="<?php echo $d_s_p->sort_order?>">
800
  <?php
801
  $custom_thumb_id = $d_s_p->custom_thumb_id;
802
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id );
803
  ?>
804
  <input type="hidden" name="data[<?php echo $d_s_p->id?>][thumb_url]" class="image_path" value="<?php echo $image_attributes[0]; ?>">
805
  </td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
806
  </tr>
807
- <?php } ?>
808
  </tbody>
809
  <tfoot>
810
  <tr>
@@ -814,36 +833,51 @@ class WC_Advanced_Shipment_Tracking_Admin {
814
  </table>
815
  </form>
816
 
817
- <script type="text/template" id="tmpl-shipping-provider-row-template">
818
- <tr class="provider_tr tr_add">
819
- <td class="column-columnname cusgtom_provider_thumb">
820
- <input type='text' placeholder='Image' name='data[{{{ data.index }}}][thumb_url]' class='image_path' value='' id='image_path'>
821
- <input type='hidden' name='data[{{{ data.index }}}][thumb_id]' class='image_id' placeholder="Image" value='' id='image_id' style="">
822
- <input id="upload_image_button" type="button" class="button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
823
  </td>
824
- <td class="column-columnname shipping_provider">
825
- <input type="text" class="text" value="{{{ data.rate.provider_name }}}" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>" name="data[{{{ data.index }}}][provider_name]" />
826
- </td>
827
- <td class="column-columnname shipping_country">
828
- <select class="select wcast_shipping_country" name="data[{{{ data.index }}}][shipping_country]" >
829
- <option value="" <# if ( "" === data.rate.rate_condition ) { #>selected="selected"<# } #>><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
830
- <?php
831
- foreach($countries as $key=>$val){ ?>
832
- <option value="<?php echo $key; ?>" ><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
833
- <?php }
834
- ?>
835
- </select>
836
- </td>
837
- <td class="column-columnname shipping_url" >
838
- <input type="text" class="text" name="data[{{{ data.index }}}][provider_url]" value="" placeholder="<?php _e( 'Tracking Page', 'woo-advanced-shipment-tracking' ); ?>">
839
- <p><?php _e('You can add tracking number parameter like this - http://shippingprovider.com?tracking_number=%number% , %number% - parameter', 'woo-advanced-shipment-tracking'); ?></p>
840
- </td>
841
- <td>
842
- <input type="hidden" name="data[{{{ data.index }}}][sort_order]" class="sort_order" value="{{{ data.sort_id }}}">
843
- <button class="button button-primary add_new btn_green"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
844
- <span class="dashicons dashicons-trash remove" data-pid="{{{ data.index }}}"></span>
845
- </td>
846
- </tr>
847
  </script>
848
  </div>
849
  </section>
@@ -851,15 +885,13 @@ class WC_Advanced_Shipment_Tracking_Admin {
851
  <div class="tab_inner_container">
852
  <form method="post" id="wc_ast_settings_form" action="" enctype="multipart/form-data">
853
  <?php #nonce?>
 
 
 
 
 
854
  <h3><?php _e( 'Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
855
- <?php $this->get_html( $this->get_settings_data() );?>
856
- <!--a class="status_label_color_th" href="<?php admin_url( 'admin.php?page=wc-settings&tab=email&section=wc_email_customer_delivered_order' ); ?>" target="blank"><?php _e( 'Manage delivered order email', 'woo-advanced-shipment-tracking' ); ?></a-->
857
- <hr style="margin:0;"></hr>
858
- <h3><?php _e( 'Tracking info display', 'woo-advanced-shipment-tracking' ); ?></h3>
859
- <?php
860
- echo sprintf( __( 'This section lets you customize the Tracking Info display design.', 'woo-advanced-shipment-tracking' ));
861
- ?>
862
- <div class="tracking_info_design"><?php $this->get_html( $this->get_email_settings_data() );?></div>
863
  <div class="submit">
864
  <button name="save" class="button-primary woocommerce-save-button btn_green" type="submit" value="Save changes"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
865
  <div class="spinner" style="float:none"></div>
@@ -867,36 +899,10 @@ class WC_Advanced_Shipment_Tracking_Admin {
867
  <div class="error_msg" style="display:none;"></div>
868
  <?php wp_nonce_field( 'wc_ast_settings_form', 'wc_ast_settings_form' );?>
869
  <input type="hidden" name="action" value="wc_ast_settings_form_update">
870
- </div>
871
- <a href="<?php echo wp_nonce_url( admin_url( '?preview_tracking_info_design=true' ), 'preview-mail' );?>" target="blank"><?php _e( 'Click here to preview your design', 'woo-advanced-shipment-tracking' ); ?></a>
872
-
873
  </form>
874
  </div>
875
- </section>
876
- <section id="content3" class="tab_section">
877
- <div class="tab_inner_container">
878
- <form method="post" id="wc_ast_api_form" action="" enctype="multipart/form-data">
879
- <?php #nonce?>
880
- <h3>Api Integration</h3>
881
- <?php $this->get_html( $this->get_form_data() );?>
882
- <div class="submit">
883
- <button name="save" class="button-primary woocommerce-save-button btn_green" type="submit" value="Save changes">Save</button>
884
- <div class="spinner" style="float:none"></div>
885
- <div class="success_msg" style="display:none;"><?php _e( 'Data saved successfully.', 'woo-advanced-shipment-tracking' ); ?></div>
886
- <div class="error_msg" style="display:none;"></div>
887
- <?php wp_nonce_field( 'wc_ast_api_form', 'wc_ast_api_form' );?>
888
- <input type="hidden" name="action" value="wc_ast_api_form_update">
889
- </div>
890
- </form>
891
- <div class="test_csv_wrap">
892
- <h3>Run Manual test</h3>
893
- <input type="button" value="Run this export manually" id="test_csv" class="button">
894
- <div class="spinner testcsv_spinner" style="float:none"></div>
895
- <div class="success_msg csv_test_success" style="display:none;"></div>
896
- <div class="error_msg csv_test_error" style="display:none;"></div>
897
- </div>
898
- </div>
899
- </section>
900
  <section id="content4" class="tab_section">
901
  <div class="mdl-grid">
902
  <div class="mdl-cell mdl-cell--12-col">
@@ -939,196 +945,62 @@ class WC_Advanced_Shipment_Tracking_Admin {
939
 
940
  </ol>
941
  </form>
942
- </div>
943
- <!--div class="mdl-cell mdl-cell--6-col">
944
- <h3><?php _e('Bulk import tracking info', 'woo-advanced-shipment-tracking'); ?></h3>
945
- <p><?php _e('Upload multiple tracking # to orders from CSV file. Option to download a CSV file with example with the fields format:', 'woo-advanced-shipment-tracking'); ?></p>
946
- <ul class="bulk_instruction_ul">
947
- <li><?php _e('order_id - WooCommerce order id', 'woo-advanced-shipment-tracking'); ?></li>
948
- <li><?php _e('tracking_provider - Shipment Provider - Must match the shipping Provider name as in the advanced shipment tracking settings.', 'woo-advanced-shipment-tracking'); ?></li>
949
- <li><?php _e('tracking_number - Tracking code / number', 'woo-advanced-shipment-tracking'); ?></li>
950
- <li><?php _e('date_shipped (Optional) Shipping date - Date format DD/MM/YYYY - if not added, we set the upload date.', 'woo-advanced-shipment-tracking'); ?></li>
951
- <li><?php _e('status_shipped (1=yes, 0=no) (Optional) Change order status to “Shipped” (completed) - if this field in null, we will treat it as 0', 'woo-advanced-shipment-tracking'); ?></li>
952
- </ul>
953
-
954
- </div-->
955
  </div>
956
  </section>
957
- <section id="content5" class="tab_section">
958
- <button class="button-primary btn_green" id="add_new_status_email"><?php _e('Add new status email', 'woo-advanced-shipment-tracking'); ?></button>
959
- <?php
960
- $email_status_array = array(
961
- 0 => 'pre_transit',
962
- 1 => 'in_transit',
963
- 2 => 'out_for_delivery',
964
- 3 => 'delivered',
965
- 4 => 'available_for_pickup',
966
- 5 => 'return_to_sender',
967
- );
968
- ?>
969
- <form id="add_new_status_email_form" action="" method="post">
970
- <table class="form-table">
971
- <tbody>
972
- <tr valign="top" class="">
973
- <th scope="row" class="">
974
- <label for=""><?php _e('Trigger', 'woo-advanced-shipment-tracking'); ?></label>
975
- </th>
976
- <td scope="row" class="">
977
- <select class="email_trigger_dropdown" id="email_trigger" name="email_trigger">
978
- <option value=""><?php _e('Select', 'woo-advanced-shipment-tracking'); ?></option>
979
- <option value="order_status"><?php _e('Order Status', 'woo-advanced-shipment-tracking'); ?></option>
980
- <option value="shipment_status"><?php _e('Shipment Status', 'woo-advanced-shipment-tracking'); ?></option>
981
- </select>
982
- </td>
983
- </tr>
984
- <tr class="hide_default shippment_status_message">
985
- <td scope="row" class="" colspan="2">
986
- <p><?php _e('This functionality only available for trackship premium customers.', 'woo-advanced-shipment-tracking'); ?></p>
987
- </td>
988
- </tr>
989
- <tr valign="top" class="hide_default show_if_order_status">
990
- <th scope="row" class="">
991
- <label for=""><?php _e('Order Status', 'woo-advanced-shipment-tracking'); ?></label>
992
- </th>
993
- <td scope="row" class="">
994
- <select class="shipment_status_dropdown" id="order_status" name="order_status">
995
- <option value=""><?php _e('Select', 'woo-advanced-shipment-tracking'); ?></option>
996
- <option value="delivered"><?php _e('Delivered', 'woo-advanced-shipment-tracking'); ?></option>
997
- </select>
998
- </td>
999
- </tr>
1000
- <tr valign="top" class="hide_default show_if_shippment_status">
1001
- <th scope="row" class="">
1002
- <label for=""><?php _e('Shipment Status', 'woo-advanced-shipment-tracking'); ?></label>
1003
- </th>
1004
- <td scope="row" class="">
1005
- <select class="shipment_status_dropdown" id="shippment_status" name="shippment_status">
1006
- <option ><?php _e('Select', 'woo-advanced-shipment-tracking'); ?></option>
1007
- <?php foreach($email_status_array as $status){ ?>
1008
- <option value="<?php echo $status; ?>"><?php echo $this->trackship_status_filter_func($status); ?></option>
1009
- <?php }; ?>
1010
- </select>
1011
- </td>
1012
- </tr>
1013
- <tr valign="top" class="hide_default show_if_any">
1014
- <th scope="row" class="">
1015
- <label for=""><?php _e('Label', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip"title="<?php _e('For Internal Use', 'woo-advanced-shipment-tracking'); ?>"></span></label>
1016
- </th>
1017
- <td scope="row" class="">
1018
- <input type="text" id="email_label" name="email_label" placeholder="<?php _e('For Internal Use', 'woo-advanced-shipment-tracking'); ?>">
1019
- </td>
1020
- </tr>
1021
- <tr valign="top" class="hide_default show_if_any">
1022
- <th scope="row" class="">
1023
- <label for=""><?php _e('To', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip"title="<?php _e('Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woo-advanced-shipment-tracking'); ?>"></span></label>
1024
- </th>
1025
- <td scope="row" class="">
1026
- <input type="text" id="email_to" name="email_to" placeholder="<?php _e('E.g. {customer.email}, admin@example.org', 'woo-advanced-shipment-tracking'); ?>">
1027
- </td>
1028
- </tr>
1029
- <tr valign="top" class="hide_default show_if_any">
1030
- <th scope="row" class="">
1031
- <label for=""><?php _e('Email subject', 'woo-advanced-shipment-tracking'); ?></label>
1032
- <span class="woocommerce-help-tip" title="<?php _e('Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking'); ?>"></span>
1033
- </th>
1034
- <td scope="row" class="">
1035
- <input type="text" id="email_subject" name="email_subject" placeholder="<?php _e('Please enter email subject here', 'woo-advanced-shipment-tracking'); ?>">
1036
- </td>
1037
- </tr>
1038
- <tr valign="top" class="hide_default show_if_any">
1039
- <th scope="row" class="">
1040
- <label for=""><?php _e('Email heading', 'woo-advanced-shipment-tracking'); ?></label>
1041
- <span class="woocommerce-help-tip" title="<?php _e('Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking'); ?>"></span>
1042
- </th>
1043
- <td scope="row" class="">
1044
- <input type="text" id="email_heading" name="email_heading" placeholder="<?php _e('Please enter email heading here', 'woo-advanced-shipment-tracking'); ?>">
1045
- </td>
1046
- </tr>
1047
- <tr valign="top" class="hide_default show_if_any">
1048
- <th scope="row" class="" colspan="2">
1049
- <label for=""><?php _e('Email content', 'woo-advanced-shipment-tracking'); ?></label>
1050
- </th>
1051
- </tr>
1052
- <tr valign="top" class="hide_default show_if_any" colspan="2">
1053
- <th scope="row" class="" colspan="2">
1054
- <div class="variable_div variable_before_content">
1055
- <h4 style="margin:0;"><?php _e('Variables', 'woo-advanced-shipment-tracking'); ?></h4>
1056
- <div class="variable_tag" id="variable_tag" ><input type="text" id="var_input" value="{site_title}" style="width: 90px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1057
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_email}" style="width: 115px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1058
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_first_name}"style="width: 150px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1059
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_last_name}" style="width: 145px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1060
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_username}" style="width: 135px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1061
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_number}" style="width: 103px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1062
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_details}" style="width: 110px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1063
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{tracking_details}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1064
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{shipping_address}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1065
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{billing_address}"style="width: 125px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1066
- </div>
1067
- <?php
1068
- $content = '';
1069
- $editor_id = 'email_content';
1070
- $settings = array(
1071
- 'editor_height' => 200,
1072
- 'textarea_rows' => 20,
1073
- );
1074
- wp_editor( $content, $editor_id, [
1075
- 'textarea_name' => $editor_id,
1076
- 'tinymce' => true, // default to visual
1077
- 'quicktags' => true,
1078
- 'editor_height' => 200,
1079
- ]);
1080
- //wp_editor( $content, $editor_id, $settings );?>
1081
- </th>
1082
- </tr>
1083
- </tbody>
1084
- </table>
1085
- <div class="variable_div hide_default show_if_any">
1086
- <h4><?php _e('Variables', 'woo-advanced-shipment-tracking'); ?></h4>
1087
- <div class="variable_tag" id="variable_tag" ><input type="text" id="var_input" value="{site_title}" style="width: 90px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1088
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_email}" style="width: 115px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1089
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_first_name}"style="width: 150px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1090
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_last_name}" style="width: 145px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1091
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_username}" style="width: 135px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1092
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_number}" style="width: 103px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1093
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_details}" style="width: 110px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1094
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{tracking_details}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1095
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{shipping_address}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1096
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{billing_address}"style="width: 125px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
1097
- </div>
1098
- <div class="" style="clear:both;">
1099
- <input type="hidden" name="action" value="save_status_email">
1100
- <button type="submit" class="button-primary btn_green hide_default show_if_any" name="save_shipment_status_email" id="save_shipment_status_email"><?php _e('Save', 'woo-advanced-shipment-tracking'); ?></button>
1101
- </div>
1102
- </form>
1103
-
1104
- <?php echo $this->status_email_list(); ?>
1105
  </section>
1106
  </div>
1107
  <div class="zorem_admin_sidebar">
1108
- <div class="zorem-sidebar-title">zorem recommendations for you</div>
 
 
 
 
 
 
 
 
1109
  <div class="zorem-sidebar__section">
1110
- <h3>Recommended plugins</h3>
1111
  <?php
1112
  $plugin_array = array(
1113
- 0 => array(
1114
- 'name' => 'Country Based Restrictions for WooCommerce',
1115
- 'url' => 'https://wordpress.org/plugins/woo-product-country-base-restrictions/',
1116
- 'img' => 'WooCommerce-Country-Based-Restrictions-thumbnail.jpg',
1117
- ),
1118
- 1 => array(
1119
  'name' => 'Shop Manager Admin Bar for WooCommerce',
1120
  'url' => 'https://wordpress.org/plugins/woo-shop-manager-admin-bar/',
1121
  'img' => 'woocommerce-shop-manager-admin-bar-thumbnail.jpg',
1122
  ),
 
 
 
 
 
 
 
 
 
 
1123
  2 => array(
1124
  'name' => 'Sales Report Email for WooCommerce',
1125
  'url' => 'https://wordpress.org/plugins/woo-advanced-sales-report-email/',
1126
  'img' => 'woocommerce-advanced-sales-report-email-thumbnail.jpg',
1127
- ),
1128
- 3 => array(
1129
- 'name' => 'Ajax Login/Register for WooCommerce',
1130
- 'url' => 'https://wordpress.org/plugins/woo-ajax-loginregister/',
1131
- 'img' => 'WooCommerce-Ajax-Login-Register-thumbnail.jpg',
1132
  ),
1133
  4 => array(
1134
  'name' => 'Sales Report By Country for WooCommerce',
@@ -1144,7 +1016,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1144
  'name' => 'Bit Payment Gateway for WooCommerce',
1145
  'url' => 'https://wordpress.org/plugins/woo-bit-payment-gateway/',
1146
  'img' => 'WooCommerce-Bit-payment-thumbnail.jpg',
1147
- ),
1148
  );
1149
  ?>
1150
  <ul>
@@ -1152,6 +1024,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1152
  <li><img class="plugin_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['img']?>"><a class="plugin_url" href="<?php echo $plugin['url']?>" target="_blank"><?php echo $plugin['name']?></a></li>
1153
  <?php }?>
1154
  </ul>
 
1155
  </div>
1156
  </div>
1157
  </div>
@@ -1353,11 +1226,13 @@ class WC_Advanced_Shipment_Tracking_Admin {
1353
  'type' => 'checkbox',
1354
  'title' => __( 'Rename the “Completed” Order status to “Shipped”', 'woo-advanced-shipment-tracking' ),
1355
  'desc' => '',
 
1356
  ),
1357
  'wc_ast_status_delivered' => array(
1358
  'type' => 'checkbox',
1359
  'title' => __( 'Enable a New Custom order status - “Delivered”', 'woo-advanced-shipment-tracking' ),
1360
  'tooltip' => __( 'if you enable the delivered item, you will have the option to send delivered email notifications.', 'woo-advanced-shipment-tracking' ),
 
1361
  ),
1362
  'wc_ast_status_label_color' => array(
1363
  'type' => 'color',
@@ -1365,128 +1240,10 @@ class WC_Advanced_Shipment_Tracking_Admin {
1365
  'desc' => '',
1366
  'class' => 'status_label_color_th',
1367
  ),
1368
- 'wc_ast_select_email_type' => array(
1369
- 'type' => 'dropdown',
1370
- 'title' => __( 'Select Delivered Email Type', 'woo-advanced-shipment-tracking' ),
1371
- 'desc' => '',
1372
- 'options' => array(
1373
- '' => __( 'Select', 'woo-advanced-shipment-tracking' ),
1374
- 'wc_email' => 'WooCommerce email',
1375
- 'wcast_email' => 'Advanced Shipment Tracking Email',
1376
- ),
1377
- 'class' => 'status_label_color_th',
1378
- ),
1379
- 'wc_ast_manage_delivered_order_email' => array(
1380
- 'type' => 'tooltip_button',
1381
- 'title' => __( 'Manage delivered order email', 'woo-advanced-shipment-tracking' ),
1382
- 'link_label' => __( 'Click here', 'woo-advanced-shipment-tracking' ),
1383
- 'link' => admin_url( 'admin.php?page=wc-settings&tab=email&section=wc_email_customer_delivered_order' ),
1384
- 'target' => '_blank',
1385
- 'desc' => '',
1386
- 'class' => 'status_label_color_th manage_delivered_order_email_link',
1387
- ),
1388
- );
1389
- return $form_data;
1390
-
1391
- }
1392
-
1393
- /*
1394
- * get settings tab array data
1395
- * return array
1396
- */
1397
- function get_email_settings_data(){
1398
- $font_size_array[ '' ] = __( 'Select', 'woo-advanced-shipment-tracking' );
1399
- for ( $i = 10; $i <= 30; $i++ ) {
1400
- $font_size_array[ $i ] = $i."px";
1401
- }
1402
-
1403
- $form_data = array(
1404
- 'display_shipment_provider_thumbnail' => array(
1405
- 'type' => 'checkbox',
1406
- 'title' => __( 'Display Shipment Provider image/thumbnail', 'woo-advanced-shipment-tracking' ),
1407
- 'desc' => '',
1408
- ),
1409
- 'remove_date_from_tracking_info' => array(
1410
- 'type' => 'checkbox',
1411
- 'title' => __( 'Remove date from tracking info', 'woo-advanced-shipment-tracking' ),
1412
- 'desc' => '',
1413
- ),
1414
- 'email_shipment_tracking_header' => array(
1415
- 'type' => 'text',
1416
- 'title' => __( 'Header Text', 'woo-advanced-shipment-tracking' ),
1417
- 'desc' => '',
1418
- 'placeholder' => __( 'Tracking Information', 'woo-advanced-shipment-tracking' ),
1419
- ),
1420
- 'email_shipment_tracking_header_text' => array(
1421
- 'type' => 'textarea',
1422
- 'title' => __( 'Additional text after header', 'woo-advanced-shipment-tracking' ),
1423
- 'desc' => '',
1424
- ),
1425
- 'email_table_backgroud_color' => array(
1426
- 'type' => 'color',
1427
- 'title' => __( 'Table Background color', 'woo-advanced-shipment-tracking' ),
1428
- 'desc' => '',
1429
- 'class' => 'color_field',
1430
- ),
1431
- 'email_border_color' => array(
1432
- 'type' => 'text',
1433
- 'title' => __( 'Table Border color', 'woo-advanced-shipment-tracking' ),
1434
- 'desc' => '',
1435
- 'class' => 'color_field',
1436
- ),
1437
- 'email_border_size' => array(
1438
- 'type' => 'dropdown',
1439
- 'title' => __( 'Table Border size', 'woo-advanced-shipment-tracking' ),
1440
- 'desc' => '',
1441
- 'options' => array(
1442
- '' => __( 'Select', 'woo-advanced-shipment-tracking' ),
1443
- '1' => '1 px',
1444
- '2' => '2 px',
1445
- '3' => '3 px',
1446
- '4' => '4 px',
1447
- '5' => '5 px',
1448
- )
1449
- ),
1450
- 'email_table_header_font_size' => array(
1451
- 'type' => 'dropdown',
1452
- 'title' => __( 'Table header font size', 'woo-advanced-shipment-tracking' ),
1453
- 'desc' => '',
1454
- 'options' => $font_size_array
1455
- ),
1456
- 'email_table_header_font_color' => array(
1457
- 'type' => 'color',
1458
- 'title' => __( 'Table header font color', 'woo-advanced-shipment-tracking' ),
1459
- 'desc' => '',
1460
- 'class' => 'color_field',
1461
- ),
1462
- 'email_table_content_font_size' => array(
1463
- 'type' => 'dropdown',
1464
- 'title' => __( 'Table content font size', 'woo-advanced-shipment-tracking' ),
1465
- 'desc' => '',
1466
- 'options' => $font_size_array
1467
- ),
1468
- 'email_table_content_font_color' => array(
1469
- 'type' => 'color',
1470
- 'title' => __( 'Table content font color', 'woo-advanced-shipment-tracking' ),
1471
- 'desc' => '',
1472
- 'class' => 'color_field',
1473
- ),
1474
- 'email_table_tracking_link_font_color' => array(
1475
- 'type' => 'color',
1476
- 'title' => __( 'Tracking link font color', 'woo-advanced-shipment-tracking' ),
1477
- 'desc' => '',
1478
- 'class' => 'color_field',
1479
- ),
1480
- 'email_table_tracking_link_bg_color' => array(
1481
- 'type' => 'color',
1482
- 'title' => __( 'Tracking link background color', 'woo-advanced-shipment-tracking' ),
1483
- 'desc' => '',
1484
- 'class' => 'color_field',
1485
- )
1486
  );
1487
  return $form_data;
1488
 
1489
- }
1490
 
1491
  /*
1492
  * settings form save
@@ -1496,16 +1253,12 @@ class WC_Advanced_Shipment_Tracking_Admin {
1496
  if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_settings_form', 'wc_ast_settings_form' ) ) {
1497
 
1498
  //echo '<pre>';print_r($_POST);echo '</pre>';
1499
- $data = $this->get_settings_data();
1500
- $email_data = $this->get_email_settings_data();
1501
- //echo '<pre>';print_r($data);echo '</pre>';
1502
 
1503
  foreach( $data as $key => $val ){
1504
  update_option( $key, sanitize_text_field( $_POST[ $key ] ) );
1505
  }
1506
- foreach( $email_data as $key => $val ){
1507
- update_option( $key, sanitize_text_field( $_POST[ $key ] ) );
1508
- }
1509
  echo json_encode( array('success' => 'true') );die();
1510
 
1511
  }
@@ -1641,74 +1394,79 @@ class WC_Advanced_Shipment_Tracking_Admin {
1641
  }
1642
  ?>
1643
  <tr class="provider_tr <?php if($d_s_p->display_in_order != 1) { echo 'status_deactivate'; } ?> <?php if($d_s_p->shipping_default == 0) { echo 'custom_provider_tr'; } ?>">
1644
- <td class="column-columnname thumb-column">
1645
  <?php if( $d_s_p->shipping_default == 1 ){ ?>
1646
- <img class="provider_thumbnail on_edit_hide" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/<?php echo sanitize_title($d_s_p->provider_name);?>.png">
1647
  <?php } else{
1648
  $custom_thumb_id = $d_s_p->custom_thumb_id;
1649
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
 
1650
  if($custom_thumb_id != 0){ ?>
1651
- <img class="provider_thumbnail on_edit_hide" src="<?php echo $image_attributes[0]; ?>">
1652
  <?php } else{
1653
  ?>
1654
- <img class="provider_thumbnail on_edit_hide" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/icon-default.png">
1655
  <?php } ?>
1656
- <input type='text' name='data[<?php echo $d_s_p->id?>][thumb_url]' class='image_path on_edit_show' placeholder='Image' value='<?php echo $image_attributes[0]; ?>' id='image_path' style="width: 95px;margin-top: 10px;">
1657
- <input type='hidden' name='data[<?php echo $d_s_p->id?>][thumb_id]' class='image_id' placeholder="Image" value='<?php echo $custom_thumb_id; ?>' id='image_id' style="">
1658
- <input id="upload_image_button" type="button" class="button on_edit_show" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
1659
  <?php } ?>
1660
- <span class="provider_name on_edit_hide">
1661
- <?php
1662
- echo $d_s_p->provider_name; ?>
1663
- </span>
1664
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
1665
- <input type="text" class="text on_edit_show custom_provider_name" name="data[<?php echo $d_s_p->id?>][provider_name]" value="<?php echo $d_s_p->provider_name;?>" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>">
1666
- <?php } ?>
1667
  </td>
1668
- <td class="column-columnname country_select_box">
1669
- <span class="on_edit_hide">
1670
- <?php
1671
- $search = array('(US)', '(UK)');
1672
- $replace = array('', '');
1673
- echo str_replace($search, $replace, $WC_Countries->countries[$d_s_p->shipping_country]);
1674
- ?>
1675
- </span>
1676
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
1677
- <select class="on_edit_show custom_provider_country" name="data[<?php echo $d_s_p->id?>][shipping_country]" >
1678
- <option value="" ><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
1679
- <?php foreach($countries as $key=>$val){ ?>
1680
- <option value="<?php echo $key; ?>" <?php if ( $key == $d_s_p->shipping_country ) echo 'selected'?>><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
1681
- <?php } ?>
1682
- </select>
1683
- <?php } ?>
1684
  </td>
1685
- <td class="column-columnname url-column">
1686
- <a href="<?php echo $d_s_p->provider_url; ?>" title="<?php echo $d_s_p->provider_url; ?>" target="_blank" class="on_edit_hide"><?php _e( 'Tracking Page', 'woo-advanced-shipment-tracking' ); ?>
1687
- </a>
1688
- <?php if( $d_s_p->shipping_default == 0 ){ ?>
1689
- <input type="text" class="text on_edit_show custom_provider_url" name="data[<?php echo $d_s_p->id?>][provider_url]" value="<?php echo $d_s_p->provider_url;?>" placeholder="<?php _e( 'Shipping URL', 'woo-advanced-shipment-tracking' ); ?>">
1690
- <?php }?>
1691
  </td>
1692
- <td class="column-columnname">
1693
  <span class="mdl-list__item-secondary-action">
1694
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="list-switch-<?php echo $d_s_p->id; ?>">
1695
  <input type="checkbox" name="select_custom_provider[]" id="list-switch-<?php echo $d_s_p->id; ?>" class="mdl-switch__input status_slide" value="<?php echo $d_s_p->id; ?>" <?php if($d_s_p->display_in_order == 1) { echo 'checked'; } ?> />
1696
  </label>
1697
  </span>
1698
  </td>
1699
- <td class="column-columnname">
1700
  <?php if( $d_s_p->shipping_default == 0 ){ ?>
1701
- <span class="dashicons dashicons-edit edit_provider on_edit_hide" style="display:none"></span>
1702
- <span class="dashicons dashicons-trash remove on_edit_hide" data-pid="<?php echo $d_s_p->id; ?>" style="display:none"></span>
1703
- <button class="button button-primary on_edit_show update_provider btn_green" style="display:none;"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
1704
  <?php } ?>
1705
- <span class="dashicons dashicons-editor-justify sort-item ui-sortable-handle on_edit_hide"></span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1706
  <input type="hidden" name="provider_id" class="provider_id" value="<?php echo $d_s_p->id?>">
1707
  <input type="hidden" name="sorting[<?php echo $d_s_p->id?>][sort_order]" class="sort_order" value="<?php echo $d_s_p->sort_order?>">
1708
- <input type="hidden" name="data[<?php echo $d_s_p->id?>][sort_order]" class="" value="<?php echo $d_s_p->sort_order?>">
1709
- <input type="hidden" name="data[<?php echo $d_s_p->id?>][thumb_url]" class="" value="<?php echo $image_attributes[0]; ?>">
1710
-
1711
- </td>
1712
  </tr>
1713
  <?php } ?>
1714
  </tbody>
@@ -1748,34 +1506,7 @@ class WC_Advanced_Shipment_Tracking_Admin {
1748
  }
1749
  </style>
1750
  <?php
1751
- }
1752
-
1753
- /**
1754
- * Preview email template.
1755
- */
1756
- public function preview_emails() {
1757
-
1758
- if ( isset( $_GET['preview_tracking_info_design'] ) ) {
1759
- if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'preview-mail' ) ) {
1760
- die( 'Security check' );
1761
- }
1762
- $mailer = WC()->mailer();
1763
-
1764
- // get the preview email subject
1765
- $email_heading = __( 'HTML email template', 'woocommerce' );
1766
- ob_start();
1767
- include 'views/html-tracking-info-design-preview.php';
1768
- $message = ob_get_clean();
1769
- // create a new email
1770
- $email = new WC_Email();
1771
-
1772
- // wrap the content with the email template and then add styles
1773
- $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
1774
-
1775
- echo $message;
1776
- exit;
1777
- }
1778
- }
1779
 
1780
  function upload_tracking_csv_fun(){
1781
 
@@ -1855,23 +1586,26 @@ class WC_Advanced_Shipment_Tracking_Admin {
1855
  $tracking_provider = $_POST['tracking_provider'];
1856
  $tracking_number = $_POST['tracking_number'];
1857
  $date_shipped = str_replace("/","-",$_POST['date_shipped']);
 
 
 
1858
  $replace_tracking_info = $_POST['replace_tracking_info'];
1859
-
1860
  global $wpdb;
1861
  $woo_shippment_table_name = $this->table;
1862
  $shippment_provider = $wpdb->get_var( "SELECT COUNT(*) FROM $woo_shippment_table_name WHERE provider_name = '".$tracking_provider."'" );
1863
 
1864
  if($shippment_provider == 0){
1865
- echo '<li class="error">Failed - Invalid Tracking Provider</li>';exit;
1866
  }
1867
  if(empty($tracking_number)){
1868
- echo '<li class="error">Failed - Empty Tracking Number</li>';exit;
1869
  }
1870
  if(empty($date_shipped)){
1871
- echo '<li class="error">Failed - Empty Date Shipped</li>';exit;
1872
  }
1873
  if(!$this->isDate($date_shipped)){
1874
- echo '<li class="error">Failed - Invalid Date Shipped</li>';exit;
1875
  }
1876
 
1877
  if($replace_tracking_info == 1){
@@ -1882,7 +1616,13 @@ class WC_Advanced_Shipment_Tracking_Admin {
1882
 
1883
  if ( count( $tracking_items ) > 0 ) {
1884
  foreach ( $tracking_items as $key => $item ) {
1885
- unset( $tracking_items[ $key ] );
 
 
 
 
 
 
1886
  }
1887
  $wast->save_tracking_items( $order_id, $tracking_items );
1888
  }
@@ -1962,238 +1702,6 @@ class WC_Advanced_Shipment_Tracking_Admin {
1962
  }
1963
  return $status;
1964
  }
1965
- public function save_status_email_fun(){
1966
- global $wpdb;
1967
- $table_name = $wpdb->prefix.'woo_shipment_status_email';
1968
-
1969
- $data = array(
1970
- 'email_trigger' => $_POST['email_trigger'],
1971
- 'order_status' => $_POST['order_status'],
1972
- 'shippment_status' => $_POST['shippment_status'],
1973
- 'email_label' => $_POST['email_label'],
1974
- 'email_to' => $_POST['email_to'],
1975
- 'email_subject' => $_POST['email_subject'],
1976
- 'email_heading' => $_POST['email_heading'],
1977
- 'email_content' => $_POST['email_content']
1978
- );
1979
-
1980
- $wpdb->insert( $table_name, $data );
1981
- $insertid = $wpdb->insert_id;
1982
- //echo '<pre>';print_r($table_name);echo '</pre>';exit;
1983
- ob_start();
1984
- $this->status_email_list();
1985
- $email_html = ob_get_clean();
1986
- $response = array();
1987
- $response['html'] = $email_html;
1988
- $response['insertid'] = $insertid;
1989
- echo json_encode($response);exit;
1990
- }
1991
-
1992
- public function update_status_email_fun(){
1993
-
1994
- $email_content = 'email_content_'.$_POST['status_email_id'];
1995
- global $wpdb;
1996
- $table_name = $wpdb->prefix.'woo_shipment_status_email';
1997
- $data = array(
1998
- 'enable' => $_POST['enable'],
1999
- 'email_label' => $_POST['email_label'],
2000
- 'email_to' => $_POST['email_to'],
2001
- 'order_status' => $_POST['order_status'],
2002
- 'email_subject' => $_POST['email_subject'],
2003
- 'email_heading' => $_POST['email_heading'],
2004
- 'email_content' => $_POST['email_content'],
2005
- );
2006
- //echo '<pre>';print_r($data);echo '</pre>';
2007
- $where = array(
2008
- 'id' => $_POST['status_email_id']
2009
- );
2010
- $wpdb->update( $table_name, $data, $where );
2011
- echo $this->status_email_list();exit;
2012
- }
2013
-
2014
- public function delete_status_email_fun(){
2015
- global $wpdb;
2016
- $table_name = $wpdb->prefix.'woo_shipment_status_email';
2017
- $where = array(
2018
- 'id' => $_POST['status_email_id'],
2019
- );
2020
- $wpdb->delete( $table_name, $where );
2021
- echo $this->status_email_list();exit;
2022
- }
2023
-
2024
- public function status_email_list(){
2025
- global $wpdb;
2026
- $shipment_status_email = $wpdb->prefix.'woo_shipment_status_email';
2027
- $shipment_status_email_list = $wpdb->get_results( "SELECT * FROM $shipment_status_email" );
2028
- $shipment_status_email_ids = $wpdb->get_col( "SELECT id FROM $shipment_status_email" );
2029
- $id_string = implode(",",$shipment_status_email_ids);
2030
- $email_status_array = array(
2031
- 0 => 'pre_transit',
2032
- 1 => 'in_transit',
2033
- 2 => 'out_for_delivery',
2034
- 3 => 'delivered',
2035
- 4 => 'available_for_pickup',
2036
- 5 => 'return_to_sender',
2037
- );
2038
- ?>
2039
- <section class="ac-container">
2040
- <?php foreach($shipment_status_email_list as $email_list){
2041
-
2042
- ?>
2043
- <div>
2044
- <form id="status_email_form_<?php echo $email_list->id; ?>" action="" method="post">
2045
- <input id="ac-<?php echo $email_list->id; ?>" name="accordion-1" class="accordion-radio" type="checkbox"/>
2046
- <label class="headig_label <?php if($email_list->enable == 1){ echo 'enable'; } else{ echo 'disable'; }?>" for="ac-<?php echo $email_list->id; ?>">
2047
- <span class="email_status_span"><?php
2048
- if($email_list->enable == 1){
2049
- echo '<i id="enable_t_'.$email_list->id.'" class="material-icons enable">lens</i><div class="mdl-tooltip mdl-tooltip--large mdl-tooltip--top" data-mdl-for="enable_t_'.$email_list->id.'">'.__('Enable', 'woo-advanced-shipment-tracking').'</div>';
2050
- } else{
2051
- echo '<i id="disable_t_'.$email_list->id.'" class="material-icons disable">panorama_fish_eye</i><div class="mdl-tooltip mdl-tooltip--large mdl-tooltip--top" data-mdl-for="disable_t_'.$email_list->id.'">'.__('Disable', 'woo-advanced-shipment-tracking').'</div>';
2052
- }
2053
- ?>
2054
- </span>
2055
- <?php echo $email_list->email_label; ?></label>
2056
- <article class="ac-small">
2057
- <table class="form-table">
2058
- <tbody>
2059
-
2060
- <tr valign="top" class="">
2061
- <th scope="row" class="">
2062
- <label for=""><?php _e('Enable/Disable', 'woo-advanced-shipment-tracking'); ?></label>
2063
- </th>
2064
- <td scope="row" class="">
2065
- <span class="mdl-list__item-secondary-action">
2066
- <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="enable_<?php echo $email_list->id; ?>">
2067
- <input type="checkbox" id="enable_<?php echo $email_list->id; ?>" name="enable" class="mdl-switch__input" <?php echo $email_list->enable ? 'checked':''?> value="1"/>
2068
- </label>
2069
- </span>
2070
- </td>
2071
- </tr>
2072
- <tr valign="top" class="">
2073
- <th scope="row" class="">
2074
- <label for=""><?php _e('Order Status', 'woo-advanced-shipment-tracking'); ?></label>
2075
- </th>
2076
- <td scope="row" class="">
2077
- <select class="shipment_status_dropdown" name="order_status" id="order_status_<?php echo $email_list->id; ?>">
2078
- <option><?php _e('Select', 'woo-advanced-shipment-tracking'); ?></option>
2079
- <option value="delivered" <?php if( 'delivered' == $email_list->order_status )echo 'selected'; ?>><?php _e('Delivered', 'woo-advanced-shipment-tracking'); ?></option>
2080
- </select>
2081
- </td>
2082
- </tr>
2083
- <tr valign="top" class="">
2084
- <th scope="row" class="">
2085
- <label for=""><?php _e('Label', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip" title="<?php _e('For Internal Use', 'woo-advanced-shipment-tracking'); ?>"></span></label>
2086
- </th>
2087
- <td scope="row" class="">
2088
- <input type="text" name="email_label" id="email_label_<?php echo $email_list->id; ?>" value="<?php echo $email_list->email_label; ?>" placeholder="<?php _e('For Internal Use', 'woo-advanced-shipment-tracking'); ?>">
2089
- </td>
2090
- </tr>
2091
- <!--tr valign="top" class="">
2092
- <th scope="row" class="">
2093
- <label for="">Shipment Status</label>
2094
- </th>
2095
- <td scope="row" class="">
2096
- <select class="shipment_status_dropdown" name="shippment_status">
2097
- <option >Select</option>
2098
- <?php foreach($email_status_array as $status){ ?>
2099
- <option value="<?php echo $status; ?>" <?php if( $status == $email_list->shippment_status )echo 'selected'; ?>><?php echo $this->trackship_status_filter_func($status); ?></option>
2100
- <?php }; ?>
2101
- </select>
2102
- </td>
2103
- </tr-->
2104
- <tr valign="top" class="">
2105
- <th scope="row" class="">
2106
- <label for=""><?php _e('To', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip" title="<?php _e('Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woo-advanced-shipment-tracking'); ?>"></span></label>
2107
- </th>
2108
- <td scope="row" class="">
2109
- <input type="text" id="email_to_<?php echo $email_list->id; ?>" name="email_to" value="<?php echo $email_list->email_to; ?>" placeholder="<?php _e('E.g. {customer.email}, admin@example.org', 'woo-advanced-shipment-tracking'); ?>">
2110
- </td>
2111
- </tr>
2112
- <tr valign="top" class="">
2113
- <th scope="row" class="">
2114
- <label for=""><?php _e('Email subject', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip" title="<?php _e('Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking'); ?>"></span></label>
2115
- </th>
2116
- <td scope="row" class="">
2117
- <input type="text" id="email_subject_<?php echo $email_list->id; ?>" name="email_subject" value="<?php echo $email_list->email_subject; ?>" placeholder="<?php _e('Please enter email subject here', 'woo-advanced-shipment-tracking'); ?>">
2118
- </td>
2119
- </tr>
2120
- <tr valign="top" class="">
2121
- <th scope="row" class="">
2122
- <label for=""><?php _e('Email heading', 'woo-advanced-shipment-tracking'); ?><span class="woocommerce-help-tip" title="<?php _e('Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking'); ?>"></span></label>
2123
- </th>
2124
- <td scope="row" class="">
2125
- <input type="text" id="email_heading_<?php echo $email_list->id; ?>" name="email_heading" value="<?php echo $email_list->email_heading; ?>" placeholder="<?php _e('Please enter email heading here', 'woo-advanced-shipment-tracking'); ?>">
2126
- </td>
2127
- </tr>
2128
- <tr valign="top" class="">
2129
- <th scope="row" class="" colspan="2">
2130
- <label for=""><?php _e('Email content', 'woo-advanced-shipment-tracking'); ?></label>
2131
- </th>
2132
- </tr>
2133
- <tr valign="top" class="">
2134
- <th scope="row" class="" colspan="2">
2135
- <div class="variable_div variable_before_content">
2136
- <h4><?php _e('Variables', 'woo-advanced-shipment-tracking'); ?></h4>
2137
- <div class="variable_tag" id="variable_tag" ><input type="text" id="var_input" value="{site_title}" style="width: 90px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2138
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_email}" style="width: 115px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2139
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_first_name}"style="width: 150px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2140
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_last_name}" style="width: 145px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2141
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_username}" style="width: 135px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2142
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_number}" style="width: 103px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2143
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_details}" style="width: 110px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2144
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{tracking_details}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2145
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{shipping_address}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2146
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{billing_address}"style="width: 125px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2147
- </div>
2148
- <?php
2149
- add_filter( 'wp_default_editor', create_function('', 'return "visual";') );
2150
- $content = $email_list->email_content;
2151
- $id = 'email_content_'.$email_list->id;
2152
- $editor_id = 'email_content';
2153
- $settings = array(
2154
- 'editor_height' => 100,
2155
- 'textarea_rows' => 20,
2156
- );
2157
- wp_editor( $content, $id, [
2158
- 'textarea_name' => $editor_id,
2159
- 'tinymce' => true, // default to visual
2160
- 'quicktags' => true,
2161
- 'editor_height' => 200,
2162
- ]);
2163
- ?>
2164
- <!--textarea name="<?php echo $editor_id; ?>"><?php echo $content; ?></textarea-->
2165
- </th>
2166
- </tr>
2167
- <tr valign="top" class="">
2168
- <th scope="row" class="" colspan="2">
2169
- <button type="button" class="button-primary btn_green" name="update_shipment_status_email_btn" id="update_shipment_status_email_btn" data-id="<?php echo $email_list->id; ?>"><?php _e('Update', 'woo-advanced-shipment-tracking'); ?></button>
2170
- <button type="button" class="button-primary btn_red" name="delete_shipment_status_email_btn" id="delete_shipment_status_email_btn" data-id="<?php echo $email_list->id; ?>"><?php _e('Delete', 'woo-advanced-shipment-tracking'); ?></button>
2171
- </th>
2172
- </tr>
2173
- </tbody>
2174
- </table>
2175
- <div class="variable_div">
2176
- <h4><?php _e('Variables', 'woo-advanced-shipment-tracking'); ?></h4>
2177
- <div class="variable_tag" id="variable_tag" ><input type="text" id="var_input" value="{site_title}" style="width: 90px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2178
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_email}" style="width: 115px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2179
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_first_name}"style="width: 150px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2180
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_last_name}" style="width: 145px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2181
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{customer_username}" style="width: 135px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2182
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_number}" style="width: 103px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2183
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{order_details}" style="width: 110px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2184
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{tracking_details}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2185
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{shipping_address}" style="width: 130px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2186
- <div class="variable_tag" id="variable_tag"><input type="text" id="var_input" value="{billing_address}"style="width: 125px;"><span class="copy"><?php _e('Copied', 'woo-advanced-shipment-tracking'); ?></span></div>
2187
- </div>
2188
- <input type="hidden" name="id_list" id="id_list" value="<?php echo $id_string; ?>">
2189
- <input type="hidden" name="action" value="update_status_email">
2190
- <input type="hidden" name="status_email_id" class="status_email_id" value="<?php echo $email_list->id; ?>">
2191
- </article>
2192
- </form>
2193
- </div>
2194
- <?php } ?>
2195
- </section>
2196
- <?php }
2197
 
2198
  // define the item in the meta box by adding an item to the $actions array
2199
  function add_order_meta_box_actions( $actions ) {
@@ -2204,22 +1712,31 @@ class WC_Advanced_Shipment_Tracking_Admin {
2204
  if($email_type == 'wc_email'){
2205
  $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
2206
  } elseif($delivered_email_list){
2207
- $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
2208
- //wc_advanced_shipment_tracking_email_class()->delivered_order_status_email_trigger($order_id, $order);
2209
  }
2210
  return $actions;
2211
  }
2212
  function process_order_meta_box_actions($order){
2213
- require_once( 'email-manager.php' );
2214
- $email_type = get_option('wc_ast_select_email_type');
2215
- if($email_type == 'wc_email'){
2216
- WC()->mailer()->emails['WC_Email_Customer_Delivered_Order']->trigger( $order->ID, $order );
2217
- } else{
2218
- wc_advanced_shipment_tracking_email_class()->delivered_order_status_email_trigger($order->ID, $order);
2219
- }
2220
  }
2221
  function update_email_type_fun(){
2222
  update_option("wc_ast_select_email_type", $_POST['email_type'] );
2223
  echo 1;exit;
2224
  }
 
 
 
 
 
 
 
 
 
 
2225
  }
135
  add_action( 'wp_ajax_delete_status_email', array( $this, 'delete_status_email_fun') );
136
 
137
  add_action( 'wp_ajax_update_email_type', array( $this, 'update_email_type_fun') );
138
+
139
+ add_action( 'wp_ajax_update_tracking_preview_order', array( $this, 'update_tracking_preview_order_fun') );
140
+
141
+ add_action( 'wp_ajax_update_email_preview_order', array( $this, 'update_email_preview_order_fun') );
142
 
143
+ add_action( 'admin_footer', array( $this, 'footer_function') );
 
 
144
  }
145
 
146
  /*
580
  public function register_woocommerce_menu() {
581
  add_submenu_page( 'woocommerce', 'Shipment Tracking', 'Shipment Tracking', 'manage_options', 'woocommerce-advanced-shipment-tracking', array( $this, 'woocommerce_advanced_shipment_tracking_page_callback' ) );
582
  }
583
+ public function sortByCountryAsc($a, $b) {
584
+ return strcmp($a->country, $b->country);
585
+ }
586
+ public function sortByCountryDesc($a, $b) {
587
+ return strcmp($b->country, $a->country);
588
+ }
589
  /*
590
  * callback for Shipment Tracking page
591
  */
663
 
664
 
665
  $default_shippment_providers = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name ORDER BY `{$orderby}` {$order} " );
666
+
667
+
668
+ foreach($default_shippment_providers as $key => $value){
669
+ $search = array('(US)', '(UK)');
670
+ $replace = array('', '');
671
+ $country = str_replace($search, $replace, $WC_Countries->countries[$value->shipping_country]);
672
+ $default_shippment_providers[$key]->country = $country;
673
+ }
674
+
675
+ if(isset( $_GET['orderby'] ) && $_GET['orderby'] == 'shipping_country' && $_GET['order'] == 'ASC'){
676
+ usort($default_shippment_providers, array( $this, 'sortByCountryAsc'));
677
+ }
678
+ if(isset( $_GET['orderby'] ) && $_GET['orderby'] == 'shipping_country' && $_GET['order'] == 'DESC'){
679
+ usort($default_shippment_providers, array( $this, 'sortByCountryDesc'));
680
+ }
681
+
682
  wp_enqueue_script( 'shipment_tracking_table_rows' );
683
  ?>
684
  <h3><?php _e('Advanced Shipment Tracking for WooCommerce', 'woo-advanced-shipment-tracking'); ?></h3>
689
  <label for="tab1" class="tab_label"><?php _e('Shipping Provider', 'woo-advanced-shipment-tracking'); ?></label>
690
 
691
  <input id="tab2" type="radio" name="tabs" class="tab_input">
692
+ <label for="tab2" class="tab_label"><?php _e('Settings', 'woo-advanced-shipment-tracking'); ?></label>
 
 
 
693
 
694
  <input id="tab4" type="radio" name="tabs" class="tab_input">
695
  <label for="tab4" class="tab_label"><?php _e('Bulk Upload', 'woo-advanced-shipment-tracking'); ?></label>
748
  continue;
749
  }
750
  ?>
751
+ <tr class="provider_tr <?php if($d_s_p->display_in_order != 1) { echo 'status_deactivate'; } ?> <?php if($d_s_p->shipping_default == 0) { echo 'custom_provider_tr'; } ?>">
752
+ <td class="column-columnname thumb-column on_edit_hide">
753
  <?php if( $d_s_p->shipping_default == 1 ){ ?>
754
+ <img class="provider_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/<?php echo sanitize_title($d_s_p->provider_name);?>.png">
755
  <?php } else{
756
  $custom_thumb_id = $d_s_p->custom_thumb_id;
757
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
758
  //echo '<pre>';print_r($custom_thumb_id);echo '</pre>';exit;
759
  if($custom_thumb_id != 0){ ?>
760
+ <img class="provider_thumbnail" src="<?php echo $image_attributes[0]; ?>">
761
  <?php } else{
762
  ?>
763
+ <img class="provider_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/icon-default.png">
764
  <?php } ?>
 
 
 
765
  <?php } ?>
766
+ <span class="provider_name">
767
+ <?php echo $d_s_p->provider_name; ?>
768
+ </span>
 
 
 
 
769
  </td>
770
+ <td class="column-columnname country_select_box on_edit_hide">
771
+ <span class="on_edit_hide">
772
+ <?php
773
+ $search = array('(US)', '(UK)');
774
+ $replace = array('', '');
775
+ echo str_replace($search, $replace, $WC_Countries->countries[$d_s_p->shipping_country]);
776
+ ?>
777
+ </span>
 
 
 
 
 
 
 
 
778
  </td>
779
+ <td class="column-columnname url-column on_edit_hide">
780
  <a href="<?php echo $d_s_p->provider_url; ?>" title="<?php echo $d_s_p->provider_url; ?>" target="_blank" class="on_edit_hide"><?php _e( 'Tracking Page','woo-advanced-shipment-tracking' ); ?>
781
+ </a>
 
 
 
782
  </td>
783
+ <td class="column-columnname status-column on_edit_hide">
784
  <span class="mdl-list__item-secondary-action">
785
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="list-switch-<?php echo $d_s_p->id; ?>">
786
  <input type="checkbox" name="select_custom_provider[]" id="list-switch-<?php echo $d_s_p->id; ?>" class="mdl-switch__input status_slide" value="<?php echo $d_s_p->id; ?>" <?php if($d_s_p->display_in_order == 1) { echo 'checked'; } ?> />
787
  </label>
788
  </span>
789
  </td>
790
+ <td class="column-columnname on_edit_hide">
791
  <?php if( $d_s_p->shipping_default == 0 ){ ?>
792
+ <span class="dashicons dashicons-edit edit_provider" style="display:none"></span>
793
+ <span class="dashicons dashicons-trash remove" data-pid="<?php echo $d_s_p->id; ?>" style="display:none"></span>
 
794
  <?php } ?>
795
+ <span class="dashicons dashicons-editor-justify sort-item ui-sortable-handle"></span>
 
 
 
796
  <?php
797
  $custom_thumb_id = $d_s_p->custom_thumb_id;
798
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id );
799
  ?>
800
  <input type="hidden" name="data[<?php echo $d_s_p->id?>][thumb_url]" class="image_path" value="<?php echo $image_attributes[0]; ?>">
801
  </td>
802
+ <td class="on_edit_show" colspan="5">
803
+ <input type="text" class="text custom_provider_name" name="data[<?php echo $d_s_p->id?>][provider_name]" value="<?php echo $d_s_p->provider_name;?>" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>"><br>
804
+
805
+ <select class="select custom_provider_country" name="data[<?php echo $d_s_p->id?>][shipping_country]" >
806
+ <option value="" ><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
807
+ <?php foreach($countries as $key=>$val){ ?>
808
+ <option value="<?php echo $key; ?>" <?php if ( $key == $d_s_p->shipping_country ) echo 'selected'?>><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
809
+ <?php } ?>
810
+ </select><br>
811
+
812
+ <input type='hidden' name='data[<?php echo $d_s_p->id?>][thumb_id]' class='image_id' placeholder="Image" value='<?php echo $custom_thumb_id; ?>' id='image_id' style="">
813
+ <input type='text' name='data[<?php echo $d_s_p->id?>][thumb_url]' class='image_path' placeholder="Image" value='<?php echo $image_attributes[0]; ?>' id='image_path' style="">
814
+ <input id="upload_image_button" type="button" class="button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" /><br>
815
+
816
+ <input type="text" class="text custom_provider_url" name="data[<?php echo $d_s_p->id?>][provider_url]" value="<?php echo $d_s_p->provider_url;?>" placeholder="<?php _e( 'Shipping URL', 'woo-advanced-shipment-tracking' ); ?>">
817
+ <p><?php _e('You can add tracking number parameter like this - http://shippingprovider.com?tracking_number=%number% , %number% - parameter', 'woo-advanced-shipment-tracking'); ?></p>
818
+
819
+ <input type="hidden" name="provider_id" class="provider_id" value="<?php echo $d_s_p->id?>">
820
+ <input type="hidden" name="sorting[<?php echo $d_s_p->id?>][sort_order]" class="sort_order" value="<?php echo $d_s_p->sort_order?>">
821
+ <input type="hidden" name="data[<?php echo $d_s_p->id?>][sort_order]" class="" value="<?php echo $d_s_p->sort_order?>"><br>
822
+ <button class="button button-primary update_provider btn_green"><?php _e( 'Update', 'woo-advanced-shipment-tracking' ); ?></button>
823
+ <a href="JavaScript:Void(0);" class="cancel_edit"><?php _e( 'Cancel' , 'woo-advanced-shipment-tracking'); ?></a>
824
+ </td>
825
  </tr>
826
+ <?php } ?>
827
  </tbody>
828
  <tfoot>
829
  <tr>
833
  </table>
834
  </form>
835
 
836
+ <script type="text/template" id="tmpl-shipping-provider-row-template">
837
+ <tr class="provider_tr tr_add">
838
+ <td colspan="5">
839
+ <table class="custom_provider_table">
840
+ <tr>
841
+ <td class="column-columnname shipping_provider">
842
+ <input type="text" class="text" value="{{{ data.rate.provider_name }}}" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>" name="data[{{{ data.index }}}][provider_name]" />
843
+ </td>
844
+ </tr>
845
+ <tr class="">
846
+ <td class="column-columnname shipping_country">
847
+ <select class="select wcast_shipping_country" name="data[{{{ data.index }}}][shipping_country]" >
848
+ <option value="" <# if ( "" === data.rate.rate_condition ) { #>selected="selected"<# } #>><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
849
+ <?php
850
+ foreach($countries as $key=>$val){ ?>
851
+ <option value="<?php echo $key; ?>" ><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
852
+ <?php }
853
+ ?>
854
+ </select>
855
+ </td>
856
+ </tr>
857
+ <tr class="">
858
+ <td class="column-columnname cusgtom_provider_thumb">
859
+ <input type='text' placeholder='Image' name='data[{{{ data.index }}}][thumb_url]' class='image_path' value='' id='image_path'>
860
+ <input type='hidden' name='data[{{{ data.index }}}][thumb_id]' class='image_id' placeholder="Image" value='' id='image_id' style="">
861
+ <input id="upload_image_button" type="button" class="button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" />
862
+ </td>
863
+ </tr>
864
+ <tr class="">
865
+ <td class="column-columnname shipping_url">
866
+ <input type="text" class="text" name="data[{{{ data.index }}}][provider_url]" value="" placeholder="<?php _e( 'Tracking Page', 'woo-advanced-shipment-tracking' ); ?>">
867
+ <p><?php _e('You can add tracking number parameter like this - http://shippingprovider.com?tracking_number=%number% , %number% - parameter', 'woo-advanced-shipment-tracking'); ?></p>
868
+ </td>
869
+ </tr>
870
+ <tr class="">
871
+ <td >
872
+ <input type="hidden" name="data[{{{ data.index }}}][sort_order]" class="sort_order" value="{{{ data.sort_id }}}">
873
+ <button class="button button-primary add_new btn_green"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
874
+ <a href="JavaScript:Void(0);" class="remove" data-pid="{{{ data.index }}}"><?php _e( 'Cancel' , 'woo-advanced-shipment-tracking'); ?></a>
875
+ <!--span class="dashicons dashicons-trash remove" data-pid="{{{ data.index }}}"></span-->
876
+ </td>
877
+ </tr>
878
+ </table>
879
  </td>
880
+ </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
881
  </script>
882
  </div>
883
  </section>
885
  <div class="tab_inner_container">
886
  <form method="post" id="wc_ast_settings_form" action="" enctype="multipart/form-data">
887
  <?php #nonce?>
888
+ <ul class="subsubsub">
889
+ <li><a href="javascript:void(0)" class="current">General</a> | </li>
890
+ <li><a href="<?php echo wcast_initialise_customizer_settings::get_customizer_url() ?>" class=""><?php _e( 'Tracking Info Display Designer', 'woo-advanced-shipment-tracking' ); ?></a></li>
891
+ </ul>
892
+ <br class="clear">
893
  <h3><?php _e( 'Settings', 'woo-advanced-shipment-tracking' ); ?></h3>
894
+ <?php $this->get_html( $this->get_settings_data() );?>
 
 
 
 
 
 
 
895
  <div class="submit">
896
  <button name="save" class="button-primary woocommerce-save-button btn_green" type="submit" value="Save changes"><?php _e( 'Save', 'woo-advanced-shipment-tracking' ); ?></button>
897
  <div class="spinner" style="float:none"></div>
899
  <div class="error_msg" style="display:none;"></div>
900
  <?php wp_nonce_field( 'wc_ast_settings_form', 'wc_ast_settings_form' );?>
901
  <input type="hidden" name="action" value="wc_ast_settings_form_update">
902
+ </div>
 
 
903
  </form>
904
  </div>
905
+ </section>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
906
  <section id="content4" class="tab_section">
907
  <div class="mdl-grid">
908
  <div class="mdl-cell mdl-cell--12-col">
945
 
946
  </ol>
947
  </form>
948
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
949
  </div>
950
  </section>
951
+ <section id="content5" class="tab_section">
952
+ <?php $wcast_enable_delivered_email = get_theme_mod('wcast_enable_delivered_email'); ?>
953
+ <section class="ac-container">
954
+ <label class="headig_label <?php if($wcast_enable_delivered_email == 1){ echo 'enable'; } else{ echo 'disable'; }?>">
955
+
956
+ <span class="email_status_span"><?php
957
+ if($wcast_enable_delivered_email == 1){
958
+ echo '<i id="enable_t" class="material-icons enable">lens</i><div class="mdl-tooltip mdl-tooltip--large mdl-tooltip--top" data-mdl-for="enable_t">'.__('Enable', 'woo-advanced-shipment-tracking').'</div>';
959
+ } else{
960
+ echo '<i id="disable_t" class="material-icons disable">panorama_fish_eye</i><div class="mdl-tooltip mdl-tooltip--large mdl-tooltip--top" data-mdl-for="disable_t">'.__('Disable', 'woo-advanced-shipment-tracking').'</div>';
961
+ }
962
+ ?>
963
+ </span>
964
+ <?php _e('Delivered order status email', 'woo-advanced-shipment-tracking'); ?>
965
+ <a class="edit_customizer_a" href="<?php echo wcast_initialise_customizer_email::get_customizer_url('customer_delivered_email') ?>"><?php _e('Edit in customizer', 'woo-advanced-shipment-tracking'); ?></a>
966
+ </label>
967
+ </section>
968
+ <?php //echo $this->status_email_list(); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
969
  </section>
970
  </div>
971
  <div class="zorem_admin_sidebar">
972
+ <div class="ts_launch">
973
+ <img src="https://trackship.info/wp-content/uploads/2019/05/logo-1024x261.png" alt="" style="max-width: 60%;">
974
+ <h4>Automate your Shipment Tracking & Delivery Operations</h4>
975
+ <p>TrackShip proactively sends shipment status updates to your WooCommerce store and streamlines your order management process and provide improved post-purchase experience to your customers.</p>
976
+ <p>We are currently in beta stage, signup to get your invitation.</p>
977
+ <a href="https://trackship.info" target="_blank" class="button button-primary btn_green" target="_blank"><span>get your invite</span><i class="icon-angle-right"></i></a>
978
+ </div>
979
+
980
+ <!--<div class="zorem-sidebar-title"></div>-->
981
  <div class="zorem-sidebar__section">
982
+ <h3>More plugins by zorem</h3>
983
  <?php
984
  $plugin_array = array(
985
+ array(
 
 
 
 
 
986
  'name' => 'Shop Manager Admin Bar for WooCommerce',
987
  'url' => 'https://wordpress.org/plugins/woo-shop-manager-admin-bar/',
988
  'img' => 'woocommerce-shop-manager-admin-bar-thumbnail.jpg',
989
  ),
990
+ array(
991
+ 'name' => 'Ajax Login/Register for WooCommerce',
992
+ 'url' => 'https://wordpress.org/plugins/woo-ajax-loginregister/',
993
+ 'img' => 'WooCommerce-Ajax-Login-Register-thumbnail.jpg',
994
+ ),
995
+ /*0 => array(
996
+ 'name' => 'Country Based Restrictions for WooCommerce',
997
+ 'url' => 'https://wordpress.org/plugins/woo-product-country-base-restrictions/',
998
+ 'img' => 'WooCommerce-Country-Based-Restrictions-thumbnail.jpg',
999
+ ),
1000
  2 => array(
1001
  'name' => 'Sales Report Email for WooCommerce',
1002
  'url' => 'https://wordpress.org/plugins/woo-advanced-sales-report-email/',
1003
  'img' => 'woocommerce-advanced-sales-report-email-thumbnail.jpg',
 
 
 
 
 
1004
  ),
1005
  4 => array(
1006
  'name' => 'Sales Report By Country for WooCommerce',
1016
  'name' => 'Bit Payment Gateway for WooCommerce',
1017
  'url' => 'https://wordpress.org/plugins/woo-bit-payment-gateway/',
1018
  'img' => 'WooCommerce-Bit-payment-thumbnail.jpg',
1019
+ ),*/
1020
  );
1021
  ?>
1022
  <ul>
1024
  <li><img class="plugin_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/images/<?php echo $plugin['img']?>"><a class="plugin_url" href="<?php echo $plugin['url']?>" target="_blank"><?php echo $plugin['name']?></a></li>
1025
  <?php }?>
1026
  </ul>
1027
+ <a href="https://www.zorem.com/plugins/" target="_blank">view all zorem plugins</a>
1028
  </div>
1029
  </div>
1030
  </div>
1226
  'type' => 'checkbox',
1227
  'title' => __( 'Rename the “Completed” Order status to “Shipped”', 'woo-advanced-shipment-tracking' ),
1228
  'desc' => '',
1229
+ 'class' => '',
1230
  ),
1231
  'wc_ast_status_delivered' => array(
1232
  'type' => 'checkbox',
1233
  'title' => __( 'Enable a New Custom order status - “Delivered”', 'woo-advanced-shipment-tracking' ),
1234
  'tooltip' => __( 'if you enable the delivered item, you will have the option to send delivered email notifications.', 'woo-advanced-shipment-tracking' ),
1235
+ 'class' => '',
1236
  ),
1237
  'wc_ast_status_label_color' => array(
1238
  'type' => 'color',
1240
  'desc' => '',
1241
  'class' => 'status_label_color_th',
1242
  ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1243
  );
1244
  return $form_data;
1245
 
1246
+ }
1247
 
1248
  /*
1249
  * settings form save
1253
  if ( ! empty( $_POST ) && check_admin_referer( 'wc_ast_settings_form', 'wc_ast_settings_form' ) ) {
1254
 
1255
  //echo '<pre>';print_r($_POST);echo '</pre>';
1256
+ $data = $this->get_settings_data();
 
 
1257
 
1258
  foreach( $data as $key => $val ){
1259
  update_option( $key, sanitize_text_field( $_POST[ $key ] ) );
1260
  }
1261
+
 
 
1262
  echo json_encode( array('success' => 'true') );die();
1263
 
1264
  }
1394
  }
1395
  ?>
1396
  <tr class="provider_tr <?php if($d_s_p->display_in_order != 1) { echo 'status_deactivate'; } ?> <?php if($d_s_p->shipping_default == 0) { echo 'custom_provider_tr'; } ?>">
1397
+ <td class="column-columnname thumb-column on_edit_hide">
1398
  <?php if( $d_s_p->shipping_default == 1 ){ ?>
1399
+ <img class="provider_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/<?php echo sanitize_title($d_s_p->provider_name);?>.png">
1400
  <?php } else{
1401
  $custom_thumb_id = $d_s_p->custom_thumb_id;
1402
  $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
1403
+ //echo '<pre>';print_r($custom_thumb_id);echo '</pre>';exit;
1404
  if($custom_thumb_id != 0){ ?>
1405
+ <img class="provider_thumbnail" src="<?php echo $image_attributes[0]; ?>">
1406
  <?php } else{
1407
  ?>
1408
+ <img class="provider_thumbnail" src="<?php echo wc_advanced_shipment_tracking()->plugin_dir_url()?>assets/shipment-provider-img/icon-default.png">
1409
  <?php } ?>
 
 
 
1410
  <?php } ?>
1411
+ <span class="provider_name">
1412
+ <?php echo $d_s_p->provider_name; ?>
1413
+ </span>
 
 
 
 
1414
  </td>
1415
+ <td class="column-columnname country_select_box on_edit_hide">
1416
+ <span class="on_edit_hide">
1417
+ <?php
1418
+ $search = array('(US)', '(UK)');
1419
+ $replace = array('', '');
1420
+ echo str_replace($search, $replace, $WC_Countries->countries[$d_s_p->shipping_country]);
1421
+ ?>
1422
+ </span>
 
 
 
 
 
 
 
 
1423
  </td>
1424
+ <td class="column-columnname url-column on_edit_hide">
1425
+ <a href="<?php echo $d_s_p->provider_url; ?>" title="<?php echo $d_s_p->provider_url; ?>" target="_blank" class="on_edit_hide"><?php _e( 'Tracking Page','woo-advanced-shipment-tracking' ); ?>
1426
+ </a>
 
 
 
1427
  </td>
1428
+ <td class="column-columnname status-column on_edit_hide">
1429
  <span class="mdl-list__item-secondary-action">
1430
  <label class="mdl-switch mdl-js-switch mdl-js-ripple-effect" for="list-switch-<?php echo $d_s_p->id; ?>">
1431
  <input type="checkbox" name="select_custom_provider[]" id="list-switch-<?php echo $d_s_p->id; ?>" class="mdl-switch__input status_slide" value="<?php echo $d_s_p->id; ?>" <?php if($d_s_p->display_in_order == 1) { echo 'checked'; } ?> />
1432
  </label>
1433
  </span>
1434
  </td>
1435
+ <td class="column-columnname on_edit_hide">
1436
  <?php if( $d_s_p->shipping_default == 0 ){ ?>
1437
+ <span class="dashicons dashicons-edit edit_provider" style="display:none"></span>
1438
+ <span class="dashicons dashicons-trash remove" data-pid="<?php echo $d_s_p->id; ?>" style="display:none"></span>
 
1439
  <?php } ?>
1440
+ <span class="dashicons dashicons-editor-justify sort-item ui-sortable-handle"></span>
1441
+ <?php
1442
+ $custom_thumb_id = $d_s_p->custom_thumb_id;
1443
+ $image_attributes = wp_get_attachment_image_src( $custom_thumb_id );
1444
+ ?>
1445
+ <input type="hidden" name="data[<?php echo $d_s_p->id?>][thumb_url]" class="image_path" value="<?php echo $image_attributes[0]; ?>">
1446
+ </td>
1447
+ <td class="on_edit_show" colspan="5">
1448
+ <input type="text" class="text custom_provider_name" name="data[<?php echo $d_s_p->id?>][provider_name]" value="<?php echo $d_s_p->provider_name;?>" placeholder="<?php _e( 'Shipping Provider', 'woo-advanced-shipment-tracking' ); ?>"><br>
1449
+
1450
+ <select class="select custom_provider_country" name="data[<?php echo $d_s_p->id?>][shipping_country]" >
1451
+ <option value="" ><?php _e( 'None', 'woo-advanced-shipment-tracking' ); ?></option>
1452
+ <?php foreach($countries as $key=>$val){ ?>
1453
+ <option value="<?php echo $key; ?>" <?php if ( $key == $d_s_p->shipping_country ) echo 'selected'?>><?php _e( $val, 'woo-advanced-shipment-tracking'); ?></option>
1454
+ <?php } ?>
1455
+ </select><br>
1456
+
1457
+ <input type='hidden' name='data[<?php echo $d_s_p->id?>][thumb_id]' class='image_id' placeholder="Image" value='<?php echo $custom_thumb_id; ?>' id='image_id' style="">
1458
+ <input type='text' name='data[<?php echo $d_s_p->id?>][thumb_url]' class='image_path' placeholder="Image" value='<?php echo $image_attributes[0]; ?>' id='image_path' style="">
1459
+ <input id="upload_image_button" type="button" class="button" value="<?php _e( 'Upload' , 'woo-advanced-shipment-tracking'); ?>" /><br>
1460
+
1461
+ <input type="text" class="text custom_provider_url" name="data[<?php echo $d_s_p->id?>][provider_url]" value="<?php echo $d_s_p->provider_url;?>" placeholder="<?php _e( 'Shipping URL', 'woo-advanced-shipment-tracking' ); ?>">
1462
+ <p><?php _e('You can add tracking number parameter like this - http://shippingprovider.com?tracking_number=%number% , %number% - parameter', 'woo-advanced-shipment-tracking'); ?></p>
1463
+
1464
  <input type="hidden" name="provider_id" class="provider_id" value="<?php echo $d_s_p->id?>">
1465
  <input type="hidden" name="sorting[<?php echo $d_s_p->id?>][sort_order]" class="sort_order" value="<?php echo $d_s_p->sort_order?>">
1466
+ <input type="hidden" name="data[<?php echo $d_s_p->id?>][sort_order]" class="" value="<?php echo $d_s_p->sort_order?>"><br>
1467
+ <button class="button button-primary update_provider btn_green"><?php _e( 'Update', 'woo-advanced-shipment-tracking' ); ?></button>
1468
+ <a href="JavaScript:Void(0);" class="cancel_edit"><?php _e( 'Cancel' , 'woo-advanced-shipment-tracking'); ?></a>
1469
+ </td>
1470
  </tr>
1471
  <?php } ?>
1472
  </tbody>
1506
  }
1507
  </style>
1508
  <?php
1509
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1510
 
1511
  function upload_tracking_csv_fun(){
1512
 
1586
  $tracking_provider = $_POST['tracking_provider'];
1587
  $tracking_number = $_POST['tracking_number'];
1588
  $date_shipped = str_replace("/","-",$_POST['date_shipped']);
1589
+ if(empty($date_shipped)){
1590
+ $date_shipped = date("d-m-Y");
1591
+ }
1592
  $replace_tracking_info = $_POST['replace_tracking_info'];
1593
+ // echo '<pre>';print_r($_POST['trackings']);echo '</pre>';
1594
  global $wpdb;
1595
  $woo_shippment_table_name = $this->table;
1596
  $shippment_provider = $wpdb->get_var( "SELECT COUNT(*) FROM $woo_shippment_table_name WHERE provider_name = '".$tracking_provider."'" );
1597
 
1598
  if($shippment_provider == 0){
1599
+ echo '<li class="error">Failed - Invalid Tracking Provider for Order Id - '.$_POST['order_id'].'</li>';exit;
1600
  }
1601
  if(empty($tracking_number)){
1602
+ echo '<li class="error">Failed - Empty Tracking Number for Order Id - '.$_POST['order_id'].'</li>';exit;
1603
  }
1604
  if(empty($date_shipped)){
1605
+ echo '<li class="error">Failed - Empty Date Shipped for Order Id - '.$_POST['order_id'].'</li>';exit;
1606
  }
1607
  if(!$this->isDate($date_shipped)){
1608
+ echo '<li class="error">Failed - Invalid Date Shipped for Order Id - '.$_POST['order_id'].'</li>';exit;
1609
  }
1610
 
1611
  if($replace_tracking_info == 1){
1616
 
1617
  if ( count( $tracking_items ) > 0 ) {
1618
  foreach ( $tracking_items as $key => $item ) {
1619
+ $tracking_number = $item['tracking_number'];
1620
+
1621
+ if(in_array($tracking_number, array_column($_POST['trackings'], 'tracking_number'))) {
1622
+
1623
+ } else{
1624
+ unset( $tracking_items[ $key ] );
1625
+ }
1626
  }
1627
  $wast->save_tracking_items( $order_id, $tracking_items );
1628
  }
1702
  }
1703
  return $status;
1704
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1705
 
1706
  // define the item in the meta box by adding an item to the $actions array
1707
  function add_order_meta_box_actions( $actions ) {
1712
  if($email_type == 'wc_email'){
1713
  $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
1714
  } elseif($delivered_email_list){
1715
+ $actions['resend_delivered_order_notification'] = __( 'Resend delivered order notification', 'woo-advanced-shipment-tracking' );
 
1716
  }
1717
  return $actions;
1718
  }
1719
  function process_order_meta_box_actions($order){
1720
+ $order_id = $order->get_id();
1721
+ require_once( 'email-manager.php' );
1722
+ $enable_delivered_email = get_theme_mod('wcast_enable_delivered_email');
1723
+
1724
+ if($enable_delivered_email == 1){
1725
+ wc_advanced_shipment_tracking_email_class()->delivered_order_status_email_trigger($order_id, $order);
1726
+ }
1727
  }
1728
  function update_email_type_fun(){
1729
  update_option("wc_ast_select_email_type", $_POST['email_type'] );
1730
  echo 1;exit;
1731
  }
1732
+ public function update_tracking_preview_order_fun(){
1733
+ set_theme_mod('wcast_preview_order_id', $_POST['wcast_email_preview_order_id']);
1734
+ set_theme_mod('wcast_email_preview_order_id', $_POST['wcast_email_preview_order_id']);
1735
+ exit;
1736
+ }
1737
+ public function update_email_preview_order_fun(){
1738
+ set_theme_mod('wcast_preview_order_id', $_POST['wcast_preview_order_id']);
1739
+ set_theme_mod('wcast_email_preview_order_id', $_POST['wcast_preview_order_id']);
1740
+ exit;
1741
+ }
1742
  }
includes/customizer/class-wc-email-customizer.php ADDED
@@ -0,0 +1,629 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customizer Setup and Custom Controls
4
+ *
5
+ */
6
+
7
+ /**
8
+ * Adds the individual sections, settings, and controls to the theme customizer
9
+ */
10
+ class wcast_initialise_customizer_email {
11
+ // Get our default values
12
+ private $defaults;
13
+ private static $order_ids = null;
14
+ public function __construct() {
15
+ // Get our Customizer defaults
16
+ $this->defaults = $this->wcast_generate_defaults();
17
+
18
+
19
+
20
+ // Register our sample default controls
21
+ add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
22
+
23
+ // Only proceed if this is own request.
24
+ if ( ! wcast_initialise_customizer_email::is_own_customizer_request() && ! wcast_initialise_customizer_email::is_own_preview_request() ) {
25
+ return;
26
+ }
27
+ add_action( 'customize_register', array( $this, 'wcast_add_customizer_panels' ) );
28
+ // Register our sections
29
+ add_action( 'customize_register', array( $this, 'wcast_add_customizer_sections' ) );
30
+
31
+ // Remove unrelated components.
32
+ add_filter( 'customize_loaded_components', array( $this, 'remove_unrelated_components' ), 99, 2 );
33
+
34
+ // Remove unrelated sections.
35
+ add_filter( 'customize_section_active', array( $this, 'remove_unrelated_sections' ), 10, 2 );
36
+
37
+ // Unhook divi front end.
38
+ add_action( 'woomail_footer', array( $this, 'unhook_divi' ), 10 );
39
+
40
+ // Unhook Flatsome js
41
+ add_action( 'customize_preview_init', array( $this, 'unhook_flatsome' ), 50 );
42
+
43
+ add_filter( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customizer_scripts' ) );
44
+
45
+ add_action( 'parse_request', array( $this, 'set_up_preview' ) );
46
+
47
+ add_action( 'customize_preview_init', array( $this, 'enqueue_preview_scripts' ) );
48
+
49
+ }
50
+
51
+ public function enqueue_preview_scripts() {
52
+ wp_enqueue_script('wcast-email-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . '/assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
53
+ }
54
+ /**
55
+ * Enqueue Customizer scripts
56
+ *
57
+ * @access public
58
+ * @return void
59
+ */
60
+ public function enqueue_customizer_scripts() {
61
+ if(isset( $_REQUEST['wcast-email-customize'] ) && '1' === $_REQUEST['wcast-email-customize']){
62
+ wp_enqueue_style('wcast-customizer-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer-styles.css', array(), wc_advanced_shipment_tracking()->version );
63
+ wp_enqueue_script('wcast-customizer-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/tracking-customizer-scripts.js', array('jquery', 'customize-controls'), wc_advanced_shipment_tracking()->version, true);
64
+
65
+ // Send variables to Javascript
66
+ wp_localize_script('wcast-customizer-scripts', 'wcast_customizer', array(
67
+ 'ajax_url' => admin_url('admin-ajax.php'),
68
+ 'email_preview_url' => $this->get_email_preview_url(),
69
+ 'tracking_preview_url' => $this->get_tracking_preview_url(),
70
+ 'labels' => array(
71
+ 'customtitle' => __('Tracking info display', 'woo-advanced-shipment-tracking'),
72
+ ),
73
+ ));
74
+ }
75
+ }
76
+ /**
77
+ * Checks to see if we are opening our custom customizer preview
78
+ *
79
+ * @access public
80
+ * @return bool
81
+ */
82
+ public static function is_own_preview_request() {
83
+ return isset( $_REQUEST['wcast-email-customizer-preview'] ) && '1' === $_REQUEST['wcast-email-customizer-preview'];
84
+ }
85
+ /**
86
+ * Checks to see if we are opening our custom customizer controls
87
+ *
88
+ * @access public
89
+ * @return bool
90
+ */
91
+ public static function is_own_customizer_request() {
92
+ return isset( $_REQUEST['wcast-email-customize'] ) && $_REQUEST['wcast-email-customize'] === '1';
93
+ }
94
+ /*
95
+ * Unhook flatsome front end.
96
+ */
97
+ public function unhook_flatsome() {
98
+ // Unhook flatsome issue.
99
+ wp_dequeue_style( 'flatsome-customizer-preview' );
100
+ wp_dequeue_script( 'flatsome-customizer-frontend-js' );
101
+ }
102
+ /*
103
+ * Unhook Divi front end.
104
+ */
105
+ public function unhook_divi() {
106
+ // Divi Theme issue.
107
+ remove_action( 'wp_footer', 'et_builder_get_modules_js_data' );
108
+ remove_action( 'et_customizer_footer_preview', 'et_load_social_icons' );
109
+ }
110
+ /**
111
+ * Get Customizer URL
112
+ *
113
+ */
114
+ public static function get_customizer_url($email) {
115
+ $customizer_url = add_query_arg( array(
116
+ 'wcast-email-customize' => '1',
117
+ 'email' => $email,
118
+ 'url' => urlencode( add_query_arg( array( 'wcast-email-customizer-preview' => '1' ), home_url( '/' ) ) ),
119
+ 'return' => urlencode( wcast_initialise_customizer_email::get_email_settings_page_url() ),
120
+ ), admin_url( 'customize.php' ) );
121
+
122
+ return $customizer_url;
123
+ }
124
+ /**
125
+ * Get Customizer URL
126
+ *
127
+ */
128
+ public static function get_email_preview_url() {
129
+ $email_preview_url = add_query_arg( array(
130
+ 'wcast-email-customizer-preview' => '1',
131
+ ), home_url( '' ) );
132
+
133
+ return $email_preview_url;
134
+ }
135
+ /**
136
+ * Get Customizer URL
137
+ *
138
+ */
139
+ public static function get_tracking_preview_url() {
140
+ $tracking_preview_url = add_query_arg( array(
141
+ 'wcast-tracking-preview' => '1',
142
+ ), home_url( '' ) );
143
+
144
+ return $tracking_preview_url;
145
+ }
146
+ /**
147
+ * Get Customizer URL
148
+ *
149
+ */
150
+ public static function get_tracking_customizer_url($email) {
151
+ $customizer_url = add_query_arg( array(
152
+ 'wcast-tracking-customize' => '1',
153
+ 'url' => urlencode( add_query_arg( array( 'wcast-tracking-preview' => '1' ), home_url( '/' ) ) ),
154
+ 'return' => urlencode( wcast_initialise_customizer_settings::get_email_settings_page_url() ),
155
+ ), admin_url( 'customize.php' ) );
156
+
157
+ return $customizer_url;
158
+ }
159
+ /**
160
+ * Get WooCommerce email settings page URL
161
+ *
162
+ * @access public
163
+ * @return string
164
+ */
165
+ public static function get_email_settings_page_url() {
166
+ return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
167
+ }
168
+ public function wcast_generate_defaults() {
169
+ $customizer_defaults = array(
170
+ 'wcast_delivered_email_subject' => __( 'Your {site_title} order is now delivered', 'woo-advanced-shipment-tracking' ),
171
+ 'wcast_delivered_email_heading' => __( 'Thanks for shopping with us', 'woo-advanced-shipment-tracking' ),
172
+ 'wcast_delivered_email_content' => __( 'Hi there. Your recent order on {site_title} has been delivered.', 'woo-advanced-shipment-tracking' ),
173
+ 'wcast_enable_delivered_email' => '',
174
+ 'wcast_delivered_email_to' => '{customer_email}',
175
+ 'wcast_show_tracking_details' => '',
176
+ 'wcast_show_order_details' => '',
177
+ 'wcast_show_address' => '',
178
+ 'wcast_email_code_block' => '',
179
+ );
180
+
181
+ return apply_filters( 'skyrocket_customizer_defaults', $customizer_defaults );
182
+ }
183
+
184
+ /**
185
+ * Register the Customizer panels
186
+ */
187
+ public function wcast_add_customizer_panels( $wp_customize ) {
188
+ /**
189
+ * Add our Header & Navigation Panel
190
+ */
191
+ $wp_customize->add_panel( 'wcast_naviation_panel',
192
+ array(
193
+ 'title' => __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ),
194
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' )
195
+ )
196
+ );
197
+ }
198
+ /**
199
+ * Register the Customizer sections
200
+ */
201
+ public function wcast_add_customizer_sections( $wp_customize ) {
202
+ $wp_customize->add_section( 'default_controls_section',
203
+ array(
204
+ 'title' => __( 'Tracking info display', 'woo-advanced-shipment-tracking' ),
205
+ 'description' => esc_html__( 'This section lets you customize the Tracking Info display design.', 'woo-advanced-shipment-tracking' ),
206
+ 'panel' => 'wcast_naviation_panel'
207
+ )
208
+ );
209
+ $wp_customize->add_section( 'email_controls_section',
210
+ array(
211
+ 'title' => __( 'Delivered order status email', 'woo-advanced-shipment-tracking' ),
212
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
213
+ 'panel' => 'wcast_naviation_panel'
214
+ )
215
+ );
216
+ }
217
+ /**
218
+ * Get Order Ids
219
+ *
220
+ * @access public
221
+ * @return array
222
+ */
223
+ public static function get_order_ids() {
224
+ if ( is_null( wcast_initialise_customizer_email::$order_ids ) ) {
225
+ $order_array = array();
226
+ $order_array['mockup'] = __( 'Select order to preview', 'woo-advanced-shipment-tracking' );
227
+ $orders = new WP_Query(
228
+ array(
229
+ 'post_type' => 'shop_order',
230
+ 'post_status' => array_keys( wc_get_order_statuses() ),
231
+ 'posts_per_page' => 20,
232
+ )
233
+ );
234
+ if ( $orders->posts ) {
235
+ foreach ( $orders->posts as $order ) {
236
+ // Get order object.
237
+ $order_object = new WC_Order( $order->ID );
238
+ $order_array[ $order_object->get_id() ] = $order_object->get_id() . ' - ' . $order_object->get_billing_first_name() . ' ' . $order_object->get_billing_last_name();
239
+ }
240
+ }
241
+ wcast_initialise_customizer_email::$order_ids = $order_array;
242
+ }
243
+ return wcast_initialise_customizer_email::$order_ids;
244
+ }
245
+ /**
246
+ * Register our sample default controls
247
+ */
248
+ public function wcast_register_sample_default_controls( $wp_customize ) {
249
+ /**
250
+ * Load all our Customizer Custom Controls
251
+ */
252
+ require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
253
+
254
+ $wp_customize->add_setting( 'delivered_order_email_heading',
255
+ array(
256
+ 'default' => '',
257
+ 'transport' => 'postMessage',
258
+ 'sanitize_callback' => ''
259
+ )
260
+ );
261
+ $wp_customize->add_control( new WP_Customize_Heading_Control( $wp_customize, 'delivered_order_email_heading',
262
+ array(
263
+ 'label' => __( 'Delivered order status email', 'woo-advanced-shipment-tracking' ),
264
+ 'description' => __( 'This section lets you customize the Email Content.', 'woo-advanced-shipment-tracking' ),
265
+ 'section' => 'email_controls_section'
266
+ )
267
+ ) );
268
+ // Display Shipment Provider image/thumbnail
269
+ $wp_customize->add_setting( 'wcast_enable_delivered_email',
270
+ array(
271
+ 'default' => $this->defaults['wcast_enable_delivered_email'],
272
+ 'transport' => 'postMessage',
273
+ 'sanitize_callback' => ''
274
+ )
275
+ );
276
+ $wp_customize->add_control( 'wcast_enable_delivered_email',
277
+ array(
278
+ 'label' => __( 'Enable Delivered order status email', 'woo-advanced-shipment-tracking' ),
279
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
280
+ 'section' => 'email_controls_section',
281
+ 'type' => 'checkbox'
282
+ )
283
+ );
284
+ // Preview Order
285
+ $wp_customize->add_setting( 'wcast_email_preview_order_id',
286
+ array(
287
+ 'default' => 'mockup',
288
+ 'transport' => 'refresh',
289
+ 'sanitize_callback' => ''
290
+ )
291
+ );
292
+ $wp_customize->add_control( 'wcast_email_preview_order_id',
293
+ array(
294
+ 'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
295
+ 'section' => 'email_controls_section',
296
+ 'type' => 'select',
297
+ 'choices' => wcast_initialise_customizer_email::get_order_ids(),
298
+ )
299
+ );
300
+
301
+ // Header Text
302
+ $wp_customize->add_setting( 'wcast_delivered_email_to',
303
+ array(
304
+ 'default' => $this->defaults['wcast_delivered_email_to'],
305
+ 'transport' => 'postMessage',
306
+ 'sanitize_callback' => ''
307
+ )
308
+ );
309
+ $wp_customize->add_control( 'wcast_delivered_email_to',
310
+ array(
311
+ 'label' => __( 'To', 'woo-advanced-shipment-tracking' ),
312
+ 'description' => esc_html__( 'Enter emails here or use variables such as {customer_email}. Multiple emails can be separated by commas.', 'woo-advanced-shipment-tracking' ),
313
+ 'section' => 'email_controls_section',
314
+ 'type' => 'text',
315
+ 'input_attrs' => array(
316
+ 'class' => '',
317
+ 'style' => '',
318
+ 'placeholder' => __( 'E.g. {customer.email}, admin@example.org', 'woo-advanced-shipment-tracking' ),
319
+ ),
320
+ )
321
+ );
322
+
323
+ // Header Text
324
+ $wp_customize->add_setting( 'wcast_delivered_email_subject',
325
+ array(
326
+ 'default' => $this->defaults['wcast_delivered_email_subject'],
327
+ 'transport' => 'postMessage',
328
+ 'sanitize_callback' => ''
329
+ )
330
+ );
331
+ $wp_customize->add_control( 'wcast_delivered_email_subject',
332
+ array(
333
+ 'label' => __( 'Email subject', 'woo-advanced-shipment-tracking' ),
334
+ 'description' => esc_html__( 'Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
335
+ 'section' => 'email_controls_section',
336
+ 'type' => 'text',
337
+ 'input_attrs' => array(
338
+ 'class' => '',
339
+ 'style' => '',
340
+ 'placeholder' => __( 'Please enter email subject here', 'woo-advanced-shipment-tracking' ),
341
+ ),
342
+ )
343
+ );
344
+
345
+ // Header Text
346
+ $wp_customize->add_setting( 'wcast_delivered_email_heading',
347
+ array(
348
+ 'default' => $this->defaults['wcast_delivered_email_heading'],
349
+ 'transport' => 'postMessage',
350
+ 'sanitize_callback' => ''
351
+ )
352
+ );
353
+ $wp_customize->add_control( 'wcast_delivered_email_heading',
354
+ array(
355
+ 'label' => __( 'Email heading', 'woo-advanced-shipment-tracking' ),
356
+ 'description' => esc_html__( 'Available placeholders: {site_title}, {order_number}', 'woo-advanced-shipment-tracking' ),
357
+ 'section' => 'email_controls_section',
358
+ 'type' => 'text',
359
+ 'input_attrs' => array(
360
+ 'class' => '',
361
+ 'style' => '',
362
+ 'placeholder' => __( 'Please enter email heading here', 'woo-advanced-shipment-tracking' ),
363
+ ),
364
+ )
365
+ );
366
+ // Display Shipment Provider image/thumbnail
367
+ $wp_customize->add_setting( 'wcast_show_tracking_details',
368
+ array(
369
+ 'default' => $this->defaults['wcast_show_tracking_details'],
370
+ 'transport' => 'refresh',
371
+ 'sanitize_callback' => ''
372
+ )
373
+ );
374
+ $wp_customize->add_control( 'wcast_show_tracking_details',
375
+ array(
376
+ 'label' => __( 'Show tracking details', 'woo-advanced-shipment-tracking' ),
377
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
378
+ 'section' => 'email_controls_section',
379
+ 'type' => 'checkbox'
380
+ )
381
+ );
382
+ // Display Shipment Provider image/thumbnail
383
+ $wp_customize->add_setting( 'wcast_show_order_details',
384
+ array(
385
+ 'default' => $this->defaults['wcast_show_order_details'],
386
+ 'transport' => 'refresh',
387
+ 'sanitize_callback' => ''
388
+ )
389
+ );
390
+ $wp_customize->add_control( 'wcast_show_order_details',
391
+ array(
392
+ 'label' => __( 'Show order details', 'woo-advanced-shipment-tracking' ),
393
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
394
+ 'section' => 'email_controls_section',
395
+ 'type' => 'checkbox'
396
+ )
397
+ );
398
+ // Display Shipment Provider image/thumbnail
399
+ $wp_customize->add_setting( 'wcast_show_address',
400
+ array(
401
+ 'default' => $this->defaults['wcast_show_address'],
402
+ 'transport' => 'refresh',
403
+ 'sanitize_callback' => ''
404
+ )
405
+ );
406
+ $wp_customize->add_control( 'wcast_show_address',
407
+ array(
408
+ 'label' => __( 'Show address', 'woo-advanced-shipment-tracking' ),
409
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
410
+ 'section' => 'email_controls_section',
411
+ 'type' => 'checkbox'
412
+ )
413
+ );
414
+ // Test of TinyMCE control
415
+ $wp_customize->add_setting( 'wcast_delivered_email_content',
416
+ array(
417
+ 'default' => $this->defaults['wcast_delivered_email_content'],
418
+ 'transport' => 'refresh',
419
+ 'sanitize_callback' => 'wp_kses_post'
420
+ )
421
+ );
422
+ $wp_customize->add_control( new Skyrocket_TinyMCE_Custom_control( $wp_customize, 'wcast_delivered_email_content',
423
+ array(
424
+ 'label' => __( 'Email content', 'woo-advanced-shipment-tracking' ),
425
+ 'description' => __( '', 'woo-advanced-shipment-tracking' ),
426
+ 'section' => 'email_controls_section',
427
+ 'input_attrs' => array(
428
+ 'toolbar1' => 'bold italic bullist numlist alignleft aligncenter alignright link',
429
+ 'mediaButtons' => true,
430
+ )
431
+ )
432
+ ) );
433
+
434
+
435
+ $wp_customize->add_setting( 'wcast_email_code_block',
436
+ array(
437
+ 'default' => $this->defaults['wcast_email_code_block'],
438
+ 'transport' => 'postMessage',
439
+ 'sanitize_callback' => ''
440
+ )
441
+ );
442
+ $wp_customize->add_control( new WP_Customize_codeinfoblock_Control( $wp_customize, 'wcast_email_code_block',
443
+ array(
444
+ 'label' => __( 'Available placeholders', 'woo-advanced-shipment-tracking' ),
445
+ 'description' => __( '<code>{site_title}, {customer_email}, {customer_first_name}, {customer_last_name}, {customer_username}, {order_number}</code>', 'woo-advanced-shipment-tracking' ),
446
+ 'section' => 'email_controls_section',
447
+ )
448
+ ) );
449
+ }
450
+ /**
451
+ * Remove unrelated components
452
+ *
453
+ * @access public
454
+ * @param array $components
455
+ * @param object $wp_customize
456
+ * @return array
457
+ */
458
+ public function remove_unrelated_components($components, $wp_customize) {
459
+ // Iterate over components
460
+ foreach ($components as $component_key => $component) {
461
+
462
+ // Check if current component is own component
463
+ if ( ! wcast_initialise_customizer_email::is_own_component( $component ) ) {
464
+ unset($components[$component_key]);
465
+ }
466
+ }
467
+
468
+ // Return remaining components
469
+ return $components;
470
+ }
471
+
472
+ /**
473
+ * Remove unrelated sections
474
+ *
475
+ * @access public
476
+ * @param bool $active
477
+ * @param object $section
478
+ * @return bool
479
+ */
480
+ public function remove_unrelated_sections( $active, $section ) {
481
+ // Check if current section is own section
482
+ if ( ! wcast_initialise_customizer_email::is_own_section( $section->id ) ) {
483
+ return false;
484
+ }
485
+
486
+ // We can override $active completely since this runs only on own Customizer requests
487
+ return true;
488
+ }
489
+
490
+ /**
491
+ * Remove unrelated controls
492
+ *
493
+ * @access public
494
+ * @param bool $active
495
+ * @param object $control
496
+ * @return bool
497
+ */
498
+ public function remove_unrelated_controls( $active, $control ) {
499
+
500
+ // Check if current control belongs to own section
501
+ if ( ! wcast_add_customizer_sections::is_own_section( $control->section ) ) {
502
+ return false;
503
+ }
504
+
505
+ // We can override $active completely since this runs only on own Customizer requests
506
+ return $active;
507
+ }
508
+
509
+ /**
510
+ * Check if current component is own component
511
+ *
512
+ * @access public
513
+ * @param string $component
514
+ * @return bool
515
+ */
516
+ public static function is_own_component( $component ) {
517
+ return false;
518
+ }
519
+
520
+ /**
521
+ * Check if current section is own section
522
+ *
523
+ * @access public
524
+ * @param string $key
525
+ * @return bool
526
+ */
527
+ public static function is_own_section( $key ) {
528
+
529
+ if ($key === 'email_controls_section' || $key === 'default_controls_section') {
530
+ return true;
531
+ }
532
+
533
+ // Section not found
534
+ return false;
535
+ }
536
+
537
+ /**
538
+ * Set up preview
539
+ *
540
+ * @access public
541
+ * @return void
542
+ */
543
+ public function set_up_preview() {
544
+
545
+ // Make sure this is own preview request.
546
+ if ( ! wcast_initialise_customizer_email::is_own_preview_request() ) {
547
+ return;
548
+ }
549
+ include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/delivered_preview.php';
550
+ exit;
551
+ }
552
+
553
+ public function preview_delivered_email(){
554
+ // Load WooCommerce emails.
555
+ $wc_emails = WC_Emails::instance();
556
+ $emails = $wc_emails->get_emails();
557
+ $preview_id = get_theme_mod('wcast_email_preview_order_id');
558
+
559
+
560
+ $email_heading = get_theme_mod('wcast_delivered_email_heading');
561
+ $email_content = get_theme_mod('wcast_delivered_email_content');
562
+ $wcast_show_tracking_details = get_theme_mod('wcast_show_tracking_details');
563
+ $wcast_show_order_details = get_theme_mod('wcast_show_order_details');
564
+ $wcast_show_address = get_theme_mod('wcast_show_address');
565
+ $sent_to_admin = false;
566
+ $plain_text = false;
567
+ $email = '';
568
+
569
+ if($preview_id == '' || $preview_id == 'mockup') {
570
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select preview order.', 'woo-advanced-shipment-tracking' ) . '</div>';
571
+ echo $content;
572
+ return;
573
+ }
574
+ $order = wc_get_order( $preview_id );
575
+ $mailer = WC()->mailer();
576
+
577
+ // get the preview email subject
578
+ $email_heading = __( $email_heading, 'woo-advanced-shipment-tracking' );
579
+ //ob_start();
580
+ //include 'views/html-tracking-info-design-preview.php';
581
+ $message = wc_advanced_shipment_tracking_email_class()->email_content($email_content,$preview_id,$order);
582
+ if($wcast_show_tracking_details == 1){
583
+ ob_start();
584
+ wc_get_template( 'emails/tracking-info.php', array(
585
+ 'tracking_items' => wc_advanced_shipment_tracking()->get_tracking_items( $preview_id, true )
586
+ ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
587
+ $message .= ob_get_clean();
588
+ }
589
+ if($wcast_show_order_details == 1){
590
+
591
+ ob_start();
592
+ wc_get_template(
593
+ 'emails/wcast-email-order-details.php', array(
594
+ 'order' => $order,
595
+ 'sent_to_admin' => $sent_to_admin,
596
+ 'plain_text' => $plain_text,
597
+ 'email' => $email,
598
+ ),
599
+ 'woocommerce-advanced-shipment-tracking/',
600
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
601
+ );
602
+ $message .= ob_get_clean();
603
+ }
604
+ if($wcast_show_address == 1){
605
+ ob_start();
606
+ wc_get_template(
607
+ 'emails/wcast-email-addresses.php', array(
608
+ 'order' => $order,
609
+ 'sent_to_admin' => $sent_to_admin,
610
+ ),
611
+ 'woocommerce-advanced-shipment-tracking/',
612
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
613
+ );
614
+ $message .= ob_get_clean();
615
+ }
616
+ // create a new email
617
+ $email = new WC_Email();
618
+
619
+ // wrap the content with the email template and then add styles
620
+ $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
621
+
622
+ echo $message;
623
+ }
624
+ }
625
+ /**
626
+ * Initialise our Customizer settings
627
+ */
628
+
629
+ $wcast_customizer_settings = new wcast_initialise_customizer_email();
includes/customizer/class-wc-tracking-info-customizer.php ADDED
@@ -0,0 +1,773 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Customizer Setup and Custom Controls
4
+ *
5
+ */
6
+
7
+ /**
8
+ * Adds the individual sections, settings, and controls to the theme customizer
9
+ */
10
+ class wcast_initialise_customizer_settings {
11
+ // Get our default values
12
+ private $defaults;
13
+ private static $order_ids = null;
14
+ public function __construct() {
15
+ // Get our Customizer defaults
16
+ $this->defaults = $this->wcast_generate_defaults();
17
+
18
+
19
+ // Register our sample default controls
20
+ add_action( 'customize_register', array( $this, 'wcast_register_sample_default_controls' ) );
21
+
22
+ // Only proceed if this is own request.
23
+ if ( ! wcast_initialise_customizer_settings::is_own_customizer_request() && ! wcast_initialise_customizer_settings::is_own_preview_request() ) {
24
+ return;
25
+ }
26
+ // Set up preview.
27
+
28
+ // Register our Panels
29
+ add_action( 'customize_register', array( $this, 'wcast_add_customizer_panels' ) );
30
+
31
+ // Register our sections
32
+ add_action( 'customize_register', array( $this, 'wcast_add_customizer_sections' ) );
33
+
34
+ // Remove unrelated components.
35
+ add_filter( 'customize_loaded_components', array( $this, 'remove_unrelated_components' ), 99, 2 );
36
+
37
+ // Remove unrelated sections.
38
+ add_filter( 'customize_section_active', array( $this, 'remove_unrelated_sections' ), 10, 2 );
39
+
40
+ // Unhook divi front end.
41
+ add_action( 'woomail_footer', array( $this, 'unhook_divi' ), 10 );
42
+
43
+ // Unhook Flatsome js
44
+ add_action( 'customize_preview_init', array( $this, 'unhook_flatsome' ), 50 );
45
+
46
+ add_filter( 'customize_controls_enqueue_scripts', array( $this, 'enqueue_customizer_scripts' ) );
47
+
48
+ add_action( 'parse_request', array( $this, 'set_up_preview' ) );
49
+
50
+ add_action( 'customize_preview_init', array( $this, 'enqueue_preview_scripts' ) );
51
+ }
52
+
53
+ public function enqueue_preview_scripts() {
54
+ wp_enqueue_script('wcast-preview-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . '/assets/js/preview-scripts.js', array('jquery', 'customize-preview'), wc_advanced_shipment_tracking()->version, true);
55
+ }
56
+ /**
57
+ * Enqueue Customizer scripts
58
+ *
59
+ * @access public
60
+ * @return void
61
+ */
62
+ public function enqueue_customizer_scripts() {
63
+ if(isset( $_REQUEST['wcast-tracking-customize'] ) && '1' === $_REQUEST['wcast-tracking-customize']){
64
+ wp_enqueue_style('wcast-customizer-styles', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer-styles.css', array(), wc_advanced_shipment_tracking()->version );
65
+ wp_enqueue_script('wcast-customizer-scripts', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/tracking-customizer-scripts.js', array('jquery', 'customize-controls'), wc_advanced_shipment_tracking()->version, true);
66
+
67
+ // Send variables to Javascript
68
+ wp_localize_script('wcast-customizer-scripts', 'wcast_customizer', array(
69
+ 'ajax_url' => admin_url('admin-ajax.php'),
70
+ 'email_preview_url' => $this->get_email_preview_url(),
71
+ 'tracking_preview_url' => $this->get_tracking_preview_url(),
72
+ 'labels' => array(
73
+ 'customtitle' => __('Tracking info display', 'woo-advanced-shipment-tracking'),
74
+ ),
75
+ ));
76
+ }
77
+ }
78
+ /**
79
+ * Checks to see if we are opening our custom customizer preview
80
+ *
81
+ * @access public
82
+ * @return bool
83
+ */
84
+ public static function is_own_preview_request() {
85
+ return isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview'];
86
+ }
87
+ /**
88
+ * Checks to see if we are opening our custom customizer controls
89
+ *
90
+ * @access public
91
+ * @return bool
92
+ */
93
+ public static function is_own_customizer_request() {
94
+ return isset( $_REQUEST['wcast-tracking-customize'] ) && $_REQUEST['wcast-tracking-customize'] === '1';
95
+ }
96
+ /*
97
+ * Unhook flatsome front end.
98
+ */
99
+ public function unhook_flatsome() {
100
+ // Unhook flatsome issue.
101
+ wp_dequeue_style( 'flatsome-customizer-preview' );
102
+ wp_dequeue_script( 'flatsome-customizer-frontend-js' );
103
+ }
104
+ /*
105
+ * Unhook Divi front end.
106
+ */
107
+ public function unhook_divi() {
108
+ // Divi Theme issue.
109
+ remove_action( 'wp_footer', 'et_builder_get_modules_js_data' );
110
+ remove_action( 'et_customizer_footer_preview', 'et_load_social_icons' );
111
+ }
112
+ /**
113
+ * Get Customizer URL
114
+ *
115
+ */
116
+ public static function get_customizer_url() {
117
+ $customizer_url = add_query_arg( array(
118
+ 'wcast-tracking-customize' => '1',
119
+ 'url' => urlencode( add_query_arg( array( 'wcast-tracking-preview' => '1' ), home_url( '/' ) ) ),
120
+ 'return' => urlencode( wcast_initialise_customizer_settings::get_email_settings_page_url() ),
121
+ ), admin_url( 'customize.php' ) );
122
+
123
+ return $customizer_url;
124
+ }
125
+ /**
126
+ * Get Customizer URL
127
+ *
128
+ */
129
+ public static function get_email_preview_url() {
130
+ $email_preview_url = add_query_arg( array(
131
+ 'wcast-email-customizer-preview' => '1',
132
+ ), home_url( '' ) );
133
+
134
+ return $email_preview_url;
135
+ }
136
+ /**
137
+ * Get Customizer URL
138
+ *
139
+ */
140
+ public static function get_tracking_preview_url() {
141
+ $tracking_preview_url = add_query_arg( array(
142
+ 'wcast-tracking-preview' => '1',
143
+ ), home_url( '' ) );
144
+
145
+ return $tracking_preview_url;
146
+ }
147
+ /**
148
+ * Get WooCommerce email settings page URL
149
+ *
150
+ * @access public
151
+ * @return string
152
+ */
153
+ public static function get_email_settings_page_url() {
154
+ return admin_url( 'admin.php?page=woocommerce-advanced-shipment-tracking' );
155
+ }
156
+ public function wcast_generate_defaults() {
157
+ $customizer_defaults = array(
158
+ 'display_shipment_provider_image' => '',
159
+ 'remove_date_from_tracking' => '',
160
+ 'header_text_change' => '',
161
+ 'additional_header_text' => '',
162
+ 'table_bg_color' => '',
163
+ 'table_border_color' => '',
164
+ 'table_border_size' => '',
165
+ 'table_header_font_size' => '',
166
+ 'table_header_font_color' => '',
167
+ 'table_content_font_size' => '',
168
+ 'table_content_font_color' => '',
169
+ 'tracking_link_font_color' => '',
170
+ 'tracking_link_bg_color' => '',
171
+ 'wcast_preview_order_id' => 'mockup',
172
+ 'table_content_line_height' => '20',
173
+ 'table_content_font_weight' => '100'
174
+ );
175
+
176
+ return apply_filters( 'skyrocket_customizer_defaults', $customizer_defaults );
177
+ }
178
+
179
+ /**
180
+ * Register the Customizer panels
181
+ */
182
+ public function wcast_add_customizer_panels( $wp_customize ) {
183
+ /**
184
+ * Add our Header & Navigation Panel
185
+ */
186
+ $wp_customize->add_panel( 'wcast_naviation_panel',
187
+ array(
188
+ 'title' => __( 'Shipment Tracking', 'woo-advanced-shipment-tracking' ),
189
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' )
190
+ )
191
+ );
192
+ }
193
+
194
+ /**
195
+ * Register the Customizer sections
196
+ */
197
+ public function wcast_add_customizer_sections( $wp_customize ) {
198
+ $wp_customize->add_section( 'default_controls_section',
199
+ array(
200
+ 'title' => __( 'Tracking info display', 'woo-advanced-shipment-tracking' ),
201
+ 'description' => esc_html__( 'This section lets you customize the Tracking Info display design.', 'woo-advanced-shipment-tracking' ),
202
+ 'panel' => 'wcast_naviation_panel'
203
+ )
204
+ );
205
+ $wp_customize->add_section( 'email_controls_section',
206
+ array(
207
+ 'title' => __( 'Delivered order status email', 'woo-advanced-shipment-tracking' ),
208
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
209
+ 'panel' => 'wcast_naviation_panel'
210
+ )
211
+ );
212
+ }
213
+ /**
214
+ * Get Order Ids
215
+ *
216
+ * @access public
217
+ * @return array
218
+ */
219
+ public static function get_order_ids() {
220
+ if ( is_null( wcast_initialise_customizer_settings::$order_ids ) ) {
221
+ $order_array = array();
222
+ $order_array['mockup'] = __( 'Select order to preview', 'woo-advanced-shipment-tracking' );
223
+ $orders = new WP_Query(
224
+ array(
225
+ 'post_type' => 'shop_order',
226
+ 'post_status' => array_keys( wc_get_order_statuses() ),
227
+ 'posts_per_page' => 20,
228
+ )
229
+ );
230
+ if ( $orders->posts ) {
231
+ foreach ( $orders->posts as $order ) {
232
+ // Get order object.
233
+ $order_object = new WC_Order( $order->ID );
234
+ $order_array[ $order_object->get_id() ] = $order_object->get_id() . ' - ' . $order_object->get_billing_first_name() . ' ' . $order_object->get_billing_last_name();
235
+ }
236
+ }
237
+ wcast_initialise_customizer_settings::$order_ids = $order_array;
238
+ }
239
+ return wcast_initialise_customizer_settings::$order_ids;
240
+ }
241
+ /**
242
+ * Register our sample default controls
243
+ */
244
+ public function wcast_register_sample_default_controls( $wp_customize ) {
245
+ /**
246
+ * Load all our Customizer Custom Controls
247
+ */
248
+ require_once trailingslashit( dirname(__FILE__) ) . 'custom-controls.php';
249
+ // Preview Order
250
+ $wp_customize->add_setting( 'wcast_preview_order_id',
251
+ array(
252
+ 'default' => $this->defaults['wcast_preview_order_id'],
253
+ 'transport' => 'refresh',
254
+ 'sanitize_callback' => ''
255
+ )
256
+ );
257
+
258
+ $wp_customize->add_control( 'wcast_preview_order_id',
259
+ array(
260
+ 'label' => __( 'Preview order', 'woo-advanced-shipment-tracking' ),
261
+ 'description' => esc_html__( 'select from last 20 orders one order that you added tracking info in order to preview and design the tracking info table.', 'woo-advanced-shipment-tracking' ),
262
+ 'section' => 'default_controls_section',
263
+ 'type' => 'select',
264
+ 'choices' => wcast_initialise_customizer_settings::get_order_ids(),
265
+ )
266
+ );
267
+ // Display Shipment Provider image/thumbnail
268
+ $wp_customize->add_setting( 'display_shipment_provider_image',
269
+ array(
270
+ 'default' => $this->defaults['display_shipment_provider_image'],
271
+ 'transport' => 'postMessage',
272
+ 'sanitize_callback' => ''
273
+ )
274
+ );
275
+ $wp_customize->add_control( 'display_shipment_provider_image',
276
+ array(
277
+ 'label' => __( 'Shipment Provider image', 'woo-advanced-shipment-tracking' ),
278
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
279
+ 'section' => 'default_controls_section',
280
+ 'type' => 'checkbox'
281
+ )
282
+ );
283
+
284
+ // Remove date from tracking info
285
+ $wp_customize->add_setting( 'remove_date_from_tracking',
286
+ array(
287
+ 'default' => $this->defaults['remove_date_from_tracking'],
288
+ 'transport' => 'postMessage',
289
+ 'sanitize_callback' => ''
290
+ )
291
+ );
292
+ $wp_customize->add_control( 'remove_date_from_tracking',
293
+ array(
294
+ 'label' => __( 'Remove date from tracking info', 'woo-advanced-shipment-tracking' ),
295
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
296
+ 'section' => 'default_controls_section',
297
+ 'type' => 'checkbox'
298
+ )
299
+ );
300
+
301
+ // Header Text
302
+ $wp_customize->add_setting( 'header_text_change',
303
+ array(
304
+ 'default' => $this->defaults['header_text_change'],
305
+ 'transport' => 'postMessage',
306
+ 'sanitize_callback' => ''
307
+ )
308
+ );
309
+ $wp_customize->add_control( 'header_text_change',
310
+ array(
311
+ 'label' => __( 'Header Text', 'woo-advanced-shipment-tracking' ),
312
+ 'description' => esc_html__( '', 'woo-advanced-shipment-tracking' ),
313
+ 'section' => 'default_controls_section',
314
+ 'type' => 'text',
315
+ 'input_attrs' => array(
316
+ 'class' => '',
317
+ 'style' => '',
318
+ 'placeholder' => __( 'Tracking Information', 'woo-advanced-shipment-tracking' ),
319
+ ),
320
+ )
321
+ );
322
+
323
+ // Additional text after header
324
+ $wp_customize->add_setting( 'additional_header_text',
325
+ array(
326
+ 'default' => $this->defaults['additional_header_text'],
327
+ 'transport' => 'postMessage',
328
+ 'sanitize_callback' => ''
329
+ )
330
+ );
331
+ $wp_customize->add_control( 'additional_header_text',
332
+ array(
333
+ 'label' => __( 'Additional text after header', 'woo-advanced-shipment-tracking' ),
334
+ 'section' => 'default_controls_section',
335
+ 'type' => 'textarea',
336
+ 'input_attrs' => array(
337
+ 'class' => '',
338
+ 'style' => '',
339
+ 'placeholder' =>'',
340
+ ),
341
+ )
342
+ );
343
+
344
+ // Test of Toggle Switch Custom Control
345
+ $wp_customize->add_setting( 'table_header',
346
+ array(
347
+ 'default' => '',
348
+ 'transport' => 'postMessage',
349
+ 'sanitize_callback' => ''
350
+ )
351
+ );
352
+ $wp_customize->add_control( new WP_Customize_Heading_Control( $wp_customize, 'table_header',
353
+ array(
354
+ 'label' => __( 'Table Design', 'woo-advanced-shipment-tracking' ),
355
+ 'section' => 'default_controls_section'
356
+ )
357
+ ) );
358
+
359
+ // Table Background color
360
+ $wp_customize->add_setting( 'table_bg_color',
361
+ array(
362
+ 'default' => $this->defaults['table_bg_color'],
363
+ 'transport' => 'postMessage',
364
+ 'sanitize_callback' => 'sanitize_hex_color'
365
+ )
366
+ );
367
+ $wp_customize->add_control( 'table_bg_color',
368
+ array(
369
+ 'label' => __( 'Background color', 'woo-advanced-shipment-tracking' ),
370
+ 'section' => 'default_controls_section',
371
+ 'type' => 'color',
372
+ )
373
+ );
374
+
375
+ // Table Border color
376
+ $wp_customize->add_setting( 'table_border_color',
377
+ array(
378
+ 'default' => $this->defaults['table_border_color'],
379
+ 'transport' => 'postMessage',
380
+ 'sanitize_callback' => 'sanitize_hex_color'
381
+ )
382
+ );
383
+ $wp_customize->add_control( 'table_border_color',
384
+ array(
385
+ 'label' => __( 'Border color', 'woo-advanced-shipment-tracking' ),
386
+ 'section' => 'default_controls_section',
387
+ 'type' => 'color'
388
+ )
389
+ );
390
+
391
+ // Table Border size
392
+ $wp_customize->add_setting( 'table_border_size',
393
+ array(
394
+ 'default' => $this->defaults['table_border_size'],
395
+ 'transport' => 'postMessage',
396
+ 'sanitize_callback' => ''
397
+ )
398
+ );
399
+ $wp_customize->add_control( 'table_border_size',
400
+ array(
401
+ 'label' => __( 'Border size', 'woo-advanced-shipment-tracking' ),
402
+ 'section' => 'default_controls_section',
403
+ 'type' => 'select',
404
+ 'choices' => array(
405
+ '' => __( 'Select', 'woo-advanced-shipment-tracking' ),
406
+ '1' => '1 px',
407
+ '2' => '2 px',
408
+ '3' => '3 px',
409
+ '4' => '4 px',
410
+ '5' => '5 px',
411
+ )
412
+ )
413
+ );
414
+ $font_size_array[ '' ] = __( 'Select', 'woo-advanced-shipment-tracking' );
415
+ for ( $i = 10; $i <= 30; $i++ ) {
416
+ $font_size_array[ $i ] = $i."px";
417
+ }
418
+ // Table header font size
419
+ $wp_customize->add_setting( 'table_header_font_size',
420
+ array(
421
+ 'default' => $this->defaults['table_header_font_size'],
422
+ 'transport' => 'postMessage',
423
+ 'sanitize_callback' => ''
424
+ )
425
+ );
426
+ $wp_customize->add_control( 'table_header_font_size',
427
+ array(
428
+ 'label' => __( 'Header font size', 'woo-advanced-shipment-tracking' ),
429
+ 'section' => 'default_controls_section',
430
+ 'type' => 'select',
431
+ 'choices' => $font_size_array
432
+ )
433
+ );
434
+
435
+ // Table header font color
436
+ $wp_customize->add_setting( 'table_header_font_color',
437
+ array(
438
+ 'default' => $this->defaults['table_header_font_color'],
439
+ 'transport' => 'postMessage',
440
+ 'sanitize_callback' => ''
441
+ )
442
+ );
443
+ $wp_customize->add_control( 'table_header_font_color',
444
+ array(
445
+ 'label' => __( 'Header font color', 'woo-advanced-shipment-tracking' ),
446
+ 'section' => 'default_controls_section',
447
+ 'type' => 'color'
448
+ )
449
+ );
450
+
451
+ // Table content font size
452
+ $wp_customize->add_setting( 'table_content_font_size',
453
+ array(
454
+ 'default' => $this->defaults['table_content_font_size'],
455
+ 'transport' => 'postMessage',
456
+ 'sanitize_callback' => ''
457
+ )
458
+ );
459
+ $wp_customize->add_control( 'table_content_font_size',
460
+ array(
461
+ 'label' => __( 'Content font size', 'woo-advanced-shipment-tracking' ),
462
+ 'section' => 'default_controls_section',
463
+ 'type' => 'select',
464
+ 'choices' => $font_size_array
465
+ )
466
+ );
467
+
468
+ // Table content font color
469
+ $wp_customize->add_setting( 'table_content_font_color',
470
+ array(
471
+ 'default' => $this->defaults['table_content_font_color'],
472
+ 'transport' => 'postMessage',
473
+ 'sanitize_callback' => ''
474
+ )
475
+ );
476
+ $wp_customize->add_control( 'table_content_font_color',
477
+ array(
478
+ 'label' => __( 'Content font color', 'woo-advanced-shipment-tracking' ),
479
+ 'section' => 'default_controls_section',
480
+ 'type' => 'color'
481
+ )
482
+ );
483
+
484
+ // Table content line height
485
+ $wp_customize->add_setting( 'table_content_line_height',
486
+ array(
487
+ 'default' => $this->defaults['table_content_line_height'],
488
+ 'transport' => 'postMessage',
489
+ 'sanitize_callback' => ''
490
+ )
491
+ );
492
+ $wp_customize->add_control( new Skyrocket_Slider_Custom_Control( $wp_customize, 'table_content_line_height',
493
+ array(
494
+ 'label' => __( 'Content line height', 'woo-advanced-shipment-tracking' ),
495
+ 'section' => 'default_controls_section',
496
+ 'input_attrs' => array(
497
+ 'default' => $this->defaults['table_content_line_height'],
498
+ 'step' => 1,
499
+ 'min' => 20,
500
+ 'max' => 90,
501
+ ),
502
+ )
503
+ ));
504
+
505
+ // Table content font weight
506
+ $wp_customize->add_setting( 'table_content_font_weight',
507
+ array(
508
+ 'default' => $this->defaults['table_content_font_weight'],
509
+ 'transport' => 'postMessage',
510
+ 'sanitize_callback' => ''
511
+ )
512
+ );
513
+ $wp_customize->add_control( new Skyrocket_Slider_Custom_Control( $wp_customize, 'table_content_font_weight',
514
+ array(
515
+ 'label' => __( 'Content font weight', 'woo-advanced-shipment-tracking' ),
516
+ 'section' => 'default_controls_section',
517
+ 'input_attrs' => array(
518
+ 'default' => $this->defaults['table_content_font_weight'],
519
+ 'step' => 100,
520
+ 'min' => 100,
521
+ 'max' => 900,
522
+ ),
523
+ )
524
+ ));
525
+
526
+ // Tracking link font color
527
+ $wp_customize->add_setting( 'tracking_link_font_color',
528
+ array(
529
+ 'default' => $this->defaults['tracking_link_font_color'],
530
+ 'transport' => 'postMessage',
531
+ 'sanitize_callback' => ''
532
+ )
533
+ );
534
+ $wp_customize->add_control( 'tracking_link_font_color',
535
+ array(
536
+ 'label' => __( 'Link font color', 'woo-advanced-shipment-tracking' ),
537
+ 'section' => 'default_controls_section',
538
+ 'type' => 'color'
539
+ )
540
+ );
541
+
542
+ // Tracking link background color
543
+ $wp_customize->add_setting( 'tracking_link_bg_color',
544
+ array(
545
+ 'default' => $this->defaults['tracking_link_bg_color'],
546
+ 'transport' => 'postMessage',
547
+ 'sanitize_callback' => ''
548
+ )
549
+ );
550
+ $wp_customize->add_control( 'tracking_link_bg_color',
551
+ array(
552
+ 'label' => __( 'Link background color', 'woo-advanced-shipment-tracking' ),
553
+ 'section' => 'default_controls_section',
554
+ 'type' => 'color'
555
+ )
556
+ );
557
+ }
558
+ /**
559
+ * Remove unrelated components
560
+ *
561
+ * @access public
562
+ * @param array $components
563
+ * @param object $wp_customize
564
+ * @return array
565
+ */
566
+ public function remove_unrelated_components($components, $wp_customize) {
567
+ // Iterate over components
568
+ foreach ($components as $component_key => $component) {
569
+
570
+ // Check if current component is own component
571
+ if ( ! wcast_initialise_customizer_settings::is_own_component( $component ) ) {
572
+ unset($components[$component_key]);
573
+ }
574
+ }
575
+
576
+ // Return remaining components
577
+ return $components;
578
+ }
579
+
580
+ /**
581
+ * Remove unrelated sections
582
+ *
583
+ * @access public
584
+ * @param bool $active
585
+ * @param object $section
586
+ * @return bool
587
+ */
588
+ public function remove_unrelated_sections( $active, $section ) {
589
+ // Check if current section is own section
590
+ if ( ! wcast_initialise_customizer_settings::is_own_section( $section->id ) ) {
591
+ return false;
592
+ }
593
+
594
+ // We can override $active completely since this runs only on own Customizer requests
595
+ return true;
596
+ }
597
+
598
+ /**
599
+ * Remove unrelated controls
600
+ *
601
+ * @access public
602
+ * @param bool $active
603
+ * @param object $control
604
+ * @return bool
605
+ */
606
+ public function remove_unrelated_controls( $active, $control ) {
607
+
608
+ // Check if current control belongs to own section
609
+ if ( ! wcast_add_customizer_sections::is_own_section( $control->section ) ) {
610
+ return false;
611
+ }
612
+
613
+ // We can override $active completely since this runs only on own Customizer requests
614
+ return $active;
615
+ }
616
+
617
+ /**
618
+ * Check if current component is own component
619
+ *
620
+ * @access public
621
+ * @param string $component
622
+ * @return bool
623
+ */
624
+ public static function is_own_component( $component ) {
625
+ return false;
626
+ }
627
+
628
+ /**
629
+ * Check if current section is own section
630
+ *
631
+ * @access public
632
+ * @param string $key
633
+ * @return bool
634
+ */
635
+ public static function is_own_section( $key ) {
636
+
637
+ if ($key === 'default_controls_section' || $key === 'email_controls_section') {
638
+ return true;
639
+ }
640
+
641
+ // Section not found
642
+ return false;
643
+ }
644
+
645
+ /**
646
+ * Set up preview
647
+ *
648
+ * @access public
649
+ * @return void
650
+ */
651
+ public function set_up_preview() {
652
+
653
+ // Make sure this is own preview request.
654
+ if ( ! wcast_initialise_customizer_settings::is_own_preview_request() ) {
655
+ return;
656
+ }
657
+ include wc_advanced_shipment_tracking()->get_plugin_path() . '/includes/customizer/preview.php';
658
+ exit;
659
+ }
660
+
661
+ public function preview_completed_email(){
662
+ // Load WooCommerce emails.
663
+ $wc_emails = WC_Emails::instance();
664
+ $emails = $wc_emails->get_emails();
665
+ $email_template = 'customer_completed_order';
666
+ $preview_id = get_theme_mod('wcast_preview_order_id');
667
+ $email_type = 'WC_Email_Customer_Completed_Order';
668
+ if ( false === $email_type ) {
669
+ return false;
670
+ }
671
+
672
+ $order_status = 'completed';
673
+
674
+ if($preview_id == '' || $preview_id == 'mockup') {
675
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . __( 'Please select preview order.', 'woo-advanced-shipment-tracking' ) . '</div>';
676
+ echo $content;
677
+ return;
678
+ }
679
+
680
+ // Reference email.
681
+ if ( isset( $emails[ $email_type ] ) && is_object( $emails[ $email_type ] ) ) {
682
+ $email = $emails[ $email_type ];
683
+ }
684
+
685
+ // Get an order
686
+ $order = self::get_wc_order_for_preview( $order_status, $preview_id );
687
+
688
+ // Make sure gateways are running in case the email needs to input content from them.
689
+ WC()->payment_gateways();
690
+ // Make sure shipping is running in case the email needs to input content from it.
691
+ WC()->shipping();
692
+
693
+ $email->object = $order;
694
+ $email->find['order-date'] = '{order_date}';
695
+ $email->find['order-number'] = '{order_number}';
696
+ if ( is_object( $order ) ) {
697
+ $email->replace['order-date'] = wc_format_datetime( $email->object->get_date_created() );
698
+ $email->replace['order-number'] = $email->object->get_order_number();
699
+ // Other properties
700
+ $email->recipient = $email->object->get_billing_email();
701
+ }
702
+ // Get email content and apply styles.
703
+ $content = $email->get_content();
704
+ $content = $email->style_inline( $content );
705
+ $content = apply_filters( 'woocommerce_mail_content', $content );
706
+
707
+ if ( 'plain' === $email->email_type ) {
708
+ $content = '<div style="padding: 35px 40px; background-color: white;">' . str_replace( "\n", '<br/>', $content ) . '</div>';
709
+ }
710
+ echo $content;
711
+ }
712
+ /**
713
+ * Get WooCommerce order for preview
714
+ *
715
+ * @access public
716
+ * @param string $order_status
717
+ * @return object
718
+ */
719
+ public static function get_wc_order_for_preview( $order_status = null, $order_id = null ) {
720
+ if ( ! empty( $order_id ) && 'mockup' != $order_id ) {
721
+ return wc_get_order( $order_id );
722
+ } else {
723
+ // Use mockup order
724
+
725
+ // Instantiate order object
726
+ $order = new WC_Order();
727
+
728
+ // Other order properties
729
+ $order->set_props( array(
730
+ 'id' => 1,
731
+ 'status' => ( null === $order_status ? 'processing' : $order_status ),
732
+ 'billing_first_name' => 'Sherlock',
733
+ 'billing_last_name' => 'Holmes',
734
+ 'billing_company' => 'Detectives Ltd.',
735
+ 'billing_address_1' => '221B Baker Street',
736
+ 'billing_city' => 'London',
737
+ 'billing_postcode' => 'NW1 6XE',
738
+ 'billing_country' => 'GB',
739
+ 'billing_email' => 'sherlock@holmes.co.uk',
740
+ 'billing_phone' => '02079304832',
741
+ 'date_created' => date( 'Y-m-d H:i:s' ),
742
+ 'total' => 24.90,
743
+ ) );
744
+
745
+ // Item #1
746
+ $order_item = new WC_Order_Item_Product();
747
+ $order_item->set_props( array(
748
+ 'name' => 'A Study in Scarlet',
749
+ 'subtotal' => '9.95',
750
+ 'sku' => 'kwd_ex_1',
751
+ ) );
752
+ $order->add_item( $order_item );
753
+
754
+ // Item #2
755
+ $order_item = new WC_Order_Item_Product();
756
+ $order_item->set_props( array(
757
+ 'name' => 'The Hound of the Baskervilles',
758
+ 'subtotal' => '14.95',
759
+ 'sku' => 'kwd_ex_2',
760
+ ) );
761
+ $order->add_item( $order_item );
762
+
763
+ // Return mockup order
764
+ return $order;
765
+ }
766
+
767
+ }
768
+ }
769
+ /**
770
+ * Initialise our Customizer settings
771
+ */
772
+
773
+ $wcast_customizer_settings = new wcast_initialise_customizer_settings();
includes/customizer/custom-controls.php ADDED
@@ -0,0 +1,1090 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Skyrocket Customizer Custom Controls
4
+ *
5
+ */
6
+ if ( class_exists( 'WP_Customize_Control' ) ) {
7
+ class WP_Customize_Heading_Control extends WP_Customize_Control {
8
+
9
+ public function render_content() {
10
+ ?>
11
+ <label>
12
+ <h3 class="control_heading"><?php _e( $this->label, 'woo-advanced-shipment-tracking' ); ?></h3>
13
+ <?php if ( ! empty( $this->description ) ) : ?>
14
+ <span class="description customize-control-description"><?php echo $this->description; ?></span>
15
+ <?php endif; ?>
16
+ </label>
17
+ <?php
18
+ }
19
+ }
20
+
21
+ class WP_Customize_codeinfoblock_Control extends WP_Customize_Control {
22
+
23
+ public function render_content() {
24
+ ?>
25
+ <label>
26
+ <h3 class="customize-control-title"><?php _e( $this->label, 'woo-advanced-shipment-tracking' ); ?></h3>
27
+ <?php if ( ! empty( $this->description ) ) : ?>
28
+ <span class="description customize-control-description"><?php echo $this->description; ?></span>
29
+ <?php endif; ?>
30
+ </label>
31
+ <?php
32
+ }
33
+ }
34
+ /**
35
+ * Custom Control Base Class
36
+ *
37
+ * @author Anthony Hortin <http://maddisondesigns.com>
38
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
39
+ * @link https://github.com/maddisondesigns
40
+ */
41
+ class Skyrocket_Custom_Control extends WP_Customize_Control {
42
+ protected function get_skyrocket_resource_url() {
43
+ if( strpos( wp_normalize_path( __DIR__ ), wp_normalize_path( WP_PLUGIN_DIR ) ) === 0 ) {
44
+ // We're in a plugin directory and need to determine the url accordingly.
45
+ return plugin_dir_url( __DIR__ );
46
+ }
47
+
48
+ return trailingslashit( get_template_directory_uri() );
49
+ }
50
+ }
51
+
52
+ /**
53
+ * Image Check Box Custom Control
54
+ *
55
+ * @author Anthony Hortin <http://maddisondesigns.com>
56
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
57
+ * @link https://github.com/maddisondesigns
58
+ */
59
+ class Skyrocket_Image_Checkbox_Custom_Control extends Skyrocket_Custom_Control {
60
+ /**
61
+ * The type of control being rendered
62
+ */
63
+ public $type = 'image_checkbox';
64
+ /**
65
+ * Enqueue our scripts and styles
66
+ */
67
+ public function enqueue() {
68
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
69
+ }
70
+ /**
71
+ * Render the control in the customizer
72
+ */
73
+ public function render_content() {
74
+ ?>
75
+ <div class="image_checkbox_control">
76
+ <?php if( !empty( $this->label ) ) { ?>
77
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
78
+ <?php } ?>
79
+ <?php if( !empty( $this->description ) ) { ?>
80
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
81
+ <?php } ?>
82
+ <?php $chkboxValues = explode( ',', esc_attr( $this->value() ) ); ?>
83
+ <input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize-control-multi-image-checkbox" <?php $this->link(); ?> />
84
+ <?php foreach ( $this->choices as $key => $value ) { ?>
85
+ <label class="checkbox-label">
86
+ <input type="checkbox" name="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php checked( in_array( esc_attr( $key ), $chkboxValues ), 1 ); ?> class="multi-image-checkbox"/>
87
+ <img src="<?php echo esc_attr( $value['image'] ); ?>" alt="<?php echo esc_attr( $value['name'] ); ?>" title="<?php echo esc_attr( $value['name'] ); ?>" />
88
+ </label>
89
+ <?php } ?>
90
+ </div>
91
+ <?php
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Text Radio Button Custom Control
97
+ *
98
+ * @author Anthony Hortin <http://maddisondesigns.com>
99
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
100
+ * @link https://github.com/maddisondesigns
101
+ */
102
+ class Skyrocket_Text_Radio_Button_Custom_Control extends Skyrocket_Custom_Control {
103
+ /**
104
+ * The type of control being rendered
105
+ */
106
+ public $type = 'text_radio_button';
107
+ /**
108
+ * Enqueue our scripts and styles
109
+ */
110
+ public function enqueue() {
111
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
112
+ }
113
+ /**
114
+ * Render the control in the customizer
115
+ */
116
+ public function render_content() {
117
+ ?>
118
+ <div class="text_radio_button_control">
119
+ <?php if( !empty( $this->label ) ) { ?>
120
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
121
+ <?php } ?>
122
+ <?php if( !empty( $this->description ) ) { ?>
123
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
124
+ <?php } ?>
125
+
126
+ <div class="radio-buttons">
127
+ <?php foreach ( $this->choices as $key => $value ) { ?>
128
+ <label class="radio-button-label">
129
+ <input type="radio" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php $this->link(); ?> <?php checked( esc_attr( $key ), $this->value() ); ?>/>
130
+ <span><?php echo esc_attr( $value ); ?></span>
131
+ </label>
132
+ <?php } ?>
133
+ </div>
134
+ </div>
135
+ <?php
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Image Radio Button Custom Control
141
+ *
142
+ * @author Anthony Hortin <http://maddisondesigns.com>
143
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
144
+ * @link https://github.com/maddisondesigns
145
+ */
146
+ class Skyrocket_Image_Radio_Button_Custom_Control extends Skyrocket_Custom_Control {
147
+ /**
148
+ * The type of control being rendered
149
+ */
150
+ public $type = 'image_radio_button';
151
+ /**
152
+ * Enqueue our scripts and styles
153
+ */
154
+ public function enqueue() {
155
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
156
+ }
157
+ /**
158
+ * Render the control in the customizer
159
+ */
160
+ public function render_content() {
161
+ ?>
162
+ <div class="image_radio_button_control">
163
+ <?php if( !empty( $this->label ) ) { ?>
164
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
165
+ <?php } ?>
166
+ <?php if( !empty( $this->description ) ) { ?>
167
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
168
+ <?php } ?>
169
+
170
+ <?php foreach ( $this->choices as $key => $value ) { ?>
171
+ <label class="radio-button-label">
172
+ <input type="radio" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $key ); ?>" <?php $this->link(); ?> <?php checked( esc_attr( $key ), $this->value() ); ?>/>
173
+ <img src="<?php echo esc_attr( $value['image'] ); ?>" alt="<?php echo esc_attr( $value['name'] ); ?>" title="<?php echo esc_attr( $value['name'] ); ?>" />
174
+ </label>
175
+ <?php } ?>
176
+ </div>
177
+ <?php
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Single Accordion Custom Control
183
+ *
184
+ * @author Anthony Hortin <http://maddisondesigns.com>
185
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
186
+ * @link https://github.com/maddisondesigns
187
+ */
188
+ class Skyrocket_Single_Accordion_Custom_Control extends Skyrocket_Custom_Control {
189
+ /**
190
+ * The type of control being rendered
191
+ */
192
+ public $type = 'single_accordion';
193
+ /**
194
+ * Enqueue our scripts and styles
195
+ */
196
+ public function enqueue() {
197
+ wp_enqueue_script( 'skyrocket-custom-controls-js', $this->get_skyrocket_resource_url() . 'js/customizer.js', array( 'jquery' ), '1.0', true );
198
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
199
+ wp_enqueue_style( 'fontawesome', $this->get_skyrocket_resource_url() . 'css/font-awesome.min.css', array(), '4.6.3', 'all' );
200
+ }
201
+ /**
202
+ * Render the control in the customizer
203
+ */
204
+ public function render_content() {
205
+ $allowed_html = array(
206
+ 'a' => array(
207
+ 'href' => array(),
208
+ 'title' => array(),
209
+ 'class' => array(),
210
+ 'target' => array(),
211
+ ),
212
+ 'br' => array(),
213
+ 'em' => array(),
214
+ 'strong' => array(),
215
+ 'i' => array(
216
+ 'class' => array()
217
+ ),
218
+ );
219
+ ?>
220
+ <div class="single-accordion-custom-control">
221
+ <div class="single-accordion-toggle"><?php echo esc_html( $this->label ); ?><span class="accordion-icon-toggle dashicons dashicons-plus"></span></div>
222
+ <div class="single-accordion customize-control-description">
223
+ <?php
224
+ if ( is_array( $this->description ) ) {
225
+ echo '<ul class="single-accordion-description">';
226
+ foreach ( $this->description as $key => $value ) {
227
+ echo '<li>' . $key . wp_kses( $value, $allowed_html ) . '</li>';
228
+ }
229
+ echo '</ul>';
230
+ }
231
+ else {
232
+ echo wp_kses( $this->description, $allowed_html );
233
+ }
234
+ ?>
235
+ </div>
236
+ </div>
237
+ <?php
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Simple Notice Custom Control
243
+ *
244
+ * @author Anthony Hortin <http://maddisondesigns.com>
245
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
246
+ * @link https://github.com/maddisondesigns
247
+ */
248
+ class Skyrocket_Simple_Notice_Custom_Control extends Skyrocket_Custom_Control {
249
+ /**
250
+ * The type of control being rendered
251
+ */
252
+ public $type = 'simple_notice';
253
+ /**
254
+ * Render the control in the customizer
255
+ */
256
+ public function render_content() {
257
+ $allowed_html = array(
258
+ 'a' => array(
259
+ 'href' => array(),
260
+ 'title' => array(),
261
+ 'class' => array(),
262
+ 'target' => array(),
263
+ ),
264
+ 'br' => array(),
265
+ 'em' => array(),
266
+ 'strong' => array(),
267
+ 'i' => array(
268
+ 'class' => array()
269
+ ),
270
+ 'span' => array(
271
+ 'class' => array(),
272
+ ),
273
+ 'code' => array(),
274
+ );
275
+ ?>
276
+ <div class="simple-notice-custom-control">
277
+ <?php if( !empty( $this->label ) ) { ?>
278
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
279
+ <?php } ?>
280
+ <?php if( !empty( $this->description ) ) { ?>
281
+ <span class="customize-control-description"><?php echo wp_kses( $this->description, $allowed_html ); ?></span>
282
+ <?php } ?>
283
+ </div>
284
+ <?php
285
+ }
286
+ }
287
+
288
+ /**
289
+ * Slider Custom Control
290
+ *
291
+ * @author Anthony Hortin <http://maddisondesigns.com>
292
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
293
+ * @link https://github.com/maddisondesigns
294
+ */
295
+ class Skyrocket_Slider_Custom_Control extends Skyrocket_Custom_Control {
296
+ /**
297
+ * The type of control being rendered
298
+ */
299
+ public $type = 'slider_control';
300
+ /**
301
+ * Enqueue our scripts and styles
302
+ */
303
+ public function enqueue() {
304
+ wp_enqueue_script( 'skyrocket-custom-controls-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer.js', array( 'jquery', 'jquery-ui-core' ), wc_advanced_shipment_tracking()->version, true );
305
+ wp_enqueue_style( 'skyrocket-custom-controls-css', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer.css', array(), wc_advanced_shipment_tracking()->version, 'all' );
306
+ }
307
+ /**
308
+ * Render the control in the customizer
309
+ */
310
+ public function render_content() {
311
+ ?>
312
+ <div class="slider-custom-control">
313
+ <span class="customize-control-title"><?php _e( $this->label, 'woo-advanced-shipment-tracking' ); ?></span>
314
+ <div class="slider" slider-min-value="<?php echo esc_attr( $this->input_attrs['min'] ); ?>" slider-max-value="<?php echo esc_attr( $this->input_attrs['max'] ); ?>" slider-step-value="<?php echo esc_attr( $this->input_attrs['step'] ); ?>">
315
+ </div>
316
+ <span class="slider-reset dashicons dashicons-image-rotate" slider-reset-value="<?php echo esc_attr( $this->input_attrs['default'] ); ?>"></span>
317
+ <input type="number" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize-control-slider-value" <?php $this->link(); ?> />
318
+ </div>
319
+ <?php
320
+ }
321
+ }
322
+
323
+ /**
324
+ * Toggle Switch Custom Control
325
+ *
326
+ * @author Anthony Hortin <http://maddisondesigns.com>
327
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
328
+ * @link https://github.com/maddisondesigns
329
+ */
330
+ class Skyrocket_Toggle_Switch_Custom_control extends Skyrocket_Custom_Control {
331
+ /**
332
+ * The type of control being rendered
333
+ */
334
+ public $type = 'toggle_switch';
335
+ /**
336
+ * Enqueue our scripts and styles
337
+ */
338
+ public function enqueue(){
339
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
340
+ }
341
+ /**
342
+ * Render the control in the customizer
343
+ */
344
+ public function render_content(){
345
+ ?>
346
+ <div class="toggle-switch-control">
347
+ <div class="toggle-switch">
348
+ <input type="checkbox" id="<?php echo esc_attr($this->id); ?>" name="<?php echo esc_attr($this->id); ?>" class="toggle-switch-checkbox" value="<?php echo esc_attr( $this->value() ); ?>" <?php $this->link(); checked( $this->value() ); ?>>
349
+ <label class="toggle-switch-label" for="<?php echo esc_attr( $this->id ); ?>">
350
+ <span class="toggle-switch-inner"></span>
351
+ <span class="toggle-switch-switch"></span>
352
+ </label>
353
+ </div>
354
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
355
+ <?php if( !empty( $this->description ) ) { ?>
356
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
357
+ <?php } ?>
358
+ </div>
359
+ <?php
360
+ }
361
+ }
362
+
363
+ /**
364
+ * Sortable Repeater Custom Control
365
+ *
366
+ * @author Anthony Hortin <http://maddisondesigns.com>
367
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
368
+ * @link https://github.com/maddisondesigns
369
+ */
370
+ class Skyrocket_Sortable_Repeater_Custom_Control extends Skyrocket_Custom_Control {
371
+ /**
372
+ * The type of control being rendered
373
+ */
374
+ public $type = 'sortable_repeater';
375
+ /**
376
+ * Button labels
377
+ */
378
+ public $button_labels = array();
379
+ /**
380
+ * Constructor
381
+ */
382
+ public function __construct( $manager, $id, $args = array(), $options = array() ) {
383
+ parent::__construct( $manager, $id, $args );
384
+ // Merge the passed button labels with our default labels
385
+ $this->button_labels = wp_parse_args( $this->button_labels,
386
+ array(
387
+ 'add' => __( 'Add', 'skyrocket' ),
388
+ )
389
+ );
390
+ }
391
+ /**
392
+ * Enqueue our scripts and styles
393
+ */
394
+ public function enqueue() {
395
+ wp_enqueue_script( 'skyrocket-custom-controls-js', $this->get_skyrocket_resource_url() . 'js/customizer.js', array( 'jquery', 'jquery-ui-core' ), '1.0', true );
396
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.0', 'all' );
397
+ }
398
+ /**
399
+ * Render the control in the customizer
400
+ */
401
+ public function render_content() {
402
+ ?>
403
+ <div class="sortable_repeater_control">
404
+ <?php if( !empty( $this->label ) ) { ?>
405
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
406
+ <?php } ?>
407
+ <?php if( !empty( $this->description ) ) { ?>
408
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
409
+ <?php } ?>
410
+ <input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize-control-sortable-repeater" <?php $this->link(); ?> />
411
+ <div class="sortable">
412
+ <div class="repeater">
413
+ <input type="text" value="" class="repeater-input" placeholder="https://" /><span class="dashicons dashicons-sort"></span><a class="customize-control-sortable-repeater-delete" href="#"><span class="dashicons dashicons-no-alt"></span></a>
414
+ </div>
415
+ </div>
416
+ <button class="button customize-control-sortable-repeater-add" type="button"><?php echo $this->button_labels['add']; ?></button>
417
+ </div>
418
+ <?php
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Dropdown Select2 Custom Control
424
+ *
425
+ * @author Anthony Hortin <http://maddisondesigns.com>
426
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
427
+ * @link https://github.com/maddisondesigns
428
+ */
429
+ class Skyrocket_Dropdown_Select2_Custom_Control extends Skyrocket_Custom_Control {
430
+ /**
431
+ * The type of control being rendered
432
+ */
433
+ public $type = 'dropdown_select2';
434
+ /**
435
+ * The type of Select2 Dropwdown to display. Can be either a single select dropdown or a multi-select dropdown. Either false for true. Default = false
436
+ */
437
+ private $multiselect = false;
438
+ /**
439
+ * The Placeholder value to display. Select2 requires a Placeholder value to be set when using the clearall option. Default = 'Please select...'
440
+ */
441
+ private $placeholder = 'Please select...';
442
+ /**
443
+ * Constructor
444
+ */
445
+ public function __construct( $manager, $id, $args = array(), $options = array() ) {
446
+ parent::__construct( $manager, $id, $args );
447
+ // Check if this is a multi-select field
448
+ if ( isset( $this->input_attrs['multiselect'] ) && $this->input_attrs['multiselect'] ) {
449
+ $this->multiselect = true;
450
+ }
451
+ // Check if a placeholder string has been specified
452
+ if ( isset( $this->input_attrs['placeholder'] ) && $this->input_attrs['placeholder'] ) {
453
+ $this->placeholder = $this->input_attrs['placeholder'];
454
+ }
455
+ }
456
+ /**
457
+ * Enqueue our scripts and styles
458
+ */
459
+ public function enqueue() {
460
+ wp_enqueue_script( 'skyrocket-select2-js', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js', array( 'jquery' ), '4.0.6', true );
461
+ wp_enqueue_script( 'skyrocket-custom-controls-js', $this->get_skyrocket_resource_url() . 'js/customizer.js', array( 'skyrocket-select2-js' ), '1.0', true );
462
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.1', 'all' );
463
+ wp_enqueue_style( 'skyrocket-select2-css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css', array(), '4.0.6', 'all' );
464
+ }
465
+ /**
466
+ * Render the control in the customizer
467
+ */
468
+ public function render_content() {
469
+ $defaultValue = $this->value();
470
+ if ( $this->multiselect ) {
471
+ $defaultValue = explode( ',', $this->value() );
472
+ }
473
+ ?>
474
+ <div class="dropdown_select2_control">
475
+ <?php if( !empty( $this->label ) ) { ?>
476
+ <label for="<?php echo esc_attr( $this->id ); ?>" class="customize-control-title">
477
+ <?php echo esc_html( $this->label ); ?>
478
+ </label>
479
+ <?php } ?>
480
+ <?php if( !empty( $this->description ) ) { ?>
481
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
482
+ <?php } ?>
483
+ <input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" class="customize-control-dropdown-select2" value="<?php echo esc_attr( $this->value() ); ?>" name="<?php echo esc_attr( $this->id ); ?>" <?php $this->link(); ?> />
484
+ <select name="select2-list-<?php echo ( $this->multiselect ? 'multi[]' : 'single' ); ?>" class="customize-control-select2" data-placeholder="<?php echo $this->placeholder; ?>" <?php echo ( $this->multiselect ? 'multiple="multiple" ' : '' ); ?>>
485
+ <?php
486
+ if ( !$this->multiselect ) {
487
+ // When using Select2 for single selection, the Placeholder needs an empty <option> at the top of the list for it to work (multi-selects dont need this)
488
+ echo '<option></option>';
489
+ }
490
+ foreach ( $this->choices as $key => $value ) {
491
+ if ( is_array( $value ) ) {
492
+ echo '<optgroup label="' . esc_attr( $key ) . '">';
493
+ foreach ( $value as $optgroupkey => $optgroupvalue ) {
494
+ echo '<option value="' . esc_attr( $optgroupkey ) . '" ' . ( in_array( esc_attr( $optgroupkey ), $defaultValue ) ? 'selected="selected"' : '' ) . '>' . esc_attr( $optgroupvalue ) . '</option>';
495
+ }
496
+ echo '</optgroup>';
497
+ }
498
+ else {
499
+ echo '<option value="' . esc_attr( $key ) . '" ' . selected( esc_attr( $key ), $defaultValue, false ) . '>' . esc_attr( $value ) . '</option>';
500
+ }
501
+ }
502
+ ?>
503
+ </select>
504
+ </div>
505
+ <?php
506
+ }
507
+ }
508
+
509
+ /**
510
+ * Dropdown Posts Custom Control
511
+ *
512
+ * @author Anthony Hortin <http://maddisondesigns.com>
513
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
514
+ * @link https://github.com/maddisondesigns
515
+ */
516
+ class Skyrocket_Dropdown_Posts_Custom_Control extends Skyrocket_Custom_Control {
517
+ /**
518
+ * The type of control being rendered
519
+ */
520
+ public $type = 'dropdown_posts';
521
+ /**
522
+ * Posts
523
+ */
524
+ private $posts = array();
525
+ /**
526
+ * Constructor
527
+ */
528
+ public function __construct( $manager, $id, $args = array(), $options = array() ) {
529
+ parent::__construct( $manager, $id, $args );
530
+ // Get our Posts
531
+ $this->posts = get_posts( $this->input_attrs );
532
+ }
533
+ /**
534
+ * Render the control in the customizer
535
+ */
536
+ public function render_content() {
537
+ ?>
538
+ <div class="dropdown_posts_control">
539
+ <?php if( !empty( $this->label ) ) { ?>
540
+ <label for="<?php echo esc_attr( $this->id ); ?>" class="customize-control-title">
541
+ <?php echo esc_html( $this->label ); ?>
542
+ </label>
543
+ <?php } ?>
544
+ <?php if( !empty( $this->description ) ) { ?>
545
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
546
+ <?php } ?>
547
+ <select name="<?php echo $this->id; ?>" id="<?php echo $this->id; ?>" <?php $this->link(); ?>>
548
+ <?php
549
+ if( !empty( $this->posts ) ) {
550
+ foreach ( $this->posts as $post ) {
551
+ printf( '<option value="%s" %s>%s</option>',
552
+ $post->ID,
553
+ selected( $this->value(), $post->ID, false ),
554
+ $post->post_title
555
+ );
556
+ }
557
+ }
558
+ ?>
559
+ </select>
560
+ </div>
561
+ <?php
562
+ }
563
+ }
564
+
565
+ /**
566
+ * TinyMCE Custom Control
567
+ *
568
+ * @author Anthony Hortin <http://maddisondesigns.com>
569
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
570
+ * @link https://github.com/maddisondesigns
571
+ */
572
+ class Skyrocket_TinyMCE_Custom_control extends Skyrocket_Custom_Control {
573
+ /**
574
+ * The type of control being rendered
575
+ */
576
+ public $type = 'tinymce_editor';
577
+ /**
578
+ * Enqueue our scripts and styles
579
+ */
580
+ public function enqueue(){
581
+ wp_enqueue_script( 'skyrocket-custom-controls-js', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/js/customizer.js', array( 'jquery', 'jquery-ui-core' ), wc_advanced_shipment_tracking()->version, true );
582
+ wp_enqueue_style( 'skyrocket-custom-controls-css', wc_advanced_shipment_tracking()->plugin_dir_url() . 'assets/css/customizer.css', array(), wc_advanced_shipment_tracking()->version, 'all' );
583
+ wp_enqueue_editor();
584
+ }
585
+ /**
586
+ * Pass our TinyMCE toolbar string to JavaScript
587
+ */
588
+ public function to_json() {
589
+ parent::to_json();
590
+ $this->json['skyrockettinymcetoolbar1'] = isset( $this->input_attrs['toolbar1'] ) ? esc_attr( $this->input_attrs['toolbar1'] ) : 'bold italic bullist numlist alignleft aligncenter alignright link';
591
+ $this->json['skyrockettinymcetoolbar2'] = isset( $this->input_attrs['toolbar2'] ) ? esc_attr( $this->input_attrs['toolbar2'] ) : '';
592
+ $this->json['skyrocketmediabuttons'] = isset( $this->input_attrs['mediaButtons'] ) && ( $this->input_attrs['mediaButtons'] === true ) ? true : false;
593
+ }
594
+ /**
595
+ * Render the control in the customizer
596
+ */
597
+ public function render_content(){
598
+ ?>
599
+ <div class="tinymce-control">
600
+ <span class="customize-control-title"><?php _e( $this->label, 'woo-advanced-shipment-tracking' ); ?></span>
601
+ <?php if( !empty( $this->description ) ) { ?>
602
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
603
+ <?php } ?>
604
+ <textarea id="<?php echo esc_attr( $this->id ); ?>" class="customize-control-tinymce-editor" <?php $this->link(); ?>><?php echo esc_attr( $this->value() ); ?></textarea>
605
+ </div>
606
+ <?php
607
+ }
608
+ }
609
+
610
+ /**
611
+ * Google Font Select Custom Control
612
+ *
613
+ * @author Anthony Hortin <http://maddisondesigns.com>
614
+ * @license http://www.gnu.org/licenses/gpl-2.0.html
615
+ * @link https://github.com/maddisondesigns
616
+ */
617
+ class Skyrocket_Google_Font_Select_Custom_Control extends Skyrocket_Custom_Control {
618
+ /**
619
+ * The type of control being rendered
620
+ */
621
+ public $type = 'google_fonts';
622
+ /**
623
+ * The list of Google Fonts
624
+ */
625
+ private $fontList = false;
626
+ /**
627
+ * The saved font values decoded from json
628
+ */
629
+ private $fontValues = [];
630
+ /**
631
+ * The index of the saved font within the list of Google fonts
632
+ */
633
+ private $fontListIndex = 0;
634
+ /**
635
+ * The number of fonts to display from the json file. Either positive integer or 'all'. Default = 'all'
636
+ */
637
+ private $fontCount = 'all';
638
+ /**
639
+ * The font list sort order. Either 'alpha' or 'popular'. Default = 'alpha'
640
+ */
641
+ private $fontOrderBy = 'alpha';
642
+ /**
643
+ * Get our list of fonts from the json file
644
+ */
645
+ public function __construct( $manager, $id, $args = array(), $options = array() ) {
646
+ parent::__construct( $manager, $id, $args );
647
+ // Get the font sort order
648
+ if ( isset( $this->input_attrs['orderby'] ) && strtolower( $this->input_attrs['orderby'] ) === 'popular' ) {
649
+ $this->fontOrderBy = 'popular';
650
+ }
651
+ // Get the list of Google fonts
652
+ if ( isset( $this->input_attrs['font_count'] ) ) {
653
+ if ( 'all' != strtolower( $this->input_attrs['font_count'] ) ) {
654
+ $this->fontCount = ( abs( (int) $this->input_attrs['font_count'] ) > 0 ? abs( (int) $this->input_attrs['font_count'] ) : 'all' );
655
+ }
656
+ }
657
+ $this->fontList = $this->skyrocket_getGoogleFonts( 'all' );
658
+ // Decode the default json font value
659
+ $this->fontValues = json_decode( $this->value() );
660
+ // Find the index of our default font within our list of Google fonts
661
+ $this->fontListIndex = $this->skyrocket_getFontIndex( $this->fontList, $this->fontValues->font );
662
+ }
663
+ /**
664
+ * Enqueue our scripts and styles
665
+ */
666
+ public function enqueue() {
667
+ wp_enqueue_script( 'skyrocket-select2-js', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js', array( 'jquery' ), '4.0.6', true );
668
+ wp_enqueue_script( 'skyrocket-custom-controls-js', $this->get_skyrocket_resource_url() . 'js/customizer.js', array( 'skyrocket-select2-js' ), '1.0', true );
669
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array(), '1.1', 'all' );
670
+ wp_enqueue_style( 'skyrocket-select2-css', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css', array(), '4.0.6', 'all' );
671
+ }
672
+ /**
673
+ * Export our List of Google Fonts to JavaScript
674
+ */
675
+ public function to_json() {
676
+ parent::to_json();
677
+ $this->json['skyrocketfontslist'] = $this->fontList;
678
+ }
679
+ /**
680
+ * Render the control in the customizer
681
+ */
682
+ public function render_content() {
683
+ $fontCounter = 0;
684
+ $isFontInList = false;
685
+ $fontListStr = '';
686
+
687
+ if( !empty($this->fontList) ) {
688
+ ?>
689
+ <div class="google_fonts_select_control">
690
+ <?php if( !empty( $this->label ) ) { ?>
691
+ <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
692
+ <?php } ?>
693
+ <?php if( !empty( $this->description ) ) { ?>
694
+ <span class="customize-control-description"><?php echo esc_html( $this->description ); ?></span>
695
+ <?php } ?>
696
+ <input type="hidden" id="<?php echo esc_attr( $this->id ); ?>" name="<?php echo esc_attr( $this->id ); ?>" value="<?php echo esc_attr( $this->value() ); ?>" class="customize-control-google-font-selection" <?php $this->link(); ?> />
697
+ <div class="google-fonts">
698
+ <select class="google-fonts-list" control-name="<?php echo esc_attr( $this->id ); ?>">
699
+ <?php
700
+ foreach( $this->fontList as $key => $value ) {
701
+ $fontCounter++;
702
+ $fontListStr .= '<option value="' . $value->family . '" ' . selected( $this->fontValues->font, $value->family, false ) . '>' . $value->family . '</option>';
703
+ if ( $this->fontValues->font === $value->family ) {
704
+ $isFontInList = true;
705
+ }
706
+ if ( is_int( $this->fontCount ) && $fontCounter === $this->fontCount ) {
707
+ break;
708
+ }
709
+ }
710
+ if ( !$isFontInList && $this->fontListIndex ) {
711
+ // If the default or saved font value isn't in the list of displayed fonts, add it to the top of the list as the default font
712
+ $fontListStr = '<option value="' . $this->fontList[$this->fontListIndex]->family . '" ' . selected( $this->fontValues->font, $this->fontList[$this->fontListIndex]->family, false ) . '>' . $this->fontList[$this->fontListIndex]->family . ' (default)</option>' . $fontListStr;
713
+ }
714
+ // Display our list of font options
715
+ echo $fontListStr;
716
+ ?>
717
+ </select>
718
+ </div>
719
+ <div class="customize-control-description">Select weight &amp; style for regular text</div>
720
+ <div class="weight-style">
721
+ <select class="google-fonts-regularweight-style">
722
+ <?php
723
+ foreach( $this->fontList[$this->fontListIndex]->variants as $key => $value ) {
724
+ echo '<option value="' . $value . '" ' . selected( $this->fontValues->regularweight, $value, false ) . '>' . $value . '</option>';
725
+ }
726
+ ?>
727
+ </select>
728
+ </div>
729
+ <div class="customize-control-description">Select weight for <italic>italic text</italic></div>
730
+ <div class="weight-style">
731
+ <select class="google-fonts-italicweight-style" <?php disabled( in_array( 'italic', $this->fontList[$this->fontListIndex]->variants ), false ); ?>>
732
+ <?php
733
+ $optionCount = 0;
734
+ foreach( $this->fontList[$this->fontListIndex]->variants as $key => $value ) {
735
+ // Only add options that are italic
736
+ if( strpos( $value, 'italic' ) !== false ) {
737
+ echo '<option value="' . $value . '" ' . selected( $this->fontValues->italicweight, $value, false ) . '>' . $value . '</option>';
738
+ $optionCount++;
739
+ }
740
+ }
741
+ if( $optionCount == 0 ) {
742
+ echo '<option value="">Not Available for this font</option>';
743
+ }
744
+ ?>
745
+ </select>
746
+ </div>
747
+ <div class="customize-control-description">Select weight for <strong>bold text</strong></div>
748
+ <div class="weight-style">
749
+ <select class="google-fonts-boldweight-style">
750
+ <?php
751
+ $optionCount = 0;
752
+ foreach( $this->fontList[$this->fontListIndex]->variants as $key => $value ) {
753
+ // Only add options that aren't italic
754
+ if( strpos( $value, 'italic' ) === false ) {
755
+ echo '<option value="' . $value . '" ' . selected( $this->fontValues->boldweight, $value, false ) . '>' . $value . '</option>';
756
+ $optionCount++;
757
+ }
758
+ }
759
+ // This should never evaluate as there'll always be at least a 'regular' weight
760
+ if( $optionCount == 0 ) {
761
+ echo '<option value="">Not Available for this font</option>';
762
+ }
763
+ ?>
764
+ </select>
765
+ </div>
766
+ <input type="hidden" class="google-fonts-category" value="<?php echo $this->fontValues->category; ?>">
767
+ </div>
768
+ <?php
769
+ }
770
+ }
771
+
772
+ /**
773
+ * Find the index of the saved font in our multidimensional array of Google Fonts
774
+ */
775
+ public function skyrocket_getFontIndex( $haystack, $needle ) {
776
+ foreach( $haystack as $key => $value ) {
777
+ if( $value->family == $needle ) {
778
+ return $key;
779
+ }
780
+ }
781
+ return false;
782
+ }
783
+
784
+ /**
785
+ * Return the list of Google Fonts from our json file. Unless otherwise specfied, list will be limited to 30 fonts.
786
+ */
787
+ public function skyrocket_getGoogleFonts( $count = 30 ) {
788
+ // Google Fonts json generated from https://www.googleapis.com/webfonts/v1/webfonts?sort=popularity&key=YOUR-API-KEY
789
+ $fontFile = $this->get_skyrocket_resource_url() . 'inc/google-fonts-alphabetical.json';
790
+ if ( $this->fontOrderBy === 'popular' ) {
791
+ $fontFile = $this->get_skyrocket_resource_url() . 'inc/google-fonts-popularity.json';
792
+ }
793
+
794
+ $request = wp_remote_get( $fontFile );
795
+ if( is_wp_error( $request ) ) {
796
+ return "";
797
+ }
798
+
799
+ $body = wp_remote_retrieve_body( $request );
800
+ $content = json_decode( $body );
801
+
802
+ if( $count == 'all' ) {
803
+ return $content->items;
804
+ } else {
805
+ return array_slice( $content->items, 0, $count );
806
+ }
807
+ }
808
+ }
809
+
810
+ /**
811
+ * Alpha Color Picker Custom Control
812
+ *
813
+ * @author Braad Martin <http://braadmartin.com>
814
+ * @license http://www.gnu.org/licenses/gpl-3.0.html
815
+ * @link https://github.com/BraadMartin/components/tree/master/customizer/alpha-color-picker
816
+ */
817
+ class Skyrocket_Customize_Alpha_Color_Control extends Skyrocket_Custom_Control {
818
+ /**
819
+ * The type of control being rendered
820
+ */
821
+ public $type = 'alpha-color';
822
+ /**
823
+ * Add support for palettes to be passed in.
824
+ *
825
+ * Supported palette values are true, false, or an array of RGBa and Hex colors.
826
+ */
827
+ public $palette;
828
+ /**
829
+ * Add support for showing the opacity value on the slider handle.
830
+ */
831
+ public $show_opacity;
832
+ /**
833
+ * Enqueue our scripts and styles
834
+ */
835
+ public function enqueue() {
836
+ wp_enqueue_script( 'skyrocket-custom-controls-js', $this->get_skyrocket_resource_url() . 'js/customizer.js', array( 'jquery', 'wp-color-picker' ), '1.0', true );
837
+ wp_enqueue_style( 'skyrocket-custom-controls-css', $this->get_skyrocket_resource_url() . 'css/customizer.css', array( 'wp-color-picker' ), '1.0', 'all' );
838
+ }
839
+ /**
840
+ * Render the control in the customizer
841
+ */
842
+ public function render_content() {
843
+
844
+ // Process the palette
845
+ if ( is_array( $this->palette ) ) {
846
+ $palette = implode( '|', $this->palette );
847
+ } else {
848
+ // Default to true.
849
+ $palette = ( false === $this->palette || 'false' === $this->palette ) ? 'false' : 'true';
850
+ }
851
+
852
+ // Support passing show_opacity as string or boolean. Default to true.
853
+ $show_opacity = ( false === $this->show_opacity || 'false' === $this->show_opacity ) ? 'false' : 'true';
854
+
855
+ ?>
856
+ <label>
857
+ <?php // Output the label and description if they were passed in.
858
+ if ( isset( $this->label ) && '' !== $this->label ) {
859
+ echo '<span class="customize-control-title">' . sanitize_text_field( $this->label ) . '</span>';
860
+ }
861
+ if ( isset( $this->description ) && '' !== $this->description ) {
862
+ echo '<span class="description customize-control-description">' . sanitize_text_field( $this->description ) . '</span>';
863
+ } ?>
864
+ </label>
865
+ <input class="alpha-color-control" type="text" data-show-opacity="<?php echo $show_opacity; ?>" data-palette="<?php echo esc_attr( $palette ); ?>" data-default-color="<?php echo esc_attr( $this->settings['default']->default ); ?>" <?php $this->link(); ?> />
866
+ <?php
867
+ }
868
+ }
869
+
870
+ /**
871
+ * URL sanitization
872
+ *
873
+ * @param string Input to be sanitized (either a string containing a single url or multiple, separated by commas)
874
+ * @return string Sanitized input
875
+ */
876
+ if ( ! function_exists( 'skyrocket_url_sanitization' ) ) {
877
+ function skyrocket_url_sanitization( $input ) {
878
+ if ( strpos( $input, ',' ) !== false) {
879
+ $input = explode( ',', $input );
880
+ }
881
+ if ( is_array( $input ) ) {
882
+ foreach ($input as $key => $value) {
883
+ $input[$key] = esc_url_raw( $value );
884
+ }
885
+ $input = implode( ',', $input );
886
+ }
887
+ else {
888
+ $input = esc_url_raw( $input );
889
+ }
890
+ return $input;
891
+ }
892
+ }
893
+
894
+ /**
895
+ * Switch sanitization
896
+ *
897
+ * @param string Switch value
898
+ * @return integer Sanitized value
899
+ */
900
+ if ( ! function_exists( 'skyrocket_switch_sanitization' ) ) {
901
+ function skyrocket_switch_sanitization( $input ) {
902
+ if ( true === $input ) {
903
+ return 1;
904
+ } else {
905
+ return 0;
906
+ }
907
+ }
908
+ }
909
+
910
+ /**
911
+ * Radio Button and Select sanitization
912
+ *
913
+ * @param string Radio Button value
914
+ * @return integer Sanitized value
915
+ */
916
+ if ( ! function_exists( 'skyrocket_radio_sanitization' ) ) {
917
+ function skyrocket_radio_sanitization( $input, $setting ) {
918
+ //get the list of possible radio box or select options
919
+ $choices = $setting->manager->get_control( $setting->id )->choices;
920
+
921
+ if ( array_key_exists( $input, $choices ) ) {
922
+ return $input;
923
+ } else {
924
+ return $setting->default;
925
+ }
926
+ }
927
+ }
928
+
929
+ /**
930
+ * Integer sanitization
931
+ *
932
+ * @param string Input value to check
933
+ * @return integer Returned integer value
934
+ */
935
+ if ( ! function_exists( 'skyrocket_sanitize_integer' ) ) {
936
+ function skyrocket_sanitize_integer( $input ) {
937
+ return (int) $input;
938
+ }
939
+ }
940
+
941
+ /**
942
+ * Text sanitization
943
+ *
944
+ * @param string Input to be sanitized (either a string containing a single string or multiple, separated by commas)
945
+ * @return string Sanitized input
946
+ */
947
+ if ( ! function_exists( 'skyrocket_text_sanitization' ) ) {
948
+ function skyrocket_text_sanitization( $input ) {
949
+ if ( strpos( $input, ',' ) !== false) {
950
+ $input = explode( ',', $input );
951
+ }
952
+ if( is_array( $input ) ) {
953
+ foreach ( $input as $key => $value ) {
954
+ $input[$key] = sanitize_text_field( $value );
955
+ }
956
+ $input = implode( ',', $input );
957
+ }
958
+ else {
959
+ $input = sanitize_text_field( $input );
960
+ }
961
+ return $input;
962
+ }
963
+ }
964
+
965
+ /**
966
+ * Array sanitization
967
+ *
968
+ * @param array Input to be sanitized
969
+ * @return array Sanitized input
970
+ */
971
+ if ( ! function_exists( 'skyrocket_array_sanitization' ) ) {
972
+ function skyrocket_array_sanitization( $input ) {
973
+ if( is_array( $input ) ) {
974
+ foreach ( $input as $key => $value ) {
975
+ $input[$key] = sanitize_text_field( $value );
976
+ }
977
+ }
978
+ else {
979
+ $input = '';
980
+ }
981
+ return $input;
982
+ }
983
+ }
984
+
985
+ /**
986
+ * Alpha Color (Hex & RGBa) sanitization
987
+ *
988
+ * @param string Input to be sanitized
989
+ * @return string Sanitized input
990
+ */
991
+ if ( ! function_exists( 'skyrocket_hex_rgba_sanitization' ) ) {
992
+ function skyrocket_hex_rgba_sanitization( $input, $setting ) {
993
+ if ( empty( $input ) || is_array( $input ) ) {
994
+ return $setting->default;
995
+ }
996
+
997
+ if ( false === strpos( $input, 'rgba' ) ) {
998
+ // If string doesn't start with 'rgba' then santize as hex color
999
+ $input = sanitize_hex_color( $input );
1000
+ } else {
1001
+ // Sanitize as RGBa color
1002
+ $input = str_replace( ' ', '', $input );
1003
+ sscanf( $input, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha );
1004
+ $input = 'rgba(' . skyrocket_in_range( $red, 0, 255 ) . ',' . skyrocket_in_range( $green, 0, 255 ) . ',' . skyrocket_in_range( $blue, 0, 255 ) . ',' . skyrocket_in_range( $alpha, 0, 1 ) . ')';
1005
+ }
1006
+ return $input;
1007
+ }
1008
+ }
1009
+
1010
+ /**
1011
+ * Only allow values between a certain minimum & maxmium range
1012
+ *
1013
+ * @param number Input to be sanitized
1014
+ * @return number Sanitized input
1015
+ */
1016
+ if ( ! function_exists( 'skyrocket_in_range' ) ) {
1017
+ function skyrocket_in_range( $input, $min, $max ){
1018
+ if ( $input < $min ) {
1019
+ $input = $min;
1020
+ }
1021
+ if ( $input > $max ) {
1022
+ $input = $max;
1023
+ }
1024
+ return $input;
1025
+ }
1026
+ }
1027
+
1028
+ /**
1029
+ * Google Font sanitization
1030
+ *
1031
+ * @param string JSON string to be sanitized
1032
+ * @return string Sanitized input
1033
+ */
1034
+ if ( ! function_exists( 'skyrocket_google_font_sanitization' ) ) {
1035
+ function skyrocket_google_font_sanitization( $input ) {
1036
+ $val = json_decode( $input, true );
1037
+ if( is_array( $val ) ) {
1038
+ foreach ( $val as $key => $value ) {
1039
+ $val[$key] = sanitize_text_field( $value );
1040
+ }
1041
+ $input = json_encode( $val );
1042
+ }
1043
+ else {
1044
+ $input = json_encode( sanitize_text_field( $val ) );
1045
+ }
1046
+ return $input;
1047
+ }
1048
+ }
1049
+
1050
+ /**
1051
+ * Date Time sanitization
1052
+ *
1053
+ * @param string Date/Time string to be sanitized
1054
+ * @return string Sanitized input
1055
+ */
1056
+ if ( ! function_exists( 'skyrocket_date_time_sanitization' ) ) {
1057
+ function skyrocket_date_time_sanitization( $input, $setting ) {
1058
+ $datetimeformat = 'Y-m-d';
1059
+ if ( $setting->manager->get_control( $setting->id )->include_time ) {
1060
+ $datetimeformat = 'Y-m-d H:i:s';
1061
+ }
1062
+ $date = DateTime::createFromFormat( $datetimeformat, $input );
1063
+ if ( $date === false ) {
1064
+ $date = DateTime::createFromFormat( $datetimeformat, $setting->default );
1065
+ }
1066
+ return $date->format( $datetimeformat );
1067
+ }
1068
+ }
1069
+
1070
+ /**
1071
+ * Slider sanitization
1072
+ *
1073
+ * @param string Slider value to be sanitized
1074
+ * @return string Sanitized input
1075
+ */
1076
+ if ( ! function_exists( 'skyrocket_range_sanitization' ) ) {
1077
+ function skyrocket_range_sanitization( $input, $setting ) {
1078
+ $attrs = $setting->manager->get_control( $setting->id )->input_attrs;
1079
+
1080
+ $min = ( isset( $attrs['min'] ) ? $attrs['min'] : $input );
1081
+ $max = ( isset( $attrs['max'] ) ? $attrs['max'] : $input );
1082
+ $step = ( isset( $attrs['step'] ) ? $attrs['step'] : 1 );
1083
+
1084
+ $number = floor( $input / $attrs['step'] ) * $attrs['step'];
1085
+
1086
+ return skyrocket_in_range( $number, $min, $max );
1087
+ }
1088
+ }
1089
+
1090
+ }
includes/customizer/delivered_preview.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly
3
+ if (!defined('ABSPATH')) {
4
+ exit;
5
+ }
6
+
7
+ ?>
8
+
9
+ <head>
10
+
11
+ <meta charset="<?php bloginfo('charset'); ?>" />
12
+ <meta name="viewport" content="width=device-width" />
13
+ <style type="text/css" id="kadence_woomail_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="kt_woomail_preview_wrapper" style="display: block;">
19
+
20
+ <?php wcast_initialise_customizer_email::preview_delivered_email(); ?>
21
+
22
+ </div>
23
+
24
+ <?php
25
+ do_action( 'woomail_footer' );
26
+ wp_footer(); ?>
27
+
28
+ </body>
29
+
30
+ </html>
includes/customizer/preview.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // Exit if accessed directly
3
+ if (!defined('ABSPATH')) {
4
+ exit;
5
+ }
6
+
7
+ ?>
8
+
9
+ <head>
10
+
11
+ <meta charset="<?php bloginfo('charset'); ?>" />
12
+ <meta name="viewport" content="width=device-width" />
13
+ <style type="text/css" id="kadence_woomail_designer_custom_css">.woocommerce-store-notice.demo_store, .mfp-hide {display: none;}</style>
14
+ </head>
15
+
16
+ <body>
17
+
18
+ <div id="kt_woomail_preview_wrapper" style="display: block;">
19
+
20
+ <?php wcast_initialise_customizer_settings::preview_completed_email(); ?>
21
+
22
+ </div>
23
+
24
+ <?php
25
+ do_action( 'woomail_footer' );
26
+ wp_footer(); ?>
27
+
28
+ </body>
29
+
30
+ </html>
includes/email-manager.php CHANGED
@@ -9,10 +9,10 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
9
  */
10
  public function __construct() {
11
  // template path
12
- if (!defined('AST_TEMPLATE_PATH')) define('AST_TEMPLATE_PATH', SHIPMENT_TRACKING_PATH . '/templates/');
13
  // hook for when order status is changed
14
  // include the email class files
15
- add_filter( 'woocommerce_email_classes', array( $this, 'custom_init_emails' ));
16
  }
17
 
18
  public function custom_init_emails( $emails ) {
@@ -22,61 +22,74 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
22
  if ( ! isset( $emails[ 'WC_Email_Customer_Delivered_Order' ] ) ) {
23
  $emails[ 'WC_Email_Customer_Delivered_Order' ] = include_once( 'emails/class-shipment-delivered-email.php' );
24
  }
25
- }
26
- //echo '<pre>';print_r($emails);echo '</pre>';
27
- return $emails;
28
- }
29
- public function trigger($order_id, $order, $old_status, $new_status){
30
-
31
- global $wpdb;
32
- $shipment_status_email = $wpdb->prefix.'shipment_status_email';
33
- $shipment_status_email_details = $wpdb->get_results( "SELECT * FROM $shipment_status_email WHERE shippment_status = '".$new_status."'" );
34
- foreach($shipment_status_email_details as $details){
35
- $subject = $this->email_subject($details->email_subject);
36
- $email_to = explode(",",$details->email_to);
37
- foreach($email_to as $email){
38
- $recipient = $this->email_to($email,$order,$order_id);
39
-
40
- $email_content = $this->email_content($details->email_content,$order_id, $order);
41
-
42
- $mailer = WC()->mailer();
43
-
44
- $email_heading = $this->email_heading($details->email_heading,$order_id);
45
- //ob_start();
46
- $message = $email_content;
47
- //$message = ob_get_clean();
48
- // create a new email
49
- $email = new WC_Email();
50
-
51
- // wrap the content with the email template and then add styles
52
- $message = apply_filters( 'woocommerce_mail_content', $email->style_inline( $mailer->wrap_message( $email_heading, $message ) ) );
53
- $headers = "Content-Type: text/html\r\n";
54
- add_filter( 'wp_mail_from', array( $this, 'get_from_address' ) );
55
- add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
56
-
57
- wp_mail( $recipient, $subject, $message, $email->get_headers() );
58
- }
59
  }
 
60
  }
 
61
  public function delivered_order_status_email_trigger($order_id, $order){
62
- global $wpdb;
63
- $shipment_status_email = $wpdb->prefix.'woo_shipment_status_email';
64
- $order_status_email_details = $wpdb->get_results( "SELECT * FROM $shipment_status_email WHERE order_status = 'delivered' AND enable=1" );
65
- foreach($order_status_email_details as $details){
66
- $subject = $this->email_subject($details->email_subject);
67
- $email_to = explode(",",$details->email_to);
68
- //echo '<pre>';print_r($email_to);echo '</pre>';exit;
69
  foreach($email_to as $email){
 
 
 
 
 
 
 
 
 
 
 
70
  $recipient = $this->email_to($email,$order,$order_id);
71
 
72
- $email_content = $this->email_content($details->email_content,$order_id, $order);
73
 
74
  $mailer = WC()->mailer();
75
 
76
- $email_heading = $this->email_heading($details->email_heading,$order_id);
77
- //ob_start();
78
  $message = $email_content;
79
- //$message = ob_get_clean();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  // create a new email
81
  $email = new WC_Email();
82
 
@@ -87,15 +100,17 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
87
  add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
88
 
89
  wp_mail( $recipient, $subject, $message, $email->get_headers() );
90
- }
91
- }
92
  }
93
 
94
- public function email_subject($string){
95
- $customer_email = $order->billing_email;
96
- $first_name = $order->billing_first_name;
97
- $last_name = $order->billing_last_name;
98
- $username = $order->get_username;
 
 
 
99
  $string = str_replace( '{order_number}', $order_id, $string );
100
  $string = str_replace( '{customer_email}', $customer_email, $string );
101
  $string = str_replace( '{customer_first_name}', $first_name, $string );
@@ -105,11 +120,14 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
105
  return $string;
106
  }
107
 
108
- public function email_heading($string,$order_id){
109
- $customer_email = $order->billing_email;
110
- $first_name = $order->billing_first_name;
111
- $last_name = $order->billing_last_name;
112
- $username = $order->get_username;
 
 
 
113
  $string = str_replace( '{order_number}', $order_id, $string );
114
  $string = str_replace( '{customer_email}', $customer_email, $string );
115
  $string = str_replace( '{customer_first_name}', $first_name, $string );
@@ -120,31 +138,25 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
120
  }
121
 
122
  public function email_to($string,$order,$order_id){
123
- $customer_email = $order->billing_email;
124
  return str_replace( '{customer_email}', $customer_email, $string );
125
  }
126
 
127
  public function email_content($email_content, $order_id, $order){
128
- $customer_email = $order->billing_email;
129
- $first_name = $order->billing_first_name;
130
- $last_name = $order->billing_last_name;
131
- $username = $order->get_username;
 
 
 
132
  $email_content = str_replace( '{customer_email}', $customer_email, $email_content );
133
  $email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
134
  $email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
135
  $email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
136
  $email_content = str_replace( '{customer_username}', $username, $email_content );
137
  $email_content = str_replace( '{order_number}', $order_id, $email_content );
138
-
139
- $order_details = $this->get_order_details($order_id, $order);
140
- $tracking_details = $this->get_tracking_details($order_id, $order);
141
- $shipping_adress = $this->get_shipping_address($order_id, $order);
142
- $billing_address = $this->get_billing_address($order_id, $order);
143
- $email_content = str_replace( '{order_details}', $order_details, $email_content );
144
- $email_content = str_replace( '{tracking_details}', $tracking_details, $email_content );
145
- $email_content = str_replace( '{shipping_address}', $shipping_adress, $email_content );
146
- $email_content = str_replace( '{billing_address}', $billing_address, $email_content );
147
-
148
  return $email_content;
149
  }
150
 
@@ -174,224 +186,7 @@ class WC_Advanced_Shipment_Tracking_Email_Manager {
174
  public function get_from_address() {
175
  $from_address = apply_filters( 'woocommerce_email_from_address', get_option( 'woocommerce_email_from_address' ), $this );
176
  return sanitize_email( $from_address );
177
- }
178
-
179
- public function get_order_details($order_id, $order){
180
- ob_start(); ?>
181
- <h2>
182
- <?php
183
- $text_align = is_rtl() ? 'right' : 'left';
184
- $sent_to_admin = false;
185
- $plain_text = '';
186
- if ( $sent_to_admin ) {
187
- $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
188
- $after = '</a>';
189
- } else {
190
- $before = '';
191
- $after = '';
192
- }
193
- /* translators: %s: Order ID. */
194
- echo wp_kses_post( $before . sprintf( __( '[Order #%s]', 'woocommerce' ) . $after . ' (<time datetime="%s">%s</time>)', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
195
- ?>
196
- </h2>
197
-
198
- <div style="margin-bottom: 40px;">
199
- <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
200
- <thead>
201
- <tr>
202
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
203
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
204
- <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
205
- </tr>
206
- </thead>
207
- <tbody>
208
- <?php
209
- echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
210
- 'show_sku' => $sent_to_admin,
211
- 'show_image' => true,
212
- 'image_size' => array( 32, 32 ),
213
- 'plain_text' => $plain_text,
214
- 'sent_to_admin' => $sent_to_admin,
215
- ) );
216
- ?>
217
- </tbody>
218
- <tfoot>
219
- <?php
220
- $totals = $order->get_order_item_totals();
221
-
222
- if ( $totals ) {
223
- $i = 0;
224
- foreach ( $totals as $total ) {
225
- $i++;
226
- ?>
227
- <tr>
228
- <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
229
- <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
230
- </tr>
231
- <?php
232
- }
233
- }
234
- if ( $order->get_customer_note() ) {
235
- ?>
236
- <tr>
237
- <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>
238
- <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
239
- </tr>
240
- <?php
241
- }
242
- ?>
243
- </tfoot>
244
- </table>
245
- </div>
246
- <?php return ob_get_clean();
247
- }
248
-
249
- public function get_tracking_details($order_id, $order){
250
- $tracking_items = wc_advanced_shipment_tracking()->get_tracking_items( $order_id, true );
251
-
252
- if ( $tracking_items ){
253
- ob_start();
254
- $table_header_font_size = '';
255
- $table_header_font_color = '';
256
- $table_content_font_size = '';
257
- $table_content_font_color = '';
258
- $email_border_color = '';
259
- $email_border_size = '';
260
- $shipment_tracking_header_text = '';
261
- $email_table_backgroud_color = '';
262
- $tracking_link_font_color = '';
263
- $tracking_link_bg_color = '';
264
- $display_thumbnail = get_option('display_shipment_provider_thumbnail');
265
- if(get_option('email_border_color')){ $email_border_color = get_option('email_border_color'); } else{ $email_border_color = "#e4e4e4"; }
266
- if(get_option('email_border_size')){ $email_border_size = get_option('email_border_size'); } else{ $email_border_size = "1"; }
267
- if(get_option('email_shipment_tracking_header')){ $shipment_tracking_header = get_option('email_shipment_tracking_header'); } else{ $shipment_tracking_header = "Tracking Information"; }
268
- if(get_option('email_shipment_tracking_header_text')){ $shipment_tracking_header_text = get_option('email_shipment_tracking_header_text'); }
269
- $email_table_backgroud_color = get_option('email_table_backgroud_color');
270
-
271
- if(get_option('email_table_header_font_size')){ $table_header_font_size = get_option('email_table_header_font_size'); }
272
- if(get_option('email_table_header_font_color')){ $table_header_font_color = get_option('email_table_header_font_color'); } else{ $table_header_font_color = "#737373"; }
273
-
274
- if(get_option('email_table_content_font_size')){ $table_content_font_size = get_option('email_table_content_font_size'); }
275
-
276
- if(get_option('email_table_content_font_color')){ $table_content_font_color = get_option('email_table_content_font_color'); } else{ $table_content_font_color = "#737373"; }
277
-
278
- if(get_option('email_table_tracking_link_font_color')){ $tracking_link_font_color = get_option('email_table_tracking_link_font_color'); }
279
-
280
- if(get_option('email_table_tracking_link_bg_color')){ $tracking_link_bg_color = get_option('email_table_tracking_link_bg_color'); }
281
-
282
- $th_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
283
-
284
- $td_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
285
-
286
- $tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;";
287
- $remove_date_from_tracking_info = get_option('remove_date_from_tracking_info');
288
-
289
- ?>
290
- <h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
291
- <p><?php echo $shipment_tracking_header_text; ?></p>
292
- <table class="td" cellspacing="0" cellpadding="6" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>" border="1">
293
-
294
- <thead>
295
- <tr>
296
- <th class="tracking-provider" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?></th>
297
- <th class="tracking-number" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?></th>
298
- <?php if($remove_date_from_tracking_info != 1){ ?>
299
- <th class="date-shipped" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Date', 'woocommerce' ); ?></th>
300
- <?php } ?>
301
- <th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>">&nbsp;</th>
302
- </tr>
303
- </thead>
304
-
305
- <tbody><?php
306
- foreach ( $tracking_items as $tracking_item ) {
307
- ?><tr class="tracking">
308
- <td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
309
- <?php
310
- if($display_thumbnail == 1){
311
- global $wpdb;
312
- $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
313
- $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
314
- $custom_thumb_id = $shippment_provider['0']->custom_thumb_id;
315
- //echo $custom_thumb_id;
316
- if($custom_thumb_id == 0){
317
- $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/".sanitize_title($tracking_item['formatted_tracking_provider']).".png";
318
- } else{
319
- $image_attributes = wp_get_attachment_image_src( $custom_thumb_id , array('60','60') );
320
- if($image_attributes[0]){
321
- $src = $image_attributes[0];
322
- } else{
323
- $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/icon-default.png";
324
- }
325
- }
326
- ?>
327
- <img style="width: 50px;" src="<?php echo $src; ?>">
328
- <?php }
329
- echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
330
- </td>
331
- <td class="tracking-number" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
332
- <?php echo esc_html( $tracking_item['tracking_number'] ); ?>
333
- </td>
334
- <?php if($remove_date_from_tracking_info != 1){ ?>
335
- <td class="date-shipped" data-title="<?php _e( 'Status', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
336
- <time datetime="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>" title="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] ); ?></time>
337
- </td>
338
- <?php } ?>
339
- <td class="order-actions" style="<?php echo $td_column_style; ?>">
340
- <?php $url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']); ?>
341
- <a href="<?php echo esc_url( $url ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
342
- </td>
343
- </tr><?php
344
- }
345
- ?></tbody>
346
- </table><br /><br />
347
- <?php
348
- return ob_get_clean();
349
- }
350
- }
351
-
352
- public function get_shipping_address($order_id, $order){
353
- ob_start();
354
- $text_align = is_rtl() ? 'right' : 'left';
355
- $shipping = $order->get_formatted_shipping_address();
356
- ?>
357
- <table id="shipping_addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
358
- <tr>
359
- <?php if ( $shipping ) : ?>
360
- <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
361
- <h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
362
-
363
- <address class="address"><?php echo wp_kses_post( $shipping ); ?></address>
364
- </td>
365
- <?php endif; ?>
366
- </tr>
367
- </table>
368
- <?php return ob_get_clean();
369
- }
370
-
371
- public function get_billing_address($order_id, $order){
372
- ob_start();
373
- $text_align = is_rtl() ? 'right' : 'left';
374
- $address = $order->get_formatted_billing_address();
375
- ?>
376
- <table id="billing_addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
377
- <tr>
378
- <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;" valign="top" width="50%">
379
- <h2><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
380
-
381
- <address class="address">
382
- <?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
383
- <?php if ( $order->get_billing_phone() ) : ?>
384
- <br/><?php echo esc_html( $order->get_billing_phone() ); ?>
385
- <?php endif; ?>
386
- <?php if ( $order->get_billing_email() ) : ?>
387
- <br/><?php echo esc_html( $order->get_billing_email() ); ?>
388
- <?php endif; ?>
389
- </address>
390
- </td>
391
- </tr>
392
- </table>
393
- <?php return ob_get_clean();
394
- }
395
 
396
  }// end of class
397
  new WC_Advanced_Shipment_Tracking_Email_Manager();
9
  */
10
  public function __construct() {
11
  // template path
12
+ if (!defined('AST_TEMPLATE_PATH')) define('AST_TEMPLATE_PATH', SHIPMENT_TRACKING_PATH . '/templates/');
13
  // hook for when order status is changed
14
  // include the email class files
15
+ //add_filter( 'woocommerce_email_classes', array( $this, 'custom_init_emails' ));
16
  }
17
 
18
  public function custom_init_emails( $emails ) {
22
  if ( ! isset( $emails[ 'WC_Email_Customer_Delivered_Order' ] ) ) {
23
  $emails[ 'WC_Email_Customer_Delivered_Order' ] = include_once( 'emails/class-shipment-delivered-email.php' );
24
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
+ return $emails;
27
  }
28
+
29
  public function delivered_order_status_email_trigger($order_id, $order){
30
+ $order_id = $order->get_id();
31
+ $email_subject = get_theme_mod('wcast_delivered_email_subject');
32
+ $subject = $this->email_subject($email_subject,$order_id,$order);
33
+ $email_to = get_theme_mod('wcast_delivered_email_to');
34
+ $email_to = explode(",",$email_to);
35
+
 
36
  foreach($email_to as $email){
37
+
38
+
39
+ $email_heading = get_theme_mod('wcast_delivered_email_heading');
40
+ $email_content = get_theme_mod('wcast_delivered_email_content');
41
+ $wcast_show_tracking_details = get_theme_mod('wcast_show_tracking_details');
42
+ $wcast_show_order_details = get_theme_mod('wcast_show_order_details');
43
+ $wcast_show_address = get_theme_mod('wcast_show_address');
44
+ $sent_to_admin = false;
45
+ $plain_text = false;
46
+
47
+
48
  $recipient = $this->email_to($email,$order,$order_id);
49
 
50
+ $email_content = $this->email_content($email_content,$order_id, $order);
51
 
52
  $mailer = WC()->mailer();
53
 
54
+ $email_heading = $this->email_heading($email_heading,$order_id,$order);
55
+
56
  $message = $email_content;
57
+
58
+ if($wcast_show_tracking_details == 1){
59
+ ob_start();
60
+ wc_get_template( 'emails/tracking-info.php', array(
61
+ 'tracking_items' => wc_advanced_shipment_tracking()->get_tracking_items( $order_id, true )
62
+ ), 'woocommerce-advanced-shipment-tracking/', wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/' );
63
+ $message .= ob_get_clean();
64
+ }
65
+ if($wcast_show_order_details == 1){
66
+
67
+ ob_start();
68
+ wc_get_template(
69
+ 'emails/wcast-email-order-details.php', array(
70
+ 'order' => $order,
71
+ 'sent_to_admin' => $sent_to_admin,
72
+ 'plain_text' => $plain_text,
73
+ 'email' => '',
74
+ ),
75
+ 'woocommerce-advanced-shipment-tracking/',
76
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
77
+ );
78
+ $message .= ob_get_clean();
79
+ }
80
+ if($wcast_show_address == 1){
81
+ ob_start();
82
+ wc_get_template(
83
+ 'emails/wcast-email-addresses.php', array(
84
+ 'order' => $order,
85
+ 'sent_to_admin' => $sent_to_admin,
86
+ ),
87
+ 'woocommerce-advanced-shipment-tracking/',
88
+ wc_advanced_shipment_tracking()->get_plugin_path() . '/templates/'
89
+ );
90
+ $message .= ob_get_clean();
91
+ }
92
+
93
  // create a new email
94
  $email = new WC_Email();
95
 
100
  add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ) );
101
 
102
  wp_mail( $recipient, $subject, $message, $email->get_headers() );
103
+ }
 
104
  }
105
 
106
+ public function email_subject($string,$order_id,$order){
107
+ $customer_email = $order->get_billing_email();
108
+ $first_name = $order->get_billing_first_name();
109
+ $last_name = $order->get_billing_last_name();
110
+ $user = $order->get_user();
111
+ if($user){
112
+ $username = $user->user_login;
113
+ }
114
  $string = str_replace( '{order_number}', $order_id, $string );
115
  $string = str_replace( '{customer_email}', $customer_email, $string );
116
  $string = str_replace( '{customer_first_name}', $first_name, $string );
120
  return $string;
121
  }
122
 
123
+ public function email_heading($string,$order_id,$order){
124
+ $customer_email = $order->get_billing_email();
125
+ $first_name = $order->get_billing_first_name();
126
+ $last_name = $order->get_billing_last_name();
127
+ $user = $order->get_user();
128
+ if($user){
129
+ $username = $user->user_login;
130
+ }
131
  $string = str_replace( '{order_number}', $order_id, $string );
132
  $string = str_replace( '{customer_email}', $customer_email, $string );
133
  $string = str_replace( '{customer_first_name}', $first_name, $string );
138
  }
139
 
140
  public function email_to($string,$order,$order_id){
141
+ $customer_email = $order->get_billing_email();
142
  return str_replace( '{customer_email}', $customer_email, $string );
143
  }
144
 
145
  public function email_content($email_content, $order_id, $order){
146
+ $customer_email = $order->get_billing_email();
147
+ $first_name = $order->get_billing_first_name();
148
+ $last_name = $order->get_billing_last_name();
149
+ $user = $order->get_user();
150
+ if($user){
151
+ $username = $user->user_login;
152
+ }
153
  $email_content = str_replace( '{customer_email}', $customer_email, $email_content );
154
  $email_content = str_replace( '{site_title}', $this->get_blogname(), $email_content );
155
  $email_content = str_replace( '{customer_first_name}', $first_name, $email_content );
156
  $email_content = str_replace( '{customer_last_name}', $last_name, $email_content );
157
  $email_content = str_replace( '{customer_username}', $username, $email_content );
158
  $email_content = str_replace( '{order_number}', $order_id, $email_content );
159
+
 
 
 
 
 
 
 
 
 
160
  return $email_content;
161
  }
162
 
186
  public function get_from_address() {
187
  $from_address = apply_filters( 'woocommerce_email_from_address', get_option( 'woocommerce_email_from_address' ), $this );
188
  return sanitize_email( $from_address );
189
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
 
191
  }// end of class
192
  new WC_Advanced_Shipment_Tracking_Email_Manager();
includes/emails/class-shipment-delivered-email.php CHANGED
@@ -38,7 +38,8 @@ if ( ! class_exists( 'WC_Email_Customer_Delivered_Order', false ) ) :
38
  '{order_date}' => '',
39
  '{order_number}' => '',
40
  );
41
- $this->template_base = CUSTOM_TEMPLATE_PATH;
 
42
  // Triggers for this email.
43
 
44
  // Call parent constructor.
@@ -101,8 +102,7 @@ if ( ! class_exists( 'WC_Email_Customer_Delivered_Order', false ) ) :
101
  */
102
  public function get_content_html() {
103
  $template = $this->get_template( 'template_html' );
104
- $local_file = $this->get_theme_template_file( $template );
105
-
106
  if ( file_exists( $local_file ) && is_writable( $local_file )){
107
  //echo $local_file;exit;
108
  return wc_get_template_html(
38
  '{order_date}' => '',
39
  '{order_number}' => '',
40
  );
41
+ $this->template_base = AST_TEMPLATE_PATH;
42
+ //echo $this->template_base;exit;
43
  // Triggers for this email.
44
 
45
  // Call parent constructor.
102
  */
103
  public function get_content_html() {
104
  $template = $this->get_template( 'template_html' );
105
+ $local_file = $this->get_theme_template_file( $template );
 
106
  if ( file_exists( $local_file ) && is_writable( $local_file )){
107
  //echo $local_file;exit;
108
  return wc_get_template_html(
readme.txt CHANGED
@@ -1,11 +1,11 @@
1
  === Advanced Shipment Tracking for WooCommerce ===
2
  Contributors: zorem
3
  Donate link: https://www.zorem.com
4
- Tags: WooCommerce
5
  Requires at least: 4.0
6
  Requires PHP: 5.2.4
7
- Tested up to: 5.1
8
- Stable tag: 5.1
9
  License: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
@@ -45,11 +45,13 @@ If you want us to add more translations, you can upload the .mo/.po files after
45
  == Compatibility with different email customizer plugin ==
46
 
47
  The plugin is copmatible with different email customizer plugin
48
- 1. [Email Customizer for WooCommerce](https://codecanyon.net/item/email-customizer-for-woocommerce/8654473)
49
- 2. [WP HTML Mail – Email Designer](https://wordpress.org/plugins/wp-html-mail/)
50
- 3. [DecoratorWooCommerce Email Customizer](https://wordpress.org/plugins/decorator-woocommerce-email-customizer/)
 
 
51
 
52
- For more information about compatibility please see this [post](https://www.zorem.com/best-email-customizer-plugin-compatible-with-advanced-shipment-tracking-for-woocommerce/)
53
 
54
  https://youtu.be/g90Glw2jjX4
55
 
@@ -89,6 +91,40 @@ For all REST API functions, [please see our documentation](https://www.zorem.com
89
 
90
  == Changelog ==
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  = 1.9.5 =
93
  * Update design of email notification section for small screen
94
  * Update design of bulk upload section
1
  === Advanced Shipment Tracking for WooCommerce ===
2
  Contributors: zorem
3
  Donate link: https://www.zorem.com
4
+ Tags: woocommerce, delivery, shipping, shipment tracking, tracking, fedex, ups, usps
5
  Requires at least: 4.0
6
  Requires PHP: 5.2.4
7
+ Tested up to: 5.2
8
+ Stable tag: 5.2
9
  License: GPLv2
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
11
 
45
  == Compatibility with different email customizer plugin ==
46
 
47
  The plugin is copmatible with different email customizer plugin
48
+ 1. [Kadence WooCommerce Email Designer](https://wordpress.org/plugins/kadence-woocommerce-email-designer/)
49
+ 2. [Email Customizer for WooCommerce](https://codecanyon.net/item/email-customizer-for-woocommerce/8654473)
50
+ 3. [WP HTML Mail – Email Designer](https://wordpress.org/plugins/wp-html-mail/)
51
+ 4. [Decorator – WooCommerce Email Customizer](https://wordpress.org/plugins/decorator-woocommerce-email-customizer/)
52
+ 5. [WooCommerce Email Customizer with Drag and Drop Email Builder](https://codecanyon.net/item/woocommerce-email-customizer-with-drag-and-drop-email-builder/19849378)
53
 
54
+ For more information about compatibility please see our [documentation](https://www.zorem.com/docs/woocommerce-advanced-shipment-tracking/)
55
 
56
  https://youtu.be/g90Glw2jjX4
57
 
91
 
92
  == Changelog ==
93
 
94
+ = 1.9.7 =
95
+
96
+ * Updated add and edit custom shipping provider design
97
+ * Change shipping provider name from DHL Logistics to DHL Parcel
98
+ * Bug fixed - Sorting companies by country instead of country code
99
+ * Added option to search by country in providers dropdown in order page
100
+ * Remove tracking info to display from processing order,cancel order, refund order and on hold order.
101
+ * Added functionality for customize Delivered order status email into customizer
102
+ * Removed WooCommerce default email fro Delivered order status email
103
+ * Changed URL of StarTrack shipping provider
104
+ * In tracking info display customizer change preview order defaut test from 'Mockup order' to 'Select order to preview'
105
+ * Added functionality for remove white space from tracking number when added in order
106
+
107
+ = 1.9.6.1 =
108
+
109
+ * Bug fixed - Added Save button in settings tab
110
+
111
+ = 1.9.6 =
112
+
113
+ * Updated Email Notifications settings design
114
+ * Updated add custom shipping provider design
115
+ * Fixed issue of Hebrew shipping provider not added in orders
116
+ * Added DHL Logistics Shipping provider as a default shipping provider
117
+ * Fixed bulk upload issue - if shipped date is null than it will take current date
118
+ * Added functionality for add multiple tracked into bulk upload for single order
119
+ * Setup tracking info display customizer with live preview in email
120
+ * Setup funvctionality for show Tracking Info only in completed order
121
+
122
+ = 1.9.5.2 =
123
+ * Added DTDC Shipping provider as a default shipping provider
124
+
125
+ = 1.9.5.1 =
126
+ * Bug Fixed - Fixed email template issue for WooCommerce Delivered order.
127
+
128
  = 1.9.5 =
129
  * Update design of email notification section for small screen
130
  * Update design of bulk upload section
templates/emails/email-order-details.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order details table shown in emails.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
6
+ *
7
+ * HOWEVER, on occasion WooCommerce will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ *
13
+ * @see https://docs.woocommerce.com/document/template-structure/
14
+ * @package WooCommerce/Templates/Emails
15
+ * @version 3.3.1
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit;
20
+ }
21
+
22
+ $text_align = is_rtl() ? 'right' : 'left'; ?>
23
+
24
+ <h2>
25
+ <?php
26
+ if ( $sent_to_admin ) {
27
+ $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
28
+ $after = '</a>';
29
+ } else {
30
+ $before = '';
31
+ $after = '';
32
+ }
33
+ /* translators: %s: Order ID. */
34
+ echo wp_kses_post( $before . sprintf( __( '[Order #%s]', 'woocommerce' ) . $after . ' (<time datetime="%s">%s</time>)', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
35
+ ?>
36
+ </h2>
37
+
38
+ <div style="margin-bottom: 40px;">
39
+ <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
40
+ <thead>
41
+ <tr>
42
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
43
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
44
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <?php
49
+ echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
50
+ 'show_sku' => $sent_to_admin,
51
+ 'show_image' => false,
52
+ 'image_size' => array( 32, 32 ),
53
+ 'plain_text' => $plain_text,
54
+ 'sent_to_admin' => $sent_to_admin,
55
+ ) );
56
+ ?>
57
+ </tbody>
58
+ <tfoot>
59
+ <?php
60
+ $totals = $order->get_order_item_totals();
61
+
62
+ if ( $totals ) {
63
+ $i = 0;
64
+ foreach ( $totals as $total ) {
65
+ $i++;
66
+ ?>
67
+ <tr>
68
+ <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
69
+ <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
70
+ </tr>
71
+ <?php
72
+ }
73
+ }
74
+ if ( $order->get_customer_note() ) {
75
+ ?>
76
+ <tr>
77
+ <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>
78
+ <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
79
+ </tr>
80
+ <?php
81
+ }
82
+ ?>
83
+ </tfoot>
84
+ </table>
85
+ </div>
templates/emails/tracking-info.php CHANGED
@@ -25,44 +25,59 @@ if ( $tracking_items ) :
25
  $email_table_backgroud_color = '';
26
  $tracking_link_font_color = '';
27
  $tracking_link_bg_color = '';
28
-
29
- $display_thumbnail = get_option('display_shipment_provider_thumbnail');
30
- if(get_option('email_border_color')){ $email_border_color = get_option('email_border_color'); } else{ $email_border_color = "#e4e4e4"; }
31
- if(get_option('email_border_size')){ $email_border_size = get_option('email_border_size'); } else{ $email_border_size = "1"; }
32
- if(get_option('email_shipment_tracking_header')){ $shipment_tracking_header = get_option('email_shipment_tracking_header'); } else{ $shipment_tracking_header = "Tracking Information"; }
33
- if(get_option('email_shipment_tracking_header_text')){ $shipment_tracking_header_text = get_option('email_shipment_tracking_header_text'); }
34
- $email_table_backgroud_color = get_option('email_table_backgroud_color');
35
 
36
- if(get_option('email_table_header_font_size')){ $table_header_font_size = get_option('email_table_header_font_size'); }
37
- if(get_option('email_table_header_font_color')){ $table_header_font_color = get_option('email_table_header_font_color'); } else{ $table_header_font_color = "#737373"; }
 
 
38
 
39
- if(get_option('email_table_content_font_size')){ $table_content_font_size = get_option('email_table_content_font_size'); }
40
 
41
- if(get_option('email_table_content_font_color')){ $table_content_font_color = get_option('email_table_content_font_color'); } else{ $table_content_font_color = "#737373"; }
 
 
42
 
43
- if(get_option('email_table_tracking_link_font_color')){ $tracking_link_font_color = get_option('email_table_tracking_link_font_color'); }
 
44
 
45
- if(get_option('email_table_tracking_link_bg_color')){ $tracking_link_bg_color = get_option('email_table_tracking_link_bg_color'); }
 
 
 
 
 
 
46
 
47
  $th_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
48
 
49
- $td_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
50
 
51
  $tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;";
52
 
53
- $remove_date_from_tracking_info = get_option('remove_date_from_tracking_info');
 
 
 
 
 
54
  ?>
55
- <h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
56
- <p><?php echo $shipment_tracking_header_text; ?></p>
57
- <table class="td" cellspacing="0" cellpadding="6" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>" border="1">
58
 
59
  <thead>
60
  <tr>
61
  <th class="tracking-provider" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?></th>
62
  <th class="tracking-number" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?></th>
63
- <?php if($remove_date_from_tracking_info != 1){ ?>
64
- <th class="date-shipped" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Date', 'woocommerce' ); ?></th>
65
- <?php } ?>
 
 
 
 
66
  <th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>">&nbsp;</th>
67
  </tr>
68
  </thead>
@@ -72,7 +87,6 @@ if ( $tracking_items ) :
72
  ?><tr class="tracking">
73
  <td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
74
  <?php
75
- if($display_thumbnail == 1){
76
  global $wpdb;
77
  $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
78
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
@@ -87,20 +101,29 @@ if ( $tracking_items ) :
87
  } else{
88
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/icon-default.png";
89
  }
90
- }
91
- ?>
92
- <img style="width: 50px;" src="<?php echo $src; ?>">
93
- <?php }
 
 
94
  echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
95
  </td>
96
  <td class="tracking-number" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
97
  <?php echo esc_html( $tracking_item['tracking_number'] ); ?>
98
  </td>
99
- <?php if($remove_date_from_tracking_info != 1){ ?>
100
- <td class="date-shipped" data-title="<?php _e( 'Status', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
101
- <time datetime="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>" title="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] ); ?></time>
102
- </td>
103
- <?php } ?>
 
 
 
 
 
 
 
104
  <td class="order-actions" style="<?php echo $td_column_style; ?>">
105
  <?php $url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']); ?>
106
  <a href="<?php echo esc_url( $url ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
25
  $email_table_backgroud_color = '';
26
  $tracking_link_font_color = '';
27
  $tracking_link_bg_color = '';
28
+ $table_content_line_height = '';
29
+ $table_content_font_weight = '';
 
 
 
 
 
30
 
31
+ $display_thumbnail = get_theme_mod('display_shipment_provider_image');
32
+ if(get_theme_mod('table_border_color')){ $email_border_color = get_theme_mod('table_border_color'); } else{ $email_border_color = "#e4e4e4"; }
33
+ if(get_theme_mod('table_border_size')){ $email_border_size = get_theme_mod('table_border_size'); } else{ $email_border_size = "1"; }
34
+ if(get_theme_mod('header_text_change')){ $shipment_tracking_header = get_theme_mod('header_text_change'); } else{ $shipment_tracking_header = "Tracking Information"; }
35
 
36
+ if(get_theme_mod('additional_header_text')){ $shipment_tracking_header_text = get_theme_mod('additional_header_text'); }
37
 
38
+ $email_table_backgroud_color = get_theme_mod('table_bg_color');
39
+ $table_content_line_height = get_theme_mod('table_content_line_height');
40
+ $table_content_font_weight = get_theme_mod('table_content_font_weight');
41
 
42
+ if(get_theme_mod('table_header_font_size')){ $table_header_font_size = get_theme_mod('table_header_font_size'); }
43
+ if(get_theme_mod('table_header_font_color')){ $table_header_font_color = get_theme_mod('table_header_font_color'); } else{ $table_header_font_color = "#737373"; }
44
 
45
+ if(get_theme_mod('table_content_font_size')){ $table_content_font_size = get_theme_mod('table_content_font_size'); }
46
+
47
+ if(get_theme_mod('table_content_font_color')){ $table_content_font_color = get_theme_mod('table_content_font_color'); } else{ $table_content_font_color = "#737373"; }
48
+
49
+ if(get_theme_mod('tracking_link_font_color')){ $tracking_link_font_color = get_theme_mod('tracking_link_font_color'); }
50
+
51
+ if(get_theme_mod('tracking_link_bg_color')){ $tracking_link_bg_color = get_theme_mod('tracking_link_bg_color'); }
52
 
53
  $th_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
54
 
55
+ $td_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
56
 
57
  $tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;";
58
 
59
+ $remove_date_from_tracking_info = get_theme_mod('remove_date_from_tracking');
60
+ if(isset( $_REQUEST['wcast-tracking-preview'] ) && '1' === $_REQUEST['wcast-tracking-preview']){
61
+ $preview = true;
62
+ } else{
63
+ $preview = false;
64
+ }
65
  ?>
66
+ <h2 class="header_text"><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
67
+ <p class="addition_header"><?php echo $shipment_tracking_header_text; ?></p>
68
+ <table class="td tracking_table" cellspacing="0" cellpadding="6" style="width: 100%;border-collapse: collapse;line-height:<?php echo $table_content_line_height; ?>px;background:<?php echo $email_table_backgroud_color; ?>" border="1">
69
 
70
  <thead>
71
  <tr>
72
  <th class="tracking-provider" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?></th>
73
  <th class="tracking-number" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?></th>
74
+ <?php if($preview){ ?>
75
+ <th class="date-shipped <?php if($remove_date_from_tracking_info == 1){ echo 'hide'; } ?>" scope="col" class="td" style="<?php echo $th_column_style; ?>"><?php _e( 'Date', 'woocommerce' ); ?></th>
76
+ <?php } else{
77
+ if($remove_date_from_tracking_info != 1){ ?>
78
+ <th class="date-shipped" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php _e( 'Date', 'woocommerce' ); ?></span></th>
79
+ <?php }
80
+ } ?>
81
  <th class="order-actions" scope="col" class="td" style="<?php echo $th_column_style; ?>">&nbsp;</th>
82
  </tr>
83
  </thead>
87
  ?><tr class="tracking">
88
  <td class="tracking-provider" data-title="<?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
89
  <?php
 
90
  global $wpdb;
91
  $woo_shippment_table_name = wc_advanced_shipment_tracking()->table;
92
  $shippment_provider = $wpdb->get_results( "SELECT * FROM $woo_shippment_table_name WHERE provider_name='".$tracking_item['formatted_tracking_provider']."'" );
101
  } else{
102
  $src = wc_advanced_shipment_tracking()->plugin_dir_url()."assets/shipment-provider-img/icon-default.png";
103
  }
104
+ }
105
+ if($preview){ ?>
106
+ <img style="width: 50px;margin-right: 5px;vertical-align: middle;" class="<?php if($display_thumbnail != 1){ echo 'hide'; } ?>" src="<?php echo $src; ?>">
107
+ <?php } else{
108
+ if($display_thumbnail == 1){ ?>
109
+ <img style="width: 50px;margin-right: 5px;vertical-align: middle;" src="<?php echo $src; ?>"><?php } }
110
  echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
111
  </td>
112
  <td class="tracking-number" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
113
  <?php echo esc_html( $tracking_item['tracking_number'] ); ?>
114
  </td>
115
+ <?php if($preview){ ?>
116
+ <td class="date-shipped <?php if($remove_date_from_tracking_info == 1){ echo 'hide'; } ?>" data-title="<?php _e( 'Status', 'woo-advanced-shipment-tracking' ); ?>" style="<?php echo $td_column_style; ?>">
117
+ <time datetime="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>" title="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] ); ?></time>
118
+ </td>
119
+ <?php } else{
120
+ if($remove_date_from_tracking_info != 1){ ?>
121
+ <td class="date-shipped" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Date', 'woocommerce' ); ?>" style="text-align:left; white-space:nowrap;">
122
+ <time datetime="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>" title="<?php echo date( 'Y-m-d', $tracking_item['date_shipped'] ); ?>"><?php echo date_i18n( get_option( 'date_format' ), $tracking_item['date_shipped'] ); ?></time>
123
+ </td>
124
+ <?php }
125
+ } ?>
126
+
127
  <td class="order-actions" style="<?php echo $td_column_style; ?>">
128
  <?php $url = str_replace('%number%',$tracking_item['tracking_number'],$tracking_item['formatted_tracking_link']); ?>
129
  <a href="<?php echo esc_url( $url ); ?>" style="<?php echo $tracking_link_style; ?>" target="_blank"><?php _e( 'Track', 'woo-advanced-shipment-tracking' ); ?></a>
templates/emails/wcast-email-addresses.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Email Addresses
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-addresses.php.
6
+ *
7
+ * HOWEVER, on occasion WooCommerce will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ *
13
+ * @see https://docs.woocommerce.com/document/template-structure/
14
+ * @package WooCommerce/Templates/Emails
15
+ * @version 3.5.4
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit;
20
+ }
21
+
22
+ $text_align = is_rtl() ? 'right' : 'left';
23
+ $address = $order->get_formatted_billing_address();
24
+ $shipping = $order->get_formatted_shipping_address();
25
+
26
+ ?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top; margin-bottom: 40px; padding:0;" border="0">
27
+ <tr>
28
+ <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; border:0; padding:0;" valign="top" width="50%">
29
+ <h2><?php esc_html_e( 'Billing address', 'woocommerce' ); ?></h2>
30
+
31
+ <address class="address">
32
+ <?php echo wp_kses_post( $address ? $address : esc_html__( 'N/A', 'woocommerce' ) ); ?>
33
+ <?php if ( $order->get_billing_phone() ) : ?>
34
+ <br/><?php echo esc_html( $order->get_billing_phone() ); ?>
35
+ <?php endif; ?>
36
+ <?php if ( $order->get_billing_email() ) : ?>
37
+ <br/><?php echo esc_html( $order->get_billing_email() ); ?>
38
+ <?php endif; ?>
39
+ </address>
40
+ </td>
41
+ <?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && $shipping ) : ?>
42
+ <td style="text-align:<?php echo esc_attr( $text_align ); ?>; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; padding:0;" valign="top" width="50%">
43
+ <h2><?php esc_html_e( 'Shipping address', 'woocommerce' ); ?></h2>
44
+
45
+ <address class="address"><?php echo wp_kses_post( $shipping ); ?></address>
46
+ </td>
47
+ <?php endif; ?>
48
+ </tr>
49
+ </table>
templates/emails/wcast-email-order-details.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order details table shown in emails.
4
+ *
5
+ * This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
6
+ *
7
+ * HOWEVER, on occasion WooCommerce will need to update template files and you
8
+ * (the theme developer) will need to copy the new files to your theme to
9
+ * maintain compatibility. We try to do this as little as possible, but it does
10
+ * happen. When this occurs the version of the template file will be bumped and
11
+ * the readme will list any important changes.
12
+ *
13
+ * @see https://docs.woocommerce.com/document/template-structure/
14
+ * @package WooCommerce/Templates/Emails
15
+ * @version 3.3.1
16
+ */
17
+
18
+ if ( ! defined( 'ABSPATH' ) ) {
19
+ exit;
20
+ }
21
+
22
+ $text_align = is_rtl() ? 'right' : 'left'; ?>
23
+ <br>
24
+ <h2>
25
+ <?php
26
+ if ( $sent_to_admin ) {
27
+ $before = '<a class="link" href="' . esc_url( $order->get_edit_order_url() ) . '">';
28
+ $after = '</a>';
29
+ } else {
30
+ $before = '';
31
+ $after = '';
32
+ }
33
+ /* translators: %s: Order ID. */
34
+ echo wp_kses_post( $before . sprintf( __( '[Order #%s]', 'woocommerce' ) . $after . ' (<time datetime="%s">%s</time>)', $order->get_order_number(), $order->get_date_created()->format( 'c' ), wc_format_datetime( $order->get_date_created() ) ) );
35
+ ?>
36
+ </h2>
37
+
38
+ <div style="margin-bottom: 40px;">
39
+ <table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
40
+ <thead>
41
+ <tr>
42
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>
43
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>
44
+ <th class="td" scope="col" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>
45
+ </tr>
46
+ </thead>
47
+ <tbody>
48
+ <?php
49
+ echo wc_get_email_order_items( $order, array( // WPCS: XSS ok.
50
+ 'show_sku' => $sent_to_admin,
51
+ 'show_image' => false,
52
+ 'image_size' => array( 32, 32 ),
53
+ 'plain_text' => $plain_text,
54
+ 'sent_to_admin' => $sent_to_admin,
55
+ ) );
56
+ ?>
57
+ </tbody>
58
+ <tfoot>
59
+ <?php
60
+ $totals = $order->get_order_item_totals();
61
+
62
+ if ( $totals ) {
63
+ $i = 0;
64
+ foreach ( $totals as $total ) {
65
+ $i++;
66
+ ?>
67
+ <tr>
68
+ <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['label'] ); ?></th>
69
+ <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>; <?php echo ( 1 === $i ) ? 'border-top-width: 4px;' : ''; ?>"><?php echo wp_kses_post( $total['value'] ); ?></td>
70
+ </tr>
71
+ <?php
72
+ }
73
+ }
74
+ if ( $order->get_customer_note() ) {
75
+ ?>
76
+ <tr>
77
+ <th class="td" scope="row" colspan="2" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php esc_html_e( 'Note:', 'woocommerce' ); ?></th>
78
+ <td class="td" style="text-align:<?php echo esc_attr( $text_align ); ?>;"><?php echo wp_kses_post( wptexturize( $order->get_customer_note() ) ); ?></td>
79
+ </tr>
80
+ <?php
81
+ }
82
+ ?>
83
+ </tfoot>
84
+ </table>
85
+ </div>
templates/myaccount/view-order.php CHANGED
@@ -23,33 +23,39 @@ if ( $tracking_items ) :
23
  $shipment_tracking_header_text = '';
24
  $email_table_backgroud_color = '';
25
  $tracking_link_font_color = '';
26
- $tracking_link_bg_color = '';
 
 
27
 
 
 
 
 
28
 
29
- $display_thumbnail = get_option('display_shipment_provider_thumbnail');
30
- if(get_option('email_border_color')){ $email_border_color = get_option('email_border_color'); }
31
- if(get_option('email_border_size')){ $email_border_size = get_option('email_border_size'); }
32
- if(get_option('email_shipment_tracking_header')){ $shipment_tracking_header = get_option('email_shipment_tracking_header'); } else{ $shipment_tracking_header = "Tracking Information"; }
33
- if(get_option('email_shipment_tracking_header_text')){ $shipment_tracking_header_text = get_option('email_shipment_tracking_header_text'); }
34
- $email_table_backgroud_color = get_option('email_table_backgroud_color');
35
 
36
- if(get_option('email_table_header_font_size')){ $table_header_font_size = get_option('email_table_header_font_size'); }
37
- if(get_option('email_table_header_font_color')){ $table_header_font_color = get_option('email_table_header_font_color'); }
 
 
 
 
38
 
39
- if(get_option('email_table_content_font_size')){ $table_content_font_size = get_option('email_table_content_font_size'); }
40
 
41
- if(get_option('email_table_content_font_color')){ $table_content_font_color = get_option('email_table_content_font_color'); }
42
 
43
- if(get_option('email_table_tracking_link_font_color')){ $tracking_link_font_color = get_option('email_table_tracking_link_font_color'); }
44
 
45
- if(get_option('email_table_tracking_link_bg_color')){ $tracking_link_bg_color = get_option('email_table_tracking_link_bg_color'); }
46
 
47
- $th_column_style = "font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color.";";
48
 
49
- $td_column_style = "font-size:".$table_content_font_size."px; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color.";";
50
 
51
- $tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";";
52
- $remove_date_from_tracking_info = get_option('remove_date_from_tracking_info');
 
53
  ?>
54
 
55
  <h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
@@ -60,7 +66,7 @@ if ( $tracking_items ) :
60
  padding-left: 10px;
61
  }
62
  </style>
63
- <table class="shop_table shop_table_responsive my_account_tracking" style="width: 100%;border-collapse: collapse;background:<?php echo $email_table_backgroud_color; ?>">
64
  <thead>
65
  <tr>
66
  <th class="tracking-provider" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?></span></th>
@@ -93,7 +99,7 @@ if ( $tracking_items ) :
93
  }
94
  }
95
  ?>
96
- <img style="width: 50px;" src="<?php echo $src; ?>">
97
  <?php } echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
98
  </td>
99
  <td class="tracking-number" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>">
23
  $shipment_tracking_header_text = '';
24
  $email_table_backgroud_color = '';
25
  $tracking_link_font_color = '';
26
+ $tracking_link_bg_color = '';
27
+ $table_content_line_height = '';
28
+ $table_content_font_weight = '';
29
 
30
+ $display_thumbnail = get_theme_mod('display_shipment_provider_image');
31
+ if(get_theme_mod('table_border_color')){ $email_border_color = get_theme_mod('table_border_color'); } else{ $email_border_color = "#e4e4e4"; }
32
+ if(get_theme_mod('table_border_size')){ $email_border_size = get_theme_mod('table_border_size'); } else{ $email_border_size = "1"; }
33
+ if(get_theme_mod('header_text_change')){ $shipment_tracking_header = get_theme_mod('header_text_change'); } else{ $shipment_tracking_header = "Tracking Information"; }
34
 
35
+ if(get_theme_mod('additional_header_text')){ $shipment_tracking_header_text = get_theme_mod('additional_header_text'); }
 
 
 
 
 
36
 
37
+ $email_table_backgroud_color = get_theme_mod('table_bg_color');
38
+ $table_content_line_height = get_theme_mod('table_content_line_height');
39
+ $table_content_font_weight = get_theme_mod('table_content_font_weight');
40
+
41
+ if(get_theme_mod('table_header_font_size')){ $table_header_font_size = get_theme_mod('table_header_font_size'); }
42
+ if(get_theme_mod('table_header_font_color')){ $table_header_font_color = get_theme_mod('table_header_font_color'); } else{ $table_header_font_color = "#737373"; }
43
 
44
+ if(get_theme_mod('table_content_font_size')){ $table_content_font_size = get_theme_mod('table_content_font_size'); }
45
 
46
+ if(get_theme_mod('table_content_font_color')){ $table_content_font_color = get_theme_mod('table_content_font_color'); } else{ $table_content_font_color = "#737373"; }
47
 
48
+ if(get_theme_mod('tracking_link_font_color')){ $tracking_link_font_color = get_theme_mod('tracking_link_font_color'); }
49
 
50
+ if(get_theme_mod('tracking_link_bg_color')){ $tracking_link_bg_color = get_theme_mod('tracking_link_bg_color'); }
51
 
52
+ $th_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;font-size:".$table_header_font_size."px; color: ".$table_header_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
53
 
54
+ $td_column_style = "text-align: center; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif; font-size:".$table_content_font_size."px;font-weight:".$table_content_font_weight."; color: ".$table_content_font_color." ; border: ".$email_border_size."px solid ".$email_border_color."; padding: 12px;";
55
 
56
+ $tracking_link_style = "color: ".$tracking_link_font_color." ;background:".$tracking_link_bg_color.";padding: 10px;";
57
+
58
+ $remove_date_from_tracking_info = get_theme_mod('remove_date_from_tracking');
59
  ?>
60
 
61
  <h2><?php echo apply_filters( 'woocommerce_shipment_tracking_my_orders_title', __( $shipment_tracking_header, 'woo-advanced-shipment-tracking' ) ); ?></h2>
66
  padding-left: 10px;
67
  }
68
  </style>
69
+ <table class="shop_table shop_table_responsive my_account_tracking" style="width: 100%;border-collapse: collapse;line-height:<?php echo $table_content_line_height; ?>px;background:<?php echo $email_table_backgroud_color; ?>">
70
  <thead>
71
  <tr>
72
  <th class="tracking-provider" style="<?php echo $th_column_style; ?>"><span class="nobr"><?php _e( 'Provider', 'woo-advanced-shipment-tracking' ); ?></span></th>
99
  }
100
  }
101
  ?>
102
+ <img style="width: 50px;margin-right: 5px;vertical-align: middle;" src="<?php echo $src; ?>">
103
  <?php } echo esc_html( $tracking_item['formatted_tracking_provider'] ); ?>
104
  </td>
105
  <td class="tracking-number" style="<?php echo $td_column_style; ?>" data-title="<?php _e( 'Tracking Number', 'woo-advanced-shipment-tracking' ); ?>">
woocommerce-advanced-shipment-tracking.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI: https://www.zorem.com/shop/woocommerce-advanced-shipment-tracking/
6
  * Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
7
- * Version: 1.9.5
8
  * Author: zorem
9
  * Author URI: http://www.zorem.com/
10
  * License: GPL-2.0+
@@ -22,7 +22,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
22
  *
23
  * @var string
24
  */
25
- public $version = '1.9.5';
26
 
27
  /**
28
  * Initialize the main plugin function
@@ -120,8 +120,9 @@ class zorem_woocommerce_advanced_shipment_tracking {
120
  add_action( 'woocommerce_view_order', array( $this, 'show_tracking_info_order' ) );
121
 
122
  add_action( 'wp_ajax_wc_shipment_tracking_delete_item', array( $this, 'meta_box_delete_tracking' ) );
123
- add_action( 'wp_ajax_wc_shipment_tracking_save_form', array( $this, 'save_meta_box_ajax' ) );
124
  add_action( 'woocommerce_email_before_order_table', array( $this, 'email_display' ), 0, 4 );
 
125
 
126
  // Custom tracking column in admin orders list.
127
  add_filter( 'manage_shop_order_posts_columns', array( $this, 'shop_order_columns' ), 99 );
@@ -165,14 +166,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
165
 
166
  }
167
 
168
- public function email_trigger_delivered($order_id, $order = false){
169
- $email_type = get_option('wc_ast_select_email_type');
170
- require_once( 'includes/email-manager.php' );
171
- if($email_type == 'wc_email'){
172
- WC()->mailer()->emails['WC_Email_Customer_Delivered_Order']->trigger( $order_id, $order );
173
- } else{
174
  wc_advanced_shipment_tracking_email_class()->delivered_order_status_email_trigger($order_id, $order);
175
- }
176
  }
177
 
178
  /**
@@ -337,7 +338,16 @@ class zorem_woocommerce_advanced_shipment_tracking {
337
 
338
  return apply_filters( 'woocommerce_shipment_tracking_get_shipment_tracking_column', ob_get_clean(), $order_id, $tracking_items );
339
  }
340
-
 
 
 
 
 
 
 
 
 
341
  /**
342
  * Display shipment info in customer emails.
343
  *
@@ -357,10 +367,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
357
  *
358
  * @see https://github.com/woocommerce/woo-advanced-shipment-tracking/issues/61
359
  */
360
- if ( is_a( $email, 'WC_Email_Customer_Refunded_Order' ) ) {
 
 
 
 
361
  return;
362
  }
363
-
364
  $order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
365
  $tracking_items = $this->get_tracking_items( $order_id, true );
366
 
@@ -368,7 +382,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
368
  wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
369
  } else {
370
  wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
371
- }
372
  }
373
 
374
  /**
@@ -540,13 +554,14 @@ class zorem_woocommerce_advanced_shipment_tracking {
540
  */
541
  public function save_meta_box_ajax() {
542
  check_ajax_referer( 'create-tracking-item', 'security', true );
543
-
 
544
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
545
 
546
  $order_id = wc_clean( $_POST['order_id'] );
547
  $args = array(
548
  'tracking_provider' => $_POST['tracking_provider'],
549
- 'tracking_number' => wc_clean( $_POST['tracking_number'] ),
550
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
551
  );
552
 
@@ -562,12 +577,12 @@ class zorem_woocommerce_advanced_shipment_tracking {
562
  *
563
  * Function for saving tracking items
564
  */
565
- public function save_meta_box( $post_id, $post ) {
566
- //echo '<pre>';print_r($_POST);echo '</pre>';exit;
567
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && strlen( $_POST['tracking_number'] ) > 0 ) {
 
568
  $args = array(
569
  'tracking_provider' => $_POST['tracking_provider'],
570
- 'tracking_number' => wc_clean( $_POST['tracking_number'] ),
571
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
572
  );
573
 
@@ -588,7 +603,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
588
 
589
  $tracking_item = array();
590
 
591
- $tracking_item['tracking_provider'] = wc_clean( $args['tracking_provider'] );
592
  $tracking_item['custom_tracking_provider'] = wc_clean( $args['custom_tracking_provider'] );
593
  $tracking_item['custom_tracking_link'] = wc_clean( $args['custom_tracking_link'] );
594
  $tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
@@ -903,7 +918,12 @@ class zorem_woocommerce_advanced_shipment_tracking {
903
  /*
904
  * include files
905
  */
906
- private function includes(){
 
 
 
 
 
907
  require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking.php';
908
  $this->actions = WC_Advanced_Shipment_Tracking_Actions::get_instance();
909
 
@@ -913,7 +933,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
913
  //cron function
914
  require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-cron.php';
915
  //api call function
916
- require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-api-call.php';
917
 
918
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
919
  if($wc_ast_status_delivered == 1) require_once $this->get_plugin_path() . '/includes/email-manager.php';
@@ -1257,7 +1277,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
1257
  ),
1258
  83 => array (
1259
  "provider_name" => 'StarTrack',
1260
- "provider_url" => 'https://sttrackandtrace.startrack.com.au/%number%',
1261
  "shipping_country" => 'AU',
1262
  "shipping_default" => '1'
1263
  ),
@@ -1272,7 +1292,13 @@ class zorem_woocommerce_advanced_shipment_tracking {
1272
  "provider_url" => 'https://tracking.i-parcel.com/?TrackingNumber=%number%',
1273
  "shipping_country" => 'US',
1274
  "shipping_default" => '1'
1275
- ),
 
 
 
 
 
 
1276
  );
1277
  $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1278
  foreach($updated_providers as $shipping_provider){
@@ -1331,7 +1357,87 @@ class zorem_woocommerce_advanced_shipment_tracking {
1331
 
1332
  $result = $wpdb->update( $woo_shippment_table_name, $data_array, $where_array );
1333
  update_option( 'wc_advanced_shipment_tracking', '1.7');
1334
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1335
  }
1336
  }
1337
 
@@ -1782,7 +1888,7 @@ class zorem_woocommerce_advanced_shipment_tracking {
1782
  ),
1783
  83 => array (
1784
  "provider_name" => 'StarTrack',
1785
- "provider_url" => 'https://sttrackandtrace.startrack.com.au/%number%',
1786
  "shipping_country" => 'AU',
1787
  "shipping_default" => '1'
1788
  ),
@@ -1797,7 +1903,19 @@ class zorem_woocommerce_advanced_shipment_tracking {
1797
  "provider_url" => 'https://tracking.i-parcel.com/?TrackingNumber=%number%',
1798
  "shipping_country" => 'US',
1799
  "shipping_default" => '1'
1800
- ),
 
 
 
 
 
 
 
 
 
 
 
 
1801
  );
1802
  return $providers;
1803
  }
4
  * Plugin Name: Advanced Shipment Tracking for WooCommerce
5
  * Plugin URI: https://www.zorem.com/shop/woocommerce-advanced-shipment-tracking/
6
  * Description: Add shipment tracking information to your WooCommerce orders and provide customers with an easy way to track their orders. Shipment tracking Info will appear in customers accounts (in the order panel) and in WooCommerce order complete email.
7
+ * Version: 1.9.7
8
  * Author: zorem
9
  * Author URI: http://www.zorem.com/
10
  * License: GPL-2.0+
22
  *
23
  * @var string
24
  */
25
+ public $version = '1.9.7';
26
 
27
  /**
28
  * Initialize the main plugin function
120
  add_action( 'woocommerce_view_order', array( $this, 'show_tracking_info_order' ) );
121
 
122
  add_action( 'wp_ajax_wc_shipment_tracking_delete_item', array( $this, 'meta_box_delete_tracking' ) );
123
+ add_action( 'wp_ajax_wc_shipment_tracking_save_form', array( $this, 'save_meta_box_ajax' ) );
124
  add_action( 'woocommerce_email_before_order_table', array( $this, 'email_display' ), 0, 4 );
125
+ add_shortcode( 'woo_mb_tracking_info' , array( $this, 'tracking_info_shortcode'));
126
 
127
  // Custom tracking column in admin orders list.
128
  add_filter( 'manage_shop_order_posts_columns', array( $this, 'shop_order_columns' ), 99 );
166
 
167
  }
168
 
169
+ public function email_trigger_delivered($order_id, $order = false){
170
+
171
+ require_once( 'includes/email-manager.php' );
172
+ $enable_delivered_email = get_theme_mod('wcast_enable_delivered_email');
173
+
174
+ if($enable_delivered_email == 1){
175
  wc_advanced_shipment_tracking_email_class()->delivered_order_status_email_trigger($order_id, $order);
176
+ }
177
  }
178
 
179
  /**
338
 
339
  return apply_filters( 'woocommerce_shipment_tracking_get_shipment_tracking_column', ob_get_clean(), $order_id, $tracking_items );
340
  }
341
+ public function tracking_info_shortcode(){
342
+ ob_start();
343
+ $woo_mb_base = new WC_Email_Base($woo_mb_email_type);
344
+ $order_id = $woo_mb_base->order_id;
345
+ $tracking_items = $this->get_tracking_items( $order_id, true );
346
+ wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
347
+ $html = ob_get_contents();
348
+ ob_end_clean();
349
+ return $html;
350
+ }
351
  /**
352
  * Display shipment info in customer emails.
353
  *
367
  *
368
  * @see https://github.com/woocommerce/woo-advanced-shipment-tracking/issues/61
369
  */
370
+
371
+ //$order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
372
+ //wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
373
+
374
+ if ( is_a( $email, 'WC_Email_Customer_Refunded_Order' ) || is_a( $email, 'WC_Email_Customer_On_Hold_Order' ) || is_a( $email, 'WC_Email_Customer_Processing_Order' )) {
375
  return;
376
  }
377
+
378
  $order_id = is_callable( array( $order, 'get_id' ) ) ? $order->get_id() : $order->id;
379
  $tracking_items = $this->get_tracking_items( $order_id, true );
380
 
382
  wc_get_template( 'emails/plain/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
383
  } else {
384
  wc_get_template( 'emails/tracking-info.php', array( 'tracking_items' => $this->get_tracking_items( $order_id, true ) ), 'woocommerce-advanced-shipment-tracking/', $this->get_plugin_path() . '/templates/' );
385
+ }
386
  }
387
 
388
  /**
554
  */
555
  public function save_meta_box_ajax() {
556
  check_ajax_referer( 'create-tracking-item', 'security', true );
557
+ $tracking_number = str_replace(' ', '', $_POST['tracking_number']);
558
+ //echo '<pre>';print_r($_POST);echo '</pre>';exit;
559
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && isset( $_POST['tracking_provider'] ) && strlen( $_POST['tracking_number'] ) > 0 ) {
560
 
561
  $order_id = wc_clean( $_POST['order_id'] );
562
  $args = array(
563
  'tracking_provider' => $_POST['tracking_provider'],
564
+ 'tracking_number' => wc_clean( $tracking_number ),
565
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
566
  );
567
 
577
  *
578
  * Function for saving tracking items
579
  */
580
+ public function save_meta_box( $post_id, $post ) {
 
581
  if ( isset( $_POST['tracking_number'] ) && $_POST['tracking_provider'] != '' && strlen( $_POST['tracking_number'] ) > 0 ) {
582
+ $tracking_number = str_replace(' ', '', $_POST['tracking_number']);
583
  $args = array(
584
  'tracking_provider' => $_POST['tracking_provider'],
585
+ 'tracking_number' => wc_clean( $tracking_number ),
586
  'date_shipped' => wc_clean( $_POST['date_shipped'] ),
587
  );
588
 
603
 
604
  $tracking_item = array();
605
 
606
+ $tracking_item['tracking_provider'] = $args['tracking_provider'] ;
607
  $tracking_item['custom_tracking_provider'] = wc_clean( $args['custom_tracking_provider'] );
608
  $tracking_item['custom_tracking_link'] = wc_clean( $args['custom_tracking_link'] );
609
  $tracking_item['tracking_number'] = wc_clean( $args['tracking_number'] );
918
  /*
919
  * include files
920
  */
921
+ private function includes(){
922
+
923
+ require_once $this->get_plugin_path() . '/includes/customizer/class-wc-tracking-info-customizer.php';
924
+
925
+ require_once $this->get_plugin_path() . '/includes/customizer/class-wc-email-customizer.php';
926
+
927
  require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking.php';
928
  $this->actions = WC_Advanced_Shipment_Tracking_Actions::get_instance();
929
 
933
  //cron function
934
  require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-cron.php';
935
  //api call function
936
+ require_once $this->get_plugin_path() . '/includes/class-wc-advanced-shipment-tracking-api-call.php';
937
 
938
  $wc_ast_status_delivered = get_option('wc_ast_status_delivered');
939
  if($wc_ast_status_delivered == 1) require_once $this->get_plugin_path() . '/includes/email-manager.php';
1277
  ),
1278
  83 => array (
1279
  "provider_name" => 'StarTrack',
1280
+ "provider_url" => 'https://msto.startrack.com.au/track-trace/?id=%number%',
1281
  "shipping_country" => 'AU',
1282
  "shipping_default" => '1'
1283
  ),
1292
  "provider_url" => 'https://tracking.i-parcel.com/?TrackingNumber=%number%',
1293
  "shipping_country" => 'US',
1294
  "shipping_default" => '1'
1295
+ ),
1296
+ 86 => array (
1297
+ "provider_name" => 'DTDC',
1298
+ "provider_url" => 'http://www.dtdc.in/tracking/tracking_results.asp?Ttype=awb_no&strCnno=%number%&TrkType2=awb_no',
1299
+ "shipping_country" => 'IN',
1300
+ "shipping_default" => '1'
1301
+ ),
1302
  );
1303
  $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1304
  foreach($updated_providers as $shipping_provider){
1357
 
1358
  $result = $wpdb->update( $woo_shippment_table_name, $data_array, $where_array );
1359
  update_option( 'wc_advanced_shipment_tracking', '1.7');
1360
+ }
1361
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'1.8', '>=') ){
1362
+ }
1363
+ else{
1364
+ global $wpdb;
1365
+ $DTDC = array(
1366
+ 86 => array (
1367
+ "provider_name" => 'DTDC',
1368
+ "provider_url" => 'http://www.dtdc.in/tracking/tracking_results.asp?Ttype=awb_no&strCnno=%number%&TrkType2=awb_no',
1369
+ "shipping_country" => 'IN',
1370
+ "shipping_default" => '1'
1371
+ ),
1372
+ );
1373
+ $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1374
+ foreach($DTDC as $shipping_provider){
1375
+ $shipping_provider['provider_name'];
1376
+ $success = $wpdb->insert($woo_shippment_table_name, array(
1377
+ "provider_name" => $shipping_provider['provider_name'],
1378
+ "provider_url" => $shipping_provider['provider_url'],
1379
+ "shipping_country" => $shipping_provider['shipping_country'],
1380
+ "shipping_default" => $shipping_provider['shipping_default'],
1381
+ ));
1382
+ }
1383
+ update_option( 'wc_advanced_shipment_tracking', '1.8');
1384
+ }
1385
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'1.9', '>=') ){
1386
+ }
1387
+ else{
1388
+ global $wpdb;
1389
+ $DTDC = array(
1390
+ 87 => array (
1391
+ "provider_name" => 'DHL Parcel',
1392
+ "provider_url" => 'https://www.logistics.dhl/us-en/home/tracking/tracking-ecommerce.html?tracking-id=%number%',
1393
+ "shipping_country" => 'US',
1394
+ "shipping_default" => '1'
1395
+ ),
1396
+ );
1397
+ $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1398
+ foreach($DTDC as $shipping_provider){
1399
+ $shipping_provider['provider_name'];
1400
+ $success = $wpdb->insert($woo_shippment_table_name, array(
1401
+ "provider_name" => $shipping_provider['provider_name'],
1402
+ "provider_url" => $shipping_provider['provider_url'],
1403
+ "shipping_country" => $shipping_provider['shipping_country'],
1404
+ "shipping_default" => $shipping_provider['shipping_default'],
1405
+ ));
1406
+ }
1407
+ update_option( 'wc_advanced_shipment_tracking', '1.9');
1408
+ }
1409
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'2.0', '>=') ){
1410
+ }
1411
+ else{
1412
+ global $wpdb;
1413
+ $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1414
+
1415
+ $data_array = array(
1416
+ 'provider_name' => 'DHL Parcel',
1417
+ );
1418
+ $where_array = array(
1419
+ 'provider_name' => 'DHL Logistics'
1420
+ );
1421
+
1422
+ $result = $wpdb->update( $woo_shippment_table_name, $data_array, $where_array );
1423
+ update_option( 'wc_advanced_shipment_tracking', '2.0');
1424
+ }
1425
+ if(version_compare(get_option( 'wc_advanced_shipment_tracking' ),'2.1', '>=') ){
1426
+ }
1427
+ else{
1428
+ global $wpdb;
1429
+ $woo_shippment_table_name = $wpdb->prefix . 'woo_shippment_provider';
1430
+
1431
+ $data_array = array(
1432
+ 'provider_url' => 'https://msto.startrack.com.au/track-trace/?id=%number%',
1433
+ );
1434
+ $where_array = array(
1435
+ 'provider_name' => 'StarTrack'
1436
+ );
1437
+
1438
+ $result = $wpdb->update( $woo_shippment_table_name, $data_array, $where_array );
1439
+ update_option( 'wc_advanced_shipment_tracking', '2.1');
1440
+ }
1441
  }
1442
  }
1443
 
1888
  ),
1889
  83 => array (
1890
  "provider_name" => 'StarTrack',
1891
+ "provider_url" => 'https://msto.startrack.com.au/track-trace/?id=%number%',
1892
  "shipping_country" => 'AU',
1893
  "shipping_default" => '1'
1894
  ),
1903
  "provider_url" => 'https://tracking.i-parcel.com/?TrackingNumber=%number%',
1904
  "shipping_country" => 'US',
1905
  "shipping_default" => '1'
1906
+ ),
1907
+ 86 => array (
1908
+ "provider_name" => 'DTDC',
1909
+ "provider_url" => 'http://www.dtdc.in/tracking/tracking_results.asp?Ttype=awb_no&strCnno=%number%&TrkType2=awb_no',
1910
+ "shipping_country" => 'IN',
1911
+ "shipping_default" => '1'
1912
+ ),
1913
+ 87 => array (
1914
+ "provider_name" => 'DHL Parcel',
1915
+ "provider_url" => 'https://www.logistics.dhl/us-en/home/tracking/tracking-ecommerce.html?tracking-id=%number%',
1916
+ "shipping_country" => 'US',
1917
+ "shipping_default" => '1'
1918
+ ),
1919
  );
1920
  return $providers;
1921
  }