Passed
Push — master ( bad3c1...1d1d3a )
by Kiran
12:03 queued 05:36
created
includes/admin/subscriptions.php 3 patches
Switch Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -577,40 +577,40 @@  discard block
 block discarded – undo
577 577
 
578 578
 								switch ( $key ) {
579 579
 
580
-								case 'total':
581
-										echo '<strong>';
582
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
-										echo '</strong>';
584
-									break;
585
-
586
-								case 'relationship':
587
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
-									break;
589
-
590
-								case 'date':
591
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
-									break;
593
-
594
-								case 'status':
595
-										$status = $payment->get_status_nicename();
596
-										if ( is_admin() ) {
597
-										$status = $payment->get_status_label_html();
598
-										}
599
-
600
-										echo wp_kses_post( $status );
601
-									break;
602
-
603
-								case 'invoice':
604
-										if ( ! is_admin() ) {
605
-											$link = $payment->get_view_url();
606
-										} else {
607
-											$link = get_edit_post_link( $payment->get_id() );
608
-										}
609
-
610
-										$invoice = esc_html( $payment->get_number() );
611
-
612
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
613
-									break;
580
+								    case 'total':
581
+										    echo '<strong>';
582
+										    wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
+										    echo '</strong>';
584
+									    break;
585
+
586
+								    case 'relationship':
587
+										    echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
+									    break;
589
+
590
+								    case 'date':
591
+									    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
+									    break;
593
+
594
+								    case 'status':
595
+										    $status = $payment->get_status_nicename();
596
+										    if ( is_admin() ) {
597
+										    $status = $payment->get_status_label_html();
598
+										    }
599
+
600
+										    echo wp_kses_post( $status );
601
+									    break;
602
+
603
+								    case 'invoice':
604
+										    if ( ! is_admin() ) {
605
+											    $link = $payment->get_view_url();
606
+										    } else {
607
+											    $link = get_edit_post_link( $payment->get_id() );
608
+										    }
609
+
610
+										    $invoice = esc_html( $payment->get_number() );
611
+
612
+										    echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
613
+									    break;
614 614
 										}
615 615
 
616 616
 								echo '</td>';
@@ -705,37 +705,37 @@  discard block
 block discarded – undo
705 705
 
706 706
 								switch ( $key ) {
707 707
 
708
-								case 'item_name':
709
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
710
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
708
+								    case 'item_name':
709
+										    $item_name = get_the_title( $subscription_group_item['item_id'] );
710
+										    $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
711 711
 
712
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
713
-										echo esc_html( $item_name );
714
-										} else {
715
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
716
-											}
712
+										    if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
713
+										    echo esc_html( $item_name );
714
+										    } else {
715
+										    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
716
+											    }
717 717
 
718
-									break;
718
+									    break;
719 719
 
720
-								case 'price':
721
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
722
-									break;
720
+								    case 'price':
721
+									    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
722
+									    break;
723 723
 
724
-								case 'tax':
725
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
726
-									break;
724
+								    case 'tax':
725
+									    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
726
+									    break;
727 727
 
728
-								case 'discount':
729
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
730
-									break;
728
+								    case 'discount':
729
+									    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
730
+									    break;
731 731
 
732
-								case 'initial':
733
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
734
-									break;
732
+								    case 'initial':
733
+									    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
734
+									    break;
735 735
 
736
-								case 'recurring':
737
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
738
-									break;
736
+								    case 'recurring':
737
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
738
+									    break;
739 739
 
740 740
 										}
741 741
 
@@ -759,29 +759,29 @@  discard block
 block discarded – undo
759 759
 
760 760
 								switch ( $key ) {
761 761
 
762
-								case 'item_name':
763
-										echo esc_html( $subscription_group_fee['name'] );
764
-									break;
762
+								    case 'item_name':
763
+										    echo esc_html( $subscription_group_fee['name'] );
764
+									    break;
765 765
 
766
-								case 'price':
767
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
768
-									break;
766
+								    case 'price':
767
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
768
+									    break;
769 769
 
770
-								case 'tax':
771
-									echo '&mdash;';
772
-									break;
770
+								    case 'tax':
771
+									    echo '&mdash;';
772
+									    break;
773 773
 
774
-								case 'discount':
775
-										echo '&mdash;';
776
-									break;
774
+								    case 'discount':
775
+										    echo '&mdash;';
776
+									    break;
777 777
 
778
-								case 'initial':
779
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
780
-									break;
778
+								    case 'initial':
779
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
780
+									    break;
781 781
 
782
-								case 'recurring':
783
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
784
-									break;
782
+								    case 'recurring':
783
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
784
+									    break;
785 785
 
786 786
 										}
787 787
 
@@ -886,39 +886,39 @@  discard block
 block discarded – undo
886 886
 
887 887
 								switch ( $key ) {
888 888
 
889
-								case 'status':
890
-										echo wp_kses_post( $_suscription->get_status_label_html() );
891
-									break;
892
-
893
-								case 'item':
894
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
895
-											echo wp_kses_post( implode( ' | ', $markup ) );
896
-									break;
897
-
898
-								case 'renewals':
899
-									$max_bills = $_suscription->get_bill_times();
900
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
901
-									break;
902
-
903
-								case 'renewal_date':
904
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
905
-									break;
906
-
907
-								case 'start_date':
908
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
909
-									break;
910
-
911
-								case 'subscription':
912
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
913
-										printf(
914
-                                            '%1$s#%2$s%3$s',
915
-                                            '<a href="' . esc_url( $url ) . '">',
916
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
917
-											'</a>'
918
-                                        );
919
-
920
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
921
-									break;
889
+								    case 'status':
890
+										    echo wp_kses_post( $_suscription->get_status_label_html() );
891
+									    break;
892
+
893
+								    case 'item':
894
+											    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
895
+											    echo wp_kses_post( implode( ' | ', $markup ) );
896
+									    break;
897
+
898
+								    case 'renewals':
899
+									    $max_bills = $_suscription->get_bill_times();
900
+									    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
901
+									    break;
902
+
903
+								    case 'renewal_date':
904
+										    echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
905
+									    break;
906
+
907
+								    case 'start_date':
908
+										    echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
909
+									    break;
910
+
911
+								    case 'subscription':
912
+										    $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
913
+										    printf(
914
+                                                '%1$s#%2$s%3$s',
915
+                                                '<a href="' . esc_url( $url ) . '">',
916
+                                                '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
917
+											    '</a>'
918
+                                            );
919
+
920
+											    echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
921
+									    break;
922 922
 
923 923
 										}
924 924
 
Please login to merge, or discard this patch.
Indentation   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-				aui()->alert(
28
+                aui()->alert(
29 29
                     array(
30
-						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-					),
33
-					true
30
+                        'type'    => 'danger',
31
+                        'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                    ),
33
+                    true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+                } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
37 37
 
38
-				// Display a single subscription.
39
-				wpinv_recurring_subscription_details();
40
-				} else {
38
+                // Display a single subscription.
39
+                wpinv_recurring_subscription_details();
40
+                } else {
41 41
 
42
-				// Display a list of available subscriptions.
43
-				getpaid_print_subscriptions_list();
44
-				}
42
+                // Display a list of available subscriptions.
43
+                getpaid_print_subscriptions_list();
44
+                }
45 45
 
46
-			?>
46
+            ?>
47 47
 
48 48
 		</div>
49 49
 	</div>
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function getpaid_print_subscriptions_list() {
62 62
 
63
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
64
-	$subscribers_table->prepare_items();
63
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
64
+    $subscribers_table->prepare_items();
65 65
 
66
-	?>
66
+    ?>
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
@@ -82,42 +82,42 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85
-	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
85
+    // Fetch the subscription.
86
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
87
+    if ( ! $sub->exists() ) {
88 88
 
89
-		aui()->alert(
90
-			array(
91
-				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
93
-			),
94
-			true
95
-		);
89
+        aui()->alert(
90
+            array(
91
+                'type'    => 'danger',
92
+                'content' => __( 'Subscription not found.', 'invoicing' ),
93
+            ),
94
+            true
95
+        );
96 96
 
97
-		return;
98
-	}
97
+        return;
98
+    }
99 99
 
100
-	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
+    // Use metaboxes to display the subscription details.
101
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
103 103
 
104
-	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
104
+    $subscription_id     = $sub->get_id();
105
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
-	}
108
+    if ( 1 < count( $subscription_groups ) ) {
109
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
+    }
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
-	}
112
+    if ( ! empty( $subscription_group ) ) {
113
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
+    }
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
119 119
 
120
-	?>
120
+    ?>
121 121
 
122 122
 		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
123 123
 
@@ -157,49 +157,49 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function getpaid_admin_subscription_details_metabox( $sub ) {
159 159
 
160
-	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
-
164
-	// Prepare subscription detail columns.
165
-	$fields = apply_filters(
166
-		'getpaid_subscription_admin_page_fields',
167
-		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
178
-		)
179
-	);
180
-
181
-	if ( ! $sub->is_active() ) {
182
-
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
185
-		}
186
-
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
189
-		}
190
-	} elseif ( $sub->is_last_renewal() ) {
191
-
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
194
-		}
195
-	}
196
-
197
-	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
200
-	}
201
-
202
-	?>
160
+    // Subscription items.
161
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
+
164
+    // Prepare subscription detail columns.
165
+    $fields = apply_filters(
166
+        'getpaid_subscription_admin_page_fields',
167
+        array(
168
+            'subscription' => __( 'Subscription', 'invoicing' ),
169
+            'customer'     => __( 'Customer', 'invoicing' ),
170
+            'amount'       => __( 'Amount', 'invoicing' ),
171
+            'start_date'   => __( 'Start Date', 'invoicing' ),
172
+            'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
+            'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
+            'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
+            'gateway'      => __( 'Payment Method', 'invoicing' ),
176
+            'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
+            'status'       => __( 'Status', 'invoicing' ),
178
+        )
179
+    );
180
+
181
+    if ( ! $sub->is_active() ) {
182
+
183
+        if ( isset( $fields['renews_on'] ) ) {
184
+            unset( $fields['renews_on'] );
185
+        }
186
+
187
+        if ( isset( $fields['gateway'] ) ) {
188
+            unset( $fields['gateway'] );
189
+        }
190
+    } elseif ( $sub->is_last_renewal() ) {
191
+
192
+        if ( isset( $fields['renews_on'] ) ) {
193
+            $fields['renews_on'] = __( 'End Date', 'invoicing' );
194
+        }
195
+    }
196
+
197
+    $profile_id = $sub->get_profile_id();
198
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
+        unset( $fields['profile_id'] );
200
+    }
201
+
202
+    ?>
203 203
 
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+    $username = __( '(Missing User)', 'invoicing' );
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+    $user = get_userdata( $subscription->get_customer_id() );
239
+    if ( $user ) {
240 240
 
241
-		$username = sprintf(
242
-			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
-		);
241
+        $username = sprintf(
242
+            '<a href="user-edit.php?user_id=%s">%s</a>',
243
+            absint( $user->ID ),
244
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
+        );
246 246
 
247
-	}
247
+    }
248 248
 
249
-	echo wp_kses_post( $username );
249
+    echo wp_kses_post( $username );
250 250
 }
251 251
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
252 252
 
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258 258
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
259
+    $amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
+    echo wp_kses_post( "<span>$amount</span>" );
261 261
 }
262 262
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
263 263
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
270 270
 
271
-	printf(
272
-		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
275
-	);
271
+    printf(
272
+        '<a href="%s">#%s</a>',
273
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
+        absint( $subscription->get_id() )
275
+    );
276 276
 
277 277
 }
278 278
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
  */
285 285
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
-		aui()->input(
289
-			array(
290
-				'type'        => 'text',
291
-				'id'          => 'wpinv_subscription_date_created',
292
-				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
294
-				'label_type'  => 'hidden',
295
-				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
-				'no_wrap'     => true,
298
-				'size'        => 'sm',
299
-			),
300
-			true
301
-		);
302
-	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
-	}
287
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
+        aui()->input(
289
+            array(
290
+                'type'        => 'text',
291
+                'id'          => 'wpinv_subscription_date_created',
292
+                'name'        => 'wpinv_subscription_date_created',
293
+                'label'       => __( 'Start Date', 'invoicing' ),
294
+                'label_type'  => 'hidden',
295
+                'placeholder' => 'YYYY-MM-DD',
296
+                'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
+                'no_wrap'     => true,
298
+                'size'        => 'sm',
299
+            ),
300
+            true
301
+        );
302
+    } else {
303
+        echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
+    }
305 305
 
306 306
 }
307 307
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
@@ -313,24 +313,24 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
-		aui()->input(
318
-			array(
319
-				'type'        => 'text',
320
-				'id'          => 'wpinv_subscription_expiration',
321
-				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
323
-				'label_type'  => 'hidden',
324
-				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
-				'no_wrap'     => true,
327
-				'size'        => 'sm',
328
-			),
329
-			true
330
-		);
331
-	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
-	}
316
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
+        aui()->input(
318
+            array(
319
+                'type'        => 'text',
320
+                'id'          => 'wpinv_subscription_expiration',
321
+                'name'        => 'wpinv_subscription_expiration',
322
+                'label'       => __( 'Renews On', 'invoicing' ),
323
+                'label_type'  => 'hidden',
324
+                'placeholder' => 'YYYY-MM-DD',
325
+                'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
+                'no_wrap'     => true,
327
+                'size'        => 'sm',
328
+            ),
329
+            true
330
+        );
331
+    } else {
332
+        echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
+    }
334 334
 }
335 335
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
336 336
 
@@ -341,32 +341,32 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
343 343
 
344
-	$max_bills    = $subscription->get_bill_times();
345
-	$times_billed = (int) $subscription->get_times_billed();
346
-
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
-		aui()->input(
349
-			array(
350
-				'type'             => 'number',
351
-				'id'               => 'wpinv_subscription_max_bill_times',
352
-				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
354
-				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
-				'no_wrap'          => true,
358
-				'size'             => 'sm',
359
-				'input_group_left' => sprintf(
360
-					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
362
-					$times_billed
363
-				),
364
-			),
365
-			true
366
-		);
367
-	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
-	}
344
+    $max_bills    = $subscription->get_bill_times();
345
+    $times_billed = (int) $subscription->get_times_billed();
346
+
347
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
+        aui()->input(
349
+            array(
350
+                'type'             => 'number',
351
+                'id'               => 'wpinv_subscription_max_bill_times',
352
+                'name'             => 'wpinv_subscription_max_bill_times',
353
+                'label'            => __( 'Maximum bill times', 'invoicing' ),
354
+                'label_type'       => 'hidden',
355
+                'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
+                'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
+                'no_wrap'          => true,
358
+                'size'             => 'sm',
359
+                'input_group_left' => sprintf(
360
+                    // translators: %d: Number of times billed
361
+                    __( '%d of', 'invoicing' ),
362
+                    $times_billed
363
+                ),
364
+            ),
365
+            true
366
+        );
367
+    } else {
368
+        echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
+    }
370 370
 }
371 371
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
372 372
 
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
-		return;
384
-	}
381
+    if ( empty( $subscription_group ) ) {
382
+        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
+        return;
384
+    }
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
+    echo wp_kses_post( implode( ' | ', $markup ) );
388 388
 
389 389
 }
390 390
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
398 398
 
399
-	$gateway = $subscription->get_gateway();
399
+    $gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
-	} else {
404
-		echo '&mdash;';
405
-	}
401
+    if ( ! empty( $gateway ) ) {
402
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
+    } else {
404
+        echo '&mdash;';
405
+    }
406 406
 
407 407
 }
408 408
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415 415
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
416
+    echo wp_kses_post( $subscription->get_status_label_html() );
417 417
 }
418 418
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
419 419
 
@@ -424,28 +424,28 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
426 426
 
427
-	$profile_id = $subscription->get_profile_id();
428
-
429
-	aui()->input(
430
-		array(
431
-			'type'              => 'text',
432
-			'id'                => 'wpinv_subscription_profile_id',
433
-			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
435
-			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
438
-			'input_group_right' => '',
439
-			'no_wrap'           => true,
440
-			'size'              => 'sm',
441
-		),
442
-		true
443
-	);
444
-
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
-	}
427
+    $profile_id = $subscription->get_profile_id();
428
+
429
+    aui()->input(
430
+        array(
431
+            'type'              => 'text',
432
+            'id'                => 'wpinv_subscription_profile_id',
433
+            'name'              => 'wpinv_subscription_profile_id',
434
+            'label'             => __( 'Profile Id', 'invoicing' ),
435
+            'label_type'        => 'hidden',
436
+            'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
+            'value'             => esc_attr( $profile_id ),
438
+            'input_group_right' => '',
439
+            'no_wrap'           => true,
440
+            'size'              => 'sm',
441
+        ),
442
+        true
443
+    );
444
+
445
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
+    if ( ! empty( $url ) ) {
447
+        echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
+    }
449 449
 
450 450
 }
451 451
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -456,40 +456,40 @@  discard block
 block discarded – undo
456 456
  * @param WPInv_Subscription $subscription
457 457
  */
458 458
 function getpaid_admin_subscription_update_metabox( $subscription ) {
459
-	global $aui_bs5;
459
+    global $aui_bs5;
460 460
 
461
-	?>
461
+    ?>
462 462
 	<div class="mt-3">
463 463
 		<?php
464
-			aui()->select(
465
-				array(
466
-					'options'   => getpaid_get_subscription_statuses(),
467
-					'name'      => 'subscription_status',
468
-					'id'        => 'subscription_status_update_select',
469
-					'required'  => true,
470
-					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
-					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
475
-				),
476
-				true
477
-			);
478
-		?>
464
+            aui()->select(
465
+                array(
466
+                    'options'   => getpaid_get_subscription_statuses(),
467
+                    'name'      => 'subscription_status',
468
+                    'id'        => 'subscription_status_update_select',
469
+                    'required'  => true,
470
+                    'no_wrap'   => false,
471
+                    'label'     => __( 'Subscription Status', 'invoicing' ),
472
+                    'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
+                    'select2'   => true,
474
+                    'value'     => $subscription->get_status( 'edit' ),
475
+                ),
476
+                true
477
+            );
478
+        ?>
479 479
 
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin:-12px">
481 481
 		<?php
482
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
482
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
483 483
 
484
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
-			$anchor = __( 'Renew Subscription', 'invoicing' );
486
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
484
+            $url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
+            $anchor = __( 'Renew Subscription', 'invoicing' );
486
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
487 487
 
488
-			if ( $subscription->is_active() ) {
489
-				echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
490
-			}
488
+            if ( $subscription->is_active() ) {
489
+                echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
490
+            }
491 491
 
492
-	echo '</div></div>';
492
+    echo '</div></div>';
493 493
 }
494 494
 
495 495
 /**
@@ -500,33 +500,33 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
502 502
 
503
-	$columns = apply_filters(
504
-		'getpaid_subscription_related_invoices_columns',
505
-		array(
506
-			'invoice'      => __( 'Invoice', 'invoicing' ),
507
-			'relationship' => __( 'Relationship', 'invoicing' ),
508
-			'date'         => __( 'Date', 'invoicing' ),
509
-			'status'       => __( 'Status', 'invoicing' ),
510
-			'total'        => __( 'Total', 'invoicing' ),
511
-		),
512
-		$subscription
513
-	);
514
-
515
-	// Prepare the invoices.
516
-	$payments = $subscription->get_child_payments( ! is_admin() );
517
-	$parent   = $subscription->get_parent_invoice();
518
-
519
-	if ( $parent->exists() ) {
520
-		$payments = array_merge( array( $parent ), $payments );
521
-	}
522
-
523
-	$table_class = 'w-100 bg-white';
524
-
525
-	if ( ! is_admin() ) {
526
-		$table_class = 'table table-bordered';
527
-	}
528
-
529
-	?>
503
+    $columns = apply_filters(
504
+        'getpaid_subscription_related_invoices_columns',
505
+        array(
506
+            'invoice'      => __( 'Invoice', 'invoicing' ),
507
+            'relationship' => __( 'Relationship', 'invoicing' ),
508
+            'date'         => __( 'Date', 'invoicing' ),
509
+            'status'       => __( 'Status', 'invoicing' ),
510
+            'total'        => __( 'Total', 'invoicing' ),
511
+        ),
512
+        $subscription
513
+    );
514
+
515
+    // Prepare the invoices.
516
+    $payments = $subscription->get_child_payments( ! is_admin() );
517
+    $parent   = $subscription->get_parent_invoice();
518
+
519
+    if ( $parent->exists() ) {
520
+        $payments = array_merge( array( $parent ), $payments );
521
+    }
522
+
523
+    $table_class = 'w-100 bg-white';
524
+
525
+    if ( ! is_admin() ) {
526
+        $table_class = 'table table-bordered';
527
+    }
528
+
529
+    ?>
530 530
 		<div class="m-0" style="overflow: auto;">
531 531
 
532 532
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 				<thead>
535 535
 					<tr>
536 536
 						<?php
537
-							foreach ( $columns as $key => $label ) {
538
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
539
-							}
540
-						?>
537
+                            foreach ( $columns as $key => $label ) {
538
+                            echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
539
+                            }
540
+                        ?>
541 541
 					</tr>
542 542
 				</thead>
543 543
 
@@ -553,73 +553,73 @@  discard block
 block discarded – undo
553 553
 
554 554
 					<?php
555 555
 
556
-						foreach ( $payments as $payment ) :
556
+                        foreach ( $payments as $payment ) :
557 557
 
558
-						// Ensure that we have an invoice.
559
-						$payment = new WPInv_Invoice( $payment );
558
+                        // Ensure that we have an invoice.
559
+                        $payment = new WPInv_Invoice( $payment );
560 560
 
561
-						// Abort if the invoice is invalid...
562
-						if ( ! $payment->exists() ) {
563
-							continue;
564
-							}
561
+                        // Abort if the invoice is invalid...
562
+                        if ( ! $payment->exists() ) {
563
+                            continue;
564
+                            }
565 565
 
566
-						// ... or belongs to a different subscription.
567
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
568
-							continue;
569
-							}
566
+                        // ... or belongs to a different subscription.
567
+                        if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
568
+                            continue;
569
+                            }
570 570
 
571
-						echo '<tr>';
571
+                        echo '<tr>';
572 572
 
573
-						foreach ( array_keys( $columns ) as $key ) {
573
+                        foreach ( array_keys( $columns ) as $key ) {
574 574
 
575
-							echo "<td class='p-2 text-left'>";
575
+                            echo "<td class='p-2 text-left'>";
576 576
 
577
-								switch ( $key ) {
577
+                                switch ( $key ) {
578 578
 
579
-								case 'total':
580
-										echo '<strong>';
581
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
582
-										echo '</strong>';
583
-									break;
579
+                                case 'total':
580
+                                        echo '<strong>';
581
+                                        wpinv_the_price( $payment->get_total(), $payment->get_currency() );
582
+                                        echo '</strong>';
583
+                                    break;
584 584
 
585
-								case 'relationship':
586
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
587
-									break;
585
+                                case 'relationship':
586
+                                        echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
587
+                                    break;
588 588
 
589
-								case 'date':
590
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
591
-									break;
589
+                                case 'date':
590
+                                    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
591
+                                    break;
592 592
 
593
-								case 'status':
594
-										$status = $payment->get_status_nicename();
595
-										if ( is_admin() ) {
596
-										$status = $payment->get_status_label_html();
597
-										}
593
+                                case 'status':
594
+                                        $status = $payment->get_status_nicename();
595
+                                        if ( is_admin() ) {
596
+                                        $status = $payment->get_status_label_html();
597
+                                        }
598 598
 
599
-										echo wp_kses_post( $status );
600
-									break;
599
+                                        echo wp_kses_post( $status );
600
+                                    break;
601 601
 
602
-								case 'invoice':
603
-										if ( ! is_admin() ) {
604
-											$link = $payment->get_view_url();
605
-										} else {
606
-											$link = get_edit_post_link( $payment->get_id() );
607
-										}
602
+                                case 'invoice':
603
+                                        if ( ! is_admin() ) {
604
+                                            $link = $payment->get_view_url();
605
+                                        } else {
606
+                                            $link = get_edit_post_link( $payment->get_id() );
607
+                                        }
608 608
 
609
-										$invoice = esc_html( $payment->get_number() );
609
+                                        $invoice = esc_html( $payment->get_number() );
610 610
 
611
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
612
-									break;
613
-										}
611
+                                        echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
612
+                                    break;
613
+                                        }
614 614
 
615
-								echo '</td>';
615
+                                echo '</td>';
616 616
 
617
-							}
617
+                            }
618 618
 
619
-						echo '</tr>';
619
+                        echo '</tr>';
620 620
 
621
-						endforeach;
622
-					?>
621
+                        endforeach;
622
+                    ?>
623 623
 
624 624
 				</tbody>
625 625
 
@@ -637,42 +637,42 @@  discard block
 block discarded – undo
637 637
  */
638 638
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
639 639
 
640
-	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
640
+    // Fetch the subscription group.
641
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
-		return;
645
-	}
643
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
+        return;
645
+    }
646 646
 
647
-	// Prepare table columns.
648
-	$columns = apply_filters(
649
-		'getpaid_subscription_item_details_columns',
650
-		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
655
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
657
-		),
658
-		$subscription
659
-	);
647
+    // Prepare table columns.
648
+    $columns = apply_filters(
649
+        'getpaid_subscription_item_details_columns',
650
+        array(
651
+            'item_name' => __( 'Item', 'invoicing' ),
652
+            'price'     => __( 'Price', 'invoicing' ),
653
+            'tax'       => __( 'Tax', 'invoicing' ),
654
+            'discount'  => __( 'Discount', 'invoicing' ),
655
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
656
+            'recurring' => __( 'Subtotal', 'invoicing' ),
657
+        ),
658
+        $subscription
659
+    );
660 660
 
661
-	// Prepare the invoices.
661
+    // Prepare the invoices.
662 662
 
663
-	$invoice = $subscription->get_parent_invoice();
663
+    $invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
667
-	}
665
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
+        unset( $columns['tax'] );
667
+    }
668 668
 
669
-	$table_class = 'w-100 bg-white';
669
+    $table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
672
-		$table_class = 'table table-bordered';
673
-	}
671
+    if ( ! is_admin() ) {
672
+        $table_class = 'table table-bordered';
673
+    }
674 674
 
675
-	?>
675
+    ?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678 678
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
-							}
687
-						?>
684
+                            foreach ( $columns as $key => $label ) {
685
+                            echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
+                            }
687
+                        ?>
688 688
 					</tr>
689 689
 				</thead>
690 690
 
@@ -692,106 +692,106 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+                        foreach ( $subscription_group['items'] as $subscription_group_item ) :
696 696
 
697
-						echo '<tr>';
697
+                        echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+                        foreach ( array_keys( $columns ) as $key ) {
700 700
 
701
-							$class = 'text-left';
701
+                            $class = 'text-left';
702 702
 
703
-							echo "<td class='p-2 text-left'>";
703
+                            echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+                                switch ( $key ) {
706 706
 
707
-								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
707
+                                case 'item_name':
708
+                                        $item_name = get_the_title( $subscription_group_item['item_id'] );
709
+                                        $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
713
-										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
-											}
711
+                                        if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
+                                        echo esc_html( $item_name );
713
+                                        } else {
714
+                                        printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
+                                            }
716 716
 
717
-									break;
717
+                                    break;
718 718
 
719
-								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
-									break;
719
+                                case 'price':
720
+                                    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
+                                    break;
722 722
 
723
-								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
-									break;
723
+                                case 'tax':
724
+                                    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
+                                    break;
726 726
 
727
-								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
-									break;
727
+                                case 'discount':
728
+                                    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
+                                    break;
730 730
 
731
-								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
-									break;
731
+                                case 'initial':
732
+                                    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
+                                    break;
734 734
 
735
-								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
-									break;
735
+                                case 'recurring':
736
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
+                                    break;
738 738
 
739
-										}
739
+                                        }
740 740
 
741
-								echo '</td>';
741
+                                echo '</td>';
742 742
 
743
-							}
743
+                            }
744 744
 
745
-						echo '</tr>';
745
+                        echo '</tr>';
746 746
 
747
-						endforeach;
747
+                        endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+                        foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
750 750
 
751
-						echo '<tr>';
751
+                        echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+                        foreach ( array_keys( $columns ) as $key ) {
754 754
 
755
-							$class = 'text-left';
755
+                            $class = 'text-left';
756 756
 
757
-							echo "<td class='p-2 text-left'>";
757
+                            echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+                                switch ( $key ) {
760 760
 
761
-								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
763
-									break;
761
+                                case 'item_name':
762
+                                        echo esc_html( $subscription_group_fee['name'] );
763
+                                    break;
764 764
 
765
-								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
-									break;
765
+                                case 'price':
766
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
+                                    break;
768 768
 
769
-								case 'tax':
770
-									echo '&mdash;';
771
-									break;
769
+                                case 'tax':
770
+                                    echo '&mdash;';
771
+                                    break;
772 772
 
773
-								case 'discount':
774
-										echo '&mdash;';
775
-									break;
773
+                                case 'discount':
774
+                                        echo '&mdash;';
775
+                                    break;
776 776
 
777
-								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
-									break;
777
+                                case 'initial':
778
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
+                                    break;
780 780
 
781
-								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
-									break;
781
+                                case 'recurring':
782
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
+                                    break;
784 784
 
785
-										}
785
+                                        }
786 786
 
787
-								echo '</td>';
787
+                                echo '</td>';
788 788
 
789
-							}
789
+                            }
790 790
 
791
-						echo '</tr>';
791
+                        echo '</tr>';
792 792
 
793
-						endforeach;
794
-					?>
793
+                        endforeach;
794
+                    ?>
795 795
 
796 796
 				</tbody>
797 797
 
@@ -810,38 +810,38 @@  discard block
 block discarded – undo
810 810
  */
811 811
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
812 812
 
813
-	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
-
816
-	if ( empty( $subscription_groups ) ) {
817
-		return;
818
-	}
819
-
820
-	// Prepare table columns.
821
-	$columns = apply_filters(
822
-		'getpaid_subscription_related_subscriptions_columns',
823
-		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
830
-		),
831
-		$subscription
832
-	);
833
-
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
836
-	}
837
-
838
-	$table_class = 'w-100 bg-white';
839
-
840
-	if ( ! is_admin() ) {
841
-		$table_class = 'table table-bordered';
842
-	}
843
-
844
-	?>
813
+    // Fetch the subscription groups.
814
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
+
816
+    if ( empty( $subscription_groups ) ) {
817
+        return;
818
+    }
819
+
820
+    // Prepare table columns.
821
+    $columns = apply_filters(
822
+        'getpaid_subscription_related_subscriptions_columns',
823
+        array(
824
+            'subscription' => __( 'Subscription', 'invoicing' ),
825
+            'start_date'   => __( 'Start Date', 'invoicing' ),
826
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
+            'renewals'     => __( 'Payments', 'invoicing' ),
828
+            'item'         => __( 'Items', 'invoicing' ),
829
+            'status'       => __( 'Status', 'invoicing' ),
830
+        ),
831
+        $subscription
832
+    );
833
+
834
+    if ( $subscription->get_status() == 'pending' ) {
835
+        unset( $columns['start_date'], $columns['renewal_date'] );
836
+    }
837
+
838
+    $table_class = 'w-100 bg-white';
839
+
840
+    if ( ! is_admin() ) {
841
+        $table_class = 'table table-bordered';
842
+    }
843
+
844
+    ?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847 847
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
-							}
856
-						?>
853
+                            foreach ( $columns as $key => $label ) {
854
+                            echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
+                            }
856
+                        ?>
857 857
 					</tr>
858 858
 				</thead>
859 859
 
@@ -861,74 +861,74 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+                        foreach ( $subscription_groups as $subscription_group ) :
865 865
 
866
-						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
-							continue;
869
-							}
866
+                        // Do not list current subscription.
867
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
+                            continue;
869
+                            }
870 870
 
871
-						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
871
+                        // Ensure the subscription exists.
872
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
873 873
 
874
-						if ( ! $_suscription->exists() ) {
875
-							continue;
876
-							}
874
+                        if ( ! $_suscription->exists() ) {
875
+                            continue;
876
+                            }
877 877
 
878
-						echo '<tr>';
878
+                        echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+                        foreach ( array_keys( $columns ) as $key ) {
881 881
 
882
-							$class = 'text-left';
882
+                            $class = 'text-left';
883 883
 
884
-							echo "<td class='p-2 text-left'>";
884
+                            echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+                                switch ( $key ) {
887 887
 
888
-								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
890
-									break;
888
+                                case 'status':
889
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
890
+                                    break;
891 891
 
892
-								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
895
-									break;
892
+                                case 'item':
893
+                                            $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
+                                            echo wp_kses_post( implode( ' | ', $markup ) );
895
+                                    break;
896 896
 
897
-								case 'renewals':
898
-									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
-									break;
897
+                                case 'renewals':
898
+                                    $max_bills = $_suscription->get_bill_times();
899
+                                    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
+                                    break;
901 901
 
902
-								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
-									break;
902
+                                case 'renewal_date':
903
+                                        echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
+                                    break;
905 905
 
906
-								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
-									break;
906
+                                case 'start_date':
907
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
+                                    break;
909 909
 
910
-								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
-										printf(
910
+                                case 'subscription':
911
+                                        $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
+                                        printf(
913 913
                                             '%1$s#%2$s%3$s',
914 914
                                             '<a href="' . esc_url( $url ) . '">',
915 915
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
916
-											'</a>'
916
+                                            '</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
-									break;
919
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
+                                    break;
921 921
 
922
-										}
922
+                                        }
923 923
 
924
-								echo '</td>';
924
+                                echo '</td>';
925 925
 
926
-							}
926
+                            }
927 927
 
928
-						echo '</tr>';
928
+                        echo '</tr>';
929 929
 
930
-						endforeach;
931
-					?>
930
+                        endforeach;
931
+                    ?>
932 932
 
933 933
 				</tbody>
934 934
 
Please login to merge, or discard this patch.
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 				aui()->alert(
29 29
                     array(
30 30
 						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+						'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 					),
33 33
 					true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+				} elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) {
37 37
 
38 38
 				// Display a single subscription.
39 39
 				wpinv_recurring_subscription_details();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
70
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
70
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
71 71
 		<?php $subscribers_table->display(); ?>
72 72
 	</form>
73 73
 	<?php
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85 85
 	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
86
+	$sub = new WPInv_Subscription((int) $_GET['id']);
87
+	if (!$sub->exists()) {
88 88
 
89 89
 		aui()->alert(
90 90
 			array(
91 91
 				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
+				'content' => __('Subscription not found.', 'invoicing'),
93 93
 			),
94 94
 			true
95 95
 		);
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
102
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
103 103
 
104 104
 	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
106
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+	if (1 < count($subscription_groups)) {
109
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
110 110
 	}
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+	if (!empty($subscription_group)) {
113
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
114 114
 	}
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
119 119
 
120 120
 	?>
121 121
 
122
-		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
122
+		<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>">
123 123
 
124
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
125
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
126
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
124
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
125
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
126
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
127 127
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
128 128
 			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
129 129
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
132 132
 
133 133
 					<div id="postbox-container-1" class="postbox-container">
134
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
134
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
135 135
 					</div>
136 136
 
137 137
 					<div id="postbox-container-2" class="postbox-container">
138
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
139
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
138
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
139
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
140 140
 					</div>
141 141
 
142 142
 				</div>
@@ -155,48 +155,48 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * @param WPInv_Subscription $sub
157 157
  */
158
-function getpaid_admin_subscription_details_metabox( $sub ) {
158
+function getpaid_admin_subscription_details_metabox($sub) {
159 159
 
160 160
 	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
162
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
163 163
 
164 164
 	// Prepare subscription detail columns.
165 165
 	$fields = apply_filters(
166 166
 		'getpaid_subscription_admin_page_fields',
167 167
 		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
168
+			'subscription' => __('Subscription', 'invoicing'),
169
+			'customer'     => __('Customer', 'invoicing'),
170
+			'amount'       => __('Amount', 'invoicing'),
171
+			'start_date'   => __('Start Date', 'invoicing'),
172
+			'renews_on'    => __('Next Payment', 'invoicing'),
173
+			'renewals'     => __('Collected Payments', 'invoicing'),
174
+			'item'         => $items_count > 1 ? __('Items', 'invoicing') : __('Item', 'invoicing'),
175
+			'gateway'      => __('Payment Method', 'invoicing'),
176
+			'profile_id'   => __('Profile ID', 'invoicing'),
177
+			'status'       => __('Status', 'invoicing'),
178 178
 		)
179 179
 	);
180 180
 
181
-	if ( ! $sub->is_active() ) {
181
+	if (!$sub->is_active()) {
182 182
 
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
183
+		if (isset($fields['renews_on'])) {
184
+			unset($fields['renews_on']);
185 185
 		}
186 186
 
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
187
+		if (isset($fields['gateway'])) {
188
+			unset($fields['gateway']);
189 189
 		}
190
-	} elseif ( $sub->is_last_renewal() ) {
190
+	} elseif ($sub->is_last_renewal()) {
191 191
 
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
192
+		if (isset($fields['renews_on'])) {
193
+			$fields['renews_on'] = __('End Date', 'invoicing');
194 194
 		}
195 195
 	}
196 196
 
197 197
 	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
198
+	if (empty($profile_id) && isset($fields['profile_id'])) {
199
+		unset($fields['profile_id']);
200 200
 	}
201 201
 
202 202
 	?>
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
206 206
 
207
-				<?php foreach ( $fields as $key => $label ) : ?>
207
+				<?php foreach ($fields as $key => $label) : ?>
208 208
 
209
-					<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
209
+					<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
210 210
 
211 211
 						<th class="w-25" style="font-weight: 500;">
212
-							<?php echo esc_html( $label ); ?>
212
+							<?php echo esc_html($label); ?>
213 213
 						</th>
214 214
 
215 215
 						<td class="w-75 text-muted">
216
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
216
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
217 217
 						</td>
218 218
 
219 219
 					</tr>
@@ -231,144 +231,144 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @param WPInv_Subscription $subscription
233 233
  */
234
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
234
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+	$username = __('(Missing User)', 'invoicing');
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+	$user = get_userdata($subscription->get_customer_id());
239
+	if ($user) {
240 240
 
241 241
 		$username = sprintf(
242 242
 			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
243
+			absint($user->ID),
244
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
245 245
 		);
246 246
 
247 247
 	}
248 248
 
249
-	echo wp_kses_post( $username );
249
+	echo wp_kses_post($username);
250 250
 }
251
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
251
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
252 252
 
253 253
 /**
254 254
  * Displays the subscription amount.
255 255
  *
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
258
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
259
+	$amount = getpaid_get_formatted_subscription_amount($subscription);
260
+	echo wp_kses_post("<span>$amount</span>");
261 261
 }
262
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
262
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
263 263
 
264 264
 /**
265 265
  * Displays the subscription id.
266 266
  *
267 267
  * @param WPInv_Subscription $subscription
268 268
  */
269
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
269
+function getpaid_admin_subscription_metabox_display_id($subscription) {
270 270
 
271 271
 	printf(
272 272
 		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
273
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
274
+		absint($subscription->get_id())
275 275
 	);
276 276
 
277 277
 }
278
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
278
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
279 279
 
280 280
 /**
281 281
  * Displays the subscription renewal date.
282 282
  *
283 283
  * @param WPInv_Subscription $subscription
284 284
  */
285
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
285
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
287
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
288 288
 		aui()->input(
289 289
 			array(
290 290
 				'type'        => 'text',
291 291
 				'id'          => 'wpinv_subscription_date_created',
292 292
 				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
293
+				'label'       => __('Start Date', 'invoicing'),
294 294
 				'label_type'  => 'hidden',
295 295
 				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
296
+				'value'       => esc_attr($subscription->get_date_created('edit')),
297 297
 				'no_wrap'     => true,
298 298
 				'size'        => 'sm',
299 299
 			),
300 300
 			true
301 301
 		);
302 302
 	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
303
+		echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
304 304
 	}
305 305
 
306 306
 }
307
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
307
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
308 308
 
309 309
 /**
310 310
  * Displays the subscription renewal date.
311 311
  *
312 312
  * @param WPInv_Subscription $subscription
313 313
  */
314
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
314
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
316
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
317 317
 		aui()->input(
318 318
 			array(
319 319
 				'type'        => 'text',
320 320
 				'id'          => 'wpinv_subscription_expiration',
321 321
 				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
322
+				'label'       => __('Renews On', 'invoicing'),
323 323
 				'label_type'  => 'hidden',
324 324
 				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
325
+				'value'       => esc_attr($subscription->get_expiration('edit')),
326 326
 				'no_wrap'     => true,
327 327
 				'size'        => 'sm',
328 328
 			),
329 329
 			true
330 330
 		);
331 331
 	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
332
+		echo esc_html(getpaid_format_date_value($subscription->get_expiration()));
333 333
 	}
334 334
 }
335
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
335
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
336 336
 
337 337
 /**
338 338
  * Displays the subscription renewal count.
339 339
  *
340 340
  * @param WPInv_Subscription $subscription
341 341
  */
342
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
342
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
343 343
 
344 344
 	$max_bills    = $subscription->get_bill_times();
345 345
 	$times_billed = (int) $subscription->get_times_billed();
346 346
 
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
347
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) {
348 348
 		aui()->input(
349 349
 			array(
350 350
 				'type'             => 'number',
351 351
 				'id'               => 'wpinv_subscription_max_bill_times',
352 352
 				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
353
+				'label'            => __('Maximum bill times', 'invoicing'),
354 354
 				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
355
+				'placeholder'      => __('Unlimited', 'invoicing'),
356
+				'value'            => empty($max_bills) ? '' : (int) $max_bills,
357 357
 				'no_wrap'          => true,
358 358
 				'size'             => 'sm',
359 359
 				'input_group_left' => sprintf(
360 360
 					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
361
+					__('%d of', 'invoicing'),
362 362
 					$times_billed
363 363
 				),
364 364
 			),
365 365
 			true
366 366
 		);
367 367
 	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
368
+		echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
369 369
 	}
370 370
 }
371
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
371
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
372 372
 
373 373
 /**
374 374
  * Displays the subscription item.
@@ -376,53 +376,53 @@  discard block
 block discarded – undo
376 376
  * @param WPInv_Subscription $subscription
377 377
  * @param false|array $subscription_group
378 378
  */
379
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
379
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
381
+	if (empty($subscription_group)) {
382
+		echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
383 383
 		return;
384 384
 	}
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
387
+	echo wp_kses_post(implode(' | ', $markup));
388 388
 
389 389
 }
390
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
390
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
391 391
 
392 392
 /**
393 393
  * Displays the subscription gateway.
394 394
  *
395 395
  * @param WPInv_Subscription $subscription
396 396
  */
397
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
397
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
398 398
 
399 399
 	$gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
401
+	if (!empty($gateway)) {
402
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
403 403
 	} else {
404 404
 		echo '&mdash;';
405 405
 	}
406 406
 
407 407
 }
408
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
408
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
409 409
 
410 410
 /**
411 411
  * Displays the subscription status.
412 412
  *
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
415
+function getpaid_admin_subscription_metabox_display_status($subscription) {
416
+	echo wp_kses_post($subscription->get_status_label_html());
417 417
 }
418
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
418
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
419 419
 
420 420
 /**
421 421
  * Displays the subscription profile id.
422 422
  *
423 423
  * @param WPInv_Subscription $subscription
424 424
  */
425
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
425
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
426 426
 
427 427
 	$profile_id = $subscription->get_profile_id();
428 428
 
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 			'type'              => 'text',
432 432
 			'id'                => 'wpinv_subscription_profile_id',
433 433
 			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
434
+			'label'             => __('Profile Id', 'invoicing'),
435 435
 			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
436
+			'placeholder'       => __('Profile Id', 'invoicing'),
437
+			'value'             => esc_attr($profile_id),
438 438
 			'input_group_right' => '',
439 439
 			'no_wrap'           => true,
440 440
 			'size'              => 'sm',
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 		true
443 443
 	);
444 444
 
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
445
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
446
+	if (!empty($url)) {
447
+		echo '&nbsp;<a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448 448
 	}
449 449
 
450 450
 }
451
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
451
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
452 452
 
453 453
 /**
454 454
  * Displays the subscriptions update metabox.
455 455
  *
456 456
  * @param WPInv_Subscription $subscription
457 457
  */
458
-function getpaid_admin_subscription_update_metabox( $subscription ) {
458
+function getpaid_admin_subscription_update_metabox($subscription) {
459 459
 	global $aui_bs5;
460 460
 
461 461
 	?>
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 					'id'        => 'subscription_status_update_select',
469 469
 					'required'  => true,
470 470
 					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
471
+					'label'     => __('Subscription Status', 'invoicing'),
472
+					'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'),
473 473
 					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
474
+					'value'     => $subscription->get_status('edit'),
475 475
 				),
476 476
 				true
477 477
 			);
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin:-12px">
481 481
 		<?php
482
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
482
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
483 483
 
484
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
-			$anchor = __( 'Renew Subscription', 'invoicing' );
486
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
484
+			$url    = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce');
485
+			$anchor = __('Renew Subscription', 'invoicing');
486
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
487 487
 
488
-			if ( $subscription->is_active() ) {
489
-				echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
488
+			if ($subscription->is_active()) {
489
+				echo "<a href='" . esc_url($url) . "' class='" . ($aui_bs5 ? 'float-end' : 'float-right') . " button button-secondary' onclick='return confirm(\"" . esc_attr($title) . "\")' title='" . esc_attr__('Renew subscription manually', 'invoicing') . "'>" . esc_html($anchor) . "</a>";
490 490
 			}
491 491
 
492 492
 	echo '</div></div>';
@@ -498,44 +498,44 @@  discard block
 block discarded – undo
498 498
  * @param WPInv_Subscription $subscription
499 499
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
500 500
  */
501
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
501
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
502 502
 
503 503
 	$columns = apply_filters(
504 504
 		'getpaid_subscription_related_invoices_columns',
505 505
 		array(
506
-			'invoice'      => __( 'Invoice', 'invoicing' ),
507
-			'relationship' => __( 'Relationship', 'invoicing' ),
508
-			'date'         => __( 'Date', 'invoicing' ),
509
-			'status'       => __( 'Status', 'invoicing' ),
510
-			'total'        => __( 'Total', 'invoicing' ),
506
+			'invoice'      => __('Invoice', 'invoicing'),
507
+			'relationship' => __('Relationship', 'invoicing'),
508
+			'date'         => __('Date', 'invoicing'),
509
+			'status'       => __('Status', 'invoicing'),
510
+			'total'        => __('Total', 'invoicing'),
511 511
 		),
512 512
 		$subscription
513 513
 	);
514 514
 
515 515
 	// Prepare the invoices.
516
-	$payments = $subscription->get_child_payments( ! is_admin() );
516
+	$payments = $subscription->get_child_payments(!is_admin());
517 517
 	$parent   = $subscription->get_parent_invoice();
518 518
 
519
-	if ( $parent->exists() ) {
520
-		$payments = array_merge( array( $parent ), $payments );
519
+	if ($parent->exists()) {
520
+		$payments = array_merge(array($parent), $payments);
521 521
 	}
522 522
 
523 523
 	$table_class = 'w-100 bg-white';
524 524
 
525
-	if ( ! is_admin() ) {
525
+	if (!is_admin()) {
526 526
 		$table_class = 'table table-bordered';
527 527
 	}
528 528
 
529 529
 	?>
530 530
 		<div class="m-0" style="overflow: auto;">
531 531
 
532
-			<table class="<?php echo esc_attr( $table_class ); ?>">
532
+			<table class="<?php echo esc_attr($table_class); ?>">
533 533
 
534 534
 				<thead>
535 535
 					<tr>
536 536
 						<?php
537
-							foreach ( $columns as $key => $label ) {
538
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
537
+							foreach ($columns as $key => $label) {
538
+							echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
539 539
 							}
540 540
 						?>
541 541
 					</tr>
@@ -543,72 +543,72 @@  discard block
 block discarded – undo
543 543
 
544 544
 				<tbody>
545 545
 
546
-					<?php if ( empty( $payments ) ) : ?>
546
+					<?php if (empty($payments)) : ?>
547 547
 						<tr>
548
-							<td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted">
549
-								<?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?>
548
+							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
549
+								<?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?>
550 550
 							</td>
551 551
 						</tr>
552 552
 					<?php endif; ?>
553 553
 
554 554
 					<?php
555 555
 
556
-						foreach ( $payments as $payment ) :
556
+						foreach ($payments as $payment) :
557 557
 
558 558
 						// Ensure that we have an invoice.
559
-						$payment = new WPInv_Invoice( $payment );
559
+						$payment = new WPInv_Invoice($payment);
560 560
 
561 561
 						// Abort if the invoice is invalid...
562
-						if ( ! $payment->exists() ) {
562
+						if (!$payment->exists()) {
563 563
 							continue;
564 564
 							}
565 565
 
566 566
 						// ... or belongs to a different subscription.
567
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
567
+						if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
568 568
 							continue;
569 569
 							}
570 570
 
571 571
 						echo '<tr>';
572 572
 
573
-						foreach ( array_keys( $columns ) as $key ) {
573
+						foreach (array_keys($columns) as $key) {
574 574
 
575 575
 							echo "<td class='p-2 text-left'>";
576 576
 
577
-								switch ( $key ) {
577
+								switch ($key) {
578 578
 
579 579
 								case 'total':
580 580
 										echo '<strong>';
581
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
581
+										wpinv_the_price($payment->get_total(), $payment->get_currency());
582 582
 										echo '</strong>';
583 583
 									break;
584 584
 
585 585
 								case 'relationship':
586
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
586
+										echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing');
587 587
 									break;
588 588
 
589 589
 								case 'date':
590
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
590
+									echo esc_html(getpaid_format_date_value($payment->get_date_created()));
591 591
 									break;
592 592
 
593 593
 								case 'status':
594 594
 										$status = $payment->get_status_nicename();
595
-										if ( is_admin() ) {
595
+										if (is_admin()) {
596 596
 										$status = $payment->get_status_label_html();
597 597
 										}
598 598
 
599
-										echo wp_kses_post( $status );
599
+										echo wp_kses_post($status);
600 600
 									break;
601 601
 
602 602
 								case 'invoice':
603
-										if ( ! is_admin() ) {
603
+										if (!is_admin()) {
604 604
 											$link = $payment->get_view_url();
605 605
 										} else {
606
-											$link = get_edit_post_link( $payment->get_id() );
606
+											$link = get_edit_post_link($payment->get_id());
607 607
 										}
608 608
 
609
-										$invoice = esc_html( $payment->get_number() );
609
+										$invoice = esc_html($payment->get_number());
610 610
 
611
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
611
+										echo wp_kses_post("<a href='" . ($link ? esc_url($link) : '#') . "'>$invoice</a>");
612 612
 									break;
613 613
 										}
614 614
 
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
  *
636 636
  * @param WPInv_Subscription $subscription
637 637
  */
638
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
638
+function getpaid_admin_subscription_item_details_metabox($subscription) {
639 639
 
640 640
 	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
641
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
643
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
644 644
 		return;
645 645
 	}
646 646
 
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
 	$columns = apply_filters(
649 649
 		'getpaid_subscription_item_details_columns',
650 650
 		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
651
+			'item_name' => __('Item', 'invoicing'),
652
+			'price'     => __('Price', 'invoicing'),
653
+			'tax'       => __('Tax', 'invoicing'),
654
+			'discount'  => __('Discount', 'invoicing'),
655 655
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
656
+			'recurring' => __('Subtotal', 'invoicing'),
657 657
 		),
658 658
 		$subscription
659 659
 	);
@@ -662,27 +662,27 @@  discard block
 block discarded – undo
662 662
 
663 663
 	$invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
665
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
666
+		unset($columns['tax']);
667 667
 	}
668 668
 
669 669
 	$table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
671
+	if (!is_admin()) {
672 672
 		$table_class = 'table table-bordered';
673 673
 	}
674 674
 
675 675
 	?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678
-			<table class="<?php echo esc_attr( $table_class ); ?>">
678
+			<table class="<?php echo esc_attr($table_class); ?>">
679 679
 
680 680
 				<thead>
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
684
+							foreach ($columns as $key => $label) {
685
+							echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
686 686
 							}
687 687
 						?>
688 688
 					</tr>
@@ -692,48 +692,48 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+						foreach ($subscription_group['items'] as $subscription_group_item) :
696 696
 
697 697
 						echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+						foreach (array_keys($columns) as $key) {
700 700
 
701 701
 							$class = 'text-left';
702 702
 
703 703
 							echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+								switch ($key) {
706 706
 
707 707
 								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
708
+										$item_name = get_the_title($subscription_group_item['item_id']);
709
+										$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
711
+										if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
712
+										echo esc_html($item_name);
713 713
 										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
714
+										printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
715 715
 											}
716 716
 
717 717
 									break;
718 718
 
719 719
 								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
720
+									wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency());
721 721
 									break;
722 722
 
723 723
 								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
724
+									wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency());
725 725
 									break;
726 726
 
727 727
 								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
728
+									wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency());
729 729
 									break;
730 730
 
731 731
 								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
732
+									wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
733 733
 									break;
734 734
 
735 735
 								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
736
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>');
737 737
 									break;
738 738
 
739 739
 										}
@@ -746,24 +746,24 @@  discard block
 block discarded – undo
746 746
 
747 747
 						endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
750 750
 
751 751
 						echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+						foreach (array_keys($columns) as $key) {
754 754
 
755 755
 							$class = 'text-left';
756 756
 
757 757
 							echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+								switch ($key) {
760 760
 
761 761
 								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
762
+										echo esc_html($subscription_group_fee['name']);
763 763
 									break;
764 764
 
765 765
 								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
766
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
767 767
 									break;
768 768
 
769 769
 								case 'tax':
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 									break;
776 776
 
777 777
 								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
778
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
779 779
 									break;
780 780
 
781 781
 								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
782
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>');
783 783
 									break;
784 784
 
785 785
 										}
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
  * @param WPInv_Subscription $subscription
809 809
  * @param bool $skip_current
810 810
  */
811
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
811
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
812 812
 
813 813
 	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
814
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
815 815
 
816
-	if ( empty( $subscription_groups ) ) {
816
+	if (empty($subscription_groups)) {
817 817
 		return;
818 818
 	}
819 819
 
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 	$columns = apply_filters(
822 822
 		'getpaid_subscription_related_subscriptions_columns',
823 823
 		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
824
+			'subscription' => __('Subscription', 'invoicing'),
825
+			'start_date'   => __('Start Date', 'invoicing'),
826
+			'renewal_date' => __('Next Payment', 'invoicing'),
827
+			'renewals'     => __('Payments', 'invoicing'),
828
+			'item'         => __('Items', 'invoicing'),
829
+			'status'       => __('Status', 'invoicing'),
830 830
 		),
831 831
 		$subscription
832 832
 	);
833 833
 
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
834
+	if ($subscription->get_status() == 'pending') {
835
+		unset($columns['start_date'], $columns['renewal_date']);
836 836
 	}
837 837
 
838 838
 	$table_class = 'w-100 bg-white';
839 839
 
840
-	if ( ! is_admin() ) {
840
+	if (!is_admin()) {
841 841
 		$table_class = 'table table-bordered';
842 842
 	}
843 843
 
844 844
 	?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847
-			<table class="<?php echo esc_attr( $table_class ); ?>">
847
+			<table class="<?php echo esc_attr($table_class); ?>">
848 848
 
849 849
 				<thead>
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
853
+							foreach ($columns as $key => $label) {
854
+							echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
855 855
 							}
856 856
 						?>
857 857
 					</tr>
@@ -861,62 +861,62 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+						foreach ($subscription_groups as $subscription_group) :
865 865
 
866 866
 						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
867
+						if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
868 868
 							continue;
869 869
 							}
870 870
 
871 871
 						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
872
+						$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
873 873
 
874
-						if ( ! $_suscription->exists() ) {
874
+						if (!$_suscription->exists()) {
875 875
 							continue;
876 876
 							}
877 877
 
878 878
 						echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+						foreach (array_keys($columns) as $key) {
881 881
 
882 882
 							$class = 'text-left';
883 883
 
884 884
 							echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+								switch ($key) {
887 887
 
888 888
 								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
889
+										echo wp_kses_post($_suscription->get_status_label_html());
890 890
 									break;
891 891
 
892 892
 								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
893
+											$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
894
+											echo wp_kses_post(implode(' | ', $markup));
895 895
 									break;
896 896
 
897 897
 								case 'renewals':
898 898
 									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
899
+									echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
900 900
 									break;
901 901
 
902 902
 								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
903
+										echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '&mdash;';
904 904
 									break;
905 905
 
906 906
 								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
907
+										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html(getpaid_format_date_value($_suscription->get_date_created()));
908 908
 									break;
909 909
 
910 910
 								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
911
+										$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
912 912
 										printf(
913 913
                                             '%1$s#%2$s%3$s',
914
-                                            '<a href="' . esc_url( $url ) . '">',
915
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
914
+                                            '<a href="' . esc_url($url) . '">',
915
+                                            '<strong>' . intval($_suscription->get_id()) . '</strong>',
916 916
 											'</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
919
+											echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription));
920 920
 									break;
921 921
 
922 922
 										}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 2 patches
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 }
9 9
 
10 10
 if ( ! class_exists( 'WP_List_Table' ) ) {
11
-	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
11
+    include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12 12
 }
13 13
 
14 14
 /**
@@ -16,471 +16,471 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class WPInv_Subscriptions_List_Table extends WP_List_Table {
18 18
 
19
-	/**
20
-	 * URL of this page
21
-	 *
22
-	 * @var   string
23
-	 * @since 1.0.19
24
-	 */
25
-	public $base_url;
26
-
27
-	/**
28
-	 * Query
29
-	 *
30
-	 * @var   GetPaid_Subscriptions_Query
31
-	 * @since 1.0.19
32
-	 */
33
-	public $query;
34
-
35
-	/**
36
-	 * Total subscriptions
37
-	 *
38
-	 * @var   string
39
-	 * @since 1.0.0
40
-	 */
41
-	public $total_count;
42
-
43
-	/**
44
-	 * Current status subscriptions
45
-	 *
46
-	 * @var   string
47
-	 * @since 1.0.0
48
-	 */
49
-	public $current_total_count;
50
-
51
-	/**
52
-	 * Status counts
53
-	 *
54
-	 * @var   array
55
-	 * @since 1.0.19
56
-	 */
57
-	public $status_counts;
58
-
59
-	/**
60
-	 * Number of results to show per page
61
-	 *
62
-	 * @var   int
63
-	 * @since 1.0.0
64
-	 */
65
-	public $per_page = 10;
66
-
67
-	/**
68
-	 *  Constructor function.
69
-	 */
70
-	public function __construct() {
71
-
72
-		parent::__construct(
73
-			array(
74
-				'singular' => 'subscription',
75
-				'plural'   => 'subscriptions',
76
-			)
77
-		);
78
-
79
-		$this->process_bulk_action();
80
-
81
-		$this->prepare_query();
82
-
83
-		$this->base_url = remove_query_arg( 'status' );
84
-
85
-	}
86
-
87
-	/**
88
-	 *  Prepares the display query
89
-	 */
90
-	public function prepare_query() {
91
-
92
-		// Prepare query args.
93
-		$query = array(
94
-			'number'      => $this->per_page,
95
-			'paged'       => $this->get_paged(),
96
-			'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
-			'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
-			'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
99
-			'customer_in' => $this->get_user_in(),
100
-		);
101
-
102
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
103
-			$this->total_count         = 0;
104
-			$this->current_total_count = 0;
105
-			$this->items               = array();
106
-			$this->status_counts       = array();
107
-			return;
108
-		}
109
-
110
-		// Prepare class properties.
111
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
112
-		$this->total_count         = $this->query->get_total();
113
-		$this->current_total_count = $this->query->get_total();
114
-		$this->items               = $this->query->get_results();
115
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
116
-
117
-		if ( 'all' != $query['status'] ) {
118
-			unset( $query['status'] );
119
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
120
-		}
121
-
122
-	}
123
-
124
-	/**
125
-	 * Get user in.
126
-	 *
127
-	 */
128
-	public function get_user_in() {
129
-
130
-		// Abort if no user.
131
-		if ( empty( $_GET['s'] ) ) {
132
-			return null;
133
-		}
134
-
135
-		// Or invalid user.
136
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
137
-
138
-		if ( empty( $user ) ) {
139
-			return null;
140
-		}
141
-
142
-		// Search matching users.
143
-		$user  = '*' . $user . '*';
144
-		$users = new WP_User_Query(
145
-			array(
146
-				'fields'      => 'ID',
147
-				'search'      => $user,
148
-				'count_total' => false,
149
-			)
150
-		);
151
-
152
-		return $users->get_results();
153
-	}
154
-
155
-	/**
156
-	 * Gets the list of views available on this table.
157
-	 *
158
-	 * The format is an associative array:
159
-	 * - `'id' => 'link'`
160
-	 *
161
-	 * @since 1.0.0
162
-	 *
163
-	 * @return array
164
-	 */
165
-	public function get_views() {
166
-
167
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
168
-		$views    = array(
169
-
170
-			'all' => sprintf(
171
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
173
-				$current === 'all' ? ' class="current"' : '',
174
-				__( 'All', 'invoicing' ),
175
-				$this->total_count
176
-			),
177
-
178
-		);
179
-
180
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
181
-
182
-			$views[ $status ] = sprintf(
183
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
185
-				$current === $status ? ' class="current"' : '',
186
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
187
-				$count
188
-			);
189
-
190
-		}
191
-
192
-		return $views;
193
-
194
-	}
195
-
196
-	/**
197
-	 * Render most columns
198
-	 *
199
-	 * @access      private
200
-	 * @since       1.0.0
201
-	 * @return      string
202
-	 */
203
-	public function column_default( $item, $column_name ) {
204
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
205
-	}
206
-
207
-	/**
208
-	 * This is how checkbox column renders.
209
-	 *
210
-	 * @param WPInv_Subscription $item
211
-	 * @return string
212
-	 */
213
-	public function column_cb( $item ) {
214
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
215
-	}
216
-
217
-	/**
218
-	 * Status column
219
-	 *
220
-	 * @param WPInv_Subscription $item
221
-	 * @since       1.0.0
222
-	 * @return      string
223
-	 */
224
-	public function column_status( $item ) {
225
-		return $item->get_status_label_html();
226
-	}
227
-
228
-	/**
229
-	 * Subscription column
230
-	 *
231
-	 * @param WPInv_Subscription $item
232
-	 * @since       1.0.0
233
-	 * @return      string
234
-	 */
235
-	public function column_subscription( $item ) {
236
-
237
-		$username = __( '(Missing User)', 'invoicing' );
238
-
239
-		$user = get_userdata( $item->get_customer_id() );
240
-		$capabilities = wpinv_current_user_can_manage_invoicing();
241
-
242
-		if ( $user ) {
243
-			$username = sprintf(
244
-				'<a href="user-edit.php?user_id=%s">%s</a>',
245
-				absint( $user->ID ),
246
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
247
-			);
248
-		}
249
-
250
-		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251
-		$column_content = sprintf(
252
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>',
255
-			'</a>',
256
-			$username
257
-		);
258
-
259
-		$row_actions = array();
260
-
261
-		// View subscription.
262
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
264
-
265
-		// View invoice.
266
-		$invoice = get_post( $item->get_parent_invoice_id() );
267
-
268
-		if ( ! empty( $invoice ) ) {
269
-			$invoice_url            = get_edit_post_link( $invoice );
270
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
271
-		}
272
-
273
-		$delete_url            = esc_url(
274
-			wp_nonce_url(
275
-				add_query_arg(
276
-					array(
277
-						'getpaid-admin-action' => 'subscription_manual_delete',
278
-						'id'                   => $item->get_id(),
279
-					)
280
-				),
281
-				'getpaid-nonce',
282
-				'getpaid-nonce'
283
-			)
284
-		);
285
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
286
-
287
-		if ( ! $capabilities ) {
288
-			$row_actions = array();
289
-		}
290
-
291
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
292
-
293
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
294
-	}
295
-
296
-	/**
297
-	 * Renewal date column
298
-	 *
299
-	 * @param WPInv_Subscription $item
300
-	 * @since       1.0.0
301
-	 * @return      string
302
-	 */
303
-	public function column_renewal_date( $item ) {
304
-		return getpaid_format_date_value( $item->get_expiration() );
305
-	}
306
-
307
-	/**
308
-	 * Start date column
309
-	 *
310
-	 * @param WPInv_Subscription $item
311
-	 * @since       1.0.0
312
-	 * @return      string
313
-	 */
314
-	public function column_start_date( $item ) {
315
-
316
-		$gateway = $item->get_parent_invoice()->get_gateway_title();
317
-
318
-		if ( empty( $gateway ) ) {
319
-			return getpaid_format_date_value( $item->get_date_created() );
320
-		}
321
-
322
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
-		if ( ! empty( $url ) ) {
324
-
325
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
-				__( 'Via %s', 'invoicing' ),
327
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
328
-			);
329
-
330
-		}
331
-
332
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
-			__( 'Via %s', 'invoicing' ),
334
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
335
-		);
336
-
337
-	}
338
-
339
-	/**
340
-	 * Amount column
341
-	 *
342
-	 * @param WPInv_Subscription $item
343
-	 * @since       1.0.19
344
-	 * @return      string
345
-	 */
346
-	public static function column_amount( $item ) {
347
-		$amount = getpaid_get_formatted_subscription_amount( $item );
348
-		return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349
-	}
350
-
351
-	/**
352
-	 * Billing Times column
353
-	 *
354
-	 * @param WPInv_Subscription $item
355
-	 * @since       1.0.0
356
-	 * @return      string
357
-	 */
358
-	public function column_renewals( $item ) {
359
-		$max_bills = $item->get_bill_times();
360
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
361
-	}
362
-
363
-	/**
364
-	 * Product ID column
365
-	 *
366
-	 * @param WPInv_Subscription $item
367
-	 * @since       1.0.0
368
-	 * @return      string
369
-	 */
370
-	public function column_item( $item ) {
371
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
372
-
373
-		if ( empty( $subscription_group ) ) {
374
-			return $this->generate_item_markup( $item->get_product_id() );
375
-		}
376
-
377
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
-		return implode( ' | ', $markup );
379
-
380
-	}
381
-
382
-	/**
383
-	 * Generates the items markup.
384
-	 *
385
-	 * @param int $item_id
386
-	 * @since       1.0.0
387
-	 * @return      string
388
-	 */
389
-	public static function generate_item_markup( $item_id ) {
390
-		$item = get_post( $item_id );
391
-
392
-		if ( ! empty( $item ) ) {
393
-			$link = get_edit_post_link( $item );
394
-			$name = esc_html( get_the_title( $item ) );
395
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
396
-		} else {
397
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
398
-		}
399
-
400
-	}
401
-
402
-	/**
403
-	 * Retrieve the current page number
404
-	 *
405
-	 * @return      int
406
-	 */
407
-	public function get_paged() {
408
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
409
-	}
410
-
411
-	/**
412
-	 * Setup the final data for the table
413
-	 *
414
-	 */
415
-	public function prepare_items() {
416
-
417
-		$columns  = $this->get_columns();
418
-		$hidden   = array();
419
-		$sortable = $this->get_sortable_columns();
420
-
421
-		$this->_column_headers = array( $columns, $hidden, $sortable );
422
-
423
-		$this->set_pagination_args(
424
-			array(
425
-				'total_items' => $this->current_total_count,
426
-				'per_page'    => $this->per_page,
427
-				'total_pages' => ceil( $this->current_total_count / $this->per_page ),
428
-			)
429
-		);
430
-	}
431
-
432
-	/**
433
-	 * Table columns
434
-	 *
435
-	 * @return array
436
-	 */
437
-	public function get_columns() {
438
-		$columns = array(
439
-			'cb'           => '<input type="checkbox" />',
440
-			'subscription' => __( 'Subscription', 'invoicing' ),
441
-			'start_date'   => __( 'Start Date', 'invoicing' ),
442
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
-			'renewals'     => __( 'Payments', 'invoicing' ),
444
-			'item'         => __( 'Items', 'invoicing' ),
445
-			'status'       => __( 'Status', 'invoicing' ),
446
-		);
447
-
448
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
449
-	}
450
-
451
-	/**
452
-	 * Sortable table columns.
453
-	 *
454
-	 * @return array
455
-	 */
456
-	public function get_sortable_columns() {
457
-		$sortable = array(
458
-			'subscription' => array( 'id', true ),
459
-			'start_date'   => array( 'created', true ),
460
-			'renewal_date' => array( 'expiration', true ),
461
-			'renewals'     => array( 'bill_times', true ),
462
-			'item'         => array( 'product_id', true ),
463
-			'status'       => array( 'status', true ),
464
-		);
465
-
466
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
467
-	}
468
-
469
-	/**
470
-	 * Whether the table has items to display or not
471
-	 *
472
-	 * @return bool
473
-	 */
474
-	public function has_items() {
475
-		return ! empty( $this->current_total_count );
476
-	}
477
-
478
-	/**
479
-	 * Processes bulk actions.
480
-	 *
481
-	 */
482
-	public function process_bulk_action() {
483
-
484
-	}
19
+    /**
20
+     * URL of this page
21
+     *
22
+     * @var   string
23
+     * @since 1.0.19
24
+     */
25
+    public $base_url;
26
+
27
+    /**
28
+     * Query
29
+     *
30
+     * @var   GetPaid_Subscriptions_Query
31
+     * @since 1.0.19
32
+     */
33
+    public $query;
34
+
35
+    /**
36
+     * Total subscriptions
37
+     *
38
+     * @var   string
39
+     * @since 1.0.0
40
+     */
41
+    public $total_count;
42
+
43
+    /**
44
+     * Current status subscriptions
45
+     *
46
+     * @var   string
47
+     * @since 1.0.0
48
+     */
49
+    public $current_total_count;
50
+
51
+    /**
52
+     * Status counts
53
+     *
54
+     * @var   array
55
+     * @since 1.0.19
56
+     */
57
+    public $status_counts;
58
+
59
+    /**
60
+     * Number of results to show per page
61
+     *
62
+     * @var   int
63
+     * @since 1.0.0
64
+     */
65
+    public $per_page = 10;
66
+
67
+    /**
68
+     *  Constructor function.
69
+     */
70
+    public function __construct() {
71
+
72
+        parent::__construct(
73
+            array(
74
+                'singular' => 'subscription',
75
+                'plural'   => 'subscriptions',
76
+            )
77
+        );
78
+
79
+        $this->process_bulk_action();
80
+
81
+        $this->prepare_query();
82
+
83
+        $this->base_url = remove_query_arg( 'status' );
84
+
85
+    }
86
+
87
+    /**
88
+     *  Prepares the display query
89
+     */
90
+    public function prepare_query() {
91
+
92
+        // Prepare query args.
93
+        $query = array(
94
+            'number'      => $this->per_page,
95
+            'paged'       => $this->get_paged(),
96
+            'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
+            'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
+            'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
99
+            'customer_in' => $this->get_user_in(),
100
+        );
101
+
102
+        if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
103
+            $this->total_count         = 0;
104
+            $this->current_total_count = 0;
105
+            $this->items               = array();
106
+            $this->status_counts       = array();
107
+            return;
108
+        }
109
+
110
+        // Prepare class properties.
111
+        $this->query               = new GetPaid_Subscriptions_Query( $query );
112
+        $this->total_count         = $this->query->get_total();
113
+        $this->current_total_count = $this->query->get_total();
114
+        $this->items               = $this->query->get_results();
115
+        $this->status_counts       = getpaid_get_subscription_status_counts( $query );
116
+
117
+        if ( 'all' != $query['status'] ) {
118
+            unset( $query['status'] );
119
+            $this->total_count   = getpaid_get_subscriptions( $query, 'count' );
120
+        }
121
+
122
+    }
123
+
124
+    /**
125
+     * Get user in.
126
+     *
127
+     */
128
+    public function get_user_in() {
129
+
130
+        // Abort if no user.
131
+        if ( empty( $_GET['s'] ) ) {
132
+            return null;
133
+        }
134
+
135
+        // Or invalid user.
136
+        $user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
137
+
138
+        if ( empty( $user ) ) {
139
+            return null;
140
+        }
141
+
142
+        // Search matching users.
143
+        $user  = '*' . $user . '*';
144
+        $users = new WP_User_Query(
145
+            array(
146
+                'fields'      => 'ID',
147
+                'search'      => $user,
148
+                'count_total' => false,
149
+            )
150
+        );
151
+
152
+        return $users->get_results();
153
+    }
154
+
155
+    /**
156
+     * Gets the list of views available on this table.
157
+     *
158
+     * The format is an associative array:
159
+     * - `'id' => 'link'`
160
+     *
161
+     * @since 1.0.0
162
+     *
163
+     * @return array
164
+     */
165
+    public function get_views() {
166
+
167
+        $current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
168
+        $views    = array(
169
+
170
+            'all' => sprintf(
171
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
+                esc_url( add_query_arg( 'status', false, $this->base_url ) ),
173
+                $current === 'all' ? ' class="current"' : '',
174
+                __( 'All', 'invoicing' ),
175
+                $this->total_count
176
+            ),
177
+
178
+        );
179
+
180
+        foreach ( array_filter( $this->status_counts ) as $status => $count ) {
181
+
182
+            $views[ $status ] = sprintf(
183
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
+                esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
185
+                $current === $status ? ' class="current"' : '',
186
+                esc_html( getpaid_get_subscription_status_label( $status ) ),
187
+                $count
188
+            );
189
+
190
+        }
191
+
192
+        return $views;
193
+
194
+    }
195
+
196
+    /**
197
+     * Render most columns
198
+     *
199
+     * @access      private
200
+     * @since       1.0.0
201
+     * @return      string
202
+     */
203
+    public function column_default( $item, $column_name ) {
204
+        return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
205
+    }
206
+
207
+    /**
208
+     * This is how checkbox column renders.
209
+     *
210
+     * @param WPInv_Subscription $item
211
+     * @return string
212
+     */
213
+    public function column_cb( $item ) {
214
+        return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
215
+    }
216
+
217
+    /**
218
+     * Status column
219
+     *
220
+     * @param WPInv_Subscription $item
221
+     * @since       1.0.0
222
+     * @return      string
223
+     */
224
+    public function column_status( $item ) {
225
+        return $item->get_status_label_html();
226
+    }
227
+
228
+    /**
229
+     * Subscription column
230
+     *
231
+     * @param WPInv_Subscription $item
232
+     * @since       1.0.0
233
+     * @return      string
234
+     */
235
+    public function column_subscription( $item ) {
236
+
237
+        $username = __( '(Missing User)', 'invoicing' );
238
+
239
+        $user = get_userdata( $item->get_customer_id() );
240
+        $capabilities = wpinv_current_user_can_manage_invoicing();
241
+
242
+        if ( $user ) {
243
+            $username = sprintf(
244
+                '<a href="user-edit.php?user_id=%s">%s</a>',
245
+                absint( $user->ID ),
246
+                ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
247
+            );
248
+        }
249
+
250
+        // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251
+        $column_content = sprintf(
252
+            _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
+            '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
+            '<strong>' . esc_attr( $item->get_id() ) . '</strong>',
255
+            '</a>',
256
+            $username
257
+        );
258
+
259
+        $row_actions = array();
260
+
261
+        // View subscription.
262
+        $view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
+        $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
264
+
265
+        // View invoice.
266
+        $invoice = get_post( $item->get_parent_invoice_id() );
267
+
268
+        if ( ! empty( $invoice ) ) {
269
+            $invoice_url            = get_edit_post_link( $invoice );
270
+            $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
271
+        }
272
+
273
+        $delete_url            = esc_url(
274
+            wp_nonce_url(
275
+                add_query_arg(
276
+                    array(
277
+                        'getpaid-admin-action' => 'subscription_manual_delete',
278
+                        'id'                   => $item->get_id(),
279
+                    )
280
+                ),
281
+                'getpaid-nonce',
282
+                'getpaid-nonce'
283
+            )
284
+        );
285
+        $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
286
+
287
+        if ( ! $capabilities ) {
288
+            $row_actions = array();
289
+        }
290
+
291
+        $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
292
+
293
+        return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
294
+    }
295
+
296
+    /**
297
+     * Renewal date column
298
+     *
299
+     * @param WPInv_Subscription $item
300
+     * @since       1.0.0
301
+     * @return      string
302
+     */
303
+    public function column_renewal_date( $item ) {
304
+        return getpaid_format_date_value( $item->get_expiration() );
305
+    }
306
+
307
+    /**
308
+     * Start date column
309
+     *
310
+     * @param WPInv_Subscription $item
311
+     * @since       1.0.0
312
+     * @return      string
313
+     */
314
+    public function column_start_date( $item ) {
315
+
316
+        $gateway = $item->get_parent_invoice()->get_gateway_title();
317
+
318
+        if ( empty( $gateway ) ) {
319
+            return getpaid_format_date_value( $item->get_date_created() );
320
+        }
321
+
322
+        $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
+        if ( ! empty( $url ) ) {
324
+
325
+            return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
+                __( 'Via %s', 'invoicing' ),
327
+                '<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
328
+            );
329
+
330
+        }
331
+
332
+        return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
+            __( 'Via %s', 'invoicing' ),
334
+            '<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
335
+        );
336
+
337
+    }
338
+
339
+    /**
340
+     * Amount column
341
+     *
342
+     * @param WPInv_Subscription $item
343
+     * @since       1.0.19
344
+     * @return      string
345
+     */
346
+    public static function column_amount( $item ) {
347
+        $amount = getpaid_get_formatted_subscription_amount( $item );
348
+        return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349
+    }
350
+
351
+    /**
352
+     * Billing Times column
353
+     *
354
+     * @param WPInv_Subscription $item
355
+     * @since       1.0.0
356
+     * @return      string
357
+     */
358
+    public function column_renewals( $item ) {
359
+        $max_bills = $item->get_bill_times();
360
+        return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
361
+    }
362
+
363
+    /**
364
+     * Product ID column
365
+     *
366
+     * @param WPInv_Subscription $item
367
+     * @since       1.0.0
368
+     * @return      string
369
+     */
370
+    public function column_item( $item ) {
371
+        $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
372
+
373
+        if ( empty( $subscription_group ) ) {
374
+            return $this->generate_item_markup( $item->get_product_id() );
375
+        }
376
+
377
+        $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
+        return implode( ' | ', $markup );
379
+
380
+    }
381
+
382
+    /**
383
+     * Generates the items markup.
384
+     *
385
+     * @param int $item_id
386
+     * @since       1.0.0
387
+     * @return      string
388
+     */
389
+    public static function generate_item_markup( $item_id ) {
390
+        $item = get_post( $item_id );
391
+
392
+        if ( ! empty( $item ) ) {
393
+            $link = get_edit_post_link( $item );
394
+            $name = esc_html( get_the_title( $item ) );
395
+            return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
396
+        } else {
397
+            return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
398
+        }
399
+
400
+    }
401
+
402
+    /**
403
+     * Retrieve the current page number
404
+     *
405
+     * @return      int
406
+     */
407
+    public function get_paged() {
408
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
409
+    }
410
+
411
+    /**
412
+     * Setup the final data for the table
413
+     *
414
+     */
415
+    public function prepare_items() {
416
+
417
+        $columns  = $this->get_columns();
418
+        $hidden   = array();
419
+        $sortable = $this->get_sortable_columns();
420
+
421
+        $this->_column_headers = array( $columns, $hidden, $sortable );
422
+
423
+        $this->set_pagination_args(
424
+            array(
425
+                'total_items' => $this->current_total_count,
426
+                'per_page'    => $this->per_page,
427
+                'total_pages' => ceil( $this->current_total_count / $this->per_page ),
428
+            )
429
+        );
430
+    }
431
+
432
+    /**
433
+     * Table columns
434
+     *
435
+     * @return array
436
+     */
437
+    public function get_columns() {
438
+        $columns = array(
439
+            'cb'           => '<input type="checkbox" />',
440
+            'subscription' => __( 'Subscription', 'invoicing' ),
441
+            'start_date'   => __( 'Start Date', 'invoicing' ),
442
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
+            'renewals'     => __( 'Payments', 'invoicing' ),
444
+            'item'         => __( 'Items', 'invoicing' ),
445
+            'status'       => __( 'Status', 'invoicing' ),
446
+        );
447
+
448
+        return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
449
+    }
450
+
451
+    /**
452
+     * Sortable table columns.
453
+     *
454
+     * @return array
455
+     */
456
+    public function get_sortable_columns() {
457
+        $sortable = array(
458
+            'subscription' => array( 'id', true ),
459
+            'start_date'   => array( 'created', true ),
460
+            'renewal_date' => array( 'expiration', true ),
461
+            'renewals'     => array( 'bill_times', true ),
462
+            'item'         => array( 'product_id', true ),
463
+            'status'       => array( 'status', true ),
464
+        );
465
+
466
+        return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
467
+    }
468
+
469
+    /**
470
+     * Whether the table has items to display or not
471
+     *
472
+     * @return bool
473
+     */
474
+    public function has_items() {
475
+        return ! empty( $this->current_total_count );
476
+    }
477
+
478
+    /**
479
+     * Processes bulk actions.
480
+     *
481
+     */
482
+    public function process_bulk_action() {
483
+
484
+    }
485 485
 
486 486
 }
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 exit;
8 8
 }
9 9
 
10
-if ( ! class_exists( 'WP_List_Table' ) ) {
10
+if (!class_exists('WP_List_Table')) {
11 11
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12 12
 }
13 13
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$this->prepare_query();
82 82
 
83
-		$this->base_url = remove_query_arg( 'status' );
83
+		$this->base_url = remove_query_arg('status');
84 84
 
85 85
 	}
86 86
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 		$query = array(
94 94
 			'number'      => $this->per_page,
95 95
 			'paged'       => $this->get_paged(),
96
-			'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
-			'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
-			'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
96
+			'status'      => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? sanitize_text_field($_GET['status']) : 'all',
97
+			'orderby'     => (isset($_GET['orderby'])) ? sanitize_text_field($_GET['orderby']) : 'id',
98
+			'order'       => (isset($_GET['order'])) ? sanitize_text_field($_GET['order']) : 'DESC',
99 99
 			'customer_in' => $this->get_user_in(),
100 100
 		);
101 101
 
102
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
102
+		if (is_array($query['customer_in']) && empty($query['customer_in'])) {
103 103
 			$this->total_count         = 0;
104 104
 			$this->current_total_count = 0;
105 105
 			$this->items               = array();
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		// Prepare class properties.
111
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
111
+		$this->query               = new GetPaid_Subscriptions_Query($query);
112 112
 		$this->total_count         = $this->query->get_total();
113 113
 		$this->current_total_count = $this->query->get_total();
114 114
 		$this->items               = $this->query->get_results();
115
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
115
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
116 116
 
117
-		if ( 'all' != $query['status'] ) {
118
-			unset( $query['status'] );
119
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
117
+		if ('all' != $query['status']) {
118
+			unset($query['status']);
119
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
120 120
 		}
121 121
 
122 122
 	}
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 	public function get_user_in() {
129 129
 
130 130
 		// Abort if no user.
131
-		if ( empty( $_GET['s'] ) ) {
131
+		if (empty($_GET['s'])) {
132 132
 			return null;
133 133
 		}
134 134
 
135 135
 		// Or invalid user.
136
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
136
+		$user = wp_unslash(sanitize_text_field($_REQUEST['s']));
137 137
 
138
-		if ( empty( $user ) ) {
138
+		if (empty($user)) {
139 139
 			return null;
140 140
 		}
141 141
 
@@ -164,26 +164,26 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function get_views() {
166 166
 
167
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
167
+		$current  = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
168 168
 		$views    = array(
169 169
 
170 170
 			'all' => sprintf(
171 171
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
172
+				esc_url(add_query_arg('status', false, $this->base_url)),
173 173
 				$current === 'all' ? ' class="current"' : '',
174
-				__( 'All', 'invoicing' ),
174
+				__('All', 'invoicing'),
175 175
 				$this->total_count
176 176
 			),
177 177
 
178 178
 		);
179 179
 
180
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
180
+		foreach (array_filter($this->status_counts) as $status => $count) {
181 181
 
182
-			$views[ $status ] = sprintf(
182
+			$views[$status] = sprintf(
183 183
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
184
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
185 185
 				$current === $status ? ' class="current"' : '',
186
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
186
+				esc_html(getpaid_get_subscription_status_label($status)),
187 187
 				$count
188 188
 			);
189 189
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @since       1.0.0
201 201
 	 * @return      string
202 202
 	 */
203
-	public function column_default( $item, $column_name ) {
204
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
203
+	public function column_default($item, $column_name) {
204
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 * @param WPInv_Subscription $item
211 211
 	 * @return string
212 212
 	 */
213
-	public function column_cb( $item ) {
214
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
213
+	public function column_cb($item) {
214
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
215 215
 	}
216 216
 
217 217
 	/**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @since       1.0.0
222 222
 	 * @return      string
223 223
 	 */
224
-	public function column_status( $item ) {
224
+	public function column_status($item) {
225 225
 		return $item->get_status_label_html();
226 226
 	}
227 227
 
@@ -232,26 +232,26 @@  discard block
 block discarded – undo
232 232
 	 * @since       1.0.0
233 233
 	 * @return      string
234 234
 	 */
235
-	public function column_subscription( $item ) {
235
+	public function column_subscription($item) {
236 236
 
237
-		$username = __( '(Missing User)', 'invoicing' );
237
+		$username = __('(Missing User)', 'invoicing');
238 238
 
239
-		$user = get_userdata( $item->get_customer_id() );
239
+		$user = get_userdata($item->get_customer_id());
240 240
 		$capabilities = wpinv_current_user_can_manage_invoicing();
241 241
 
242
-		if ( $user ) {
242
+		if ($user) {
243 243
 			$username = sprintf(
244 244
 				'<a href="user-edit.php?user_id=%s">%s</a>',
245
-				absint( $user->ID ),
246
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
+				absint($user->ID),
246
+				!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
247 247
 			);
248 248
 		}
249 249
 
250 250
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251 251
 		$column_content = sprintf(
252
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>',
252
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
253
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
254
+			'<strong>' . esc_attr($item->get_id()) . '</strong>',
255 255
 			'</a>',
256 256
 			$username
257 257
 		);
@@ -259,18 +259,18 @@  discard block
 block discarded – undo
259 259
 		$row_actions = array();
260 260
 
261 261
 		// View subscription.
262
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
262
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
263
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
264 264
 
265 265
 		// View invoice.
266
-		$invoice = get_post( $item->get_parent_invoice_id() );
266
+		$invoice = get_post($item->get_parent_invoice_id());
267 267
 
268
-		if ( ! empty( $invoice ) ) {
269
-			$invoice_url            = get_edit_post_link( $invoice );
270
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
268
+		if (!empty($invoice)) {
269
+			$invoice_url            = get_edit_post_link($invoice);
270
+			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>';
271 271
 		}
272 272
 
273
-		$delete_url            = esc_url(
273
+		$delete_url = esc_url(
274 274
 			wp_nonce_url(
275 275
 				add_query_arg(
276 276
 					array(
@@ -282,15 +282,15 @@  discard block
 block discarded – undo
282 282
 				'getpaid-nonce'
283 283
 			)
284 284
 		);
285
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
285
+		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>';
286 286
 
287
-		if ( ! $capabilities ) {
287
+		if (!$capabilities) {
288 288
 			$row_actions = array();
289 289
 		}
290 290
 
291
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
291
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
292 292
 
293
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
293
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
294 294
 	}
295 295
 
296 296
 	/**
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @since       1.0.0
301 301
 	 * @return      string
302 302
 	 */
303
-	public function column_renewal_date( $item ) {
304
-		return getpaid_format_date_value( $item->get_expiration() );
303
+	public function column_renewal_date($item) {
304
+		return getpaid_format_date_value($item->get_expiration());
305 305
 	}
306 306
 
307 307
 	/**
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 	 * @since       1.0.0
312 312
 	 * @return      string
313 313
 	 */
314
-	public function column_start_date( $item ) {
314
+	public function column_start_date($item) {
315 315
 
316 316
 		$gateway = $item->get_parent_invoice()->get_gateway_title();
317 317
 
318
-		if ( empty( $gateway ) ) {
319
-			return getpaid_format_date_value( $item->get_date_created() );
318
+		if (empty($gateway)) {
319
+			return getpaid_format_date_value($item->get_date_created());
320 320
 		}
321 321
 
322
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
-		if ( ! empty( $url ) ) {
322
+		$url = apply_filters('getpaid_remote_subscription_profile_url', '', $item);
323
+		if (!empty($url)) {
324 324
 
325
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
-				__( 'Via %s', 'invoicing' ),
327
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
325
+			return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
326
+				__('Via %s', 'invoicing'),
327
+				'<strong><a href="' . esc_url($url) . '" target="_blank">' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</a></strong>'
328 328
 			);
329 329
 
330 330
 		}
331 331
 
332
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
-			__( 'Via %s', 'invoicing' ),
334
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
332
+		return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
333
+			__('Via %s', 'invoicing'),
334
+			'<strong>' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</strong>'
335 335
 		);
336 336
 
337 337
 	}
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @since       1.0.19
344 344
 	 * @return      string
345 345
 	 */
346
-	public static function column_amount( $item ) {
347
-		$amount = getpaid_get_formatted_subscription_amount( $item );
346
+	public static function column_amount($item) {
347
+		$amount = getpaid_get_formatted_subscription_amount($item);
348 348
 		return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349 349
 	}
350 350
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @since       1.0.0
356 356
 	 * @return      string
357 357
 	 */
358
-	public function column_renewals( $item ) {
358
+	public function column_renewals($item) {
359 359
 		$max_bills = $item->get_bill_times();
360
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
360
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? '&infin;' : $max_bills);
361 361
 	}
362 362
 
363 363
 	/**
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 	 * @since       1.0.0
368 368
 	 * @return      string
369 369
 	 */
370
-	public function column_item( $item ) {
371
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
370
+	public function column_item($item) {
371
+		$subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id());
372 372
 
373
-		if ( empty( $subscription_group ) ) {
374
-			return $this->generate_item_markup( $item->get_product_id() );
373
+		if (empty($subscription_group)) {
374
+			return $this->generate_item_markup($item->get_product_id());
375 375
 		}
376 376
 
377
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
-		return implode( ' | ', $markup );
377
+		$markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items']));
378
+		return implode(' | ', $markup);
379 379
 
380 380
 	}
381 381
 
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
 	 * @since       1.0.0
387 387
 	 * @return      string
388 388
 	 */
389
-	public static function generate_item_markup( $item_id ) {
390
-		$item = get_post( $item_id );
389
+	public static function generate_item_markup($item_id) {
390
+		$item = get_post($item_id);
391 391
 
392
-		if ( ! empty( $item ) ) {
393
-			$link = get_edit_post_link( $item );
394
-			$name = esc_html( get_the_title( $item ) );
395
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
392
+		if (!empty($item)) {
393
+			$link = get_edit_post_link($item);
394
+			$name = esc_html(get_the_title($item));
395
+			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ($link ? esc_url($link) : '#') . "'>$name</a>" : $name;
396 396
 		} else {
397
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
397
+			return sprintf(__('Item #%s', 'invoicing'), $item_id);
398 398
 		}
399 399
 
400 400
 	}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return      int
406 406
 	 */
407 407
 	public function get_paged() {
408
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
408
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
409 409
 	}
410 410
 
411 411
 	/**
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 		$hidden   = array();
419 419
 		$sortable = $this->get_sortable_columns();
420 420
 
421
-		$this->_column_headers = array( $columns, $hidden, $sortable );
421
+		$this->_column_headers = array($columns, $hidden, $sortable);
422 422
 
423 423
 		$this->set_pagination_args(
424 424
 			array(
425 425
 				'total_items' => $this->current_total_count,
426 426
 				'per_page'    => $this->per_page,
427
-				'total_pages' => ceil( $this->current_total_count / $this->per_page ),
427
+				'total_pages' => ceil($this->current_total_count / $this->per_page),
428 428
 			)
429 429
 		);
430 430
 	}
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
 	public function get_columns() {
438 438
 		$columns = array(
439 439
 			'cb'           => '<input type="checkbox" />',
440
-			'subscription' => __( 'Subscription', 'invoicing' ),
441
-			'start_date'   => __( 'Start Date', 'invoicing' ),
442
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
-			'renewals'     => __( 'Payments', 'invoicing' ),
444
-			'item'         => __( 'Items', 'invoicing' ),
445
-			'status'       => __( 'Status', 'invoicing' ),
440
+			'subscription' => __('Subscription', 'invoicing'),
441
+			'start_date'   => __('Start Date', 'invoicing'),
442
+			'renewal_date' => __('Next Payment', 'invoicing'),
443
+			'renewals'     => __('Payments', 'invoicing'),
444
+			'item'         => __('Items', 'invoicing'),
445
+			'status'       => __('Status', 'invoicing'),
446 446
 		);
447 447
 
448
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
448
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
449 449
 	}
450 450
 
451 451
 	/**
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 	 */
456 456
 	public function get_sortable_columns() {
457 457
 		$sortable = array(
458
-			'subscription' => array( 'id', true ),
459
-			'start_date'   => array( 'created', true ),
460
-			'renewal_date' => array( 'expiration', true ),
461
-			'renewals'     => array( 'bill_times', true ),
462
-			'item'         => array( 'product_id', true ),
463
-			'status'       => array( 'status', true ),
458
+			'subscription' => array('id', true),
459
+			'start_date'   => array('created', true),
460
+			'renewal_date' => array('expiration', true),
461
+			'renewals'     => array('bill_times', true),
462
+			'item'         => array('product_id', true),
463
+			'status'       => array('status', true),
464 464
 		);
465 465
 
466
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
466
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
467 467
 	}
468 468
 
469 469
 	/**
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @return bool
473 473
 	 */
474 474
 	public function has_items() {
475
-		return ! empty( $this->current_total_count );
475
+		return !empty($this->current_total_count);
476 476
 	}
477 477
 
478 478
 	/**
Please login to merge, or discard this patch.
includes/subscription-functions.php 2 patches
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  */
51 51
 function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52 52
     $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
53
+    $matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54 54
     return reset( $matching_group );
55 55
 }
56 56
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function getpaid_get_subscription( $subscription ) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
68
-	}
66
+    if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
+        $subscription = new WPInv_Subscription( $subscription );
68
+    }
69 69
 
70
-	return $subscription->exists() ? $subscription : false;
70
+    return $subscription->exists() ? $subscription : false;
71 71
 }
72 72
 
73 73
 /**
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
83 83
 
84
-	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
86
-		$args['fields'] = 'id';
87
-		$args['number'] = 1;
88
-	}
84
+    // Do not retrieve all fields if we just want the count.
85
+    if ( 'count' == $return ) {
86
+        $args['fields'] = 'id';
87
+        $args['number'] = 1;
88
+    }
89 89
 
90
-	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
92
-		$args['count_total'] = false;
93
-	}
90
+    // Do not count all matches if we just want the results.
91
+    if ( 'results' == $return ) {
92
+        $args['count_total'] = false;
93
+    }
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+    $query = new GetPaid_Subscriptions_Query( $args );
96 96
 
97
-	if ( 'results' == $return ) {
98
-		return $query->get_results();
99
-	}
97
+    if ( 'results' == $return ) {
98
+        return $query->get_results();
99
+    }
100 100
 
101
-	if ( 'count' == $return ) {
102
-		return $query->get_total();
103
-	}
101
+    if ( 'count' == $return ) {
102
+        return $query->get_total();
103
+    }
104 104
 
105
-	return $query;
105
+    return $query;
106 106
 }
107 107
 
108 108
 /**
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function getpaid_get_subscription_statuses() {
114 114
 
115
-	return apply_filters(
116
-		'getpaid_get_subscription_statuses',
117
-		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
125
-		)
126
-	);
115
+    return apply_filters(
116
+        'getpaid_get_subscription_statuses',
117
+        array(
118
+            'pending'   => __( 'Pending', 'invoicing' ),
119
+            'trialling' => __( 'Trialing', 'invoicing' ),
120
+            'active'    => __( 'Active', 'invoicing' ),
121
+            'failing'   => __( 'Failing', 'invoicing' ),
122
+            'expired'   => __( 'Expired', 'invoicing' ),
123
+            'completed' => __( 'Complete', 'invoicing' ),
124
+            'cancelled' => __( 'Cancelled', 'invoicing' ),
125
+        )
126
+    );
127 127
 
128 128
 }
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
  * @return string
134 134
  */
135 135
 function getpaid_get_subscription_status_label( $status ) {
136
-	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
136
+    $statuses = getpaid_get_subscription_statuses();
137
+    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
138 138
 }
139 139
 
140 140
 /**
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function getpaid_get_subscription_status_classes() {
146 146
 
147
-	return apply_filters(
148
-		'getpaid_get_subscription_status_classes',
149
-		array(
150
-			'pending'   => 'bg-dark',
151
-			'trialling' => 'bg-info',
152
-			'active'    => 'bg-success',
153
-			'failing'   => 'bg-warning text-dark',
154
-			'expired'   => 'bg-danger',
155
-			'completed' => 'bg-primary',
156
-			'cancelled' => 'bg-secondary',
157
-		)
158
-	);
147
+    return apply_filters(
148
+        'getpaid_get_subscription_status_classes',
149
+        array(
150
+            'pending'   => 'bg-dark',
151
+            'trialling' => 'bg-info',
152
+            'active'    => 'bg-success',
153
+            'failing'   => 'bg-warning text-dark',
154
+            'expired'   => 'bg-danger',
155
+            'completed' => 'bg-primary',
156
+            'cancelled' => 'bg-secondary',
157
+        )
158
+    );
159 159
 
160 160
 }
161 161
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function getpaid_get_subscription_status_counts( $args = array() ) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
170
-	$counts   = array();
169
+    $statuses = array_keys( getpaid_get_subscription_statuses() );
170
+    $counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
-	}
172
+    foreach ( $statuses as $status ) {
173
+        $_args             = wp_parse_args( "status=$status", $args );
174
+        $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
+    }
176 176
 
177
-	return $counts;
177
+    return $counts;
178 178
 
179 179
 }
180 180
 
@@ -185,32 +185,32 @@  discard block
 block discarded – undo
185 185
  */
186 186
 function getpaid_get_subscription_periods() {
187 187
 
188
-	return apply_filters(
189
-		'getpaid_get_subscription_periods',
190
-		array(
188
+    return apply_filters(
189
+        'getpaid_get_subscription_periods',
190
+        array(
191 191
 
192
-			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
195
-			),
192
+            'day'   => array(
193
+                'singular' => __( '%s day', 'invoicing' ),
194
+                'plural'   => __( '%d days', 'invoicing' ),
195
+            ),
196 196
 
197
-			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
200
-			),
197
+            'week'  => array(
198
+                'singular' => __( '%s week', 'invoicing' ),
199
+                'plural'   => __( '%d weeks', 'invoicing' ),
200
+            ),
201 201
 
202
-			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
205
-			),
202
+            'month' => array(
203
+                'singular' => __( '%s month', 'invoicing' ),
204
+                'plural'   => __( '%d months', 'invoicing' ),
205
+            ),
206 206
 
207
-			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
210
-			),
207
+            'year'  => array(
208
+                'singular' => __( '%s year', 'invoicing' ),
209
+                'plural'   => __( '%d years', 'invoicing' ),
210
+            ),
211 211
 
212
-		)
213
-	);
212
+        )
213
+    );
214 214
 
215 215
 }
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return int
222 222
  */
223 223
 function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
224
+    return (int) preg_replace( '/[^0-9]/', '', $trial_period );
225 225
 }
226 226
 
227 227
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return string
232 232
  */
233 233
 function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
234
+    return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
235 235
 }
236 236
 
237 237
 /**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
  * @return string
243 243
  */
244 244
 function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
245
+    $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
+    return strtolower( sanitize_text_field( $label ) );
247 247
 }
248 248
 
249 249
 /**
@@ -254,22 +254,22 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
256 256
 
257
-	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
257
+    $periods = getpaid_get_subscription_periods();
258
+    $period  = strtolower( $period );
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
-	}
260
+    if ( isset( $periods[ $period ] ) ) {
261
+        return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
+    }
263 263
 
264
-	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
268
-		}
269
-	}
264
+    // Backwards compatibility.
265
+    foreach ( $periods as $key => $data ) {
266
+        if ( strpos( $key, $period ) === 0 ) {
267
+            return sprintf( $data['singular'], $singular_prefix );
268
+        }
269
+    }
270 270
 
271
-	// Invalid string.
272
-	return '';
271
+    // Invalid string.
272
+    return '';
273 273
 }
274 274
 
275 275
 /**
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function getpaid_get_plural_subscription_period_label( $period, $interval ) {
283 283
 
284
-	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
284
+    $periods = getpaid_get_subscription_periods();
285
+    $period  = strtolower( $period );
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
289
-	}
287
+    if ( isset( $periods[ $period ] ) ) {
288
+        return sprintf( $periods[ $period ]['plural'], $interval );
289
+    }
290 290
 
291
-	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
295
-		}
296
-	}
291
+    // Backwards compatibility.
292
+    foreach ( $periods as $key => $data ) {
293
+        if ( strpos( $key, $period ) === 0 ) {
294
+            return sprintf( $data['plural'], $interval );
295
+        }
296
+    }
297 297
 
298
-	// Invalid string.
299
-	return '';
298
+    // Invalid string.
299
+    return '';
300 300
 }
301 301
 
302 302
 /**
@@ -307,92 +307,92 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function getpaid_get_formatted_subscription_amount( $subscription ) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
-	$bill_times = $subscription->get_bill_times();
314
-	$bill_times_less = $bill_times - 1;
315
-
316
-	if ( ! empty( $bill_times ) ) {
317
-		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
-	}
321
-
322
-	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
324
-
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
-
328
-		if ( empty( $bill_times ) ) {
329
-
330
-			return sprintf(
331
-				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
-				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
-				$recurring,
336
-				$period
337
-			);
338
-
339
-		}
340
-
341
-		return sprintf(
342
-			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
-			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
-			$recurring,
347
-			$period,
348
-			$bill_times
349
-		);
350
-
351
-	}
352
-
353
-	if ( $initial != $recurring ) {
354
-
355
-		if ( empty( $bill_times ) ) {
356
-
357
-			return sprintf(
358
-				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
-				$initial,
361
-				$recurring,
362
-				$period
363
-			);
364
-
365
-		}
366
-
367
-		return sprintf(
368
-			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
-			$initial,
371
-			$recurring,
372
-			$period,
373
-			$bill_times_less
374
-		);
375
-
376
-	}
377
-
378
-	if ( empty( $bill_times ) ) {
379
-
380
-		return sprintf(
381
-			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
-			$initial,
384
-			$period
385
-		);
386
-
387
-	}
388
-
389
-	return sprintf(
390
-		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
-		$bill_times,
393
-		$initial,
394
-		$period
395
-	);
310
+    $initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
+    $recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
+    $period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
+    $bill_times = $subscription->get_bill_times();
314
+    $bill_times_less = $bill_times - 1;
315
+
316
+    if ( ! empty( $bill_times ) ) {
317
+        $bill_times = $subscription->get_frequency() * $bill_times;
318
+        $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
+        $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
+    }
321
+
322
+    // Trial periods.
323
+    if ( $subscription->has_trial_period() ) {
324
+
325
+        $trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
+        $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
+
328
+        if ( empty( $bill_times ) ) {
329
+
330
+            return sprintf(
331
+                // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
+                _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
+                $initial,
334
+                getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
+                $recurring,
336
+                $period
337
+            );
338
+
339
+        }
340
+
341
+        return sprintf(
342
+            // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
+            _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
+            $initial,
345
+            getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
+            $recurring,
347
+            $period,
348
+            $bill_times
349
+        );
350
+
351
+    }
352
+
353
+    if ( $initial != $recurring ) {
354
+
355
+        if ( empty( $bill_times ) ) {
356
+
357
+            return sprintf(
358
+                // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
+                _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
+                $initial,
361
+                $recurring,
362
+                $period
363
+            );
364
+
365
+        }
366
+
367
+        return sprintf(
368
+            // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
+            _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
+            $initial,
371
+            $recurring,
372
+            $period,
373
+            $bill_times_less
374
+        );
375
+
376
+    }
377
+
378
+    if ( empty( $bill_times ) ) {
379
+
380
+        return sprintf(
381
+            // translators: $1: is the recurring amount, $2: is the recurring period
382
+            _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
+            $initial,
384
+            $period
385
+        );
386
+
387
+    }
388
+
389
+    return sprintf(
390
+        // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
+        _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
+        $bill_times,
393
+        $initial,
394
+        $period
395
+    );
396 396
 
397 397
 }
398 398
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
  * @return WPInv_Subscription|false
404 404
  */
405 405
 function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
406
+    return getpaid_subscriptions()->get_invoice_subscription( $invoice );
407 407
 }
408 408
 
409 409
 /**
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414 414
 function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
-		$subscription->activate();
418
-	}
415
+    $subscription = getpaid_get_invoice_subscription( $invoice );
416
+    if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
+        $subscription->activate();
418
+    }
419 419
 }
420 420
 
421 421
 /**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+    return getpaid()->get( 'subscriptions' );
428 428
 }
429 429
 
430 430
 /**
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
         return false;
444 444
     }
445 445
 
446
-	// Fetch the invoice subscription.
447
-	$subscription = getpaid_get_subscriptions(
448
-		array(
449
-			'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
-			'number'     => 1,
451
-		)
452
-	);
446
+    // Fetch the invoice subscription.
447
+    $subscription = getpaid_get_subscriptions(
448
+        array(
449
+            'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
+            'number'     => 1,
451
+        )
452
+    );
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+    return empty( $subscription ) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -468,48 +468,48 @@  discard block
 block discarded – undo
468 468
  */
469 469
 function getpaid_get_recurring_item_key( $cart_item ) {
470 470
 
471
-	$cart_key     = 'renews_';
472
-	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
474
-	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
476
-	$trial_length = $cart_item->get_trial_interval();
477
-
478
-	// First start with the billing interval and period
479
-	switch ( $interval ) {
480
-		case 1:
481
-			if ( 'day' == $period ) {
482
-				$cart_key .= 'daily';
483
-			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
485
-			}
486
-			break;
487
-		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
489
-			break;
490
-		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
492
-		    break;
493
-		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
-			break;
496
-	}
497
-
498
-	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
500
-		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
503
-			$cart_key .= 's';
504
-		}
505
-	}
506
-
507
-	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
-	}
511
-
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
471
+    $cart_key     = 'renews_';
472
+    $interval     = $cart_item->get_recurring_interval();
473
+    $period       = $cart_item->get_recurring_period( true );
474
+    $length       = $cart_item->get_recurring_limit() * $interval;
475
+    $trial_period = $cart_item->get_trial_period( true );
476
+    $trial_length = $cart_item->get_trial_interval();
477
+
478
+    // First start with the billing interval and period
479
+    switch ( $interval ) {
480
+        case 1:
481
+            if ( 'day' == $period ) {
482
+                $cart_key .= 'daily';
483
+            } else {
484
+                $cart_key .= sprintf( '%sly', $period );
485
+            }
486
+            break;
487
+        case 2:
488
+            $cart_key .= sprintf( 'every_2nd_%s', $period );
489
+            break;
490
+        case 3:
491
+            $cart_key .= sprintf( 'every_3rd_%s', $period );
492
+            break;
493
+        default:
494
+            $cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
+            break;
496
+    }
497
+
498
+    // Maybe add the optional maximum billing periods...
499
+    if ( $length > 0 ) {
500
+        $cart_key .= '_for_';
501
+        $cart_key .= sprintf( '%d_%s', $length, $period );
502
+        if ( $length > 1 ) {
503
+            $cart_key .= 's';
504
+        }
505
+    }
506
+
507
+    // And an optional free trial.
508
+    if ( $cart_item->has_free_trial() ) {
509
+        $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
+    }
511
+
512
+    return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
513 513
 }
514 514
 
515 515
 /**
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
  */
521 521
 function getpaid_get_subscription_groups( $invoice ) {
522 522
 
523
-	// Generate subscription groups.
524
-	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
523
+    // Generate subscription groups.
524
+    $subscription_groups = array();
525
+    foreach ( $invoice->get_items() as $item ) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
-		}
527
+        if ( $item->is_recurring() ) {
528
+            $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
+        }
530 530
 }
531 531
 
532
-	return $subscription_groups;
532
+    return $subscription_groups;
533 533
 }
534 534
 
535 535
 /**
@@ -543,56 +543,56 @@  discard block
 block discarded – undo
543 543
  */
544 544
 function getpaid_calculate_subscription_totals( $invoice ) {
545 545
 
546
-	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
546
+    // Generate subscription groups.
547
+    $subscription_groups = getpaid_get_subscription_groups( $invoice );
548 548
 
549
-	// Now let's calculate the totals for each group of subscriptions
550
-	$subscription_totals = array();
549
+    // Now let's calculate the totals for each group of subscriptions
550
+    $subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+    foreach ( $subscription_groups as $subscription_key => $items ) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+        if ( empty( $subscription_totals[ $subscription_key ] ) ) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
557
-				'initial_total'   => 0,
558
-				'recurring_total' => 0,
559
-				'items'           => array(),
560
-				'trialling'       => false,
561
-			);
556
+            $subscription_totals[ $subscription_key ] = array(
557
+                'initial_total'   => 0,
558
+                'recurring_total' => 0,
559
+                'items'           => array(),
560
+                'trialling'       => false,
561
+            );
562 562
 
563
-		}
563
+        }
564 564
 
565
-		/**
566
-		 * Get the totals of the group.
567
-		 * @var GetPaid_Form_Item $item
568
-		 */
569
-		foreach ( $items as $item ) {
565
+        /**
566
+         * Get the totals of the group.
567
+         * @var GetPaid_Form_Item $item
568
+         */
569
+        foreach ( $items as $item ) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+            $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
+            $subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
+            $subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
+            $subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
+            $subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+            $subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+            $subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579
-			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
581
-			$interval     = $item->get_recurring_interval();
579
+            // Calculate the next renewal date.
580
+            $period       = $item->get_recurring_period( true );
581
+            $interval     = $item->get_recurring_interval();
582 582
 
583
-			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
586
-				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
-			}
583
+            // If the subscription item has a trial period...
584
+            if ( $item->has_free_trial() ) {
585
+                $period   = $item->get_trial_period( true );
586
+                $interval = $item->get_trial_interval();
587
+                $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
+            }
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+            $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
591 591
 
592
-		}
592
+        }
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+    return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
596 596
 }
597 597
 
598 598
 /**
@@ -603,16 +603,16 @@  discard block
 block discarded – undo
603 603
  */
604 604
 function getpaid_should_group_subscriptions( $invoice ) {
605 605
 
606
-	$recurring_items = 0;
606
+    $recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+    foreach ( $invoice->get_items() as $item ) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
612
-		}
610
+        if ( $item->is_recurring() ) {
611
+            $recurring_items ++;
612
+        }
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+    return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
616 616
 }
617 617
 
618 618
 /**
@@ -623,39 +623,39 @@  discard block
 block discarded – undo
623 623
  * @return int
624 624
  */
625 625
 function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
626
-	global $wpdb;
626
+    global $wpdb;
627 627
 
628
-	$parent_invoice_id = (int) $parent_invoice_id;
628
+    $parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+    if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
631 631
 
632
-		return (int) $wpdb->get_var(
633
-			$wpdb->prepare(
634
-				"SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
-				$parent_invoice_id,
636
-				$parent_invoice_id
637
-			)
638
-		);
632
+        return (int) $wpdb->get_var(
633
+            $wpdb->prepare(
634
+                "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
+                $parent_invoice_id,
636
+                $parent_invoice_id
637
+            )
638
+        );
639 639
 
640
-	}
640
+    }
641 641
 
642
-	$invoice_ids = $wpdb->get_col(
643
-		$wpdb->prepare(
644
-			"SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
-			$parent_invoice_id,
646
-			$parent_invoice_id
647
-		)
648
-	);
642
+    $invoice_ids = $wpdb->get_col(
643
+        $wpdb->prepare(
644
+            "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
+            $parent_invoice_id,
646
+            $parent_invoice_id
647
+        )
648
+    );
649 649
 
650
-	$count = 0;
650
+    $count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+    foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
656
-			continue;
657
-		}
654
+        if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
+            $count ++;
656
+            continue;
657
+        }
658 658
 }
659 659
 
660
-	return $count;
660
+    return $count;
661 661
 }
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
  * @return      WPInv_Subscription[]|WPInv_Subscription|false
14 14
  * @since       2.3.0
15 15
  */
16
-function getpaid_get_invoice_subscriptions( $invoice ) {
16
+function getpaid_get_invoice_subscriptions($invoice) {
17 17
 
18 18
     // Retrieve subscription groups.
19
-    $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' );
19
+    $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id');
20 20
 
21 21
     // No subscription groups, normal subscription.
22
-    if ( empty( $subscription_ids ) ) {
23
-        return getpaid_subscriptions()->get_invoice_subscription( $invoice );
22
+    if (empty($subscription_ids)) {
23
+        return getpaid_subscriptions()->get_invoice_subscription($invoice);
24 24
     }
25 25
 
26 26
     // Subscription groups.
27
-    return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) );
27
+    return array_filter(array_map('getpaid_get_subscription', $subscription_ids));
28 28
 
29 29
 }
30 30
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @return      array
36 36
  * @since       2.3.0
37 37
  */
38
-function getpaid_get_invoice_subscription_groups( $invoice_id ) {
39
-    $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true );
40
-    return empty( $subscription_groups ) ? array() : $subscription_groups;
38
+function getpaid_get_invoice_subscription_groups($invoice_id) {
39
+    $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true);
40
+    return empty($subscription_groups) ? array() : $subscription_groups;
41 41
 }
42 42
 
43 43
 /**
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  * @return      array|false
49 49
  * @since       2.3.0
50 50
  */
51
-function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52
-    $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54
-    return reset( $matching_group );
51
+function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) {
52
+    $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id);
53
+	$matching_group = wp_list_filter($subscription_groups, compact('subscription_id'));
54
+    return reset($matching_group);
55 55
 }
56 56
 
57 57
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
  * @since       2.3.0
62 62
  * @return WPInv_Subscription|false
63 63
  */
64
-function getpaid_get_subscription( $subscription ) {
64
+function getpaid_get_subscription($subscription) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
66
+	if (!is_a($subscription, 'WPInv_Subscription')) {
67
+		$subscription = new WPInv_Subscription($subscription);
68 68
 	}
69 69
 
70 70
 	return $subscription->exists() ? $subscription : false;
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
  *
80 80
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
81 81
  */
82
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
82
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
83 83
 
84 84
 	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
85
+	if ('count' == $return) {
86 86
 		$args['fields'] = 'id';
87 87
 		$args['number'] = 1;
88 88
 	}
89 89
 
90 90
 	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
91
+	if ('results' == $return) {
92 92
 		$args['count_total'] = false;
93 93
 	}
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+	$query = new GetPaid_Subscriptions_Query($args);
96 96
 
97
-	if ( 'results' == $return ) {
97
+	if ('results' == $return) {
98 98
 		return $query->get_results();
99 99
 	}
100 100
 
101
-	if ( 'count' == $return ) {
101
+	if ('count' == $return) {
102 102
 		return $query->get_total();
103 103
 	}
104 104
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	return apply_filters(
116 116
 		'getpaid_get_subscription_statuses',
117 117
 		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
118
+			'pending'   => __('Pending', 'invoicing'),
119
+			'trialling' => __('Trialing', 'invoicing'),
120
+			'active'    => __('Active', 'invoicing'),
121
+			'failing'   => __('Failing', 'invoicing'),
122
+			'expired'   => __('Expired', 'invoicing'),
123
+			'completed' => __('Complete', 'invoicing'),
124
+			'cancelled' => __('Cancelled', 'invoicing'),
125 125
 		)
126 126
 	);
127 127
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return string
134 134
  */
135
-function getpaid_get_subscription_status_label( $status ) {
135
+function getpaid_get_subscription_status_label($status) {
136 136
 	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
137
+	return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status));
138 138
 }
139 139
 
140 140
 /**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return array
166 166
  */
167
-function getpaid_get_subscription_status_counts( $args = array() ) {
167
+function getpaid_get_subscription_status_counts($args = array()) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
169
+	$statuses = array_keys(getpaid_get_subscription_statuses());
170 170
 	$counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
172
+	foreach ($statuses as $status) {
173
+		$_args             = wp_parse_args("status=$status", $args);
174
+		$counts[$status] = getpaid_get_subscriptions($_args, 'count');
175 175
 	}
176 176
 
177 177
 	return $counts;
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 		array(
191 191
 
192 192
 			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
193
+				'singular' => __('%s day', 'invoicing'),
194
+				'plural'   => __('%d days', 'invoicing'),
195 195
 			),
196 196
 
197 197
 			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
198
+				'singular' => __('%s week', 'invoicing'),
199
+				'plural'   => __('%d weeks', 'invoicing'),
200 200
 			),
201 201
 
202 202
 			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
203
+				'singular' => __('%s month', 'invoicing'),
204
+				'plural'   => __('%d months', 'invoicing'),
205 205
 			),
206 206
 
207 207
 			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
208
+				'singular' => __('%s year', 'invoicing'),
209
+				'plural'   => __('%d years', 'invoicing'),
210 210
 			),
211 211
 
212 212
 		)
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
  * @param string $trial_period
221 221
  * @return int
222 222
  */
223
-function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
223
+function getpaid_get_subscription_trial_period_interval($trial_period) {
224
+	return (int) preg_replace('/[^0-9]/', '', $trial_period);
225 225
 }
226 226
 
227 227
 /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
  * @param string $trial_period
231 231
  * @return string
232 232
  */
233
-function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
233
+function getpaid_get_subscription_trial_period_period($trial_period) {
234
+	return preg_replace('/[^a-z]/', '', strtolower($trial_period));
235 235
 }
236 236
 
237 237
 /**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
  * @param int $interval
242 242
  * @return string
243 243
  */
244
-function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
244
+function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') {
245
+	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix);
246
+	return strtolower(sanitize_text_field($label));
247 247
 }
248 248
 
249 249
 /**
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
  * @param string $period
253 253
  * @return string
254 254
  */
255
-function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
255
+function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') {
256 256
 
257 257
 	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
258
+	$period  = strtolower($period);
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
260
+	if (isset($periods[$period])) {
261
+		return sprintf($periods[$period]['singular'], $singular_prefix);
262 262
 	}
263 263
 
264 264
 	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
265
+	foreach ($periods as $key => $data) {
266
+		if (strpos($key, $period) === 0) {
267
+			return sprintf($data['singular'], $singular_prefix);
268 268
 		}
269 269
 	}
270 270
 
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
  * @param int $interval
280 280
  * @return string
281 281
  */
282
-function getpaid_get_plural_subscription_period_label( $period, $interval ) {
282
+function getpaid_get_plural_subscription_period_label($period, $interval) {
283 283
 
284 284
 	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
285
+	$period  = strtolower($period);
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
287
+	if (isset($periods[$period])) {
288
+		return sprintf($periods[$period]['plural'], $interval);
289 289
 	}
290 290
 
291 291
 	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
292
+	foreach ($periods as $key => $data) {
293
+		if (strpos($key, $period) === 0) {
294
+			return sprintf($data['plural'], $interval);
295 295
 		}
296 296
 	}
297 297
 
@@ -305,33 +305,33 @@  discard block
 block discarded – undo
305 305
  * @param WPInv_Subscription $subscription
306 306
  * @return string
307 307
  */
308
-function getpaid_get_formatted_subscription_amount( $subscription ) {
308
+function getpaid_get_formatted_subscription_amount($subscription) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
310
+	$initial    = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
311
+	$recurring  = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
312
+	$period     = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
313 313
 	$bill_times = $subscription->get_bill_times();
314 314
 	$bill_times_less = $bill_times - 1;
315 315
 
316
-	if ( ! empty( $bill_times ) ) {
316
+	if (!empty($bill_times)) {
317 317
 		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
318
+		$bill_times_less = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times - $subscription->get_frequency());
319
+		$bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times);
320 320
 	}
321 321
 
322 322
 	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
323
+	if ($subscription->has_trial_period()) {
324 324
 
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
325
+		$trial_period   = getpaid_get_subscription_trial_period_period($subscription->get_trial_period());
326
+		$trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period());
327 327
 
328
-		if ( empty( $bill_times ) ) {
328
+		if (empty($bill_times)) {
329 329
 
330 330
 			return sprintf(
331 331
 				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
332
+				_x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
333 333
 				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
334
+				getpaid_get_subscription_period_label($trial_period, $trial_interval),
335 335
 				$recurring,
336 336
 				$period
337 337
 			);
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 
341 341
 		return sprintf(
342 342
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
343
+			_x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'),
344 344
 			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
345
+			getpaid_get_subscription_period_label($trial_period, $trial_interval),
346 346
 			$recurring,
347 347
 			$period,
348 348
 			$bill_times
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 
351 351
 	}
352 352
 
353
-	if ( $initial != $recurring ) {
353
+	if ($initial != $recurring) {
354 354
 
355
-		if ( empty( $bill_times ) ) {
355
+		if (empty($bill_times)) {
356 356
 
357 357
 			return sprintf(
358 358
 				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
359
+				_x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'),
360 360
 				$initial,
361 361
 				$recurring,
362 362
 				$period
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
 		return sprintf(
368 368
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
369
+			_x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'),
370 370
 			$initial,
371 371
 			$recurring,
372 372
 			$period,
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 
376 376
 	}
377 377
 
378
-	if ( empty( $bill_times ) ) {
378
+	if (empty($bill_times)) {
379 379
 
380 380
 		return sprintf(
381 381
 			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
382
+			_x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'),
383 383
 			$initial,
384 384
 			$period
385 385
 		);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	return sprintf(
390 390
 		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
391
+		_x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
392 392
 		$bill_times,
393 393
 		$initial,
394 394
 		$period
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @param WPInv_Invoice $invoice
403 403
  * @return WPInv_Subscription|false
404 404
  */
405
-function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
405
+function getpaid_get_invoice_subscription($invoice) {
406
+	return getpaid_subscriptions()->get_invoice_subscription($invoice);
407 407
 }
408 408
 
409 409
 /**
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414
-function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
414
+function getpaid_activate_invoice_subscription($invoice) {
415
+	$subscription = getpaid_get_invoice_subscription($invoice);
416
+	if (is_a($subscription, 'WPInv_Subscription')) {
417 417
 		$subscription->activate();
418 418
 	}
419 419
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+	return getpaid()->get('subscriptions');
428 428
 }
429 429
 
430 430
 /**
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
  * @since 2.3.0
434 434
  * @return WPInv_Subscription|bool
435 435
  */
436
-function wpinv_get_invoice_subscription( $invoice ) {
436
+function wpinv_get_invoice_subscription($invoice) {
437 437
 
438 438
     // Retrieve the invoice.
439
-    $invoice = new WPInv_Invoice( $invoice );
439
+    $invoice = new WPInv_Invoice($invoice);
440 440
 
441 441
     // Ensure it is a recurring invoice.
442
-    if ( ! $invoice->is_recurring() ) {
442
+    if (!$invoice->is_recurring()) {
443 443
         return false;
444 444
     }
445 445
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		)
452 452
 	);
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+	return empty($subscription) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -466,50 +466,50 @@  discard block
 block discarded – undo
466 466
  * @param GetPaid_Form_Item|WPInv_Item $cart_item
467 467
  * @return string
468 468
  */
469
-function getpaid_get_recurring_item_key( $cart_item ) {
469
+function getpaid_get_recurring_item_key($cart_item) {
470 470
 
471 471
 	$cart_key     = 'renews_';
472 472
 	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
473
+	$period       = $cart_item->get_recurring_period(true);
474 474
 	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
475
+	$trial_period = $cart_item->get_trial_period(true);
476 476
 	$trial_length = $cart_item->get_trial_interval();
477 477
 
478 478
 	// First start with the billing interval and period
479
-	switch ( $interval ) {
479
+	switch ($interval) {
480 480
 		case 1:
481
-			if ( 'day' == $period ) {
481
+			if ('day' == $period) {
482 482
 				$cart_key .= 'daily';
483 483
 			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
484
+				$cart_key .= sprintf('%sly', $period);
485 485
 			}
486 486
 			break;
487 487
 		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
488
+			$cart_key .= sprintf('every_2nd_%s', $period);
489 489
 			break;
490 490
 		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
491
+			$cart_key .= sprintf('every_3rd_%s', $period);
492 492
 		    break;
493 493
 		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
494
+			$cart_key .= sprintf('every_%dth_%s', $interval, $period);
495 495
 			break;
496 496
 	}
497 497
 
498 498
 	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
499
+	if ($length > 0) {
500 500
 		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
501
+		$cart_key .= sprintf('%d_%s', $length, $period);
502
+		if ($length > 1) {
503 503
 			$cart_key .= 's';
504 504
 		}
505 505
 	}
506 506
 
507 507
 	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
508
+	if ($cart_item->has_free_trial()) {
509
+		$cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period);
510 510
 	}
511 511
 
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
512
+	return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item);
513 513
 }
514 514
 
515 515
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
519 519
  * @return array
520 520
  */
521
-function getpaid_get_subscription_groups( $invoice ) {
521
+function getpaid_get_subscription_groups($invoice) {
522 522
 
523 523
 	// Generate subscription groups.
524 524
 	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
525
+	foreach ($invoice->get_items() as $item) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
527
+		if ($item->is_recurring()) {
528
+			$subscription_groups[getpaid_get_recurring_item_key($item)][] = $item;
529 529
 		}
530 530
 }
531 531
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
542 542
  * @return array
543 543
  */
544
-function getpaid_calculate_subscription_totals( $invoice ) {
544
+function getpaid_calculate_subscription_totals($invoice) {
545 545
 
546 546
 	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
547
+	$subscription_groups = getpaid_get_subscription_groups($invoice);
548 548
 
549 549
 	// Now let's calculate the totals for each group of subscriptions
550 550
 	$subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+	foreach ($subscription_groups as $subscription_key => $items) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+		if (empty($subscription_totals[$subscription_key])) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
556
+			$subscription_totals[$subscription_key] = array(
557 557
 				'initial_total'   => 0,
558 558
 				'recurring_total' => 0,
559 559
 				'items'           => array(),
@@ -566,33 +566,33 @@  discard block
 block discarded – undo
566 566
 		 * Get the totals of the group.
567 567
 		 * @var GetPaid_Form_Item $item
568 568
 		 */
569
-		foreach ( $items as $item ) {
569
+		foreach ($items as $item) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+			$subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving();
572
+			$subscription_totals[$subscription_key]['item_id']                 = $item->get_id();
573
+			$subscription_totals[$subscription_key]['period']                  = $item->get_recurring_period(true);
574
+			$subscription_totals[$subscription_key]['interval']                = $item->get_recurring_interval();
575
+			$subscription_totals[$subscription_key]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+			$subscription_totals[$subscription_key]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+			$subscription_totals[$subscription_key]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579 579
 			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
580
+			$period       = $item->get_recurring_period(true);
581 581
 			$interval     = $item->get_recurring_interval();
582 582
 
583 583
 			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
584
+			if ($item->has_free_trial()) {
585
+				$period   = $item->get_trial_period(true);
586 586
 				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
587
+				$subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period;
588 588
 			}
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+			$subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp')));
591 591
 
592 592
 		}
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+	return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice);
596 596
 }
597 597
 
598 598
 /**
@@ -601,18 +601,18 @@  discard block
 block discarded – undo
601 601
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
602 602
  * @return array
603 603
  */
604
-function getpaid_should_group_subscriptions( $invoice ) {
604
+function getpaid_should_group_subscriptions($invoice) {
605 605
 
606 606
 	$recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+	foreach ($invoice->get_items() as $item) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
610
+		if ($item->is_recurring()) {
611
+			$recurring_items++;
612 612
 		}
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+	return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice);
616 616
 }
617 617
 
618 618
 /**
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
  * @param int|false $subscription_id
623 623
  * @return int
624 624
  */
625
-function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
625
+function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) {
626 626
 	global $wpdb;
627 627
 
628 628
 	$parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+	if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) {
631 631
 
632 632
 		return (int) $wpdb->get_var(
633 633
 			$wpdb->prepare(
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 
650 650
 	$count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+	foreach (wp_parse_id_list($invoice_ids) as $invoice_id) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
654
+		if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) {
655
+			$count++;
656 656
 			continue;
657 657
 		}
658 658
 }
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -963,7 +963,7 @@
 block discarded – undo
963 963
 
964 964
 		if ( $discount->exists() && $discount->is_recurring() ) {
965 965
 			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
966
+		} else {
967 967
 			// Unset discount code.
968 968
 			$invoice->set_discount_code( '' );
969 969
 
Please login to merge, or discard this patch.
Indentation   +1036 added lines, -1036 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => '',
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	/**
66
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
-	 *
68
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
-	 * @param  bool $deprecated
70
-	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
72
-
73
-		parent::__construct( $subscription );
74
-
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} else {
84
-			$this->set_object_read( true );
85
-		}
86
-
87
-		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
-
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
92
-		}
93
-
94
-	}
95
-
96
-	/**
97
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
-	 *
99
-	 *
100
-	 * @static
101
-	 * @param string $value
102
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
103
-	 * @since 1.0.19
104
-	 * @return int
105
-	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => '',
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    /**
66
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
+     *
68
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
+     * @param  bool $deprecated
70
+     */
71
+    function __construct( $subscription = 0, $deprecated = false ) {
72
+
73
+        parent::__construct( $subscription );
74
+
75
+        if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
+            $this->set_id( $subscription );
77
+        } elseif ( $subscription instanceof self ) {
78
+            $this->set_id( $subscription->get_id() );
79
+        } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
+            $this->set_id( $subscription_id );
81
+        } elseif ( ! empty( $subscription->id ) ) {
82
+            $this->set_id( $subscription->id );
83
+        } else {
84
+            $this->set_object_read( true );
85
+        }
86
+
87
+        // Load the datastore.
88
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
+
90
+        if ( $this->get_id() > 0 ) {
91
+            $this->data_store->read( $this );
92
+        }
93
+
94
+    }
95
+
96
+    /**
97
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
+     *
99
+     *
100
+     * @static
101
+     * @param string $value
102
+     * @param string $field Either invoice_id, transaction_id or profile_id.
103
+     * @since 1.0.19
104
+     * @return int
105
+     */
106
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
107 107
         global $wpdb;
108 108
 
109
-		// Trim the value.
110
-		$value = trim( $value );
109
+        // Trim the value.
110
+        $value = trim( $value );
111 111
 
112
-		if ( empty( $value ) ) {
113
-			return 0;
114
-		}
112
+        if ( empty( $value ) ) {
113
+            return 0;
114
+        }
115 115
 
116
-		if ( 'invoice_id' == $field ) {
117
-			$field = 'parent_payment_id';
118
-		}
116
+        if ( 'invoice_id' == $field ) {
117
+            $field = 'parent_payment_id';
118
+        }
119 119
 
120 120
         // Valid fields.
121 121
         $fields = array(
122
-			'parent_payment_id',
123
-			'transaction_id',
124
-			'profile_id',
125
-		);
126
-
127
-		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
-			return 0;
130
-		}
131
-
132
-		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
135
-			return $subscription_id;
136
-		}
122
+            'parent_payment_id',
123
+            'transaction_id',
124
+            'profile_id',
125
+        );
126
+
127
+        // Ensure a field has been passed.
128
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
+            return 0;
130
+        }
131
+
132
+        // Maybe retrieve from the cache.
133
+        $subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
+        if ( ! empty( $subscription_id ) ) {
135
+            return $subscription_id;
136
+        }
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -141,42 +141,42 @@  discard block
 block discarded – undo
141 141
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
145
-			return 0;
146
-		}
144
+        if ( empty( $subscription_id ) ) {
145
+            return 0;
146
+        }
147 147
 
148
-		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
148
+        // Update the cache with our data.
149
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150 150
 
151
-		return $subscription_id;
152
-	}
151
+        return $subscription_id;
152
+    }
153 153
 
154
-	/**
154
+    /**
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		$caches = array(
159
-			'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
-			'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
-			'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
-			'getpaid_subscriptions'                                       => $this->get_id(),
163
-		);
164
-
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
168
-			}
169
-		}
170
-	}
171
-
172
-	/**
158
+        $caches = array(
159
+            'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
+            'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
+            'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
+            'getpaid_subscriptions'                                       => $this->get_id(),
163
+        );
164
+
165
+        foreach ( $caches as $cache => $value ) {
166
+            if ( '' !== $value && false !== $value ) {
167
+                wp_cache_delete( $value, $cache );
168
+            }
169
+        }
170
+    }
171
+
172
+    /**
173 173
      * Checks if a subscription key is set.
174 174
      */
175 175
     public function _isset( $key ) {
176 176
         return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
177
-	}
177
+    }
178 178
 
179
-	/*
179
+    /*
180 180
 	|--------------------------------------------------------------------------
181 181
 	| CRUD methods
182 182
 	|--------------------------------------------------------------------------
@@ -185,57 +185,57 @@  discard block
 block discarded – undo
185 185
 	|
186 186
     */
187 187
 
188
-	/*
188
+    /*
189 189
 	|--------------------------------------------------------------------------
190 190
 	| Getters
191 191
 	|--------------------------------------------------------------------------
192 192
 	*/
193 193
 
194
-	/**
195
-	 * Get customer id.
196
-	 *
197
-	 * @since 1.0.19
198
-	 * @param  string $context View or edit context.
199
-	 * @return int
200
-	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
203
-	}
204
-
205
-	/**
206
-	 * Get customer information.
207
-	 *
208
-	 * @since 1.0.19
209
-	 * @param  string $context View or edit context.
210
-	 * @return WP_User|false WP_User object on success, false on failure.
211
-	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
214
-	}
215
-
216
-	/**
217
-	 * Get parent invoice id.
218
-	 *
219
-	 * @since 1.0.19
220
-	 * @param  string $context View or edit context.
221
-	 * @return int
222
-	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
225
-	}
226
-
227
-	/**
228
-	 * Alias for self::get_parent_invoice_id().
229
-	 *
230
-	 * @since 1.0.19
231
-	 * @param  string $context View or edit context.
232
-	 * @return int
233
-	 */
194
+    /**
195
+     * Get customer id.
196
+     *
197
+     * @since 1.0.19
198
+     * @param  string $context View or edit context.
199
+     * @return int
200
+     */
201
+    public function get_customer_id( $context = 'view' ) {
202
+        return (int) $this->get_prop( 'customer_id', $context );
203
+    }
204
+
205
+    /**
206
+     * Get customer information.
207
+     *
208
+     * @since 1.0.19
209
+     * @param  string $context View or edit context.
210
+     * @return WP_User|false WP_User object on success, false on failure.
211
+     */
212
+    public function get_customer( $context = 'view' ) {
213
+        return get_userdata( $this->get_customer_id( $context ) );
214
+    }
215
+
216
+    /**
217
+     * Get parent invoice id.
218
+     *
219
+     * @since 1.0.19
220
+     * @param  string $context View or edit context.
221
+     * @return int
222
+     */
223
+    public function get_parent_invoice_id( $context = 'view' ) {
224
+        return (int) $this->get_prop( 'parent_payment_id', $context );
225
+    }
226
+
227
+    /**
228
+     * Alias for self::get_parent_invoice_id().
229
+     *
230
+     * @since 1.0.19
231
+     * @param  string $context View or edit context.
232
+     * @return int
233
+     */
234 234
     public function get_parent_payment_id( $context = 'view' ) {
235 235
         return $this->get_parent_invoice_id( $context );
236
-	}
236
+    }
237 237
 
238
-	/**
238
+    /**
239 239
      * Alias for self::get_parent_invoice_id().
240 240
      *
241 241
      * @since  1.0.0
@@ -245,390 +245,390 @@  discard block
 block discarded – undo
245 245
         return $this->get_parent_invoice_id( $context );
246 246
     }
247 247
 
248
-	/**
249
-	 * Get parent invoice.
250
-	 *
251
-	 * @since 1.0.19
252
-	 * @param  string $context View or edit context.
253
-	 * @return WPInv_Invoice
254
-	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
-	}
258
-
259
-	/**
260
-	 * Alias for self::get_parent_invoice().
261
-	 *
262
-	 * @since 1.0.19
263
-	 * @param  string $context View or edit context.
264
-	 * @return WPInv_Invoice
265
-	 */
248
+    /**
249
+     * Get parent invoice.
250
+     *
251
+     * @since 1.0.19
252
+     * @param  string $context View or edit context.
253
+     * @return WPInv_Invoice
254
+     */
255
+    public function get_parent_invoice( $context = 'view' ) {
256
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
+    }
258
+
259
+    /**
260
+     * Alias for self::get_parent_invoice().
261
+     *
262
+     * @since 1.0.19
263
+     * @param  string $context View or edit context.
264
+     * @return WPInv_Invoice
265
+     */
266 266
     public function get_parent_payment( $context = 'view' ) {
267 267
         return $this->get_parent_invoice( $context );
268
-	}
269
-
270
-	/**
271
-	 * Get subscription's product id.
272
-	 *
273
-	 * @since 1.0.19
274
-	 * @param  string $context View or edit context.
275
-	 * @return int
276
-	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
279
-	}
280
-
281
-	/**
282
-	 * Get the subscription product.
283
-	 *
284
-	 * @since 1.0.19
285
-	 * @param  string $context View or edit context.
286
-	 * @return WPInv_Item
287
-	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
290
-	}
291
-
292
-	/**
293
-	 * Get parent invoice's gateway.
294
-	 *
295
-	 * Here for backwards compatibility.
296
-	 *
297
-	 * @since 1.0.19
298
-	 * @param  string $context View or edit context.
299
-	 * @return string
300
-	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
303
-	}
304
-
305
-	/**
306
-	 * Get the period of a renewal.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @param  string $context View or edit context.
310
-	 * @return string
311
-	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
314
-	}
315
-
316
-	/**
317
-	 * Get number of periods each renewal is valid for.
318
-	 *
319
-	 * @since 1.0.19
320
-	 * @param  string $context View or edit context.
321
-	 * @return int
322
-	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
325
-	}
326
-
327
-	/**
328
-	 * Get the initial amount for the subscription.
329
-	 *
330
-	 * @since 1.0.19
331
-	 * @param  string $context View or edit context.
332
-	 * @return float
333
-	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
-	}
337
-
338
-	/**
339
-	 * Get the recurring amount for the subscription.
340
-	 *
341
-	 * @since 1.0.19
342
-	 * @param  string $context View or edit context.
343
-	 * @return float
344
-	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
-	}
348
-
349
-	/**
350
-	 * Get number of times that this subscription can be renewed.
351
-	 *
352
-	 * @since 1.0.19
353
-	 * @param  string $context View or edit context.
354
-	 * @return int
355
-	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
358
-	}
359
-
360
-	/**
361
-	 * Get transaction id of this subscription's parent invoice.
362
-	 *
363
-	 * @since 1.0.19
364
-	 * @param  string $context View or edit context.
365
-	 * @return string
366
-	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
369
-	}
370
-
371
-	/**
372
-	 * Get the date that the subscription was created.
373
-	 *
374
-	 * @since 1.0.19
375
-	 * @param  string $context View or edit context.
376
-	 * @return string
377
-	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
380
-	}
381
-
382
-	/**
383
-	 * Alias for self::get_created().
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $context View or edit context.
387
-	 * @return string
388
-	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
391
-	}
392
-
393
-	/**
394
-	 * Retrieves the creation date in a timestamp
395
-	 *
396
-	 * @since  1.0.0
397
-	 * @return int
398
-	 */
399
-	public function get_time_created() {
400
-		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
-	}
403
-
404
-	/**
405
-	 * Get GMT date when the subscription was created.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @param  string $context View or edit context.
409
-	 * @return string
410
-	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
268
+    }
269
+
270
+    /**
271
+     * Get subscription's product id.
272
+     *
273
+     * @since 1.0.19
274
+     * @param  string $context View or edit context.
275
+     * @return int
276
+     */
277
+    public function get_product_id( $context = 'view' ) {
278
+        return (int) $this->get_prop( 'product_id', $context );
279
+    }
280
+
281
+    /**
282
+     * Get the subscription product.
283
+     *
284
+     * @since 1.0.19
285
+     * @param  string $context View or edit context.
286
+     * @return WPInv_Item
287
+     */
288
+    public function get_product( $context = 'view' ) {
289
+        return new WPInv_Item( $this->get_product_id( $context ) );
290
+    }
291
+
292
+    /**
293
+     * Get parent invoice's gateway.
294
+     *
295
+     * Here for backwards compatibility.
296
+     *
297
+     * @since 1.0.19
298
+     * @param  string $context View or edit context.
299
+     * @return string
300
+     */
301
+    public function get_gateway( $context = 'view' ) {
302
+        return $this->get_parent_invoice( $context )->get_gateway();
303
+    }
304
+
305
+    /**
306
+     * Get the period of a renewal.
307
+     *
308
+     * @since 1.0.19
309
+     * @param  string $context View or edit context.
310
+     * @return string
311
+     */
312
+    public function get_period( $context = 'view' ) {
313
+        return $this->get_prop( 'period', $context );
314
+    }
315
+
316
+    /**
317
+     * Get number of periods each renewal is valid for.
318
+     *
319
+     * @since 1.0.19
320
+     * @param  string $context View or edit context.
321
+     * @return int
322
+     */
323
+    public function get_frequency( $context = 'view' ) {
324
+        return (int) $this->get_prop( 'frequency', $context );
325
+    }
326
+
327
+    /**
328
+     * Get the initial amount for the subscription.
329
+     *
330
+     * @since 1.0.19
331
+     * @param  string $context View or edit context.
332
+     * @return float
333
+     */
334
+    public function get_initial_amount( $context = 'view' ) {
335
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
+    }
337
+
338
+    /**
339
+     * Get the recurring amount for the subscription.
340
+     *
341
+     * @since 1.0.19
342
+     * @param  string $context View or edit context.
343
+     * @return float
344
+     */
345
+    public function get_recurring_amount( $context = 'view' ) {
346
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
+    }
348
+
349
+    /**
350
+     * Get number of times that this subscription can be renewed.
351
+     *
352
+     * @since 1.0.19
353
+     * @param  string $context View or edit context.
354
+     * @return int
355
+     */
356
+    public function get_bill_times( $context = 'view' ) {
357
+        return (int) $this->get_prop( 'bill_times', $context );
358
+    }
359
+
360
+    /**
361
+     * Get transaction id of this subscription's parent invoice.
362
+     *
363
+     * @since 1.0.19
364
+     * @param  string $context View or edit context.
365
+     * @return string
366
+     */
367
+    public function get_transaction_id( $context = 'view' ) {
368
+        return $this->get_prop( 'transaction_id', $context );
369
+    }
370
+
371
+    /**
372
+     * Get the date that the subscription was created.
373
+     *
374
+     * @since 1.0.19
375
+     * @param  string $context View or edit context.
376
+     * @return string
377
+     */
378
+    public function get_created( $context = 'view' ) {
379
+        return $this->get_prop( 'created', $context );
380
+    }
381
+
382
+    /**
383
+     * Alias for self::get_created().
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $context View or edit context.
387
+     * @return string
388
+     */
389
+    public function get_date_created( $context = 'view' ) {
390
+        return $this->get_created( $context );
391
+    }
392
+
393
+    /**
394
+     * Retrieves the creation date in a timestamp
395
+     *
396
+     * @since  1.0.0
397
+     * @return int
398
+     */
399
+    public function get_time_created() {
400
+        $created = $this->get_date_created();
401
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
+    }
403
+
404
+    /**
405
+     * Get GMT date when the subscription was created.
406
+     *
407
+     * @since 1.0.19
408
+     * @param  string $context View or edit context.
409
+     * @return string
410
+     */
411
+    public function get_date_created_gmt( $context = 'view' ) {
412 412
         $date = $this->get_date_created( $context );
413 413
 
414 414
         if ( $date ) {
415 415
             $date = get_gmt_from_date( $date );
416 416
         }
417
-		return $date;
418
-	}
419
-
420
-	/**
421
-	 * Get the date that the subscription will renew.
422
-	 *
423
-	 * @since 1.0.19
424
-	 * @param  string $context View or edit context.
425
-	 * @return string
426
-	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
429
-	}
430
-
431
-	/**
432
-	 * Alias for self::get_next_renewal_date().
433
-	 *
434
-	 * @since 1.0.19
435
-	 * @param  string $context View or edit context.
436
-	 * @return string
437
-	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
440
-	}
441
-
442
-	/**
443
-	 * Retrieves the expiration date in a timestamp
444
-	 *
445
-	 * @since  1.0.0
446
-	 * @return int
447
-	 */
448
-	public function get_expiration_time() {
449
-		$expiration = $this->get_expiration();
450
-
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
453
-		}
454
-
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
-	}
458
-
459
-	/**
460
-	 * Get GMT date when the subscription will renew.
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
417
+        return $date;
418
+    }
419
+
420
+    /**
421
+     * Get the date that the subscription will renew.
422
+     *
423
+     * @since 1.0.19
424
+     * @param  string $context View or edit context.
425
+     * @return string
426
+     */
427
+    public function get_next_renewal_date( $context = 'view' ) {
428
+        return $this->get_prop( 'expiration', $context );
429
+    }
430
+
431
+    /**
432
+     * Alias for self::get_next_renewal_date().
433
+     *
434
+     * @since 1.0.19
435
+     * @param  string $context View or edit context.
436
+     * @return string
437
+     */
438
+    public function get_expiration( $context = 'view' ) {
439
+        return $this->get_next_renewal_date( $context );
440
+    }
441
+
442
+    /**
443
+     * Retrieves the expiration date in a timestamp
444
+     *
445
+     * @since  1.0.0
446
+     * @return int
447
+     */
448
+    public function get_expiration_time() {
449
+        $expiration = $this->get_expiration();
450
+
451
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
+            return current_time( 'timestamp' );
453
+        }
454
+
455
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
+    }
458
+
459
+    /**
460
+     * Get GMT date when the subscription will renew.
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
467 467
         $date = $this->get_next_renewal_date( $context );
468 468
 
469 469
         if ( $date ) {
470 470
             $date = get_gmt_from_date( $date );
471 471
         }
472
-		return $date;
473
-	}
474
-
475
-	/**
476
-	 * Get the subscription's trial period.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
484
-	}
485
-
486
-	/**
487
-	 * Get the subscription's status.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
495
-	}
496
-
497
-	/**
498
-	 * Get the subscription's profile id.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
506
-	}
507
-
508
-	/*
472
+        return $date;
473
+    }
474
+
475
+    /**
476
+     * Get the subscription's trial period.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_trial_period( $context = 'view' ) {
483
+        return $this->get_prop( 'trial_period', $context );
484
+    }
485
+
486
+    /**
487
+     * Get the subscription's status.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_status( $context = 'view' ) {
494
+        return $this->get_prop( 'status', $context );
495
+    }
496
+
497
+    /**
498
+     * Get the subscription's profile id.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_profile_id( $context = 'view' ) {
505
+        return $this->get_prop( 'profile_id', $context );
506
+    }
507
+
508
+    /*
509 509
 	|--------------------------------------------------------------------------
510 510
 	| Setters
511 511
 	|--------------------------------------------------------------------------
512 512
 	*/
513 513
 
514
-	/**
515
-	 * Set customer id.
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param  int $value The customer's id.
519
-	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
522
-	}
523
-
524
-	/**
525
-	 * Set parent invoice id.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  int $value The parent invoice id.
529
-	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
532
-	}
533
-
534
-	/**
535
-	 * Alias for self::set_parent_invoice_id().
536
-	 *
537
-	 * @since 1.0.19
538
-	 * @param  int $value The parent invoice id.
539
-	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
542
-	}
514
+    /**
515
+     * Set customer id.
516
+     *
517
+     * @since 1.0.19
518
+     * @param  int $value The customer's id.
519
+     */
520
+    public function set_customer_id( $value ) {
521
+        $this->set_prop( 'customer_id', (int) $value );
522
+    }
523
+
524
+    /**
525
+     * Set parent invoice id.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  int $value The parent invoice id.
529
+     */
530
+    public function set_parent_invoice_id( $value ) {
531
+        $this->set_prop( 'parent_payment_id', (int) $value );
532
+    }
533
+
534
+    /**
535
+     * Alias for self::set_parent_invoice_id().
536
+     *
537
+     * @since 1.0.19
538
+     * @param  int $value The parent invoice id.
539
+     */
540
+    public function set_parent_payment_id( $value ) {
541
+        $this->set_parent_invoice_id( $value );
542
+    }
543
+
544
+    /**
545
+     * Alias for self::set_parent_invoice_id().
546
+     *
547
+     * @since 1.0.19
548
+     * @param  int $value The parent invoice id.
549
+     */
550
+    public function set_original_payment_id( $value ) {
551
+        $this->set_parent_invoice_id( $value );
552
+    }
553
+
554
+    /**
555
+     * Set subscription's product id.
556
+     *
557
+     * @since 1.0.19
558
+     * @param  int $value The subscription product id.
559
+     */
560
+    public function set_product_id( $value ) {
561
+        $this->set_prop( 'product_id', (int) $value );
562
+    }
563
+
564
+    /**
565
+     * Set the period of a renewal.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $value The renewal period.
569
+     */
570
+    public function set_period( $value ) {
571
+        $this->set_prop( 'period', $value );
572
+    }
573
+
574
+    /**
575
+     * Set number of periods each renewal is valid for.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  int $value The subscription frequency.
579
+     */
580
+    public function set_frequency( $value ) {
581
+        $value = empty( $value ) ? 1 : (int) $value;
582
+        $this->set_prop( 'frequency', absint( $value ) );
583
+    }
584
+
585
+    /**
586
+     * Set the initial amount for the subscription.
587
+     *
588
+     * @since 1.0.19
589
+     * @param  float $value The initial subcription amount.
590
+     */
591
+    public function set_initial_amount( $value ) {
592
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
+    }
594
+
595
+    /**
596
+     * Set the recurring amount for the subscription.
597
+     *
598
+     * @since 1.0.19
599
+     * @param  float $value The recurring subcription amount.
600
+     */
601
+    public function set_recurring_amount( $value ) {
602
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
+    }
604
+
605
+    /**
606
+     * Set number of times that this subscription can be renewed.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  int $value Bill times.
610
+     */
611
+    public function set_bill_times( $value ) {
612
+        $this->set_prop( 'bill_times', (int) $value );
613
+    }
614
+
615
+    /**
616
+     * Get transaction id of this subscription's parent invoice.
617
+     *
618
+     * @since 1.0.19
619
+     * @param string $value Bill times.
620
+     */
621
+    public function set_transaction_id( $value ) {
622
+        $this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
+    }
543 624
 
544
-	/**
545
-     * Alias for self::set_parent_invoice_id().
625
+    /**
626
+     * Set date when this subscription started.
546 627
      *
547 628
      * @since 1.0.19
548
-	 * @param  int $value The parent invoice id.
629
+     * @param string $value strtotime compliant date.
549 630
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
552
-	}
553
-
554
-	/**
555
-	 * Set subscription's product id.
556
-	 *
557
-	 * @since 1.0.19
558
-	 * @param  int $value The subscription product id.
559
-	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
562
-	}
563
-
564
-	/**
565
-	 * Set the period of a renewal.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $value The renewal period.
569
-	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
572
-	}
573
-
574
-	/**
575
-	 * Set number of periods each renewal is valid for.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  int $value The subscription frequency.
579
-	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
583
-	}
584
-
585
-	/**
586
-	 * Set the initial amount for the subscription.
587
-	 *
588
-	 * @since 1.0.19
589
-	 * @param  float $value The initial subcription amount.
590
-	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
-	}
594
-
595
-	/**
596
-	 * Set the recurring amount for the subscription.
597
-	 *
598
-	 * @since 1.0.19
599
-	 * @param  float $value The recurring subcription amount.
600
-	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
-	}
604
-
605
-	/**
606
-	 * Set number of times that this subscription can be renewed.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  int $value Bill times.
610
-	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
613
-	}
614
-
615
-	/**
616
-	 * Get transaction id of this subscription's parent invoice.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @param string $value Bill times.
620
-	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
-	}
624
-
625
-	/**
626
-	 * Set date when this subscription started.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param string $value strtotime compliant date.
630
-	 */
631
-	public function set_created( $value ) {
631
+    public function set_created( $value ) {
632 632
         $date = strtotime( $value );
633 633
 
634 634
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -636,93 +636,93 @@  discard block
 block discarded – undo
636 636
             return;
637 637
         }
638 638
 
639
-		$this->set_prop( 'created', '' );
639
+        $this->set_prop( 'created', '' );
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
644
-	 * Alias for self::set_created().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param string $value strtotime compliant date.
648
-	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
643
+    /**
644
+     * Alias for self::set_created().
645
+     *
646
+     * @since 1.0.19
647
+     * @param string $value strtotime compliant date.
648
+     */
649
+    public function set_date_created( $value ) {
650
+        $this->set_created( $value );
651 651
     }
652 652
 
653
-	/**
654
-	 * Set the date that the subscription will renew.
655
-	 *
656
-	 * @since 1.0.19
657
-	 * @param string $value strtotime compliant date.
658
-	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
653
+    /**
654
+     * Set the date that the subscription will renew.
655
+     *
656
+     * @since 1.0.19
657
+     * @param string $value strtotime compliant date.
658
+     */
659
+    public function set_next_renewal_date( $value ) {
660
+        $date = strtotime( $value );
661 661
 
662 662
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
663 663
             $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
664 664
             return;
665
-		}
666
-
667
-		$this->set_prop( 'expiration', '' );
668
-
669
-	}
670
-
671
-	/**
672
-	 * Alias for self::set_next_renewal_date().
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param string $value strtotime compliant date.
676
-	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
679
-    }
680
-
681
-	/**
682
-	 * Set the subscription's trial period.
683
-	 *
684
-	 * @since 1.0.19
685
-	 * @param string $value trial period e.g 1 year.
686
-	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
689
-	}
690
-
691
-	/**
692
-	 * Set the subscription's status.
693
-	 *
694
-	 * @since 1.0.19
695
-	 * @param string $new_status    New subscription status.
696
-	 */
697
-	public function set_status( $new_status ) {
698
-
699
-		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
701
-			return;
702
-		}
703
-
704
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
-		if ( true === $this->object_read && $old_status !== $new_status ) {
706
-			$this->status_transition = array(
707
-				'from' => $old_status,
708
-				'to'   => $new_status,
709
-			);
710
-		}
711
-
712
-		$this->set_prop( 'status', $new_status );
713
-	}
714
-
715
-	/**
716
-	 * Set the subscription's (remote) profile id.
717
-	 *
718
-	 * @since 1.0.19
719
-	 * @param  string $value the remote profile id.
720
-	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
-	}
724
-
725
-	/*
665
+        }
666
+
667
+        $this->set_prop( 'expiration', '' );
668
+
669
+    }
670
+
671
+    /**
672
+     * Alias for self::set_next_renewal_date().
673
+     *
674
+     * @since 1.0.19
675
+     * @param string $value strtotime compliant date.
676
+     */
677
+    public function set_expiration( $value ) {
678
+        $this->set_next_renewal_date( $value );
679
+    }
680
+
681
+    /**
682
+     * Set the subscription's trial period.
683
+     *
684
+     * @since 1.0.19
685
+     * @param string $value trial period e.g 1 year.
686
+     */
687
+    public function set_trial_period( $value ) {
688
+        $this->set_prop( 'trial_period', $value );
689
+    }
690
+
691
+    /**
692
+     * Set the subscription's status.
693
+     *
694
+     * @since 1.0.19
695
+     * @param string $new_status    New subscription status.
696
+     */
697
+    public function set_status( $new_status ) {
698
+
699
+        // Abort if this is not a valid status;
700
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
701
+            return;
702
+        }
703
+
704
+        $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
+        if ( true === $this->object_read && $old_status !== $new_status ) {
706
+            $this->status_transition = array(
707
+                'from' => $old_status,
708
+                'to'   => $new_status,
709
+            );
710
+        }
711
+
712
+        $this->set_prop( 'status', $new_status );
713
+    }
714
+
715
+    /**
716
+     * Set the subscription's (remote) profile id.
717
+     *
718
+     * @since 1.0.19
719
+     * @param  string $value the remote profile id.
720
+     */
721
+    public function set_profile_id( $value ) {
722
+        $this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
+    }
724
+
725
+    /*
726 726
 	|--------------------------------------------------------------------------
727 727
 	| Boolean methods
728 728
 	|--------------------------------------------------------------------------
@@ -731,55 +731,55 @@  discard block
 block discarded – undo
731 731
 	|
732 732
 	*/
733 733
 
734
-	/**
734
+    /**
735 735
      * Checks if the subscription has a given status.
736
-	 *
737
-	 * @param string|array String or array of strings to check for.
738
-	 * @return bool
736
+     *
737
+     * @param string|array String or array of strings to check for.
738
+     * @return bool
739 739
      */
740 740
     public function has_status( $status ) {
741 741
         return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
742
-	}
742
+    }
743 743
 
744
-	/**
744
+    /**
745 745
      * Checks if the subscription has a trial period.
746
-	 *
747
-	 * @return bool
746
+     *
747
+     * @return bool
748 748
      */
749 749
     public function has_trial_period() {
750
-		$period = $this->get_trial_period();
750
+        $period = $this->get_trial_period();
751 751
         return ! empty( $period );
752
-	}
753
-
754
-	/**
755
-	 * Is the subscription active?
756
-	 *
757
-	 * @return bool
758
-	 */
759
-	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
-	}
762
-
763
-	/**
764
-	 * Is the subscription expired?
765
-	 *
766
-	 * @return bool
767
-	 */
768
-	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
-	}
771
-
772
-	/**
773
-	 * Is this the last renewals?
774
-	 *
775
-	 * @return bool
776
-	 */
777
-	public function is_last_renewal() {
778
-		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
-	}
781
-
782
-	/*
752
+    }
753
+
754
+    /**
755
+     * Is the subscription active?
756
+     *
757
+     * @return bool
758
+     */
759
+    public function is_active() {
760
+        return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
+    }
762
+
763
+    /**
764
+     * Is the subscription expired?
765
+     *
766
+     * @return bool
767
+     */
768
+    public function is_expired() {
769
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
+    }
771
+
772
+    /**
773
+     * Is this the last renewals?
774
+     *
775
+     * @return bool
776
+     */
777
+    public function is_last_renewal() {
778
+        $max_bills = $this->get_bill_times();
779
+        return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
+    }
781
+
782
+    /*
783 783
 	|--------------------------------------------------------------------------
784 784
 	| Additional methods
785 785
 	|--------------------------------------------------------------------------
@@ -788,27 +788,27 @@  discard block
 block discarded – undo
788 788
 	|
789 789
 	*/
790 790
 
791
-	/**
792
-	 * Backwards compatibilty.
793
-	 */
794
-	public function create( $data = array() ) {
791
+    /**
792
+     * Backwards compatibilty.
793
+     */
794
+    public function create( $data = array() ) {
795 795
 
796
-		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
799
-		}
796
+        // Set the properties.
797
+        if ( is_array( $data ) ) {
798
+            $this->set_props( $data );
799
+        }
800 800
 
801
-		// Save the item.
802
-		return $this->save();
801
+        // Save the item.
802
+        return $this->save();
803 803
 
804
-	}
804
+    }
805 805
 
806
-	/**
807
-	 * Backwards compatibilty.
808
-	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
811
-	}
806
+    /**
807
+     * Backwards compatibilty.
808
+     */
809
+    public function update( $args = array() ) {
810
+        return $this->create( $args );
811
+    }
812 812
 
813 813
     /**
814 814
      * Retrieve renewal payments for a subscription
@@ -818,22 +818,22 @@  discard block
 block discarded – undo
818 818
      */
819 819
     public function get_child_payments( $hide_pending = true ) {
820 820
 
821
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
821
+        $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
822 822
 
823
-		if ( ! $hide_pending ) {
824
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
825
-		}
823
+        if ( ! $hide_pending ) {
824
+            $statuses = array_keys( wpinv_get_invoice_statuses() );
825
+        }
826 826
 
827 827
         return get_posts(
828
-			array(
829
-            	'post_parent' => $this->get_parent_payment_id(),
830
-            	'numberposts' => -1,
831
-            	'post_status' => $statuses,
832
-            	'orderby'     => 'ID',
833
-            	'order'       => 'ASC',
834
-            	'post_type'   => 'wpi_invoice',
835
-			)
836
-		);
828
+            array(
829
+                'post_parent' => $this->get_parent_payment_id(),
830
+                'numberposts' => -1,
831
+                'post_status' => $statuses,
832
+                'orderby'     => 'ID',
833
+                'order'       => 'ASC',
834
+                'post_type'   => 'wpi_invoice',
835
+            )
836
+        );
837 837
     }
838 838
 
839 839
     /**
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return int
844 844
      */
845 845
     public function get_total_payments() {
846
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
846
+        return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
847 847
     }
848 848
 
849 849
     /**
@@ -867,202 +867,202 @@  discard block
 block discarded – undo
867 867
      *
868 868
      * @since  2.4
869 869
      * @param  array $args Array of values for the payment, including amount and transaction ID
870
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
870
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873 873
     public function add_payment( $args = array(), $invoice = false ) {
874 874
 
875
-		// Process each payment once.
875
+        // Process each payment once.
876 876
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
877 877
             return false;
878 878
         }
879 879
 
880
-		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
880
+        // Are we creating a new invoice?
881
+        if ( empty( $invoice ) ) {
882
+            $invoice = $this->create_payment( false );
883 883
 
884
-			if ( empty( $invoice ) ) {
885
-				return false;
886
-			}
887
-		}
884
+            if ( empty( $invoice ) ) {
885
+                return false;
886
+            }
887
+        }
888 888
 
889
-		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
892
-		}
889
+        // Maybe set a transaction id.
890
+        if ( ! empty( $args['transaction_id'] ) ) {
891
+            $invoice->set_transaction_id( $args['transaction_id'] );
892
+        }
893 893
 
894
-		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
894
+        // Set the completed date.
895
+        $invoice->set_completed_date( current_time( 'mysql' ) );
896 896
 
897
-		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
900
-		}
897
+        // And the gateway.
898
+        if ( ! empty( $args['gateway'] ) ) {
899
+            $invoice->set_gateway( $args['gateway'] );
900
+        }
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
903
-		$invoice->save();
902
+        $invoice->set_status( 'wpi-renewal' );
903
+        $invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
906
-			return false;
907
-		}
905
+        if ( ! $invoice->exists() ) {
906
+            return false;
907
+        }
908 908
 
909
-		return $this->after_add_payment( $invoice );
910
-	}
909
+        return $this->after_add_payment( $invoice );
910
+    }
911 911
 
912 912
     public function after_add_payment( $invoice ) {
913 913
 
914
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
914
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916 916
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
917 917
 
918 918
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
919 919
 
920 920
         return $invoice->get_id();
921
-	}
921
+    }
922 922
 
923
-	/**
923
+    /**
924 924
      * Creates a new invoice and returns it.
925 925
      *
926 926
      * @since  1.0.19
927
-	 * @param bool $save Whether we should save the invoice.
927
+     * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930 930
     public function create_payment( $save = true ) {
931 931
 
932
-		$parent_invoice = $this->get_parent_payment();
933
-
934
-		if ( ! $parent_invoice->exists() ) {
935
-			return false;
936
-		}
937
-
938
-		// Duplicate the parent invoice.
939
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
940
-		$invoice->set_parent_id( $parent_invoice->get_id() );
941
-		$invoice->set_subscription_id( $this->get_id() );
942
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
943
-
944
-		// Set invoice items.
945
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
947
-		$invoice_items      = array();
948
-
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
951
-				$invoice_items[] = $item;
952
-			}
953
-		}
954
-
955
-		$invoice->set_items( $invoice_items );
956
-
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
959
-		}
960
-
961
-		// Maybe recalculate discount (Pre-GetPaid Fix).
962
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
963
-
964
-		if ( $discount->exists() && $discount->is_recurring() ) {
965
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
967
-			// Unset discount code.
968
-			$invoice->set_discount_code( '' );
969
-
970
-			$invoice->remove_discount( 'discount_code' );
971
-		}
972
-
973
-		$invoice->recalculate_total();
974
-		$invoice->set_status( 'wpi-pending' );
975
-
976
-		if ( ! $save ) {
977
-			return $invoice;
978
-		}
979
-
980
-		$invoice->save();
981
-
982
-		return $invoice->exists() ? $invoice : false;
983
-    }
984
-
985
-	/**
986
-	 * Renews or completes a subscription
987
-	 *
988
-	 * @since  1.0.0
989
-	 * @return int The subscription's id
990
-	 */
991
-	public function renew( $calculate_from = null, $_new_expiration = null ) {
992
-		// Complete subscription if applicable
993
-		if ( $this->is_last_renewal() ) {
994
-			return $this->complete();
995
-		}
996
-
997
-		if ( ! empty( $_new_expiration ) ) {
998
-			$new_expiration = $_new_expiration;
999
-		} else {
1000
-			// Calculate new expiration
1001
-			$frequency      = $this->get_frequency();
1002
-			$period         = $this->get_period();
1003
-			$calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
-			$new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
-			$new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1006
-		}
1007
-
1008
-		$this->set_expiration( $new_expiration );
1009
-		$this->set_status( 'active' );
1010
-		$this->save();
1011
-
1012
-		do_action( 'getpaid_subscription_renewed', $this );
1013
-
1014
-		return $this->get_id();
1015
-	}
1016
-
1017
-	/**
1018
-	 * Marks a subscription as completed
1019
-	 *
1020
-	 * Subscription is completed when the number of payments matches the billing_times field
1021
-	 *
1022
-	 * @since  1.0.0
1023
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
1024
-	 */
1025
-	public function complete() {
1026
-
1027
-		// Only mark a subscription as complete if it's not already cancelled.
1028
-		if ( $this->has_status( 'cancelled' ) ) {
1029
-			return false;
1030
-		}
1031
-
1032
-		$this->set_status( 'completed' );
1033
-		return $this->save();
1034
-
1035
-	}
1036
-
1037
-	/**
1038
-	 * Marks a subscription as expired
1039
-	 *
1040
-	 * @since  1.0.0
1041
-	 * @param  bool $check_expiration
1042
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043
-	 */
1044
-	public function expire( $check_expiration = false ) {
1045
-
1046
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1047
-			// Do not mark as expired since real expiration date is in the future
1048
-			return false;
1049
-		}
1050
-
1051
-		$this->set_status( 'expired' );
1052
-		return $this->save();
1053
-
1054
-	}
1055
-
1056
-	/**
1057
-	 * Marks a subscription as failing
1058
-	 *
1059
-	 * @since  2.4.2
1060
-	 * @return int Subscription id.
1061
-	 */
1062
-	public function failing() {
1063
-		$this->set_status( 'failing' );
1064
-		return $this->save();
1065
-	}
932
+        $parent_invoice = $this->get_parent_payment();
933
+
934
+        if ( ! $parent_invoice->exists() ) {
935
+            return false;
936
+        }
937
+
938
+        // Duplicate the parent invoice.
939
+        $invoice = getpaid_duplicate_invoice( $parent_invoice );
940
+        $invoice->set_parent_id( $parent_invoice->get_id() );
941
+        $invoice->set_subscription_id( $this->get_id() );
942
+        $invoice->set_remote_subscription_id( $this->get_profile_id() );
943
+
944
+        // Set invoice items.
945
+        $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
+        $allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
947
+        $invoice_items      = array();
948
+
949
+        foreach ( $invoice->get_items() as $item ) {
950
+            if ( in_array( $item->get_id(), $allowed_items ) ) {
951
+                $invoice_items[] = $item;
952
+            }
953
+        }
954
+
955
+        $invoice->set_items( $invoice_items );
956
+
957
+        if ( ! empty( $subscription_group['fees'] ) ) {
958
+            $invoice->set_fees( $subscription_group['fees'] );
959
+        }
960
+
961
+        // Maybe recalculate discount (Pre-GetPaid Fix).
962
+        $discount = new WPInv_Discount( $invoice->get_discount_code() );
963
+
964
+        if ( $discount->exists() && $discount->is_recurring() ) {
965
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
+        }  else {
967
+            // Unset discount code.
968
+            $invoice->set_discount_code( '' );
969
+
970
+            $invoice->remove_discount( 'discount_code' );
971
+        }
972
+
973
+        $invoice->recalculate_total();
974
+        $invoice->set_status( 'wpi-pending' );
975
+
976
+        if ( ! $save ) {
977
+            return $invoice;
978
+        }
979
+
980
+        $invoice->save();
981
+
982
+        return $invoice->exists() ? $invoice : false;
983
+    }
984
+
985
+    /**
986
+     * Renews or completes a subscription
987
+     *
988
+     * @since  1.0.0
989
+     * @return int The subscription's id
990
+     */
991
+    public function renew( $calculate_from = null, $_new_expiration = null ) {
992
+        // Complete subscription if applicable
993
+        if ( $this->is_last_renewal() ) {
994
+            return $this->complete();
995
+        }
996
+
997
+        if ( ! empty( $_new_expiration ) ) {
998
+            $new_expiration = $_new_expiration;
999
+        } else {
1000
+            // Calculate new expiration
1001
+            $frequency      = $this->get_frequency();
1002
+            $period         = $this->get_period();
1003
+            $calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
+            $new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
+            $new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1006
+        }
1007
+
1008
+        $this->set_expiration( $new_expiration );
1009
+        $this->set_status( 'active' );
1010
+        $this->save();
1011
+
1012
+        do_action( 'getpaid_subscription_renewed', $this );
1013
+
1014
+        return $this->get_id();
1015
+    }
1016
+
1017
+    /**
1018
+     * Marks a subscription as completed
1019
+     *
1020
+     * Subscription is completed when the number of payments matches the billing_times field
1021
+     *
1022
+     * @since  1.0.0
1023
+     * @return int|bool Subscription id or false if the subscription is cancelled.
1024
+     */
1025
+    public function complete() {
1026
+
1027
+        // Only mark a subscription as complete if it's not already cancelled.
1028
+        if ( $this->has_status( 'cancelled' ) ) {
1029
+            return false;
1030
+        }
1031
+
1032
+        $this->set_status( 'completed' );
1033
+        return $this->save();
1034
+
1035
+    }
1036
+
1037
+    /**
1038
+     * Marks a subscription as expired
1039
+     *
1040
+     * @since  1.0.0
1041
+     * @param  bool $check_expiration
1042
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043
+     */
1044
+    public function expire( $check_expiration = false ) {
1045
+
1046
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1047
+            // Do not mark as expired since real expiration date is in the future
1048
+            return false;
1049
+        }
1050
+
1051
+        $this->set_status( 'expired' );
1052
+        return $this->save();
1053
+
1054
+    }
1055
+
1056
+    /**
1057
+     * Marks a subscription as failing
1058
+     *
1059
+     * @since  2.4.2
1060
+     * @return int Subscription id.
1061
+     */
1062
+    public function failing() {
1063
+        $this->set_status( 'failing' );
1064
+        return $this->save();
1065
+    }
1066 1066
 
1067 1067
     /**
1068 1068
      * Marks a subscription as cancelled
@@ -1071,19 +1071,19 @@  discard block
 block discarded – undo
1071 1071
      * @return int Subscription id.
1072 1072
      */
1073 1073
     public function cancel() {
1074
-		$this->set_status( 'cancelled' );
1075
-		return $this->save();
1074
+        $this->set_status( 'cancelled' );
1075
+        return $this->save();
1076 1076
     }
1077 1077
 
1078
-	/**
1079
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1080
-	 *
1081
-	 * @since  1.0.0
1082
-	 * @return bool
1083
-	 */
1084
-	public function can_cancel() {
1085
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1086
-	}
1078
+    /**
1079
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1080
+     *
1081
+     * @since  1.0.0
1082
+     * @return bool
1083
+     */
1084
+    public function can_cancel() {
1085
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1086
+    }
1087 1087
 
1088 1088
     /**
1089 1089
      * Returns an array of subscription statuses that can be cancelled
@@ -1096,109 +1096,109 @@  discard block
 block discarded – undo
1096 1096
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1097 1097
     }
1098 1098
 
1099
-	/**
1100
-	 * Retrieves the URL to cancel subscription
1101
-	 *
1102
-	 * @since  1.0.0
1103
-	 * @return string
1104
-	 */
1105
-	public function get_cancel_url() {
1106
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1108
-	}
1109
-
1110
-	/**
1111
-	 * Retrieves the URL to view a subscription
1112
-	 *
1113
-	 * @since  1.0.19
1114
-	 * @return string
1115
-	 */
1116
-	public function get_view_url() {
1117
-
1118
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1120
-
1121
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1122
-	}
1123
-
1124
-	/**
1125
-	 * Determines if subscription can be manually renewed
1126
-	 *
1127
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1128
-	 * that can be renewed manually
1129
-	 *
1130
-	 * @since  2.5
1131
-	 * @return bool
1132
-	 */
1133
-	public function can_renew() {
1134
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1135
-	}
1136
-
1137
-	/**
1138
-	 * Retrieves the URL to renew a subscription
1139
-	 *
1140
-	 * @since  2.5
1141
-	 * @return string
1142
-	 */
1143
-	public function get_renew_url() {
1144
-		$url = wp_nonce_url(
1099
+    /**
1100
+     * Retrieves the URL to cancel subscription
1101
+     *
1102
+     * @since  1.0.0
1103
+     * @return string
1104
+     */
1105
+    public function get_cancel_url() {
1106
+        $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1108
+    }
1109
+
1110
+    /**
1111
+     * Retrieves the URL to view a subscription
1112
+     *
1113
+     * @since  1.0.19
1114
+     * @return string
1115
+     */
1116
+    public function get_view_url() {
1117
+
1118
+        $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
+        $url = add_query_arg( 'subscription', $this->get_id(), $url );
1120
+
1121
+        return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1122
+    }
1123
+
1124
+    /**
1125
+     * Determines if subscription can be manually renewed
1126
+     *
1127
+     * This method is filtered by payment gateways in order to return true on subscriptions
1128
+     * that can be renewed manually
1129
+     *
1130
+     * @since  2.5
1131
+     * @return bool
1132
+     */
1133
+    public function can_renew() {
1134
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1135
+    }
1136
+
1137
+    /**
1138
+     * Retrieves the URL to renew a subscription
1139
+     *
1140
+     * @since  2.5
1141
+     * @return string
1142
+     */
1143
+    public function get_renew_url() {
1144
+        $url = wp_nonce_url(
1145 1145
             add_query_arg(
1146 1146
                 array(
1147
-					'getpaid-action' => 'renew_subscription',
1148
-					'sub_id'         => $this->get_id,
1147
+                    'getpaid-action' => 'renew_subscription',
1148
+                    'sub_id'         => $this->get_id,
1149 1149
                 )
1150 1150
             ),
1151 1151
             'getpaid-nonce'
1152 1152
         );
1153
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1154
-	}
1155
-
1156
-	/**
1157
-	 * Determines if subscription can have their payment method updated
1158
-	 *
1159
-	 * @since  1.0.0
1160
-	 * @return bool
1161
-	 */
1162
-	public function can_update() {
1163
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1164
-	}
1165
-
1166
-	/**
1167
-	 * Retrieves the URL to update subscription
1168
-	 *
1169
-	 * @since  1.0.0
1170
-	 * @return string
1171
-	 */
1172
-	public function get_update_url() {
1173
-		$url = add_query_arg(
1153
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1154
+    }
1155
+
1156
+    /**
1157
+     * Determines if subscription can have their payment method updated
1158
+     *
1159
+     * @since  1.0.0
1160
+     * @return bool
1161
+     */
1162
+    public function can_update() {
1163
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1164
+    }
1165
+
1166
+    /**
1167
+     * Retrieves the URL to update subscription
1168
+     *
1169
+     * @since  1.0.0
1170
+     * @return string
1171
+     */
1172
+    public function get_update_url() {
1173
+        $url = add_query_arg(
1174 1174
             array(
1175
-				'action'          => 'update',
1176
-				'subscription_id' => $this->get_id(),
1175
+                'action'          => 'update',
1176
+                'subscription_id' => $this->get_id(),
1177 1177
             )
1178 1178
         );
1179
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1180
-	}
1181
-
1182
-	/**
1183
-	 * Retrieves the subscription status label
1184
-	 *
1185
-	 * @since  1.0.0
1186
-	 * @return string
1187
-	 */
1188
-	public function get_status_label() {
1189
-		return getpaid_get_subscription_status_label( $this->get_status() );
1190
-	}
1191
-
1192
-	/**
1193
-	 * Retrieves the subscription status class
1194
-	 *
1195
-	 * @since  1.0.19
1196
-	 * @return string
1197
-	 */
1198
-	public function get_status_class() {
1199
-		$statuses = getpaid_get_subscription_status_classes();
1200
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1201
-	}
1179
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1180
+    }
1181
+
1182
+    /**
1183
+     * Retrieves the subscription status label
1184
+     *
1185
+     * @since  1.0.0
1186
+     * @return string
1187
+     */
1188
+    public function get_status_label() {
1189
+        return getpaid_get_subscription_status_label( $this->get_status() );
1190
+    }
1191
+
1192
+    /**
1193
+     * Retrieves the subscription status class
1194
+     *
1195
+     * @since  1.0.19
1196
+     * @return string
1197
+     */
1198
+    public function get_status_class() {
1199
+        $statuses = getpaid_get_subscription_status_classes();
1200
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1201
+    }
1202 1202
 
1203 1203
     /**
1204 1204
      * Retrieves the subscription status label
@@ -1208,11 +1208,11 @@  discard block
 block discarded – undo
1208 1208
      */
1209 1209
     public function get_status_label_html() {
1210 1210
 
1211
-		$status_label = sanitize_text_field( $this->get_status_label() );
1212
-		$class        = esc_attr( $this->get_status_class() );
1213
-		$status       = sanitize_html_class( $this->get_status() );
1211
+        $status_label = sanitize_text_field( $this->get_status_label() );
1212
+        $class        = esc_attr( $this->get_status_class() );
1213
+        $status       = sanitize_html_class( $this->get_status() );
1214 1214
 
1215
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1215
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1216 1216
     }
1217 1217
 
1218 1218
     /**
@@ -1223,75 +1223,75 @@  discard block
 block discarded – undo
1223 1223
      * @return bool
1224 1224
      */
1225 1225
     public function payment_exists( $txn_id = '' ) {
1226
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1226
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1227 1227
         return ! empty( $invoice_id );
1228
-	}
1229
-
1230
-	/**
1231
-	 * Handle the status transition.
1232
-	 */
1233
-	protected function status_transition() {
1234
-		$status_transition = $this->status_transition;
1235
-
1236
-		// Reset status transition variable.
1237
-		$this->status_transition = false;
1238
-
1239
-		if ( $status_transition ) {
1240
-			try {
1241
-
1242
-				// Fire a hook for the status change.
1243
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1245
-
1246
-				if ( ! empty( $status_transition['from'] ) ) {
1247
-
1248
-					/* translators: 1: old subscription status 2: new subscription status */
1249
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1250
-
1251
-					// Note the transition occurred.
1252
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1253
-
1254
-					// Fire another hook.
1255
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1257
-
1258
-				} else {
1259
-					/* translators: %s: new invoice status */
1260
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1261
-
1262
-					// Note the transition occurred.
1263
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1264
-
1265
-				}
1266
-			} catch ( Exception $e ) {
1267
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1268
-			}
1269
-		}
1270
-
1271
-	}
1272
-
1273
-	/**
1274
-	 * Save data to the database.
1275
-	 *
1276
-	 * @since 1.0.19
1277
-	 * @return int subscription ID
1278
-	 */
1279
-	public function save() {
1280
-		parent::save();
1281
-		$this->status_transition();
1282
-		return $this->get_id();
1283
-	}
1284
-
1285
-	/**
1286
-	 * Activates a subscription.
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @return int subscription ID
1290
-	 */
1291
-	public function activate() {
1292
-		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
-		$this->set_status( $status );
1294
-		return $this->save();
1295
-	}
1228
+    }
1229
+
1230
+    /**
1231
+     * Handle the status transition.
1232
+     */
1233
+    protected function status_transition() {
1234
+        $status_transition = $this->status_transition;
1235
+
1236
+        // Reset status transition variable.
1237
+        $this->status_transition = false;
1238
+
1239
+        if ( $status_transition ) {
1240
+            try {
1241
+
1242
+                // Fire a hook for the status change.
1243
+                do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
+                do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1245
+
1246
+                if ( ! empty( $status_transition['from'] ) ) {
1247
+
1248
+                    /* translators: 1: old subscription status 2: new subscription status */
1249
+                    $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1250
+
1251
+                    // Note the transition occurred.
1252
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1253
+
1254
+                    // Fire another hook.
1255
+                    do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
+                    do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1257
+
1258
+                } else {
1259
+                    /* translators: %s: new invoice status */
1260
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1261
+
1262
+                    // Note the transition occurred.
1263
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1264
+
1265
+                }
1266
+            } catch ( Exception $e ) {
1267
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1268
+            }
1269
+        }
1270
+
1271
+    }
1272
+
1273
+    /**
1274
+     * Save data to the database.
1275
+     *
1276
+     * @since 1.0.19
1277
+     * @return int subscription ID
1278
+     */
1279
+    public function save() {
1280
+        parent::save();
1281
+        $this->status_transition();
1282
+        return $this->get_id();
1283
+    }
1284
+
1285
+    /**
1286
+     * Activates a subscription.
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @return int subscription ID
1290
+     */
1291
+    public function activate() {
1292
+        $status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
+        $this->set_status( $status );
1294
+        return $this->save();
1295
+    }
1296 1296
 
1297 1297
 }
Please login to merge, or discard this patch.
Spacing   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 			'getpaid_subscriptions'                                       => $this->get_id(),
163 163
 		);
164 164
 
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
165
+		foreach ($caches as $cache => $value) {
166
+			if ('' !== $value && false !== $value) {
167
+				wp_cache_delete($value, $cache);
168 168
 			}
169 169
 		}
170 170
 	}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
      * Checks if a subscription key is set.
174 174
      */
175
-    public function _isset( $key ) {
176
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
175
+    public function _isset($key) {
176
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
177 177
 	}
178 178
 
179 179
 	/*
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param  string $context View or edit context.
199 199
 	 * @return int
200 200
 	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
201
+	public function get_customer_id($context = 'view') {
202
+		return (int) $this->get_prop('customer_id', $context);
203 203
 	}
204 204
 
205 205
 	/**
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param  string $context View or edit context.
210 210
 	 * @return WP_User|false WP_User object on success, false on failure.
211 211
 	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
212
+	public function get_customer($context = 'view') {
213
+		return get_userdata($this->get_customer_id($context));
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * @param  string $context View or edit context.
221 221
 	 * @return int
222 222
 	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
223
+	public function get_parent_invoice_id($context = 'view') {
224
+		return (int) $this->get_prop('parent_payment_id', $context);
225 225
 	}
226 226
 
227 227
 	/**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 * @param  string $context View or edit context.
232 232
 	 * @return int
233 233
 	 */
234
-    public function get_parent_payment_id( $context = 'view' ) {
235
-        return $this->get_parent_invoice_id( $context );
234
+    public function get_parent_payment_id($context = 'view') {
235
+        return $this->get_parent_invoice_id($context);
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
      * @since  1.0.0
242 242
      * @return int
243 243
      */
244
-    public function get_original_payment_id( $context = 'view' ) {
245
-        return $this->get_parent_invoice_id( $context );
244
+    public function get_original_payment_id($context = 'view') {
245
+        return $this->get_parent_invoice_id($context);
246 246
     }
247 247
 
248 248
 	/**
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @param  string $context View or edit context.
253 253
 	 * @return WPInv_Invoice
254 254
 	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
255
+	public function get_parent_invoice($context = 'view') {
256
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
257 257
 	}
258 258
 
259 259
 	/**
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @param  string $context View or edit context.
264 264
 	 * @return WPInv_Invoice
265 265
 	 */
266
-    public function get_parent_payment( $context = 'view' ) {
267
-        return $this->get_parent_invoice( $context );
266
+    public function get_parent_payment($context = 'view') {
267
+        return $this->get_parent_invoice($context);
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 	 * @param  string $context View or edit context.
275 275
 	 * @return int
276 276
 	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
277
+	public function get_product_id($context = 'view') {
278
+		return (int) $this->get_prop('product_id', $context);
279 279
 	}
280 280
 
281 281
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param  string $context View or edit context.
286 286
 	 * @return WPInv_Item
287 287
 	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
288
+	public function get_product($context = 'view') {
289
+		return new WPInv_Item($this->get_product_id($context));
290 290
 	}
291 291
 
292 292
 	/**
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	 * @param  string $context View or edit context.
299 299
 	 * @return string
300 300
 	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
301
+	public function get_gateway($context = 'view') {
302
+		return $this->get_parent_invoice($context)->get_gateway();
303 303
 	}
304 304
 
305 305
 	/**
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 	 * @param  string $context View or edit context.
310 310
 	 * @return string
311 311
 	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
312
+	public function get_period($context = 'view') {
313
+		return $this->get_prop('period', $context);
314 314
 	}
315 315
 
316 316
 	/**
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 	 * @param  string $context View or edit context.
321 321
 	 * @return int
322 322
 	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
323
+	public function get_frequency($context = 'view') {
324
+		return (int) $this->get_prop('frequency', $context);
325 325
 	}
326 326
 
327 327
 	/**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param  string $context View or edit context.
332 332
 	 * @return float
333 333
 	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
334
+	public function get_initial_amount($context = 'view') {
335
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 * @param  string $context View or edit context.
343 343
 	 * @return float
344 344
 	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
345
+	public function get_recurring_amount($context = 'view') {
346
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
347 347
 	}
348 348
 
349 349
 	/**
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 * @param  string $context View or edit context.
354 354
 	 * @return int
355 355
 	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
356
+	public function get_bill_times($context = 'view') {
357
+		return (int) $this->get_prop('bill_times', $context);
358 358
 	}
359 359
 
360 360
 	/**
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	 * @param  string $context View or edit context.
365 365
 	 * @return string
366 366
 	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
367
+	public function get_transaction_id($context = 'view') {
368
+		return $this->get_prop('transaction_id', $context);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $context View or edit context.
376 376
 	 * @return string
377 377
 	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
378
+	public function get_created($context = 'view') {
379
+		return $this->get_prop('created', $context);
380 380
 	}
381 381
 
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $context View or edit context.
387 387
 	 * @return string
388 388
 	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
389
+	public function get_date_created($context = 'view') {
390
+		return $this->get_created($context);
391 391
 	}
392 392
 
393 393
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function get_time_created() {
400 400
 		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
401
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
402 402
 	}
403 403
 
404 404
 	/**
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	 * @param  string $context View or edit context.
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
412
-        $date = $this->get_date_created( $context );
411
+	public function get_date_created_gmt($context = 'view') {
412
+        $date = $this->get_date_created($context);
413 413
 
414
-        if ( $date ) {
415
-            $date = get_gmt_from_date( $date );
414
+        if ($date) {
415
+            $date = get_gmt_from_date($date);
416 416
         }
417 417
 		return $date;
418 418
 	}
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 * @param  string $context View or edit context.
425 425
 	 * @return string
426 426
 	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
427
+	public function get_next_renewal_date($context = 'view') {
428
+		return $this->get_prop('expiration', $context);
429 429
 	}
430 430
 
431 431
 	/**
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $context View or edit context.
436 436
 	 * @return string
437 437
 	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
438
+	public function get_expiration($context = 'view') {
439
+		return $this->get_next_renewal_date($context);
440 440
 	}
441 441
 
442 442
 	/**
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	public function get_expiration_time() {
449 449
 		$expiration = $this->get_expiration();
450 450
 
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
451
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
452
+			return current_time('timestamp');
453 453
 		}
454 454
 
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
455
+		$expiration = strtotime($expiration, current_time('timestamp'));
456
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
457 457
 	}
458 458
 
459 459
 	/**
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_next_renewal_date( $context );
466
+	public function get_next_renewal_date_gmt($context = 'view') {
467
+        $date = $this->get_next_renewal_date($context);
468 468
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
469
+        if ($date) {
470
+            $date = get_gmt_from_date($date);
471 471
         }
472 472
 		return $date;
473 473
 	}
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
482
+	public function get_trial_period($context = 'view') {
483
+		return $this->get_prop('trial_period', $context);
484 484
 	}
485 485
 
486 486
 	/**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
493
+	public function get_status($context = 'view') {
494
+		return $this->get_prop('status', $context);
495 495
 	}
496 496
 
497 497
 	/**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
504
+	public function get_profile_id($context = 'view') {
505
+		return $this->get_prop('profile_id', $context);
506 506
 	}
507 507
 
508 508
 	/*
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @since 1.0.19
518 518
 	 * @param  int $value The customer's id.
519 519
 	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
520
+	public function set_customer_id($value) {
521
+		$this->set_prop('customer_id', (int) $value);
522 522
 	}
523 523
 
524 524
 	/**
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @since 1.0.19
528 528
 	 * @param  int $value The parent invoice id.
529 529
 	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
530
+	public function set_parent_invoice_id($value) {
531
+		$this->set_prop('parent_payment_id', (int) $value);
532 532
 	}
533 533
 
534 534
 	/**
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @since 1.0.19
538 538
 	 * @param  int $value The parent invoice id.
539 539
 	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
540
+    public function set_parent_payment_id($value) {
541
+        $this->set_parent_invoice_id($value);
542 542
 	}
543 543
 
544 544
 	/**
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
      * @since 1.0.19
548 548
 	 * @param  int $value The parent invoice id.
549 549
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
550
+    public function set_original_payment_id($value) {
551
+        $this->set_parent_invoice_id($value);
552 552
 	}
553 553
 
554 554
 	/**
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 	 * @since 1.0.19
558 558
 	 * @param  int $value The subscription product id.
559 559
 	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
560
+	public function set_product_id($value) {
561
+		$this->set_prop('product_id', (int) $value);
562 562
 	}
563 563
 
564 564
 	/**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @since 1.0.19
568 568
 	 * @param  string $value The renewal period.
569 569
 	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
570
+	public function set_period($value) {
571
+		$this->set_prop('period', $value);
572 572
 	}
573 573
 
574 574
 	/**
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 	 * @since 1.0.19
578 578
 	 * @param  int $value The subscription frequency.
579 579
 	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
580
+	public function set_frequency($value) {
581
+		$value = empty($value) ? 1 : (int) $value;
582
+		$this->set_prop('frequency', absint($value));
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 * @since 1.0.19
589 589
 	 * @param  float $value The initial subcription amount.
590 590
 	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
591
+	public function set_initial_amount($value) {
592
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
593 593
 	}
594 594
 
595 595
 	/**
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 * @param  float $value The recurring subcription amount.
600 600
 	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
601
+	public function set_recurring_amount($value) {
602
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
603 603
 	}
604 604
 
605 605
 	/**
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @since 1.0.19
609 609
 	 * @param  int $value Bill times.
610 610
 	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
611
+	public function set_bill_times($value) {
612
+		$this->set_prop('bill_times', (int) $value);
613 613
 	}
614 614
 
615 615
 	/**
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * @since 1.0.19
619 619
 	 * @param string $value Bill times.
620 620
 	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
621
+	public function set_transaction_id($value) {
622
+		$this->set_prop('transaction_id', sanitize_text_field($value));
623 623
 	}
624 624
 
625 625
 	/**
@@ -628,15 +628,15 @@  discard block
 block discarded – undo
628 628
 	 * @since 1.0.19
629 629
 	 * @param string $value strtotime compliant date.
630 630
 	 */
631
-	public function set_created( $value ) {
632
-        $date = strtotime( $value );
631
+	public function set_created($value) {
632
+        $date = strtotime($value);
633 633
 
634
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
635
-            $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) );
634
+        if ($date && $value !== '0000-00-00 00:00:00') {
635
+            $this->set_prop('created', gmdate('Y-m-d H:i:s', $date));
636 636
             return;
637 637
         }
638 638
 
639
-		$this->set_prop( 'created', '' );
639
+		$this->set_prop('created', '');
640 640
 
641 641
 	}
642 642
 
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @since 1.0.19
647 647
 	 * @param string $value strtotime compliant date.
648 648
 	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
649
+	public function set_date_created($value) {
650
+		$this->set_created($value);
651 651
     }
652 652
 
653 653
 	/**
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * @since 1.0.19
657 657
 	 * @param string $value strtotime compliant date.
658 658
 	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
659
+	public function set_next_renewal_date($value) {
660
+		$date = strtotime($value);
661 661
 
662
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
663
-            $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
662
+        if ($date && $value !== '0000-00-00 00:00:00') {
663
+            $this->set_prop('expiration', gmdate('Y-m-d H:i:s', $date));
664 664
             return;
665 665
 		}
666 666
 
667
-		$this->set_prop( 'expiration', '' );
667
+		$this->set_prop('expiration', '');
668 668
 
669 669
 	}
670 670
 
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
 	 * @since 1.0.19
675 675
 	 * @param string $value strtotime compliant date.
676 676
 	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
677
+	public function set_expiration($value) {
678
+		$this->set_next_renewal_date($value);
679 679
     }
680 680
 
681 681
 	/**
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 * @since 1.0.19
685 685
 	 * @param string $value trial period e.g 1 year.
686 686
 	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
687
+	public function set_trial_period($value) {
688
+		$this->set_prop('trial_period', $value);
689 689
 	}
690 690
 
691 691
 	/**
@@ -694,22 +694,22 @@  discard block
 block discarded – undo
694 694
 	 * @since 1.0.19
695 695
 	 * @param string $new_status    New subscription status.
696 696
 	 */
697
-	public function set_status( $new_status ) {
697
+	public function set_status($new_status) {
698 698
 
699 699
 		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
700
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
701 701
 			return;
702 702
 		}
703 703
 
704
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
-		if ( true === $this->object_read && $old_status !== $new_status ) {
704
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
705
+		if (true === $this->object_read && $old_status !== $new_status) {
706 706
 			$this->status_transition = array(
707 707
 				'from' => $old_status,
708 708
 				'to'   => $new_status,
709 709
 			);
710 710
 		}
711 711
 
712
-		$this->set_prop( 'status', $new_status );
712
+		$this->set_prop('status', $new_status);
713 713
 	}
714 714
 
715 715
 	/**
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
 	 * @since 1.0.19
719 719
 	 * @param  string $value the remote profile id.
720 720
 	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
721
+	public function set_profile_id($value) {
722
+		$this->set_prop('profile_id', sanitize_text_field($value));
723 723
 	}
724 724
 
725 725
 	/*
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param string|array String or array of strings to check for.
738 738
 	 * @return bool
739 739
      */
740
-    public function has_status( $status ) {
741
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
740
+    public function has_status($status) {
741
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
742 742
 	}
743 743
 
744 744
 	/**
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function has_trial_period() {
750 750
 		$period = $this->get_trial_period();
751
-        return ! empty( $period );
751
+        return !empty($period);
752 752
 	}
753 753
 
754 754
 	/**
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 * @return bool
758 758
 	 */
759 759
 	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
760
+		return $this->has_status('active trialling') && !$this->is_expired();
761 761
 	}
762 762
 
763 763
 	/**
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	 * @return bool
767 767
 	 */
768 768
 	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
769
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp'));
770 770
 	}
771 771
 
772 772
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public function is_last_renewal() {
778 778
 		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
779
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
780 780
 	}
781 781
 
782 782
 	/*
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function create( $data = array() ) {
794
+	public function create($data = array()) {
795 795
 
796 796
 		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
797
+		if (is_array($data)) {
798
+			$this->set_props($data);
799 799
 		}
800 800
 
801 801
 		// Save the item.
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 	/**
807 807
 	 * Backwards compatibilty.
808 808
 	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
809
+	public function update($args = array()) {
810
+		return $this->create($args);
811 811
 	}
812 812
 
813 813
     /**
@@ -816,12 +816,12 @@  discard block
 block discarded – undo
816 816
      * @since  1.0.0
817 817
      * @return WP_Post[]
818 818
      */
819
-    public function get_child_payments( $hide_pending = true ) {
819
+    public function get_child_payments($hide_pending = true) {
820 820
 
821
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
821
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
822 822
 
823
-		if ( ! $hide_pending ) {
824
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
823
+		if (!$hide_pending) {
824
+			$statuses = array_keys(wpinv_get_invoice_statuses());
825 825
 		}
826 826
 
827 827
         return get_posts(
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return int
844 844
      */
845 845
     public function get_total_payments() {
846
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
846
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
847 847
     }
848 848
 
849 849
     /**
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     public function get_times_billed() {
856 856
         $times_billed = $this->get_total_payments();
857 857
 
858
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
858
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
859 859
             $times_billed--;
860 860
         }
861 861
 
@@ -870,52 +870,52 @@  discard block
 block discarded – undo
870 870
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873
-    public function add_payment( $args = array(), $invoice = false ) {
873
+    public function add_payment($args = array(), $invoice = false) {
874 874
 
875 875
 		// Process each payment once.
876
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
876
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
877 877
             return false;
878 878
         }
879 879
 
880 880
 		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
881
+		if (empty($invoice)) {
882
+			$invoice = $this->create_payment(false);
883 883
 
884
-			if ( empty( $invoice ) ) {
884
+			if (empty($invoice)) {
885 885
 				return false;
886 886
 			}
887 887
 		}
888 888
 
889 889
 		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
890
+		if (!empty($args['transaction_id'])) {
891
+			$invoice->set_transaction_id($args['transaction_id']);
892 892
 		}
893 893
 
894 894
 		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
895
+		$invoice->set_completed_date(current_time('mysql'));
896 896
 
897 897
 		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
898
+		if (!empty($args['gateway'])) {
899
+			$invoice->set_gateway($args['gateway']);
900 900
 		}
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
902
+		$invoice->set_status('wpi-renewal');
903 903
 		$invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
905
+		if (!$invoice->exists()) {
906 906
 			return false;
907 907
 		}
908 908
 
909
-		return $this->after_add_payment( $invoice );
909
+		return $this->after_add_payment($invoice);
910 910
 	}
911 911
 
912
-    public function after_add_payment( $invoice ) {
912
+    public function after_add_payment($invoice) {
913 913
 
914
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
914
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
915
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
916
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
917 917
 
918
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
918
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
919 919
 
920 920
         return $invoice->get_id();
921 921
 	}
@@ -927,53 +927,53 @@  discard block
 block discarded – undo
927 927
 	 * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930
-    public function create_payment( $save = true ) {
930
+    public function create_payment($save = true) {
931 931
 
932 932
 		$parent_invoice = $this->get_parent_payment();
933 933
 
934
-		if ( ! $parent_invoice->exists() ) {
934
+		if (!$parent_invoice->exists()) {
935 935
 			return false;
936 936
 		}
937 937
 
938 938
 		// Duplicate the parent invoice.
939
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
940
-		$invoice->set_parent_id( $parent_invoice->get_id() );
941
-		$invoice->set_subscription_id( $this->get_id() );
942
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
939
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
940
+		$invoice->set_parent_id($parent_invoice->get_id());
941
+		$invoice->set_subscription_id($this->get_id());
942
+		$invoice->set_remote_subscription_id($this->get_profile_id());
943 943
 
944 944
 		// Set invoice items.
945
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
945
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
946
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
947 947
 		$invoice_items      = array();
948 948
 
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
949
+		foreach ($invoice->get_items() as $item) {
950
+			if (in_array($item->get_id(), $allowed_items)) {
951 951
 				$invoice_items[] = $item;
952 952
 			}
953 953
 		}
954 954
 
955
-		$invoice->set_items( $invoice_items );
955
+		$invoice->set_items($invoice_items);
956 956
 
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
957
+		if (!empty($subscription_group['fees'])) {
958
+			$invoice->set_fees($subscription_group['fees']);
959 959
 		}
960 960
 
961 961
 		// Maybe recalculate discount (Pre-GetPaid Fix).
962
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
962
+		$discount = new WPInv_Discount($invoice->get_discount_code());
963 963
 
964
-		if ( $discount->exists() && $discount->is_recurring() ) {
965
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
964
+		if ($discount->exists() && $discount->is_recurring()) {
965
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
966
+		} else {
967 967
 			// Unset discount code.
968
-			$invoice->set_discount_code( '' );
968
+			$invoice->set_discount_code('');
969 969
 
970
-			$invoice->remove_discount( 'discount_code' );
970
+			$invoice->remove_discount('discount_code');
971 971
 		}
972 972
 
973 973
 		$invoice->recalculate_total();
974
-		$invoice->set_status( 'wpi-pending' );
974
+		$invoice->set_status('wpi-pending');
975 975
 
976
-		if ( ! $save ) {
976
+		if (!$save) {
977 977
 			return $invoice;
978 978
 		}
979 979
 
@@ -988,28 +988,28 @@  discard block
 block discarded – undo
988 988
 	 * @since  1.0.0
989 989
 	 * @return int The subscription's id
990 990
 	 */
991
-	public function renew( $calculate_from = null, $_new_expiration = null ) {
991
+	public function renew($calculate_from = null, $_new_expiration = null) {
992 992
 		// Complete subscription if applicable
993
-		if ( $this->is_last_renewal() ) {
993
+		if ($this->is_last_renewal()) {
994 994
 			return $this->complete();
995 995
 		}
996 996
 
997
-		if ( ! empty( $_new_expiration ) ) {
997
+		if (!empty($_new_expiration)) {
998 998
 			$new_expiration = $_new_expiration;
999 999
 		} else {
1000 1000
 			// Calculate new expiration
1001 1001
 			$frequency      = $this->get_frequency();
1002 1002
 			$period         = $this->get_period();
1003
-			$calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
-			$new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
-			$new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1003
+			$calculate_from = empty($calculate_from) ? $this->get_expiration_time() : $calculate_from;
1004
+			$new_expiration = strtotime("+ $frequency $period", $calculate_from);
1005
+			$new_expiration = date('Y-m-d H:i:s', $new_expiration);
1006 1006
 		}
1007 1007
 
1008
-		$this->set_expiration( $new_expiration );
1009
-		$this->set_status( 'active' );
1008
+		$this->set_expiration($new_expiration);
1009
+		$this->set_status('active');
1010 1010
 		$this->save();
1011 1011
 
1012
-		do_action( 'getpaid_subscription_renewed', $this );
1012
+		do_action('getpaid_subscription_renewed', $this);
1013 1013
 
1014 1014
 		return $this->get_id();
1015 1015
 	}
@@ -1025,11 +1025,11 @@  discard block
 block discarded – undo
1025 1025
 	public function complete() {
1026 1026
 
1027 1027
 		// Only mark a subscription as complete if it's not already cancelled.
1028
-		if ( $this->has_status( 'cancelled' ) ) {
1028
+		if ($this->has_status('cancelled')) {
1029 1029
 			return false;
1030 1030
 		}
1031 1031
 
1032
-		$this->set_status( 'completed' );
1032
+		$this->set_status('completed');
1033 1033
 		return $this->save();
1034 1034
 
1035 1035
 	}
@@ -1041,14 +1041,14 @@  discard block
 block discarded – undo
1041 1041
 	 * @param  bool $check_expiration
1042 1042
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043 1043
 	 */
1044
-	public function expire( $check_expiration = false ) {
1044
+	public function expire($check_expiration = false) {
1045 1045
 
1046
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1046
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1047 1047
 			// Do not mark as expired since real expiration date is in the future
1048 1048
 			return false;
1049 1049
 		}
1050 1050
 
1051
-		$this->set_status( 'expired' );
1051
+		$this->set_status('expired');
1052 1052
 		return $this->save();
1053 1053
 
1054 1054
 	}
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @return int Subscription id.
1061 1061
 	 */
1062 1062
 	public function failing() {
1063
-		$this->set_status( 'failing' );
1063
+		$this->set_status('failing');
1064 1064
 		return $this->save();
1065 1065
 	}
1066 1066
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
      * @return int Subscription id.
1072 1072
      */
1073 1073
     public function cancel() {
1074
-		$this->set_status( 'cancelled' );
1074
+		$this->set_status('cancelled');
1075 1075
 		return $this->save();
1076 1076
     }
1077 1077
 
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	 * @return bool
1083 1083
 	 */
1084 1084
 	public function can_cancel() {
1085
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1085
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1086 1086
 	}
1087 1087
 
1088 1088
     /**
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      * @return      array
1094 1094
      */
1095 1095
     public function get_cancellable_statuses() {
1096
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1096
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1097 1097
     }
1098 1098
 
1099 1099
 	/**
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
 	 * @return string
1104 1104
 	 */
1105 1105
 	public function get_cancel_url() {
1106
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1106
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1107
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1108 1108
 	}
1109 1109
 
1110 1110
 	/**
@@ -1115,10 +1115,10 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	public function get_view_url() {
1117 1117
 
1118
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1118
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1119
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1120 1120
 
1121
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1121
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1122 1122
 	}
1123 1123
 
1124 1124
 	/**
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	 * @return bool
1132 1132
 	 */
1133 1133
 	public function can_renew() {
1134
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1134
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1135 1135
 	}
1136 1136
 
1137 1137
 	/**
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
             ),
1151 1151
             'getpaid-nonce'
1152 1152
         );
1153
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1153
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	 * @return bool
1161 1161
 	 */
1162 1162
 	public function can_update() {
1163
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1163
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 				'subscription_id' => $this->get_id(),
1177 1177
             )
1178 1178
         );
1179
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1179
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1180 1180
 	}
1181 1181
 
1182 1182
 	/**
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	 * @return string
1187 1187
 	 */
1188 1188
 	public function get_status_label() {
1189
-		return getpaid_get_subscription_status_label( $this->get_status() );
1189
+		return getpaid_get_subscription_status_label($this->get_status());
1190 1190
 	}
1191 1191
 
1192 1192
 	/**
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	public function get_status_class() {
1199 1199
 		$statuses = getpaid_get_subscription_status_classes();
1200
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1200
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark';
1201 1201
 	}
1202 1202
 
1203 1203
     /**
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
      */
1209 1209
     public function get_status_label_html() {
1210 1210
 
1211
-		$status_label = sanitize_text_field( $this->get_status_label() );
1212
-		$class        = esc_attr( $this->get_status_class() );
1213
-		$status       = sanitize_html_class( $this->get_status() );
1211
+		$status_label = sanitize_text_field($this->get_status_label());
1212
+		$class        = esc_attr($this->get_status_class());
1213
+		$status       = sanitize_html_class($this->get_status());
1214 1214
 
1215 1215
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1216 1216
     }
@@ -1222,9 +1222,9 @@  discard block
 block discarded – undo
1222 1222
      * @param  string $txn_id The transaction ID from the merchant processor
1223 1223
      * @return bool
1224 1224
      */
1225
-    public function payment_exists( $txn_id = '' ) {
1226
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1227
-        return ! empty( $invoice_id );
1225
+    public function payment_exists($txn_id = '') {
1226
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1227
+        return !empty($invoice_id);
1228 1228
 	}
1229 1229
 
1230 1230
 	/**
@@ -1236,35 +1236,35 @@  discard block
 block discarded – undo
1236 1236
 		// Reset status transition variable.
1237 1237
 		$this->status_transition = false;
1238 1238
 
1239
-		if ( $status_transition ) {
1239
+		if ($status_transition) {
1240 1240
 			try {
1241 1241
 
1242 1242
 				// Fire a hook for the status change.
1243
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1243
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1244
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1245 1245
 
1246
-				if ( ! empty( $status_transition['from'] ) ) {
1246
+				if (!empty($status_transition['from'])) {
1247 1247
 
1248 1248
 					/* translators: 1: old subscription status 2: new subscription status */
1249
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1249
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1250 1250
 
1251 1251
 					// Note the transition occurred.
1252
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1252
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1253 1253
 
1254 1254
 					// Fire another hook.
1255
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1255
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1256
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1257 1257
 
1258 1258
 				} else {
1259 1259
 					/* translators: %s: new invoice status */
1260
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1260
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1261 1261
 
1262 1262
 					// Note the transition occurred.
1263
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1263
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1264 1264
 
1265 1265
 				}
1266
-			} catch ( Exception $e ) {
1267
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1266
+			} catch (Exception $e) {
1267
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1268 1268
 			}
1269 1269
 		}
1270 1270
 
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
 	 */
1291 1291
 	public function activate() {
1292 1292
 		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
-		$this->set_status( $status );
1293
+		$this->set_status($status);
1294 1294
 		return $this->save();
1295 1295
 	}
1296 1296
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 4 patches
Braces   +42 added lines, -44 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			if(!empty($this->options['nested-block'])){
61 61
 				if(empty($this->options['output_types'])){
62 62
 					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
63
+				} elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
 					unset($this->options['output_types'][$key]);
65 65
 				}
66 66
 			}
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 				<?php
717 717
 				if(! empty( $insert_shortcode_function )){
718 718
 					echo $insert_shortcode_function;
719
-				}else{
719
+				} else{
720 720
 
721 721
 				/**
722 722
 				 * Function for super duper insert shortcode.
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 				$p_pl = 'ps-';
2241 2241
 				$p_pr = 'pe-';
2242 2242
 					<?php
2243
-				}else{
2243
+				} else{
2244 2244
 						?>
2245 2245
 				$aui_bs5 = false;
2246 2246
 				$p_ml = 'ml-';
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 					var InnerBlocks = blockEditor.InnerBlocks;
2469 2469
 
2470 2470
 					var term_query_type = '';
2471
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2471
+					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>;
2472 2472
 					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2473 2473
 					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2474 2474
 					const MediaUpload = wp.blockEditor.MediaUpload;
@@ -2525,9 +2525,9 @@  discard block
 block discarded – undo
2525 2525
 						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2526 2526
 						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2527 2527
 							// no preview if set to false
2528
-						}elseif( !empty( $example_args ) ){
2528
+						} elseif( !empty( $example_args ) ){
2529 2529
 							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2530
-						}elseif( !empty( $this->options['example'] ) ){
2530
+						} elseif( !empty( $this->options['example'] ) ){
2531 2531
 							unset($this->options['example']['viewportWidth']);
2532 2532
 							unset($this->options['example']['innerBlocks']);
2533 2533
 							$example_atts = $this->array_to_attributes( $this->options['example'] );
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 							if(!empty($example_parts)){
2545 2545
 								echo "example : {".implode(',', $example_parts)."},";
2546 2546
 							}
2547
-						}else{
2547
+						} else{
2548 2548
 							echo 'example : {viewportWidth: 500},';
2549 2549
 						}
2550 2550
 
@@ -2615,8 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 
2616 2616
 									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2617 2617
 										continue;
2618
-									}
2619
-									elseif ( $args['type'] == 'checkbox' ) {
2618
+									} elseif ( $args['type'] == 'checkbox' ) {
2620 2619
 										$type    = 'boolean';
2621 2620
 										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2622 2621
 									} elseif ( $args['type'] == 'number' ) {
@@ -2752,7 +2751,7 @@  discard block
 block discarded – undo
2752 2751
 							<?php
2753 2752
 							if(!empty($this->options['block-edit-raw'])) {
2754 2753
 								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2755
-							}else{
2754
+							} else{
2756 2755
 							?>
2757 2756
 
2758 2757
 function hasSelectedInnerBlock(props) {
@@ -2887,7 +2886,7 @@  discard block
 block discarded – undo
2887 2886
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2888 2887
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2889 2888
 	echo 'const { deviceType } = "";';
2890
-}else{
2889
+} else{
2891 2890
 ?>
2892 2891
 /** Get device type const. */
2893 2892
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
@@ -2951,7 +2950,7 @@  discard block
 block discarded – undo
2951 2950
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2952 2951
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2953 2952
 										echo $post->ID;
2954
-									}else{echo '0';}?>,
2953
+									} else{echo '0';}?>,
2955 2954
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2956 2955
 									};
2957 2956
 
@@ -2971,7 +2970,7 @@  discard block
 block discarded – undo
2971 2970
 										is_fetching = false;
2972 2971
 										prev_attributes[props.clientId] = props.attributes;
2973 2972
 											 <?php
2974
-										}else{
2973
+										} else{
2975 2974
 										?>
2976 2975
 										props.setAttributes({content: env});
2977 2976
 										is_fetching = false;
@@ -3182,7 +3181,7 @@  discard block
 block discarded – undo
3182 3181
 //
3183 3182
 
3184 3183
 									}
3185
-									}else {
3184
+									} else {
3186 3185
 									?>
3187 3186
 									el(wp.components.PanelBody, {
3188 3187
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
@@ -3208,9 +3207,9 @@  discard block
 block discarded – undo
3208 3207
 								// If the user sets block-output array then build it
3209 3208
 								if ( ! empty( $this->options['block-output'] ) ) {
3210 3209
 								$this->block_element( $this->options['block-output'] );
3211
-							}elseif(!empty($this->options['block-edit-return'])){
3210
+							} elseif(!empty($this->options['block-edit-return'])){
3212 3211
 								   echo $this->options['block-edit-return'];
3213
-							}else{
3212
+							} else{
3214 3213
 								// if no block-output is set then we try and get the shortcode html output via ajax.
3215 3214
 								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3216 3215
 								?>
@@ -3322,9 +3321,9 @@  discard block
 block discarded – undo
3322 3321
 							   );
3323 3322
 								<?php
3324 3323
 
3325
-							}elseif(!empty($this->options['block-save-return'])){
3324
+							} elseif(!empty($this->options['block-save-return'])){
3326 3325
 								   echo 'return ' . $this->options['block-save-return'];
3327
-							}elseif(!empty($this->options['nested-block'])){
3326
+							} elseif(!empty($this->options['nested-block'])){
3328 3327
 								?>
3329 3328
 							  return el(
3330 3329
 								   '',
@@ -3334,13 +3333,13 @@  discard block
 block discarded – undo
3334 3333
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3335 3334
 							   );
3336 3335
 								<?php
3337
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3336
+							} elseif(!empty( $this->options['block-save-return'] ) ){
3338 3337
 								echo "return ". $this->options['block-edit-return'].";";
3339
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3338
+							} elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3340 3339
 							?>
3341 3340
 							return content;
3342 3341
 							<?php
3343
-							}else{
3342
+							} else{
3344 3343
 							?>
3345 3344
 							var block_wrap = 'div';
3346 3345
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -3391,9 +3390,9 @@  discard block
 block discarded – undo
3391 3390
 				$device_type_icon = '';
3392 3391
 				if($device_type=='Desktop'){
3393 3392
 					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3394
-				}elseif($device_type=='Tablet'){
3393
+				} elseif($device_type=='Tablet'){
3395 3394
 					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3396
-				}elseif($device_type=='Mobile'){
3395
+				} elseif($device_type=='Mobile'){
3397 3396
 					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3398 3397
 				}
3399 3398
 				echo $element_require;
@@ -3438,7 +3437,7 @@  discard block
 block discarded – undo
3438 3437
 
3439 3438
 					<?php
3440 3439
 					if(false){?></script><?php }
3441
-				}elseif(!empty($args['row']['close'])){
3440
+				} elseif(!empty($args['row']['close'])){
3442 3441
 					if(false){?><script><?php }?>
3443 3442
 						el(
3444 3443
 							'div',
@@ -3447,7 +3446,7 @@  discard block
 block discarded – undo
3447 3446
 							},
3448 3447
 					<?php
3449 3448
 					if(false){?></script><?php }
3450
-				}else{
3449
+				} else{
3451 3450
 					if(false){?><script><?php }?>
3452 3451
 						el(
3453 3452
 							'div',
@@ -3552,9 +3551,9 @@  discard block
 block discarded – undo
3552 3551
 			$device_type_icon = '';
3553 3552
 			if($device_type=='Desktop'){
3554 3553
 				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3555
-			}elseif($device_type=='Tablet'){
3554
+			} elseif($device_type=='Tablet'){
3556 3555
 				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3557
-			}elseif($device_type=='Mobile'){
3556
+			} elseif($device_type=='Mobile'){
3558 3557
 				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3559 3558
 			}
3560 3559
 
@@ -3617,7 +3616,7 @@  discard block
 block discarded – undo
3617 3616
 				$args['type'] == 'text';
3618 3617
 				// Save numbers as numbers and not strings
3619 3618
 				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3620
-			}else if ( $args['type'] == 'notice' ) {
3619
+			} else if ( $args['type'] == 'notice' ) {
3621 3620
 
3622 3621
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3623 3622
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3692,7 +3691,7 @@  discard block
 block discarded – undo
3692 3691
 							$key: value
3693 3692
 						});
3694 3693
 					},";
3695
-			}elseif ( $args['type'] == 'gradient' ) {
3694
+			} elseif ( $args['type'] == 'gradient' ) {
3696 3695
 				$type = 'GradientPicker';
3697 3696
 				$extra .= "gradients: [{
3698 3697
 			name: 'Vivid cyan blue to vivid purple',
@@ -3731,7 +3730,7 @@  discard block
 block discarded – undo
3731 3730
 			slug: 'cool-to-warm-spectrum',
3732 3731
 		}],";
3733 3732
 
3734
-			}elseif ( $args['type'] == 'image' ) {
3733
+			} elseif ( $args['type'] == 'image' ) {
3735 3734
 //                print_r($args);
3736 3735
 
3737 3736
 				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3868,8 +3867,7 @@  discard block
 block discarded – undo
3868 3867
 				$onchange = "";
3869 3868
 
3870 3869
 				//$inside_elements = ",el('div',{},'file upload')";
3871
-			}
3872
-			elseif ( $args['type'] == 'checkbox' ) {
3870
+			} elseif ( $args['type'] == 'checkbox' ) {
3873 3871
 				$type = 'CheckboxControl';
3874 3872
 				$extra .= "checked: props.attributes.$key,";
3875 3873
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
@@ -3881,9 +3879,9 @@  discard block
 block discarded – undo
3881 3879
 
3882 3880
 				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3883 3881
 					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3884
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3882
+				} elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3885 3883
 					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3886
-				}else {
3884
+				} else {
3887 3885
 
3888 3886
 					if ( ! empty( $args['options'] ) ) {
3889 3887
 						$options .= "options: [";
@@ -4047,7 +4045,7 @@  discard block
 block discarded – undo
4047 4045
 				foreach ( $custom_attributes as $key => $val ) {
4048 4046
 					if(is_array($val)){
4049 4047
 						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4050
-					}else{
4048
+					} else{
4051 4049
 						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4052 4050
 					}
4053 4051
 				}
@@ -4088,7 +4086,7 @@  discard block
 block discarded – undo
4088 4086
 
4089 4087
 							if($new_args['element']=='InnerBlocks'){
4090 4088
 								echo "\n el( InnerBlocks, {";
4091
-							}elseif($new_args['element']=='innerBlocksProps'){
4089
+							} elseif($new_args['element']=='innerBlocksProps'){
4092 4090
 								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4093 4091
 							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4094 4092
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
@@ -4101,11 +4099,11 @@  discard block
 block discarded – undo
4101 4099
 							//    echo '###';
4102 4100
 
4103 4101
 							  //  echo '###';
4104
-							}elseif($new_args['element']=='BlocksProps'){
4102
+							} elseif($new_args['element']=='BlocksProps'){
4105 4103
 
4106 4104
 								if ( isset($new_args['if_inner_element']) ) {
4107 4105
 									$element = $new_args['if_inner_element'];
4108
-								}else {
4106
+								} else {
4109 4107
 									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4110 4108
 								}
4111 4109
 
@@ -4116,7 +4114,7 @@  discard block
 block discarded – undo
4116 4114
 
4117 4115
 							   // echo "} ),";
4118 4116
 
4119
-							}else{
4117
+							} else{
4120 4118
 								echo "\n el( '" . $new_args['element'] . "', {";
4121 4119
 							}
4122 4120
 
@@ -4141,7 +4139,7 @@  discard block
 block discarded – undo
4141 4139
 
4142 4140
 									if ( $new_key === 'content' ) {
4143 4141
 										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4144
-									}else if ( $new_key === 'if_content' ) {
4142
+									} else if ( $new_key === 'if_content' ) {
4145 4143
 										echo  $this->block_props_replace(  $new_value  );
4146 4144
 									}
4147 4145
 
@@ -4171,7 +4169,7 @@  discard block
 block discarded – undo
4171 4169
 
4172 4170
 							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4173 4171
 								echo "))";// end content
4174
-							}else{
4172
+							} else{
4175 4173
 								echo ")";// end content
4176 4174
 							}
4177 4175
 
@@ -4795,11 +4793,11 @@  discard block
 block discarded – undo
4795 4793
 		public function get_widget_icon($icon = 'box-top', $title = ''){
4796 4794
 			if($icon=='box-top'){
4797 4795
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4798
-			}elseif($icon=='box-right'){
4796
+			} elseif($icon=='box-right'){
4799 4797
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4800
-			}elseif($icon=='box-bottom'){
4798
+			} elseif($icon=='box-bottom'){
4801 4799
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4802
-			}elseif($icon=='box-left'){
4800
+			} elseif($icon=='box-left'){
4803 4801
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4804 4802
 			}
4805 4803
 		}
Please login to merge, or discard this patch.
Indentation   +2687 added lines, -2687 removed lines patch added patch discarded remove patch
@@ -1,147 +1,147 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.2.17' );
9
-
10
-	/**
11
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
-	 *
13
-	 * Should not be called direct but extended instead.
14
-	 *
15
-	 * Class WP_Super_Duper
16
-	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
-	 * @ver 1.1.1
18
-	 */
19
-	class WP_Super_Duper extends WP_Widget {
20
-
21
-		public $version = SUPER_DUPER_VER;
22
-		public $font_awesome_icon_version = "5.11.2";
23
-		public $block_code;
24
-		public $options;
25
-		public $base_id;
26
-		public $settings_hash;
27
-		public $arguments = array();
28
-		public $instance = array();
29
-		private $class_name;
30
-
31
-		/**
32
-		 * The relative url to the current folder.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $url = '';
37
-
38
-		/**
39
-		 * Take the array options and use them to build.
40
-		 */
41
-		public function __construct( $options ) {
42
-			global $sd_widgets;
43
-
44
-			$sd_widgets[ $options['base_id'] ] = array(
45
-				'name'       => $options['name'],
46
-				'class_name' => $options['class_name'],
47
-				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
-			);
49
-			$this->base_id                     = $options['base_id'];
50
-			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
54
-			$this->options = $options;
55
-
56
-			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
-
59
-			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
-					unset($this->options['output_types'][$key]);
65
-				}
66
-			}
8
+    define( 'SUPER_DUPER_VER', '1.2.17' );
9
+
10
+    /**
11
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
+     *
13
+     * Should not be called direct but extended instead.
14
+     *
15
+     * Class WP_Super_Duper
16
+     * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
+     * @ver 1.1.1
18
+     */
19
+    class WP_Super_Duper extends WP_Widget {
20
+
21
+        public $version = SUPER_DUPER_VER;
22
+        public $font_awesome_icon_version = "5.11.2";
23
+        public $block_code;
24
+        public $options;
25
+        public $base_id;
26
+        public $settings_hash;
27
+        public $arguments = array();
28
+        public $instance = array();
29
+        private $class_name;
67 30
 
68
-			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
-			}
31
+        /**
32
+         * The relative url to the current folder.
33
+         *
34
+         * @var string
35
+         */
36
+        public $url = '';
37
+
38
+        /**
39
+         * Take the array options and use them to build.
40
+         */
41
+        public function __construct( $options ) {
42
+            global $sd_widgets;
43
+
44
+            $sd_widgets[ $options['base_id'] ] = array(
45
+                'name'       => $options['name'],
46
+                'class_name' => $options['class_name'],
47
+                'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
+            );
49
+            $this->base_id                     = $options['base_id'];
50
+            // lets filter the options before we do anything
51
+            $options       = apply_filters( "wp_super_duper_options", $options );
52
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
+            $options       = $this->add_name_from_key( $options );
54
+            $this->options = $options;
55
+
56
+            $this->base_id   = $options['base_id'];
57
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
+
59
+            // nested blocks can't work as a widget
60
+            if(!empty($this->options['nested-block'])){
61
+                if(empty($this->options['output_types'])){
62
+                    $this->options['output_types'] = array('shortcode','block');
63
+                }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
+                    unset($this->options['output_types'][$key]);
65
+                }
66
+            }
72 67
 
68
+            // init parent
69
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
+                parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
+            }
73 72
 
74
-			if ( isset( $options['class_name'] ) ) {
75
-				// register widget
76
-				$this->class_name = $options['class_name'];
77 73
 
78
-				// register shortcode, this needs to be done even for blocks and widgets
79
-				$this->register_shortcode();
74
+            if ( isset( $options['class_name'] ) ) {
75
+                // register widget
76
+                $this->class_name = $options['class_name'];
80 77
 
78
+                // register shortcode, this needs to be done even for blocks and widgets
79
+                $this->register_shortcode();
81 80
 
82
-				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
85
-				}
81
+
82
+                // Fusion Builder (avada) support
83
+                if ( function_exists( 'fusion_builder_map' ) ) {
84
+                    add_action( 'init', array( $this, 'register_fusion_element' ) );
85
+                }
86 86
 
87 87
                 // maybe load the Bricks transformer class
88 88
                 if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
89
+                    add_action( 'init', array( $this, 'load_bricks_element_class' ) );
90 90
                 }
91 91
 
92
-				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
-				}
96
-			}
92
+                // register block
93
+                if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
+                    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
+                }
96
+            }
97 97
 
98
-			// add the CSS and JS we need ONCE
99
-			global $sd_widget_scripts;
98
+            // add the CSS and JS we need ONCE
99
+            global $sd_widget_scripts;
100 100
 
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
101
+            if ( ! $sd_widget_scripts ) {
102
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
+                wp_add_inline_style( 'widgets', $this->widget_css() );
105 105
 
106
-				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
106
+                // maybe add elementor editor styles
107
+                add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
108 108
 
109
-				$sd_widget_scripts = true;
109
+                $sd_widget_scripts = true;
110 110
 
111
-				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
-				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
-				}
118
-				/* Load script on Divi theme builder page */
119
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
-					add_thickbox();
121
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
-				}
111
+                // add shortcode insert button once
112
+                add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
+                // generatepress theme sections compatibility
115
+                if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
+                    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
+                }
118
+                /* Load script on Divi theme builder page */
119
+                if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
+                    add_thickbox();
121
+                    add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
+                }
123 123
 
124
-				if ( $this->is_preview() ) {
125
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
-					// this makes the insert button work for elementor
127
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
128
-						$this,
129
-						'shortcode_insert_button_script'
130
-					) ); // for elementor
131
-				}
132
-				// this makes the insert button work for cornerstone
133
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
124
+                if ( $this->is_preview() ) {
125
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
+                    // this makes the insert button work for elementor
127
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
128
+                        $this,
129
+                        'shortcode_insert_button_script'
130
+                    ) ); // for elementor
131
+                }
132
+                // this makes the insert button work for cornerstone
133
+                add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
134 134
 
135
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
135
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
137 137
 
138
-				// add generator text to head
139
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
-			}
138
+                // add generator text to head
139
+                add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
+                add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
+            }
142 142
 
143
-			do_action( 'wp_super_duper_widget_init', $options, $this );
144
-		}
143
+            do_action( 'wp_super_duper_widget_init', $options, $this );
144
+        }
145 145
 
146 146
         /**
147 147
          * Load the Bricks conversion class if we are running Bricks.
@@ -151,163 +151,163 @@  discard block
 block discarded – undo
151 151
                     include_once __DIR__ . '/includes/class-super-duper-bricks-element.php';
152 152
         }
153 153
 
154
-		/**
155
-		 * The register widget function
156
-		 * @return void
157
-		 */
158
-		public function _register() {
159
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
-				parent::_register();
161
-			}
162
-		}
163
-
164
-		/**
165
-		 * Add our widget CSS to elementor editor.
166
-		 */
167
-		public function elementor_editor_styles() {
168
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
-		}
170
-
171
-		public function register_fusion_element() {
172
-
173
-			$options = $this->options;
174
-
175
-			if ( $this->base_id ) {
176
-
177
-				$params = $this->get_fusion_params();
178
-
179
-				$args = array(
180
-					'name'            => $options['name'],
181
-					'shortcode'       => $this->base_id,
182
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
-					'allow_generator' => true,
184
-				);
185
-
186
-				if ( ! empty( $params ) ) {
187
-					$args['params'] = $params;
188
-				}
189
-
190
-				fusion_builder_map( $args );
191
-			}
154
+        /**
155
+         * The register widget function
156
+         * @return void
157
+         */
158
+        public function _register() {
159
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
+                parent::_register();
161
+            }
162
+        }
192 163
 
193
-		}
164
+        /**
165
+         * Add our widget CSS to elementor editor.
166
+         */
167
+        public function elementor_editor_styles() {
168
+            wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
+        }
194 170
 
195
-		public function get_fusion_params() {
196
-			$params    = array();
197
-			$arguments = $this->get_arguments();
198
-
199
-			if ( ! empty( $arguments ) ) {
200
-				foreach ( $arguments as $key => $val ) {
201
-					$param = array();
202
-					// type
203
-					$param['type'] = str_replace(
204
-						array(
205
-							"text",
206
-							"number",
207
-							"email",
208
-							"color",
209
-							"checkbox"
210
-						),
211
-						array(
212
-							"textfield",
213
-							"textfield",
214
-							"textfield",
215
-							"colorpicker",
216
-							"select",
171
+        public function register_fusion_element() {
217 172
 
218
-						),
219
-						$val['type'] );
173
+            $options = $this->options;
220 174
 
221
-					// multiselect
222
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
-						$param['type']     = 'multiple_select';
224
-						$param['multiple'] = true;
225
-					}
175
+            if ( $this->base_id ) {
226 176
 
227
-					// heading
228
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
177
+                $params = $this->get_fusion_params();
229 178
 
230
-					// description
231
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
179
+                $args = array(
180
+                    'name'            => $options['name'],
181
+                    'shortcode'       => $this->base_id,
182
+                    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
+                    'allow_generator' => true,
184
+                );
232 185
 
233
-					// param_name
234
-					$param['param_name'] = $key;
186
+                if ( ! empty( $params ) ) {
187
+                    $args['params'] = $params;
188
+                }
235 189
 
236
-					// Default
237
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
190
+                fusion_builder_map( $args );
191
+            }
238 192
 
239
-					// Group
240
-					if ( isset( $val['group'] ) ) {
241
-						$param['group'] = $val['group'];
242
-					}
193
+        }
243 194
 
244
-					// value
245
-					if ( $val['type'] == 'checkbox' ) {
246
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
-							unset( $param['default'] );
248
-						}
249
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
-					} else {
253
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
-					}
195
+        public function get_fusion_params() {
196
+            $params    = array();
197
+            $arguments = $this->get_arguments();
198
+
199
+            if ( ! empty( $arguments ) ) {
200
+                foreach ( $arguments as $key => $val ) {
201
+                    $param = array();
202
+                    // type
203
+                    $param['type'] = str_replace(
204
+                        array(
205
+                            "text",
206
+                            "number",
207
+                            "email",
208
+                            "color",
209
+                            "checkbox"
210
+                        ),
211
+                        array(
212
+                            "textfield",
213
+                            "textfield",
214
+                            "textfield",
215
+                            "colorpicker",
216
+                            "select",
217
+
218
+                        ),
219
+                        $val['type'] );
220
+
221
+                    // multiselect
222
+                    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
+                        $param['type']     = 'multiple_select';
224
+                        $param['multiple'] = true;
225
+                    }
226
+
227
+                    // heading
228
+                    $param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
229
+
230
+                    // description
231
+                    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
232
+
233
+                    // param_name
234
+                    $param['param_name'] = $key;
235
+
236
+                    // Default
237
+                    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
238
+
239
+                    // Group
240
+                    if ( isset( $val['group'] ) ) {
241
+                        $param['group'] = $val['group'];
242
+                    }
243
+
244
+                    // value
245
+                    if ( $val['type'] == 'checkbox' ) {
246
+                        if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
+                            unset( $param['default'] );
248
+                        }
249
+                        $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
+                    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
+                        $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
+                    } else {
253
+                        $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
+                    }
255
+
256
+                    // setup the param
257
+                    $params[] = $param;
255 258
 
256
-					// setup the param
257
-					$params[] = $param;
259
+                }
260
+            }
258 261
 
259
-				}
260
-			}
261 262
 
263
+            return $params;
264
+        }
262 265
 
263
-			return $params;
264
-		}
266
+        /**
267
+         * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268
+         */
269
+        public static function maybe_cornerstone_builder() {
270
+            if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
+                self::shortcode_insert_button_script();
272
+            }
273
+        }
265 274
 
266
-		/**
267
-		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268
-		 */
269
-		public static function maybe_cornerstone_builder() {
270
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
-				self::shortcode_insert_button_script();
272
-			}
273
-		}
275
+        /**
276
+         * A function to ge the shortcode builder picker html.
277
+         *
278
+         * @param string $editor_id
279
+         *
280
+         * @return string
281
+         */
282
+        public static function get_picker( $editor_id = '' ) {
274 283
 
275
-		/**
276
-		 * A function to ge the shortcode builder picker html.
277
-		 *
278
-		 * @param string $editor_id
279
-		 *
280
-		 * @return string
281
-		 */
282
-		public static function get_picker( $editor_id = '' ) {
283
-
284
-			ob_start();
285
-			if ( isset( $_POST['editor_id'] ) ) {
286
-				$editor_id = esc_attr( $_POST['editor_id'] );
287
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
-				$editor_id = 'main_content_content_vb_tiny_mce';
289
-			}
284
+            ob_start();
285
+            if ( isset( $_POST['editor_id'] ) ) {
286
+                $editor_id = esc_attr( $_POST['editor_id'] );
287
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
+                $editor_id = 'main_content_content_vb_tiny_mce';
289
+            }
290 290
 
291
-			global $sd_widgets;
291
+            global $sd_widgets;
292 292
 
293 293
 //			print_r($sd_widgets);exit;
294
-			?>
294
+            ?>
295 295
 
296 296
 			<div class="sd-shortcode-left-wrap">
297 297
 				<?php
298
-				ksort( $sd_widgets );
299
-				//				print_r($sd_widgets);exit;
300
-				if ( ! empty( $sd_widgets ) ) {
301
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
-					foreach ( $sd_widgets as $shortcode => $class ) {
304
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
-					}
307
-					echo "</select>";
298
+                ksort( $sd_widgets );
299
+                //				print_r($sd_widgets);exit;
300
+                if ( ! empty( $sd_widgets ) ) {
301
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
+                    echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
+                    foreach ( $sd_widgets as $shortcode => $class ) {
304
+                        if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
+                    }
307
+                    echo "</select>";
308 308
 
309
-				}
310
-				?>
309
+                }
310
+                ?>
311 311
 				<div class="sd-shortcode-settings"></div>
312 312
 
313 313
 			</div>
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 					<?php if ( $editor_id != '' ) { ?>
319 319
 						<button class="button sd-insert-shortcode-button"
320 320
 								onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
321
-									echo "'" . $editor_id . "'";
322
-								} ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
321
+                                    echo "'" . $editor_id . "'";
322
+                                } ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
323 323
 					<?php } ?>
324 324
 					<button class="button"
325 325
 							onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -327,150 +327,150 @@  discard block
 block discarded – undo
327 327
 			</div>
328 328
 			<?php
329 329
 
330
-			$html = ob_get_clean();
330
+            $html = ob_get_clean();
331 331
 
332
-			if ( wp_doing_ajax() ) {
333
-				echo $html;
334
-				$should_die = true;
332
+            if ( wp_doing_ajax() ) {
333
+                echo $html;
334
+                $should_die = true;
335 335
 
336
-				// some builder get the editor via ajax so we should not die on those occasions
337
-				$dont_die = array(
338
-					'parent_tag',// WP Bakery
339
-					'avia_request' // enfold
340
-				);
336
+                // some builder get the editor via ajax so we should not die on those occasions
337
+                $dont_die = array(
338
+                    'parent_tag',// WP Bakery
339
+                    'avia_request' // enfold
340
+                );
341 341
 
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
344
-						$should_die = false;
345
-					}
346
-				}
342
+                foreach ( $dont_die as $request ) {
343
+                    if ( isset( $_REQUEST[ $request ] ) ) {
344
+                        $should_die = false;
345
+                    }
346
+                }
347 347
 
348
-				if ( $should_die ) {
349
-					wp_die();
350
-				}
348
+                if ( $should_die ) {
349
+                    wp_die();
350
+                }
351 351
 
352
-			} else {
353
-				return $html;
354
-			}
352
+            } else {
353
+                return $html;
354
+            }
355 355
 
356
-			return '';
356
+            return '';
357 357
 
358
-		}
358
+        }
359 359
 
360
-		/**
361
-		 * Output the version in the header.
362
-		 */
363
-		public function generator() {
364
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
-
367
-			// Find source plugin/theme of SD
368
-			$source = array();
369
-			if ( strpos( $file, $plugins_dir ) !== false ) {
370
-				$source = explode( "/", plugin_basename( $file ) );
371
-			} else if ( function_exists( 'get_theme_root' ) ) {
372
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
-
374
-				if ( strpos( $file, $themes_dir ) !== false ) {
375
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
-				}
377
-			}
360
+        /**
361
+         * Output the version in the header.
362
+         */
363
+        public function generator() {
364
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
+
367
+            // Find source plugin/theme of SD
368
+            $source = array();
369
+            if ( strpos( $file, $plugins_dir ) !== false ) {
370
+                $source = explode( "/", plugin_basename( $file ) );
371
+            } else if ( function_exists( 'get_theme_root' ) ) {
372
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
+
374
+                if ( strpos( $file, $themes_dir ) !== false ) {
375
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
+                }
377
+            }
378 378
 
379
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
-		}
379
+            echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
+        }
381 381
 
382
-		/**
383
-		 * Get widget settings.
384
-		 *
385
-		 * @since 1.0.0
386
-		 */
387
-		public static function get_widget_settings() {
388
-			global $sd_widgets;
389
-
390
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
-			if ( ! $shortcode ) {
392
-				wp_die();
393
-			}
394
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
-			if ( ! $widget_args ) {
396
-				wp_die();
397
-			}
398
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
-			if ( ! $class_name ) {
400
-				wp_die();
401
-			}
382
+        /**
383
+         * Get widget settings.
384
+         *
385
+         * @since 1.0.0
386
+         */
387
+        public static function get_widget_settings() {
388
+            global $sd_widgets;
402 389
 
403
-			// invoke an instance method
404
-			$widget = new $class_name;
390
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
+            if ( ! $shortcode ) {
392
+                wp_die();
393
+            }
394
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
+            if ( ! $widget_args ) {
396
+                wp_die();
397
+            }
398
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
+            if ( ! $class_name ) {
400
+                wp_die();
401
+            }
402
+
403
+            // invoke an instance method
404
+            $widget = new $class_name;
405 405
 
406
-			ob_start();
407
-			$widget->form( array() );
408
-			$form = ob_get_clean();
409
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
-			echo "<style>" . $widget->widget_css() . "</style>";
411
-			echo "<script>" . $widget->widget_js() . "</script>";
412
-			?>
406
+            ob_start();
407
+            $widget->form( array() );
408
+            $form = ob_get_clean();
409
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
+            echo "<style>" . $widget->widget_css() . "</style>";
411
+            echo "<script>" . $widget->widget_js() . "</script>";
412
+            ?>
413 413
 			<?php
414
-			wp_die();
415
-		}
414
+            wp_die();
415
+        }
416 416
 
417
-		/**
418
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
419
-		 *
420
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
421
-		 * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
422
-		 *
423
-		 *@since 1.0.0
424
-		 *
425
-		 */
426
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
-			global $sd_widgets, $shortcode_insert_button_once;
428
-			if ( $shortcode_insert_button_once ) {
429
-				return;
430
-			}
431
-			add_thickbox();
417
+        /**
418
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
419
+         *
420
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
421
+         * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
422
+         *
423
+         *@since 1.0.0
424
+         *
425
+         */
426
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
+            global $sd_widgets, $shortcode_insert_button_once;
428
+            if ( $shortcode_insert_button_once ) {
429
+                return;
430
+            }
431
+            add_thickbox();
432 432
 
433 433
 
434
-			/**
435
-			 * Cornerstone makes us play dirty tricks :/
436
-			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437
-			 */
438
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
-				echo '<span id="insert-media-button">';
440
-			}
434
+            /**
435
+             * Cornerstone makes us play dirty tricks :/
436
+             * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437
+             */
438
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
+                echo '<span id="insert-media-button">';
440
+            }
441 441
 
442
-			echo self::shortcode_button( 'this', 'true' );
442
+            echo self::shortcode_button( 'this', 'true' );
443 443
 
444
-			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
-				echo '</span>'; // end #insert-media-button
447
-			}
444
+            // see opening note
445
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
+                echo '</span>'; // end #insert-media-button
447
+            }
448 448
 
449
-			// Add separate script for generatepress theme sections
450
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
-			} else {
452
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
-			}
449
+            // Add separate script for generatepress theme sections
450
+            if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
+            } else {
452
+                self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
+            }
454 454
 
455
-			$shortcode_insert_button_once = true;
456
-		}
455
+            $shortcode_insert_button_once = true;
456
+        }
457 457
 
458
-		/**
459
-		 * Gets the shortcode insert button html.
460
-		 *
461
-		 * @param string $id
462
-		 * @param string $search_for_id
463
-		 *
464
-		 * @return mixed
465
-		 */
466
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
-			ob_start();
468
-			?>
458
+        /**
459
+         * Gets the shortcode insert button html.
460
+         *
461
+         * @param string $id
462
+         * @param string $search_for_id
463
+         *
464
+         * @return mixed
465
+         */
466
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
+            ob_start();
468
+            ?>
469 469
 			<span class="sd-lable-shortcode-inserter">
470 470
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
471
-				if ( $search_for_id ) {
472
-					echo "," . $search_for_id;
473
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
471
+                if ( $search_for_id ) {
472
+                    echo "," . $search_for_id;
473
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
474 474
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
475 475
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
476 476
 						  class="dashicons dashicons-screenoptions"></span>
@@ -481,21 +481,21 @@  discard block
 block discarded – undo
481 481
 			</span>
482 482
 
483 483
 			<?php
484
-			$html = ob_get_clean();
484
+            $html = ob_get_clean();
485 485
 
486
-			// remove line breaks so we can use it in js
487
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
488
-		}
486
+            // remove line breaks so we can use it in js
487
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
488
+        }
489 489
 
490
-		/**
491
-		 * Makes SD work with the siteOrigin page builder.
492
-		 *
493
-		 * @return mixed
494
-		 *@since 1.0.6
495
-		 */
496
-		public static function siteorigin_js() {
497
-			ob_start();
498
-			?>
490
+        /**
491
+         * Makes SD work with the siteOrigin page builder.
492
+         *
493
+         * @return mixed
494
+         *@since 1.0.6
495
+         */
496
+        public static function siteorigin_js() {
497
+            ob_start();
498
+            ?>
499 499
 			<script>
500 500
 				/**
501 501
 				 * Check a form to see what items should be shown or hidden.
@@ -571,29 +571,29 @@  discard block
 block discarded – undo
571 571
 				});
572 572
 			</script>
573 573
 			<?php
574
-			$output = ob_get_clean();
574
+            $output = ob_get_clean();
575 575
 
576
-			/*
576
+            /*
577 577
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
578 578
 			 */
579 579
 
580
-			return str_replace( array(
581
-				'<script>',
582
-				'</script>'
583
-			), '', $output );
584
-		}
580
+            return str_replace( array(
581
+                '<script>',
582
+                '</script>'
583
+            ), '', $output );
584
+        }
585 585
 
586
-		/**
587
-		 * Output the JS and CSS for the shortcode insert button.
588
-		 *
589
-		 * @param string $editor_id
590
-		 * @param string $insert_shortcode_function
591
-		 *
592
-		 *@since 1.0.6
593
-		 *
594
-		 */
595
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
-			?>
586
+        /**
587
+         * Output the JS and CSS for the shortcode insert button.
588
+         *
589
+         * @param string $editor_id
590
+         * @param string $insert_shortcode_function
591
+         *
592
+         *@since 1.0.6
593
+         *
594
+         */
595
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
+            ?>
597 597
 			<style>
598 598
 				.sd-shortcode-left-wrap {
599 599
 					float: left;
@@ -721,35 +721,35 @@  discard block
 block discarded – undo
721 721
 				<?php } ?>
722 722
 			</style>
723 723
 			<?php
724
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
-				echo "<script>" . self::siteorigin_js() . "</script>";
726
-			}
727
-			?>
724
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
+                echo "<script>" . self::siteorigin_js() . "</script>";
726
+            }
727
+            ?>
728 728
 			<script>
729 729
 				<?php
730
-				if(! empty( $insert_shortcode_function )){
731
-					echo $insert_shortcode_function;
732
-				}else{
733
-
734
-				/**
735
-				 * Function for super duper insert shortcode.
736
-				 *
737
-				 * @since 1.0.0
738
-				 */
739
-				?>
730
+                if(! empty( $insert_shortcode_function )){
731
+                    echo $insert_shortcode_function;
732
+                }else{
733
+
734
+                /**
735
+                 * Function for super duper insert shortcode.
736
+                 *
737
+                 * @since 1.0.0
738
+                 */
739
+                ?>
740 740
 				function sd_insert_shortcode($editor_id) {
741 741
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
742 742
 					if ($shortcode) {
743 743
 						if (!$editor_id) {
744 744
 							<?php
745
-							if ( isset( $_REQUEST['et_fb'] ) ) {
746
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
-							} else {
750
-								echo '$editor_id = "#wp-content-editor-container textarea";';
751
-							}
752
-							?>
745
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
746
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
+                            } else {
750
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
751
+                            }
752
+                            ?>
753 753
 						} else {
754 754
 							$editor_id = '#' + $editor_id;
755 755
 						}
@@ -1063,18 +1063,18 @@  discard block
 block discarded – undo
1063 1063
 				}
1064 1064
 			</script>
1065 1065
 			<?php
1066
-		}
1066
+        }
1067 1067
 
1068
-		/**
1069
-		 * Gets some CSS for the widgets screen.
1070
-		 *
1071
-		 * @param bool $advanced If we should include advanced CSS.
1072
-		 *
1073
-		 * @return mixed
1074
-		 */
1075
-		public function widget_css( $advanced = true ) {
1076
-			ob_start();
1077
-			?>
1068
+        /**
1069
+         * Gets some CSS for the widgets screen.
1070
+         *
1071
+         * @param bool $advanced If we should include advanced CSS.
1072
+         *
1073
+         * @return mixed
1074
+         */
1075
+        public function widget_css( $advanced = true ) {
1076
+            ob_start();
1077
+            ?>
1078 1078
 			<style>
1079 1079
 				<?php if( $advanced ){ ?>
1080 1080
 				.sd-advanced-setting {
@@ -1114,26 +1114,26 @@  discard block
 block discarded – undo
1114 1114
 				.elementor-control .sd-argument select[multiple] option{padding:3px}
1115 1115
 			</style>
1116 1116
 			<?php
1117
-			$output = ob_get_clean();
1117
+            $output = ob_get_clean();
1118 1118
 
1119
-			/*
1119
+            /*
1120 1120
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1121 1121
 			 */
1122 1122
 
1123
-			return str_replace( array(
1124
-				'<style>',
1125
-				'</style>'
1126
-			), '', $output );
1127
-		}
1123
+            return str_replace( array(
1124
+                '<style>',
1125
+                '</style>'
1126
+            ), '', $output );
1127
+        }
1128 1128
 
1129
-		/**
1130
-		 * Gets some JS for the widgets screen.
1131
-		 *
1132
-		 * @return mixed
1133
-		 */
1134
-		public function widget_js() {
1135
-			ob_start();
1136
-			?>
1129
+        /**
1130
+         * Gets some JS for the widgets screen.
1131
+         *
1132
+         * @return mixed
1133
+         */
1134
+        public function widget_js() {
1135
+            ob_start();
1136
+            ?>
1137 1137
 			<script>
1138 1138
 
1139 1139
 				/**
@@ -1284,513 +1284,513 @@  discard block
 block discarded – undo
1284 1284
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1285 1285
 			</script>
1286 1286
 			<?php
1287
-			$output = ob_get_clean();
1287
+            $output = ob_get_clean();
1288 1288
 
1289
-			/*
1289
+            /*
1290 1290
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1291 1291
 			 */
1292 1292
 
1293
-			return str_replace( array(
1294
-				'<script>',
1295
-				'</script>'
1296
-			), '', $output );
1297
-		}
1293
+            return str_replace( array(
1294
+                '<script>',
1295
+                '</script>'
1296
+            ), '', $output );
1297
+        }
1298 1298
 
1299 1299
 
1300
-		/**
1301
-		 * Set the name from the argument key.
1302
-		 *
1303
-		 * @param $options
1304
-		 *
1305
-		 * @return mixed
1306
-		 */
1307
-		private function add_name_from_key( $options, $arguments = false ) {
1308
-			if ( ! empty( $options['arguments'] ) ) {
1309
-				foreach ( $options['arguments'] as $key => $val ) {
1310
-					$options['arguments'][ $key ]['name'] = $key;
1311
-				}
1312
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
-				foreach ( $options as $key => $val ) {
1314
-					$options[ $key ]['name'] = $key;
1315
-				}
1316
-			}
1300
+        /**
1301
+         * Set the name from the argument key.
1302
+         *
1303
+         * @param $options
1304
+         *
1305
+         * @return mixed
1306
+         */
1307
+        private function add_name_from_key( $options, $arguments = false ) {
1308
+            if ( ! empty( $options['arguments'] ) ) {
1309
+                foreach ( $options['arguments'] as $key => $val ) {
1310
+                    $options['arguments'][ $key ]['name'] = $key;
1311
+                }
1312
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
+                foreach ( $options as $key => $val ) {
1314
+                    $options[ $key ]['name'] = $key;
1315
+                }
1316
+            }
1317 1317
 
1318
-			return $options;
1319
-		}
1318
+            return $options;
1319
+        }
1320 1320
 
1321
-		/**
1322
-		 * Register the parent shortcode.
1323
-		 *
1324
-		 * @since 1.0.0
1325
-		 */
1326
-		public function register_shortcode() {
1327
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
-		}
1321
+        /**
1322
+         * Register the parent shortcode.
1323
+         *
1324
+         * @since 1.0.0
1325
+         */
1326
+        public function register_shortcode() {
1327
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
+        }
1330 1330
 
1331
-		/**
1332
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1333
-		 *
1334
-		 * @since 1.0.0
1335
-		 */
1336
-		public function render_shortcode() {
1337
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
-			if ( ! current_user_can( 'manage_options' ) ) {
1339
-				wp_die();
1340
-			}
1331
+        /**
1332
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1333
+         *
1334
+         * @since 1.0.0
1335
+         */
1336
+        public function render_shortcode() {
1337
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
+            if ( ! current_user_can( 'manage_options' ) ) {
1339
+                wp_die();
1340
+            }
1341 1341
 
1342
-			// we might need the $post value here so lets set it.
1343
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1345
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
-					global $post;
1347
-					$post = $post_obj;
1348
-				}
1349
-			}
1342
+            // we might need the $post value here so lets set it.
1343
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1345
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
+                    global $post;
1347
+                    $post = $post_obj;
1348
+                }
1349
+            }
1350 1350
 
1351
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
-				$is_preview = $this->is_preview();
1353
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
-				$attributes       = '';
1356
-				if ( ! empty( $attributes_array ) ) {
1357
-					foreach ( $attributes_array as $key => $value ) {
1358
-						if ( is_array( $value ) ) {
1359
-							$value = implode( ",", $value );
1360
-						}
1351
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
+                $is_preview = $this->is_preview();
1353
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
+                $attributes       = '';
1356
+                if ( ! empty( $attributes_array ) ) {
1357
+                    foreach ( $attributes_array as $key => $value ) {
1358
+                        if ( is_array( $value ) ) {
1359
+                            $value = implode( ",", $value );
1360
+                        }
1361
+
1362
+                        if ( ! empty( $value ) ) {
1363
+                            $value = wp_unslash( $value );
1364
+
1365
+                            // Encode [ and ].
1366
+                            if ( $is_preview ) {
1367
+                                $value = $this->encode_shortcodes( $value );
1368
+                            }
1369
+                        }
1370
+                        $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
+                    }
1372
+                }
1361 1373
 
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1374
+                $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1364 1375
 
1365
-							// Encode [ and ].
1366
-							if ( $is_preview ) {
1367
-								$value = $this->encode_shortcodes( $value );
1368
-							}
1369
-						}
1370
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
-					}
1372
-				}
1376
+                $content = do_shortcode( $shortcode );
1373 1377
 
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1378
+                // Decode [ and ].
1379
+                if ( ! empty( $content ) && $is_preview ) {
1380
+                    $content = $this->decode_shortcodes( $content );
1381
+                }
1375 1382
 
1376
-				$content = do_shortcode( $shortcode );
1383
+                echo $content;
1384
+            }
1385
+            wp_die();
1386
+        }
1377 1387
 
1378
-				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1381
-				}
1388
+        /**
1389
+         * Output the shortcode.
1390
+         *
1391
+         * @param array $args
1392
+         * @param string $content
1393
+         *
1394
+         * @return string
1395
+         */
1396
+        public function shortcode_output( $args = array(), $content = '' ) {
1397
+            $_instance = $args;
1382 1398
 
1383
-				echo $content;
1384
-			}
1385
-			wp_die();
1386
-		}
1399
+            $args = $this->argument_values( $args );
1387 1400
 
1388
-		/**
1389
-		 * Output the shortcode.
1390
-		 *
1391
-		 * @param array $args
1392
-		 * @param string $content
1393
-		 *
1394
-		 * @return string
1395
-		 */
1396
-		public function shortcode_output( $args = array(), $content = '' ) {
1397
-			$_instance = $args;
1398
-
1399
-			$args = $this->argument_values( $args );
1400
-
1401
-			// add extra argument so we know its a output to gutenberg
1402
-			//$args
1403
-			$args = $this->string_to_bool( $args );
1404
-
1405
-			// if we have a enclosed shortcode we add it to the special `html` argument
1406
-			if ( ! empty( $content ) ) {
1407
-				$args['html'] = $content;
1408
-			}
1401
+            // add extra argument so we know its a output to gutenberg
1402
+            //$args
1403
+            $args = $this->string_to_bool( $args );
1409 1404
 
1410
-			if ( ! $this->is_preview() ) {
1411
-				/**
1412
-				 * Filters the settings for a particular widget args.
1413
-				 *
1414
-				 * @param array          $args      The current widget instance's settings.
1415
-				 * @param WP_Super_Duper $widget    The current widget settings.
1416
-				 * @param array          $_instance An array of default widget arguments.
1417
-				 *
1418
-				 *@since 1.0.28
1419
-				 *
1420
-				 */
1421
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1405
+            // if we have a enclosed shortcode we add it to the special `html` argument
1406
+            if ( ! empty( $content ) ) {
1407
+                $args['html'] = $content;
1408
+            }
1422 1409
 
1423
-				if ( ! is_array( $args ) ) {
1424
-					return $args;
1425
-				}
1426
-			}
1410
+            if ( ! $this->is_preview() ) {
1411
+                /**
1412
+                 * Filters the settings for a particular widget args.
1413
+                 *
1414
+                 * @param array          $args      The current widget instance's settings.
1415
+                 * @param WP_Super_Duper $widget    The current widget settings.
1416
+                 * @param array          $_instance An array of default widget arguments.
1417
+                 *
1418
+                 *@since 1.0.28
1419
+                 *
1420
+                 */
1421
+                $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1422
+
1423
+                if ( ! is_array( $args ) ) {
1424
+                    return $args;
1425
+                }
1426
+            }
1427 1427
 
1428
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
-			$class .= " sdel-".$this->get_instance_hash();
1428
+            $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
+            $class .= " sdel-".$this->get_instance_hash();
1430 1430
 
1431
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1431
+            $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
+            $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1433 1433
 
1434
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1434
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1436 1436
 
1437
-			$shortcode_args = array();
1438
-			$output         = '';
1439
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
-				$no_wrap = true;
1442
-			}
1443
-			$main_content = $this->output( $args, $shortcode_args, $content );
1444
-			if ( $main_content && ! $no_wrap ) {
1445
-				// wrap the shortcode in a div with the same class as the widget
1446
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
-				if ( ! empty( $args['title'] ) ) {
1448
-					// if its a shortcode and there is a title try to grab the title wrappers
1449
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
-					if ( empty( $instance ) ) {
1451
-						global $wp_registered_sidebars;
1452
-						if ( ! empty( $wp_registered_sidebars ) ) {
1453
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1454
-								if ( ! empty( $sidebar['before_title'] ) ) {
1455
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1456
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1457
-									break;
1458
-								}
1459
-							}
1460
-						}
1461
-					}
1462
-					$output .= $this->output_title( $shortcode_args, $args );
1463
-				}
1464
-				$output .= $main_content;
1465
-				$output .= '</div>';
1466
-			} elseif ( $main_content && $no_wrap ) {
1467
-				$output .= $main_content;
1468
-			}
1437
+            $shortcode_args = array();
1438
+            $output         = '';
1439
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
+            if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
+                $no_wrap = true;
1442
+            }
1443
+            $main_content = $this->output( $args, $shortcode_args, $content );
1444
+            if ( $main_content && ! $no_wrap ) {
1445
+                // wrap the shortcode in a div with the same class as the widget
1446
+                $output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
+                if ( ! empty( $args['title'] ) ) {
1448
+                    // if its a shortcode and there is a title try to grab the title wrappers
1449
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
+                    if ( empty( $instance ) ) {
1451
+                        global $wp_registered_sidebars;
1452
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1453
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1454
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1455
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1456
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1457
+                                    break;
1458
+                                }
1459
+                            }
1460
+                        }
1461
+                    }
1462
+                    $output .= $this->output_title( $shortcode_args, $args );
1463
+                }
1464
+                $output .= $main_content;
1465
+                $output .= '</div>';
1466
+            } elseif ( $main_content && $no_wrap ) {
1467
+                $output .= $main_content;
1468
+            }
1469 1469
 
1470
-			// if preview show a placeholder if empty
1471
-			if ( $this->is_preview() && $output == '' ) {
1472
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
-			}
1470
+            // if preview show a placeholder if empty
1471
+            if ( $this->is_preview() && $output == '' ) {
1472
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
+            }
1474 1474
 
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
-		}
1475
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
+        }
1477 1477
 
1478
-		/**
1479
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1480
-		 *
1481
-		 * @param string $name
1482
-		 *
1483
-		 * @return string
1484
-		 */
1485
-		public function preview_placeholder_text( $name = '' ) {
1486
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
-		}
1478
+        /**
1479
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1480
+         *
1481
+         * @param string $name
1482
+         *
1483
+         * @return string
1484
+         */
1485
+        public function preview_placeholder_text( $name = '' ) {
1486
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
+        }
1488 1488
 
1489
-		/**
1490
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1491
-		 *
1492
-		 * @param $options
1493
-		 *
1494
-		 * @return mixed
1495
-		 */
1496
-		public function string_to_bool( $options ) {
1497
-			// convert bool strings to booleans
1498
-			foreach ( $options as $key => $val ) {
1499
-				if ( $val == 'false' ) {
1500
-					$options[ $key ] = false;
1501
-				} elseif ( $val == 'true' ) {
1502
-					$options[ $key ] = true;
1503
-				}
1504
-			}
1489
+        /**
1490
+         * Sometimes booleans values can be turned to strings, so we fix that.
1491
+         *
1492
+         * @param $options
1493
+         *
1494
+         * @return mixed
1495
+         */
1496
+        public function string_to_bool( $options ) {
1497
+            // convert bool strings to booleans
1498
+            foreach ( $options as $key => $val ) {
1499
+                if ( $val == 'false' ) {
1500
+                    $options[ $key ] = false;
1501
+                } elseif ( $val == 'true' ) {
1502
+                    $options[ $key ] = true;
1503
+                }
1504
+            }
1505 1505
 
1506
-			return $options;
1507
-		}
1506
+            return $options;
1507
+        }
1508 1508
 
1509
-		/**
1510
-		 * Get the argument values that are also filterable.
1511
-		 *
1512
-		 * @param $instance
1513
-		 *
1514
-		 * @return array
1515
-		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516
-		 *
1517
-		 */
1518
-		public function argument_values( $instance ) {
1519
-			$argument_values = array();
1520
-
1521
-			// set widget instance
1522
-			$this->instance = $instance;
1523
-
1524
-			if ( empty( $this->arguments ) ) {
1525
-				$this->arguments = $this->get_arguments();
1526
-			}
1509
+        /**
1510
+         * Get the argument values that are also filterable.
1511
+         *
1512
+         * @param $instance
1513
+         *
1514
+         * @return array
1515
+         *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516
+         *
1517
+         */
1518
+        public function argument_values( $instance ) {
1519
+            $argument_values = array();
1527 1520
 
1528
-			if ( ! empty( $this->arguments ) ) {
1529
-				foreach ( $this->arguments as $key => $args ) {
1530
-					// set the input name from the key
1531
-					$args['name'] = $key;
1532
-					//
1533
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
-						// don't set default for an empty checkbox
1536
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
-						$argument_values[ $key ] = $args['default'];
1538
-					}
1539
-				}
1540
-			}
1521
+            // set widget instance
1522
+            $this->instance = $instance;
1541 1523
 
1542
-			return $argument_values;
1543
-		}
1524
+            if ( empty( $this->arguments ) ) {
1525
+                $this->arguments = $this->get_arguments();
1526
+            }
1544 1527
 
1545
-		/**
1546
-		 * Set arguments in super duper.
1547
-		 *
1548
-		 * @return array Set arguments.
1549
-		 *@since 1.0.0
1550
-		 *
1551
-		 */
1552
-		public function set_arguments() {
1553
-			return $this->arguments;
1554
-		}
1528
+            if ( ! empty( $this->arguments ) ) {
1529
+                foreach ( $this->arguments as $key => $args ) {
1530
+                    // set the input name from the key
1531
+                    $args['name'] = $key;
1532
+                    //
1533
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
+                    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
+                        // don't set default for an empty checkbox
1536
+                    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
+                        $argument_values[ $key ] = $args['default'];
1538
+                    }
1539
+                }
1540
+            }
1555 1541
 
1556
-		/**
1557
-		 * Get arguments in super duper.
1558
-		 *
1559
-		 * @return array Get arguments.
1560
-		 *@since 1.0.0
1561
-		 *
1562
-		 */
1563
-		public function get_arguments() {
1564
-			if ( empty( $this->arguments ) ) {
1565
-				$this->arguments = $this->set_arguments();
1566
-			}
1542
+            return $argument_values;
1543
+        }
1567 1544
 
1568
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1545
+        /**
1546
+         * Set arguments in super duper.
1547
+         *
1548
+         * @return array Set arguments.
1549
+         *@since 1.0.0
1550
+         *
1551
+         */
1552
+        public function set_arguments() {
1553
+            return $this->arguments;
1554
+        }
1570 1555
 
1571
-			return $this->arguments;
1572
-		}
1556
+        /**
1557
+         * Get arguments in super duper.
1558
+         *
1559
+         * @return array Get arguments.
1560
+         *@since 1.0.0
1561
+         *
1562
+         */
1563
+        public function get_arguments() {
1564
+            if ( empty( $this->arguments ) ) {
1565
+                $this->arguments = $this->set_arguments();
1566
+            }
1573 1567
 
1574
-		/**
1575
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1576
-		 *
1577
-		 * @param array $args
1578
-		 * @param array $widget_args
1579
-		 * @param string $content
1580
-		 */
1581
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1568
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1582 1570
 
1583
-		}
1571
+            return $this->arguments;
1572
+        }
1584 1573
 
1585
-		/**
1586
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1587
-		 */
1588
-		public function register_block() {
1589
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1590
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
-			}
1593
-		}
1574
+        /**
1575
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1576
+         *
1577
+         * @param array $args
1578
+         * @param array $widget_args
1579
+         * @param string $content
1580
+         */
1581
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1594 1582
 
1595
-		/**
1596
-		 * Check if we need to show advanced options.
1597
-		 *
1598
-		 * @return bool
1599
-		 */
1600
-		public function block_show_advanced() {
1601
-
1602
-			$show      = false;
1603
-			$arguments = $this->get_arguments();
1604
-
1605
-			if ( ! empty( $arguments ) ) {
1606
-				foreach ( $arguments as $argument ) {
1607
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
-						$show = true;
1609
-						break; // no need to continue if we know we have it
1610
-					}
1611
-				}
1612
-			}
1583
+        }
1613 1584
 
1614
-			return $show;
1615
-		}
1585
+        /**
1586
+         * Add the dynamic block code inline when the wp-block in enqueued.
1587
+         */
1588
+        public function register_block() {
1589
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1590
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
+            }
1593
+        }
1616 1594
 
1617
-		/**
1618
-		 * Get the url path to the current folder.
1619
-		 *
1620
-		 * @return string
1621
-		 */
1622
-		public function get_url() {
1623
-			$url = $this->url;
1624
-
1625
-			if ( ! $url ) {
1626
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1628
-
1629
-				// Replace http:// to https://.
1630
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1632
-				}
1595
+        /**
1596
+         * Check if we need to show advanced options.
1597
+         *
1598
+         * @return bool
1599
+         */
1600
+        public function block_show_advanced() {
1633 1601
 
1634
-				// Check if we are inside a plugin
1635
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1637
-				$url = trailingslashit( $url );
1638
-				$this->url = $url;
1639
-			}
1602
+            $show      = false;
1603
+            $arguments = $this->get_arguments();
1640 1604
 
1641
-			return $url;
1642
-		}
1605
+            if ( ! empty( $arguments ) ) {
1606
+                foreach ( $arguments as $argument ) {
1607
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
+                        $show = true;
1609
+                        break; // no need to continue if we know we have it
1610
+                    }
1611
+                }
1612
+            }
1643 1613
 
1644
-		/**
1645
-		 * Get the url path to the current folder.
1646
-		 *
1647
-		 * @return string
1648
-		 */
1649
-		public function get_url_old() {
1614
+            return $show;
1615
+        }
1650 1616
 
1651
-			$url = $this->url;
1617
+        /**
1618
+         * Get the url path to the current folder.
1619
+         *
1620
+         * @return string
1621
+         */
1622
+        public function get_url() {
1623
+            $url = $this->url;
1652 1624
 
1653
-			if ( ! $url ) {
1654
-				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1625
+            if ( ! $url ) {
1626
+                $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
+                $content_url = untrailingslashit( WP_CONTENT_URL );
1656 1628
 
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
1629
+                // Replace http:// to https://.
1630
+                if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
+                    $content_url = str_replace( 'http://', 'https://', $content_url );
1632
+                }
1659 1633
 
1660
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
-					$this->url = $url;
1663
-				}
1664
-			}
1634
+                // Check if we are inside a plugin
1635
+                $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
+                $url = str_replace( $content_dir, $content_url, $file_dir );
1637
+                $url = trailingslashit( $url );
1638
+                $this->url = $url;
1639
+            }
1665 1640
 
1641
+            return $url;
1642
+        }
1666 1643
 
1667
-			return $url;
1668
-		}
1644
+        /**
1645
+         * Get the url path to the current folder.
1646
+         *
1647
+         * @return string
1648
+         */
1649
+        public function get_url_old() {
1669 1650
 
1670
-		/**
1671
-		 * Generate the block icon.
1672
-		 *
1673
-		 * Enables the use of Font Awesome icons.
1674
-		 *
1675
-		 * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1676
-		 *
1677
-		 * @param $icon
1678
-		 *
1679
-		 * @return string
1680
-		 *@since 1.1.0
1681
-		 */
1682
-		public function get_block_icon( $icon ) {
1683
-
1684
-			// check if we have a Font Awesome icon
1685
-			$fa_type = '';
1686
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
-				$fa_type = 'solid';
1688
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
-				$fa_type = 'regular';
1690
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
-				$fa_type = 'brands';
1692
-			} else {
1693
-				$icon = "'" . $icon . "'";
1694
-			}
1651
+            $url = $this->url;
1695 1652
 
1696
-			// set the icon if we found one
1697
-			if ( $fa_type ) {
1698
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
-				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
-			}
1653
+            if ( ! $url ) {
1654
+                // check if we are inside a plugin
1655
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1701 1656
 
1702
-			return $icon;
1703
-		}
1657
+                $dir_parts = explode( "/wp-content/", $file_dir );
1658
+                $url_parts = explode( "/wp-content/", plugins_url() );
1704 1659
 
1705
-		public function group_arguments( $arguments ) {
1706
-			if ( ! empty( $arguments ) ) {
1707
-				$temp_arguments = array();
1708
-				$general        = __( "General", 'ayecode-connect' );
1709
-				$add_sections   = false;
1710
-				foreach ( $arguments as $key => $args ) {
1711
-					if ( isset( $args['group'] ) ) {
1712
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1713
-						$add_sections                             = true;
1714
-					} else {
1715
-						$temp_arguments[ $general ][ $key ] = $args;
1716
-					}
1717
-				}
1660
+                if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
+                    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
+                    $this->url = $url;
1663
+                }
1664
+            }
1718 1665
 
1719
-				// only add sections if more than one
1720
-				if ( $add_sections ) {
1721
-					$arguments = $temp_arguments;
1722
-				}
1723
-			}
1724 1666
 
1725
-			return $arguments;
1726
-		}
1667
+            return $url;
1668
+        }
1727 1669
 
1728
-		/**
1729
-		 * Parse used group tabs.
1730
-		 *
1731
-		 * @since 1.1.17
1732
-		 */
1733
-		public function group_block_tabs( $tabs, $arguments ) {
1734
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
-				$has_sections = false;
1736
-
1737
-				foreach ( $this->arguments as $key => $args ) {
1738
-					if ( isset( $args['group'] ) ) {
1739
-						$has_sections = true;
1740
-						break;
1741
-					}
1742
-				}
1670
+        /**
1671
+         * Generate the block icon.
1672
+         *
1673
+         * Enables the use of Font Awesome icons.
1674
+         *
1675
+         * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1676
+         *
1677
+         * @param $icon
1678
+         *
1679
+         * @return string
1680
+         *@since 1.1.0
1681
+         */
1682
+        public function get_block_icon( $icon ) {
1683
+
1684
+            // check if we have a Font Awesome icon
1685
+            $fa_type = '';
1686
+            if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
+                $fa_type = 'solid';
1688
+            } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
+                $fa_type = 'regular';
1690
+            } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
+                $fa_type = 'brands';
1692
+            } else {
1693
+                $icon = "'" . $icon . "'";
1694
+            }
1743 1695
 
1744
-				if ( ! $has_sections ) {
1745
-					return $tabs;
1746
-				}
1696
+            // set the icon if we found one
1697
+            if ( $fa_type ) {
1698
+                $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
+                $icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
+            }
1747 1701
 
1748
-				$new_tabs = array();
1702
+            return $icon;
1703
+        }
1749 1704
 
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1751
-					$new_groups = array();
1705
+        public function group_arguments( $arguments ) {
1706
+            if ( ! empty( $arguments ) ) {
1707
+                $temp_arguments = array();
1708
+                $general        = __( "General", 'ayecode-connect' );
1709
+                $add_sections   = false;
1710
+                foreach ( $arguments as $key => $args ) {
1711
+                    if ( isset( $args['group'] ) ) {
1712
+                        $temp_arguments[ $args['group'] ][ $key ] = $args;
1713
+                        $add_sections                             = true;
1714
+                    } else {
1715
+                        $temp_arguments[ $general ][ $key ] = $args;
1716
+                    }
1717
+                }
1752 1718
 
1753
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
-						foreach ( $tab['groups'] as $group ) {
1755
-							if ( isset( $arguments[ $group ] ) ) {
1756
-								$new_groups[] = $group;
1757
-							}
1758
-						}
1759
-					}
1719
+                // only add sections if more than one
1720
+                if ( $add_sections ) {
1721
+                    $arguments = $temp_arguments;
1722
+                }
1723
+            }
1760 1724
 
1761
-					if ( ! empty( $new_groups ) ) {
1762
-						$tab['groups'] = $new_groups;
1725
+            return $arguments;
1726
+        }
1763 1727
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1765
-					}
1766
-				}
1728
+        /**
1729
+         * Parse used group tabs.
1730
+         *
1731
+         * @since 1.1.17
1732
+         */
1733
+        public function group_block_tabs( $tabs, $arguments ) {
1734
+            if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
+                $has_sections = false;
1736
+
1737
+                foreach ( $this->arguments as $key => $args ) {
1738
+                    if ( isset( $args['group'] ) ) {
1739
+                        $has_sections = true;
1740
+                        break;
1741
+                    }
1742
+                }
1767 1743
 
1768
-				$tabs = $new_tabs;
1769
-			}
1744
+                if ( ! $has_sections ) {
1745
+                    return $tabs;
1746
+                }
1770 1747
 
1771
-			return $tabs;
1772
-		}
1748
+                $new_tabs = array();
1749
+
1750
+                foreach ( $tabs as $tab_key => $tab ) {
1751
+                    $new_groups = array();
1752
+
1753
+                    if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
+                        foreach ( $tab['groups'] as $group ) {
1755
+                            if ( isset( $arguments[ $group ] ) ) {
1756
+                                $new_groups[] = $group;
1757
+                            }
1758
+                        }
1759
+                    }
1760
+
1761
+                    if ( ! empty( $new_groups ) ) {
1762
+                        $tab['groups'] = $new_groups;
1773 1763
 
1774
-		/**
1775
-		 * Output the JS for building the dynamic Guntenberg block.
1776
-		 *
1777
-		 * @return mixed
1778
-		 *@since 1.0.9 Save numbers as numbers and not strings.
1779
-		 * @since 1.1.0 Font Awesome classes can be used for icons.
1780
-		 * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1781
-		 */
1782
-		public function block() {
1783
-			global $sd_is_js_functions_loaded, $aui_bs5;
1784
-
1785
-			$show_advanced = $this->block_show_advanced();
1786
-
1787
-			ob_start();
1788
-			?>
1764
+                        $new_tabs[ $tab_key ] = $tab;
1765
+                    }
1766
+                }
1767
+
1768
+                $tabs = $new_tabs;
1769
+            }
1770
+
1771
+            return $tabs;
1772
+        }
1773
+
1774
+        /**
1775
+         * Output the JS for building the dynamic Guntenberg block.
1776
+         *
1777
+         * @return mixed
1778
+         *@since 1.0.9 Save numbers as numbers and not strings.
1779
+         * @since 1.1.0 Font Awesome classes can be used for icons.
1780
+         * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1781
+         */
1782
+        public function block() {
1783
+            global $sd_is_js_functions_loaded, $aui_bs5;
1784
+
1785
+            $show_advanced = $this->block_show_advanced();
1786
+
1787
+            ob_start();
1788
+            ?>
1789 1789
 			<script>
1790 1790
 			<?php
1791
-			if ( ! $sd_is_js_functions_loaded ) {
1792
-				$sd_is_js_functions_loaded = true;
1793
-			?>
1791
+            if ( ! $sd_is_js_functions_loaded ) {
1792
+                $sd_is_js_functions_loaded = true;
1793
+            ?>
1794 1794
 function sd_show_view_options($this){
1795 1795
 	if(jQuery($this).html().length){
1796 1796
 		jQuery($this).html('');
@@ -2290,8 +2290,8 @@  discard block
 block discarded – undo
2290 2290
 				$classes = [];
2291 2291
 
2292 2292
 				<?php
2293
-				if($aui_bs5){
2294
-					?>
2293
+                if($aui_bs5){
2294
+                    ?>
2295 2295
 				$aui_bs5 = true;
2296 2296
 				$p_ml = 'ms-';
2297 2297
 				$p_mr = 'me-';
@@ -2299,8 +2299,8 @@  discard block
 block discarded – undo
2299 2299
 				$p_pl = 'ps-';
2300 2300
 				$p_pr = 'pe-';
2301 2301
 					<?php
2302
-				}else{
2303
-						?>
2302
+                }else{
2303
+                        ?>
2304 2304
 				$aui_bs5 = false;
2305 2305
 				$p_ml = 'ml-';
2306 2306
 				$p_mr = 'mr-';
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
 				$p_pl = 'pl-';
2309 2309
 				$p_pr = 'pr-';
2310 2310
 					<?php
2311
-				}
2312
-				?>
2311
+                }
2312
+                ?>
2313 2313
 
2314 2314
 				// margins
2315 2315
 				if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] );  $mt = $args['mt']; }else{$mt = null;}
@@ -2493,12 +2493,12 @@  discard block
 block discarded – undo
2493 2493
 			<?php
2494 2494
 
2495 2495
 
2496
-			}
2496
+            }
2497 2497
 
2498
-			if(method_exists($this,'block_global_js')){
2499
-					echo $this->block_global_js();
2500
-			}
2501
-			?>
2498
+            if(method_exists($this,'block_global_js')){
2499
+                    echo $this->block_global_js();
2500
+            }
2501
+            ?>
2502 2502
 
2503 2503
 jQuery(function() {
2504 2504
 
@@ -2551,13 +2551,13 @@  discard block
 block discarded – undo
2551 2551
 						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2552 2552
 						supports: {
2553 2553
 							<?php
2554
-							if(!isset($this->options['block-supports']['renaming'])){
2555
-								$this->options['block-supports']['renaming'] = false;
2556
-							}
2557
-							if ( isset( $this->options['block-supports'] ) ) {
2558
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2559
-							}
2560
-							?>
2554
+                            if(!isset($this->options['block-supports']['renaming'])){
2555
+                                $this->options['block-supports']['renaming'] = false;
2556
+                            }
2557
+                            if ( isset( $this->options['block-supports'] ) ) {
2558
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
2559
+                            }
2560
+                            ?>
2561 2561
 						},
2562 2562
 						__experimentalLabel( attributes, { context } ) {
2563 2563
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
@@ -2567,174 +2567,174 @@  discard block
 block discarded – undo
2567 2567
 						},
2568 2568
 						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
2569 2569
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2570
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2571
-						}
2572
-
2573
-
2574
-						// block hover preview.
2575
-						$example_args = array();
2576
-						if(!empty($this->arguments)){
2577
-							foreach($this->arguments as $key => $a_args){
2578
-								if(isset($a_args['example'])){
2579
-									$example_args[$key] = $a_args['example'];
2580
-								}
2581
-							}
2582
-						}
2583
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
-						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
-							// no preview if set to false
2587
-						}elseif( !empty( $example_args ) ){
2588
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
-						}elseif( !empty( $this->options['example'] ) ){
2590
-							unset($this->options['example']['viewportWidth']);
2591
-							unset($this->options['example']['innerBlocks']);
2592
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2593
-							$example_parts = array();
2594
-							if($example_atts){
2595
-								$example_parts[] = rtrim($example_atts,",");
2596
-							}
2597
-							if($viewport_width){
2598
-								$example_parts[] = $viewport_width;
2599
-							}
2600
-							if($example_inner_blocks){
2601
-								$example_parts[] = $example_inner_blocks;
2602
-							}
2603
-							if(!empty($example_parts)){
2604
-								echo "example : {".implode(',', $example_parts)."},";
2605
-							}
2606
-						}else{
2607
-							echo 'example : {viewportWidth: 500},';
2608
-						}
2609
-
2610
-
2611
-
2612
-						// limit to parent
2613
-						if( !empty( $this->options['parent'] ) ){
2614
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
-						}
2616
-
2617
-						// limit allowed blocks
2618
-						if( !empty( $this->options['allowed-blocks'] ) ){
2619
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
-						}
2621
-
2622
-						// maybe set no_wrap
2623
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
-							$no_wrap = true;
2626
-						}
2627
-						if ( $no_wrap ) {
2628
-							$this->options['block-wrap'] = '';
2629
-						}
2630
-
2631
-						// maybe load the drag/drop functions.
2632
-						$img_drag_drop = false;
2633
-
2634
-						$show_alignment = false;
2635
-						// align feature
2636
-						/*echo "supports: {";
2570
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
2571
+                        }
2572
+
2573
+
2574
+                        // block hover preview.
2575
+                        $example_args = array();
2576
+                        if(!empty($this->arguments)){
2577
+                            foreach($this->arguments as $key => $a_args){
2578
+                                if(isset($a_args['example'])){
2579
+                                    $example_args[$key] = $a_args['example'];
2580
+                                }
2581
+                            }
2582
+                        }
2583
+                        $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
+                        $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
+                        if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
+                            // no preview if set to false
2587
+                        }elseif( !empty( $example_args ) ){
2588
+                            echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
+                        }elseif( !empty( $this->options['example'] ) ){
2590
+                            unset($this->options['example']['viewportWidth']);
2591
+                            unset($this->options['example']['innerBlocks']);
2592
+                            $example_atts = $this->array_to_attributes( $this->options['example'] );
2593
+                            $example_parts = array();
2594
+                            if($example_atts){
2595
+                                $example_parts[] = rtrim($example_atts,",");
2596
+                            }
2597
+                            if($viewport_width){
2598
+                                $example_parts[] = $viewport_width;
2599
+                            }
2600
+                            if($example_inner_blocks){
2601
+                                $example_parts[] = $example_inner_blocks;
2602
+                            }
2603
+                            if(!empty($example_parts)){
2604
+                                echo "example : {".implode(',', $example_parts)."},";
2605
+                            }
2606
+                        }else{
2607
+                            echo 'example : {viewportWidth: 500},';
2608
+                        }
2609
+
2610
+
2611
+
2612
+                        // limit to parent
2613
+                        if( !empty( $this->options['parent'] ) ){
2614
+                            echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
+                        }
2616
+
2617
+                        // limit allowed blocks
2618
+                        if( !empty( $this->options['allowed-blocks'] ) ){
2619
+                            echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
+                        }
2621
+
2622
+                        // maybe set no_wrap
2623
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
+                            $no_wrap = true;
2626
+                        }
2627
+                        if ( $no_wrap ) {
2628
+                            $this->options['block-wrap'] = '';
2629
+                        }
2630
+
2631
+                        // maybe load the drag/drop functions.
2632
+                        $img_drag_drop = false;
2633
+
2634
+                        $show_alignment = false;
2635
+                        // align feature
2636
+                        /*echo "supports: {";
2637 2637
 						echo "	align: true,";
2638 2638
 						echo "  html: false";
2639 2639
 						echo "},";*/
2640 2640
 
2641 2641
 
2642
-							echo "attributes : {";
2643
-
2644
-							if ( $show_advanced ) {
2645
-								echo "show_advanced: {";
2646
-								echo "	type: 'boolean',";
2647
-								echo "  default: false,";
2648
-								echo "},";
2649
-							}
2650
-
2651
-							// block wrap element
2652
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
-								echo "block_wrap: {";
2654
-								echo "	type: 'string',";
2655
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
-								echo "},";
2657
-							}
2658
-
2659
-
2660
-							if ( ! empty( $this->arguments ) ) {
2661
-
2662
-								foreach ( $this->arguments as $key => $args ) {
2663
-
2664
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
-										$img_drag_drop = true;
2666
-									}
2667
-
2668
-									// set if we should show alignment
2669
-									if ( $key == 'alignment' ) {
2670
-										$show_alignment = true;
2671
-									}
2672
-
2673
-									$extra = '';
2674
-
2675
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
-										continue;
2677
-									}
2678
-									elseif ( $args['type'] == 'checkbox' ) {
2679
-										$type    = 'boolean';
2680
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
-									} elseif ( $args['type'] == 'number' ) {
2682
-										$type    = 'number';
2683
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
-										$type = 'array';
2686
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
-										} else {
2689
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
-										}
2691
-									} elseif ( $args['type'] == 'tagselect' ) {
2692
-										$type    = 'array';
2693
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
-									} elseif ( $args['type'] == 'multiselect' ) {
2695
-										$type    = 'array';
2696
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
-									} elseif ( $args['type'] == 'image_xy' ) {
2698
-										$type    = 'object';
2699
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
-									} elseif ( $args['type'] == 'image' ) {
2701
-										$type    = 'string';
2702
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
-
2704
-										// add a field for ID
2705
-	//                                    echo $key . "_id : {";
2706
-	//                                    echo "type : 'number',";
2707
-	//                                    echo "},";
2708
-	//                                    echo $key . "_xy : {";
2709
-	//                                    echo "type : 'object',";
2710
-	//                                    echo "},";
2711
-
2712
-									} else {
2713
-										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
-
2716
-									}
2717
-									echo $key . " : {";
2718
-									echo "type : '$type',";
2719
-									echo "default : $default,";
2720
-									echo "},";
2721
-								}
2722
-							}
2723
-
2724
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
-							echo "sd_shortcode : {type : 'string',default: ''},";
2726
-
2727
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
-								echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
-							}
2730
-
2731
-							echo "className: { type: 'string', default: '' },";
2732
-
2733
-							echo "},";
2734
-
2735
-
2736
-
2737
-						?>
2642
+                            echo "attributes : {";
2643
+
2644
+                            if ( $show_advanced ) {
2645
+                                echo "show_advanced: {";
2646
+                                echo "	type: 'boolean',";
2647
+                                echo "  default: false,";
2648
+                                echo "},";
2649
+                            }
2650
+
2651
+                            // block wrap element
2652
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
+                                echo "block_wrap: {";
2654
+                                echo "	type: 'string',";
2655
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
+                                echo "},";
2657
+                            }
2658
+
2659
+
2660
+                            if ( ! empty( $this->arguments ) ) {
2661
+
2662
+                                foreach ( $this->arguments as $key => $args ) {
2663
+
2664
+                                    if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
+                                        $img_drag_drop = true;
2666
+                                    }
2667
+
2668
+                                    // set if we should show alignment
2669
+                                    if ( $key == 'alignment' ) {
2670
+                                        $show_alignment = true;
2671
+                                    }
2672
+
2673
+                                    $extra = '';
2674
+
2675
+                                    if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
+                                        continue;
2677
+                                    }
2678
+                                    elseif ( $args['type'] == 'checkbox' ) {
2679
+                                        $type    = 'boolean';
2680
+                                        $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
+                                    } elseif ( $args['type'] == 'number' ) {
2682
+                                        $type    = 'number';
2683
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
+                                    } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
+                                        $type = 'array';
2686
+                                        if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
+                                            $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
+                                        } else {
2689
+                                            $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
+                                        }
2691
+                                    } elseif ( $args['type'] == 'tagselect' ) {
2692
+                                        $type    = 'array';
2693
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
+                                    } elseif ( $args['type'] == 'multiselect' ) {
2695
+                                        $type    = 'array';
2696
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
+                                    } elseif ( $args['type'] == 'image_xy' ) {
2698
+                                        $type    = 'object';
2699
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
+                                    } elseif ( $args['type'] == 'image' ) {
2701
+                                        $type    = 'string';
2702
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
+
2704
+                                        // add a field for ID
2705
+    //                                    echo $key . "_id : {";
2706
+    //                                    echo "type : 'number',";
2707
+    //                                    echo "},";
2708
+    //                                    echo $key . "_xy : {";
2709
+    //                                    echo "type : 'object',";
2710
+    //                                    echo "},";
2711
+
2712
+                                    } else {
2713
+                                        $type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
+
2716
+                                    }
2717
+                                    echo $key . " : {";
2718
+                                    echo "type : '$type',";
2719
+                                    echo "default : $default,";
2720
+                                    echo "},";
2721
+                                }
2722
+                            }
2723
+
2724
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
+                            echo "sd_shortcode : {type : 'string',default: ''},";
2726
+
2727
+                            if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
+                                echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
+                            }
2730
+
2731
+                            echo "className: { type: 'string', default: '' },";
2732
+
2733
+                            echo "},";
2734
+
2735
+
2736
+
2737
+                        ?>
2738 2738
 
2739 2739
 						// The "edit" property must be a valid function.
2740 2740
 						edit: function (props) {
@@ -2809,10 +2809,10 @@  discard block
 block discarded – undo
2809 2809
 							}
2810 2810
 
2811 2811
 							<?php
2812
-							if(!empty($this->options['block-edit-raw'])) {
2813
-								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
-							}else{
2815
-							?>
2812
+                            if(!empty($this->options['block-edit-raw'])) {
2813
+                                echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
+                            }else{
2815
+                            ?>
2816 2816
 
2817 2817
 function hasSelectedInnerBlock(props) {
2818 2818
 	const select = wp.data.select('core/editor');
@@ -2834,9 +2834,9 @@  discard block
 block discarded – undo
2834 2834
 
2835 2835
 	var $value = '';
2836 2836
 	<?php
2837
-	// if we have a post_type and a category then link them
2838
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
-	?>
2837
+    // if we have a post_type and a category then link them
2838
+    if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
+    ?>
2840 2840
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2841 2841
 		$pt = props.attributes.post_type;
2842 2842
 		if(post_type_rest_slugs.length){
@@ -2849,11 +2849,11 @@  discard block
 block discarded – undo
2849 2849
 			term_query_type = $pt;
2850 2850
 		}
2851 2851
 <?php
2852
-	$cat_path = '';
2853
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
-	}
2852
+    $cat_path = '';
2853
+    if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
+        $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
+        $cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
+    }
2857 2857
 ?>
2858 2858
 		/* taxonomies */
2859 2859
 		if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){
@@ -2945,7 +2945,7 @@  discard block
 block discarded – undo
2945 2945
 <?php
2946 2946
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947 2947
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2948
-	echo 'const { deviceType } = "";';
2948
+    echo 'const { deviceType } = "";';
2949 2949
 }else{
2950 2950
 ?>
2951 2951
 /** Get device type const. */
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
 										'attributes': props.attributes,
3010 3010
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
3011 3011
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
3012
-										echo $post->ID;
3013
-									}else{echo '0';}?>,
3012
+                                        echo $post->ID;
3013
+                                    }else{echo '0';}?>,
3014 3014
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
3015 3015
 									};
3016 3016
 
@@ -3024,20 +3024,20 @@  discard block
 block discarded – undo
3024 3024
 										}
3025 3025
 
3026 3026
 										 <?php
3027
-										if(!empty($this->options['nested-block'])){
3028
-											?>
3027
+                                        if(!empty($this->options['nested-block'])){
3028
+                                            ?>
3029 3029
 											// props.setAttributes({content: env});
3030 3030
 										is_fetching = false;
3031 3031
 										prev_attributes[props.clientId] = props.attributes;
3032 3032
 											 <?php
3033
-										}else{
3034
-										?>
3033
+                                        }else{
3034
+                                        ?>
3035 3035
 										props.setAttributes({content: env});
3036 3036
 										is_fetching = false;
3037 3037
 										prev_attributes[props.clientId] = props.attributes;
3038 3038
 										<?php
3039
-										}
3040
-										?>
3039
+                                        }
3040
+                                        ?>
3041 3041
 
3042 3042
 
3043 3043
 										// if AUI is active call the js init function
@@ -3056,31 +3056,31 @@  discard block
 block discarded – undo
3056 3056
 							}
3057 3057
 
3058 3058
 							<?php
3059
-							if(!empty($this->options['block-edit-js'])) {
3060
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
-							}
3059
+                            if(!empty($this->options['block-edit-js'])) {
3060
+                                echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
+                            }
3062 3062
 
3063 3063
 
3064 3064
 
3065 3065
 
3066
-							if(empty($this->options['block-save-return'])){
3067
-							?>
3066
+                            if(empty($this->options['block-save-return'])){
3067
+                            ?>
3068 3068
 								///////////////////////////////////////////////////////////////////////
3069 3069
 
3070 3070
 									 // build the shortcode.
3071 3071
 								shortcode = "[<?php echo $this->options['base_id'];?>";
3072 3072
 								<?php
3073 3073
 
3074
-								if(! empty( $this->arguments )){
3074
+                                if(! empty( $this->arguments )){
3075 3075
 
3076
-								foreach($this->arguments as $key => $args){
3077
-								   // if($args['type']=='tabs'){continue;}
3076
+                                foreach($this->arguments as $key => $args){
3077
+                                    // if($args['type']=='tabs'){continue;}
3078 3078
 
3079
-								   // don't add metadata arguments
3080
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3081
-									   continue;
3082
-								   }
3083
-								?>
3079
+                                    // don't add metadata arguments
3080
+                                    if (substr($key, 0, 9 ) === 'metadata_') {
3081
+                                        continue;
3082
+                                    }
3083
+                                ?>
3084 3084
 								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3085 3085
 									if ('<?php echo esc_attr( $key );?>' == 'html') {
3086 3086
 									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
@@ -3091,10 +3091,10 @@  discard block
 block discarded – undo
3091 3091
 									}
3092 3092
 								}
3093 3093
 								<?php
3094
-								}
3095
-								}
3094
+                                }
3095
+                                }
3096 3096
 
3097
-								?>
3097
+                                ?>
3098 3098
 								shortcode += "]";
3099 3099
 
3100 3100
 								if(shortcode){
@@ -3106,17 +3106,17 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 
3108 3108
 									<?php
3109
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
-									}
3112
-									?>
3109
+                                    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
+                                        echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
+                                    }
3112
+                                    ?>
3113 3113
 								}
3114 3114
 
3115 3115
 
3116 3116
 							///////////////////////////////////////////////////////////////////////
3117 3117
 							<?php
3118
-							} // end nested block check
3119
-							?>
3118
+                            } // end nested block check
3119
+                            ?>
3120 3120
 
3121 3121
 							return [
3122 3122
 
@@ -3140,10 +3140,10 @@  discard block
 block discarded – undo
3140 3140
 
3141 3141
 									<?php
3142 3142
 
3143
-									if(! empty( $this->arguments )){
3143
+                                    if(! empty( $this->arguments )){
3144 3144
 
3145
-									if ( $show_advanced ) {
3146
-									?>
3145
+                                    if ( $show_advanced ) {
3146
+                                    ?>
3147 3147
 									el('div', {
3148 3148
 											style: {'padding-left': '16px','padding-right': '16px'}
3149 3149
 										},
@@ -3160,119 +3160,119 @@  discard block
 block discarded – undo
3160 3160
 									)
3161 3161
 									,
3162 3162
 									<?php
3163
-									}
3164
-
3165
-									$arguments = $this->group_arguments( $this->arguments );
3166
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
-
3168
-									// Do we have sections?
3169
-									$has_sections = $arguments == $this->arguments ? false : true;
3170
-
3171
-									if($has_sections){
3172
-									$panel_count = 0;
3173
-									$open_tab = '';
3174
-
3175
-									$open_tab_groups = array();
3176
-									$used_tabs = array();
3177
-
3178
-									foreach ( $arguments as $key => $args ) {
3179
-										$close_tab = false;
3180
-										$close_tabs = false;
3181
-
3182
-										 if ( ! empty( $block_group_tabs ) ) {
3183
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3185
-													$open_tab_groups[] = $key;
3186
-
3187
-													if ( $open_tab != $tab_name ) {
3188
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
-														$tab_args['tab']['open'] = true;
3190
-
3191
-														$this->block_tab_start( '', $tab_args );
3192
-														$open_tab = $tab_name;
3193
-														$used_tabs[] = $tab_name;
3194
-													}
3195
-
3196
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3197
-														$close_tab = true;
3198
-														$open_tab_groups = array();
3199
-
3200
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
-															$close_tabs = true;
3202
-														}
3203
-													}
3204
-												}
3205
-											}
3206
-										}
3207
-										?>
3163
+                                    }
3164
+
3165
+                                    $arguments = $this->group_arguments( $this->arguments );
3166
+                                    $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
+
3168
+                                    // Do we have sections?
3169
+                                    $has_sections = $arguments == $this->arguments ? false : true;
3170
+
3171
+                                    if($has_sections){
3172
+                                    $panel_count = 0;
3173
+                                    $open_tab = '';
3174
+
3175
+                                    $open_tab_groups = array();
3176
+                                    $used_tabs = array();
3177
+
3178
+                                    foreach ( $arguments as $key => $args ) {
3179
+                                        $close_tab = false;
3180
+                                        $close_tabs = false;
3181
+
3182
+                                            if ( ! empty( $block_group_tabs ) ) {
3183
+                                            foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
+                                                if ( in_array( $key, $tab_args['groups'] ) ) {
3185
+                                                    $open_tab_groups[] = $key;
3186
+
3187
+                                                    if ( $open_tab != $tab_name ) {
3188
+                                                        $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
+                                                        $tab_args['tab']['open'] = true;
3190
+
3191
+                                                        $this->block_tab_start( '', $tab_args );
3192
+                                                        $open_tab = $tab_name;
3193
+                                                        $used_tabs[] = $tab_name;
3194
+                                                    }
3195
+
3196
+                                                    if ( $open_tab_groups == $tab_args['groups'] ) {
3197
+                                                        $close_tab = true;
3198
+                                                        $open_tab_groups = array();
3199
+
3200
+                                                        if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
+                                                            $close_tabs = true;
3202
+                                                        }
3203
+                                                    }
3204
+                                                }
3205
+                                            }
3206
+                                        }
3207
+                                        ?>
3208 3208
 										el(wp.components.PanelBody, {
3209 3209
 												title: '<?php esc_attr_e( $key ); ?>',
3210 3210
 												initialOpen: <?php if ( $panel_count ) {
3211
-												echo "false";
3212
-											} else {
3213
-												echo "true";
3214
-											}?>
3211
+                                                echo "false";
3212
+                                            } else {
3213
+                                                echo "true";
3214
+                                            }?>
3215 3215
 											},
3216 3216
 											<?php
3217
-											foreach ( $args as $k => $a ) {
3218
-												$this->block_tab_start( $k, $a );
3219
-												$this->block_row_start( $k, $a );
3220
-												$this->build_block_arguments( $k, $a );
3221
-												$this->block_row_end( $k, $a );
3222
-												$this->block_tab_end( $k, $a );
3223
-											}
3224
-											?>
3217
+                                            foreach ( $args as $k => $a ) {
3218
+                                                $this->block_tab_start( $k, $a );
3219
+                                                $this->block_row_start( $k, $a );
3220
+                                                $this->build_block_arguments( $k, $a );
3221
+                                                $this->block_row_end( $k, $a );
3222
+                                                $this->block_tab_end( $k, $a );
3223
+                                            }
3224
+                                            ?>
3225 3225
 										),
3226 3226
 										<?php
3227
-										$panel_count ++;
3227
+                                        $panel_count ++;
3228 3228
 
3229
-										if($close_tab || $close_tabs){
3230
-											$tab_args = array(
3231
-												'tab'	=> array(
3232
-													'tabs_close' => $close_tabs,
3233
-												'close' => true,
3234
-												)
3229
+                                        if($close_tab || $close_tabs){
3230
+                                            $tab_args = array(
3231
+                                                'tab'	=> array(
3232
+                                                    'tabs_close' => $close_tabs,
3233
+                                                'close' => true,
3234
+                                                )
3235 3235
 
3236
-											);
3237
-											$this->block_tab_end( '', $tab_args );
3236
+                                            );
3237
+                                            $this->block_tab_end( '', $tab_args );
3238 3238
 //											echo '###close'; print_r($tab_args);
3239
-											$panel_count = 0;
3240
-										}
3239
+                                            $panel_count = 0;
3240
+                                        }
3241 3241
 //
3242 3242
 
3243
-									}
3244
-									}else {
3245
-									?>
3243
+                                    }
3244
+                                    }else {
3245
+                                    ?>
3246 3246
 									el(wp.components.PanelBody, {
3247 3247
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3248 3248
 											initialOpen: true
3249 3249
 										},
3250 3250
 										<?php
3251
-										foreach ( $this->arguments as $key => $args ) {
3252
-											$this->block_row_start( $key, $args );
3253
-											$this->build_block_arguments( $key, $args );
3254
-											$this->block_row_end( $key, $args );
3255
-										}
3256
-										?>
3251
+                                        foreach ( $this->arguments as $key => $args ) {
3252
+                                            $this->block_row_start( $key, $args );
3253
+                                            $this->build_block_arguments( $key, $args );
3254
+                                            $this->block_row_end( $key, $args );
3255
+                                        }
3256
+                                        ?>
3257 3257
 									),
3258 3258
 									<?php
3259
-									}
3259
+                                    }
3260 3260
 
3261
-									}
3262
-									?>
3261
+                                    }
3262
+                                    ?>
3263 3263
 
3264 3264
 								),
3265 3265
 
3266 3266
 								<?php
3267
-								// If the user sets block-output array then build it
3268
-								if ( ! empty( $this->options['block-output'] ) ) {
3269
-								$this->block_element( $this->options['block-output'] );
3270
-							}elseif(!empty($this->options['block-edit-return'])){
3271
-								   echo $this->options['block-edit-return'];
3272
-							}else{
3273
-								// if no block-output is set then we try and get the shortcode html output via ajax.
3274
-								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
-								?>
3267
+                                // If the user sets block-output array then build it
3268
+                                if ( ! empty( $this->options['block-output'] ) ) {
3269
+                                $this->block_element( $this->options['block-output'] );
3270
+                            }elseif(!empty($this->options['block-edit-return'])){
3271
+                                    echo $this->options['block-edit-return'];
3272
+                            }else{
3273
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
3274
+                                $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
+                                ?>
3276 3276
 								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3277 3277
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
3278 3278
 									className: props.className,
@@ -3280,13 +3280,13 @@  discard block
 block discarded – undo
3280 3280
 									style: {'minHeight': '30px'}
3281 3281
 								}))
3282 3282
 								<?php
3283
-								}
3284
-								?>
3283
+                                }
3284
+                                ?>
3285 3285
 							]; // end return
3286 3286
 
3287 3287
 							<?php
3288
-							} // end block-edit-raw else
3289
-							?>
3288
+                            } // end block-edit-raw else
3289
+                            ?>
3290 3290
 						},
3291 3291
 
3292 3292
 						// The "save" property must be specified and must be a valid function.
@@ -3300,16 +3300,16 @@  discard block
 block discarded – undo
3300 3300
 							$html = '';
3301 3301
 							<?php
3302 3302
 
3303
-							if(! empty( $this->arguments )){
3303
+                            if(! empty( $this->arguments )){
3304 3304
 
3305
-							foreach($this->arguments as $key => $args){
3306
-							   // if($args['type']=='tabs'){continue;}
3305
+                            foreach($this->arguments as $key => $args){
3306
+                                // if($args['type']=='tabs'){continue;}
3307 3307
 
3308
-							   // don't add metadata arguments
3309
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3310
-								   continue;
3311
-							   }
3312
-							?>
3308
+                                // don't add metadata arguments
3309
+                                if (substr($key, 0, 9 ) === 'metadata_') {
3310
+                                    continue;
3311
+                                }
3312
+                            ?>
3313 3313
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3314 3314
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
3315 3315
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -3320,10 +3320,10 @@  discard block
 block discarded – undo
3320 3320
 								}
3321 3321
 							}
3322 3322
 							<?php
3323
-							}
3324
-							}
3323
+                            }
3324
+                            }
3325 3325
 
3326
-							?>
3326
+                            ?>
3327 3327
 							content += "]";
3328 3328
 							 content = '';
3329 3329
 
@@ -3333,7 +3333,7 @@  discard block
 block discarded – undo
3333 3333
 //                                $html = 'el( InnerBlocks.Content )';
3334 3334
 //                                <?php
3335 3335
 //                            }
3336
-							?>
3336
+                            ?>
3337 3337
 							// if has html element
3338 3338
 							if ($html) {
3339 3339
 								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
@@ -3366,12 +3366,12 @@  discard block
 block discarded – undo
3366 3366
 //                                <x?php
3367 3367
 //							}else
3368 3368
 
3369
-							if(!empty($this->options['block-output'])){
3369
+                            if(!empty($this->options['block-output'])){
3370 3370
 //                               echo "return";
3371 3371
 //                               $this->block_element( $this->options['block-output'], true );
3372 3372
 //                               echo ";";
3373 3373
 
3374
-							   ?>
3374
+                                ?>
3375 3375
 							  return el(
3376 3376
 								   '',
3377 3377
 								   {},
@@ -3381,10 +3381,10 @@  discard block
 block discarded – undo
3381 3381
 							   );
3382 3382
 								<?php
3383 3383
 
3384
-							}elseif(!empty($this->options['block-save-return'])){
3385
-								   echo 'return ' . $this->options['block-save-return'];
3386
-							}elseif(!empty($this->options['nested-block'])){
3387
-								?>
3384
+                            }elseif(!empty($this->options['block-save-return'])){
3385
+                                    echo 'return ' . $this->options['block-save-return'];
3386
+                            }elseif(!empty($this->options['nested-block'])){
3387
+                                ?>
3388 3388
 							  return el(
3389 3389
 								   '',
3390 3390
 								   {},
@@ -3393,22 +3393,22 @@  discard block
 block discarded – undo
3393 3393
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3394 3394
 							   );
3395 3395
 								<?php
3396
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3397
-								echo "return ". $this->options['block-edit-return'].";";
3398
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
-							?>
3396
+                            }elseif(!empty( $this->options['block-save-return'] ) ){
3397
+                                echo "return ". $this->options['block-edit-return'].";";
3398
+                            }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
+                            ?>
3400 3400
 							return content;
3401 3401
 							<?php
3402
-							}else{
3403
-							?>
3402
+                            }else{
3403
+                            ?>
3404 3404
 							var block_wrap = 'div';
3405 3405
 							if (attr.hasOwnProperty("block_wrap")) {
3406 3406
 								block_wrap = attr.block_wrap;
3407 3407
 							}
3408 3408
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
3409 3409
 							<?php
3410
-							}
3411
-							?>
3410
+                            }
3411
+                            ?>
3412 3412
 
3413 3413
 
3414 3414
 						}
@@ -3422,43 +3422,43 @@  discard block
 block discarded – undo
3422 3422
 				});
3423 3423
 			</script>
3424 3424
 			<?php
3425
-			$output = ob_get_clean();
3425
+            $output = ob_get_clean();
3426 3426
 
3427
-			/*
3427
+            /*
3428 3428
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3429 3429
 			 */
3430 3430
 
3431
-			return str_replace( array(
3432
-				'<script>',
3433
-				'</script>'
3434
-			), '', $output );
3435
-		}
3431
+            return str_replace( array(
3432
+                '<script>',
3433
+                '</script>'
3434
+            ), '', $output );
3435
+        }
3436 3436
 
3437 3437
 
3438 3438
 
3439
-		public function block_row_start($key, $args){
3439
+        public function block_row_start($key, $args){
3440 3440
 
3441
-			// check for row
3442
-			if(!empty($args['row'])){
3441
+            // check for row
3442
+            if(!empty($args['row'])){
3443 3443
 
3444
-				if(!empty($args['row']['open'])){
3444
+                if(!empty($args['row']['open'])){
3445 3445
 
3446
-				// element require
3447
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
-				$device_type_icon = '';
3451
-				if($device_type=='Desktop'){
3452
-					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
-				}elseif($device_type=='Tablet'){
3454
-					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
-				}elseif($device_type=='Mobile'){
3456
-					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
-				}
3458
-				echo $element_require;
3459
-				echo $device_type_require;
3446
+                // element require
3447
+                $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
+                $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
+                $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
+                $device_type_icon = '';
3451
+                if($device_type=='Desktop'){
3452
+                    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
+                }elseif($device_type=='Tablet'){
3454
+                    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
+                }elseif($device_type=='Mobile'){
3456
+                    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
+                }
3458
+                echo $element_require;
3459
+                echo $device_type_require;
3460 3460
 
3461
-					if(false){?><script><?php }?>
3461
+                    if(false){?><script><?php }?>
3462 3462
 						el('div', {
3463 3463
 								className: 'bsui components-base-control',
3464 3464
 							},
@@ -3471,8 +3471,8 @@  discard block
 block discarded – undo
3471 3471
 								<?php if($device_type_icon){ ?>
3472 3472
 									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3473 3473
 								<?php
3474
-								}
3475
-								?>
3474
+                                }
3475
+                                ?>
3476 3476
 
3477 3477
 
3478 3478
 							),
@@ -3496,51 +3496,51 @@  discard block
 block discarded – undo
3496 3496
 									},
3497 3497
 
3498 3498
 					<?php
3499
-					if(false){?></script><?php }
3500
-				}elseif(!empty($args['row']['close'])){
3501
-					if(false){?><script><?php }?>
3499
+                    if(false){?></script><?php }
3500
+                }elseif(!empty($args['row']['close'])){
3501
+                    if(false){?><script><?php }?>
3502 3502
 						el(
3503 3503
 							'div',
3504 3504
 							{
3505 3505
 								className: 'col pl-0 ps-0',
3506 3506
 							},
3507 3507
 					<?php
3508
-					if(false){?></script><?php }
3509
-				}else{
3510
-					if(false){?><script><?php }?>
3508
+                    if(false){?></script><?php }
3509
+                }else{
3510
+                    if(false){?><script><?php }?>
3511 3511
 						el(
3512 3512
 							'div',
3513 3513
 							{
3514 3514
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3515 3515
 							},
3516 3516
 					<?php
3517
-					if(false){?></script><?php }
3518
-				}
3517
+                    if(false){?></script><?php }
3518
+                }
3519 3519
 
3520
-			}
3520
+            }
3521 3521
 
3522
-		}
3522
+        }
3523 3523
 
3524
-		public function block_row_end($key, $args){
3524
+        public function block_row_end($key, $args){
3525 3525
 
3526
-			if(!empty($args['row'])){
3527
-				// maybe close
3528
-				if(!empty($args['row']['close'])){
3529
-					echo "))";
3530
-				}
3526
+            if(!empty($args['row'])){
3527
+                // maybe close
3528
+                if(!empty($args['row']['close'])){
3529
+                    echo "))";
3530
+                }
3531 3531
 
3532
-				echo "),";
3533
-			}
3534
-		}
3532
+                echo "),";
3533
+            }
3534
+        }
3535 3535
 
3536
-		public function block_tab_start($key, $args){
3536
+        public function block_tab_start($key, $args){
3537 3537
 
3538
-			// check for row
3539
-			if(!empty($args['tab'])){
3538
+            // check for row
3539
+            if(!empty($args['tab'])){
3540 3540
 
3541
-				if(!empty($args['tab']['tabs_open'])){
3541
+                if(!empty($args['tab']['tabs_open'])){
3542 3542
 
3543
-					if(false){?><script><?php }?>
3543
+                    if(false){?><script><?php }?>
3544 3544
 
3545 3545
 el('div',{className: 'bsui'},
3546 3546
 
@@ -3553,12 +3553,12 @@  discard block
 block discarded – undo
3553 3553
 										tabs: [
3554 3554
 
3555 3555
 					<?php
3556
-					if(false){?></script><?php }
3557
-				}
3556
+                    if(false){?></script><?php }
3557
+                }
3558 3558
 
3559
-				if(!empty($args['tab']['open'])){
3559
+                if(!empty($args['tab']['open'])){
3560 3560
 
3561
-					if(false){?><script><?php }?>
3561
+                    if(false){?><script><?php }?>
3562 3562
 							{
3563 3563
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3564 3564
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3567,93 +3567,93 @@  discard block
 block discarded – undo
3567 3567
 									className: 'components-base-control__help mb-0',
3568 3568
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3569 3569
 								}),<?php }
3570
-					if(false){?></script><?php }
3571
-				}
3570
+                    if(false){?></script><?php }
3571
+                }
3572 3572
 
3573
-			}
3573
+            }
3574 3574
 
3575
-		}
3575
+        }
3576 3576
 
3577
-		public function block_tab_end($key, $args){
3577
+        public function block_tab_end($key, $args){
3578 3578
 
3579
-			if(!empty($args['tab'])){
3580
-				// maybe close
3581
-				if(!empty($args['tab']['close'])){
3582
-					echo ")}, /* tab close */";
3583
-				}
3579
+            if(!empty($args['tab'])){
3580
+                // maybe close
3581
+                if(!empty($args['tab']['close'])){
3582
+                    echo ")}, /* tab close */";
3583
+                }
3584 3584
 
3585
-				if(!empty($args['tab']['tabs_close'])){
3586
-					if(false){?><script><?php }?>
3585
+                if(!empty($args['tab']['tabs_close'])){
3586
+                    if(false){?><script><?php }?>
3587 3587
 						]}, ( tab ) => {
3588 3588
 								return tab.content;
3589 3589
 							}
3590 3590
 						)), /* tabs close */
3591 3591
 					<?php if(false){ ?></script><?php }
3592
-				}
3593
-			}
3594
-		}
3592
+                }
3593
+            }
3594
+        }
3595 3595
 
3596
-		public function build_block_arguments( $key, $args ) {
3597
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
-			$options           = '';
3599
-			$extra             = '';
3600
-			$require           = '';
3601
-			$inside_elements   = '';
3602
-			$after_elements	   = '';
3603
-
3604
-			// `content` is a protected and special argument
3605
-			if ( $key == 'content' ) {
3606
-				return;
3607
-			}
3596
+        public function build_block_arguments( $key, $args ) {
3597
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
+            $options           = '';
3599
+            $extra             = '';
3600
+            $require           = '';
3601
+            $inside_elements   = '';
3602
+            $after_elements	   = '';
3603
+
3604
+            // `content` is a protected and special argument
3605
+            if ( $key == 'content' ) {
3606
+                return;
3607
+            }
3608 3608
 
3609
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
-			$device_type_icon = '';
3612
-			if($device_type=='Desktop'){
3613
-				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
-			}elseif($device_type=='Tablet'){
3615
-				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
-			}elseif($device_type=='Mobile'){
3617
-				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
-			}
3609
+            $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
+            $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
+            $device_type_icon = '';
3612
+            if($device_type=='Desktop'){
3613
+                $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
+            }elseif($device_type=='Tablet'){
3615
+                $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
+            }elseif($device_type=='Mobile'){
3617
+                $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
+            }
3619 3619
 
3620
-			// icon
3621
-			$icon = '';
3622
-			if( !empty( $args['icon'] ) ){
3623
-				$icon .= "el('div', {";
3624
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
-									$icon .= "className: 'text-center',";
3626
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3627
-								$icon .= "}),";
3628
-
3629
-				// blank title as its added to the icon.
3630
-				$args['title'] = '';
3631
-			}
3620
+            // icon
3621
+            $icon = '';
3622
+            if( !empty( $args['icon'] ) ){
3623
+                $icon .= "el('div', {";
3624
+                                    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
+                                    $icon .= "className: 'text-center',";
3626
+                                    $icon .= "title: '".addslashes( $args['title'] )."',";
3627
+                                $icon .= "}),";
3628
+
3629
+                // blank title as its added to the icon.
3630
+                $args['title'] = '';
3631
+            }
3632 3632
 
3633
-			// require advanced
3634
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3633
+            // require advanced
3634
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3635 3635
 
3636
-			// element require
3637
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3636
+            // element require
3637
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3638 3638
 
3639 3639
 
3640
-			$onchange  = "props.setAttributes({ $key: $key } )";
3641
-			$onchangecomplete  = "";
3642
-			$value     = "props.attributes.$key";
3643
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
-			if ( in_array( $args['type'], $text_type ) ) {
3645
-				$type = 'TextControl';
3646
-				// Save numbers as numbers and not strings
3647
-				if ( $args['type'] == 'number' ) {
3648
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
-				}
3640
+            $onchange  = "props.setAttributes({ $key: $key } )";
3641
+            $onchangecomplete  = "";
3642
+            $value     = "props.attributes.$key";
3643
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
+            if ( in_array( $args['type'], $text_type ) ) {
3645
+                $type = 'TextControl';
3646
+                // Save numbers as numbers and not strings
3647
+                if ( $args['type'] == 'number' ) {
3648
+                    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
+                }
3650 3650
 
3651
-				if (substr($key, 0, 9 ) === 'metadata_') {
3652
-					$real_key = str_replace('metadata_','', $key );
3653
-					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
-				}
3656
-			}
3651
+                if (substr($key, 0, 9 ) === 'metadata_') {
3652
+                    $real_key = str_replace('metadata_','', $key );
3653
+                    $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
+                    $value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
+                }
3656
+            }
3657 3657
 //			else if ( $args['type'] == 'popup' ) {
3658 3658
 //				$type = 'TextControl';
3659 3659
 //				$args['type'] == 'text';
@@ -3671,21 +3671,21 @@  discard block
 block discarded – undo
3671 3671
 //
3672 3672
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673 3673
 //			}
3674
-			else if ( $args['type'] == 'styleid' ) {
3675
-				$type = 'TextControl';
3676
-				$args['type'] == 'text';
3677
-				// Save numbers as numbers and not strings
3678
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
-			}else if ( $args['type'] == 'notice' ) {
3680
-
3681
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
-
3684
-				$notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3685
-				echo $notice_message ? $element_require . $notice : '';
3686
-				return;
3687
-			}
3688
-			/*
3674
+            else if ( $args['type'] == 'styleid' ) {
3675
+                $type = 'TextControl';
3676
+                $args['type'] == 'text';
3677
+                // Save numbers as numbers and not strings
3678
+                $value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
+            }else if ( $args['type'] == 'notice' ) {
3680
+
3681
+                $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
+                $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
+
3684
+                $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3685
+                echo $notice_message ? $element_require . $notice : '';
3686
+                return;
3687
+            }
3688
+            /*
3689 3689
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3690 3690
 						elseif($args['type']=='tabs'){
3691 3691
 							?>
@@ -3738,22 +3738,22 @@  discard block
 block discarded – undo
3738 3738
 							return;
3739 3739
 						}
3740 3740
 */
3741
-			elseif ( $args['type'] == 'color' ) {
3742
-				$type = 'ColorPicker';
3743
-				$onchange = "";
3744
-				$extra = "color: $value,";
3745
-				if(!empty($args['disable_alpha'])){
3746
-					$extra .= "disableAlpha: true,";
3747
-				}
3748
-				$onchangecomplete = "onChangeComplete: function($key) {
3741
+            elseif ( $args['type'] == 'color' ) {
3742
+                $type = 'ColorPicker';
3743
+                $onchange = "";
3744
+                $extra = "color: $value,";
3745
+                if(!empty($args['disable_alpha'])){
3746
+                    $extra .= "disableAlpha: true,";
3747
+                }
3748
+                $onchangecomplete = "onChangeComplete: function($key) {
3749 3749
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3750 3750
 						props.setAttributes({
3751 3751
 							$key: value
3752 3752
 						});
3753 3753
 					},";
3754
-			}elseif ( $args['type'] == 'gradient' ) {
3755
-				$type = 'GradientPicker';
3756
-				$extra .= "gradients: [{
3754
+            }elseif ( $args['type'] == 'gradient' ) {
3755
+                $type = 'GradientPicker';
3756
+                $extra .= "gradients: [{
3757 3757
 			name: 'Vivid cyan blue to vivid purple',
3758 3758
 			gradient:
3759 3759
 				'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
@@ -3790,10 +3790,10 @@  discard block
 block discarded – undo
3790 3790
 			slug: 'cool-to-warm-spectrum',
3791 3791
 		}],";
3792 3792
 
3793
-			}elseif ( $args['type'] == 'image' ) {
3793
+            }elseif ( $args['type'] == 'image' ) {
3794 3794
 //                print_r($args);
3795 3795
 
3796
-				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3796
+                $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3797 3797
 							url:  props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4='  : props.attributes.$key,
3798 3798
 							value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3799 3799
 //                            value: props.attributes.{$key}_xy,
@@ -3814,16 +3814,16 @@  discard block
 block discarded – undo
3814 3814
 						}), ";
3815 3815
 
3816 3816
 
3817
-				$value = '""';
3818
-				$type = 'MediaUpload';
3819
-				$extra .= "onSelect: function(media){
3817
+                $value = '""';
3818
+                $type = 'MediaUpload';
3819
+                $extra .= "onSelect: function(media){
3820 3820
 					  return props.setAttributes({
3821 3821
 						  $key: media.url,
3822 3822
 						  {$key}_id: media.id
3823 3823
 						});
3824 3824
 					  },";
3825
-				   $extra .= "type: 'image',";
3826
-				   $extra .= "render: function (obj) {
3825
+                    $extra .= "type: 'image',";
3826
+                    $extra .= "render: function (obj) {
3827 3827
 						return el( 'div',{},
3828 3828
 						( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3829 3829
 						  className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3849,11 +3849,11 @@  discard block
 block discarded – undo
3849 3849
 
3850 3850
 
3851 3851
 					  }";
3852
-				$onchange = "";
3852
+                $onchange = "";
3853 3853
 
3854
-				//$inside_elements = ",el('div',{},'file upload')";
3855
-			} else if ( $args['type'] == 'images' ) {
3856
-				$img_preview = "props.attributes.$key && (function() {
3854
+                //$inside_elements = ",el('div',{},'file upload')";
3855
+            } else if ( $args['type'] == 'images' ) {
3856
+                $img_preview = "props.attributes.$key && (function() {
3857 3857
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3858 3858
 	let images = [];
3859 3859
 	uploads.map((upload, index) => (
@@ -3880,9 +3880,9 @@  discard block
 block discarded – undo
3880 3880
 })(),";
3881 3881
 
3882 3882
 
3883
-				$value = '""';
3884
-				$type = 'MediaUpload';
3885
-				$extra .= "onSelect: function(media){
3883
+                $value = '""';
3884
+                $type = 'MediaUpload';
3885
+                $extra .= "onSelect: function(media){
3886 3886
 	let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
3887 3887
 	if(media.length){
3888 3888
 		for (var i=0; i < media.length; i++) {
@@ -3895,9 +3895,9 @@  discard block
 block discarded – undo
3895 3895
 	}
3896 3896
 	return props.setAttributes({ $key: slimImagesV});
3897 3897
 },";
3898
-				$extra .= "type: 'image',";
3899
-				$extra .= "multiple: true,";
3900
-				$extra .= "render: function (obj) {
3898
+                $extra .= "type: 'image',";
3899
+                $extra .= "multiple: true,";
3900
+                $extra .= "render: function (obj) {
3901 3901
 	/* Init the sort */
3902 3902
 	enableDragSort('sd-sortable');
3903 3903
 	return el( 'div',{},
@@ -3924,40 +3924,40 @@  discard block
 block discarded – undo
3924 3924
 		)
3925 3925
 	)
3926 3926
 }";
3927
-				$onchange = "";
3927
+                $onchange = "";
3928 3928
 
3929
-				//$inside_elements = ",el('div',{},'file upload')";
3930
-			}
3931
-			elseif ( $args['type'] == 'checkbox' ) {
3932
-				$type = 'CheckboxControl';
3933
-				$extra .= "checked: props.attributes.$key,";
3934
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
-			} elseif ( $args['type'] == 'textarea' ) {
3936
-				$type = 'TextareaControl';
3937
-
3938
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
-				$type = 'SelectControl';
3940
-
3941
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
-				}else {
3946
-
3947
-					if ( ! empty( $args['options'] ) ) {
3948
-						$options .= "options: [";
3949
-						foreach ( $args['options'] as $option_val => $option_label ) {
3950
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
-						}
3952
-						$options .= "],";
3953
-					}
3954
-				}
3955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
-				}
3929
+                //$inside_elements = ",el('div',{},'file upload')";
3930
+            }
3931
+            elseif ( $args['type'] == 'checkbox' ) {
3932
+                $type = 'CheckboxControl';
3933
+                $extra .= "checked: props.attributes.$key,";
3934
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
+            } elseif ( $args['type'] == 'textarea' ) {
3936
+                $type = 'TextareaControl';
3937
+
3938
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
+                $type = 'SelectControl';
3940
+
3941
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
+                }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
+                    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
+                }else {
3946
+
3947
+                    if ( ! empty( $args['options'] ) ) {
3948
+                        $options .= "options: [";
3949
+                        foreach ( $args['options'] as $option_val => $option_label ) {
3950
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
+                        }
3952
+                        $options .= "],";
3953
+                    }
3954
+                }
3955
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
+                    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
+                }
3958 3958
 
3959
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3959
+                if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
+                    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3961 3961
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3962 3962
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3963 3963
 									  onClick: function(){
@@ -3968,8 +3968,8 @@  discard block
 block discarded – undo
3968 3968
 									},
3969 3969
 									'Clear'
3970 3970
 							),";
3971
-				}
3972
-			} elseif ( $args['type'] == 'tagselect' ) {
3971
+                }
3972
+            } elseif ( $args['type'] == 'tagselect' ) {
3973 3973
 //				$type = 'FormTokenField';
3974 3974
 //
3975 3975
 //				if ( ! empty( $args['options'] ) ) {
@@ -4004,20 +4004,20 @@  discard block
 block discarded – undo
4004 4004
 //				$value     = "[]";
4005 4005
 //				$extra .= ' __experimentalExpandOnFocus: true,';
4006 4006
 
4007
-			} else if ( $args['type'] == 'alignment' ) {
4008
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
-			} else if ( $args['type'] == 'margins' ) {
4010
-
4011
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
-				$type = 'TextControl';
4013
-				$value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
-				$args['type'] = 'text';
4015
-				$options .= 'disabled:true,';
4016
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
-				$bsvc_body = $this->block_visibility_fields( $args );
4018
-				// @TODO reset button
4019
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
4020
-				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4007
+            } else if ( $args['type'] == 'alignment' ) {
4008
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
+            } else if ( $args['type'] == 'margins' ) {
4010
+
4011
+            } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
+                $type = 'TextControl';
4013
+                $value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
+                $args['type'] = 'text';
4015
+                $options .= 'disabled:true,';
4016
+                $bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
+                $bsvc_body = $this->block_visibility_fields( $args );
4018
+                // @TODO reset button
4019
+                $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
4020
+                $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4021 4021
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
4022 4022
 						onClick: function() {
4023 4023
 							var sValue = props.attributes." . $key . ";
@@ -4043,39 +4043,39 @@  discard block
 block discarded – undo
4043 4043
 					},
4044 4044
 					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4045 4045
 				) ),";
4046
-			} else {
4047
-				return;// if we have not implemented the control then don't break the JS.
4048
-			}
4046
+            } else {
4047
+                return;// if we have not implemented the control then don't break the JS.
4048
+            }
4049 4049
 
4050
-			// color input does not show the labels so we add them
4051
-			if($args['type']=='color'){
4052
-				// add show only if advanced
4053
-				echo $require_advanced;
4054
-				// add setting require if defined
4055
-				echo $element_require;
4056
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
-			}
4050
+            // color input does not show the labels so we add them
4051
+            if($args['type']=='color'){
4052
+                // add show only if advanced
4053
+                echo $require_advanced;
4054
+                // add setting require if defined
4055
+                echo $element_require;
4056
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
+            }
4058 4058
 
4059
-			// add show only if advanced
4060
-			echo $require_advanced;
4061
-			// add setting require if defined
4062
-			echo $element_require;
4063
-			echo $device_type_require;
4059
+            // add show only if advanced
4060
+            echo $require_advanced;
4061
+            // add setting require if defined
4062
+            echo $element_require;
4063
+            echo $device_type_require;
4064 4064
 
4065
-			// icon
4066
-			echo $icon;
4067
-			?>
4065
+            // icon
4066
+            echo $icon;
4067
+            ?>
4068 4068
 			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4069 4069
 			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4070
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4070
+            } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4071 4071
 			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4072 4072
 			value: <?php echo $value; ?>,
4073 4073
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4074
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4075
-			} ?>
4074
+                echo "type: '" . addslashes( $args['type'] ) . "',";
4075
+            } ?>
4076 4076
 			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
-			} ?>
4077
+                echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
+            } ?>
4079 4079
 			<?php echo $options; ?>
4080 4080
 			<?php echo $extra; ?>
4081 4081
 			<?php echo $custom_attributes; ?>
@@ -4087,1361 +4087,1361 @@  discard block
 block discarded – undo
4087 4087
 			<?php } ?>
4088 4088
 		} <?php echo $inside_elements; ?> ),
4089 4089
 			<?php
4090
-			echo $after_elements;
4091
-		}
4090
+            echo $after_elements;
4091
+        }
4092 4092
 
4093
-		/**
4094
-		 * Convert an array of attributes to block string.
4095
-		 *
4096
-		 * @param $custom_attributes
4097
-		 *
4098
-		 * @return string
4099
-		 *@todo there is prob a faster way to do this, also we could add some validation here.
4100
-		 *
4101
-		 */
4102
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4103
-			$attributes = '';
4104
-			if ( ! empty( $custom_attributes ) ) {
4105
-
4106
-				foreach ( $custom_attributes as $key => $val ) {
4107
-					if(is_array($val)){
4108
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
-					}else{
4110
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
-					}
4112
-				}
4093
+        /**
4094
+         * Convert an array of attributes to block string.
4095
+         *
4096
+         * @param $custom_attributes
4097
+         *
4098
+         * @return string
4099
+         *@todo there is prob a faster way to do this, also we could add some validation here.
4100
+         *
4101
+         */
4102
+        public function array_to_attributes( $custom_attributes, $html = false ) {
4103
+            $attributes = '';
4104
+            if ( ! empty( $custom_attributes ) ) {
4105
+
4106
+                foreach ( $custom_attributes as $key => $val ) {
4107
+                    if(is_array($val)){
4108
+                        $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
+                    }else{
4110
+                        $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
+                    }
4112
+                }
4113 4113
 
4114
-			}
4114
+            }
4115 4115
 
4116
-			return $attributes;
4117
-		}
4116
+            return $attributes;
4117
+        }
4118 4118
 
4119 4119
 
4120 4120
 
4121
-		/**
4122
-		 * A self looping function to create the output for JS block elements.
4123
-		 *
4124
-		 * This is what is output in the WP Editor visual view.
4125
-		 *
4126
-		 * @param $args
4127
-		 */
4128
-		public function block_element( $args, $save = false ) {
4121
+        /**
4122
+         * A self looping function to create the output for JS block elements.
4123
+         *
4124
+         * This is what is output in the WP Editor visual view.
4125
+         *
4126
+         * @param $args
4127
+         */
4128
+        public function block_element( $args, $save = false ) {
4129 4129
 
4130 4130
 //            print_r($args);echo '###';exit;
4131 4131
 
4132
-			if ( ! empty( $args ) ) {
4133
-				foreach ( $args as $element => $new_args ) {
4132
+            if ( ! empty( $args ) ) {
4133
+                foreach ( $args as $element => $new_args ) {
4134 4134
 
4135
-					if ( is_array( $new_args ) ) { // its an element
4135
+                    if ( is_array( $new_args ) ) { // its an element
4136 4136
 
4137 4137
 
4138
-						if ( isset( $new_args['element'] ) ) {
4138
+                        if ( isset( $new_args['element'] ) ) {
4139 4139
 
4140
-							if ( isset( $new_args['element_require'] ) ) {
4141
-								echo str_replace( array(
4142
-										"'+",
4143
-										"+'"
4144
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
-								unset( $new_args['element_require'] );
4146
-							}
4140
+                            if ( isset( $new_args['element_require'] ) ) {
4141
+                                echo str_replace( array(
4142
+                                        "'+",
4143
+                                        "+'"
4144
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
+                                unset( $new_args['element_require'] );
4146
+                            }
4147 4147
 
4148
-							if($new_args['element']=='InnerBlocks'){
4149
-								echo "\n el( InnerBlocks, {";
4150
-							}elseif($new_args['element']=='innerBlocksProps'){
4151
-								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
-							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4148
+                            if($new_args['element']=='InnerBlocks'){
4149
+                                echo "\n el( InnerBlocks, {";
4150
+                            }elseif($new_args['element']=='innerBlocksProps'){
4151
+                                $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
+                                //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153 4153
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154
-								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
-								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
-
4158
-								echo "} ), {";
4159
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
-							//    echo '###';
4161
-
4162
-							  //  echo '###';
4163
-							}elseif($new_args['element']=='BlocksProps'){
4164
-
4165
-								if ( isset($new_args['if_inner_element']) ) {
4166
-									$element = $new_args['if_inner_element'];
4167
-								}else {
4168
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
-								}
4170
-
4171
-								unset($new_args['inner_element']);
4172
-								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
-
4175
-
4176
-							   // echo "} ),";
4177
-
4178
-							}else{
4179
-								echo "\n el( '" . $new_args['element'] . "', {";
4180
-							}
4181
-
4182
-
4183
-							// get the attributes
4184
-							foreach ( $new_args as $new_key => $new_value ) {
4185
-
4186
-
4187
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
-									// do nothing
4189
-								} else {
4190
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4191
-								}
4192
-							}
4193
-
4194
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
-
4196
-							// get the content
4197
-							$first_item = 0;
4198
-							foreach ( $new_args as $new_key => $new_value ) {
4199
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
-
4201
-									if ( $new_key === 'content' ) {
4202
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
-									}else if ( $new_key === 'if_content' ) {
4204
-										echo  $this->block_props_replace(  $new_value  );
4205
-									}
4206
-
4207
-									if ( is_array( $new_value ) ) {
4208
-
4209
-										if ( isset( $new_value['element_require'] ) ) {
4210
-											echo str_replace( array(
4211
-													"'+",
4212
-													"+'"
4213
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
-											unset( $new_value['element_require'] );
4215
-										}
4216
-
4217
-										if ( isset( $new_value['element_repeat'] ) ) {
4218
-											$x = 1;
4219
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
-												$this->block_element( array( '' => $new_value ),$save );
4221
-												$x ++;
4222
-											}
4223
-										} else {
4224
-											$this->block_element( array( '' => $new_value ),$save );
4225
-										}
4226
-									}
4227
-									$first_item ++;
4228
-								}
4229
-							}
4230
-
4231
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
-								echo "))";// end content
4233
-							}else{
4234
-								echo ")";// end content
4235
-							}
4236
-
4237
-
4238
-							echo ", \n";
4239
-
4240
-						}
4241
-					} else {
4242
-
4243
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4244
-							$extra = '';
4245
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
-							}
4249
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4154
+                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
+                                echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
+
4158
+                                echo "} ), {";
4159
+                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
+                            //    echo '###';
4161
+
4162
+                                //  echo '###';
4163
+                            }elseif($new_args['element']=='BlocksProps'){
4164
+
4165
+                                if ( isset($new_args['if_inner_element']) ) {
4166
+                                    $element = $new_args['if_inner_element'];
4167
+                                }else {
4168
+                                    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
+                                }
4170
+
4171
+                                unset($new_args['inner_element']);
4172
+                                echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
+
4175
+
4176
+                                // echo "} ),";
4177
+
4178
+                            }else{
4179
+                                echo "\n el( '" . $new_args['element'] . "', {";
4180
+                            }
4181
+
4182
+
4183
+                            // get the attributes
4184
+                            foreach ( $new_args as $new_key => $new_value ) {
4185
+
4186
+
4187
+                                if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
+                                    // do nothing
4189
+                                } else {
4190
+                                    echo $this->block_element( array( $new_key => $new_value ),$save );
4191
+                                }
4192
+                            }
4193
+
4194
+                            echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
+
4196
+                            // get the content
4197
+                            $first_item = 0;
4198
+                            foreach ( $new_args as $new_key => $new_value ) {
4199
+                                if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
+
4201
+                                    if ( $new_key === 'content' ) {
4202
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
+                                    }else if ( $new_key === 'if_content' ) {
4204
+                                        echo  $this->block_props_replace(  $new_value  );
4205
+                                    }
4206
+
4207
+                                    if ( is_array( $new_value ) ) {
4208
+
4209
+                                        if ( isset( $new_value['element_require'] ) ) {
4210
+                                            echo str_replace( array(
4211
+                                                    "'+",
4212
+                                                    "+'"
4213
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
+                                            unset( $new_value['element_require'] );
4215
+                                        }
4216
+
4217
+                                        if ( isset( $new_value['element_repeat'] ) ) {
4218
+                                            $x = 1;
4219
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
+                                                $this->block_element( array( '' => $new_value ),$save );
4221
+                                                $x ++;
4222
+                                            }
4223
+                                        } else {
4224
+                                            $this->block_element( array( '' => $new_value ),$save );
4225
+                                        }
4226
+                                    }
4227
+                                    $first_item ++;
4228
+                                }
4229
+                            }
4230
+
4231
+                            if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
+                                echo "))";// end content
4233
+                            }else{
4234
+                                echo ")";// end content
4235
+                            }
4236
+
4237
+
4238
+                            echo ", \n";
4239
+
4240
+                        }
4241
+                    } else {
4242
+
4243
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
4244
+                            $extra = '';
4245
+                            if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
+                                $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
+                                $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
+                            }
4249
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
+                        } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
+                            $new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
+                            echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4253 4253
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
-						} elseif ( $element == 'style' ) {
4255
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4258
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
-						} elseif ( $element == 'template' && $new_args ) {
4260
-							echo $element . ": $new_args,";
4261
-						} else {
4262
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
-						}
4264
-
4265
-					}
4266
-				}
4267
-			}
4268
-		}
4254
+                        } elseif ( $element == 'style' ) {
4255
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
+                        } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
+                            $new_args = str_replace('[%WrapClass%]','',$new_args);
4258
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
+                        } elseif ( $element == 'template' && $new_args ) {
4260
+                            echo $element . ": $new_args,";
4261
+                        } else {
4262
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
+                        }
4264
+
4265
+                    }
4266
+                }
4267
+            }
4268
+        }
4269 4269
 
4270
-		/**
4271
-		 * Replace block attributes placeholders with the proper naming.
4272
-		 *
4273
-		 * @param $string
4274
-		 *
4275
-		 * @return mixed
4276
-		 */
4277
-		public function block_props_replace( $string, $no_wrap = false ) {
4278
-			if ( $no_wrap ) {
4279
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
-			} else {
4281
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
-			}
4270
+        /**
4271
+         * Replace block attributes placeholders with the proper naming.
4272
+         *
4273
+         * @param $string
4274
+         *
4275
+         * @return mixed
4276
+         */
4277
+        public function block_props_replace( $string, $no_wrap = false ) {
4278
+            if ( $no_wrap ) {
4279
+                $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
+            } else {
4281
+                $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
+            }
4283 4283
 
4284
-			return $string;
4285
-		}
4284
+            return $string;
4285
+        }
4286 4286
 
4287
-		/**
4288
-		 * Outputs the content of the widget
4289
-		 *
4290
-		 * @param array $args
4291
-		 * @param array $instance
4292
-		 */
4293
-		public function widget( $args, $instance ) {
4294
-			if ( ! is_array( $args ) ) {
4295
-				$args = array();
4296
-			}
4287
+        /**
4288
+         * Outputs the content of the widget
4289
+         *
4290
+         * @param array $args
4291
+         * @param array $instance
4292
+         */
4293
+        public function widget( $args, $instance ) {
4294
+            if ( ! is_array( $args ) ) {
4295
+                $args = array();
4296
+            }
4297 4297
 
4298
-			// Get the filtered values
4299
-			$argument_values = $this->argument_values( $instance );
4300
-			$argument_values = $this->string_to_bool( $argument_values );
4301
-			$output          = $this->output( $argument_values, $args );
4298
+            // Get the filtered values
4299
+            $argument_values = $this->argument_values( $instance );
4300
+            $argument_values = $this->string_to_bool( $argument_values );
4301
+            $output          = $this->output( $argument_values, $args );
4302 4302
 
4303
-			$no_wrap = false;
4304
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
-				$no_wrap = true;
4306
-			}
4303
+            $no_wrap = false;
4304
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
+                $no_wrap = true;
4306
+            }
4307 4307
 
4308
-			ob_start();
4309
-			if ( $output && ! $no_wrap ) {
4308
+            ob_start();
4309
+            if ( $output && ! $no_wrap ) {
4310 4310
 
4311
-				$class_original = $this->options['widget_ops']['classname'];
4312
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4311
+                $class_original = $this->options['widget_ops']['classname'];
4312
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4313 4313
 
4314
-				// Before widget
4315
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4314
+                // Before widget
4315
+                $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
+                $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4319 4319
 
4320
-				// After widget
4321
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4320
+                // After widget
4321
+                $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4324 4324
 
4325
-				echo $before_widget;
4326
-				// elementor strips the widget wrapping div so we check for and add it back if needed
4327
-				if ( $this->is_elementor_widget_output() ) {
4328
-					// Filter class & attrs for elementor widget output.
4329
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4325
+                echo $before_widget;
4326
+                // elementor strips the widget wrapping div so we check for and add it back if needed
4327
+                if ( $this->is_elementor_widget_output() ) {
4328
+                    // Filter class & attrs for elementor widget output.
4329
+                    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
+                    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4331 4331
 
4332
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4332
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4334 4334
 
4335
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
-				}
4337
-				echo $this->output_title( $args, $instance );
4338
-				echo $output;
4339
-				if ( $this->is_elementor_widget_output() ) {
4340
-					echo "</span>";
4341
-				}
4342
-				echo $after_widget;
4343
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
-				echo $output;
4346
-			} elseif ( $output && $no_wrap ) {
4347
-				echo $output;
4348
-			}
4349
-			$output = ob_get_clean();
4335
+                    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
+                }
4337
+                echo $this->output_title( $args, $instance );
4338
+                echo $output;
4339
+                if ( $this->is_elementor_widget_output() ) {
4340
+                    echo "</span>";
4341
+                }
4342
+                echo $after_widget;
4343
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
+                echo $output;
4346
+            } elseif ( $output && $no_wrap ) {
4347
+                echo $output;
4348
+            }
4349
+            $output = ob_get_clean();
4350 4350
 
4351
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4351
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4352 4352
 
4353
-			echo $output;
4354
-		}
4353
+            echo $output;
4354
+        }
4355 4355
 
4356
-		/**
4357
-		 * Tests if the current output is inside a elementor container.
4358
-		 *
4359
-		 * @return bool
4360
-		 *@since 1.0.4
4361
-		 */
4362
-		public function is_elementor_widget_output() {
4363
-			$result = false;
4364
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
-				$result = true;
4366
-			}
4356
+        /**
4357
+         * Tests if the current output is inside a elementor container.
4358
+         *
4359
+         * @return bool
4360
+         *@since 1.0.4
4361
+         */
4362
+        public function is_elementor_widget_output() {
4363
+            $result = false;
4364
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
+                $result = true;
4366
+            }
4367 4367
 
4368
-			return $result;
4369
-		}
4368
+            return $result;
4369
+        }
4370 4370
 
4371
-		/**
4372
-		 * Tests if the current output is inside a elementor preview.
4373
-		 *
4374
-		 * @return bool
4375
-		 *@since 1.0.4
4376
-		 */
4377
-		public function is_elementor_preview() {
4378
-			$result = false;
4379
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
-				$result = true;
4381
-			}
4371
+        /**
4372
+         * Tests if the current output is inside a elementor preview.
4373
+         *
4374
+         * @return bool
4375
+         *@since 1.0.4
4376
+         */
4377
+        public function is_elementor_preview() {
4378
+            $result = false;
4379
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
+                $result = true;
4381
+            }
4382 4382
 
4383
-			return $result;
4384
-		}
4383
+            return $result;
4384
+        }
4385 4385
 
4386
-		/**
4387
-		 * Tests if the current output is inside a Divi preview.
4388
-		 *
4389
-		 * @return bool
4390
-		 *@since 1.0.6
4391
-		 */
4392
-		public function is_divi_preview() {
4393
-			$result = false;
4394
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
-				$result = true;
4396
-			}
4386
+        /**
4387
+         * Tests if the current output is inside a Divi preview.
4388
+         *
4389
+         * @return bool
4390
+         *@since 1.0.6
4391
+         */
4392
+        public function is_divi_preview() {
4393
+            $result = false;
4394
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
+                $result = true;
4396
+            }
4397 4397
 
4398
-			return $result;
4399
-		}
4398
+            return $result;
4399
+        }
4400 4400
 
4401
-		/**
4402
-		 * Tests if the current output is inside a Beaver builder preview.
4403
-		 *
4404
-		 * @return bool
4405
-		 *@since 1.0.6
4406
-		 */
4407
-		public function is_beaver_preview() {
4408
-			$result = false;
4409
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
-				$result = true;
4411
-			}
4401
+        /**
4402
+         * Tests if the current output is inside a Beaver builder preview.
4403
+         *
4404
+         * @return bool
4405
+         *@since 1.0.6
4406
+         */
4407
+        public function is_beaver_preview() {
4408
+            $result = false;
4409
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
+                $result = true;
4411
+            }
4412 4412
 
4413
-			return $result;
4414
-		}
4413
+            return $result;
4414
+        }
4415 4415
 
4416
-		/**
4417
-		 * Tests if the current output is inside a siteorigin builder preview.
4418
-		 *
4419
-		 * @return bool
4420
-		 *@since 1.0.6
4421
-		 */
4422
-		public function is_siteorigin_preview() {
4423
-			$result = false;
4424
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
-				$result = true;
4426
-			}
4416
+        /**
4417
+         * Tests if the current output is inside a siteorigin builder preview.
4418
+         *
4419
+         * @return bool
4420
+         *@since 1.0.6
4421
+         */
4422
+        public function is_siteorigin_preview() {
4423
+            $result = false;
4424
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
+                $result = true;
4426
+            }
4427 4427
 
4428
-			return $result;
4429
-		}
4428
+            return $result;
4429
+        }
4430 4430
 
4431
-		/**
4432
-		 * Tests if the current output is inside a cornerstone builder preview.
4433
-		 *
4434
-		 * @return bool
4435
-		 *@since 1.0.8
4436
-		 */
4437
-		public function is_cornerstone_preview() {
4438
-			$result = false;
4439
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
-				$result = true;
4441
-			}
4431
+        /**
4432
+         * Tests if the current output is inside a cornerstone builder preview.
4433
+         *
4434
+         * @return bool
4435
+         *@since 1.0.8
4436
+         */
4437
+        public function is_cornerstone_preview() {
4438
+            $result = false;
4439
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
+                $result = true;
4441
+            }
4442 4442
 
4443
-			return $result;
4444
-		}
4443
+            return $result;
4444
+        }
4445 4445
 
4446
-		/**
4447
-		 * Tests if the current output is inside a fusion builder preview.
4448
-		 *
4449
-		 * @return bool
4450
-		 *@since 1.1.0
4451
-		 */
4452
-		public function is_fusion_preview() {
4453
-			$result = false;
4454
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
-				$result = true;
4456
-			}
4446
+        /**
4447
+         * Tests if the current output is inside a fusion builder preview.
4448
+         *
4449
+         * @return bool
4450
+         *@since 1.1.0
4451
+         */
4452
+        public function is_fusion_preview() {
4453
+            $result = false;
4454
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
+                $result = true;
4456
+            }
4457 4457
 
4458
-			return $result;
4459
-		}
4458
+            return $result;
4459
+        }
4460 4460
 
4461
-		/**
4462
-		 * Tests if the current output is inside a Oxygen builder preview.
4463
-		 *
4464
-		 * @return bool
4465
-		 *@since 1.0.18
4466
-		 */
4467
-		public function is_oxygen_preview() {
4468
-			$result = false;
4469
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
-				$result = true;
4471
-			}
4461
+        /**
4462
+         * Tests if the current output is inside a Oxygen builder preview.
4463
+         *
4464
+         * @return bool
4465
+         *@since 1.0.18
4466
+         */
4467
+        public function is_oxygen_preview() {
4468
+            $result = false;
4469
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
+                $result = true;
4471
+            }
4472 4472
 
4473
-			return $result;
4474
-		}
4473
+            return $result;
4474
+        }
4475 4475
 
4476
-		/**
4477
-		 * Check for Kallyas theme Zion builder preview.
4478
-		 *
4479
-		 * @since 1.1.22
4480
-		 *
4481
-		 * @return bool True when preview page otherwise false.
4482
-		 */
4483
-		public function is_kallyas_zion_preview() {
4484
-			$result = false;
4485
-
4486
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
-				$result = true;
4488
-			}
4476
+        /**
4477
+         * Check for Kallyas theme Zion builder preview.
4478
+         *
4479
+         * @since 1.1.22
4480
+         *
4481
+         * @return bool True when preview page otherwise false.
4482
+         */
4483
+        public function is_kallyas_zion_preview() {
4484
+            $result = false;
4489 4485
 
4490
-			return $result;
4491
-		}
4486
+            if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
+                $result = true;
4488
+            }
4492 4489
 
4493
-		/**
4494
-		 * Check for Bricks theme builder preview.
4495
-		 *
4496
-		 * @since 1.1.31
4497
-		 *
4498
-		 * @return bool True when preview page otherwise false.
4499
-		 */
4500
-		public function is_bricks_preview() {
4501
-			$result = false;
4502
-
4503
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
-				$result = true;
4505
-			}
4490
+            return $result;
4491
+        }
4506 4492
 
4507
-			return $result;
4508
-		}
4493
+        /**
4494
+         * Check for Bricks theme builder preview.
4495
+         *
4496
+         * @since 1.1.31
4497
+         *
4498
+         * @return bool True when preview page otherwise false.
4499
+         */
4500
+        public function is_bricks_preview() {
4501
+            $result = false;
4509 4502
 
4510
-		/**
4511
-		 * General function to check if we are in a preview situation.
4512
-		 *
4513
-		 * @return bool
4514
-		 *@since 1.0.6
4515
-		 */
4516
-		public function is_preview() {
4517
-			$preview = false;
4518
-			if ( $this->is_divi_preview() ) {
4519
-				$preview = true;
4520
-			} elseif ( $this->is_elementor_preview() ) {
4521
-				$preview = true;
4522
-			} elseif ( $this->is_beaver_preview() ) {
4523
-				$preview = true;
4524
-			} elseif ( $this->is_siteorigin_preview() ) {
4525
-				$preview = true;
4526
-			} elseif ( $this->is_cornerstone_preview() ) {
4527
-				$preview = true;
4528
-			} elseif ( $this->is_fusion_preview() ) {
4529
-				$preview = true;
4530
-			} elseif ( $this->is_oxygen_preview() ) {
4531
-				$preview = true;
4532
-			} elseif( $this->is_kallyas_zion_preview() ) {
4533
-				$preview = true;
4534
-			} elseif( $this->is_block_content_call() ) {
4535
-				$preview = true;
4536
-			} elseif( $this->is_bricks_preview() ) {
4537
-				$preview = true;
4538
-			}
4503
+            if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
+                $result = true;
4505
+            }
4539 4506
 
4540
-			return $preview;
4541
-		}
4507
+            return $result;
4508
+        }
4542 4509
 
4543
-		/**
4544
-		 * Output the super title.
4545
-		 *
4546
-		 * @param $args
4547
-		 * @param array $instance
4548
-		 *
4549
-		 * @return string
4550
-		 */
4551
-		public function output_title( $args, $instance = array() ) {
4552
-			$output = '';
4553
-			if ( ! empty( $instance['title'] ) ) {
4554
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
-
4557
-				if ( empty( $instance['widget_title_tag'] ) ) {
4558
-					if ( ! isset( $args['before_title'] ) ) {
4559
-						$args['before_title'] = '';
4560
-					}
4510
+        /**
4511
+         * General function to check if we are in a preview situation.
4512
+         *
4513
+         * @return bool
4514
+         *@since 1.0.6
4515
+         */
4516
+        public function is_preview() {
4517
+            $preview = false;
4518
+            if ( $this->is_divi_preview() ) {
4519
+                $preview = true;
4520
+            } elseif ( $this->is_elementor_preview() ) {
4521
+                $preview = true;
4522
+            } elseif ( $this->is_beaver_preview() ) {
4523
+                $preview = true;
4524
+            } elseif ( $this->is_siteorigin_preview() ) {
4525
+                $preview = true;
4526
+            } elseif ( $this->is_cornerstone_preview() ) {
4527
+                $preview = true;
4528
+            } elseif ( $this->is_fusion_preview() ) {
4529
+                $preview = true;
4530
+            } elseif ( $this->is_oxygen_preview() ) {
4531
+                $preview = true;
4532
+            } elseif( $this->is_kallyas_zion_preview() ) {
4533
+                $preview = true;
4534
+            } elseif( $this->is_block_content_call() ) {
4535
+                $preview = true;
4536
+            } elseif( $this->is_bricks_preview() ) {
4537
+                $preview = true;
4538
+            }
4561 4539
 
4562
-					if ( ! isset( $args['after_title'] ) ) {
4563
-						$args['after_title'] = '';
4564
-					}
4540
+            return $preview;
4541
+        }
4565 4542
 
4566
-					$output = $args['before_title'] . $title . $args['after_title'];
4567
-				} else {
4568
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4569
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
-
4572
-					// classes
4573
-					$title_classes = array();
4574
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
-
4588
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
4590
-				}
4543
+        /**
4544
+         * Output the super title.
4545
+         *
4546
+         * @param $args
4547
+         * @param array $instance
4548
+         *
4549
+         * @return string
4550
+         */
4551
+        public function output_title( $args, $instance = array() ) {
4552
+            $output = '';
4553
+            if ( ! empty( $instance['title'] ) ) {
4554
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
+
4557
+                if ( empty( $instance['widget_title_tag'] ) ) {
4558
+                    if ( ! isset( $args['before_title'] ) ) {
4559
+                        $args['before_title'] = '';
4560
+                    }
4561
+
4562
+                    if ( ! isset( $args['after_title'] ) ) {
4563
+                        $args['after_title'] = '';
4564
+                    }
4565
+
4566
+                    $output = $args['before_title'] . $title . $args['after_title'];
4567
+                } else {
4568
+                    $tag 			= esc_attr( $instance['widget_title_tag'] );
4569
+                    $allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
+                    $title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
+
4572
+                    // classes
4573
+                    $title_classes = array();
4574
+                    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
+                    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
+                    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
+                    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
+                    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
+                    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
+                    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
+                    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
+                    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
+                    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
+                    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
+                    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
+                    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
+
4588
+                    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
+                    $output = "<$title_tag class='$class' >$title</$title_tag>";
4590
+                }
4591 4591
 
4592
-			}
4592
+            }
4593 4593
 
4594
-			return $output;
4595
-		}
4594
+            return $output;
4595
+        }
4596 4596
 
4597
-		/**
4598
-		 * Outputs the options form inputs for the widget.
4599
-		 *
4600
-		 * @param array $instance The widget options.
4601
-		 */
4602
-		public function form( $instance ) {
4597
+        /**
4598
+         * Outputs the options form inputs for the widget.
4599
+         *
4600
+         * @param array $instance The widget options.
4601
+         */
4602
+        public function form( $instance ) {
4603 4603
 
4604
-			// set widget instance
4605
-			$this->instance = $instance;
4604
+            // set widget instance
4605
+            $this->instance = $instance;
4606 4606
 
4607
-			// set it as a SD widget
4608
-			echo $this->widget_advanced_toggle();
4607
+            // set it as a SD widget
4608
+            echo $this->widget_advanced_toggle();
4609 4609
 
4610
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
-			$arguments_raw = $this->get_arguments();
4610
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
+            $arguments_raw = $this->get_arguments();
4612 4612
 
4613
-			if ( is_array( $arguments_raw ) ) {
4613
+            if ( is_array( $arguments_raw ) ) {
4614 4614
 
4615
-				$arguments = $this->group_arguments( $arguments_raw );
4615
+                $arguments = $this->group_arguments( $arguments_raw );
4616 4616
 
4617
-				// Do we have sections?
4618
-				$has_sections = $arguments == $arguments_raw ? false : true;
4617
+                // Do we have sections?
4618
+                $has_sections = $arguments == $arguments_raw ? false : true;
4619 4619
 
4620 4620
 
4621
-				if ( $has_sections ) {
4622
-					$panel_count = 0;
4623
-					foreach ( $arguments as $key => $args ) {
4621
+                if ( $has_sections ) {
4622
+                    $panel_count = 0;
4623
+                    foreach ( $arguments as $key => $args ) {
4624 4624
 
4625
-						?>
4625
+                        ?>
4626 4626
 						<script>
4627 4627
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
4628 4628
 						</script>
4629 4629
 						<?php
4630 4630
 
4631
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
4632
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4631
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
4632
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
+                        echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4635 4635
 
4636
-						foreach ( $args as $k => $a ) {
4636
+                        foreach ( $args as $k => $a ) {
4637 4637
 
4638
-							$this->widget_inputs_row_start($k, $a);
4639
-							$this->widget_inputs( $a, $instance );
4640
-							$this->widget_inputs_row_end($k, $a);
4638
+                            $this->widget_inputs_row_start($k, $a);
4639
+                            $this->widget_inputs( $a, $instance );
4640
+                            $this->widget_inputs_row_end($k, $a);
4641 4641
 
4642
-						}
4642
+                        }
4643 4643
 
4644
-						echo "</div>";
4644
+                        echo "</div>";
4645 4645
 
4646
-						$panel_count ++;
4646
+                        $panel_count ++;
4647 4647
 
4648
-					}
4649
-				} else {
4650
-					foreach ( $arguments as $key => $args ) {
4651
-						$this->widget_inputs_row_start($key, $args);
4652
-						$this->widget_inputs( $args, $instance );
4653
-						$this->widget_inputs_row_end($key, $args);
4654
-					}
4655
-				}
4648
+                    }
4649
+                } else {
4650
+                    foreach ( $arguments as $key => $args ) {
4651
+                        $this->widget_inputs_row_start($key, $args);
4652
+                        $this->widget_inputs( $args, $instance );
4653
+                        $this->widget_inputs_row_end($key, $args);
4654
+                    }
4655
+                }
4656 4656
 
4657
-			}
4658
-		}
4657
+            }
4658
+        }
4659 4659
 
4660
-		public function widget_inputs_row_start( $key, $args ) {
4661
-			if ( ! empty( $args['row'] ) ) {
4662
-				// Maybe open
4663
-				if ( ! empty( $args['row']['open'] ) ) {
4664
-					?>
4660
+        public function widget_inputs_row_start( $key, $args ) {
4661
+            if ( ! empty( $args['row'] ) ) {
4662
+                // Maybe open
4663
+                if ( ! empty( $args['row']['open'] ) ) {
4664
+                    ?>
4665 4665
 					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4666 4666
 					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4667 4667
 					<?php
4668
-						if ( isset( $args['row']['icon'] ) ) {
4669
-							$args['row']['icon'] = '';
4670
-						}
4671
-
4672
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
-							$args['row']['device_type'] = $args['device_type'];
4674
-						}
4675
-					?>
4668
+                        if ( isset( $args['row']['icon'] ) ) {
4669
+                            $args['row']['icon'] = '';
4670
+                        }
4671
+
4672
+                        if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
+                            $args['row']['device_type'] = $args['device_type'];
4674
+                        }
4675
+                    ?>
4676 4676
 					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4677 4677
 					<?php } ?>
4678 4678
 					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4679 4679
 					<div class='col pr-2'>
4680 4680
 					<?php
4681
-				} else if ( ! empty( $args['row']['close'] ) ) {
4682
-					echo "<div class='col pl-0 ps-0'>";
4683
-				} else {
4684
-					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
-				}
4686
-			}
4687
-		}
4681
+                } else if ( ! empty( $args['row']['close'] ) ) {
4682
+                    echo "<div class='col pl-0 ps-0'>";
4683
+                } else {
4684
+                    echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
+                }
4686
+            }
4687
+        }
4688 4688
 
4689
-		public function widget_inputs_row_end( $key, $args ) {
4690
-			if ( ! empty( $args['row'] ) ) {
4691
-				// Maybe close
4692
-				if ( ! empty( $args['row']['close'] ) ) {
4693
-					echo "</div></div>";
4694
-				}
4695
-				echo "</div>";
4696
-			}
4697
-		}
4689
+        public function widget_inputs_row_end( $key, $args ) {
4690
+            if ( ! empty( $args['row'] ) ) {
4691
+                // Maybe close
4692
+                if ( ! empty( $args['row']['close'] ) ) {
4693
+                    echo "</div></div>";
4694
+                }
4695
+                echo "</div>";
4696
+            }
4697
+        }
4698 4698
 
4699
-		/**
4700
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
4701
-		 *
4702
-		 * @return string
4703
-		 */
4704
-		public function widget_advanced_toggle() {
4699
+        /**
4700
+         * Get the hidden input that when added makes the advanced button show on widget settings.
4701
+         *
4702
+         * @return string
4703
+         */
4704
+        public function widget_advanced_toggle() {
4705 4705
 
4706
-			$output = '';
4707
-			if ( $this->block_show_advanced() ) {
4708
-				$val = 1;
4709
-			} else {
4710
-				$val = 0;
4711
-			}
4706
+            $output = '';
4707
+            if ( $this->block_show_advanced() ) {
4708
+                $val = 1;
4709
+            } else {
4710
+                $val = 0;
4711
+            }
4712 4712
 
4713
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4713
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4714 4714
 
4715
-			return $output;
4716
-		}
4715
+            return $output;
4716
+        }
4717 4717
 
4718
-		/**
4719
-		 * Convert require element.
4720
-		 *
4721
-		 * @param string $input Input element.
4722
-		 *
4723
-		 * @return string $output
4724
-		 *@since 1.0.0
4725
-		 *
4726
-		 */
4727
-		public function convert_element_require( $input ) {
4728
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4729
-
4730
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
-				"jQuery(form).find('[data-argument=\"",
4732
-				"\"]').find('input,select,textarea').val()",
4733
-				"\"]').find('input:checked').val()"
4734
-			), $input ) );
4735
-
4736
-			return $output;
4737
-		}
4718
+        /**
4719
+         * Convert require element.
4720
+         *
4721
+         * @param string $input Input element.
4722
+         *
4723
+         * @return string $output
4724
+         *@since 1.0.0
4725
+         *
4726
+         */
4727
+        public function convert_element_require( $input ) {
4728
+            $input = str_replace( "'", '"', $input );// we only want double quotes
4738 4729
 
4739
-		/**
4740
-		 * Builds the inputs for the widget options.
4741
-		 *
4742
-		 * @param $args
4743
-		 * @param $instance
4744
-		 */
4745
-		public function widget_inputs( $args, $instance ) {
4746
-
4747
-			$class             = "";
4748
-			$element_require   = "";
4749
-			$custom_attributes = "";
4750
-
4751
-			// get value
4752
-			if ( isset( $instance[ $args['name'] ] ) ) {
4753
-				$value = $instance[ $args['name'] ];
4754
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
-			} else {
4757
-				$value = '';
4758
-			}
4730
+            $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
+                "jQuery(form).find('[data-argument=\"",
4732
+                "\"]').find('input,select,textarea').val()",
4733
+                "\"]').find('input:checked').val()"
4734
+            ), $input ) );
4759 4735
 
4760
-			// get placeholder
4761
-			if ( ! empty( $args['placeholder'] ) ) {
4762
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
-			} else {
4764
-				$placeholder = '';
4765
-			}
4736
+            return $output;
4737
+        }
4766 4738
 
4767
-			// get if advanced
4768
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
-				$class .= " sd-advanced-setting ";
4770
-			}
4739
+        /**
4740
+         * Builds the inputs for the widget options.
4741
+         *
4742
+         * @param $args
4743
+         * @param $instance
4744
+         */
4745
+        public function widget_inputs( $args, $instance ) {
4746
+
4747
+            $class             = "";
4748
+            $element_require   = "";
4749
+            $custom_attributes = "";
4750
+
4751
+            // get value
4752
+            if ( isset( $instance[ $args['name'] ] ) ) {
4753
+                $value = $instance[ $args['name'] ];
4754
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
+            } else {
4757
+                $value = '';
4758
+            }
4771 4759
 
4772
-			// element_require
4773
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
-				$element_require = $args['element_require'];
4775
-			}
4760
+            // get placeholder
4761
+            if ( ! empty( $args['placeholder'] ) ) {
4762
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
+            } else {
4764
+                $placeholder = '';
4765
+            }
4776 4766
 
4777
-			// custom_attributes
4778
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
-			}
4767
+            // get if advanced
4768
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
+                $class .= " sd-advanced-setting ";
4770
+            }
4781 4771
 
4782
-			// before wrapper
4783
-			?>
4772
+            // element_require
4773
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
+                $element_require = $args['element_require'];
4775
+            }
4776
+
4777
+            // custom_attributes
4778
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
+            }
4781
+
4782
+            // before wrapper
4783
+            ?>
4784 4784
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4785 4785
 			<?php
4786
-			switch ( $args['type'] ) {
4787
-				//array('text','password','number','email','tel','url','color')
4788
-				case "text":
4789
-				case "password":
4790
-				case "number":
4791
-				case "email":
4792
-				case "tel":
4793
-				case "url":
4794
-				case "color":
4795
-					?>
4786
+            switch ( $args['type'] ) {
4787
+                //array('text','password','number','email','tel','url','color')
4788
+                case "text":
4789
+                case "password":
4790
+                case "number":
4791
+                case "email":
4792
+                case "tel":
4793
+                case "url":
4794
+                case "color":
4795
+                    ?>
4796 4796
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4797 4797
 					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>">
4798 4798
 					<?php
4799 4799
 
4800
-					break;
4801
-				case "select":
4802
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
-					if ( $multiple ) {
4804
-						if ( empty( $value ) ) {
4805
-							$value = array();
4806
-						}
4807
-					}
4808
-					?>
4800
+                    break;
4801
+                case "select":
4802
+                    $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
+                    if ( $multiple ) {
4804
+                        if ( empty( $value ) ) {
4805
+                            $value = array();
4806
+                        }
4807
+                    }
4808
+                    ?>
4809 4809
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4810 4810
 					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>"
4811 4811
 						<?php if ( $multiple ) {
4812
-							echo "multiple";
4813
-						} //@todo not implemented yet due to gutenberg not supporting it
4814
-						?>>
4812
+                            echo "multiple";
4813
+                        } //@todo not implemented yet due to gutenberg not supporting it
4814
+                        ?>>
4815 4815
 						<?php
4816 4816
 
4817
-						if ( ! empty( $args['options'] ) ) {
4818
-							foreach ( $args['options'] as $val => $label ) {
4819
-								if ( $multiple ) {
4820
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4821
-								} else {
4822
-									$selected = selected( $value, $val, false );
4823
-								}
4824
-								echo "<option value='$val' " . $selected . ">$label</option>";
4825
-							}
4826
-						}
4827
-						?>
4817
+                        if ( ! empty( $args['options'] ) ) {
4818
+                            foreach ( $args['options'] as $val => $label ) {
4819
+                                if ( $multiple ) {
4820
+                                    $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4821
+                                } else {
4822
+                                    $selected = selected( $value, $val, false );
4823
+                                }
4824
+                                echo "<option value='$val' " . $selected . ">$label</option>";
4825
+                            }
4826
+                        }
4827
+                        ?>
4828 4828
 					</select>
4829 4829
 					<?php
4830
-					break;
4831
-				case "checkbox":
4832
-					?>
4830
+                    break;
4831
+                case "checkbox":
4832
+                    ?>
4833 4833
 					<input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1">
4834 4834
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4835 4835
 					<?php
4836
-					break;
4837
-				case "textarea":
4838
-					?>
4836
+                    break;
4837
+                case "textarea":
4838
+                    ?>
4839 4839
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4840 4840
 					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea>
4841 4841
 					<?php
4842 4842
 
4843
-					break;
4844
-				case "hidden":
4845
-					?>
4843
+                    break;
4844
+                case "hidden":
4845
+                    ?>
4846 4846
 					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>">
4847 4847
 					<?php
4848
-					break;
4849
-				default:
4850
-					echo "No input type found!"; // @todo we need to add more input types.
4851
-			}
4852
-			// after wrapper
4853
-			?></p><?php
4854
-		}
4848
+                    break;
4849
+                default:
4850
+                    echo "No input type found!"; // @todo we need to add more input types.
4851
+            }
4852
+            // after wrapper
4853
+            ?></p><?php
4854
+        }
4855 4855
 
4856
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4857
-			if($icon=='box-top'){
4858
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4859
-			}elseif($icon=='box-right'){
4860
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4861
-			}elseif($icon=='box-bottom'){
4862
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4863
-			}elseif($icon=='box-left'){
4864
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4865
-			}
4866
-		}
4856
+        public function get_widget_icon($icon = 'box-top', $title = ''){
4857
+            if($icon=='box-top'){
4858
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4859
+            }elseif($icon=='box-right'){
4860
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4861
+            }elseif($icon=='box-bottom'){
4862
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4863
+            }elseif($icon=='box-left'){
4864
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4865
+            }
4866
+        }
4867 4867
 
4868
-		/**
4869
-		 * Get the widget input description html.
4870
-		 *
4871
-		 * @param $args
4872
-		 *
4873
-		 * @return string
4874
-		 * @todo, need to make its own tooltip script
4875
-		 */
4876
-		public function widget_field_desc( $args ) {
4877
-
4878
-			$description = '';
4879
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
-					$description = $this->desc_tip( $args['desc'] );
4882
-				} else {
4883
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4884
-				}
4885
-			}
4868
+        /**
4869
+         * Get the widget input description html.
4870
+         *
4871
+         * @param $args
4872
+         *
4873
+         * @return string
4874
+         * @todo, need to make its own tooltip script
4875
+         */
4876
+        public function widget_field_desc( $args ) {
4877
+
4878
+            $description = '';
4879
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
+                    $description = $this->desc_tip( $args['desc'] );
4882
+                } else {
4883
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4884
+                }
4885
+            }
4886 4886
 
4887
-			return $description;
4888
-		}
4887
+            return $description;
4888
+        }
4889 4889
 
4890
-		/**
4891
-		 * Get the widget input title html.
4892
-		 *
4893
-		 * @param $args
4894
-		 *
4895
-		 * @return string
4896
-		 */
4897
-		public function widget_field_title( $args ) {
4898
-			$title = '';
4899
-
4900
-			if ( isset( $args['title'] ) && $args['title'] ) {
4901
-				if ( ! empty( $args['device_type'] ) ) {
4902
-					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903
-				}
4890
+        /**
4891
+         * Get the widget input title html.
4892
+         *
4893
+         * @param $args
4894
+         *
4895
+         * @return string
4896
+         */
4897
+        public function widget_field_title( $args ) {
4898
+            $title = '';
4904 4899
 
4905
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4907
-				} else {
4908
-					$title = esc_attr( $args['title'] );
4909
-				}
4910
-			}
4900
+            if ( isset( $args['title'] ) && $args['title'] ) {
4901
+                if ( ! empty( $args['device_type'] ) ) {
4902
+                    $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903
+                }
4911 4904
 
4912
-			return $title;
4913
-		}
4905
+                if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
+                    $title = self::get_widget_icon( $args['icon'], $args['title']  );
4907
+                } else {
4908
+                    $title = esc_attr( $args['title'] );
4909
+                }
4910
+            }
4914 4911
 
4915
-		/**
4916
-		 * Get the tool tip html.
4917
-		 *
4918
-		 * @param $tip
4919
-		 * @param bool $allow_html
4920
-		 *
4921
-		 * @return string
4922
-		 */
4923
-		function desc_tip( $tip, $allow_html = false ) {
4924
-			if ( $allow_html ) {
4925
-				$tip = $this->sanitize_tooltip( $tip );
4926
-			} else {
4927
-				$tip = esc_attr( $tip );
4928
-			}
4912
+            return $title;
4913
+        }
4929 4914
 
4930
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4931
-		}
4915
+        /**
4916
+         * Get the tool tip html.
4917
+         *
4918
+         * @param $tip
4919
+         * @param bool $allow_html
4920
+         *
4921
+         * @return string
4922
+         */
4923
+        function desc_tip( $tip, $allow_html = false ) {
4924
+            if ( $allow_html ) {
4925
+                $tip = $this->sanitize_tooltip( $tip );
4926
+            } else {
4927
+                $tip = esc_attr( $tip );
4928
+            }
4932 4929
 
4933
-		/**
4934
-		 * Sanitize a string destined to be a tooltip.
4935
-		 *
4936
-		 * @param string $var
4937
-		 *
4938
-		 * @return string
4939
-		 */
4940
-		public function sanitize_tooltip( $var ) {
4941
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4942
-				'br'     => array(),
4943
-				'em'     => array(),
4944
-				'strong' => array(),
4945
-				'small'  => array(),
4946
-				'span'   => array(),
4947
-				'ul'     => array(),
4948
-				'li'     => array(),
4949
-				'ol'     => array(),
4950
-				'p'      => array(),
4951
-			) ) );
4952
-		}
4930
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4931
+        }
4953 4932
 
4954
-		/**
4955
-		 * Processing widget options on save
4956
-		 *
4957
-		 * @param array $new_instance The new options
4958
-		 * @param array $old_instance The previous options
4959
-		 *
4960
-		 * @return array
4961
-		 * @todo we should add some sanitation here.
4962
-		 */
4963
-		public function update( $new_instance, $old_instance ) {
4964
-
4965
-			//save the widget
4966
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4967
-
4968
-			// set widget instance
4969
-			$this->instance = $instance;
4970
-
4971
-			if ( empty( $this->arguments ) ) {
4972
-				$this->get_arguments();
4973
-			}
4933
+        /**
4934
+         * Sanitize a string destined to be a tooltip.
4935
+         *
4936
+         * @param string $var
4937
+         *
4938
+         * @return string
4939
+         */
4940
+        public function sanitize_tooltip( $var ) {
4941
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4942
+                'br'     => array(),
4943
+                'em'     => array(),
4944
+                'strong' => array(),
4945
+                'small'  => array(),
4946
+                'span'   => array(),
4947
+                'ul'     => array(),
4948
+                'li'     => array(),
4949
+                'ol'     => array(),
4950
+                'p'      => array(),
4951
+            ) ) );
4952
+        }
4974 4953
 
4975
-			// check for checkboxes
4976
-			if ( ! empty( $this->arguments ) ) {
4977
-				foreach ( $this->arguments as $argument ) {
4978
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
-						$instance[ $argument['name'] ] = '0';
4980
-					}
4981
-				}
4982
-			}
4954
+        /**
4955
+         * Processing widget options on save
4956
+         *
4957
+         * @param array $new_instance The new options
4958
+         * @param array $old_instance The previous options
4959
+         *
4960
+         * @return array
4961
+         * @todo we should add some sanitation here.
4962
+         */
4963
+        public function update( $new_instance, $old_instance ) {
4983 4964
 
4984
-			return $instance;
4985
-		}
4965
+            //save the widget
4966
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
4986 4967
 
4987
-		/**
4988
-		 * Checks if the current call is a ajax call to get the block content.
4989
-		 *
4990
-		 * This can be used in your widget to return different content as the block content.
4991
-		 *
4992
-		 * @return bool
4993
-		 *@since 1.0.3
4994
-		 */
4995
-		public function is_block_content_call() {
4996
-			$result = false;
4997
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4998
-				$result = true;
4999
-			}
4968
+            // set widget instance
4969
+            $this->instance = $instance;
5000 4970
 
5001
-			return $result;
5002
-		}
4971
+            if ( empty( $this->arguments ) ) {
4972
+                $this->get_arguments();
4973
+            }
5003 4974
 
5004
-		/**
5005
-		 * Get an instance hash that will be unique to the type and settings.
5006
-		 *
5007
-		 * @return string
5008
-		 *@since 1.0.20
5009
-		 */
5010
-		public function get_instance_hash(){
5011
-			$instance_string = $this->base_id.serialize($this->instance);
5012
-			return hash('crc32b',$instance_string);
5013
-		}
4975
+            // check for checkboxes
4976
+            if ( ! empty( $this->arguments ) ) {
4977
+                foreach ( $this->arguments as $argument ) {
4978
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
+                        $instance[ $argument['name'] ] = '0';
4980
+                    }
4981
+                }
4982
+            }
5014 4983
 
5015
-		/**
5016
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
5017
-		 *
5018
-		 * @param array $rules
5019
-		 *
5020
-		 * @return string
5021
-		 *@since 1.0.20
5022
-		 */
5023
-		public function get_instance_style($rules = array()){
5024
-			$css = '';
5025
-
5026
-			if(!empty($rules)){
5027
-				$rules = array_unique($rules);
5028
-				$instance_hash = $this->get_instance_hash();
5029
-				$css .= "<style>";
5030
-				foreach($rules as $rule){
5031
-					$css .= ".sdel-$instance_hash $rule";
5032
-				}
5033
-				$css .= "</style>";
5034
-			}
4984
+            return $instance;
4985
+        }
5035 4986
 
5036
-			return $css;
5037
-		}
4987
+        /**
4988
+         * Checks if the current call is a ajax call to get the block content.
4989
+         *
4990
+         * This can be used in your widget to return different content as the block content.
4991
+         *
4992
+         * @return bool
4993
+         *@since 1.0.3
4994
+         */
4995
+        public function is_block_content_call() {
4996
+            $result = false;
4997
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4998
+                $result = true;
4999
+            }
5000
+
5001
+            return $result;
5002
+        }
5038 5003
 
5039
-		/**
5040
-		 * Encode shortcodes tags.
5041
-		 *
5042
-		 * @param string $content Content to search for shortcode tags.
5043
-		 *
5004
+        /**
5005
+         * Get an instance hash that will be unique to the type and settings.
5006
+         *
5007
+         * @return string
5008
+         *@since 1.0.20
5009
+         */
5010
+        public function get_instance_hash(){
5011
+            $instance_string = $this->base_id.serialize($this->instance);
5012
+            return hash('crc32b',$instance_string);
5013
+        }
5014
+
5015
+        /**
5016
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
5017
+         *
5018
+         * @param array $rules
5019
+         *
5020
+         * @return string
5021
+         *@since 1.0.20
5022
+         */
5023
+        public function get_instance_style($rules = array()){
5024
+            $css = '';
5025
+
5026
+            if(!empty($rules)){
5027
+                $rules = array_unique($rules);
5028
+                $instance_hash = $this->get_instance_hash();
5029
+                $css .= "<style>";
5030
+                foreach($rules as $rule){
5031
+                    $css .= ".sdel-$instance_hash $rule";
5032
+                }
5033
+                $css .= "</style>";
5034
+            }
5035
+
5036
+            return $css;
5037
+        }
5038
+
5039
+        /**
5040
+         * Encode shortcodes tags.
5041
+         *
5042
+         * @param string $content Content to search for shortcode tags.
5043
+         *
5044 5044
 *@return string Content with shortcode tags removed.
5045
-		 *@since 1.0.28
5046
-		 *
5047
-		 */
5048
-		public function encode_shortcodes( $content ) {
5049
-			// Avoids existing encoded tags.
5050
-			$trans   = array(
5051
-				'&#91;' => '&#091;',
5052
-				'&#93;' => '&#093;',
5053
-				'&amp;#91;' => '&#091;',
5054
-				'&amp;#93;' => '&#093;',
5055
-				'&lt;' => '&0lt;',
5056
-				'&gt;' => '&0gt;',
5057
-				'&amp;lt;' => '&0lt;',
5058
-				'&amp;gt;' => '&0gt;',
5059
-			);
5060
-
5061
-			$content = strtr( $content, $trans );
5062
-
5063
-			$trans   = array(
5064
-				'[' => '&#91;',
5065
-				']' => '&#93;',
5066
-				'<' => '&lt;',
5067
-				'>' => '&gt;',
5068
-				'"' => '&quot;',
5069
-				"'" => '&#39;',
5070
-			);
5071
-
5072
-			$content = strtr( $content, $trans );
5073
-
5074
-			return $content;
5075
-		}
5045
+         *@since 1.0.28
5046
+         *
5047
+         */
5048
+        public function encode_shortcodes( $content ) {
5049
+            // Avoids existing encoded tags.
5050
+            $trans   = array(
5051
+                '&#91;' => '&#091;',
5052
+                '&#93;' => '&#093;',
5053
+                '&amp;#91;' => '&#091;',
5054
+                '&amp;#93;' => '&#093;',
5055
+                '&lt;' => '&0lt;',
5056
+                '&gt;' => '&0gt;',
5057
+                '&amp;lt;' => '&0lt;',
5058
+                '&amp;gt;' => '&0gt;',
5059
+            );
5060
+
5061
+            $content = strtr( $content, $trans );
5062
+
5063
+            $trans   = array(
5064
+                '[' => '&#91;',
5065
+                ']' => '&#93;',
5066
+                '<' => '&lt;',
5067
+                '>' => '&gt;',
5068
+                '"' => '&quot;',
5069
+                "'" => '&#39;',
5070
+            );
5071
+
5072
+            $content = strtr( $content, $trans );
5073
+
5074
+            return $content;
5075
+        }
5076 5076
 
5077
-		/**
5078
-		 * Remove encoded shortcod tags.
5079
-		 *
5080
-		 * @param string $content Content to search for shortcode tags.
5081
-		 *
5077
+        /**
5078
+         * Remove encoded shortcod tags.
5079
+         *
5080
+         * @param string $content Content to search for shortcode tags.
5081
+         *
5082 5082
 *@return string Content with decoded shortcode tags.
5083
-		 *@since 1.0.28
5084
-		 *
5085
-		 */
5086
-		public function decode_shortcodes( $content ) {
5087
-			$trans   = array(
5088
-				'&#91;' => '[',
5089
-				'&#93;' => ']',
5090
-				'&amp;#91;' => '[',
5091
-				'&amp;#93;' => ']',
5092
-				'&lt;' => '<',
5093
-				'&gt;' => '>',
5094
-				'&amp;lt;' => '<',
5095
-				'&amp;gt;' => '>',
5096
-				'&quot;' => '"',
5097
-				'&apos;' => "'",
5098
-			);
5099
-
5100
-			$content = strtr( $content, $trans );
5101
-
5102
-			$trans   = array(
5103
-				'&#091;' => '&#91;',
5104
-				'&#093;' => '&#93;',
5105
-				'&amp;#091;' => '&#91;',
5106
-				'&amp;#093;' => '&#93;',
5107
-				'&0lt;' => '&lt;',
5108
-				'&0gt;' => '&gt;',
5109
-				'&amp;0lt;' => '&lt;',
5110
-				'&amp;0gt;' => '&gt;',
5111
-			);
5112
-
5113
-			$content = strtr( $content, $trans );
5114
-
5115
-			return $content;
5116
-		}
5117
-
5118
-		public function block_visibility_fields( $args ) {
5119
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5120
-			$content = '<div class="bs-vc-rule-template d-none">';
5121
-				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122
-					$content .= '<div class="row">';
5123
-						$content .= '<div class="col-sm-12">';
5124
-							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5125
-							$content .= aui()->select(
5126
-								array(
5127
-									'id'          => 'bsvc_rule_BSVCINDEX',
5128
-									'name'        => 'bsvc_rule_BSVCINDEX',
5129
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5130
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5131
-									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132
-									'options'     => sd_visibility_rules_options(),
5133
-									'default'     => '',
5134
-									'value'       => '',
5135
-									'label_type'  => '',
5136
-									'select2'     => false,
5137
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5138
-									'extra_attributes' => array(
5139
-										'data-minimum-results-for-search' => '-1'
5140
-									)
5141
-								)
5142
-							);
5143
-
5144
-						$content .= '</div>';
5145
-
5146
-						if ( class_exists( 'GeoDirectory' ) ) {
5147
-							$content .= '<div class="col-md-7 col-sm-12">';
5148
-
5149
-								$content .= aui()->select(
5150
-									array(
5151
-										'id'          => 'bsvc_gd_field_BSVCINDEX',
5152
-										'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5155
-										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156
-										'options'     => sd_visibility_gd_field_options(),
5157
-										'default'     => '',
5158
-										'value'       => '',
5159
-										'label_type'  => '',
5160
-										'select2'     => false,
5161
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5162
-										'extra_attributes' => array(
5163
-											'data-minimum-results-for-search' => '-1'
5164
-										)
5165
-									)
5166
-								);
5167
-
5168
-							$content .= '</div>';
5169
-							$content .= '<div class="col-md-5 col-sm-12">';
5170
-
5171
-								$content .= aui()->select(
5172
-									array(
5173
-										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174
-										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5177
-										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178
-										'options'     => sd_visibility_field_condition_options(),
5179
-										'default'     => '',
5180
-										'value'       => '',
5181
-										'label_type'  => '',
5182
-										'select2'     => false,
5183
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5184
-										'extra_attributes' => array(
5185
-											'data-minimum-results-for-search' => '-1'
5186
-										)
5187
-									)
5188
-								);
5189
-
5190
-							$content .= '</div>';
5191
-							$content .= '<div class="col-sm-12">';
5192
-
5193
-								$content .= aui()->input(
5194
-									array(
5195
-										'type'            => 'text',
5196
-										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197
-										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5199
-										'class'           => 'bsvc_gd_field_search form-control-sm',
5200
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5201
-										'label_type'      => '',
5202
-										'value'           => '',
5203
-										'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5204
-									)
5205
-								);
5083
+         *@since 1.0.28
5084
+         *
5085
+         */
5086
+        public function decode_shortcodes( $content ) {
5087
+            $trans   = array(
5088
+                '&#91;' => '[',
5089
+                '&#93;' => ']',
5090
+                '&amp;#91;' => '[',
5091
+                '&amp;#93;' => ']',
5092
+                '&lt;' => '<',
5093
+                '&gt;' => '>',
5094
+                '&amp;lt;' => '<',
5095
+                '&amp;gt;' => '>',
5096
+                '&quot;' => '"',
5097
+                '&apos;' => "'",
5098
+            );
5099
+
5100
+            $content = strtr( $content, $trans );
5101
+
5102
+            $trans   = array(
5103
+                '&#091;' => '&#91;',
5104
+                '&#093;' => '&#93;',
5105
+                '&amp;#091;' => '&#91;',
5106
+                '&amp;#093;' => '&#93;',
5107
+                '&0lt;' => '&lt;',
5108
+                '&0gt;' => '&gt;',
5109
+                '&amp;0lt;' => '&lt;',
5110
+                '&amp;0gt;' => '&gt;',
5111
+            );
5112
+
5113
+            $content = strtr( $content, $trans );
5114
+
5115
+            return $content;
5116
+        }
5206 5117
 
5207
-							$content .= '</div>';
5208
-						}
5118
+        public function block_visibility_fields( $args ) {
5119
+            $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5120
+            $content = '<div class="bs-vc-rule-template d-none">';
5121
+                $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122
+                    $content .= '<div class="row">';
5123
+                        $content .= '<div class="col-sm-12">';
5124
+                            $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5125
+                            $content .= aui()->select(
5126
+                                array(
5127
+                                    'id'          => 'bsvc_rule_BSVCINDEX',
5128
+                                    'name'        => 'bsvc_rule_BSVCINDEX',
5129
+                                    'label'       => __( 'Rule', 'ayecode-connect' ),
5130
+                                    'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5131
+                                    'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132
+                                    'options'     => sd_visibility_rules_options(),
5133
+                                    'default'     => '',
5134
+                                    'value'       => '',
5135
+                                    'label_type'  => '',
5136
+                                    'select2'     => false,
5137
+                                    'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5138
+                                    'extra_attributes' => array(
5139
+                                        'data-minimum-results-for-search' => '-1'
5140
+                                    )
5141
+                                )
5142
+                            );
5143
+
5144
+                        $content .= '</div>';
5145
+
5146
+                        if ( class_exists( 'GeoDirectory' ) ) {
5147
+                            $content .= '<div class="col-md-7 col-sm-12">';
5148
+
5149
+                                $content .= aui()->select(
5150
+                                    array(
5151
+                                        'id'          => 'bsvc_gd_field_BSVCINDEX',
5152
+                                        'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
+                                        'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
+                                        'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5155
+                                        'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156
+                                        'options'     => sd_visibility_gd_field_options(),
5157
+                                        'default'     => '',
5158
+                                        'value'       => '',
5159
+                                        'label_type'  => '',
5160
+                                        'select2'     => false,
5161
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5162
+                                        'extra_attributes' => array(
5163
+                                            'data-minimum-results-for-search' => '-1'
5164
+                                        )
5165
+                                    )
5166
+                                );
5167
+
5168
+                            $content .= '</div>';
5169
+                            $content .= '<div class="col-md-5 col-sm-12">';
5170
+
5171
+                                $content .= aui()->select(
5172
+                                    array(
5173
+                                        'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174
+                                        'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
+                                        'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
+                                        'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5177
+                                        'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178
+                                        'options'     => sd_visibility_field_condition_options(),
5179
+                                        'default'     => '',
5180
+                                        'value'       => '',
5181
+                                        'label_type'  => '',
5182
+                                        'select2'     => false,
5183
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5184
+                                        'extra_attributes' => array(
5185
+                                            'data-minimum-results-for-search' => '-1'
5186
+                                        )
5187
+                                    )
5188
+                                );
5189
+
5190
+                            $content .= '</div>';
5191
+                            $content .= '<div class="col-sm-12">';
5192
+
5193
+                                $content .= aui()->input(
5194
+                                    array(
5195
+                                        'type'            => 'text',
5196
+                                        'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197
+                                        'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
+                                        'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5199
+                                        'class'           => 'bsvc_gd_field_search form-control-sm',
5200
+                                        'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5201
+                                        'label_type'      => '',
5202
+                                        'value'           => '',
5203
+                                        'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5204
+                                    )
5205
+                                );
5206
+
5207
+                            $content .= '</div>';
5208
+                        }
5209 5209
 
5210 5210
                         $content .= apply_filters( 'sd_block_visibility_fields', '', $args );
5211 5211
 
5212
-					$content .= '</div>';
5213
-
5214
-					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5215
-						$role_options = sd_user_roles_options();
5216
-
5217
-						$role_option_i = 0;
5218
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5219
-							$role_option_i++;
5220
-
5221
-							$content .= '<div class="col-sm-6">';
5222
-							$content .= aui()->input(
5223
-								array(
5224
-									'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5225
-									'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5226
-									'type'             => 'checkbox',
5227
-									'label'            => $role_option_name,
5228
-									'label_type'       => 'hidden',
5229
-									'class'            => 'bsvc_user_roles',
5230
-									'value'            => $role_option_key,
5231
-									'switch'           => 'md',
5232
-									'no_wrap'          => true
5233
-								)
5234
-							);
5235
-							$content .= '</div>';
5236
-						}
5237
-					$content .= '</div>';
5238
-					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5239
-				$content .= '</div>';
5240
-			$content .= '</div>';
5241
-			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242
-			$content .= '<div class="bs-vc-rule-sets"></div>';
5243
-			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5244
-			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245
-			$content .= aui()->select(
5246
-				array(
5247
-					'id'          => 'bsvc_output',
5248
-					'name'        => 'bsvc_output',
5249
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5251
-					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252
-					'options'     => sd_visibility_output_options(),
5253
-					'default'     => '',
5254
-					'value'       => '',
5255
-					'label_type'  => 'top',
5256
-					'select2'     => false,
5257
-					'extra_attributes' => array(
5258
-						'data-minimum-results-for-search' => '-1'
5259
-					)
5260
-				)
5261
-			);
5262
-
5263
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5264
-
5265
-			$content .= aui()->select(
5266
-				array(
5267
-					'id'              => 'bsvc_page',
5268
-					'name'            => 'bsvc_page',
5269
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5271
-					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272
-					'options'         => sd_template_page_options(),
5273
-					'default'         => '',
5274
-					'value'           => '',
5275
-					'label_type'      => 'top',
5276
-					'select2'         => false,
5277
-					'element_require' => '[%bsvc_output%]=="page"'
5278
-				)
5279
-			);
5280
-
5281
-			$content .= aui()->select(
5282
-				array(
5283
-					'id'          => 'bsvc_tmpl_part',
5284
-					'name'        => 'bsvc_tmpl_part',
5285
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5287
-					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288
-					'options'     => sd_template_part_options(),
5289
-					'default'     => '',
5290
-					'value'       => '',
5291
-					'label_type'  => 'top',
5292
-					'select2'     => false,
5293
-					'element_require'  => '[%bsvc_output%]=="template_part"',
5294
-					'extra_attributes' => array(
5295
-						'data-minimum-results-for-search' => '-1'
5296
-					)
5297
-				)
5298
-			);
5299
-
5300
-			$content .= aui()->select(
5301
-				array(
5302
-					'id'               => 'bsvc_message_type',
5303
-					'name'             => 'bsvc_message_type',
5304
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5306
-					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307
-					'options'          => sd_aui_colors(),
5308
-					'default'          => '',
5309
-					'value'            => '',
5310
-					'label_type'       => 'top',
5311
-					'select2'          => false,
5312
-					'element_require'  => '[%bsvc_output%]=="message"',
5313
-					'extra_attributes' => array(
5314
-						'data-minimum-results-for-search' => '-1'
5315
-					)
5316
-				)
5317
-			);
5318
-
5319
-			$content .= '</div><div class="col-sm-12">';
5320
-
5321
-			$content .= aui()->input(
5322
-				array(
5323
-					'type'            => 'text',
5324
-					'id'              => 'bsvc_message',
5325
-					'name'            => 'bsvc_message',
5326
-					'label'           => '',
5327
-					'class'           => 'bsvc_message form-control-sm mb-3',
5328
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5329
-					'label_type'      => '',
5330
-					'value'           => '',
5331
-					'form_group_class' => ' ',
5332
-					'element_require' => '[%bsvc_output%]=="message"',
5333
-				)
5334
-			);
5335
-
5336
-			$content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5337
-			$content .= aui()->select(
5338
-				array(
5339
-					'id'          => 'bsvc_output_n',
5340
-					'name'        => 'bsvc_output_n',
5341
-					'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5343
-					'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344
-					'options'     => sd_visibility_output_options(),
5345
-					'default'     => '',
5346
-					'value'       => '',
5347
-					'label_type'  => 'top',
5348
-					'select2'     => false,
5349
-					'extra_attributes' => array(
5350
-						'data-minimum-results-for-search' => '-1'
5351
-					)
5352
-				)
5353
-			);
5354
-
5355
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5356
-
5357
-			$content .= aui()->select(
5358
-				array(
5359
-					'id'              => 'bsvc_page_n',
5360
-					'name'            => 'bsvc_page_n',
5361
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5363
-					'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364
-					'options'         => sd_template_page_options(),
5365
-					'default'         => '',
5366
-					'value'           => '',
5367
-					'label_type'      => 'top',
5368
-					'select2'         => false,
5369
-					'element_require' => '[%bsvc_output_n%]=="page"'
5370
-				)
5371
-			);
5372
-
5373
-			$content .= aui()->select(
5374
-				array(
5375
-					'id'          => 'bsvc_tmpl_part_n',
5376
-					'name'        => 'bsvc_tmpl_part_n',
5377
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5379
-					'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380
-					'options'     => sd_template_part_options(),
5381
-					'default'     => '',
5382
-					'value'       => '',
5383
-					'label_type'  => 'top',
5384
-					'select2'     => false,
5385
-					'element_require'  => '[%bsvc_output_n%]=="template_part"',
5386
-					'extra_attributes' => array(
5387
-						'data-minimum-results-for-search' => '-1'
5388
-					)
5389
-				)
5390
-			);
5391
-
5392
-			$content .= aui()->select(
5393
-				array(
5394
-					'id'               => 'bsvc_message_type_n',
5395
-					'name'             => 'bsvc_message_type_n',
5396
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5398
-					'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399
-					'options'          => sd_aui_colors(),
5400
-					'default'          => '',
5401
-					'value'            => '',
5402
-					'label_type'       => 'top',
5403
-					'select2'          => false,
5404
-					'element_require'  => '[%bsvc_output_n%]=="message"',
5405
-					'extra_attributes' => array(
5406
-						'data-minimum-results-for-search' => '-1'
5407
-					)
5408
-				)
5409
-			);
5410
-
5411
-			$content .= '</div><div class="col-sm-12">';
5412
-
5413
-			$content .= aui()->input(
5414
-				array(
5415
-					'type'            => 'text',
5416
-					'id'              => 'bsvc_message_n',
5417
-					'name'            => 'bsvc_message_n',
5418
-					'label'           => '',
5419
-					'class'           => 'bsvc_message_n form-control-sm',
5420
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5421
-					'label_type'      => '',
5422
-					'value'           => '',
5423
-					'form_group_class' => ' ',
5424
-					'element_require' => '[%bsvc_output_n%]=="message"',
5425
-				)
5426
-			);
5427
-
5428
-			$content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5429
-
5430
-			return $content;
5431
-		}
5212
+                    $content .= '</div>';
5213
+
5214
+                    $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5215
+                        $role_options = sd_user_roles_options();
5216
+
5217
+                        $role_option_i = 0;
5218
+                        foreach ( $role_options as $role_option_key => $role_option_name ) {
5219
+                            $role_option_i++;
5220
+
5221
+                            $content .= '<div class="col-sm-6">';
5222
+                            $content .= aui()->input(
5223
+                                array(
5224
+                                    'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5225
+                                    'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5226
+                                    'type'             => 'checkbox',
5227
+                                    'label'            => $role_option_name,
5228
+                                    'label_type'       => 'hidden',
5229
+                                    'class'            => 'bsvc_user_roles',
5230
+                                    'value'            => $role_option_key,
5231
+                                    'switch'           => 'md',
5232
+                                    'no_wrap'          => true
5233
+                                )
5234
+                            );
5235
+                            $content .= '</div>';
5236
+                        }
5237
+                    $content .= '</div>';
5238
+                    $content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5239
+                $content .= '</div>';
5240
+            $content .= '</div>';
5241
+            $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242
+            $content .= '<div class="bs-vc-rule-sets"></div>';
5243
+            $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5244
+            $content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245
+            $content .= aui()->select(
5246
+                array(
5247
+                    'id'          => 'bsvc_output',
5248
+                    'name'        => 'bsvc_output',
5249
+                    'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5251
+                    'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252
+                    'options'     => sd_visibility_output_options(),
5253
+                    'default'     => '',
5254
+                    'value'       => '',
5255
+                    'label_type'  => 'top',
5256
+                    'select2'     => false,
5257
+                    'extra_attributes' => array(
5258
+                        'data-minimum-results-for-search' => '-1'
5259
+                    )
5260
+                )
5261
+            );
5262
+
5263
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5264
+
5265
+            $content .= aui()->select(
5266
+                array(
5267
+                    'id'              => 'bsvc_page',
5268
+                    'name'            => 'bsvc_page',
5269
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5271
+                    'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272
+                    'options'         => sd_template_page_options(),
5273
+                    'default'         => '',
5274
+                    'value'           => '',
5275
+                    'label_type'      => 'top',
5276
+                    'select2'         => false,
5277
+                    'element_require' => '[%bsvc_output%]=="page"'
5278
+                )
5279
+            );
5280
+
5281
+            $content .= aui()->select(
5282
+                array(
5283
+                    'id'          => 'bsvc_tmpl_part',
5284
+                    'name'        => 'bsvc_tmpl_part',
5285
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5287
+                    'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288
+                    'options'     => sd_template_part_options(),
5289
+                    'default'     => '',
5290
+                    'value'       => '',
5291
+                    'label_type'  => 'top',
5292
+                    'select2'     => false,
5293
+                    'element_require'  => '[%bsvc_output%]=="template_part"',
5294
+                    'extra_attributes' => array(
5295
+                        'data-minimum-results-for-search' => '-1'
5296
+                    )
5297
+                )
5298
+            );
5299
+
5300
+            $content .= aui()->select(
5301
+                array(
5302
+                    'id'               => 'bsvc_message_type',
5303
+                    'name'             => 'bsvc_message_type',
5304
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5306
+                    'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307
+                    'options'          => sd_aui_colors(),
5308
+                    'default'          => '',
5309
+                    'value'            => '',
5310
+                    'label_type'       => 'top',
5311
+                    'select2'          => false,
5312
+                    'element_require'  => '[%bsvc_output%]=="message"',
5313
+                    'extra_attributes' => array(
5314
+                        'data-minimum-results-for-search' => '-1'
5315
+                    )
5316
+                )
5317
+            );
5318
+
5319
+            $content .= '</div><div class="col-sm-12">';
5320
+
5321
+            $content .= aui()->input(
5322
+                array(
5323
+                    'type'            => 'text',
5324
+                    'id'              => 'bsvc_message',
5325
+                    'name'            => 'bsvc_message',
5326
+                    'label'           => '',
5327
+                    'class'           => 'bsvc_message form-control-sm mb-3',
5328
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5329
+                    'label_type'      => '',
5330
+                    'value'           => '',
5331
+                    'form_group_class' => ' ',
5332
+                    'element_require' => '[%bsvc_output%]=="message"',
5333
+                )
5334
+            );
5335
+
5336
+            $content .= '</div></div><div class="row"><div class="col col-12"><div class="pt-3 mt-1 border-top"></div></div><div class="col-md-6 col-sm-12">';
5337
+            $content .= aui()->select(
5338
+                array(
5339
+                    'id'          => 'bsvc_output_n',
5340
+                    'name'        => 'bsvc_output_n',
5341
+                    'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
+                    'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5343
+                    'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344
+                    'options'     => sd_visibility_output_options(),
5345
+                    'default'     => '',
5346
+                    'value'       => '',
5347
+                    'label_type'  => 'top',
5348
+                    'select2'     => false,
5349
+                    'extra_attributes' => array(
5350
+                        'data-minimum-results-for-search' => '-1'
5351
+                    )
5352
+                )
5353
+            );
5354
+
5355
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5356
+
5357
+            $content .= aui()->select(
5358
+                array(
5359
+                    'id'              => 'bsvc_page_n',
5360
+                    'name'            => 'bsvc_page_n',
5361
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5363
+                    'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364
+                    'options'         => sd_template_page_options(),
5365
+                    'default'         => '',
5366
+                    'value'           => '',
5367
+                    'label_type'      => 'top',
5368
+                    'select2'         => false,
5369
+                    'element_require' => '[%bsvc_output_n%]=="page"'
5370
+                )
5371
+            );
5372
+
5373
+            $content .= aui()->select(
5374
+                array(
5375
+                    'id'          => 'bsvc_tmpl_part_n',
5376
+                    'name'        => 'bsvc_tmpl_part_n',
5377
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5379
+                    'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380
+                    'options'     => sd_template_part_options(),
5381
+                    'default'     => '',
5382
+                    'value'       => '',
5383
+                    'label_type'  => 'top',
5384
+                    'select2'     => false,
5385
+                    'element_require'  => '[%bsvc_output_n%]=="template_part"',
5386
+                    'extra_attributes' => array(
5387
+                        'data-minimum-results-for-search' => '-1'
5388
+                    )
5389
+                )
5390
+            );
5391
+
5392
+            $content .= aui()->select(
5393
+                array(
5394
+                    'id'               => 'bsvc_message_type_n',
5395
+                    'name'             => 'bsvc_message_type_n',
5396
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5398
+                    'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399
+                    'options'          => sd_aui_colors(),
5400
+                    'default'          => '',
5401
+                    'value'            => '',
5402
+                    'label_type'       => 'top',
5403
+                    'select2'          => false,
5404
+                    'element_require'  => '[%bsvc_output_n%]=="message"',
5405
+                    'extra_attributes' => array(
5406
+                        'data-minimum-results-for-search' => '-1'
5407
+                    )
5408
+                )
5409
+            );
5410
+
5411
+            $content .= '</div><div class="col-sm-12">';
5412
+
5413
+            $content .= aui()->input(
5414
+                array(
5415
+                    'type'            => 'text',
5416
+                    'id'              => 'bsvc_message_n',
5417
+                    'name'            => 'bsvc_message_n',
5418
+                    'label'           => '',
5419
+                    'class'           => 'bsvc_message_n form-control-sm',
5420
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5421
+                    'label_type'      => '',
5422
+                    'value'           => '',
5423
+                    'form_group_class' => ' ',
5424
+                    'element_require' => '[%bsvc_output_n%]=="message"',
5425
+                )
5426
+            );
5427
+
5428
+            $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5429
+
5430
+            return $content;
5431
+        }
5432 5432
 
5433
-		/**
5434
-		 * Handle media_buttons hook.
5435
-		 *
5436
-		 * @since 1.2.7
5437
-		 */
5438
-		public function wp_media_buttons() {
5439
-			global $shortcode_insert_button_once;
5440
-
5441
-			// Fix conflicts with UpSolution Core in header template edit element.
5442
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5443
-				$shortcode_insert_button_once = true;
5444
-			}
5445
-		}
5446
-	}
5433
+        /**
5434
+         * Handle media_buttons hook.
5435
+         *
5436
+         * @since 1.2.7
5437
+         */
5438
+        public function wp_media_buttons() {
5439
+            global $shortcode_insert_button_once;
5440
+
5441
+            // Fix conflicts with UpSolution Core in header template edit element.
5442
+            if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5443
+                $shortcode_insert_button_once = true;
5444
+            }
5445
+        }
5446
+    }
5447 5447
 }
Please login to merge, or discard this patch.
Spacing   +831 added lines, -831 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.2.17' );
8
+	define('SUPER_DUPER_VER', '1.2.17');
9 9
 
10 10
 	/**
11 11
 	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
@@ -38,40 +38,40 @@  discard block
 block discarded – undo
38 38
 		/**
39 39
 		 * Take the array options and use them to build.
40 40
 		 */
41
-		public function __construct( $options ) {
41
+		public function __construct($options) {
42 42
 			global $sd_widgets;
43 43
 
44
-			$sd_widgets[ $options['base_id'] ] = array(
44
+			$sd_widgets[$options['base_id']] = array(
45 45
 				'name'       => $options['name'],
46 46
 				'class_name' => $options['class_name'],
47 47
 				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48 48
 			);
49
-			$this->base_id                     = $options['base_id'];
49
+			$this->base_id = $options['base_id'];
50 50
 			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
51
+			$options       = apply_filters("wp_super_duper_options", $options);
52
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
53
+			$options       = $this->add_name_from_key($options);
54 54
 			$this->options = $options;
55 55
 
56 56
 			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
57
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
58 58
 
59 59
 			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
60
+			if (!empty($this->options['nested-block'])) {
61
+				if (empty($this->options['output_types'])) {
62
+					$this->options['output_types'] = array('shortcode', 'block');
63 63
 				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
 					unset($this->options['output_types'][$key]);
65 65
 				}
66 66
 			}
67 67
 
68 68
 			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
69
+			if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
70
+				parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
71 71
 			}
72 72
 
73 73
 
74
-			if ( isset( $options['class_name'] ) ) {
74
+			if (isset($options['class_name'])) {
75 75
 				// register widget
76 76
 				$this->class_name = $options['class_name'];
77 77
 
@@ -80,67 +80,67 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
83
+				if (function_exists('fusion_builder_map')) {
84
+					add_action('init', array($this, 'register_fusion_element'));
85 85
 				}
86 86
 
87 87
                 // maybe load the Bricks transformer class
88
-                if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
88
+                if (class_exists('\Bricks\Elements', false)) {
89
+					add_action('init', array($this, 'load_bricks_element_class'));
90 90
                 }
91 91
 
92 92
 				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
93
+				if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) {
94
+					add_action('admin_enqueue_scripts', array($this, 'register_block'));
95 95
 				}
96 96
 			}
97 97
 
98 98
 			// add the CSS and JS we need ONCE
99 99
 			global $sd_widget_scripts;
100 100
 
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
101
+			if (!$sd_widget_scripts) {
102
+				wp_add_inline_script('admin-widgets', $this->widget_js());
103
+				wp_add_inline_script('customize-controls', $this->widget_js());
104
+				wp_add_inline_style('widgets', $this->widget_css());
105 105
 
106 106
 				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
107
+				add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles'));
108 108
 
109 109
 				$sd_widget_scripts = true;
110 110
 
111 111
 				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
112
+				add_action('media_buttons', array($this, 'wp_media_buttons'), 1);
113
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
114 114
 				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
115
+				if (function_exists('generate_sections_sections_metabox')) {
116
+					add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script'));
117 117
 				}
118 118
 				/* Load script on Divi theme builder page */
119
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
119
+				if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) {
120 120
 					add_thickbox();
121
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
121
+					add_action('admin_footer', array($this, 'shortcode_insert_button_script'));
122 122
 				}
123 123
 
124
-				if ( $this->is_preview() ) {
125
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
124
+				if ($this->is_preview()) {
125
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
126 126
 					// this makes the insert button work for elementor
127
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
127
+					add_action('elementor/editor/after_enqueue_scripts', array(
128 128
 						$this,
129 129
 						'shortcode_insert_button_script'
130
-					) ); // for elementor
130
+					)); // for elementor
131 131
 				}
132 132
 				// this makes the insert button work for cornerstone
133
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
133
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
134 134
 
135
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
135
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
136
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
137 137
 
138 138
 				// add generator text to head
139
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
139
+				add_action('admin_head', array($this, 'generator'), 99);
140
+				add_action('wp_head', array($this, 'generator'), 99);
141 141
 			}
142 142
 
143
-			do_action( 'wp_super_duper_widget_init', $options, $this );
143
+			do_action('wp_super_duper_widget_init', $options, $this);
144 144
 		}
145 145
 
146 146
         /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		 * @return void
157 157
 		 */
158 158
 		public function _register() {
159
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
159
+			if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
160 160
 				parent::_register();
161 161
 			}
162 162
 		}
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 		 * Add our widget CSS to elementor editor.
166 166
 		 */
167 167
 		public function elementor_editor_styles() {
168
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
168
+			wp_add_inline_style('elementor-editor', $this->widget_css(false));
169 169
 		}
170 170
 
171 171
 		public function register_fusion_element() {
172 172
 
173 173
 			$options = $this->options;
174 174
 
175
-			if ( $this->base_id ) {
175
+			if ($this->base_id) {
176 176
 
177 177
 				$params = $this->get_fusion_params();
178 178
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 					'allow_generator' => true,
184 184
 				);
185 185
 
186
-				if ( ! empty( $params ) ) {
186
+				if (!empty($params)) {
187 187
 					$args['params'] = $params;
188 188
 				}
189 189
 
190
-				fusion_builder_map( $args );
190
+				fusion_builder_map($args);
191 191
 			}
192 192
 
193 193
 		}
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 			$params    = array();
197 197
 			$arguments = $this->get_arguments();
198 198
 
199
-			if ( ! empty( $arguments ) ) {
200
-				foreach ( $arguments as $key => $val ) {
199
+			if (!empty($arguments)) {
200
+				foreach ($arguments as $key => $val) {
201 201
 					$param = array();
202 202
 					// type
203 203
 					$param['type'] = str_replace(
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
 						$val['type'] );
220 220
 
221 221
 					// multiselect
222
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
222
+					if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) {
223 223
 						$param['type']     = 'multiple_select';
224 224
 						$param['multiple'] = true;
225 225
 					}
226 226
 
227 227
 					// heading
228
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
228
+					$param['heading'] = isset($val['title']) ? $val['title'] : '';
229 229
 
230 230
 					// description
231
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
231
+					$param['description'] = isset($val['desc']) ? $val['desc'] : '';
232 232
 
233 233
 					// param_name
234 234
 					$param['param_name'] = $key;
235 235
 
236 236
 					// Default
237
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
237
+					$param['default'] = isset($val['default']) ? $val['default'] : '';
238 238
 
239 239
 					// Group
240
-					if ( isset( $val['group'] ) ) {
240
+					if (isset($val['group'])) {
241 241
 						$param['group'] = $val['group'];
242 242
 					}
243 243
 
244 244
 					// value
245
-					if ( $val['type'] == 'checkbox' ) {
246
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
-							unset( $param['default'] );
245
+					if ($val['type'] == 'checkbox') {
246
+						if (isset($val['default']) && $val['default'] == '0') {
247
+							unset($param['default']);
248 248
 						}
249
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
249
+						$param['value'] = array('0' => __("No", 'ayecode-connect'), '1' => __("Yes", 'ayecode-connect'));
250
+					} elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') {
251
+						$param['value'] = isset($val['options']) ? $val['options'] : array();
252 252
 					} else {
253
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
253
+						$param['value'] = isset($val['default']) ? $val['default'] : '';
254 254
 					}
255 255
 
256 256
 					// setup the param
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268 268
 		 */
269 269
 		public static function maybe_cornerstone_builder() {
270
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
270
+			if (did_action('cornerstone_before_boot_app')) {
271 271
 				self::shortcode_insert_button_script();
272 272
 			}
273 273
 		}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 		 *
280 280
 		 * @return string
281 281
 		 */
282
-		public static function get_picker( $editor_id = '' ) {
282
+		public static function get_picker($editor_id = '') {
283 283
 
284 284
 			ob_start();
285
-			if ( isset( $_POST['editor_id'] ) ) {
286
-				$editor_id = esc_attr( $_POST['editor_id'] );
287
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
285
+			if (isset($_POST['editor_id'])) {
286
+				$editor_id = esc_attr($_POST['editor_id']);
287
+			} elseif (isset($_REQUEST['et_fb'])) {
288 288
 				$editor_id = 'main_content_content_vb_tiny_mce';
289 289
 			}
290 290
 
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 
296 296
 			<div class="sd-shortcode-left-wrap">
297 297
 				<?php
298
-				ksort( $sd_widgets );
298
+				ksort($sd_widgets);
299 299
 				//				print_r($sd_widgets);exit;
300
-				if ( ! empty( $sd_widgets ) ) {
300
+				if (!empty($sd_widgets)) {
301 301
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
-					foreach ( $sd_widgets as $shortcode => $class ) {
304
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
302
+					echo "<option>" . __('Select shortcode', 'ayecode-connect') . "</option>";
303
+					foreach ($sd_widgets as $shortcode => $class) {
304
+						if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; }
305
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
306 306
 					}
307 307
 					echo "</select>";
308 308
 
@@ -315,37 +315,37 @@  discard block
 block discarded – undo
315 315
 			<div class="sd-shortcode-right-wrap">
316 316
 				<textarea id='sd-shortcode-output' disabled></textarea>
317 317
 				<div id='sd-shortcode-output-actions'>
318
-					<?php if ( $editor_id != '' ) { ?>
318
+					<?php if ($editor_id != '') { ?>
319 319
 						<button class="button sd-insert-shortcode-button"
320
-								onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
320
+								onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
321 321
 									echo "'" . $editor_id . "'";
322
-								} ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
322
+								} ?>)"><?php _e('Insert shortcode', 'ayecode-connect'); ?></button>
323 323
 					<?php } ?>
324 324
 					<button class="button"
325
-							onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
325
+							onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
326 326
 				</div>
327 327
 			</div>
328 328
 			<?php
329 329
 
330 330
 			$html = ob_get_clean();
331 331
 
332
-			if ( wp_doing_ajax() ) {
332
+			if (wp_doing_ajax()) {
333 333
 				echo $html;
334 334
 				$should_die = true;
335 335
 
336 336
 				// some builder get the editor via ajax so we should not die on those occasions
337 337
 				$dont_die = array(
338
-					'parent_tag',// WP Bakery
338
+					'parent_tag', // WP Bakery
339 339
 					'avia_request' // enfold
340 340
 				);
341 341
 
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
342
+				foreach ($dont_die as $request) {
343
+					if (isset($_REQUEST[$request])) {
344 344
 						$should_die = false;
345 345
 					}
346 346
 				}
347 347
 
348
-				if ( $should_die ) {
348
+				if ($should_die) {
349 349
 					wp_die();
350 350
 				}
351 351
 
@@ -361,22 +361,22 @@  discard block
 block discarded – undo
361 361
 		 * Output the version in the header.
362 362
 		 */
363 363
 		public function generator() {
364
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
364
+			$file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
365
+			$plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
366 366
 
367 367
 			// Find source plugin/theme of SD
368 368
 			$source = array();
369
-			if ( strpos( $file, $plugins_dir ) !== false ) {
370
-				$source = explode( "/", plugin_basename( $file ) );
371
-			} else if ( function_exists( 'get_theme_root' ) ) {
372
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
369
+			if (strpos($file, $plugins_dir) !== false) {
370
+				$source = explode("/", plugin_basename($file));
371
+			} else if (function_exists('get_theme_root')) {
372
+				$themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
373 373
 
374
-				if ( strpos( $file, $themes_dir ) !== false ) {
375
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
374
+				if (strpos($file, $themes_dir) !== false) {
375
+					$source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
376 376
 				}
377 377
 			}
378 378
 
379
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
379
+			echo '<meta name="generator" content="WP Super Duper v' . esc_attr($this->version) . '"' . (!empty($source[0]) ? ' data-sd-source="' . esc_attr($source[0]) . '"' : '') . ' />';
380 380
 		}
381 381
 
382 382
 		/**
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 		public static function get_widget_settings() {
388 388
 			global $sd_widgets;
389 389
 
390
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
-			if ( ! $shortcode ) {
390
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
391
+			if (!$shortcode) {
392 392
 				wp_die();
393 393
 			}
394
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
-			if ( ! $widget_args ) {
394
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
395
+			if (!$widget_args) {
396 396
 				wp_die();
397 397
 			}
398
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
-			if ( ! $class_name ) {
398
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
+			if (!$class_name) {
400 400
 				wp_die();
401 401
 			}
402 402
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$widget = new $class_name;
405 405
 
406 406
 			ob_start();
407
-			$widget->form( array() );
407
+			$widget->form(array());
408 408
 			$form = ob_get_clean();
409 409
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410 410
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 		 *@since 1.0.0
424 424
 		 *
425 425
 		 */
426
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
426
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
427 427
 			global $sd_widgets, $shortcode_insert_button_once;
428
-			if ( $shortcode_insert_button_once ) {
428
+			if ($shortcode_insert_button_once) {
429 429
 				return;
430 430
 			}
431 431
 			add_thickbox();
@@ -435,21 +435,21 @@  discard block
 block discarded – undo
435 435
 			 * Cornerstone makes us play dirty tricks :/
436 436
 			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437 437
 			 */
438
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
438
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
439 439
 				echo '<span id="insert-media-button">';
440 440
 			}
441 441
 
442
-			echo self::shortcode_button( 'this', 'true' );
442
+			echo self::shortcode_button('this', 'true');
443 443
 
444 444
 			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
445
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
446 446
 				echo '</span>'; // end #insert-media-button
447 447
 			}
448 448
 
449 449
 			// Add separate script for generatepress theme sections
450
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
450
+			if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) {
451 451
 			} else {
452
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
452
+				self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
453 453
 			}
454 454
 
455 455
 			$shortcode_insert_button_once = true;
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 		 *
464 464
 		 * @return mixed
465 465
 		 */
466
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
466
+		public static function shortcode_button($id = '', $search_for_id = '') {
467 467
 			ob_start();
468 468
 			?>
469 469
 			<span class="sd-lable-shortcode-inserter">
470 470
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
471
-				if ( $search_for_id ) {
471
+				if ($search_for_id) {
472 472
 					echo "," . $search_for_id;
473 473
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
474 474
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$html = ob_get_clean();
485 485
 
486 486
 			// remove line breaks so we can use it in js
487
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
487
+			return preg_replace("/\r|\n/", "", trim($html));
488 488
 		}
489 489
 
490 490
 		/**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 						jQuery($this).data('sd-widget-enabled', true);
543 543
 					}
544 544
 
545
-					var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
545
+					var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
546 546
 					var form = jQuery($this).parents('' + $selector + '');
547 547
 
548 548
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -577,10 +577,10 @@  discard block
 block discarded – undo
577 577
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
578 578
 			 */
579 579
 
580
-			return str_replace( array(
580
+			return str_replace(array(
581 581
 				'<script>',
582 582
 				'</script>'
583
-			), '', $output );
583
+			), '', $output);
584 584
 		}
585 585
 
586 586
 		/**
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		 *@since 1.0.6
593 593
 		 *
594 594
 		 */
595
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
595
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
596 596
 			?>
597 597
 			<style>
598 598
 				.sd-shortcode-left-wrap {
@@ -711,25 +711,25 @@  discard block
 block discarded – undo
711 711
 					width: 100%;
712 712
 				}
713 713
 
714
-				<?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?>
714
+				<?php if (function_exists('generate_sections_sections_metabox')) { ?>
715 715
 				.generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter {
716 716
 					display: inline;
717 717
 				}
718 718
 				<?php } ?>
719
-				<?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?>
719
+				<?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?>
720 720
 				body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999}
721 721
 				<?php } ?>
722 722
 			</style>
723 723
 			<?php
724
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
724
+			if (class_exists('SiteOrigin_Panels')) {
725 725
 				echo "<script>" . self::siteorigin_js() . "</script>";
726 726
 			}
727 727
 			?>
728 728
 			<script>
729 729
 				<?php
730
-				if(! empty( $insert_shortcode_function )){
730
+				if (!empty($insert_shortcode_function)) {
731 731
 					echo $insert_shortcode_function;
732
-				}else{
732
+				} else {
733 733
 
734 734
 				/**
735 735
 				 * Function for super duper insert shortcode.
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
 					if ($shortcode) {
743 743
 						if (!$editor_id) {
744 744
 							<?php
745
-							if ( isset( $_REQUEST['et_fb'] ) ) {
745
+							if (isset($_REQUEST['et_fb'])) {
746 746
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
747
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
748 748
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749 749
 							} else {
750 750
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 							'shortcode': $short_code,
828 828
 							'attributes': 123,
829 829
 							'post_id': 321,
830
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
830
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
831 831
 						};
832 832
 
833 833
 						if (typeof ajaxurl === 'undefined') {
834
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
834
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
835 835
 						}
836 836
 
837 837
 						jQuery.post(ajaxurl, data, function (response) {
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 					var data = {
1031 1031
 						'action': 'super_duper_get_picker',
1032 1032
 						'editor_id': $id,
1033
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
1033
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
1034 1034
 					};
1035 1035
 
1036 1036
 					if (!ajaxurl) {
1037
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
1037
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
1038 1038
 					}
1039 1039
 
1040 1040
 					jQuery.post(ajaxurl, data, function (response) {
@@ -1056,9 +1056,9 @@  discard block
 block discarded – undo
1056 1056
 				 */
1057 1057
 				function sd_shortcode_button($id) {
1058 1058
 					if ($id) {
1059
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
1059
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
1060 1060
 					} else {
1061
-						return '<?php echo self::shortcode_button();?>';
1061
+						return '<?php echo self::shortcode_button(); ?>';
1062 1062
 					}
1063 1063
 				}
1064 1064
 			</script>
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
 		 *
1073 1073
 		 * @return mixed
1074 1074
 		 */
1075
-		public function widget_css( $advanced = true ) {
1075
+		public function widget_css($advanced = true) {
1076 1076
 			ob_start();
1077 1077
 			?>
1078 1078
 			<style>
1079
-				<?php if( $advanced ){ ?>
1079
+				<?php if ($advanced) { ?>
1080 1080
 				.sd-advanced-setting {
1081 1081
 					display: none;
1082 1082
 				}
@@ -1120,10 +1120,10 @@  discard block
 block discarded – undo
1120 1120
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1121 1121
 			 */
1122 1122
 
1123
-			return str_replace( array(
1123
+			return str_replace(array(
1124 1124
 				'<style>',
1125 1125
 				'</style>'
1126
-			), '', $output );
1126
+			), '', $output);
1127 1127
 		}
1128 1128
 
1129 1129
 		/**
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 						jQuery($this).data('sd-widget-enabled', true);
1191 1191
 					}
1192 1192
 
1193
-					var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1193
+					var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1194 1194
 					var form = $form ? $form : jQuery($this).parents('' + $selector + '');
1195 1195
 
1196 1196
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 					});
1282 1282
 
1283 1283
 				}
1284
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1284
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1285 1285
 			</script>
1286 1286
 			<?php
1287 1287
 			$output = ob_get_clean();
@@ -1290,10 +1290,10 @@  discard block
 block discarded – undo
1290 1290
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1291 1291
 			 */
1292 1292
 
1293
-			return str_replace( array(
1293
+			return str_replace(array(
1294 1294
 				'<script>',
1295 1295
 				'</script>'
1296
-			), '', $output );
1296
+			), '', $output);
1297 1297
 		}
1298 1298
 
1299 1299
 
@@ -1304,14 +1304,14 @@  discard block
 block discarded – undo
1304 1304
 		 *
1305 1305
 		 * @return mixed
1306 1306
 		 */
1307
-		private function add_name_from_key( $options, $arguments = false ) {
1308
-			if ( ! empty( $options['arguments'] ) ) {
1309
-				foreach ( $options['arguments'] as $key => $val ) {
1310
-					$options['arguments'][ $key ]['name'] = $key;
1307
+		private function add_name_from_key($options, $arguments = false) {
1308
+			if (!empty($options['arguments'])) {
1309
+				foreach ($options['arguments'] as $key => $val) {
1310
+					$options['arguments'][$key]['name'] = $key;
1311 1311
 				}
1312
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
-				foreach ( $options as $key => $val ) {
1314
-					$options[ $key ]['name'] = $key;
1312
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1313
+				foreach ($options as $key => $val) {
1314
+					$options[$key]['name'] = $key;
1315 1315
 				}
1316 1316
 			}
1317 1317
 
@@ -1324,8 +1324,8 @@  discard block
 block discarded – undo
1324 1324
 		 * @since 1.0.0
1325 1325
 		 */
1326 1326
 		public function register_shortcode() {
1327
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1327
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1328
+			add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode'));
1329 1329
 		}
1330 1330
 
1331 1331
 		/**
@@ -1334,50 +1334,50 @@  discard block
 block discarded – undo
1334 1334
 		 * @since 1.0.0
1335 1335
 		 */
1336 1336
 		public function render_shortcode() {
1337
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
-			if ( ! current_user_can( 'manage_options' ) ) {
1337
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1338
+			if (!current_user_can('manage_options')) {
1339 1339
 				wp_die();
1340 1340
 			}
1341 1341
 
1342 1342
 			// we might need the $post value here so lets set it.
1343
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1345
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1343
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1344
+				$post_obj = get_post(absint($_POST['post_id']));
1345
+				if (!empty($post_obj) && empty($post)) {
1346 1346
 					global $post;
1347 1347
 					$post = $post_obj;
1348 1348
 				}
1349 1349
 			}
1350 1350
 
1351
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1351
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1352 1352
 				$is_preview = $this->is_preview();
1353
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1353
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1354
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355 1355
 				$attributes       = '';
1356
-				if ( ! empty( $attributes_array ) ) {
1357
-					foreach ( $attributes_array as $key => $value ) {
1358
-						if ( is_array( $value ) ) {
1359
-							$value = implode( ",", $value );
1356
+				if (!empty($attributes_array)) {
1357
+					foreach ($attributes_array as $key => $value) {
1358
+						if (is_array($value)) {
1359
+							$value = implode(",", $value);
1360 1360
 						}
1361 1361
 
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1362
+						if (!empty($value)) {
1363
+							$value = wp_unslash($value);
1364 1364
 
1365 1365
 							// Encode [ and ].
1366
-							if ( $is_preview ) {
1367
-								$value = $this->encode_shortcodes( $value );
1366
+							if ($is_preview) {
1367
+								$value = $this->encode_shortcodes($value);
1368 1368
 							}
1369 1369
 						}
1370
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1370
+						$attributes .= " " . esc_attr(sanitize_title_with_dashes($key)) . "='" . esc_attr($value) . "' ";
1371 1371
 					}
1372 1372
 				}
1373 1373
 
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1374
+				$shortcode = "[" . esc_attr($shortcode_name) . " " . $attributes . "]";
1375 1375
 
1376
-				$content = do_shortcode( $shortcode );
1376
+				$content = do_shortcode($shortcode);
1377 1377
 
1378 1378
 				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1379
+				if (!empty($content) && $is_preview) {
1380
+					$content = $this->decode_shortcodes($content);
1381 1381
 				}
1382 1382
 
1383 1383
 				echo $content;
@@ -1393,21 +1393,21 @@  discard block
 block discarded – undo
1393 1393
 		 *
1394 1394
 		 * @return string
1395 1395
 		 */
1396
-		public function shortcode_output( $args = array(), $content = '' ) {
1396
+		public function shortcode_output($args = array(), $content = '') {
1397 1397
 			$_instance = $args;
1398 1398
 
1399
-			$args = $this->argument_values( $args );
1399
+			$args = $this->argument_values($args);
1400 1400
 
1401 1401
 			// add extra argument so we know its a output to gutenberg
1402 1402
 			//$args
1403
-			$args = $this->string_to_bool( $args );
1403
+			$args = $this->string_to_bool($args);
1404 1404
 
1405 1405
 			// if we have a enclosed shortcode we add it to the special `html` argument
1406
-			if ( ! empty( $content ) ) {
1406
+			if (!empty($content)) {
1407 1407
 				$args['html'] = $content;
1408 1408
 			}
1409 1409
 
1410
-			if ( ! $this->is_preview() ) {
1410
+			if (!$this->is_preview()) {
1411 1411
 				/**
1412 1412
 				 * Filters the settings for a particular widget args.
1413 1413
 				 *
@@ -1418,40 +1418,40 @@  discard block
 block discarded – undo
1418 1418
 				 *@since 1.0.28
1419 1419
 				 *
1420 1420
 				 */
1421
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1421
+				$args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance);
1422 1422
 
1423
-				if ( ! is_array( $args ) ) {
1423
+				if (!is_array($args)) {
1424 1424
 					return $args;
1425 1425
 				}
1426 1426
 			}
1427 1427
 
1428
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
-			$class .= " sdel-".$this->get_instance_hash();
1428
+			$class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1429
+			$class .= " sdel-" . $this->get_instance_hash();
1430 1430
 
1431
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1431
+			$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
1432
+			$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
1433 1433
 
1434
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1434
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1435
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1436 1436
 
1437 1437
 			$shortcode_args = array();
1438 1438
 			$output         = '';
1439
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1439
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1440
+			if (isset($args['no_wrap']) && $args['no_wrap']) {
1441 1441
 				$no_wrap = true;
1442 1442
 			}
1443
-			$main_content = $this->output( $args, $shortcode_args, $content );
1444
-			if ( $main_content && ! $no_wrap ) {
1443
+			$main_content = $this->output($args, $shortcode_args, $content);
1444
+			if ($main_content && !$no_wrap) {
1445 1445
 				// wrap the shortcode in a div with the same class as the widget
1446 1446
 				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
-				if ( ! empty( $args['title'] ) ) {
1447
+				if (!empty($args['title'])) {
1448 1448
 					// if its a shortcode and there is a title try to grab the title wrappers
1449
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
-					if ( empty( $instance ) ) {
1449
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1450
+					if (empty($instance)) {
1451 1451
 						global $wp_registered_sidebars;
1452
-						if ( ! empty( $wp_registered_sidebars ) ) {
1453
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1454
-								if ( ! empty( $sidebar['before_title'] ) ) {
1452
+						if (!empty($wp_registered_sidebars)) {
1453
+							foreach ($wp_registered_sidebars as $sidebar) {
1454
+								if (!empty($sidebar['before_title'])) {
1455 1455
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1456 1456
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1457 1457
 									break;
@@ -1459,20 +1459,20 @@  discard block
 block discarded – undo
1459 1459
 							}
1460 1460
 						}
1461 1461
 					}
1462
-					$output .= $this->output_title( $shortcode_args, $args );
1462
+					$output .= $this->output_title($shortcode_args, $args);
1463 1463
 				}
1464 1464
 				$output .= $main_content;
1465 1465
 				$output .= '</div>';
1466
-			} elseif ( $main_content && $no_wrap ) {
1466
+			} elseif ($main_content && $no_wrap) {
1467 1467
 				$output .= $main_content;
1468 1468
 			}
1469 1469
 
1470 1470
 			// if preview show a placeholder if empty
1471
-			if ( $this->is_preview() && $output == '' ) {
1472
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1471
+			if ($this->is_preview() && $output == '') {
1472
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1473 1473
 			}
1474 1474
 
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1475
+			return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this);
1476 1476
 		}
1477 1477
 
1478 1478
 		/**
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 		 *
1483 1483
 		 * @return string
1484 1484
 		 */
1485
-		public function preview_placeholder_text( $name = '' ) {
1486
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1485
+		public function preview_placeholder_text($name = '') {
1486
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf(__('Placeholder for: %s', 'ayecode-connect'), $name) . "</div>";
1487 1487
 		}
1488 1488
 
1489 1489
 		/**
@@ -1493,13 +1493,13 @@  discard block
 block discarded – undo
1493 1493
 		 *
1494 1494
 		 * @return mixed
1495 1495
 		 */
1496
-		public function string_to_bool( $options ) {
1496
+		public function string_to_bool($options) {
1497 1497
 			// convert bool strings to booleans
1498
-			foreach ( $options as $key => $val ) {
1499
-				if ( $val == 'false' ) {
1500
-					$options[ $key ] = false;
1501
-				} elseif ( $val == 'true' ) {
1502
-					$options[ $key ] = true;
1498
+			foreach ($options as $key => $val) {
1499
+				if ($val == 'false') {
1500
+					$options[$key] = false;
1501
+				} elseif ($val == 'true') {
1502
+					$options[$key] = true;
1503 1503
 				}
1504 1504
 			}
1505 1505
 
@@ -1515,26 +1515,26 @@  discard block
 block discarded – undo
1515 1515
 		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516 1516
 		 *
1517 1517
 		 */
1518
-		public function argument_values( $instance ) {
1518
+		public function argument_values($instance) {
1519 1519
 			$argument_values = array();
1520 1520
 
1521 1521
 			// set widget instance
1522 1522
 			$this->instance = $instance;
1523 1523
 
1524
-			if ( empty( $this->arguments ) ) {
1524
+			if (empty($this->arguments)) {
1525 1525
 				$this->arguments = $this->get_arguments();
1526 1526
 			}
1527 1527
 
1528
-			if ( ! empty( $this->arguments ) ) {
1529
-				foreach ( $this->arguments as $key => $args ) {
1528
+			if (!empty($this->arguments)) {
1529
+				foreach ($this->arguments as $key => $args) {
1530 1530
 					// set the input name from the key
1531 1531
 					$args['name'] = $key;
1532 1532
 					//
1533
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1533
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1534
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1535 1535
 						// don't set default for an empty checkbox
1536
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
-						$argument_values[ $key ] = $args['default'];
1536
+					} elseif ($argument_values[$key] == '' && isset($args['default'])) {
1537
+						$argument_values[$key] = $args['default'];
1538 1538
 					}
1539 1539
 				}
1540 1540
 			}
@@ -1561,12 +1561,12 @@  discard block
 block discarded – undo
1561 1561
 		 *
1562 1562
 		 */
1563 1563
 		public function get_arguments() {
1564
-			if ( empty( $this->arguments ) ) {
1564
+			if (empty($this->arguments)) {
1565 1565
 				$this->arguments = $this->set_arguments();
1566 1566
 			}
1567 1567
 
1568
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1568
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1569
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1570 1570
 
1571 1571
 			return $this->arguments;
1572 1572
 		}
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		 * @param array $widget_args
1579 1579
 		 * @param string $content
1580 1580
 		 */
1581
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1581
+		public function output($args = array(), $widget_args = array(), $content = '') {
1582 1582
 
1583 1583
 		}
1584 1584
 
@@ -1586,9 +1586,9 @@  discard block
 block discarded – undo
1586 1586
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1587 1587
 		 */
1588 1588
 		public function register_block() {
1589
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1590
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1589
+			wp_add_inline_script('wp-blocks', $this->block());
1590
+			if (class_exists('SiteOrigin_Panels')) {
1591
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1592 1592
 			}
1593 1593
 		}
1594 1594
 
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 			$show      = false;
1603 1603
 			$arguments = $this->get_arguments();
1604 1604
 
1605
-			if ( ! empty( $arguments ) ) {
1606
-				foreach ( $arguments as $argument ) {
1607
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1605
+			if (!empty($arguments)) {
1606
+				foreach ($arguments as $argument) {
1607
+					if (isset($argument['advanced']) && $argument['advanced']) {
1608 1608
 						$show = true;
1609 1609
 						break; // no need to continue if we know we have it
1610 1610
 					}
@@ -1622,19 +1622,19 @@  discard block
 block discarded – undo
1622 1622
 		public function get_url() {
1623 1623
 			$url = $this->url;
1624 1624
 
1625
-			if ( ! $url ) {
1626
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1625
+			if (!$url) {
1626
+				$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
1627
+				$content_url = untrailingslashit(WP_CONTENT_URL);
1628 1628
 
1629 1629
 				// Replace http:// to https://.
1630
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1630
+				if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
1631
+					$content_url = str_replace('http://', 'https://', $content_url);
1632 1632
 				}
1633 1633
 
1634 1634
 				// Check if we are inside a plugin
1635
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1637
-				$url = trailingslashit( $url );
1635
+				$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
1636
+				$url = str_replace($content_dir, $content_url, $file_dir);
1637
+				$url = trailingslashit($url);
1638 1638
 				$this->url = $url;
1639 1639
 			}
1640 1640
 
@@ -1650,15 +1650,15 @@  discard block
 block discarded – undo
1650 1650
 
1651 1651
 			$url = $this->url;
1652 1652
 
1653
-			if ( ! $url ) {
1653
+			if (!$url) {
1654 1654
 				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1655
+				$file_dir = str_replace("/includes", "", dirname(__FILE__));
1656 1656
 
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
1657
+				$dir_parts = explode("/wp-content/", $file_dir);
1658
+				$url_parts = explode("/wp-content/", plugins_url());
1659 1659
 
1660
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1660
+				if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1661
+					$url       = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]);
1662 1662
 					$this->url = $url;
1663 1663
 				}
1664 1664
 			}
@@ -1679,45 +1679,45 @@  discard block
 block discarded – undo
1679 1679
 		 * @return string
1680 1680
 		 *@since 1.1.0
1681 1681
 		 */
1682
-		public function get_block_icon( $icon ) {
1682
+		public function get_block_icon($icon) {
1683 1683
 
1684 1684
 			// check if we have a Font Awesome icon
1685 1685
 			$fa_type = '';
1686
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1686
+			if (substr($icon, 0, 7) === "fas fa-") {
1687 1687
 				$fa_type = 'solid';
1688
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1688
+			} elseif (substr($icon, 0, 7) === "far fa-") {
1689 1689
 				$fa_type = 'regular';
1690
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1690
+			} elseif (substr($icon, 0, 7) === "fab fa-") {
1691 1691
 				$fa_type = 'brands';
1692 1692
 			} else {
1693 1693
 				$icon = "'" . $icon . "'";
1694 1694
 			}
1695 1695
 
1696 1696
 			// set the icon if we found one
1697
-			if ( $fa_type ) {
1698
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1697
+			if ($fa_type) {
1698
+				$fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon);
1699 1699
 				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700 1700
 			}
1701 1701
 
1702 1702
 			return $icon;
1703 1703
 		}
1704 1704
 
1705
-		public function group_arguments( $arguments ) {
1706
-			if ( ! empty( $arguments ) ) {
1705
+		public function group_arguments($arguments) {
1706
+			if (!empty($arguments)) {
1707 1707
 				$temp_arguments = array();
1708
-				$general        = __( "General", 'ayecode-connect' );
1708
+				$general        = __("General", 'ayecode-connect');
1709 1709
 				$add_sections   = false;
1710
-				foreach ( $arguments as $key => $args ) {
1711
-					if ( isset( $args['group'] ) ) {
1712
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1710
+				foreach ($arguments as $key => $args) {
1711
+					if (isset($args['group'])) {
1712
+						$temp_arguments[$args['group']][$key] = $args;
1713 1713
 						$add_sections                             = true;
1714 1714
 					} else {
1715
-						$temp_arguments[ $general ][ $key ] = $args;
1715
+						$temp_arguments[$general][$key] = $args;
1716 1716
 					}
1717 1717
 				}
1718 1718
 
1719 1719
 				// only add sections if more than one
1720
-				if ( $add_sections ) {
1720
+				if ($add_sections) {
1721 1721
 					$arguments = $temp_arguments;
1722 1722
 				}
1723 1723
 			}
@@ -1730,38 +1730,38 @@  discard block
 block discarded – undo
1730 1730
 		 *
1731 1731
 		 * @since 1.1.17
1732 1732
 		 */
1733
-		public function group_block_tabs( $tabs, $arguments ) {
1734
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1733
+		public function group_block_tabs($tabs, $arguments) {
1734
+			if (!empty($tabs) && !empty($arguments)) {
1735 1735
 				$has_sections = false;
1736 1736
 
1737
-				foreach ( $this->arguments as $key => $args ) {
1738
-					if ( isset( $args['group'] ) ) {
1737
+				foreach ($this->arguments as $key => $args) {
1738
+					if (isset($args['group'])) {
1739 1739
 						$has_sections = true;
1740 1740
 						break;
1741 1741
 					}
1742 1742
 				}
1743 1743
 
1744
-				if ( ! $has_sections ) {
1744
+				if (!$has_sections) {
1745 1745
 					return $tabs;
1746 1746
 				}
1747 1747
 
1748 1748
 				$new_tabs = array();
1749 1749
 
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1750
+				foreach ($tabs as $tab_key => $tab) {
1751 1751
 					$new_groups = array();
1752 1752
 
1753
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
-						foreach ( $tab['groups'] as $group ) {
1755
-							if ( isset( $arguments[ $group ] ) ) {
1753
+					if (!empty($tab['groups']) && is_array($tab['groups'])) {
1754
+						foreach ($tab['groups'] as $group) {
1755
+							if (isset($arguments[$group])) {
1756 1756
 								$new_groups[] = $group;
1757 1757
 							}
1758 1758
 						}
1759 1759
 					}
1760 1760
 
1761
-					if ( ! empty( $new_groups ) ) {
1761
+					if (!empty($new_groups)) {
1762 1762
 						$tab['groups'] = $new_groups;
1763 1763
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1764
+						$new_tabs[$tab_key] = $tab;
1765 1765
 					}
1766 1766
 				}
1767 1767
 
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 			?>
1789 1789
 			<script>
1790 1790
 			<?php
1791
-			if ( ! $sd_is_js_functions_loaded ) {
1791
+			if (!$sd_is_js_functions_loaded) {
1792 1792
 				$sd_is_js_functions_loaded = true;
1793 1793
 			?>
1794 1794
 function sd_show_view_options($this){
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	}
2112 2112
 }
2113 2113
 
2114
-<?php if( !isset( $_REQUEST['sd-block-recover-debug'] ) ){ ?>
2114
+<?php if (!isset($_REQUEST['sd-block-recover-debug'])) { ?>
2115 2115
 // Wait will window is loaded before calling.
2116 2116
 window.onload = function() {
2117 2117
 	sd_auto_recover_blocks();
@@ -2290,7 +2290,7 @@  discard block
 block discarded – undo
2290 2290
 				$classes = [];
2291 2291
 
2292 2292
 				<?php
2293
-				if($aui_bs5){
2293
+				if ($aui_bs5) {
2294 2294
 					?>
2295 2295
 				$aui_bs5 = true;
2296 2296
 				$p_ml = 'ms-';
@@ -2299,7 +2299,7 @@  discard block
 block discarded – undo
2299 2299
 				$p_pl = 'ps-';
2300 2300
 				$p_pr = 'pe-';
2301 2301
 					<?php
2302
-				}else{
2302
+				} else {
2303 2303
 						?>
2304 2304
 				$aui_bs5 = false;
2305 2305
 				$p_ml = 'ml-';
@@ -2487,7 +2487,7 @@  discard block
 block discarded – undo
2487 2487
 			}
2488 2488
 
2489 2489
 			function sd_get_class_build_keys(){
2490
-				return <?php echo json_encode(sd_get_class_build_keys());?>;
2490
+				return <?php echo json_encode(sd_get_class_build_keys()); ?>;
2491 2491
 			}
2492 2492
 
2493 2493
 			<?php
@@ -2495,7 +2495,7 @@  discard block
 block discarded – undo
2495 2495
 
2496 2496
 			}
2497 2497
 
2498
-			if(method_exists($this,'block_global_js')){
2498
+			if (method_exists($this, 'block_global_js')) {
2499 2499
 					echo $this->block_global_js();
2500 2500
 			}
2501 2501
 			?>
@@ -2527,9 +2527,9 @@  discard block
 block discarded – undo
2527 2527
 					var InnerBlocks = blockEditor.InnerBlocks;
2528 2528
 
2529 2529
 					var term_query_type = '';
2530
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2531
-					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2532
-					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2530
+					var post_type_rest_slugs = <?php if (!empty($this->arguments) && isset($this->arguments['post_type']['onchange_rest']['values'])) {echo "[" . json_encode($this->arguments['post_type']['onchange_rest']['values']) . "]"; } else {echo "[]"; } ?>;
2531
+					const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2532
+					const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2533 2533
 					const MediaUpload = wp.blockEditor.MediaUpload;
2534 2534
 
2535 2535
 					/**
@@ -2544,87 +2544,87 @@  discard block
 block discarded – undo
2544 2544
 					 * @return {?WPBlock}          The block, if it has been successfully
2545 2545
 					 *                             registered; otherwise `undefined`.
2546 2546
 					 */
2547
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2548
-						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2 ; ?>,
2549
-						title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title.
2550
-						description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title.
2551
-						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2547
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2548
+						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2; ?>,
2549
+						title: '<?php echo addslashes($this->options['name']); ?>', // Block title.
2550
+						description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title.
2551
+						icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2552 2552
 						supports: {
2553 2553
 							<?php
2554
-							if(!isset($this->options['block-supports']['renaming'])){
2554
+							if (!isset($this->options['block-supports']['renaming'])) {
2555 2555
 								$this->options['block-supports']['renaming'] = false;
2556 2556
 							}
2557
-							if ( isset( $this->options['block-supports'] ) ) {
2558
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2557
+							if (isset($this->options['block-supports'])) {
2558
+								echo $this->array_to_attributes($this->options['block-supports']);
2559 2559
 							}
2560 2560
 							?>
2561 2561
 						},
2562 2562
 						__experimentalLabel( attributes, { context } ) {
2563 2563
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
2564 2564
 							var metadata_name = attributes && attributes.metadata && attributes.metadata.name ? attributes.metadata.name : '';
2565
-							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr( addslashes( $this->options['name'] ) ) . "'"; ?>;
2565
+							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr(addslashes($this->options['name'])) . "'"; ?>;
2566 2566
 							return metadata_name ? metadata_name + visibility_html  : label_name + visibility_html;
2567 2567
 						},
2568
-						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
2569
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
2568
+						category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
2569
+						<?php if (isset($this->options['block-keywords'])) {
2570 2570
 						echo "keywords : " . $this->options['block-keywords'] . ",";
2571 2571
 						}
2572 2572
 
2573 2573
 
2574 2574
 						// block hover preview.
2575 2575
 						$example_args = array();
2576
-						if(!empty($this->arguments)){
2577
-							foreach($this->arguments as $key => $a_args){
2578
-								if(isset($a_args['example'])){
2576
+						if (!empty($this->arguments)) {
2577
+							foreach ($this->arguments as $key => $a_args) {
2578
+								if (isset($a_args['example'])) {
2579 2579
 									$example_args[$key] = $a_args['example'];
2580 2580
 								}
2581 2581
 							}
2582 2582
 						}
2583
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2583
+						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: ' . absint($this->options['example']['viewportWidth']) : '';
2584 2584
 						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2585
+						if (isset($this->options['example']) && $this->options['example'] === false) {
2586 2586
 							// no preview if set to false
2587
-						}elseif( !empty( $example_args ) ){
2588
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
-						}elseif( !empty( $this->options['example'] ) ){
2587
+						}elseif (!empty($example_args)) {
2588
+							echo "example : {attributes:{" . $this->array_to_attributes($example_args) . "},$viewport_width},";
2589
+						}elseif (!empty($this->options['example'])) {
2590 2590
 							unset($this->options['example']['viewportWidth']);
2591 2591
 							unset($this->options['example']['innerBlocks']);
2592
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2592
+							$example_atts = $this->array_to_attributes($this->options['example']);
2593 2593
 							$example_parts = array();
2594
-							if($example_atts){
2595
-								$example_parts[] = rtrim($example_atts,",");
2594
+							if ($example_atts) {
2595
+								$example_parts[] = rtrim($example_atts, ",");
2596 2596
 							}
2597
-							if($viewport_width){
2597
+							if ($viewport_width) {
2598 2598
 								$example_parts[] = $viewport_width;
2599 2599
 							}
2600
-							if($example_inner_blocks){
2600
+							if ($example_inner_blocks) {
2601 2601
 								$example_parts[] = $example_inner_blocks;
2602 2602
 							}
2603
-							if(!empty($example_parts)){
2604
-								echo "example : {".implode(',', $example_parts)."},";
2603
+							if (!empty($example_parts)) {
2604
+								echo "example : {" . implode(',', $example_parts) . "},";
2605 2605
 							}
2606
-						}else{
2606
+						} else {
2607 2607
 							echo 'example : {viewportWidth: 500},';
2608 2608
 						}
2609 2609
 
2610 2610
 
2611 2611
 
2612 2612
 						// limit to parent
2613
-						if( !empty( $this->options['parent'] ) ){
2614
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2613
+						if (!empty($this->options['parent'])) {
2614
+							echo "parent : " . wp_json_encode($this->options['parent']) . ",";
2615 2615
 						}
2616 2616
 
2617 2617
 						// limit allowed blocks
2618
-						if( !empty( $this->options['allowed-blocks'] ) ){
2619
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2618
+						if (!empty($this->options['allowed-blocks'])) {
2619
+							echo "allowedBlocks : " . wp_json_encode($this->options['allowed-blocks']) . ",";
2620 2620
 						}
2621 2621
 
2622 2622
 						// maybe set no_wrap
2623
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2623
+						$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
2624
+						if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) {
2625 2625
 							$no_wrap = true;
2626 2626
 						}
2627
-						if ( $no_wrap ) {
2627
+						if ($no_wrap) {
2628 2628
 							$this->options['block-wrap'] = '';
2629 2629
 						}
2630 2630
 
@@ -2641,7 +2641,7 @@  discard block
 block discarded – undo
2641 2641
 
2642 2642
 							echo "attributes : {";
2643 2643
 
2644
-							if ( $show_advanced ) {
2644
+							if ($show_advanced) {
2645 2645
 								echo "show_advanced: {";
2646 2646
 								echo "	type: 'boolean',";
2647 2647
 								echo "  default: false,";
@@ -2649,57 +2649,57 @@  discard block
 block discarded – undo
2649 2649
 							}
2650 2650
 
2651 2651
 							// block wrap element
2652
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2652
+							if (!empty($this->options['block-wrap'])) { //@todo we should validate this?
2653 2653
 								echo "block_wrap: {";
2654 2654
 								echo "	type: 'string',";
2655
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2655
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
2656 2656
 								echo "},";
2657 2657
 							}
2658 2658
 
2659 2659
 
2660
-							if ( ! empty( $this->arguments ) ) {
2660
+							if (!empty($this->arguments)) {
2661 2661
 
2662
-								foreach ( $this->arguments as $key => $args ) {
2662
+								foreach ($this->arguments as $key => $args) {
2663 2663
 
2664
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2664
+									if ($args['type'] == 'image' || $args['type'] == 'images') {
2665 2665
 										$img_drag_drop = true;
2666 2666
 									}
2667 2667
 
2668 2668
 									// set if we should show alignment
2669
-									if ( $key == 'alignment' ) {
2669
+									if ($key == 'alignment') {
2670 2670
 										$show_alignment = true;
2671 2671
 									}
2672 2672
 
2673 2673
 									$extra = '';
2674 2674
 
2675
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2675
+									if ($args['type'] == 'notice' || $args['type'] == 'tab') {
2676 2676
 										continue;
2677 2677
 									}
2678
-									elseif ( $args['type'] == 'checkbox' ) {
2678
+									elseif ($args['type'] == 'checkbox') {
2679 2679
 										$type    = 'boolean';
2680
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
-									} elseif ( $args['type'] == 'number' ) {
2680
+										$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
2681
+									} elseif ($args['type'] == 'number') {
2682 2682
 										$type    = 'number';
2683
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2683
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2684
+									} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
2685 2685
 										$type = 'array';
2686
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2686
+										if (isset($args['default']) && is_array($args['default'])) {
2687
+											$default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
2688 2688
 										} else {
2689
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2689
+											$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2690 2690
 										}
2691
-									} elseif ( $args['type'] == 'tagselect' ) {
2691
+									} elseif ($args['type'] == 'tagselect') {
2692 2692
 										$type    = 'array';
2693
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
-									} elseif ( $args['type'] == 'multiselect' ) {
2693
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2694
+									} elseif ($args['type'] == 'multiselect') {
2695 2695
 										$type    = 'array';
2696
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
-									} elseif ( $args['type'] == 'image_xy' ) {
2696
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2697
+									} elseif ($args['type'] == 'image_xy') {
2698 2698
 										$type    = 'object';
2699
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
-									} elseif ( $args['type'] == 'image' ) {
2699
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2700
+									} elseif ($args['type'] == 'image') {
2701 2701
 										$type    = 'string';
2702
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2702
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2703 2703
 
2704 2704
 										// add a field for ID
2705 2705
 	//                                    echo $key . "_id : {";
@@ -2711,7 +2711,7 @@  discard block
 block discarded – undo
2711 2711
 
2712 2712
 									} else {
2713 2713
 										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2714
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2715 2715
 
2716 2716
 									}
2717 2717
 									echo $key . " : {";
@@ -2724,7 +2724,7 @@  discard block
 block discarded – undo
2724 2724
 							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725 2725
 							echo "sd_shortcode : {type : 'string',default: ''},";
2726 2726
 
2727
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2727
+							if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
2728 2728
 								echo "sd_shortcode_close : {type : 'string',default: ''},";
2729 2729
 							}
2730 2730
 
@@ -2743,7 +2743,7 @@  discard block
 block discarded – undo
2743 2743
 
2744 2744
 <?php
2745 2745
 // only include the drag/drop functions if required.
2746
-if( $img_drag_drop ){
2746
+if ($img_drag_drop) {
2747 2747
 
2748 2748
 ?>
2749 2749
 
@@ -2809,9 +2809,9 @@  discard block
 block discarded – undo
2809 2809
 							}
2810 2810
 
2811 2811
 							<?php
2812
-							if(!empty($this->options['block-edit-raw'])) {
2812
+							if (!empty($this->options['block-edit-raw'])) {
2813 2813
 								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
-							}else{
2814
+							} else {
2815 2815
 							?>
2816 2816
 
2817 2817
 function hasSelectedInnerBlock(props) {
@@ -2835,7 +2835,7 @@  discard block
 block discarded – undo
2835 2835
 	var $value = '';
2836 2836
 	<?php
2837 2837
 	// if we have a post_type and a category then link them
2838
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2838
+	if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) {
2839 2839
 	?>
2840 2840
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2841 2841
 		$pt = props.attributes.post_type;
@@ -2850,9 +2850,9 @@  discard block
 block discarded – undo
2850 2850
 		}
2851 2851
 <?php
2852 2852
 	$cat_path = '';
2853
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2853
+	if (!empty($this->arguments['post_type']['onchange_rest']['path'])) {
2854
+		$cat_path = esc_js(strip_tags($this->arguments['post_type']['onchange_rest']['path']));
2855
+		$cat_path = str_replace(array('&quot;', '&#039;'), array('"', "'"), $cat_path);
2856 2856
 	}
2857 2857
 ?>
2858 2858
 		/* taxonomies */
@@ -2860,15 +2860,15 @@  discard block
 block discarded – undo
2860 2860
 			if (!window.gdCPTCats) {
2861 2861
 				window.gdCPTCats = [];
2862 2862
 			}
2863
-			var gdCatPath = "<?php echo ( ! empty( $cat_path ) ? $cat_path : "/wp/v2/" + $value + "/categories/?per_page=100" ); ?>";
2863
+			var gdCatPath = "<?php echo (!empty($cat_path) ? $cat_path : "/wp/v2/" +$value + "/categories/?per_page=100"); ?>";
2864 2864
 			if (window.gdCPTCats[gdCatPath]) {
2865 2865
 				terms = window.gdCPTCats[gdCatPath];
2866
-				while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2867
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2866
+				while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2867
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2868 2868
 				}
2869
-				taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2869
+				taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2870 2870
 				jQuery.each( terms, function( key, val ) {
2871
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2871
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2872 2872
 				});
2873 2873
 
2874 2874
 				/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2878,12 +2878,12 @@  discard block
 block discarded – undo
2878 2878
 			} else {
2879 2879
 				wp.apiFetch({path: gdCatPath}).then(terms => {
2880 2880
 					window.gdCPTCats[gdCatPath] = terms;
2881
-					while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2882
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2881
+					while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2882
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2883 2883
 					}
2884
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2884
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2885 2885
 					jQuery.each( terms, function( key, val ) {
2886
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2886
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2887 2887
 					});
2888 2888
 
2889 2889
 					/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
 					props.setAttributes({category: [0] });
2892 2892
 					props.setAttributes({category: $old_cat_value });
2893 2893
 
2894
-					return taxonomies_<?php echo str_replace("-","_", $this->id);?>;
2894
+					return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>;
2895 2895
 				});
2896 2896
 			}
2897 2897
 		}
@@ -2903,12 +2903,12 @@  discard block
 block discarded – undo
2903 2903
 			}
2904 2904
 			if (window.gdCPTSort[$pt]) {
2905 2905
 				response = window.gdCPTSort[$pt];
2906
-				while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2907
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2906
+				while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2907
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2908 2908
 				}
2909 2909
 
2910 2910
 				jQuery.each( response, function( key, val ) {
2911
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2911
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2912 2912
 				});
2913 2913
 
2914 2914
 				// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2923,12 +2923,12 @@  discard block
 block discarded – undo
2923 2923
 				jQuery.post(ajaxurl, data, function(response) {
2924 2924
 					response = JSON.parse(response);
2925 2925
 					window.gdCPTSort[$pt] = response;
2926
-					while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2927
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2926
+					while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2927
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2928 2928
 					}
2929 2929
 
2930 2930
 					jQuery.each( response, function( key, val ) {
2931
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2931
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2932 2932
 					});
2933 2933
 
2934 2934
 					// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2936,7 +2936,7 @@  discard block
 block discarded – undo
2936 2936
 					props.setAttributes({sort_by: [0] });
2937 2937
 					props.setAttributes({sort_by: $old_sort_by_value });
2938 2938
 
2939
-					return sort_by_<?php echo str_replace("-","_", $this->id);?>;
2939
+					return sort_by_<?php echo str_replace("-", "_", $this->id); ?>;
2940 2940
 				});
2941 2941
 			}
2942 2942
 		}
@@ -2944,9 +2944,9 @@  discard block
 block discarded – undo
2944 2944
 	<?php } ?>
2945 2945
 <?php
2946 2946
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947
-if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2947
+if (!empty($current_screen->base) && $current_screen->base === 'widgets') {
2948 2948
 	echo 'const { deviceType } = "";';
2949
-}else{
2949
+} else {
2950 2950
 ?>
2951 2951
 /** Get device type const. */
2952 2952
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
@@ -3005,13 +3005,13 @@  discard block
 block discarded – undo
3005 3005
 
3006 3006
 									var data = {
3007 3007
 										'action': 'super_duper_output_shortcode',
3008
-										'shortcode': '<?php echo $this->options['base_id'];?>',
3008
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
3009 3009
 										'attributes': props.attributes,
3010 3010
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
3011
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
3011
+										'post_id': <?php global $post; if (isset($post->ID)) {
3012 3012
 										echo $post->ID;
3013
-									}else{echo '0';}?>,
3014
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
3013
+									} else {echo '0'; }?>,
3014
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
3015 3015
 									};
3016 3016
 
3017 3017
 									jQuery.post(ajaxurl, data, function (response) {
@@ -3020,17 +3020,17 @@  discard block
 block discarded – undo
3020 3020
 
3021 3021
 										// if the content is empty then we place some placeholder text
3022 3022
 										if (env == '') {
3023
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for:', 'ayecode-connect' );?> " + props.name + "</div>";
3023
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for:', 'ayecode-connect'); ?> " + props.name + "</div>";
3024 3024
 										}
3025 3025
 
3026 3026
 										 <?php
3027
-										if(!empty($this->options['nested-block'])){
3027
+										if (!empty($this->options['nested-block'])) {
3028 3028
 											?>
3029 3029
 											// props.setAttributes({content: env});
3030 3030
 										is_fetching = false;
3031 3031
 										prev_attributes[props.clientId] = props.attributes;
3032 3032
 											 <?php
3033
-										}else{
3033
+										} else {
3034 3034
 										?>
3035 3035
 										props.setAttributes({content: env});
3036 3036
 										is_fetching = false;
@@ -3056,38 +3056,38 @@  discard block
 block discarded – undo
3056 3056
 							}
3057 3057
 
3058 3058
 							<?php
3059
-							if(!empty($this->options['block-edit-js'])) {
3060
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3059
+							if (!empty($this->options['block-edit-js'])) {
3060
+								echo  $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues
3061 3061
 							}
3062 3062
 
3063 3063
 
3064 3064
 
3065 3065
 
3066
-							if(empty($this->options['block-save-return'])){
3066
+							if (empty($this->options['block-save-return'])) {
3067 3067
 							?>
3068 3068
 								///////////////////////////////////////////////////////////////////////
3069 3069
 
3070 3070
 									 // build the shortcode.
3071
-								shortcode = "[<?php echo $this->options['base_id'];?>";
3071
+								shortcode = "[<?php echo $this->options['base_id']; ?>";
3072 3072
 								<?php
3073 3073
 
3074
-								if(! empty( $this->arguments )){
3074
+								if (!empty($this->arguments)) {
3075 3075
 
3076
-								foreach($this->arguments as $key => $args){
3076
+								foreach ($this->arguments as $key => $args) {
3077 3077
 								   // if($args['type']=='tabs'){continue;}
3078 3078
 
3079 3079
 								   // don't add metadata arguments
3080
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3080
+								   if (substr($key, 0, 9) === 'metadata_') {
3081 3081
 									   continue;
3082 3082
 								   }
3083 3083
 								?>
3084
-								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3085
-									if ('<?php echo esc_attr( $key );?>' == 'html') {
3086
-									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3087
-										shortcode += props.attributes.<?php echo esc_attr( $key );?>.length && ( props.attributes.<?php echo esc_attr( $key );?>.x.length || props.attributes.<?php echo esc_attr( $key );?>.y.length ) ? " <?php echo esc_attr( $key );?>='{x:" + props.attributes.<?php echo esc_attr( $key );?>.x + ",y:"+props.attributes.<?php echo esc_attr( $key );?>.y +"}' " : "";
3084
+								if (props.attributes.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3085
+									if ('<?php echo esc_attr($key); ?>' == 'html') {
3086
+									} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3087
+										shortcode += props.attributes.<?php echo esc_attr($key); ?>.length && ( props.attributes.<?php echo esc_attr($key); ?>.x.length || props.attributes.<?php echo esc_attr($key); ?>.y.length ) ? " <?php echo esc_attr($key); ?>='{x:" + props.attributes.<?php echo esc_attr($key); ?>.x + ",y:"+props.attributes.<?php echo esc_attr($key); ?>.y +"}' " : "";
3088 3088
 									} else {
3089
-										//shortcode += props.attributes.<?php echo esc_attr( $key );?>.length ? " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' " : "";
3090
-										shortcode +=  " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3089
+										//shortcode += props.attributes.<?php echo esc_attr($key); ?>.length ? " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' " : "";
3090
+										shortcode +=  " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3091 3091
 									}
3092 3092
 								}
3093 3093
 								<?php
@@ -3106,8 +3106,8 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 
3108 3108
 									<?php
3109
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3109
+									if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
3110
+										echo "props.setAttributes({sd_shortcode_close: '[/" . esc_attr($this->options['base_id']) . "]'});";
3111 3111
 									}
3112 3112
 									?>
3113 3113
 								}
@@ -3122,7 +3122,7 @@  discard block
 block discarded – undo
3122 3122
 
3123 3123
 								el(wp.blockEditor.BlockControls, {key: 'controls'},
3124 3124
 
3125
-									<?php if($show_alignment){?>
3125
+									<?php if ($show_alignment) {?>
3126 3126
 									el(
3127 3127
 										wp.blockEditor.AlignmentToolbar,
3128 3128
 										{
@@ -3140,9 +3140,9 @@  discard block
 block discarded – undo
3140 3140
 
3141 3141
 									<?php
3142 3142
 
3143
-									if(! empty( $this->arguments )){
3143
+									if (!empty($this->arguments)) {
3144 3144
 
3145
-									if ( $show_advanced ) {
3145
+									if ($show_advanced) {
3146 3146
 									?>
3147 3147
 									el('div', {
3148 3148
 											style: {'padding-left': '16px','padding-right': '16px'}
@@ -3162,42 +3162,42 @@  discard block
 block discarded – undo
3162 3162
 									<?php
3163 3163
 									}
3164 3164
 
3165
-									$arguments = $this->group_arguments( $this->arguments );
3166
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3165
+									$arguments = $this->group_arguments($this->arguments);
3166
+									$block_group_tabs = !empty($this->options['block_group_tabs']) ? $this->group_block_tabs($this->options['block_group_tabs'], $arguments) : array();
3167 3167
 
3168 3168
 									// Do we have sections?
3169 3169
 									$has_sections = $arguments == $this->arguments ? false : true;
3170 3170
 
3171
-									if($has_sections){
3171
+									if ($has_sections) {
3172 3172
 									$panel_count = 0;
3173 3173
 									$open_tab = '';
3174 3174
 
3175 3175
 									$open_tab_groups = array();
3176 3176
 									$used_tabs = array();
3177 3177
 
3178
-									foreach ( $arguments as $key => $args ) {
3178
+									foreach ($arguments as $key => $args) {
3179 3179
 										$close_tab = false;
3180 3180
 										$close_tabs = false;
3181 3181
 
3182
-										 if ( ! empty( $block_group_tabs ) ) {
3183
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3182
+										 if (!empty($block_group_tabs)) {
3183
+											foreach ($block_group_tabs as $tab_name => $tab_args) {
3184
+												if (in_array($key, $tab_args['groups'])) {
3185 3185
 													$open_tab_groups[] = $key;
3186 3186
 
3187
-													if ( $open_tab != $tab_name ) {
3187
+													if ($open_tab != $tab_name) {
3188 3188
 														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189 3189
 														$tab_args['tab']['open'] = true;
3190 3190
 
3191
-														$this->block_tab_start( '', $tab_args );
3191
+														$this->block_tab_start('', $tab_args);
3192 3192
 														$open_tab = $tab_name;
3193 3193
 														$used_tabs[] = $tab_name;
3194 3194
 													}
3195 3195
 
3196
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3196
+													if ($open_tab_groups == $tab_args['groups']) {
3197 3197
 														$close_tab = true;
3198 3198
 														$open_tab_groups = array();
3199 3199
 
3200
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3200
+														if ($used_tabs == array_keys($block_group_tabs)) {
3201 3201
 															$close_tabs = true;
3202 3202
 														}
3203 3203
 													}
@@ -3206,27 +3206,27 @@  discard block
 block discarded – undo
3206 3206
 										}
3207 3207
 										?>
3208 3208
 										el(wp.components.PanelBody, {
3209
-												title: '<?php esc_attr_e( $key ); ?>',
3210
-												initialOpen: <?php if ( $panel_count ) {
3209
+												title: '<?php esc_attr_e($key); ?>',
3210
+												initialOpen: <?php if ($panel_count) {
3211 3211
 												echo "false";
3212 3212
 											} else {
3213 3213
 												echo "true";
3214 3214
 											}?>
3215 3215
 											},
3216 3216
 											<?php
3217
-											foreach ( $args as $k => $a ) {
3218
-												$this->block_tab_start( $k, $a );
3219
-												$this->block_row_start( $k, $a );
3220
-												$this->build_block_arguments( $k, $a );
3221
-												$this->block_row_end( $k, $a );
3222
-												$this->block_tab_end( $k, $a );
3217
+											foreach ($args as $k => $a) {
3218
+												$this->block_tab_start($k, $a);
3219
+												$this->block_row_start($k, $a);
3220
+												$this->build_block_arguments($k, $a);
3221
+												$this->block_row_end($k, $a);
3222
+												$this->block_tab_end($k, $a);
3223 3223
 											}
3224 3224
 											?>
3225 3225
 										),
3226 3226
 										<?php
3227
-										$panel_count ++;
3227
+										$panel_count++;
3228 3228
 
3229
-										if($close_tab || $close_tabs){
3229
+										if ($close_tab || $close_tabs) {
3230 3230
 											$tab_args = array(
3231 3231
 												'tab'	=> array(
3232 3232
 													'tabs_close' => $close_tabs,
@@ -3234,24 +3234,24 @@  discard block
 block discarded – undo
3234 3234
 												)
3235 3235
 
3236 3236
 											);
3237
-											$this->block_tab_end( '', $tab_args );
3237
+											$this->block_tab_end('', $tab_args);
3238 3238
 //											echo '###close'; print_r($tab_args);
3239 3239
 											$panel_count = 0;
3240 3240
 										}
3241 3241
 //
3242 3242
 
3243 3243
 									}
3244
-									}else {
3244
+									} else {
3245 3245
 									?>
3246 3246
 									el(wp.components.PanelBody, {
3247
-											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3247
+											title: '<?php esc_attr_e("Settings", 'ayecode-connect'); ?>',
3248 3248
 											initialOpen: true
3249 3249
 										},
3250 3250
 										<?php
3251
-										foreach ( $this->arguments as $key => $args ) {
3252
-											$this->block_row_start( $key, $args );
3253
-											$this->build_block_arguments( $key, $args );
3254
-											$this->block_row_end( $key, $args );
3251
+										foreach ($this->arguments as $key => $args) {
3252
+											$this->block_row_start($key, $args);
3253
+											$this->build_block_arguments($key, $args);
3254
+											$this->block_row_end($key, $args);
3255 3255
 										}
3256 3256
 										?>
3257 3257
 									),
@@ -3265,11 +3265,11 @@  discard block
 block discarded – undo
3265 3265
 
3266 3266
 								<?php
3267 3267
 								// If the user sets block-output array then build it
3268
-								if ( ! empty( $this->options['block-output'] ) ) {
3269
-								$this->block_element( $this->options['block-output'] );
3270
-							}elseif(!empty($this->options['block-edit-return'])){
3268
+								if (!empty($this->options['block-output'])) {
3269
+								$this->block_element($this->options['block-output']);
3270
+							}elseif (!empty($this->options['block-edit-return'])) {
3271 3271
 								   echo $this->options['block-edit-return'];
3272
-							}else{
3272
+							} else {
3273 3273
 								// if no block-output is set then we try and get the shortcode html output via ajax.
3274 3274
 								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275 3275
 								?>
@@ -3296,27 +3296,27 @@  discard block
 block discarded – undo
3296 3296
 							var align = '';
3297 3297
 
3298 3298
 							// build the shortcode.
3299
-							var content = "[<?php echo $this->options['base_id'];?>";
3299
+							var content = "[<?php echo $this->options['base_id']; ?>";
3300 3300
 							$html = '';
3301 3301
 							<?php
3302 3302
 
3303
-							if(! empty( $this->arguments )){
3303
+							if (!empty($this->arguments)) {
3304 3304
 
3305
-							foreach($this->arguments as $key => $args){
3305
+							foreach ($this->arguments as $key => $args) {
3306 3306
 							   // if($args['type']=='tabs'){continue;}
3307 3307
 
3308 3308
 							   // don't add metadata arguments
3309
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3309
+							   if (substr($key, 0, 9) === 'metadata_') {
3310 3310
 								   continue;
3311 3311
 							   }
3312 3312
 							?>
3313
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3314
-								if ('<?php echo esc_attr( $key );?>' == 'html') {
3315
-									$html = attr.<?php echo esc_attr( $key );?>;
3316
-								} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3317
-									content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' ";
3313
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3314
+								if ('<?php echo esc_attr($key); ?>' == 'html') {
3315
+									$html = attr.<?php echo esc_attr($key); ?>;
3316
+								} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3317
+									content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' ";
3318 3318
 								} else {
3319
-									content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3319
+									content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3320 3320
 								}
3321 3321
 							}
3322 3322
 							<?php
@@ -3336,7 +3336,7 @@  discard block
 block discarded – undo
3336 3336
 							?>
3337 3337
 							// if has html element
3338 3338
 							if ($html) {
3339
-								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
3339
+								//content += $html + "[/<?php echo $this->options['base_id']; ?>]";
3340 3340
 							}
3341 3341
 
3342 3342
 							// @todo should we add inline style here or just css classes?
@@ -3366,7 +3366,7 @@  discard block
 block discarded – undo
3366 3366
 //                                <x?php
3367 3367
 //							}else
3368 3368
 
3369
-							if(!empty($this->options['block-output'])){
3369
+							if (!empty($this->options['block-output'])) {
3370 3370
 //                               echo "return";
3371 3371
 //                               $this->block_element( $this->options['block-output'], true );
3372 3372
 //                               echo ";";
@@ -3376,30 +3376,30 @@  discard block
 block discarded – undo
3376 3376
 								   '',
3377 3377
 								   {},
3378 3378
 								  // el('', {dangerouslySetInnerHTML: {__html: content}}),
3379
-								   <?php $this->block_element( $this->options['block-output'], true ); ?>
3380
-								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3379
+								   <?php $this->block_element($this->options['block-output'], true); ?>
3380
+								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3381 3381
 							   );
3382 3382
 								<?php
3383 3383
 
3384
-							}elseif(!empty($this->options['block-save-return'])){
3384
+							}elseif (!empty($this->options['block-save-return'])) {
3385 3385
 								   echo 'return ' . $this->options['block-save-return'];
3386
-							}elseif(!empty($this->options['nested-block'])){
3386
+							}elseif (!empty($this->options['nested-block'])) {
3387 3387
 								?>
3388 3388
 							  return el(
3389 3389
 								   '',
3390 3390
 								   {},
3391 3391
 								   el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}),
3392 3392
 								   InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here
3393
-								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3393
+								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3394 3394
 							   );
3395 3395
 								<?php
3396
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3397
-								echo "return ". $this->options['block-edit-return'].";";
3398
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3396
+							}elseif (!empty($this->options['block-save-return'])) {
3397
+								echo "return " . $this->options['block-edit-return'] . ";";
3398
+							}elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') {
3399 3399
 							?>
3400 3400
 							return content;
3401 3401
 							<?php
3402
-							}else{
3402
+							} else {
3403 3403
 							?>
3404 3404
 							var block_wrap = 'div';
3405 3405
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -3428,48 +3428,48 @@  discard block
 block discarded – undo
3428 3428
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3429 3429
 			 */
3430 3430
 
3431
-			return str_replace( array(
3431
+			return str_replace(array(
3432 3432
 				'<script>',
3433 3433
 				'</script>'
3434
-			), '', $output );
3434
+			), '', $output);
3435 3435
 		}
3436 3436
 
3437 3437
 
3438 3438
 
3439
-		public function block_row_start($key, $args){
3439
+		public function block_row_start($key, $args) {
3440 3440
 
3441 3441
 			// check for row
3442
-			if(!empty($args['row'])){
3442
+			if (!empty($args['row'])) {
3443 3443
 
3444
-				if(!empty($args['row']['open'])){
3444
+				if (!empty($args['row']['open'])) {
3445 3445
 
3446 3446
 				// element require
3447
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3447
+				$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3448
+				$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3449
+				$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450 3450
 				$device_type_icon = '';
3451
-				if($device_type=='Desktop'){
3451
+				if ($device_type == 'Desktop') {
3452 3452
 					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
-				}elseif($device_type=='Tablet'){
3453
+				}elseif ($device_type == 'Tablet') {
3454 3454
 					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
-				}elseif($device_type=='Mobile'){
3455
+				}elseif ($device_type == 'Mobile') {
3456 3456
 					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457 3457
 				}
3458 3458
 				echo $element_require;
3459 3459
 				echo $device_type_require;
3460 3460
 
3461
-					if(false){?><script><?php }?>
3461
+					if (false) {?><script><?php }?>
3462 3462
 						el('div', {
3463 3463
 								className: 'bsui components-base-control',
3464 3464
 							},
3465
-							<?php if(!empty($args['row']['title'])){ ?>
3465
+							<?php if (!empty($args['row']['title'])) { ?>
3466 3466
 							el('label', {
3467 3467
 									className: 'components-base-control__label position-relative',
3468 3468
 									style: {width:"100%"}
3469 3469
 								},
3470
-								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}),
3471
-								<?php if($device_type_icon){ ?>
3472
-									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3470
+								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}),
3471
+								<?php if ($device_type_icon) { ?>
3472
+									deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3473 3473
 								<?php
3474 3474
 								}
3475 3475
 								?>
@@ -3477,17 +3477,17 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
 							),
3479 3479
 							<?php }?>
3480
-							<?php if(!empty($args['row']['desc'])){ ?>
3480
+							<?php if (!empty($args['row']['desc'])) { ?>
3481 3481
 							el('p', {
3482 3482
 									className: 'components-base-control__help mb-0',
3483 3483
 								},
3484
-								'<?php echo addslashes( $args['row']['desc'] ); ?>'
3484
+								'<?php echo addslashes($args['row']['desc']); ?>'
3485 3485
 							),
3486 3486
 							<?php }?>
3487 3487
 							el(
3488 3488
 								'div',
3489 3489
 								{
3490
-									className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>',
3490
+									className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>',
3491 3491
 								},
3492 3492
 								el(
3493 3493
 									'div',
@@ -3496,36 +3496,36 @@  discard block
 block discarded – undo
3496 3496
 									},
3497 3497
 
3498 3498
 					<?php
3499
-					if(false){?></script><?php }
3500
-				}elseif(!empty($args['row']['close'])){
3501
-					if(false){?><script><?php }?>
3499
+					if (false) {?></script><?php }
3500
+				}elseif (!empty($args['row']['close'])) {
3501
+					if (false) {?><script><?php }?>
3502 3502
 						el(
3503 3503
 							'div',
3504 3504
 							{
3505 3505
 								className: 'col pl-0 ps-0',
3506 3506
 							},
3507 3507
 					<?php
3508
-					if(false){?></script><?php }
3509
-				}else{
3510
-					if(false){?><script><?php }?>
3508
+					if (false) {?></script><?php }
3509
+				} else {
3510
+					if (false) {?><script><?php }?>
3511 3511
 						el(
3512 3512
 							'div',
3513 3513
 							{
3514 3514
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3515 3515
 							},
3516 3516
 					<?php
3517
-					if(false){?></script><?php }
3517
+					if (false) {?></script><?php }
3518 3518
 				}
3519 3519
 
3520 3520
 			}
3521 3521
 
3522 3522
 		}
3523 3523
 
3524
-		public function block_row_end($key, $args){
3524
+		public function block_row_end($key, $args) {
3525 3525
 
3526
-			if(!empty($args['row'])){
3526
+			if (!empty($args['row'])) {
3527 3527
 				// maybe close
3528
-				if(!empty($args['row']['close'])){
3528
+				if (!empty($args['row']['close'])) {
3529 3529
 					echo "))";
3530 3530
 				}
3531 3531
 
@@ -3533,14 +3533,14 @@  discard block
 block discarded – undo
3533 3533
 			}
3534 3534
 		}
3535 3535
 
3536
-		public function block_tab_start($key, $args){
3536
+		public function block_tab_start($key, $args) {
3537 3537
 
3538 3538
 			// check for row
3539
-			if(!empty($args['tab'])){
3539
+			if (!empty($args['tab'])) {
3540 3540
 
3541
-				if(!empty($args['tab']['tabs_open'])){
3541
+				if (!empty($args['tab']['tabs_open'])) {
3542 3542
 
3543
-					if(false){?><script><?php }?>
3543
+					if (false) {?><script><?php }?>
3544 3544
 
3545 3545
 el('div',{className: 'bsui'},
3546 3546
 
@@ -3549,52 +3549,52 @@  discard block
 block discarded – undo
3549 3549
 									{
3550 3550
 										activeClass: 'is-active',
3551 3551
 										className: 'btn-groupx',
3552
-										initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3552
+										initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3553 3553
 										tabs: [
3554 3554
 
3555 3555
 					<?php
3556
-					if(false){?></script><?php }
3556
+					if (false) {?></script><?php }
3557 3557
 				}
3558 3558
 
3559
-				if(!empty($args['tab']['open'])){
3559
+				if (!empty($args['tab']['open'])) {
3560 3560
 
3561
-					if(false){?><script><?php }?>
3561
+					if (false) {?><script><?php }?>
3562 3562
 							{
3563
-												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3564
-												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
3565
-												className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>',
3566
-												content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', {
3563
+												name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3564
+												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}),
3565
+												className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>',
3566
+												content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', {
3567 3567
 									className: 'components-base-control__help mb-0',
3568
-									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3568
+									dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'}
3569 3569
 								}),<?php }
3570
-					if(false){?></script><?php }
3570
+					if (false) {?></script><?php }
3571 3571
 				}
3572 3572
 
3573 3573
 			}
3574 3574
 
3575 3575
 		}
3576 3576
 
3577
-		public function block_tab_end($key, $args){
3577
+		public function block_tab_end($key, $args) {
3578 3578
 
3579
-			if(!empty($args['tab'])){
3579
+			if (!empty($args['tab'])) {
3580 3580
 				// maybe close
3581
-				if(!empty($args['tab']['close'])){
3581
+				if (!empty($args['tab']['close'])) {
3582 3582
 					echo ")}, /* tab close */";
3583 3583
 				}
3584 3584
 
3585
-				if(!empty($args['tab']['tabs_close'])){
3586
-					if(false){?><script><?php }?>
3585
+				if (!empty($args['tab']['tabs_close'])) {
3586
+					if (false) {?><script><?php }?>
3587 3587
 						]}, ( tab ) => {
3588 3588
 								return tab.content;
3589 3589
 							}
3590 3590
 						)), /* tabs close */
3591
-					<?php if(false){ ?></script><?php }
3591
+					<?php if (false) { ?></script><?php }
3592 3592
 				}
3593 3593
 			}
3594 3594
 		}
3595 3595
 
3596
-		public function build_block_arguments( $key, $args ) {
3597
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3596
+		public function build_block_arguments($key, $args) {
3597
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
3598 3598
 			$options           = '';
3599 3599
 			$extra             = '';
3600 3600
 			$require           = '';
@@ -3602,28 +3602,28 @@  discard block
 block discarded – undo
3602 3602
 			$after_elements	   = '';
3603 3603
 
3604 3604
 			// `content` is a protected and special argument
3605
-			if ( $key == 'content' ) {
3605
+			if ($key == 'content') {
3606 3606
 				return;
3607 3607
 			}
3608 3608
 
3609
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3609
+			$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3610
+			$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611 3611
 			$device_type_icon = '';
3612
-			if($device_type=='Desktop'){
3612
+			if ($device_type == 'Desktop') {
3613 3613
 				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
-			}elseif($device_type=='Tablet'){
3614
+			}elseif ($device_type == 'Tablet') {
3615 3615
 				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
-			}elseif($device_type=='Mobile'){
3616
+			}elseif ($device_type == 'Mobile') {
3617 3617
 				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618 3618
 			}
3619 3619
 
3620 3620
 			// icon
3621 3621
 			$icon = '';
3622
-			if( !empty( $args['icon'] ) ){
3622
+			if (!empty($args['icon'])) {
3623 3623
 				$icon .= "el('div', {";
3624
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3624
+									$icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},";
3625 3625
 									$icon .= "className: 'text-center',";
3626
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3626
+									$icon .= "title: '" . addslashes($args['title']) . "',";
3627 3627
 								$icon .= "}),";
3628 3628
 
3629 3629
 				// blank title as its added to the icon.
@@ -3631,27 +3631,27 @@  discard block
 block discarded – undo
3631 3631
 			}
3632 3632
 
3633 3633
 			// require advanced
3634
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3634
+			$require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : "";
3635 3635
 
3636 3636
 			// element require
3637
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3637
+			$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3638 3638
 
3639 3639
 
3640 3640
 			$onchange  = "props.setAttributes({ $key: $key } )";
3641
-			$onchangecomplete  = "";
3641
+			$onchangecomplete = "";
3642 3642
 			$value     = "props.attributes.$key";
3643
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
-			if ( in_array( $args['type'], $text_type ) ) {
3643
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range');
3644
+			if (in_array($args['type'], $text_type)) {
3645 3645
 				$type = 'TextControl';
3646 3646
 				// Save numbers as numbers and not strings
3647
-				if ( $args['type'] == 'number' ) {
3647
+				if ($args['type'] == 'number') {
3648 3648
 					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649 3649
 				}
3650 3650
 
3651
-				if (substr($key, 0, 9 ) === 'metadata_') {
3652
-					$real_key = str_replace('metadata_','', $key );
3651
+				if (substr($key, 0, 9) === 'metadata_') {
3652
+					$real_key = str_replace('metadata_', '', $key);
3653 3653
 					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3654
+					$value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655 3655
 				}
3656 3656
 			}
3657 3657
 //			else if ( $args['type'] == 'popup' ) {
@@ -3671,12 +3671,12 @@  discard block
 block discarded – undo
3671 3671
 //
3672 3672
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673 3673
 //			}
3674
-			else if ( $args['type'] == 'styleid' ) {
3674
+			else if ($args['type'] == 'styleid') {
3675 3675
 				$type = 'TextControl';
3676 3676
 				$args['type'] == 'text';
3677 3677
 				// Save numbers as numbers and not strings
3678
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
-			}else if ( $args['type'] == 'notice' ) {
3678
+				$value = "props.attributes.$key ? props.attributes.$key : ''";
3679
+			} else if ($args['type'] == 'notice') {
3680 3680
 
3681 3681
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682 3682
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3738,11 +3738,11 @@  discard block
 block discarded – undo
3738 3738
 							return;
3739 3739
 						}
3740 3740
 */
3741
-			elseif ( $args['type'] == 'color' ) {
3741
+			elseif ($args['type'] == 'color') {
3742 3742
 				$type = 'ColorPicker';
3743 3743
 				$onchange = "";
3744 3744
 				$extra = "color: $value,";
3745
-				if(!empty($args['disable_alpha'])){
3745
+				if (!empty($args['disable_alpha'])) {
3746 3746
 					$extra .= "disableAlpha: true,";
3747 3747
 				}
3748 3748
 				$onchangecomplete = "onChangeComplete: function($key) {
@@ -3751,7 +3751,7 @@  discard block
 block discarded – undo
3751 3751
 							$key: value
3752 3752
 						});
3753 3753
 					},";
3754
-			}elseif ( $args['type'] == 'gradient' ) {
3754
+			}elseif ($args['type'] == 'gradient') {
3755 3755
 				$type = 'GradientPicker';
3756 3756
 				$extra .= "gradients: [{
3757 3757
 			name: 'Vivid cyan blue to vivid purple',
@@ -3790,7 +3790,7 @@  discard block
 block discarded – undo
3790 3790
 			slug: 'cool-to-warm-spectrum',
3791 3791
 		}],";
3792 3792
 
3793
-			}elseif ( $args['type'] == 'image' ) {
3793
+			}elseif ($args['type'] == 'image') {
3794 3794
 //                print_r($args);
3795 3795
 
3796 3796
 				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3852,7 +3852,7 @@  discard block
 block discarded – undo
3852 3852
 				$onchange = "";
3853 3853
 
3854 3854
 				//$inside_elements = ",el('div',{},'file upload')";
3855
-			} else if ( $args['type'] == 'images' ) {
3855
+			} else if ($args['type'] == 'images') {
3856 3856
 				$img_preview = "props.attributes.$key && (function() {
3857 3857
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3858 3858
 	let images = [];
@@ -3865,7 +3865,7 @@  discard block
 block discarded – undo
3865 3865
 			el('i',{
3866 3866
 				className: 'fas fa-times-circle text-danger position-absolute  ml-n2 mt-n1 bg-white rounded-circle c-pointer',
3867 3867
 				onClick: function() {
3868
-					aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) {
3868
+					aui_confirm('" . esc_attr__('Are you sure?') . "', '" . esc_attr__('Delete') . "', '" . esc_attr__('Cancel') . "', true).then(function(confirmed) {
3869 3869
 						if (confirmed) {
3870 3870
 							let new_uploads = JSON.parse('['+props.attributes.$key+']');
3871 3871
 							new_uploads.splice(index, 1);
@@ -3928,36 +3928,36 @@  discard block
 block discarded – undo
3928 3928
 
3929 3929
 				//$inside_elements = ",el('div',{},'file upload')";
3930 3930
 			}
3931
-			elseif ( $args['type'] == 'checkbox' ) {
3931
+			elseif ($args['type'] == 'checkbox') {
3932 3932
 				$type = 'CheckboxControl';
3933 3933
 				$extra .= "checked: props.attributes.$key,";
3934 3934
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
-			} elseif ( $args['type'] == 'textarea' ) {
3935
+			} elseif ($args['type'] == 'textarea') {
3936 3936
 				$type = 'TextareaControl';
3937 3937
 
3938
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3938
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
3939 3939
 				$type = 'SelectControl';
3940 3940
 
3941
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
-				}else {
3941
+				if ($args['name'] == 'category' && !empty($args['post_type_linked'])) {
3942
+					$options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ",";
3943
+				}elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) {
3944
+					$options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ",";
3945
+				} else {
3946 3946
 
3947
-					if ( ! empty( $args['options'] ) ) {
3947
+					if (!empty($args['options'])) {
3948 3948
 						$options .= "options: [";
3949
-						foreach ( $args['options'] as $option_val => $option_label ) {
3950
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3949
+						foreach ($args['options'] as $option_val => $option_label) {
3950
+							$options .= "{ value: '" . esc_attr($option_val) . "', label: '" . esc_js(addslashes($option_label)) . "' },";
3951 3951
 						}
3952 3952
 						$options .= "],";
3953 3953
 					}
3954 3954
 				}
3955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3955
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956 3956
 					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957 3957
 				}
3958 3958
 
3959
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3959
+				if ($args['type'] == 'multiselect' || (isset($args['multiple']) && $args['multiple'])) {
3960
+					$after_elements .= "props.attributes.$key && el( wp.components.Button, {
3961 3961
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3962 3962
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3963 3963
 									  onClick: function(){
@@ -3969,7 +3969,7 @@  discard block
 block discarded – undo
3969 3969
 									'Clear'
3970 3970
 							),";
3971 3971
 				}
3972
-			} elseif ( $args['type'] == 'tagselect' ) {
3972
+			} elseif ($args['type'] == 'tagselect') {
3973 3973
 //				$type = 'FormTokenField';
3974 3974
 //
3975 3975
 //				if ( ! empty( $args['options'] ) ) {
@@ -4004,19 +4004,19 @@  discard block
 block discarded – undo
4004 4004
 //				$value     = "[]";
4005 4005
 //				$extra .= ' __experimentalExpandOnFocus: true,';
4006 4006
 
4007
-			} else if ( $args['type'] == 'alignment' ) {
4007
+			} else if ($args['type'] == 'alignment') {
4008 4008
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
-			} else if ( $args['type'] == 'margins' ) {
4009
+			} else if ($args['type'] == 'margins') {
4010 4010
 
4011
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4011
+			} else if ($args['type'] == 'visibility_conditions' && (function_exists('wp_is_block_theme') && wp_is_block_theme())) {
4012 4012
 				$type = 'TextControl';
4013 4013
 				$value = "(props.attributes.$key ? props.attributes.$key : '')";
4014 4014
 				$args['type'] = 'text';
4015 4015
 				$options .= 'disabled:true,';
4016
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
-				$bsvc_body = $this->block_visibility_fields( $args );
4016
+				$bsvc_title = esc_attr(addslashes($args['title']));
4017
+				$bsvc_body = $this->block_visibility_fields($args);
4018 4018
 				// @TODO reset button
4019
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
4019
+				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __('Reset', 'ayecode-connect') . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __('Close', 'ayecode-connect') . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __('Save Rules', 'ayecode-connect') . '</button>';
4020 4020
 				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4021 4021
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
4022 4022
 						onClick: function() {
@@ -4035,25 +4035,25 @@  discard block
 block discarded – undo
4035 4035
 									jQuery('.bs-vc-modal-form').trigger('change');
4036 4036
 								}
4037 4037
 							});
4038
-							aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
4038
+							aui_modal('" . $bsvc_title . "', '" . addslashes($bsvc_body) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
4039 4039
 							jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) {
4040 4040
 								props.setAttributes({" . $key . ": e.target.value});
4041 4041
 							});
4042 4042
 						}
4043 4043
 					},
4044
-					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4044
+					'" . addslashes(!empty($args['button_title']) ? $args['button_title'] : $args['title']) . "'
4045 4045
 				) ),";
4046 4046
 			} else {
4047
-				return;// if we have not implemented the control then don't break the JS.
4047
+				return; // if we have not implemented the control then don't break the JS.
4048 4048
 			}
4049 4049
 
4050 4050
 			// color input does not show the labels so we add them
4051
-			if($args['type']=='color'){
4051
+			if ($args['type'] == 'color') {
4052 4052
 				// add show only if advanced
4053 4053
 				echo $require_advanced;
4054 4054
 				// add setting require if defined
4055 4055
 				echo $element_require;
4056
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4056
+				echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),";
4057 4057
 			}
4058 4058
 
4059 4059
 			// add show only if advanced
@@ -4065,22 +4065,22 @@  discard block
 block discarded – undo
4065 4065
 			// icon
4066 4066
 			echo $icon;
4067 4067
 			?>
4068
-			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4069
-			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4070
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4071
-			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4068
+			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, {
4069
+			label: <?php if (empty($args['title'])) { echo "''"; } else if (empty($args['row']) && !empty($args['device_type'])) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}),<?php if ($device_type_icon) { ?>deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4070
+			} else { ?>'<?php echo addslashes(trim(esc_html($args['title']))); ?>'<?php } ?>,
4071
+			help: <?php echo (isset($args['desc']) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim(wp_kses_post(addslashes($args['desc']))) . "'}})" : "''"); ?>,
4072 4072
 			value: <?php echo $value; ?>,
4073
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4074
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4073
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
4074
+				echo "type: '" . addslashes($args['type']) . "',";
4075 4075
 			} ?>
4076
-			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4076
+			<?php if (!empty($args['placeholder'])) {
4077
+				echo "placeholder: '" . esc_js(addslashes(trim(esc_html($args['placeholder'])))) . "',";
4078 4078
 			} ?>
4079 4079
 			<?php echo $options; ?>
4080 4080
 			<?php echo $extra; ?>
4081 4081
 			<?php echo $custom_attributes; ?>
4082 4082
 			<?php echo $onchangecomplete; ?>
4083
-			<?php if ( $onchange ) { ?>
4083
+			<?php if ($onchange) { ?>
4084 4084
 			onChange: function ( <?php echo $key; ?> ) {
4085 4085
 				<?php echo $onchange; ?>
4086 4086
 			}
@@ -4099,15 +4099,15 @@  discard block
 block discarded – undo
4099 4099
 		 *@todo there is prob a faster way to do this, also we could add some validation here.
4100 4100
 		 *
4101 4101
 		 */
4102
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4102
+		public function array_to_attributes($custom_attributes, $html = false) {
4103 4103
 			$attributes = '';
4104
-			if ( ! empty( $custom_attributes ) ) {
4104
+			if (!empty($custom_attributes)) {
4105 4105
 
4106
-				foreach ( $custom_attributes as $key => $val ) {
4107
-					if(is_array($val)){
4108
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
-					}else{
4110
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4106
+				foreach ($custom_attributes as $key => $val) {
4107
+					if (is_array($val)) {
4108
+						$attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},';
4109
+					} else {
4110
+						$attributes .= $html ? " $key='$val' " : "'$key': '$val',";
4111 4111
 					}
4112 4112
 				}
4113 4113
 
@@ -4125,113 +4125,113 @@  discard block
 block discarded – undo
4125 4125
 		 *
4126 4126
 		 * @param $args
4127 4127
 		 */
4128
-		public function block_element( $args, $save = false ) {
4128
+		public function block_element($args, $save = false) {
4129 4129
 
4130 4130
 //            print_r($args);echo '###';exit;
4131 4131
 
4132
-			if ( ! empty( $args ) ) {
4133
-				foreach ( $args as $element => $new_args ) {
4132
+			if (!empty($args)) {
4133
+				foreach ($args as $element => $new_args) {
4134 4134
 
4135
-					if ( is_array( $new_args ) ) { // its an element
4135
+					if (is_array($new_args)) { // its an element
4136 4136
 
4137 4137
 
4138
-						if ( isset( $new_args['element'] ) ) {
4138
+						if (isset($new_args['element'])) {
4139 4139
 
4140
-							if ( isset( $new_args['element_require'] ) ) {
4141
-								echo str_replace( array(
4140
+							if (isset($new_args['element_require'])) {
4141
+								echo str_replace(array(
4142 4142
 										"'+",
4143 4143
 										"+'"
4144
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
-								unset( $new_args['element_require'] );
4144
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
4145
+								unset($new_args['element_require']);
4146 4146
 							}
4147 4147
 
4148
-							if($new_args['element']=='InnerBlocks'){
4148
+							if ($new_args['element'] == 'InnerBlocks') {
4149 4149
 								echo "\n el( InnerBlocks, {";
4150
-							}elseif($new_args['element']=='innerBlocksProps'){
4150
+							}elseif ($new_args['element'] == 'innerBlocksProps') {
4151 4151
 								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152 4152
 							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153 4153
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154 4154
 								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155 4155
 								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4156
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4157 4157
 
4158 4158
 								echo "} ), {";
4159
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4159
+								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : '';
4160 4160
 							//    echo '###';
4161 4161
 
4162 4162
 							  //  echo '###';
4163
-							}elseif($new_args['element']=='BlocksProps'){
4163
+							}elseif ($new_args['element'] == 'BlocksProps') {
4164 4164
 
4165
-								if ( isset($new_args['if_inner_element']) ) {
4165
+								if (isset($new_args['if_inner_element'])) {
4166 4166
 									$element = $new_args['if_inner_element'];
4167
-								}else {
4168
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4167
+								} else {
4168
+									$element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'";
4169 4169
 								}
4170 4170
 
4171 4171
 								unset($new_args['inner_element']);
4172 4172
 								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4173
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4174 4174
 
4175 4175
 
4176 4176
 							   // echo "} ),";
4177 4177
 
4178
-							}else{
4178
+							} else {
4179 4179
 								echo "\n el( '" . $new_args['element'] . "', {";
4180 4180
 							}
4181 4181
 
4182 4182
 
4183 4183
 							// get the attributes
4184
-							foreach ( $new_args as $new_key => $new_value ) {
4184
+							foreach ($new_args as $new_key => $new_value) {
4185 4185
 
4186 4186
 
4187
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4187
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
4188 4188
 									// do nothing
4189 4189
 								} else {
4190
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4190
+									echo $this->block_element(array($new_key => $new_value), $save);
4191 4191
 								}
4192 4192
 							}
4193 4193
 
4194
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4194
+							echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes
4195 4195
 
4196 4196
 							// get the content
4197 4197
 							$first_item = 0;
4198
-							foreach ( $new_args as $new_key => $new_value ) {
4199
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4198
+							foreach ($new_args as $new_key => $new_value) {
4199
+								if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) {
4200 4200
 
4201
-									if ( $new_key === 'content' ) {
4202
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
-									}else if ( $new_key === 'if_content' ) {
4204
-										echo  $this->block_props_replace(  $new_value  );
4201
+									if ($new_key === 'content') {
4202
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
4203
+									} else if ($new_key === 'if_content') {
4204
+										echo  $this->block_props_replace($new_value);
4205 4205
 									}
4206 4206
 
4207
-									if ( is_array( $new_value ) ) {
4207
+									if (is_array($new_value)) {
4208 4208
 
4209
-										if ( isset( $new_value['element_require'] ) ) {
4210
-											echo str_replace( array(
4209
+										if (isset($new_value['element_require'])) {
4210
+											echo str_replace(array(
4211 4211
 													"'+",
4212 4212
 													"+'"
4213
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
-											unset( $new_value['element_require'] );
4213
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
4214
+											unset($new_value['element_require']);
4215 4215
 										}
4216 4216
 
4217
-										if ( isset( $new_value['element_repeat'] ) ) {
4217
+										if (isset($new_value['element_repeat'])) {
4218 4218
 											$x = 1;
4219
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
-												$this->block_element( array( '' => $new_value ),$save );
4221
-												$x ++;
4219
+											while ($x <= absint($new_value['element_repeat'])) {
4220
+												$this->block_element(array('' => $new_value), $save);
4221
+												$x++;
4222 4222
 											}
4223 4223
 										} else {
4224
-											$this->block_element( array( '' => $new_value ),$save );
4224
+											$this->block_element(array('' => $new_value), $save);
4225 4225
 										}
4226 4226
 									}
4227
-									$first_item ++;
4227
+									$first_item++;
4228 4228
 								}
4229 4229
 							}
4230 4230
 
4231
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
-								echo "))";// end content
4233
-							}else{
4234
-								echo ")";// end content
4231
+							if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') {
4232
+								echo "))"; // end content
4233
+							} else {
4234
+								echo ")"; // end content
4235 4235
 							}
4236 4236
 
4237 4237
 
@@ -4240,26 +4240,26 @@  discard block
 block discarded – undo
4240 4240
 						}
4241 4241
 					} else {
4242 4242
 
4243
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4243
+						if (substr($element, 0, 3) === "if_") {
4244 4244
 							$extra = '';
4245
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4245
+							if (strpos($new_args, '[%WrapClass%]') !== false) {
4246
+								$new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args);
4247
+								$new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args);
4248 4248
 							}
4249
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4249
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
4250
+						} elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) {
4251
+							$new_args = str_replace('[%WrapStyle%]', '', $new_args);
4252
+							echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },";
4253 4253
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
-						} elseif ( $element == 'style' ) {
4255
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4258
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
-						} elseif ( $element == 'template' && $new_args ) {
4254
+						} elseif ($element == 'style') {
4255
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
4256
+						} elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) {
4257
+							$new_args = str_replace('[%WrapClass%]', '', $new_args);
4258
+							echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),";
4259
+						} elseif ($element == 'template' && $new_args) {
4260 4260
 							echo $element . ": $new_args,";
4261 4261
 						} else {
4262
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4262
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
4263 4263
 						}
4264 4264
 
4265 4265
 					}
@@ -4274,11 +4274,11 @@  discard block
 block discarded – undo
4274 4274
 		 *
4275 4275
 		 * @return mixed
4276 4276
 		 */
4277
-		public function block_props_replace( $string, $no_wrap = false ) {
4278
-			if ( $no_wrap ) {
4279
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4277
+		public function block_props_replace($string, $no_wrap = false) {
4278
+			if ($no_wrap) {
4279
+				$string = str_replace(array("[%", "%]", "%:checked]"), array("props.attributes.", "", ""), $string);
4280 4280
 			} else {
4281
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4281
+				$string = str_replace(array("![%", "[%", "%]", "%:checked]"), array("'+!props.attributes.", "'+props.attributes.", "+'", "+'"), $string);
4282 4282
 			}
4283 4283
 
4284 4284
 			return $string;
@@ -4290,65 +4290,65 @@  discard block
 block discarded – undo
4290 4290
 		 * @param array $args
4291 4291
 		 * @param array $instance
4292 4292
 		 */
4293
-		public function widget( $args, $instance ) {
4294
-			if ( ! is_array( $args ) ) {
4293
+		public function widget($args, $instance) {
4294
+			if (!is_array($args)) {
4295 4295
 				$args = array();
4296 4296
 			}
4297 4297
 
4298 4298
 			// Get the filtered values
4299
-			$argument_values = $this->argument_values( $instance );
4300
-			$argument_values = $this->string_to_bool( $argument_values );
4301
-			$output          = $this->output( $argument_values, $args );
4299
+			$argument_values = $this->argument_values($instance);
4300
+			$argument_values = $this->string_to_bool($argument_values);
4301
+			$output          = $this->output($argument_values, $args);
4302 4302
 
4303 4303
 			$no_wrap = false;
4304
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4304
+			if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) {
4305 4305
 				$no_wrap = true;
4306 4306
 			}
4307 4307
 
4308 4308
 			ob_start();
4309
-			if ( $output && ! $no_wrap ) {
4309
+			if ($output && !$no_wrap) {
4310 4310
 
4311 4311
 				$class_original = $this->options['widget_ops']['classname'];
4312
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4312
+				$class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash();
4313 4313
 
4314 4314
 				// Before widget
4315
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4315
+				$before_widget = !empty($args['before_widget']) ? $args['before_widget'] : '';
4316
+				$before_widget = $before_widget ? str_replace($class_original, $class, $before_widget) : $before_widget;
4317
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
4318
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
4319 4319
 
4320 4320
 				// After widget
4321
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4321
+				$after_widget = !empty($args['after_widget']) ? $args['after_widget'] : '';
4322
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
4323
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
4324 4324
 
4325 4325
 				echo $before_widget;
4326 4326
 				// elementor strips the widget wrapping div so we check for and add it back if needed
4327
-				if ( $this->is_elementor_widget_output() ) {
4327
+				if ($this->is_elementor_widget_output()) {
4328 4328
 					// Filter class & attrs for elementor widget output.
4329
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4329
+					$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
4330
+					$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
4331 4331
 
4332
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4332
+					$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
4333
+					$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
4334 4334
 
4335
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4335
+					echo "<span class='" . esc_attr($class) . "' " . $attrs . ">";
4336 4336
 				}
4337
-				echo $this->output_title( $args, $instance );
4337
+				echo $this->output_title($args, $instance);
4338 4338
 				echo $output;
4339
-				if ( $this->is_elementor_widget_output() ) {
4339
+				if ($this->is_elementor_widget_output()) {
4340 4340
 					echo "</span>";
4341 4341
 				}
4342 4342
 				echo $after_widget;
4343
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4343
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
4344
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
4345 4345
 				echo $output;
4346
-			} elseif ( $output && $no_wrap ) {
4346
+			} elseif ($output && $no_wrap) {
4347 4347
 				echo $output;
4348 4348
 			}
4349 4349
 			$output = ob_get_clean();
4350 4350
 
4351
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4351
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
4352 4352
 
4353 4353
 			echo $output;
4354 4354
 		}
@@ -4361,7 +4361,7 @@  discard block
 block discarded – undo
4361 4361
 		 */
4362 4362
 		public function is_elementor_widget_output() {
4363 4363
 			$result = false;
4364
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4364
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
4365 4365
 				$result = true;
4366 4366
 			}
4367 4367
 
@@ -4376,7 +4376,7 @@  discard block
 block discarded – undo
4376 4376
 		 */
4377 4377
 		public function is_elementor_preview() {
4378 4378
 			$result = false;
4379
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4379
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
4380 4380
 				$result = true;
4381 4381
 			}
4382 4382
 
@@ -4391,7 +4391,7 @@  discard block
 block discarded – undo
4391 4391
 		 */
4392 4392
 		public function is_divi_preview() {
4393 4393
 			$result = false;
4394
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4394
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
4395 4395
 				$result = true;
4396 4396
 			}
4397 4397
 
@@ -4406,7 +4406,7 @@  discard block
 block discarded – undo
4406 4406
 		 */
4407 4407
 		public function is_beaver_preview() {
4408 4408
 			$result = false;
4409
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4409
+			if (isset($_REQUEST['fl_builder'])) {
4410 4410
 				$result = true;
4411 4411
 			}
4412 4412
 
@@ -4421,7 +4421,7 @@  discard block
 block discarded – undo
4421 4421
 		 */
4422 4422
 		public function is_siteorigin_preview() {
4423 4423
 			$result = false;
4424
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4424
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
4425 4425
 				$result = true;
4426 4426
 			}
4427 4427
 
@@ -4436,7 +4436,7 @@  discard block
 block discarded – undo
4436 4436
 		 */
4437 4437
 		public function is_cornerstone_preview() {
4438 4438
 			$result = false;
4439
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4439
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
4440 4440
 				$result = true;
4441 4441
 			}
4442 4442
 
@@ -4451,7 +4451,7 @@  discard block
 block discarded – undo
4451 4451
 		 */
4452 4452
 		public function is_fusion_preview() {
4453 4453
 			$result = false;
4454
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4454
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
4455 4455
 				$result = true;
4456 4456
 			}
4457 4457
 
@@ -4466,7 +4466,7 @@  discard block
 block discarded – undo
4466 4466
 		 */
4467 4467
 		public function is_oxygen_preview() {
4468 4468
 			$result = false;
4469
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4469
+			if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) {
4470 4470
 				$result = true;
4471 4471
 			}
4472 4472
 
@@ -4483,7 +4483,7 @@  discard block
 block discarded – undo
4483 4483
 		public function is_kallyas_zion_preview() {
4484 4484
 			$result = false;
4485 4485
 
4486
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4486
+			if (function_exists('znhg_kallyas_theme_config') && !empty($_REQUEST['zn_pb_edit'])) {
4487 4487
 				$result = true;
4488 4488
 			}
4489 4489
 
@@ -4500,7 +4500,7 @@  discard block
 block discarded – undo
4500 4500
 		public function is_bricks_preview() {
4501 4501
 			$result = false;
4502 4502
 
4503
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4503
+			if (function_exists('bricks_is_builder') && (bricks_is_builder() || bricks_is_builder_call())) {
4504 4504
 				$result = true;
4505 4505
 			}
4506 4506
 
@@ -4515,25 +4515,25 @@  discard block
 block discarded – undo
4515 4515
 		 */
4516 4516
 		public function is_preview() {
4517 4517
 			$preview = false;
4518
-			if ( $this->is_divi_preview() ) {
4518
+			if ($this->is_divi_preview()) {
4519 4519
 				$preview = true;
4520
-			} elseif ( $this->is_elementor_preview() ) {
4520
+			} elseif ($this->is_elementor_preview()) {
4521 4521
 				$preview = true;
4522
-			} elseif ( $this->is_beaver_preview() ) {
4522
+			} elseif ($this->is_beaver_preview()) {
4523 4523
 				$preview = true;
4524
-			} elseif ( $this->is_siteorigin_preview() ) {
4524
+			} elseif ($this->is_siteorigin_preview()) {
4525 4525
 				$preview = true;
4526
-			} elseif ( $this->is_cornerstone_preview() ) {
4526
+			} elseif ($this->is_cornerstone_preview()) {
4527 4527
 				$preview = true;
4528
-			} elseif ( $this->is_fusion_preview() ) {
4528
+			} elseif ($this->is_fusion_preview()) {
4529 4529
 				$preview = true;
4530
-			} elseif ( $this->is_oxygen_preview() ) {
4530
+			} elseif ($this->is_oxygen_preview()) {
4531 4531
 				$preview = true;
4532
-			} elseif( $this->is_kallyas_zion_preview() ) {
4532
+			} elseif ($this->is_kallyas_zion_preview()) {
4533 4533
 				$preview = true;
4534
-			} elseif( $this->is_block_content_call() ) {
4534
+			} elseif ($this->is_block_content_call()) {
4535 4535
 				$preview = true;
4536
-			} elseif( $this->is_bricks_preview() ) {
4536
+			} elseif ($this->is_bricks_preview()) {
4537 4537
 				$preview = true;
4538 4538
 			}
4539 4539
 
@@ -4548,44 +4548,44 @@  discard block
 block discarded – undo
4548 4548
 		 *
4549 4549
 		 * @return string
4550 4550
 		 */
4551
-		public function output_title( $args, $instance = array() ) {
4551
+		public function output_title($args, $instance = array()) {
4552 4552
 			$output = '';
4553
-			if ( ! empty( $instance['title'] ) ) {
4553
+			if (!empty($instance['title'])) {
4554 4554
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4555
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
4556 4556
 
4557
-				if ( empty( $instance['widget_title_tag'] ) ) {
4558
-					if ( ! isset( $args['before_title'] ) ) {
4557
+				if (empty($instance['widget_title_tag'])) {
4558
+					if (!isset($args['before_title'])) {
4559 4559
 						$args['before_title'] = '';
4560 4560
 					}
4561 4561
 
4562
-					if ( ! isset( $args['after_title'] ) ) {
4562
+					if (!isset($args['after_title'])) {
4563 4563
 						$args['after_title'] = '';
4564 4564
 					}
4565 4565
 
4566 4566
 					$output = $args['before_title'] . $title . $args['after_title'];
4567 4567
 				} else {
4568
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4569
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4568
+					$tag 			= esc_attr($instance['widget_title_tag']);
4569
+					$allowed_tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p');
4570
+					$title_tag = in_array($tag, $allowed_tags, true) ? esc_attr($tag) : 'h2';
4571 4571
 
4572 4572
 					// classes
4573 4573
 					$title_classes = array();
4574
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
-
4588
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4574
+					$title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : '';
4575
+					$title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : '';
4576
+					$title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : '';
4577
+					$title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : '';
4578
+					$title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : '';
4579
+					$title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : '';
4580
+					$title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : '';
4581
+					$title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : '';
4582
+					$title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : '';
4583
+					$title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : '';
4584
+					$title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : '';
4585
+					$title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : '';
4586
+					$title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : '';
4587
+
4588
+					$class = !empty($title_classes) ? implode(" ", $title_classes) : '';
4589 4589
 					$output = "<$title_tag class='$class' >$title</$title_tag>";
4590 4590
 				}
4591 4591
 
@@ -4599,7 +4599,7 @@  discard block
 block discarded – undo
4599 4599
 		 *
4600 4600
 		 * @param array $instance The widget options.
4601 4601
 		 */
4602
-		public function form( $instance ) {
4602
+		public function form($instance) {
4603 4603
 
4604 4604
 			// set widget instance
4605 4605
 			$this->instance = $instance;
@@ -4607,20 +4607,20 @@  discard block
 block discarded – undo
4607 4607
 			// set it as a SD widget
4608 4608
 			echo $this->widget_advanced_toggle();
4609 4609
 
4610
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4610
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
4611 4611
 			$arguments_raw = $this->get_arguments();
4612 4612
 
4613
-			if ( is_array( $arguments_raw ) ) {
4613
+			if (is_array($arguments_raw)) {
4614 4614
 
4615
-				$arguments = $this->group_arguments( $arguments_raw );
4615
+				$arguments = $this->group_arguments($arguments_raw);
4616 4616
 
4617 4617
 				// Do we have sections?
4618 4618
 				$has_sections = $arguments == $arguments_raw ? false : true;
4619 4619
 
4620 4620
 
4621
-				if ( $has_sections ) {
4621
+				if ($has_sections) {
4622 4622
 					$panel_count = 0;
4623
-					foreach ( $arguments as $key => $args ) {
4623
+					foreach ($arguments as $key => $args) {
4624 4624
 
4625 4625
 						?>
4626 4626
 						<script>
@@ -4630,26 +4630,26 @@  discard block
 block discarded – undo
4630 4630
 
4631 4631
 						$hide       = $panel_count ? ' style="display:none;" ' : '';
4632 4632
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4633
+						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
4635 4635
 
4636
-						foreach ( $args as $k => $a ) {
4636
+						foreach ($args as $k => $a) {
4637 4637
 
4638 4638
 							$this->widget_inputs_row_start($k, $a);
4639
-							$this->widget_inputs( $a, $instance );
4639
+							$this->widget_inputs($a, $instance);
4640 4640
 							$this->widget_inputs_row_end($k, $a);
4641 4641
 
4642 4642
 						}
4643 4643
 
4644 4644
 						echo "</div>";
4645 4645
 
4646
-						$panel_count ++;
4646
+						$panel_count++;
4647 4647
 
4648 4648
 					}
4649 4649
 				} else {
4650
-					foreach ( $arguments as $key => $args ) {
4650
+					foreach ($arguments as $key => $args) {
4651 4651
 						$this->widget_inputs_row_start($key, $args);
4652
-						$this->widget_inputs( $args, $instance );
4652
+						$this->widget_inputs($args, $instance);
4653 4653
 						$this->widget_inputs_row_end($key, $args);
4654 4654
 					}
4655 4655
 				}
@@ -4657,28 +4657,28 @@  discard block
 block discarded – undo
4657 4657
 			}
4658 4658
 		}
4659 4659
 
4660
-		public function widget_inputs_row_start( $key, $args ) {
4661
-			if ( ! empty( $args['row'] ) ) {
4660
+		public function widget_inputs_row_start($key, $args) {
4661
+			if (!empty($args['row'])) {
4662 4662
 				// Maybe open
4663
-				if ( ! empty( $args['row']['open'] ) ) {
4663
+				if (!empty($args['row']['open'])) {
4664 4664
 					?>
4665
-					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4666
-					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4665
+					<div class='bsui sd-argument' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php echo (!empty($args['row']['element_require']) ? $this->convert_element_require($args['row']['element_require']) : ''); ?>'>
4666
+					<?php if (!empty($args['row']['title'])) { ?>
4667 4667
 					<?php
4668
-						if ( isset( $args['row']['icon'] ) ) {
4668
+						if (isset($args['row']['icon'])) {
4669 4669
 							$args['row']['icon'] = '';
4670 4670
 						}
4671 4671
 
4672
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4672
+						if (!isset($args['row']['device_type']) && isset($args['device_type'])) {
4673 4673
 							$args['row']['device_type'] = $args['device_type'];
4674 4674
 						}
4675 4675
 					?>
4676
-					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4676
+					<label class="mb-0"><?php echo $this->widget_field_title($args['row']); ?><?php echo $this->widget_field_desc($args['row']); ?></label>
4677 4677
 					<?php } ?>
4678
-					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4678
+					<div class='row<?php echo (!empty($args['row']['class']) ? ' ' . esc_attr($args['row']['class']) : ''); ?>'>
4679 4679
 					<div class='col pr-2'>
4680 4680
 					<?php
4681
-				} else if ( ! empty( $args['row']['close'] ) ) {
4681
+				} else if (!empty($args['row']['close'])) {
4682 4682
 					echo "<div class='col pl-0 ps-0'>";
4683 4683
 				} else {
4684 4684
 					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
@@ -4686,10 +4686,10 @@  discard block
 block discarded – undo
4686 4686
 			}
4687 4687
 		}
4688 4688
 
4689
-		public function widget_inputs_row_end( $key, $args ) {
4690
-			if ( ! empty( $args['row'] ) ) {
4689
+		public function widget_inputs_row_end($key, $args) {
4690
+			if (!empty($args['row'])) {
4691 4691
 				// Maybe close
4692
-				if ( ! empty( $args['row']['close'] ) ) {
4692
+				if (!empty($args['row']['close'])) {
4693 4693
 					echo "</div></div>";
4694 4694
 				}
4695 4695
 				echo "</div>";
@@ -4704,7 +4704,7 @@  discard block
 block discarded – undo
4704 4704
 		public function widget_advanced_toggle() {
4705 4705
 
4706 4706
 			$output = '';
4707
-			if ( $this->block_show_advanced() ) {
4707
+			if ($this->block_show_advanced()) {
4708 4708
 				$val = 1;
4709 4709
 			} else {
4710 4710
 				$val = 0;
@@ -4724,14 +4724,14 @@  discard block
 block discarded – undo
4724 4724
 		 *@since 1.0.0
4725 4725
 		 *
4726 4726
 		 */
4727
-		public function convert_element_require( $input ) {
4728
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4727
+		public function convert_element_require($input) {
4728
+			$input = str_replace("'", '"', $input); // we only want double quotes
4729 4729
 
4730
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4730
+			$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
4731 4731
 				"jQuery(form).find('[data-argument=\"",
4732 4732
 				"\"]').find('input,select,textarea').val()",
4733 4733
 				"\"]').find('input:checked').val()"
4734
-			), $input ) );
4734
+			), $input));
4735 4735
 
4736 4736
 			return $output;
4737 4737
 		}
@@ -4742,48 +4742,48 @@  discard block
 block discarded – undo
4742 4742
 		 * @param $args
4743 4743
 		 * @param $instance
4744 4744
 		 */
4745
-		public function widget_inputs( $args, $instance ) {
4745
+		public function widget_inputs($args, $instance) {
4746 4746
 
4747 4747
 			$class             = "";
4748 4748
 			$element_require   = "";
4749 4749
 			$custom_attributes = "";
4750 4750
 
4751 4751
 			// get value
4752
-			if ( isset( $instance[ $args['name'] ] ) ) {
4753
-				$value = $instance[ $args['name'] ];
4754
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4752
+			if (isset($instance[$args['name']])) {
4753
+				$value = $instance[$args['name']];
4754
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
4755
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
4756 4756
 			} else {
4757 4757
 				$value = '';
4758 4758
 			}
4759 4759
 
4760 4760
 			// get placeholder
4761
-			if ( ! empty( $args['placeholder'] ) ) {
4762
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4761
+			if (!empty($args['placeholder'])) {
4762
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
4763 4763
 			} else {
4764 4764
 				$placeholder = '';
4765 4765
 			}
4766 4766
 
4767 4767
 			// get if advanced
4768
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4768
+			if (isset($args['advanced']) && $args['advanced']) {
4769 4769
 				$class .= " sd-advanced-setting ";
4770 4770
 			}
4771 4771
 
4772 4772
 			// element_require
4773
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4773
+			if (isset($args['element_require']) && $args['element_require']) {
4774 4774
 				$element_require = $args['element_require'];
4775 4775
 			}
4776 4776
 
4777 4777
 			// custom_attributes
4778
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4778
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
4779
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
4780 4780
 			}
4781 4781
 
4782 4782
 			// before wrapper
4783 4783
 			?>
4784
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4784
+			<p class="sd-argument <?php echo esc_attr($class); ?>" data-argument='<?php echo esc_attr($args['name']); ?>' data-element_require='<?php if ($element_require) { echo $this->convert_element_require($element_require); } ?>'>
4785 4785
 			<?php
4786
-			switch ( $args['type'] ) {
4786
+			switch ($args['type']) {
4787 4787
 				//array('text','password','number','email','tel','url','color')
4788 4788
 				case "text":
4789 4789
 				case "password":
@@ -4793,33 +4793,33 @@  discard block
 block discarded – undo
4793 4793
 				case "url":
4794 4794
 				case "color":
4795 4795
 					?>
4796
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4797
-					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>">
4796
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4797
+					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="<?php echo esc_attr($args['type']); ?>" value="<?php echo esc_attr($value); ?>">
4798 4798
 					<?php
4799 4799
 
4800 4800
 					break;
4801 4801
 				case "select":
4802
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4803
-					if ( $multiple ) {
4804
-						if ( empty( $value ) ) {
4802
+					$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
4803
+					if ($multiple) {
4804
+						if (empty($value)) {
4805 4805
 							$value = array();
4806 4806
 						}
4807 4807
 					}
4808 4808
 					?>
4809
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4810
-					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>"
4811
-						<?php if ( $multiple ) {
4809
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4810
+					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); if ($multiple) { echo "[]"; } ?>"
4811
+						<?php if ($multiple) {
4812 4812
 							echo "multiple";
4813 4813
 						} //@todo not implemented yet due to gutenberg not supporting it
4814 4814
 						?>>
4815 4815
 						<?php
4816 4816
 
4817
-						if ( ! empty( $args['options'] ) ) {
4818
-							foreach ( $args['options'] as $val => $label ) {
4819
-								if ( $multiple ) {
4820
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4817
+						if (!empty($args['options'])) {
4818
+							foreach ($args['options'] as $val => $label) {
4819
+								if ($multiple) {
4820
+									$selected = in_array($val, $value) ? 'selected="selected"' : '';
4821 4821
 								} else {
4822
-									$selected = selected( $value, $val, false );
4822
+									$selected = selected($value, $val, false);
4823 4823
 								}
4824 4824
 								echo "<option value='$val' " . $selected . ">$label</option>";
4825 4825
 							}
@@ -4830,20 +4830,20 @@  discard block
 block discarded – undo
4830 4830
 					break;
4831 4831
 				case "checkbox":
4832 4832
 					?>
4833
-					<input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1">
4834
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4833
+					<input <?php echo $placeholder; ?> <?php checked(1, $value, true) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" value="1">
4834
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4835 4835
 					<?php
4836 4836
 					break;
4837 4837
 				case "textarea":
4838 4838
 					?>
4839
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4840
-					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea>
4839
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4840
+					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"><?php echo esc_attr($value); ?></textarea>
4841 4841
 					<?php
4842 4842
 
4843 4843
 					break;
4844 4844
 				case "hidden":
4845 4845
 					?>
4846
-					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>">
4846
+					<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" value="<?php echo esc_attr($value); ?>">
4847 4847
 					<?php
4848 4848
 					break;
4849 4849
 				default:
@@ -4853,15 +4853,15 @@  discard block
 block discarded – undo
4853 4853
 			?></p><?php
4854 4854
 		}
4855 4855
 
4856
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4857
-			if($icon=='box-top'){
4858
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4859
-			}elseif($icon=='box-right'){
4860
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4861
-			}elseif($icon=='box-bottom'){
4862
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4863
-			}elseif($icon=='box-left'){
4864
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4856
+		public function get_widget_icon($icon = 'box-top', $title = '') {
4857
+			if ($icon == 'box-top') {
4858
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4859
+			}elseif ($icon == 'box-right') {
4860
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4861
+			}elseif ($icon == 'box-bottom') {
4862
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4863
+			}elseif ($icon == 'box-left') {
4864
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4865 4865
 			}
4866 4866
 		}
4867 4867
 
@@ -4873,14 +4873,14 @@  discard block
 block discarded – undo
4873 4873
 		 * @return string
4874 4874
 		 * @todo, need to make its own tooltip script
4875 4875
 		 */
4876
-		public function widget_field_desc( $args ) {
4876
+		public function widget_field_desc($args) {
4877 4877
 
4878 4878
 			$description = '';
4879
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4880
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4881
-					$description = $this->desc_tip( $args['desc'] );
4879
+			if (isset($args['desc']) && $args['desc']) {
4880
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
4881
+					$description = $this->desc_tip($args['desc']);
4882 4882
 				} else {
4883
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4883
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
4884 4884
 				}
4885 4885
 			}
4886 4886
 
@@ -4894,18 +4894,18 @@  discard block
 block discarded – undo
4894 4894
 		 *
4895 4895
 		 * @return string
4896 4896
 		 */
4897
-		public function widget_field_title( $args ) {
4897
+		public function widget_field_title($args) {
4898 4898
 			$title = '';
4899 4899
 
4900
-			if ( isset( $args['title'] ) && $args['title'] ) {
4901
-				if ( ! empty( $args['device_type'] ) ) {
4900
+			if (isset($args['title']) && $args['title']) {
4901
+				if (!empty($args['device_type'])) {
4902 4902
 					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4903 4903
 				}
4904 4904
 
4905
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4906
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4905
+				if (isset($args['icon']) && $args['icon']) {
4906
+					$title = self::get_widget_icon($args['icon'], $args['title']);
4907 4907
 				} else {
4908
-					$title = esc_attr( $args['title'] );
4908
+					$title = esc_attr($args['title']);
4909 4909
 				}
4910 4910
 			}
4911 4911
 
@@ -4920,11 +4920,11 @@  discard block
 block discarded – undo
4920 4920
 		 *
4921 4921
 		 * @return string
4922 4922
 		 */
4923
-		function desc_tip( $tip, $allow_html = false ) {
4924
-			if ( $allow_html ) {
4925
-				$tip = $this->sanitize_tooltip( $tip );
4923
+		function desc_tip($tip, $allow_html = false) {
4924
+			if ($allow_html) {
4925
+				$tip = $this->sanitize_tooltip($tip);
4926 4926
 			} else {
4927
-				$tip = esc_attr( $tip );
4927
+				$tip = esc_attr($tip);
4928 4928
 			}
4929 4929
 
4930 4930
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -4937,8 +4937,8 @@  discard block
 block discarded – undo
4937 4937
 		 *
4938 4938
 		 * @return string
4939 4939
 		 */
4940
-		public function sanitize_tooltip( $var ) {
4941
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4940
+		public function sanitize_tooltip($var) {
4941
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
4942 4942
 				'br'     => array(),
4943 4943
 				'em'     => array(),
4944 4944
 				'strong' => array(),
@@ -4948,7 +4948,7 @@  discard block
 block discarded – undo
4948 4948
 				'li'     => array(),
4949 4949
 				'ol'     => array(),
4950 4950
 				'p'      => array(),
4951
-			) ) );
4951
+			)));
4952 4952
 		}
4953 4953
 
4954 4954
 		/**
@@ -4960,23 +4960,23 @@  discard block
 block discarded – undo
4960 4960
 		 * @return array
4961 4961
 		 * @todo we should add some sanitation here.
4962 4962
 		 */
4963
-		public function update( $new_instance, $old_instance ) {
4963
+		public function update($new_instance, $old_instance) {
4964 4964
 
4965 4965
 			//save the widget
4966
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4966
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
4967 4967
 
4968 4968
 			// set widget instance
4969 4969
 			$this->instance = $instance;
4970 4970
 
4971
-			if ( empty( $this->arguments ) ) {
4971
+			if (empty($this->arguments)) {
4972 4972
 				$this->get_arguments();
4973 4973
 			}
4974 4974
 
4975 4975
 			// check for checkboxes
4976
-			if ( ! empty( $this->arguments ) ) {
4977
-				foreach ( $this->arguments as $argument ) {
4978
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4979
-						$instance[ $argument['name'] ] = '0';
4976
+			if (!empty($this->arguments)) {
4977
+				foreach ($this->arguments as $argument) {
4978
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
4979
+						$instance[$argument['name']] = '0';
4980 4980
 					}
4981 4981
 				}
4982 4982
 			}
@@ -4994,7 +4994,7 @@  discard block
 block discarded – undo
4994 4994
 		 */
4995 4995
 		public function is_block_content_call() {
4996 4996
 			$result = false;
4997
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4997
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
4998 4998
 				$result = true;
4999 4999
 			}
5000 5000
 
@@ -5007,9 +5007,9 @@  discard block
 block discarded – undo
5007 5007
 		 * @return string
5008 5008
 		 *@since 1.0.20
5009 5009
 		 */
5010
-		public function get_instance_hash(){
5011
-			$instance_string = $this->base_id.serialize($this->instance);
5012
-			return hash('crc32b',$instance_string);
5010
+		public function get_instance_hash() {
5011
+			$instance_string = $this->base_id . serialize($this->instance);
5012
+			return hash('crc32b', $instance_string);
5013 5013
 		}
5014 5014
 
5015 5015
 		/**
@@ -5020,14 +5020,14 @@  discard block
 block discarded – undo
5020 5020
 		 * @return string
5021 5021
 		 *@since 1.0.20
5022 5022
 		 */
5023
-		public function get_instance_style($rules = array()){
5023
+		public function get_instance_style($rules = array()) {
5024 5024
 			$css = '';
5025 5025
 
5026
-			if(!empty($rules)){
5026
+			if (!empty($rules)) {
5027 5027
 				$rules = array_unique($rules);
5028 5028
 				$instance_hash = $this->get_instance_hash();
5029 5029
 				$css .= "<style>";
5030
-				foreach($rules as $rule){
5030
+				foreach ($rules as $rule) {
5031 5031
 					$css .= ".sdel-$instance_hash $rule";
5032 5032
 				}
5033 5033
 				$css .= "</style>";
@@ -5045,9 +5045,9 @@  discard block
 block discarded – undo
5045 5045
 		 *@since 1.0.28
5046 5046
 		 *
5047 5047
 		 */
5048
-		public function encode_shortcodes( $content ) {
5048
+		public function encode_shortcodes($content) {
5049 5049
 			// Avoids existing encoded tags.
5050
-			$trans   = array(
5050
+			$trans = array(
5051 5051
 				'&#91;' => '&#091;',
5052 5052
 				'&#93;' => '&#093;',
5053 5053
 				'&amp;#91;' => '&#091;',
@@ -5058,7 +5058,7 @@  discard block
 block discarded – undo
5058 5058
 				'&amp;gt;' => '&0gt;',
5059 5059
 			);
5060 5060
 
5061
-			$content = strtr( $content, $trans );
5061
+			$content = strtr($content, $trans);
5062 5062
 
5063 5063
 			$trans   = array(
5064 5064
 				'[' => '&#91;',
@@ -5069,7 +5069,7 @@  discard block
 block discarded – undo
5069 5069
 				"'" => '&#39;',
5070 5070
 			);
5071 5071
 
5072
-			$content = strtr( $content, $trans );
5072
+			$content = strtr($content, $trans);
5073 5073
 
5074 5074
 			return $content;
5075 5075
 		}
@@ -5083,8 +5083,8 @@  discard block
 block discarded – undo
5083 5083
 		 *@since 1.0.28
5084 5084
 		 *
5085 5085
 		 */
5086
-		public function decode_shortcodes( $content ) {
5087
-			$trans   = array(
5086
+		public function decode_shortcodes($content) {
5087
+			$trans = array(
5088 5088
 				'&#91;' => '[',
5089 5089
 				'&#93;' => ']',
5090 5090
 				'&amp;#91;' => '[',
@@ -5097,7 +5097,7 @@  discard block
 block discarded – undo
5097 5097
 				'&apos;' => "'",
5098 5098
 			);
5099 5099
 
5100
-			$content = strtr( $content, $trans );
5100
+			$content = strtr($content, $trans);
5101 5101
 
5102 5102
 			$trans   = array(
5103 5103
 				'&#091;' => '&#91;',
@@ -5110,31 +5110,31 @@  discard block
 block discarded – undo
5110 5110
 				'&amp;0gt;' => '&gt;',
5111 5111
 			);
5112 5112
 
5113
-			$content = strtr( $content, $trans );
5113
+			$content = strtr($content, $trans);
5114 5114
 
5115 5115
 			return $content;
5116 5116
 		}
5117 5117
 
5118
-		public function block_visibility_fields( $args ) {
5119
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5118
+		public function block_visibility_fields($args) {
5119
+			$value = !empty($args['value']) ? esc_attr($args['value']) : '';
5120 5120
 			$content = '<div class="bs-vc-rule-template d-none">';
5121 5121
 				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5122 5122
 					$content .= '<div class="row">';
5123 5123
 						$content .= '<div class="col-sm-12">';
5124
-							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5124
+							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__('Remove Rule', 'ayecode-connect') . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5125 5125
 							$content .= aui()->select(
5126 5126
 								array(
5127 5127
 									'id'          => 'bsvc_rule_BSVCINDEX',
5128 5128
 									'name'        => 'bsvc_rule_BSVCINDEX',
5129
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5130
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5129
+									'label'       => __('Rule', 'ayecode-connect'),
5130
+									'placeholder' => __('Select Rule...', 'ayecode-connect'),
5131 5131
 									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5132 5132
 									'options'     => sd_visibility_rules_options(),
5133 5133
 									'default'     => '',
5134 5134
 									'value'       => '',
5135 5135
 									'label_type'  => '',
5136 5136
 									'select2'     => false,
5137
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5137
+									'input_group_left' => __('Rule:', 'ayecode-connect'),
5138 5138
 									'extra_attributes' => array(
5139 5139
 										'data-minimum-results-for-search' => '-1'
5140 5140
 									)
@@ -5143,15 +5143,15 @@  discard block
 block discarded – undo
5143 5143
 
5144 5144
 						$content .= '</div>';
5145 5145
 
5146
-						if ( class_exists( 'GeoDirectory' ) ) {
5146
+						if (class_exists('GeoDirectory')) {
5147 5147
 							$content .= '<div class="col-md-7 col-sm-12">';
5148 5148
 
5149 5149
 								$content .= aui()->select(
5150 5150
 									array(
5151 5151
 										'id'          => 'bsvc_gd_field_BSVCINDEX',
5152 5152
 										'name'        => 'bsvc_gd_field_BSVCINDEX',
5153
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5154
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5153
+										'label'       => __('FIELD', 'ayecode-connect'),
5154
+										'placeholder' => __('FIELD', 'ayecode-connect'),
5155 5155
 										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5156 5156
 										'options'     => sd_visibility_gd_field_options(),
5157 5157
 										'default'     => '',
@@ -5172,8 +5172,8 @@  discard block
 block discarded – undo
5172 5172
 									array(
5173 5173
 										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5174 5174
 										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5175
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5176
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5175
+										'label'       => __('CONDITION', 'ayecode-connect'),
5176
+										'placeholder' => __('CONDITION', 'ayecode-connect'),
5177 5177
 										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5178 5178
 										'options'     => sd_visibility_field_condition_options(),
5179 5179
 										'default'     => '',
@@ -5195,9 +5195,9 @@  discard block
 block discarded – undo
5195 5195
 										'type'            => 'text',
5196 5196
 										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5197 5197
 										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5198
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5198
+										'label'           => __('VALUE TO MATCH', 'ayecode-connect'),
5199 5199
 										'class'           => 'bsvc_gd_field_search form-control-sm',
5200
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5200
+										'placeholder'     => __('VALUE TO MATCH', 'ayecode-connect'),
5201 5201
 										'label_type'      => '',
5202 5202
 										'value'           => '',
5203 5203
 										'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
@@ -5207,15 +5207,15 @@  discard block
 block discarded – undo
5207 5207
 							$content .= '</div>';
5208 5208
 						}
5209 5209
 
5210
-                        $content .= apply_filters( 'sd_block_visibility_fields', '', $args );
5210
+                        $content .= apply_filters('sd_block_visibility_fields', '', $args);
5211 5211
 
5212 5212
 					$content .= '</div>';
5213 5213
 
5214
-					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5214
+					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __('Select User Roles:', 'ayecode-connect') . '</label>';
5215 5215
 						$role_options = sd_user_roles_options();
5216 5216
 
5217 5217
 						$role_option_i = 0;
5218
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5218
+						foreach ($role_options as $role_option_key => $role_option_name) {
5219 5219
 							$role_option_i++;
5220 5220
 
5221 5221
 							$content .= '<div class="col-sm-6">';
@@ -5235,19 +5235,19 @@  discard block
 block discarded – undo
5235 5235
 							$content .= '</div>';
5236 5236
 						}
5237 5237
 					$content .= '</div>';
5238
-					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__( 'AND', 'ayecode-connect' ) . '</div></div>';
5238
+					$content .= '<div class="bs-vc-sep-wrap text-center position-absolute top-0 mt-n3"><div class="bs-vc-sep-cond d-inline-block badge text-dark bg-gray mt-1">' . esc_html__('AND', 'ayecode-connect') . '</div></div>';
5239 5239
 				$content .= '</div>';
5240 5240
 			$content .= '</div>';
5241 5241
 			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5242 5242
 			$content .= '<div class="bs-vc-rule-sets"></div>';
5243
-			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5243
+			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __('Add Rule', 'ayecode-connect') . '</button></div></div>';
5244 5244
 			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5245 5245
 			$content .= aui()->select(
5246 5246
 				array(
5247 5247
 					'id'          => 'bsvc_output',
5248 5248
 					'name'        => 'bsvc_output',
5249
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5250
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5249
+					'label'       => __('What should happen if rules met.', 'ayecode-connect'),
5250
+					'placeholder' => __('Show Block', 'ayecode-connect'),
5251 5251
 					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5252 5252
 					'options'     => sd_visibility_output_options(),
5253 5253
 					'default'     => '',
@@ -5266,8 +5266,8 @@  discard block
 block discarded – undo
5266 5266
 				array(
5267 5267
 					'id'              => 'bsvc_page',
5268 5268
 					'name'            => 'bsvc_page',
5269
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5270
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5269
+					'label'           => __('Page Content', 'ayecode-connect'),
5270
+					'placeholder'     => __('Select Page ID...', 'ayecode-connect'),
5271 5271
 					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5272 5272
 					'options'         => sd_template_page_options(),
5273 5273
 					'default'         => '',
@@ -5282,8 +5282,8 @@  discard block
 block discarded – undo
5282 5282
 				array(
5283 5283
 					'id'          => 'bsvc_tmpl_part',
5284 5284
 					'name'        => 'bsvc_tmpl_part',
5285
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5286
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5285
+					'label'       => __('Template Part', 'ayecode-connect'),
5286
+					'placeholder' => __('Select Template Part...', 'ayecode-connect'),
5287 5287
 					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5288 5288
 					'options'     => sd_template_part_options(),
5289 5289
 					'default'     => '',
@@ -5301,8 +5301,8 @@  discard block
 block discarded – undo
5301 5301
 				array(
5302 5302
 					'id'               => 'bsvc_message_type',
5303 5303
 					'name'             => 'bsvc_message_type',
5304
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5305
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5304
+					'label'            => __('Custom Message Type', 'ayecode-connect'),
5305
+					'placeholder'      => __('Default (none)', 'ayecode-connect'),
5306 5306
 					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5307 5307
 					'options'          => sd_aui_colors(),
5308 5308
 					'default'          => '',
@@ -5325,7 +5325,7 @@  discard block
 block discarded – undo
5325 5325
 					'name'            => 'bsvc_message',
5326 5326
 					'label'           => '',
5327 5327
 					'class'           => 'bsvc_message form-control-sm mb-3',
5328
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5328
+					'placeholder'     => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'),
5329 5329
 					'label_type'      => '',
5330 5330
 					'value'           => '',
5331 5331
 					'form_group_class' => ' ',
@@ -5338,8 +5338,8 @@  discard block
 block discarded – undo
5338 5338
 				array(
5339 5339
 					'id'          => 'bsvc_output_n',
5340 5340
 					'name'        => 'bsvc_output_n',
5341
-					'label'       => __( 'What should happen if rules NOT met.', 'ayecode-connect' ),
5342
-					'placeholder' => __( 'Show Block', 'ayecode-connect' ),
5341
+					'label'       => __('What should happen if rules NOT met.', 'ayecode-connect'),
5342
+					'placeholder' => __('Show Block', 'ayecode-connect'),
5343 5343
 					'class'       => 'bsvc_output_n form-select-sm no-select2 mw-100',
5344 5344
 					'options'     => sd_visibility_output_options(),
5345 5345
 					'default'     => '',
@@ -5358,8 +5358,8 @@  discard block
 block discarded – undo
5358 5358
 				array(
5359 5359
 					'id'              => 'bsvc_page_n',
5360 5360
 					'name'            => 'bsvc_page_n',
5361
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5362
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5361
+					'label'           => __('Page Content', 'ayecode-connect'),
5362
+					'placeholder'     => __('Select Page ID...', 'ayecode-connect'),
5363 5363
 					'class'           => 'bsvc_page_n form-select-sm no-select2 mw-100',
5364 5364
 					'options'         => sd_template_page_options(),
5365 5365
 					'default'         => '',
@@ -5374,8 +5374,8 @@  discard block
 block discarded – undo
5374 5374
 				array(
5375 5375
 					'id'          => 'bsvc_tmpl_part_n',
5376 5376
 					'name'        => 'bsvc_tmpl_part_n',
5377
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5378
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5377
+					'label'       => __('Template Part', 'ayecode-connect'),
5378
+					'placeholder' => __('Select Template Part...', 'ayecode-connect'),
5379 5379
 					'class'       => 'bsvc_tmpl_part_n form-select-sm no-select2 mw-100',
5380 5380
 					'options'     => sd_template_part_options(),
5381 5381
 					'default'     => '',
@@ -5393,8 +5393,8 @@  discard block
 block discarded – undo
5393 5393
 				array(
5394 5394
 					'id'               => 'bsvc_message_type_n',
5395 5395
 					'name'             => 'bsvc_message_type_n',
5396
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5397
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5396
+					'label'            => __('Custom Message Type', 'ayecode-connect'),
5397
+					'placeholder'      => __('Default (none)', 'ayecode-connect'),
5398 5398
 					'class'            => 'bsvc_message_type_n form-select-sm no-select2 mw-100',
5399 5399
 					'options'          => sd_aui_colors(),
5400 5400
 					'default'          => '',
@@ -5417,7 +5417,7 @@  discard block
 block discarded – undo
5417 5417
 					'name'            => 'bsvc_message_n',
5418 5418
 					'label'           => '',
5419 5419
 					'class'           => 'bsvc_message_n form-control-sm',
5420
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5420
+					'placeholder'     => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'),
5421 5421
 					'label_type'      => '',
5422 5422
 					'value'           => '',
5423 5423
 					'form_group_class' => ' ',
@@ -5439,7 +5439,7 @@  discard block
 block discarded – undo
5439 5439
 			global $shortcode_insert_button_once;
5440 5440
 
5441 5441
 			// Fix conflicts with UpSolution Core in header template edit element.
5442
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5442
+			if (defined('US_CORE_DIR') && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html') {
5443 5443
 				$shortcode_insert_button_once = true;
5444 5444
 			}
5445 5445
 		}
Please login to merge, or discard this patch.
Switch Indentation   +2015 added lines, -2015 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1
-<?php
2
-if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
1
+    <?php
2
+    if ( ! defined( 'ABSPATH' ) ) {
3
+	    exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+    if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.2.17' );
8
+	    define( 'SUPER_DUPER_VER', '1.2.17' );
9 9
 
10
-	/**
10
+	    /**
11 11
 	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12 12
 	 *
13 13
 	 * Should not be called direct but extended instead.
@@ -16,298 +16,298 @@  discard block
 block discarded – undo
16 16
 	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17 17
 	 * @ver 1.1.1
18 18
 	 */
19
-	class WP_Super_Duper extends WP_Widget {
20
-
21
-		public $version = SUPER_DUPER_VER;
22
-		public $font_awesome_icon_version = "5.11.2";
23
-		public $block_code;
24
-		public $options;
25
-		public $base_id;
26
-		public $settings_hash;
27
-		public $arguments = array();
28
-		public $instance = array();
29
-		private $class_name;
30
-
31
-		/**
19
+	    class WP_Super_Duper extends WP_Widget {
20
+
21
+		    public $version = SUPER_DUPER_VER;
22
+		    public $font_awesome_icon_version = "5.11.2";
23
+		    public $block_code;
24
+		    public $options;
25
+		    public $base_id;
26
+		    public $settings_hash;
27
+		    public $arguments = array();
28
+		    public $instance = array();
29
+		    private $class_name;
30
+
31
+		    /**
32 32
 		 * The relative url to the current folder.
33 33
 		 *
34 34
 		 * @var string
35 35
 		 */
36
-		public $url = '';
36
+		    public $url = '';
37 37
 
38
-		/**
38
+		    /**
39 39
 		 * Take the array options and use them to build.
40 40
 		 */
41
-		public function __construct( $options ) {
42
-			global $sd_widgets;
43
-
44
-			$sd_widgets[ $options['base_id'] ] = array(
45
-				'name'       => $options['name'],
46
-				'class_name' => $options['class_name'],
47
-				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
-			);
49
-			$this->base_id                     = $options['base_id'];
50
-			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
54
-			$this->options = $options;
55
-
56
-			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
-
59
-			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
-					unset($this->options['output_types'][$key]);
65
-				}
66
-			}
67
-
68
-			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
-			}
72
-
73
-
74
-			if ( isset( $options['class_name'] ) ) {
75
-				// register widget
76
-				$this->class_name = $options['class_name'];
77
-
78
-				// register shortcode, this needs to be done even for blocks and widgets
79
-				$this->register_shortcode();
80
-
81
-
82
-				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
85
-				}
86
-
87
-                // maybe load the Bricks transformer class
88
-                if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
90
-                }
91
-
92
-				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
-				}
96
-			}
97
-
98
-			// add the CSS and JS we need ONCE
99
-			global $sd_widget_scripts;
100
-
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
105
-
106
-				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
108
-
109
-				$sd_widget_scripts = true;
110
-
111
-				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
-				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
-				}
118
-				/* Load script on Divi theme builder page */
119
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
-					add_thickbox();
121
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
-				}
123
-
124
-				if ( $this->is_preview() ) {
125
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
-					// this makes the insert button work for elementor
127
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
128
-						$this,
129
-						'shortcode_insert_button_script'
130
-					) ); // for elementor
131
-				}
132
-				// this makes the insert button work for cornerstone
133
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
134
-
135
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
137
-
138
-				// add generator text to head
139
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
-			}
142
-
143
-			do_action( 'wp_super_duper_widget_init', $options, $this );
144
-		}
145
-
146
-        /**
41
+		    public function __construct( $options ) {
42
+			    global $sd_widgets;
43
+
44
+			    $sd_widgets[ $options['base_id'] ] = array(
45
+				    'name'       => $options['name'],
46
+				    'class_name' => $options['class_name'],
47
+				    'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
+			    );
49
+			    $this->base_id                     = $options['base_id'];
50
+			    // lets filter the options before we do anything
51
+			    $options       = apply_filters( "wp_super_duper_options", $options );
52
+			    $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
+			    $options       = $this->add_name_from_key( $options );
54
+			    $this->options = $options;
55
+
56
+			    $this->base_id   = $options['base_id'];
57
+			    $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
+
59
+			    // nested blocks can't work as a widget
60
+			    if(!empty($this->options['nested-block'])){
61
+				    if(empty($this->options['output_types'])){
62
+					    $this->options['output_types'] = array('shortcode','block');
63
+				    }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
+					    unset($this->options['output_types'][$key]);
65
+				    }
66
+			    }
67
+
68
+			    // init parent
69
+			    if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
+				    parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
+			    }
72
+
73
+
74
+			    if ( isset( $options['class_name'] ) ) {
75
+				    // register widget
76
+				    $this->class_name = $options['class_name'];
77
+
78
+				    // register shortcode, this needs to be done even for blocks and widgets
79
+				    $this->register_shortcode();
80
+
81
+
82
+				    // Fusion Builder (avada) support
83
+				    if ( function_exists( 'fusion_builder_map' ) ) {
84
+					    add_action( 'init', array( $this, 'register_fusion_element' ) );
85
+				    }
86
+
87
+                    // maybe load the Bricks transformer class
88
+                    if( class_exists('\Bricks\Elements', false) ){
89
+					    add_action( 'init', array( $this, 'load_bricks_element_class' ) );
90
+                    }
91
+
92
+				    // register block
93
+				    if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
+					    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
+				    }
96
+			    }
97
+
98
+			    // add the CSS and JS we need ONCE
99
+			    global $sd_widget_scripts;
100
+
101
+			    if ( ! $sd_widget_scripts ) {
102
+				    wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
+				    wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
+				    wp_add_inline_style( 'widgets', $this->widget_css() );
105
+
106
+				    // maybe add elementor editor styles
107
+				    add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
108
+
109
+				    $sd_widget_scripts = true;
110
+
111
+				    // add shortcode insert button once
112
+				    add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
+				    add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
+				    // generatepress theme sections compatibility
115
+				    if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
+					    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
+				    }
118
+				    /* Load script on Divi theme builder page */
119
+				    if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
+					    add_thickbox();
121
+					    add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
+				    }
123
+
124
+				    if ( $this->is_preview() ) {
125
+					    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
+					    // this makes the insert button work for elementor
127
+					    add_action( 'elementor/editor/after_enqueue_scripts', array(
128
+						    $this,
129
+						    'shortcode_insert_button_script'
130
+					    ) ); // for elementor
131
+				    }
132
+				    // this makes the insert button work for cornerstone
133
+				    add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
134
+
135
+				    add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
+				    add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
137
+
138
+				    // add generator text to head
139
+				    add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
+				    add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
+			    }
142
+
143
+			    do_action( 'wp_super_duper_widget_init', $options, $this );
144
+		    }
145
+
146
+            /**
147 147
          * Load the Bricks conversion class if we are running Bricks.
148 148
          * @return void
149 149
          */
150
-        public function load_bricks_element_class() {
151
-                    include_once __DIR__ . '/includes/class-super-duper-bricks-element.php';
152
-        }
150
+            public function load_bricks_element_class() {
151
+                        include_once __DIR__ . '/includes/class-super-duper-bricks-element.php';
152
+            }
153 153
 
154
-		/**
154
+		    /**
155 155
 		 * The register widget function
156 156
 		 * @return void
157 157
 		 */
158
-		public function _register() {
159
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
-				parent::_register();
161
-			}
162
-		}
158
+		    public function _register() {
159
+			    if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
+				    parent::_register();
161
+			    }
162
+		    }
163 163
 
164
-		/**
164
+		    /**
165 165
 		 * Add our widget CSS to elementor editor.
166 166
 		 */
167
-		public function elementor_editor_styles() {
168
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
-		}
170
-
171
-		public function register_fusion_element() {
172
-
173
-			$options = $this->options;
174
-
175
-			if ( $this->base_id ) {
176
-
177
-				$params = $this->get_fusion_params();
178
-
179
-				$args = array(
180
-					'name'            => $options['name'],
181
-					'shortcode'       => $this->base_id,
182
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
-					'allow_generator' => true,
184
-				);
185
-
186
-				if ( ! empty( $params ) ) {
187
-					$args['params'] = $params;
188
-				}
189
-
190
-				fusion_builder_map( $args );
191
-			}
192
-
193
-		}
194
-
195
-		public function get_fusion_params() {
196
-			$params    = array();
197
-			$arguments = $this->get_arguments();
198
-
199
-			if ( ! empty( $arguments ) ) {
200
-				foreach ( $arguments as $key => $val ) {
201
-					$param = array();
202
-					// type
203
-					$param['type'] = str_replace(
204
-						array(
205
-							"text",
206
-							"number",
207
-							"email",
208
-							"color",
209
-							"checkbox"
210
-						),
211
-						array(
212
-							"textfield",
213
-							"textfield",
214
-							"textfield",
215
-							"colorpicker",
216
-							"select",
217
-
218
-						),
219
-						$val['type'] );
220
-
221
-					// multiselect
222
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
-						$param['type']     = 'multiple_select';
224
-						$param['multiple'] = true;
225
-					}
226
-
227
-					// heading
228
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
229
-
230
-					// description
231
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
232
-
233
-					// param_name
234
-					$param['param_name'] = $key;
235
-
236
-					// Default
237
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
238
-
239
-					// Group
240
-					if ( isset( $val['group'] ) ) {
241
-						$param['group'] = $val['group'];
242
-					}
243
-
244
-					// value
245
-					if ( $val['type'] == 'checkbox' ) {
246
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
-							unset( $param['default'] );
248
-						}
249
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
-					} else {
253
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
-					}
255
-
256
-					// setup the param
257
-					$params[] = $param;
258
-
259
-				}
260
-			}
261
-
262
-
263
-			return $params;
264
-		}
265
-
266
-		/**
167
+		    public function elementor_editor_styles() {
168
+			    wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
+		    }
170
+
171
+		    public function register_fusion_element() {
172
+
173
+			    $options = $this->options;
174
+
175
+			    if ( $this->base_id ) {
176
+
177
+				    $params = $this->get_fusion_params();
178
+
179
+				    $args = array(
180
+					    'name'            => $options['name'],
181
+					    'shortcode'       => $this->base_id,
182
+					    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
+					    'allow_generator' => true,
184
+				    );
185
+
186
+				    if ( ! empty( $params ) ) {
187
+					    $args['params'] = $params;
188
+				    }
189
+
190
+				    fusion_builder_map( $args );
191
+			    }
192
+
193
+		    }
194
+
195
+		    public function get_fusion_params() {
196
+			    $params    = array();
197
+			    $arguments = $this->get_arguments();
198
+
199
+			    if ( ! empty( $arguments ) ) {
200
+				    foreach ( $arguments as $key => $val ) {
201
+					    $param = array();
202
+					    // type
203
+					    $param['type'] = str_replace(
204
+						    array(
205
+							    "text",
206
+							    "number",
207
+							    "email",
208
+							    "color",
209
+							    "checkbox"
210
+						    ),
211
+						    array(
212
+							    "textfield",
213
+							    "textfield",
214
+							    "textfield",
215
+							    "colorpicker",
216
+							    "select",
217
+
218
+						    ),
219
+						    $val['type'] );
220
+
221
+					    // multiselect
222
+					    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
+						    $param['type']     = 'multiple_select';
224
+						    $param['multiple'] = true;
225
+					    }
226
+
227
+					    // heading
228
+					    $param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
229
+
230
+					    // description
231
+					    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
232
+
233
+					    // param_name
234
+					    $param['param_name'] = $key;
235
+
236
+					    // Default
237
+					    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
238
+
239
+					    // Group
240
+					    if ( isset( $val['group'] ) ) {
241
+						    $param['group'] = $val['group'];
242
+					    }
243
+
244
+					    // value
245
+					    if ( $val['type'] == 'checkbox' ) {
246
+						    if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
+							    unset( $param['default'] );
248
+						    }
249
+						    $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
+					    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
+						    $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
+					    } else {
253
+						    $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
+					    }
255
+
256
+					    // setup the param
257
+					    $params[] = $param;
258
+
259
+				    }
260
+			    }
261
+
262
+
263
+			    return $params;
264
+		    }
265
+
266
+		    /**
267 267
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268 268
 		 */
269
-		public static function maybe_cornerstone_builder() {
270
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
-				self::shortcode_insert_button_script();
272
-			}
273
-		}
269
+		    public static function maybe_cornerstone_builder() {
270
+			    if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
+				    self::shortcode_insert_button_script();
272
+			    }
273
+		    }
274 274
 
275
-		/**
275
+		    /**
276 276
 		 * A function to ge the shortcode builder picker html.
277 277
 		 *
278 278
 		 * @param string $editor_id
279 279
 		 *
280 280
 		 * @return string
281 281
 		 */
282
-		public static function get_picker( $editor_id = '' ) {
282
+		    public static function get_picker( $editor_id = '' ) {
283 283
 
284
-			ob_start();
285
-			if ( isset( $_POST['editor_id'] ) ) {
286
-				$editor_id = esc_attr( $_POST['editor_id'] );
287
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
-				$editor_id = 'main_content_content_vb_tiny_mce';
289
-			}
284
+			    ob_start();
285
+			    if ( isset( $_POST['editor_id'] ) ) {
286
+				    $editor_id = esc_attr( $_POST['editor_id'] );
287
+			    } elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
+				    $editor_id = 'main_content_content_vb_tiny_mce';
289
+			    }
290 290
 
291
-			global $sd_widgets;
291
+			    global $sd_widgets;
292 292
 
293
-//			print_r($sd_widgets);exit;
294
-			?>
293
+    //			print_r($sd_widgets);exit;
294
+			    ?>
295 295
 
296 296
 			<div class="sd-shortcode-left-wrap">
297 297
 				<?php
298
-				ksort( $sd_widgets );
299
-				//				print_r($sd_widgets);exit;
300
-				if ( ! empty( $sd_widgets ) ) {
301
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
-					foreach ( $sd_widgets as $shortcode => $class ) {
304
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
-					}
307
-					echo "</select>";
308
-
309
-				}
310
-				?>
298
+				    ksort( $sd_widgets );
299
+				    //				print_r($sd_widgets);exit;
300
+				    if ( ! empty( $sd_widgets ) ) {
301
+					    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
+					    echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
+					    foreach ( $sd_widgets as $shortcode => $class ) {
304
+						    if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
+						    echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
+					    }
307
+					    echo "</select>";
308
+
309
+				    }
310
+				    ?>
311 311
 				<div class="sd-shortcode-settings"></div>
312 312
 
313 313
 			</div>
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 					<?php if ( $editor_id != '' ) { ?>
319 319
 						<button class="button sd-insert-shortcode-button"
320 320
 								onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
321
-									echo "'" . $editor_id . "'";
322
-								} ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
321
+									    echo "'" . $editor_id . "'";
322
+								    } ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
323 323
 					<?php } ?>
324 324
 					<button class="button"
325 325
 							onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -327,94 +327,94 @@  discard block
 block discarded – undo
327 327
 			</div>
328 328
 			<?php
329 329
 
330
-			$html = ob_get_clean();
330
+			    $html = ob_get_clean();
331 331
 
332
-			if ( wp_doing_ajax() ) {
333
-				echo $html;
334
-				$should_die = true;
332
+			    if ( wp_doing_ajax() ) {
333
+				    echo $html;
334
+				    $should_die = true;
335 335
 
336
-				// some builder get the editor via ajax so we should not die on those occasions
337
-				$dont_die = array(
338
-					'parent_tag',// WP Bakery
339
-					'avia_request' // enfold
340
-				);
336
+				    // some builder get the editor via ajax so we should not die on those occasions
337
+				    $dont_die = array(
338
+					    'parent_tag',// WP Bakery
339
+					    'avia_request' // enfold
340
+				    );
341 341
 
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
344
-						$should_die = false;
345
-					}
346
-				}
342
+				    foreach ( $dont_die as $request ) {
343
+					    if ( isset( $_REQUEST[ $request ] ) ) {
344
+						    $should_die = false;
345
+					    }
346
+				    }
347 347
 
348
-				if ( $should_die ) {
349
-					wp_die();
350
-				}
348
+				    if ( $should_die ) {
349
+					    wp_die();
350
+				    }
351 351
 
352
-			} else {
353
-				return $html;
354
-			}
352
+			    } else {
353
+				    return $html;
354
+			    }
355 355
 
356
-			return '';
356
+			    return '';
357 357
 
358
-		}
358
+		    }
359 359
 
360
-		/**
360
+		    /**
361 361
 		 * Output the version in the header.
362 362
 		 */
363
-		public function generator() {
364
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
-
367
-			// Find source plugin/theme of SD
368
-			$source = array();
369
-			if ( strpos( $file, $plugins_dir ) !== false ) {
370
-				$source = explode( "/", plugin_basename( $file ) );
371
-			} else if ( function_exists( 'get_theme_root' ) ) {
372
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
-
374
-				if ( strpos( $file, $themes_dir ) !== false ) {
375
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
-				}
377
-			}
378
-
379
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
-		}
381
-
382
-		/**
363
+		    public function generator() {
364
+			    $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
+			    $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
+
367
+			    // Find source plugin/theme of SD
368
+			    $source = array();
369
+			    if ( strpos( $file, $plugins_dir ) !== false ) {
370
+				    $source = explode( "/", plugin_basename( $file ) );
371
+			    } else if ( function_exists( 'get_theme_root' ) ) {
372
+				    $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
+
374
+				    if ( strpos( $file, $themes_dir ) !== false ) {
375
+					    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
+				    }
377
+			    }
378
+
379
+			    echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
+		    }
381
+
382
+		    /**
383 383
 		 * Get widget settings.
384 384
 		 *
385 385
 		 * @since 1.0.0
386 386
 		 */
387
-		public static function get_widget_settings() {
388
-			global $sd_widgets;
389
-
390
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
-			if ( ! $shortcode ) {
392
-				wp_die();
393
-			}
394
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
-			if ( ! $widget_args ) {
396
-				wp_die();
397
-			}
398
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
-			if ( ! $class_name ) {
400
-				wp_die();
401
-			}
402
-
403
-			// invoke an instance method
404
-			$widget = new $class_name;
405
-
406
-			ob_start();
407
-			$widget->form( array() );
408
-			$form = ob_get_clean();
409
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
-			echo "<style>" . $widget->widget_css() . "</style>";
411
-			echo "<script>" . $widget->widget_js() . "</script>";
412
-			?>
413
-			<?php
414
-			wp_die();
415
-		}
416
-
417
-		/**
387
+		    public static function get_widget_settings() {
388
+			    global $sd_widgets;
389
+
390
+			    $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
+			    if ( ! $shortcode ) {
392
+				    wp_die();
393
+			    }
394
+			    $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
+			    if ( ! $widget_args ) {
396
+				    wp_die();
397
+			    }
398
+			    $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
+			    if ( ! $class_name ) {
400
+				    wp_die();
401
+			    }
402
+
403
+			    // invoke an instance method
404
+			    $widget = new $class_name;
405
+
406
+			    ob_start();
407
+			    $widget->form( array() );
408
+			    $form = ob_get_clean();
409
+			    echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
+			    echo "<style>" . $widget->widget_css() . "</style>";
411
+			    echo "<script>" . $widget->widget_js() . "</script>";
412
+			    ?>
413
+    			<?php
414
+			    wp_die();
415
+		    }
416
+
417
+		    /**
418 418
 		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
419 419
 		 *
420 420
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
@@ -423,39 +423,39 @@  discard block
 block discarded – undo
423 423
 		 *@since 1.0.0
424 424
 		 *
425 425
 		 */
426
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
-			global $sd_widgets, $shortcode_insert_button_once;
428
-			if ( $shortcode_insert_button_once ) {
429
-				return;
430
-			}
431
-			add_thickbox();
426
+		    public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
+			    global $sd_widgets, $shortcode_insert_button_once;
428
+			    if ( $shortcode_insert_button_once ) {
429
+				    return;
430
+			    }
431
+			    add_thickbox();
432 432
 
433 433
 
434
-			/**
434
+			    /**
435 435
 			 * Cornerstone makes us play dirty tricks :/
436 436
 			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437 437
 			 */
438
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
-				echo '<span id="insert-media-button">';
440
-			}
438
+			    if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
+				    echo '<span id="insert-media-button">';
440
+			    }
441 441
 
442
-			echo self::shortcode_button( 'this', 'true' );
442
+			    echo self::shortcode_button( 'this', 'true' );
443 443
 
444
-			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
-				echo '</span>'; // end #insert-media-button
447
-			}
444
+			    // see opening note
445
+			    if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
+				    echo '</span>'; // end #insert-media-button
447
+			    }
448 448
 
449
-			// Add separate script for generatepress theme sections
450
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
-			} else {
452
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
-			}
449
+			    // Add separate script for generatepress theme sections
450
+			    if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
+			    } else {
452
+				    self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
+			    }
454 454
 
455
-			$shortcode_insert_button_once = true;
456
-		}
455
+			    $shortcode_insert_button_once = true;
456
+		    }
457 457
 
458
-		/**
458
+		    /**
459 459
 		 * Gets the shortcode insert button html.
460 460
 		 *
461 461
 		 * @param string $id
@@ -463,14 +463,14 @@  discard block
 block discarded – undo
463 463
 		 *
464 464
 		 * @return mixed
465 465
 		 */
466
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
-			ob_start();
468
-			?>
466
+		    public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
+			    ob_start();
468
+			    ?>
469 469
 			<span class="sd-lable-shortcode-inserter">
470 470
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
471
-				if ( $search_for_id ) {
472
-					echo "," . $search_for_id;
473
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
471
+				    if ( $search_for_id ) {
472
+					    echo "," . $search_for_id;
473
+				    } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
474 474
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
475 475
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
476 476
 						  class="dashicons dashicons-screenoptions"></span>
@@ -481,21 +481,21 @@  discard block
 block discarded – undo
481 481
 			</span>
482 482
 
483 483
 			<?php
484
-			$html = ob_get_clean();
484
+			    $html = ob_get_clean();
485 485
 
486
-			// remove line breaks so we can use it in js
487
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
488
-		}
486
+			    // remove line breaks so we can use it in js
487
+			    return preg_replace( "/\r|\n/", "", trim( $html ) );
488
+		    }
489 489
 
490
-		/**
490
+		    /**
491 491
 		 * Makes SD work with the siteOrigin page builder.
492 492
 		 *
493 493
 		 * @return mixed
494 494
 		 *@since 1.0.6
495 495
 		 */
496
-		public static function siteorigin_js() {
497
-			ob_start();
498
-			?>
496
+		    public static function siteorigin_js() {
497
+			    ob_start();
498
+			    ?>
499 499
 			<script>
500 500
 				/**
501 501
 				 * Check a form to see what items should be shown or hidden.
@@ -571,19 +571,19 @@  discard block
 block discarded – undo
571 571
 				});
572 572
 			</script>
573 573
 			<?php
574
-			$output = ob_get_clean();
574
+			    $output = ob_get_clean();
575 575
 
576
-			/*
576
+			    /*
577 577
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
578 578
 			 */
579 579
 
580
-			return str_replace( array(
581
-				'<script>',
582
-				'</script>'
583
-			), '', $output );
584
-		}
580
+			    return str_replace( array(
581
+				    '<script>',
582
+				    '</script>'
583
+			    ), '', $output );
584
+		    }
585 585
 
586
-		/**
586
+		    /**
587 587
 		 * Output the JS and CSS for the shortcode insert button.
588 588
 		 *
589 589
 		 * @param string $editor_id
@@ -592,8 +592,8 @@  discard block
 block discarded – undo
592 592
 		 *@since 1.0.6
593 593
 		 *
594 594
 		 */
595
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
-			?>
595
+		    public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
+			    ?>
597 597
 			<style>
598 598
 				.sd-shortcode-left-wrap {
599 599
 					float: left;
@@ -716,40 +716,40 @@  discard block
 block discarded – undo
716 716
 					display: inline;
717 717
 				}
718 718
 				<?php } ?>
719
-				<?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?>
720
-				body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999}
719
+    				<?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?>
720
+    				body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999}
721 721
 				<?php } ?>
722
-			</style>
722
+    			</style>
723 723
 			<?php
724
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
-				echo "<script>" . self::siteorigin_js() . "</script>";
726
-			}
727
-			?>
728
-			<script>
724
+			    if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
+				    echo "<script>" . self::siteorigin_js() . "</script>";
726
+			    }
727
+			    ?>
728
+    			<script>
729 729
 				<?php
730
-				if(! empty( $insert_shortcode_function )){
731
-					echo $insert_shortcode_function;
732
-				}else{
730
+				    if(! empty( $insert_shortcode_function )){
731
+					    echo $insert_shortcode_function;
732
+				    }else{
733 733
 
734
-				/**
734
+				    /**
735 735
 				 * Function for super duper insert shortcode.
736 736
 				 *
737 737
 				 * @since 1.0.0
738 738
 				 */
739
-				?>
739
+				    ?>
740 740
 				function sd_insert_shortcode($editor_id) {
741 741
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
742 742
 					if ($shortcode) {
743 743
 						if (!$editor_id) {
744 744
 							<?php
745
-							if ( isset( $_REQUEST['et_fb'] ) ) {
746
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
-							} else {
750
-								echo '$editor_id = "#wp-content-editor-container textarea";';
751
-							}
752
-							?>
745
+							    if ( isset( $_REQUEST['et_fb'] ) ) {
746
+								    echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
+							    } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
+								    echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
+							    } else {
750
+								    echo '$editor_id = "#wp-content-editor-container textarea";';
751
+							    }
752
+							    ?>
753 753
 						} else {
754 754
 							$editor_id = '#' + $editor_id;
755 755
 						}
@@ -1063,19 +1063,19 @@  discard block
 block discarded – undo
1063 1063
 				}
1064 1064
 			</script>
1065 1065
 			<?php
1066
-		}
1066
+		    }
1067 1067
 
1068
-		/**
1068
+		    /**
1069 1069
 		 * Gets some CSS for the widgets screen.
1070 1070
 		 *
1071 1071
 		 * @param bool $advanced If we should include advanced CSS.
1072 1072
 		 *
1073 1073
 		 * @return mixed
1074 1074
 		 */
1075
-		public function widget_css( $advanced = true ) {
1076
-			ob_start();
1077
-			?>
1078
-			<style>
1075
+		    public function widget_css( $advanced = true ) {
1076
+			    ob_start();
1077
+			    ?>
1078
+    			<style>
1079 1079
 				<?php if( $advanced ){ ?>
1080 1080
 				.sd-advanced-setting {
1081 1081
 					display: none;
@@ -1114,26 +1114,26 @@  discard block
 block discarded – undo
1114 1114
 				.elementor-control .sd-argument select[multiple] option{padding:3px}
1115 1115
 			</style>
1116 1116
 			<?php
1117
-			$output = ob_get_clean();
1117
+			    $output = ob_get_clean();
1118 1118
 
1119
-			/*
1119
+			    /*
1120 1120
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1121 1121
 			 */
1122 1122
 
1123
-			return str_replace( array(
1124
-				'<style>',
1125
-				'</style>'
1126
-			), '', $output );
1127
-		}
1123
+			    return str_replace( array(
1124
+				    '<style>',
1125
+				    '</style>'
1126
+			    ), '', $output );
1127
+		    }
1128 1128
 
1129
-		/**
1129
+		    /**
1130 1130
 		 * Gets some JS for the widgets screen.
1131 1131
 		 *
1132 1132
 		 * @return mixed
1133 1133
 		 */
1134
-		public function widget_js() {
1135
-			ob_start();
1136
-			?>
1134
+		    public function widget_js() {
1135
+			    ob_start();
1136
+			    ?>
1137 1137
 			<script>
1138 1138
 
1139 1139
 				/**
@@ -1282,110 +1282,110 @@  discard block
 block discarded – undo
1282 1282
 
1283 1283
 				}
1284 1284
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1285
-			</script>
1285
+    			</script>
1286 1286
 			<?php
1287
-			$output = ob_get_clean();
1287
+			    $output = ob_get_clean();
1288 1288
 
1289
-			/*
1289
+			    /*
1290 1290
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1291 1291
 			 */
1292 1292
 
1293
-			return str_replace( array(
1294
-				'<script>',
1295
-				'</script>'
1296
-			), '', $output );
1297
-		}
1293
+			    return str_replace( array(
1294
+				    '<script>',
1295
+				    '</script>'
1296
+			    ), '', $output );
1297
+		    }
1298 1298
 
1299 1299
 
1300
-		/**
1300
+		    /**
1301 1301
 		 * Set the name from the argument key.
1302 1302
 		 *
1303 1303
 		 * @param $options
1304 1304
 		 *
1305 1305
 		 * @return mixed
1306 1306
 		 */
1307
-		private function add_name_from_key( $options, $arguments = false ) {
1308
-			if ( ! empty( $options['arguments'] ) ) {
1309
-				foreach ( $options['arguments'] as $key => $val ) {
1310
-					$options['arguments'][ $key ]['name'] = $key;
1311
-				}
1312
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
-				foreach ( $options as $key => $val ) {
1314
-					$options[ $key ]['name'] = $key;
1315
-				}
1316
-			}
1317
-
1318
-			return $options;
1319
-		}
1320
-
1321
-		/**
1307
+		    private function add_name_from_key( $options, $arguments = false ) {
1308
+			    if ( ! empty( $options['arguments'] ) ) {
1309
+				    foreach ( $options['arguments'] as $key => $val ) {
1310
+					    $options['arguments'][ $key ]['name'] = $key;
1311
+				    }
1312
+			    } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
+				    foreach ( $options as $key => $val ) {
1314
+					    $options[ $key ]['name'] = $key;
1315
+				    }
1316
+			    }
1317
+
1318
+			    return $options;
1319
+		    }
1320
+
1321
+		    /**
1322 1322
 		 * Register the parent shortcode.
1323 1323
 		 *
1324 1324
 		 * @since 1.0.0
1325 1325
 		 */
1326
-		public function register_shortcode() {
1327
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
-		}
1326
+		    public function register_shortcode() {
1327
+			    add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
+			    add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
+		    }
1330 1330
 
1331
-		/**
1331
+		    /**
1332 1332
 		 * Render the shortcode via ajax so we can return it to Gutenberg.
1333 1333
 		 *
1334 1334
 		 * @since 1.0.0
1335 1335
 		 */
1336
-		public function render_shortcode() {
1337
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
-			if ( ! current_user_can( 'manage_options' ) ) {
1339
-				wp_die();
1340
-			}
1341
-
1342
-			// we might need the $post value here so lets set it.
1343
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1345
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
-					global $post;
1347
-					$post = $post_obj;
1348
-				}
1349
-			}
1350
-
1351
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
-				$is_preview = $this->is_preview();
1353
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
-				$attributes       = '';
1356
-				if ( ! empty( $attributes_array ) ) {
1357
-					foreach ( $attributes_array as $key => $value ) {
1358
-						if ( is_array( $value ) ) {
1359
-							$value = implode( ",", $value );
1360
-						}
1361
-
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1364
-
1365
-							// Encode [ and ].
1366
-							if ( $is_preview ) {
1367
-								$value = $this->encode_shortcodes( $value );
1368
-							}
1369
-						}
1370
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
-					}
1372
-				}
1373
-
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1375
-
1376
-				$content = do_shortcode( $shortcode );
1377
-
1378
-				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1381
-				}
1382
-
1383
-				echo $content;
1384
-			}
1385
-			wp_die();
1386
-		}
1387
-
1388
-		/**
1336
+		    public function render_shortcode() {
1337
+			    check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
+			    if ( ! current_user_can( 'manage_options' ) ) {
1339
+				    wp_die();
1340
+			    }
1341
+
1342
+			    // we might need the $post value here so lets set it.
1343
+			    if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
+				    $post_obj = get_post( absint( $_POST['post_id'] ) );
1345
+				    if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
+					    global $post;
1347
+					    $post = $post_obj;
1348
+				    }
1349
+			    }
1350
+
1351
+			    if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
+				    $is_preview = $this->is_preview();
1353
+				    $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
+				    $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
+				    $attributes       = '';
1356
+				    if ( ! empty( $attributes_array ) ) {
1357
+					    foreach ( $attributes_array as $key => $value ) {
1358
+						    if ( is_array( $value ) ) {
1359
+							    $value = implode( ",", $value );
1360
+						    }
1361
+
1362
+						    if ( ! empty( $value ) ) {
1363
+							    $value = wp_unslash( $value );
1364
+
1365
+							    // Encode [ and ].
1366
+							    if ( $is_preview ) {
1367
+								    $value = $this->encode_shortcodes( $value );
1368
+							    }
1369
+						    }
1370
+						    $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
+					    }
1372
+				    }
1373
+
1374
+				    $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1375
+
1376
+				    $content = do_shortcode( $shortcode );
1377
+
1378
+				    // Decode [ and ].
1379
+				    if ( ! empty( $content ) && $is_preview ) {
1380
+					    $content = $this->decode_shortcodes( $content );
1381
+				    }
1382
+
1383
+				    echo $content;
1384
+			    }
1385
+			    wp_die();
1386
+		    }
1387
+
1388
+		    /**
1389 1389
 		 * Output the shortcode.
1390 1390
 		 *
1391 1391
 		 * @param array $args
@@ -1393,22 +1393,22 @@  discard block
 block discarded – undo
1393 1393
 		 *
1394 1394
 		 * @return string
1395 1395
 		 */
1396
-		public function shortcode_output( $args = array(), $content = '' ) {
1397
-			$_instance = $args;
1396
+		    public function shortcode_output( $args = array(), $content = '' ) {
1397
+			    $_instance = $args;
1398 1398
 
1399
-			$args = $this->argument_values( $args );
1399
+			    $args = $this->argument_values( $args );
1400 1400
 
1401
-			// add extra argument so we know its a output to gutenberg
1402
-			//$args
1403
-			$args = $this->string_to_bool( $args );
1401
+			    // add extra argument so we know its a output to gutenberg
1402
+			    //$args
1403
+			    $args = $this->string_to_bool( $args );
1404 1404
 
1405
-			// if we have a enclosed shortcode we add it to the special `html` argument
1406
-			if ( ! empty( $content ) ) {
1407
-				$args['html'] = $content;
1408
-			}
1405
+			    // if we have a enclosed shortcode we add it to the special `html` argument
1406
+			    if ( ! empty( $content ) ) {
1407
+				    $args['html'] = $content;
1408
+			    }
1409 1409
 
1410
-			if ( ! $this->is_preview() ) {
1411
-				/**
1410
+			    if ( ! $this->is_preview() ) {
1411
+				    /**
1412 1412
 				 * Filters the settings for a particular widget args.
1413 1413
 				 *
1414 1414
 				 * @param array          $args      The current widget instance's settings.
@@ -1418,95 +1418,95 @@  discard block
 block discarded – undo
1418 1418
 				 *@since 1.0.28
1419 1419
 				 *
1420 1420
 				 */
1421
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1422
-
1423
-				if ( ! is_array( $args ) ) {
1424
-					return $args;
1425
-				}
1426
-			}
1427
-
1428
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
-			$class .= " sdel-".$this->get_instance_hash();
1430
-
1431
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1433
-
1434
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1436
-
1437
-			$shortcode_args = array();
1438
-			$output         = '';
1439
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
-				$no_wrap = true;
1442
-			}
1443
-			$main_content = $this->output( $args, $shortcode_args, $content );
1444
-			if ( $main_content && ! $no_wrap ) {
1445
-				// wrap the shortcode in a div with the same class as the widget
1446
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
-				if ( ! empty( $args['title'] ) ) {
1448
-					// if its a shortcode and there is a title try to grab the title wrappers
1449
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
-					if ( empty( $instance ) ) {
1451
-						global $wp_registered_sidebars;
1452
-						if ( ! empty( $wp_registered_sidebars ) ) {
1453
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1454
-								if ( ! empty( $sidebar['before_title'] ) ) {
1455
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1456
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1457
-									break;
1458
-								}
1459
-							}
1460
-						}
1461
-					}
1462
-					$output .= $this->output_title( $shortcode_args, $args );
1463
-				}
1464
-				$output .= $main_content;
1465
-				$output .= '</div>';
1466
-			} elseif ( $main_content && $no_wrap ) {
1467
-				$output .= $main_content;
1468
-			}
1469
-
1470
-			// if preview show a placeholder if empty
1471
-			if ( $this->is_preview() && $output == '' ) {
1472
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
-			}
1474
-
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
-		}
1477
-
1478
-		/**
1421
+				    $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1422
+
1423
+				    if ( ! is_array( $args ) ) {
1424
+					    return $args;
1425
+				    }
1426
+			    }
1427
+
1428
+			    $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
+			    $class .= " sdel-".$this->get_instance_hash();
1430
+
1431
+			    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
+			    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1433
+
1434
+			    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
+			    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1436
+
1437
+			    $shortcode_args = array();
1438
+			    $output         = '';
1439
+			    $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
+			    if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
+				    $no_wrap = true;
1442
+			    }
1443
+			    $main_content = $this->output( $args, $shortcode_args, $content );
1444
+			    if ( $main_content && ! $no_wrap ) {
1445
+				    // wrap the shortcode in a div with the same class as the widget
1446
+				    $output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
+				    if ( ! empty( $args['title'] ) ) {
1448
+					    // if its a shortcode and there is a title try to grab the title wrappers
1449
+					    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
+					    if ( empty( $instance ) ) {
1451
+						    global $wp_registered_sidebars;
1452
+						    if ( ! empty( $wp_registered_sidebars ) ) {
1453
+							    foreach ( $wp_registered_sidebars as $sidebar ) {
1454
+								    if ( ! empty( $sidebar['before_title'] ) ) {
1455
+									    $shortcode_args['before_title'] = $sidebar['before_title'];
1456
+									    $shortcode_args['after_title']  = $sidebar['after_title'];
1457
+									    break;
1458
+								    }
1459
+							    }
1460
+						    }
1461
+					    }
1462
+					    $output .= $this->output_title( $shortcode_args, $args );
1463
+				    }
1464
+				    $output .= $main_content;
1465
+				    $output .= '</div>';
1466
+			    } elseif ( $main_content && $no_wrap ) {
1467
+				    $output .= $main_content;
1468
+			    }
1469
+
1470
+			    // if preview show a placeholder if empty
1471
+			    if ( $this->is_preview() && $output == '' ) {
1472
+				    $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
+			    }
1474
+
1475
+			    return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
+		    }
1477
+
1478
+		    /**
1479 1479
 		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1480 1480
 		 *
1481 1481
 		 * @param string $name
1482 1482
 		 *
1483 1483
 		 * @return string
1484 1484
 		 */
1485
-		public function preview_placeholder_text( $name = '' ) {
1486
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
-		}
1485
+		    public function preview_placeholder_text( $name = '' ) {
1486
+			    return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
+		    }
1488 1488
 
1489
-		/**
1489
+		    /**
1490 1490
 		 * Sometimes booleans values can be turned to strings, so we fix that.
1491 1491
 		 *
1492 1492
 		 * @param $options
1493 1493
 		 *
1494 1494
 		 * @return mixed
1495 1495
 		 */
1496
-		public function string_to_bool( $options ) {
1497
-			// convert bool strings to booleans
1498
-			foreach ( $options as $key => $val ) {
1499
-				if ( $val == 'false' ) {
1500
-					$options[ $key ] = false;
1501
-				} elseif ( $val == 'true' ) {
1502
-					$options[ $key ] = true;
1503
-				}
1504
-			}
1505
-
1506
-			return $options;
1507
-		}
1508
-
1509
-		/**
1496
+		    public function string_to_bool( $options ) {
1497
+			    // convert bool strings to booleans
1498
+			    foreach ( $options as $key => $val ) {
1499
+				    if ( $val == 'false' ) {
1500
+					    $options[ $key ] = false;
1501
+				    } elseif ( $val == 'true' ) {
1502
+					    $options[ $key ] = true;
1503
+				    }
1504
+			    }
1505
+
1506
+			    return $options;
1507
+		    }
1508
+
1509
+		    /**
1510 1510
 		 * Get the argument values that are also filterable.
1511 1511
 		 *
1512 1512
 		 * @param $instance
@@ -1515,159 +1515,159 @@  discard block
 block discarded – undo
1515 1515
 		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516 1516
 		 *
1517 1517
 		 */
1518
-		public function argument_values( $instance ) {
1519
-			$argument_values = array();
1520
-
1521
-			// set widget instance
1522
-			$this->instance = $instance;
1523
-
1524
-			if ( empty( $this->arguments ) ) {
1525
-				$this->arguments = $this->get_arguments();
1526
-			}
1527
-
1528
-			if ( ! empty( $this->arguments ) ) {
1529
-				foreach ( $this->arguments as $key => $args ) {
1530
-					// set the input name from the key
1531
-					$args['name'] = $key;
1532
-					//
1533
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
-						// don't set default for an empty checkbox
1536
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
-						$argument_values[ $key ] = $args['default'];
1538
-					}
1539
-				}
1540
-			}
1541
-
1542
-			return $argument_values;
1543
-		}
1544
-
1545
-		/**
1518
+		    public function argument_values( $instance ) {
1519
+			    $argument_values = array();
1520
+
1521
+			    // set widget instance
1522
+			    $this->instance = $instance;
1523
+
1524
+			    if ( empty( $this->arguments ) ) {
1525
+				    $this->arguments = $this->get_arguments();
1526
+			    }
1527
+
1528
+			    if ( ! empty( $this->arguments ) ) {
1529
+				    foreach ( $this->arguments as $key => $args ) {
1530
+					    // set the input name from the key
1531
+					    $args['name'] = $key;
1532
+					    //
1533
+					    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
+					    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
+						    // don't set default for an empty checkbox
1536
+					    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
+						    $argument_values[ $key ] = $args['default'];
1538
+					    }
1539
+				    }
1540
+			    }
1541
+
1542
+			    return $argument_values;
1543
+		    }
1544
+
1545
+		    /**
1546 1546
 		 * Set arguments in super duper.
1547 1547
 		 *
1548 1548
 		 * @return array Set arguments.
1549 1549
 		 *@since 1.0.0
1550 1550
 		 *
1551 1551
 		 */
1552
-		public function set_arguments() {
1553
-			return $this->arguments;
1554
-		}
1552
+		    public function set_arguments() {
1553
+			    return $this->arguments;
1554
+		    }
1555 1555
 
1556
-		/**
1556
+		    /**
1557 1557
 		 * Get arguments in super duper.
1558 1558
 		 *
1559 1559
 		 * @return array Get arguments.
1560 1560
 		 *@since 1.0.0
1561 1561
 		 *
1562 1562
 		 */
1563
-		public function get_arguments() {
1564
-			if ( empty( $this->arguments ) ) {
1565
-				$this->arguments = $this->set_arguments();
1566
-			}
1563
+		    public function get_arguments() {
1564
+			    if ( empty( $this->arguments ) ) {
1565
+				    $this->arguments = $this->set_arguments();
1566
+			    }
1567 1567
 
1568
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1568
+			    $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
+			    $this->arguments = $this->add_name_from_key( $this->arguments, true );
1570 1570
 
1571
-			return $this->arguments;
1572
-		}
1571
+			    return $this->arguments;
1572
+		    }
1573 1573
 
1574
-		/**
1574
+		    /**
1575 1575
 		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1576 1576
 		 *
1577 1577
 		 * @param array $args
1578 1578
 		 * @param array $widget_args
1579 1579
 		 * @param string $content
1580 1580
 		 */
1581
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1581
+		    public function output( $args = array(), $widget_args = array(), $content = '' ) {
1582 1582
 
1583
-		}
1583
+		    }
1584 1584
 
1585
-		/**
1585
+		    /**
1586 1586
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1587 1587
 		 */
1588
-		public function register_block() {
1589
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1590
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
-			}
1593
-		}
1594
-
1595
-		/**
1588
+		    public function register_block() {
1589
+			    wp_add_inline_script( 'wp-blocks', $this->block() );
1590
+			    if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
+				    wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
+			    }
1593
+		    }
1594
+
1595
+		    /**
1596 1596
 		 * Check if we need to show advanced options.
1597 1597
 		 *
1598 1598
 		 * @return bool
1599 1599
 		 */
1600
-		public function block_show_advanced() {
1600
+		    public function block_show_advanced() {
1601 1601
 
1602
-			$show      = false;
1603
-			$arguments = $this->get_arguments();
1602
+			    $show      = false;
1603
+			    $arguments = $this->get_arguments();
1604 1604
 
1605
-			if ( ! empty( $arguments ) ) {
1606
-				foreach ( $arguments as $argument ) {
1607
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
-						$show = true;
1609
-						break; // no need to continue if we know we have it
1610
-					}
1611
-				}
1612
-			}
1605
+			    if ( ! empty( $arguments ) ) {
1606
+				    foreach ( $arguments as $argument ) {
1607
+					    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
+						    $show = true;
1609
+						    break; // no need to continue if we know we have it
1610
+					    }
1611
+				    }
1612
+			    }
1613 1613
 
1614
-			return $show;
1615
-		}
1614
+			    return $show;
1615
+		    }
1616 1616
 
1617
-		/**
1617
+		    /**
1618 1618
 		 * Get the url path to the current folder.
1619 1619
 		 *
1620 1620
 		 * @return string
1621 1621
 		 */
1622
-		public function get_url() {
1623
-			$url = $this->url;
1622
+		    public function get_url() {
1623
+			    $url = $this->url;
1624 1624
 
1625
-			if ( ! $url ) {
1626
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1625
+			    if ( ! $url ) {
1626
+				    $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
+				    $content_url = untrailingslashit( WP_CONTENT_URL );
1628 1628
 
1629
-				// Replace http:// to https://.
1630
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1632
-				}
1629
+				    // Replace http:// to https://.
1630
+				    if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
+					    $content_url = str_replace( 'http://', 'https://', $content_url );
1632
+				    }
1633 1633
 
1634
-				// Check if we are inside a plugin
1635
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1637
-				$url = trailingslashit( $url );
1638
-				$this->url = $url;
1639
-			}
1634
+				    // Check if we are inside a plugin
1635
+				    $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
+				    $url = str_replace( $content_dir, $content_url, $file_dir );
1637
+				    $url = trailingslashit( $url );
1638
+				    $this->url = $url;
1639
+			    }
1640 1640
 
1641
-			return $url;
1642
-		}
1641
+			    return $url;
1642
+		    }
1643 1643
 
1644
-		/**
1644
+		    /**
1645 1645
 		 * Get the url path to the current folder.
1646 1646
 		 *
1647 1647
 		 * @return string
1648 1648
 		 */
1649
-		public function get_url_old() {
1649
+		    public function get_url_old() {
1650 1650
 
1651
-			$url = $this->url;
1651
+			    $url = $this->url;
1652 1652
 
1653
-			if ( ! $url ) {
1654
-				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1653
+			    if ( ! $url ) {
1654
+				    // check if we are inside a plugin
1655
+				    $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1656 1656
 
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
1657
+				    $dir_parts = explode( "/wp-content/", $file_dir );
1658
+				    $url_parts = explode( "/wp-content/", plugins_url() );
1659 1659
 
1660
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
-					$this->url = $url;
1663
-				}
1664
-			}
1660
+				    if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
+					    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
+					    $this->url = $url;
1663
+				    }
1664
+			    }
1665 1665
 
1666 1666
 
1667
-			return $url;
1668
-		}
1667
+			    return $url;
1668
+		    }
1669 1669
 
1670
-		/**
1670
+		    /**
1671 1671
 		 * Generate the block icon.
1672 1672
 		 *
1673 1673
 		 * Enables the use of Font Awesome icons.
@@ -1679,99 +1679,99 @@  discard block
 block discarded – undo
1679 1679
 		 * @return string
1680 1680
 		 *@since 1.1.0
1681 1681
 		 */
1682
-		public function get_block_icon( $icon ) {
1683
-
1684
-			// check if we have a Font Awesome icon
1685
-			$fa_type = '';
1686
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
-				$fa_type = 'solid';
1688
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
-				$fa_type = 'regular';
1690
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
-				$fa_type = 'brands';
1692
-			} else {
1693
-				$icon = "'" . $icon . "'";
1694
-			}
1682
+		    public function get_block_icon( $icon ) {
1683
+
1684
+			    // check if we have a Font Awesome icon
1685
+			    $fa_type = '';
1686
+			    if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
+				    $fa_type = 'solid';
1688
+			    } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
+				    $fa_type = 'regular';
1690
+			    } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
+				    $fa_type = 'brands';
1692
+			    } else {
1693
+				    $icon = "'" . $icon . "'";
1694
+			    }
1695
+
1696
+			    // set the icon if we found one
1697
+			    if ( $fa_type ) {
1698
+				    $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
+				    $icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
+			    }
1701
+
1702
+			    return $icon;
1703
+		    }
1704
+
1705
+		    public function group_arguments( $arguments ) {
1706
+			    if ( ! empty( $arguments ) ) {
1707
+				    $temp_arguments = array();
1708
+				    $general        = __( "General", 'ayecode-connect' );
1709
+				    $add_sections   = false;
1710
+				    foreach ( $arguments as $key => $args ) {
1711
+					    if ( isset( $args['group'] ) ) {
1712
+						    $temp_arguments[ $args['group'] ][ $key ] = $args;
1713
+						    $add_sections                             = true;
1714
+					    } else {
1715
+						    $temp_arguments[ $general ][ $key ] = $args;
1716
+					    }
1717
+				    }
1718
+
1719
+				    // only add sections if more than one
1720
+				    if ( $add_sections ) {
1721
+					    $arguments = $temp_arguments;
1722
+				    }
1723
+			    }
1724
+
1725
+			    return $arguments;
1726
+		    }
1727
+
1728
+		    /**
1729
+		 * Parse used group tabs.
1730
+		 *
1731
+		 * @since 1.1.17
1732
+		 */
1733
+		    public function group_block_tabs( $tabs, $arguments ) {
1734
+			    if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
+				    $has_sections = false;
1695 1736
 
1696
-			// set the icon if we found one
1697
-			if ( $fa_type ) {
1698
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
-				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
-			}
1737
+				    foreach ( $this->arguments as $key => $args ) {
1738
+					    if ( isset( $args['group'] ) ) {
1739
+						    $has_sections = true;
1740
+						    break;
1741
+					    }
1742
+				    }
1701 1743
 
1702
-			return $icon;
1703
-		}
1744
+				    if ( ! $has_sections ) {
1745
+					    return $tabs;
1746
+				    }
1704 1747
 
1705
-		public function group_arguments( $arguments ) {
1706
-			if ( ! empty( $arguments ) ) {
1707
-				$temp_arguments = array();
1708
-				$general        = __( "General", 'ayecode-connect' );
1709
-				$add_sections   = false;
1710
-				foreach ( $arguments as $key => $args ) {
1711
-					if ( isset( $args['group'] ) ) {
1712
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1713
-						$add_sections                             = true;
1714
-					} else {
1715
-						$temp_arguments[ $general ][ $key ] = $args;
1716
-					}
1717
-				}
1748
+				    $new_tabs = array();
1718 1749
 
1719
-				// only add sections if more than one
1720
-				if ( $add_sections ) {
1721
-					$arguments = $temp_arguments;
1722
-				}
1723
-			}
1750
+				    foreach ( $tabs as $tab_key => $tab ) {
1751
+					    $new_groups = array();
1724 1752
 
1725
-			return $arguments;
1726
-		}
1753
+					    if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
+						    foreach ( $tab['groups'] as $group ) {
1755
+							    if ( isset( $arguments[ $group ] ) ) {
1756
+								    $new_groups[] = $group;
1757
+							    }
1758
+						    }
1759
+					    }
1727 1760
 
1728
-		/**
1729
-		 * Parse used group tabs.
1730
-		 *
1731
-		 * @since 1.1.17
1732
-		 */
1733
-		public function group_block_tabs( $tabs, $arguments ) {
1734
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
-				$has_sections = false;
1736
-
1737
-				foreach ( $this->arguments as $key => $args ) {
1738
-					if ( isset( $args['group'] ) ) {
1739
-						$has_sections = true;
1740
-						break;
1741
-					}
1742
-				}
1743
-
1744
-				if ( ! $has_sections ) {
1745
-					return $tabs;
1746
-				}
1747
-
1748
-				$new_tabs = array();
1749
-
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1751
-					$new_groups = array();
1752
-
1753
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
-						foreach ( $tab['groups'] as $group ) {
1755
-							if ( isset( $arguments[ $group ] ) ) {
1756
-								$new_groups[] = $group;
1757
-							}
1758
-						}
1759
-					}
1761
+					    if ( ! empty( $new_groups ) ) {
1762
+						    $tab['groups'] = $new_groups;
1760 1763
 
1761
-					if ( ! empty( $new_groups ) ) {
1762
-						$tab['groups'] = $new_groups;
1764
+						    $new_tabs[ $tab_key ] = $tab;
1765
+					    }
1766
+				    }
1763 1767
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1765
-					}
1766
-				}
1767
-
1768
-				$tabs = $new_tabs;
1769
-			}
1768
+				    $tabs = $new_tabs;
1769
+			    }
1770 1770
 
1771
-			return $tabs;
1772
-		}
1771
+			    return $tabs;
1772
+		    }
1773 1773
 
1774
-		/**
1774
+		    /**
1775 1775
 		 * Output the JS for building the dynamic Guntenberg block.
1776 1776
 		 *
1777 1777
 		 * @return mixed
@@ -1779,18 +1779,18 @@  discard block
 block discarded – undo
1779 1779
 		 * @since 1.1.0 Font Awesome classes can be used for icons.
1780 1780
 		 * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1781 1781
 		 */
1782
-		public function block() {
1783
-			global $sd_is_js_functions_loaded, $aui_bs5;
1782
+		    public function block() {
1783
+			    global $sd_is_js_functions_loaded, $aui_bs5;
1784 1784
 
1785
-			$show_advanced = $this->block_show_advanced();
1785
+			    $show_advanced = $this->block_show_advanced();
1786 1786
 
1787
-			ob_start();
1788
-			?>
1789
-			<script>
1787
+			    ob_start();
1788
+			    ?>
1789
+    			<script>
1790 1790
 			<?php
1791
-			if ( ! $sd_is_js_functions_loaded ) {
1792
-				$sd_is_js_functions_loaded = true;
1793
-			?>
1791
+			    if ( ! $sd_is_js_functions_loaded ) {
1792
+				    $sd_is_js_functions_loaded = true;
1793
+			    ?>
1794 1794
 function sd_show_view_options($this){
1795 1795
 	if(jQuery($this).html().length){
1796 1796
 		jQuery($this).html('');
@@ -2290,8 +2290,8 @@  discard block
 block discarded – undo
2290 2290
 				$classes = [];
2291 2291
 
2292 2292
 				<?php
2293
-				if($aui_bs5){
2294
-					?>
2293
+				    if($aui_bs5){
2294
+					    ?>
2295 2295
 				$aui_bs5 = true;
2296 2296
 				$p_ml = 'ms-';
2297 2297
 				$p_mr = 'me-';
@@ -2299,8 +2299,8 @@  discard block
 block discarded – undo
2299 2299
 				$p_pl = 'ps-';
2300 2300
 				$p_pr = 'pe-';
2301 2301
 					<?php
2302
-				}else{
2303
-						?>
2302
+				    }else{
2303
+						    ?>
2304 2304
 				$aui_bs5 = false;
2305 2305
 				$p_ml = 'ml-';
2306 2306
 				$p_mr = 'mr-';
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
 				$p_pl = 'pl-';
2309 2309
 				$p_pr = 'pr-';
2310 2310
 					<?php
2311
-				}
2312
-				?>
2311
+				    }
2312
+				    ?>
2313 2313
 
2314 2314
 				// margins
2315 2315
 				if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] );  $mt = $args['mt']; }else{$mt = null;}
@@ -2493,12 +2493,12 @@  discard block
 block discarded – undo
2493 2493
 			<?php
2494 2494
 
2495 2495
 
2496
-			}
2496
+			    }
2497 2497
 
2498
-			if(method_exists($this,'block_global_js')){
2499
-					echo $this->block_global_js();
2500
-			}
2501
-			?>
2498
+			    if(method_exists($this,'block_global_js')){
2499
+					    echo $this->block_global_js();
2500
+			    }
2501
+			    ?>
2502 2502
 
2503 2503
 jQuery(function() {
2504 2504
 
@@ -2551,13 +2551,13 @@  discard block
 block discarded – undo
2551 2551
 						icon: <?php echo $this->get_block_icon( $this->options['block-icon'] );?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
2552 2552
 						supports: {
2553 2553
 							<?php
2554
-							if(!isset($this->options['block-supports']['renaming'])){
2555
-								$this->options['block-supports']['renaming'] = false;
2556
-							}
2557
-							if ( isset( $this->options['block-supports'] ) ) {
2558
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2559
-							}
2560
-							?>
2554
+							    if(!isset($this->options['block-supports']['renaming'])){
2555
+								    $this->options['block-supports']['renaming'] = false;
2556
+							    }
2557
+							    if ( isset( $this->options['block-supports'] ) ) {
2558
+								    echo $this->array_to_attributes( $this->options['block-supports'] );
2559
+							    }
2560
+							    ?>
2561 2561
 						},
2562 2562
 						__experimentalLabel( attributes, { context } ) {
2563 2563
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
@@ -2567,174 +2567,174 @@  discard block
 block discarded – undo
2567 2567
 						},
2568 2568
 						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
2569 2569
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2570
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2571
-						}
2572
-
2573
-
2574
-						// block hover preview.
2575
-						$example_args = array();
2576
-						if(!empty($this->arguments)){
2577
-							foreach($this->arguments as $key => $a_args){
2578
-								if(isset($a_args['example'])){
2579
-									$example_args[$key] = $a_args['example'];
2580
-								}
2581
-							}
2582
-						}
2583
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
-						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
-							// no preview if set to false
2587
-						}elseif( !empty( $example_args ) ){
2588
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
-						}elseif( !empty( $this->options['example'] ) ){
2590
-							unset($this->options['example']['viewportWidth']);
2591
-							unset($this->options['example']['innerBlocks']);
2592
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2593
-							$example_parts = array();
2594
-							if($example_atts){
2595
-								$example_parts[] = rtrim($example_atts,",");
2596
-							}
2597
-							if($viewport_width){
2598
-								$example_parts[] = $viewport_width;
2599
-							}
2600
-							if($example_inner_blocks){
2601
-								$example_parts[] = $example_inner_blocks;
2602
-							}
2603
-							if(!empty($example_parts)){
2604
-								echo "example : {".implode(',', $example_parts)."},";
2605
-							}
2606
-						}else{
2607
-							echo 'example : {viewportWidth: 500},';
2608
-						}
2609
-
2610
-
2611
-
2612
-						// limit to parent
2613
-						if( !empty( $this->options['parent'] ) ){
2614
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
-						}
2616
-
2617
-						// limit allowed blocks
2618
-						if( !empty( $this->options['allowed-blocks'] ) ){
2619
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
-						}
2621
-
2622
-						// maybe set no_wrap
2623
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
-							$no_wrap = true;
2626
-						}
2627
-						if ( $no_wrap ) {
2628
-							$this->options['block-wrap'] = '';
2629
-						}
2630
-
2631
-						// maybe load the drag/drop functions.
2632
-						$img_drag_drop = false;
2633
-
2634
-						$show_alignment = false;
2635
-						// align feature
2636
-						/*echo "supports: {";
2570
+						    echo "keywords : " . $this->options['block-keywords'] . ",";
2571
+						    }
2572
+
2573
+
2574
+						    // block hover preview.
2575
+						    $example_args = array();
2576
+						    if(!empty($this->arguments)){
2577
+							    foreach($this->arguments as $key => $a_args){
2578
+								    if(isset($a_args['example'])){
2579
+									    $example_args[$key] = $a_args['example'];
2580
+								    }
2581
+							    }
2582
+						    }
2583
+						    $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2584
+						    $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2585
+						    if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2586
+							    // no preview if set to false
2587
+						    }elseif( !empty( $example_args ) ){
2588
+							    echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2589
+						    }elseif( !empty( $this->options['example'] ) ){
2590
+							    unset($this->options['example']['viewportWidth']);
2591
+							    unset($this->options['example']['innerBlocks']);
2592
+							    $example_atts = $this->array_to_attributes( $this->options['example'] );
2593
+							    $example_parts = array();
2594
+							    if($example_atts){
2595
+								    $example_parts[] = rtrim($example_atts,",");
2596
+							    }
2597
+							    if($viewport_width){
2598
+								    $example_parts[] = $viewport_width;
2599
+							    }
2600
+							    if($example_inner_blocks){
2601
+								    $example_parts[] = $example_inner_blocks;
2602
+							    }
2603
+							    if(!empty($example_parts)){
2604
+								    echo "example : {".implode(',', $example_parts)."},";
2605
+							    }
2606
+						    }else{
2607
+							    echo 'example : {viewportWidth: 500},';
2608
+						    }
2609
+
2610
+
2611
+
2612
+						    // limit to parent
2613
+						    if( !empty( $this->options['parent'] ) ){
2614
+							    echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2615
+						    }
2616
+
2617
+						    // limit allowed blocks
2618
+						    if( !empty( $this->options['allowed-blocks'] ) ){
2619
+							    echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2620
+						    }
2621
+
2622
+						    // maybe set no_wrap
2623
+						    $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2624
+						    if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2625
+							    $no_wrap = true;
2626
+						    }
2627
+						    if ( $no_wrap ) {
2628
+							    $this->options['block-wrap'] = '';
2629
+						    }
2630
+
2631
+						    // maybe load the drag/drop functions.
2632
+						    $img_drag_drop = false;
2633
+
2634
+						    $show_alignment = false;
2635
+						    // align feature
2636
+						    /*echo "supports: {";
2637 2637
 						echo "	align: true,";
2638 2638
 						echo "  html: false";
2639 2639
 						echo "},";*/
2640 2640
 
2641 2641
 
2642
-							echo "attributes : {";
2643
-
2644
-							if ( $show_advanced ) {
2645
-								echo "show_advanced: {";
2646
-								echo "	type: 'boolean',";
2647
-								echo "  default: false,";
2648
-								echo "},";
2649
-							}
2650
-
2651
-							// block wrap element
2652
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
-								echo "block_wrap: {";
2654
-								echo "	type: 'string',";
2655
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
-								echo "},";
2657
-							}
2658
-
2659
-
2660
-							if ( ! empty( $this->arguments ) ) {
2661
-
2662
-								foreach ( $this->arguments as $key => $args ) {
2663
-
2664
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
-										$img_drag_drop = true;
2666
-									}
2667
-
2668
-									// set if we should show alignment
2669
-									if ( $key == 'alignment' ) {
2670
-										$show_alignment = true;
2671
-									}
2672
-
2673
-									$extra = '';
2674
-
2675
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
-										continue;
2677
-									}
2678
-									elseif ( $args['type'] == 'checkbox' ) {
2679
-										$type    = 'boolean';
2680
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
-									} elseif ( $args['type'] == 'number' ) {
2682
-										$type    = 'number';
2683
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
-										$type = 'array';
2686
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
-										} else {
2689
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
-										}
2691
-									} elseif ( $args['type'] == 'tagselect' ) {
2692
-										$type    = 'array';
2693
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
-									} elseif ( $args['type'] == 'multiselect' ) {
2695
-										$type    = 'array';
2696
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
-									} elseif ( $args['type'] == 'image_xy' ) {
2698
-										$type    = 'object';
2699
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
-									} elseif ( $args['type'] == 'image' ) {
2701
-										$type    = 'string';
2702
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
-
2704
-										// add a field for ID
2705
-	//                                    echo $key . "_id : {";
2706
-	//                                    echo "type : 'number',";
2707
-	//                                    echo "},";
2708
-	//                                    echo $key . "_xy : {";
2709
-	//                                    echo "type : 'object',";
2710
-	//                                    echo "},";
2711
-
2712
-									} else {
2713
-										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
-
2716
-									}
2717
-									echo $key . " : {";
2718
-									echo "type : '$type',";
2719
-									echo "default : $default,";
2720
-									echo "},";
2721
-								}
2722
-							}
2723
-
2724
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
-							echo "sd_shortcode : {type : 'string',default: ''},";
2726
-
2727
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
-								echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
-							}
2730
-
2731
-							echo "className: { type: 'string', default: '' },";
2732
-
2733
-							echo "},";
2734
-
2735
-
2736
-
2737
-						?>
2642
+							    echo "attributes : {";
2643
+
2644
+							    if ( $show_advanced ) {
2645
+								    echo "show_advanced: {";
2646
+								    echo "	type: 'boolean',";
2647
+								    echo "  default: false,";
2648
+								    echo "},";
2649
+							    }
2650
+
2651
+							    // block wrap element
2652
+							    if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2653
+								    echo "block_wrap: {";
2654
+								    echo "	type: 'string',";
2655
+								    echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2656
+								    echo "},";
2657
+							    }
2658
+
2659
+
2660
+							    if ( ! empty( $this->arguments ) ) {
2661
+
2662
+								    foreach ( $this->arguments as $key => $args ) {
2663
+
2664
+									    if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2665
+										    $img_drag_drop = true;
2666
+									    }
2667
+
2668
+									    // set if we should show alignment
2669
+									    if ( $key == 'alignment' ) {
2670
+										    $show_alignment = true;
2671
+									    }
2672
+
2673
+									    $extra = '';
2674
+
2675
+									    if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2676
+										    continue;
2677
+									    }
2678
+									    elseif ( $args['type'] == 'checkbox' ) {
2679
+										    $type    = 'boolean';
2680
+										    $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2681
+									    } elseif ( $args['type'] == 'number' ) {
2682
+										    $type    = 'number';
2683
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2684
+									    } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2685
+										    $type = 'array';
2686
+										    if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2687
+											    $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2688
+										    } else {
2689
+											    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2690
+										    }
2691
+									    } elseif ( $args['type'] == 'tagselect' ) {
2692
+										    $type    = 'array';
2693
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2694
+									    } elseif ( $args['type'] == 'multiselect' ) {
2695
+										    $type    = 'array';
2696
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2697
+									    } elseif ( $args['type'] == 'image_xy' ) {
2698
+										    $type    = 'object';
2699
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2700
+									    } elseif ( $args['type'] == 'image' ) {
2701
+										    $type    = 'string';
2702
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2703
+
2704
+										    // add a field for ID
2705
+	    //                                    echo $key . "_id : {";
2706
+	    //                                    echo "type : 'number',";
2707
+	    //                                    echo "},";
2708
+	    //                                    echo $key . "_xy : {";
2709
+	    //                                    echo "type : 'object',";
2710
+	    //                                    echo "},";
2711
+
2712
+									    } else {
2713
+										    $type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2714
+										    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2715
+
2716
+									    }
2717
+									    echo $key . " : {";
2718
+									    echo "type : '$type',";
2719
+									    echo "default : $default,";
2720
+									    echo "},";
2721
+								    }
2722
+							    }
2723
+
2724
+							    echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2725
+							    echo "sd_shortcode : {type : 'string',default: ''},";
2726
+
2727
+							    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2728
+								    echo "sd_shortcode_close : {type : 'string',default: ''},";
2729
+							    }
2730
+
2731
+							    echo "className: { type: 'string', default: '' },";
2732
+
2733
+							    echo "},";
2734
+
2735
+
2736
+
2737
+						    ?>
2738 2738
 
2739 2739
 						// The "edit" property must be a valid function.
2740 2740
 						edit: function (props) {
@@ -2742,10 +2742,10 @@  discard block
 block discarded – undo
2742 2742
 							const selectedBlock = wp.data.select('core/block-editor').getSelectedBlock();
2743 2743
 
2744 2744
 <?php
2745
-// only include the drag/drop functions if required.
2746
-if( $img_drag_drop ){
2745
+    // only include the drag/drop functions if required.
2746
+    if( $img_drag_drop ){
2747 2747
 
2748
-?>
2748
+    ?>
2749 2749
 
2750 2750
 function enableDragSort(listClass) {
2751 2751
 	setTimeout(function(){
@@ -2809,10 +2809,10 @@  discard block
 block discarded – undo
2809 2809
 							}
2810 2810
 
2811 2811
 							<?php
2812
-							if(!empty($this->options['block-edit-raw'])) {
2813
-								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
-							}else{
2815
-							?>
2812
+							    if(!empty($this->options['block-edit-raw'])) {
2813
+								    echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2814
+							    }else{
2815
+							    ?>
2816 2816
 
2817 2817
 function hasSelectedInnerBlock(props) {
2818 2818
 	const select = wp.data.select('core/editor');
@@ -2834,9 +2834,9 @@  discard block
 block discarded – undo
2834 2834
 
2835 2835
 	var $value = '';
2836 2836
 	<?php
2837
-	// if we have a post_type and a category then link them
2838
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
-	?>
2837
+	    // if we have a post_type and a category then link them
2838
+	    if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2839
+	    ?>
2840 2840
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2841 2841
 		$pt = props.attributes.post_type;
2842 2842
 		if(post_type_rest_slugs.length){
@@ -2849,12 +2849,12 @@  discard block
 block discarded – undo
2849 2849
 			term_query_type = $pt;
2850 2850
 		}
2851 2851
 <?php
2852
-	$cat_path = '';
2853
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
-	}
2857
-?>
2852
+	    $cat_path = '';
2853
+	    if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2854
+		    $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2855
+		    $cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2856
+	    }
2857
+    ?>
2858 2858
 		/* taxonomies */
2859 2859
 		if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){
2860 2860
 			if (!window.gdCPTCats) {
@@ -2942,12 +2942,12 @@  discard block
 block discarded – undo
2942 2942
 		}
2943 2943
 	}
2944 2944
 	<?php } ?>
2945
-<?php
2946
-$current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947
-if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2948
-	echo 'const { deviceType } = "";';
2945
+    <?php
2946
+    $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2947
+    if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2948
+	    echo 'const { deviceType } = "";';
2949 2949
 }else{
2950
-?>
2950
+    ?>
2951 2951
 /** Get device type const. */
2952 2952
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
2953 2953
 const { deviceType } = typeof wp.data.useSelect !== 'undefined' ? wp.data.useSelect(select => {
@@ -3009,8 +3009,8 @@  discard block
 block discarded – undo
3009 3009
 										'attributes': props.attributes,
3010 3010
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
3011 3011
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
3012
-										echo $post->ID;
3013
-									}else{echo '0';}?>,
3012
+										    echo $post->ID;
3013
+									    }else{echo '0';}?>,
3014 3014
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
3015 3015
 									};
3016 3016
 
@@ -3024,20 +3024,20 @@  discard block
 block discarded – undo
3024 3024
 										}
3025 3025
 
3026 3026
 										 <?php
3027
-										if(!empty($this->options['nested-block'])){
3028
-											?>
3027
+										    if(!empty($this->options['nested-block'])){
3028
+											    ?>
3029 3029
 											// props.setAttributes({content: env});
3030 3030
 										is_fetching = false;
3031 3031
 										prev_attributes[props.clientId] = props.attributes;
3032 3032
 											 <?php
3033
-										}else{
3034
-										?>
3033
+										    }else{
3034
+										    ?>
3035 3035
 										props.setAttributes({content: env});
3036 3036
 										is_fetching = false;
3037 3037
 										prev_attributes[props.clientId] = props.attributes;
3038 3038
 										<?php
3039
-										}
3040
-										?>
3039
+										    }
3040
+										    ?>
3041 3041
 
3042 3042
 
3043 3043
 										// if AUI is active call the js init function
@@ -3056,32 +3056,32 @@  discard block
 block discarded – undo
3056 3056
 							}
3057 3057
 
3058 3058
 							<?php
3059
-							if(!empty($this->options['block-edit-js'])) {
3060
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
-							}
3059
+							    if(!empty($this->options['block-edit-js'])) {
3060
+								    echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3061
+							    }
3062 3062
 
3063 3063
 
3064 3064
 
3065 3065
 
3066
-							if(empty($this->options['block-save-return'])){
3067
-							?>
3066
+							    if(empty($this->options['block-save-return'])){
3067
+							    ?>
3068 3068
 								///////////////////////////////////////////////////////////////////////
3069 3069
 
3070 3070
 									 // build the shortcode.
3071 3071
 								shortcode = "[<?php echo $this->options['base_id'];?>";
3072 3072
 								<?php
3073 3073
 
3074
-								if(! empty( $this->arguments )){
3074
+								    if(! empty( $this->arguments )){
3075 3075
 
3076
-								foreach($this->arguments as $key => $args){
3077
-								   // if($args['type']=='tabs'){continue;}
3076
+								    foreach($this->arguments as $key => $args){
3077
+								       // if($args['type']=='tabs'){continue;}
3078 3078
 
3079
-								   // don't add metadata arguments
3080
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3081
-									   continue;
3082
-								   }
3083
-								?>
3084
-								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3079
+								       // don't add metadata arguments
3080
+								       if (substr($key, 0, 9 ) === 'metadata_') {
3081
+									       continue;
3082
+								       }
3083
+								    ?>
3084
+    								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3085 3085
 									if ('<?php echo esc_attr( $key );?>' == 'html') {
3086 3086
 									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3087 3087
 										shortcode += props.attributes.<?php echo esc_attr( $key );?>.length && ( props.attributes.<?php echo esc_attr( $key );?>.x.length || props.attributes.<?php echo esc_attr( $key );?>.y.length ) ? " <?php echo esc_attr( $key );?>='{x:" + props.attributes.<?php echo esc_attr( $key );?>.x + ",y:"+props.attributes.<?php echo esc_attr( $key );?>.y +"}' " : "";
@@ -3091,10 +3091,10 @@  discard block
 block discarded – undo
3091 3091
 									}
3092 3092
 								}
3093 3093
 								<?php
3094
-								}
3095
-								}
3094
+								    }
3095
+								    }
3096 3096
 
3097
-								?>
3097
+								    ?>
3098 3098
 								shortcode += "]";
3099 3099
 
3100 3100
 								if(shortcode){
@@ -3106,17 +3106,17 @@  discard block
 block discarded – undo
3106 3106
 
3107 3107
 
3108 3108
 									<?php
3109
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
-									}
3112
-									?>
3109
+									    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3110
+										    echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3111
+									    }
3112
+									    ?>
3113 3113
 								}
3114 3114
 
3115 3115
 
3116 3116
 							///////////////////////////////////////////////////////////////////////
3117 3117
 							<?php
3118
-							} // end nested block check
3119
-							?>
3118
+							    } // end nested block check
3119
+							    ?>
3120 3120
 
3121 3121
 							return [
3122 3122
 
@@ -3140,10 +3140,10 @@  discard block
 block discarded – undo
3140 3140
 
3141 3141
 									<?php
3142 3142
 
3143
-									if(! empty( $this->arguments )){
3143
+									    if(! empty( $this->arguments )){
3144 3144
 
3145
-									if ( $show_advanced ) {
3146
-									?>
3145
+									    if ( $show_advanced ) {
3146
+									    ?>
3147 3147
 									el('div', {
3148 3148
 											style: {'padding-left': '16px','padding-right': '16px'}
3149 3149
 										},
@@ -3160,133 +3160,133 @@  discard block
 block discarded – undo
3160 3160
 									)
3161 3161
 									,
3162 3162
 									<?php
3163
-									}
3164
-
3165
-									$arguments = $this->group_arguments( $this->arguments );
3166
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
-
3168
-									// Do we have sections?
3169
-									$has_sections = $arguments == $this->arguments ? false : true;
3170
-
3171
-									if($has_sections){
3172
-									$panel_count = 0;
3173
-									$open_tab = '';
3174
-
3175
-									$open_tab_groups = array();
3176
-									$used_tabs = array();
3177
-
3178
-									foreach ( $arguments as $key => $args ) {
3179
-										$close_tab = false;
3180
-										$close_tabs = false;
3181
-
3182
-										 if ( ! empty( $block_group_tabs ) ) {
3183
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3185
-													$open_tab_groups[] = $key;
3186
-
3187
-													if ( $open_tab != $tab_name ) {
3188
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
-														$tab_args['tab']['open'] = true;
3190
-
3191
-														$this->block_tab_start( '', $tab_args );
3192
-														$open_tab = $tab_name;
3193
-														$used_tabs[] = $tab_name;
3194
-													}
3195
-
3196
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3197
-														$close_tab = true;
3198
-														$open_tab_groups = array();
3199
-
3200
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
-															$close_tabs = true;
3202
-														}
3203
-													}
3204
-												}
3205
-											}
3206
-										}
3207
-										?>
3163
+									    }
3164
+
3165
+									    $arguments = $this->group_arguments( $this->arguments );
3166
+									    $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3167
+
3168
+									    // Do we have sections?
3169
+									    $has_sections = $arguments == $this->arguments ? false : true;
3170
+
3171
+									    if($has_sections){
3172
+									    $panel_count = 0;
3173
+									    $open_tab = '';
3174
+
3175
+									    $open_tab_groups = array();
3176
+									    $used_tabs = array();
3177
+
3178
+									    foreach ( $arguments as $key => $args ) {
3179
+										    $close_tab = false;
3180
+										    $close_tabs = false;
3181
+
3182
+										     if ( ! empty( $block_group_tabs ) ) {
3183
+											    foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3184
+												    if ( in_array( $key, $tab_args['groups'] ) ) {
3185
+													    $open_tab_groups[] = $key;
3186
+
3187
+													    if ( $open_tab != $tab_name ) {
3188
+														    $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3189
+														    $tab_args['tab']['open'] = true;
3190
+
3191
+														    $this->block_tab_start( '', $tab_args );
3192
+														    $open_tab = $tab_name;
3193
+														    $used_tabs[] = $tab_name;
3194
+													    }
3195
+
3196
+													    if ( $open_tab_groups == $tab_args['groups'] ) {
3197
+														    $close_tab = true;
3198
+														    $open_tab_groups = array();
3199
+
3200
+														    if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3201
+															    $close_tabs = true;
3202
+														    }
3203
+													    }
3204
+												    }
3205
+											    }
3206
+										    }
3207
+										    ?>
3208 3208
 										el(wp.components.PanelBody, {
3209 3209
 												title: '<?php esc_attr_e( $key ); ?>',
3210 3210
 												initialOpen: <?php if ( $panel_count ) {
3211
-												echo "false";
3212
-											} else {
3213
-												echo "true";
3214
-											}?>
3215
-											},
3211
+												    echo "false";
3212
+											    } else {
3213
+												    echo "true";
3214
+											    }?>
3215
+    											},
3216 3216
 											<?php
3217
-											foreach ( $args as $k => $a ) {
3218
-												$this->block_tab_start( $k, $a );
3219
-												$this->block_row_start( $k, $a );
3220
-												$this->build_block_arguments( $k, $a );
3221
-												$this->block_row_end( $k, $a );
3222
-												$this->block_tab_end( $k, $a );
3223
-											}
3224
-											?>
3225
-										),
3217
+											    foreach ( $args as $k => $a ) {
3218
+												    $this->block_tab_start( $k, $a );
3219
+												    $this->block_row_start( $k, $a );
3220
+												    $this->build_block_arguments( $k, $a );
3221
+												    $this->block_row_end( $k, $a );
3222
+												    $this->block_tab_end( $k, $a );
3223
+											    }
3224
+											    ?>
3225
+    										),
3226 3226
 										<?php
3227
-										$panel_count ++;
3228
-
3229
-										if($close_tab || $close_tabs){
3230
-											$tab_args = array(
3231
-												'tab'	=> array(
3232
-													'tabs_close' => $close_tabs,
3233
-												'close' => true,
3234
-												)
3235
-
3236
-											);
3237
-											$this->block_tab_end( '', $tab_args );
3238
-//											echo '###close'; print_r($tab_args);
3239
-											$panel_count = 0;
3240
-										}
3241
-//
3242
-
3243
-									}
3244
-									}else {
3245
-									?>
3227
+										    $panel_count ++;
3228
+
3229
+										    if($close_tab || $close_tabs){
3230
+											    $tab_args = array(
3231
+												    'tab'	=> array(
3232
+													    'tabs_close' => $close_tabs,
3233
+												    'close' => true,
3234
+												    )
3235
+
3236
+											    );
3237
+											    $this->block_tab_end( '', $tab_args );
3238
+    //											echo '###close'; print_r($tab_args);
3239
+											    $panel_count = 0;
3240
+										    }
3241
+    //
3242
+
3243
+									    }
3244
+									    }else {
3245
+									    ?>
3246 3246
 									el(wp.components.PanelBody, {
3247 3247
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3248 3248
 											initialOpen: true
3249 3249
 										},
3250 3250
 										<?php
3251
-										foreach ( $this->arguments as $key => $args ) {
3252
-											$this->block_row_start( $key, $args );
3253
-											$this->build_block_arguments( $key, $args );
3254
-											$this->block_row_end( $key, $args );
3255
-										}
3256
-										?>
3257
-									),
3251
+										    foreach ( $this->arguments as $key => $args ) {
3252
+											    $this->block_row_start( $key, $args );
3253
+											    $this->build_block_arguments( $key, $args );
3254
+											    $this->block_row_end( $key, $args );
3255
+										    }
3256
+										    ?>
3257
+    									),
3258 3258
 									<?php
3259
-									}
3259
+									    }
3260 3260
 
3261
-									}
3262
-									?>
3261
+									    }
3262
+									    ?>
3263 3263
 
3264 3264
 								),
3265 3265
 
3266 3266
 								<?php
3267
-								// If the user sets block-output array then build it
3268
-								if ( ! empty( $this->options['block-output'] ) ) {
3269
-								$this->block_element( $this->options['block-output'] );
3270
-							}elseif(!empty($this->options['block-edit-return'])){
3271
-								   echo $this->options['block-edit-return'];
3272
-							}else{
3273
-								// if no block-output is set then we try and get the shortcode html output via ajax.
3274
-								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
-								?>
3276
-								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3267
+								    // If the user sets block-output array then build it
3268
+								    if ( ! empty( $this->options['block-output'] ) ) {
3269
+								    $this->block_element( $this->options['block-output'] );
3270
+							    }elseif(!empty($this->options['block-edit-return'])){
3271
+								       echo $this->options['block-edit-return'];
3272
+							    }else{
3273
+								    // if no block-output is set then we try and get the shortcode html output via ajax.
3274
+								    $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3275
+								    ?>
3276
+    								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3277 3277
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
3278 3278
 									className: props.className,
3279 3279
 									<?php //if(isset($this->arguments['visibility_conditions'])){ echo 'dataVisibilityConditionSD: props.visibility_conditions ? true : false,';} //@todo we need to implement this in the other outputs also ?>
3280 3280
 									style: {'minHeight': '30px'}
3281 3281
 								}))
3282 3282
 								<?php
3283
-								}
3284
-								?>
3285
-							]; // end return
3283
+								    }
3284
+								    ?>
3285
+    							]; // end return
3286 3286
 
3287 3287
 							<?php
3288
-							} // end block-edit-raw else
3289
-							?>
3288
+							    } // end block-edit-raw else
3289
+							    ?>
3290 3290
 						},
3291 3291
 
3292 3292
 						// The "save" property must be specified and must be a valid function.
@@ -3300,17 +3300,17 @@  discard block
 block discarded – undo
3300 3300
 							$html = '';
3301 3301
 							<?php
3302 3302
 
3303
-							if(! empty( $this->arguments )){
3303
+							    if(! empty( $this->arguments )){
3304 3304
 
3305
-							foreach($this->arguments as $key => $args){
3306
-							   // if($args['type']=='tabs'){continue;}
3305
+							    foreach($this->arguments as $key => $args){
3306
+							       // if($args['type']=='tabs'){continue;}
3307 3307
 
3308
-							   // don't add metadata arguments
3309
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3310
-								   continue;
3311
-							   }
3312
-							?>
3313
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3308
+							       // don't add metadata arguments
3309
+							       if (substr($key, 0, 9 ) === 'metadata_') {
3310
+								       continue;
3311
+							       }
3312
+							    ?>
3313
+    							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3314 3314
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
3315 3315
 									$html = attr.<?php echo esc_attr( $key );?>;
3316 3316
 								} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
@@ -3320,20 +3320,20 @@  discard block
 block discarded – undo
3320 3320
 								}
3321 3321
 							}
3322 3322
 							<?php
3323
-							}
3324
-							}
3323
+							    }
3324
+							    }
3325 3325
 
3326
-							?>
3326
+							    ?>
3327 3327
 							content += "]";
3328 3328
 							 content = '';
3329 3329
 
3330 3330
 							<?php
3331
-//                            if(!empty($this->options['nested-block'])){
3332
-//                                ?>
3331
+    //                            if(!empty($this->options['nested-block'])){
3332
+    //                                ?>
3333 3333
 //                                $html = 'el( InnerBlocks.Content )';
3334 3334
 //                                <?php
3335
-//                            }
3336
-							?>
3335
+    //                            }
3336
+							    ?>
3337 3337
 							// if has html element
3338 3338
 							if ($html) {
3339 3339
 								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
@@ -3353,38 +3353,38 @@  discard block
 block discarded – undo
3353 3353
 							}
3354 3354
 
3355 3355
 							<?php
3356
-//							if(!empty($this->options['nested-block'])){
3357
-//                                ?x>
3358
-//                              return el(
3359
-//                                    'div',
3360
-//                                    { className: props.className,
3361
-//                                        style: {'minHeight': '300px','position':'relative','overflow':'hidden','backgroundImage': 'url(https://s.w.org/images/core/5.5/don-quixote-06.jpg)'}
3362
-//                                    },
3363
-//                                    el( InnerBlocks.Content ),
3364
-//                                    el('div', {dangerouslySetInnerHTML: {__html: content}, className: align})
3365
-//                                );
3366
-//                                <x?php
3367
-//							}else
3368
-
3369
-							if(!empty($this->options['block-output'])){
3370
-//                               echo "return";
3371
-//                               $this->block_element( $this->options['block-output'], true );
3372
-//                               echo ";";
3373
-
3374
-							   ?>
3356
+    //							if(!empty($this->options['nested-block'])){
3357
+    //                                ?x>
3358
+    //                              return el(
3359
+    //                                    'div',
3360
+    //                                    { className: props.className,
3361
+    //                                        style: {'minHeight': '300px','position':'relative','overflow':'hidden','backgroundImage': 'url(https://s.w.org/images/core/5.5/don-quixote-06.jpg)'}
3362
+    //                                    },
3363
+    //                                    el( InnerBlocks.Content ),
3364
+    //                                    el('div', {dangerouslySetInnerHTML: {__html: content}, className: align})
3365
+    //                                );
3366
+    //                                <x?php
3367
+    //							}else
3368
+
3369
+							    if(!empty($this->options['block-output'])){
3370
+    //                               echo "return";
3371
+    //                               $this->block_element( $this->options['block-output'], true );
3372
+    //                               echo ";";
3373
+
3374
+							       ?>
3375 3375
 							  return el(
3376 3376
 								   '',
3377 3377
 								   {},
3378 3378
 								  // el('', {dangerouslySetInnerHTML: {__html: content}}),
3379 3379
 								   <?php $this->block_element( $this->options['block-output'], true ); ?>
3380
-								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3380
+    								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3381 3381
 							   );
3382 3382
 								<?php
3383 3383
 
3384
-							}elseif(!empty($this->options['block-save-return'])){
3385
-								   echo 'return ' . $this->options['block-save-return'];
3386
-							}elseif(!empty($this->options['nested-block'])){
3387
-								?>
3384
+							    }elseif(!empty($this->options['block-save-return'])){
3385
+								       echo 'return ' . $this->options['block-save-return'];
3386
+							    }elseif(!empty($this->options['nested-block'])){
3387
+								    ?>
3388 3388
 							  return el(
3389 3389
 								   '',
3390 3390
 								   {},
@@ -3393,22 +3393,22 @@  discard block
 block discarded – undo
3393 3393
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3394 3394
 							   );
3395 3395
 								<?php
3396
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3397
-								echo "return ". $this->options['block-edit-return'].";";
3398
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
-							?>
3400
-							return content;
3396
+							    }elseif(!empty( $this->options['block-save-return'] ) ){
3397
+								    echo "return ". $this->options['block-edit-return'].";";
3398
+							    }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3399
+							    ?>
3400
+    							return content;
3401 3401
 							<?php
3402
-							}else{
3403
-							?>
3402
+							    }else{
3403
+							    ?>
3404 3404
 							var block_wrap = 'div';
3405 3405
 							if (attr.hasOwnProperty("block_wrap")) {
3406 3406
 								block_wrap = attr.block_wrap;
3407 3407
 							}
3408 3408
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
3409 3409
 							<?php
3410
-							}
3411
-							?>
3410
+							    }
3411
+							    ?>
3412 3412
 
3413 3413
 
3414 3414
 						}
@@ -3422,43 +3422,43 @@  discard block
 block discarded – undo
3422 3422
 				});
3423 3423
 			</script>
3424 3424
 			<?php
3425
-			$output = ob_get_clean();
3425
+			    $output = ob_get_clean();
3426 3426
 
3427
-			/*
3427
+			    /*
3428 3428
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3429 3429
 			 */
3430 3430
 
3431
-			return str_replace( array(
3432
-				'<script>',
3433
-				'</script>'
3434
-			), '', $output );
3435
-		}
3431
+			    return str_replace( array(
3432
+				    '<script>',
3433
+				    '</script>'
3434
+			    ), '', $output );
3435
+		    }
3436 3436
 
3437 3437
 
3438 3438
 
3439
-		public function block_row_start($key, $args){
3439
+		    public function block_row_start($key, $args){
3440 3440
 
3441
-			// check for row
3442
-			if(!empty($args['row'])){
3441
+			    // check for row
3442
+			    if(!empty($args['row'])){
3443 3443
 
3444
-				if(!empty($args['row']['open'])){
3444
+				    if(!empty($args['row']['open'])){
3445 3445
 
3446
-				// element require
3447
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
-				$device_type_icon = '';
3451
-				if($device_type=='Desktop'){
3452
-					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
-				}elseif($device_type=='Tablet'){
3454
-					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
-				}elseif($device_type=='Mobile'){
3456
-					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
-				}
3458
-				echo $element_require;
3459
-				echo $device_type_require;
3446
+				    // element require
3447
+				    $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3448
+				    $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3449
+				    $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3450
+				    $device_type_icon = '';
3451
+				    if($device_type=='Desktop'){
3452
+					    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3453
+				    }elseif($device_type=='Tablet'){
3454
+					    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3455
+				    }elseif($device_type=='Mobile'){
3456
+					    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3457
+				    }
3458
+				    echo $element_require;
3459
+				    echo $device_type_require;
3460 3460
 
3461
-					if(false){?><script><?php }?>
3461
+					    if(false){?><script><?php }?>
3462 3462
 						el('div', {
3463 3463
 								className: 'bsui components-base-control',
3464 3464
 							},
@@ -3469,15 +3469,15 @@  discard block
 block discarded – undo
3469 3469
 								},
3470 3470
 								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}),
3471 3471
 								<?php if($device_type_icon){ ?>
3472
-									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3472
+    									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3473 3473
 								<?php
3474
-								}
3475
-								?>
3474
+								    }
3475
+								    ?>
3476 3476
 
3477 3477
 
3478 3478
 							),
3479 3479
 							<?php }?>
3480
-							<?php if(!empty($args['row']['desc'])){ ?>
3480
+    							<?php if(!empty($args['row']['desc'])){ ?>
3481 3481
 							el('p', {
3482 3482
 									className: 'components-base-control__help mb-0',
3483 3483
 								},
@@ -3496,51 +3496,51 @@  discard block
 block discarded – undo
3496 3496
 									},
3497 3497
 
3498 3498
 					<?php
3499
-					if(false){?></script><?php }
3500
-				}elseif(!empty($args['row']['close'])){
3501
-					if(false){?><script><?php }?>
3499
+					    if(false){?></script><?php }
3500
+				    }elseif(!empty($args['row']['close'])){
3501
+					    if(false){?><script><?php }?>
3502 3502
 						el(
3503 3503
 							'div',
3504 3504
 							{
3505 3505
 								className: 'col pl-0 ps-0',
3506 3506
 							},
3507 3507
 					<?php
3508
-					if(false){?></script><?php }
3509
-				}else{
3510
-					if(false){?><script><?php }?>
3508
+					    if(false){?></script><?php }
3509
+				    }else{
3510
+					    if(false){?><script><?php }?>
3511 3511
 						el(
3512 3512
 							'div',
3513 3513
 							{
3514 3514
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3515 3515
 							},
3516 3516
 					<?php
3517
-					if(false){?></script><?php }
3518
-				}
3517
+					    if(false){?></script><?php }
3518
+				    }
3519 3519
 
3520
-			}
3520
+			    }
3521 3521
 
3522
-		}
3522
+		    }
3523 3523
 
3524
-		public function block_row_end($key, $args){
3524
+		    public function block_row_end($key, $args){
3525 3525
 
3526
-			if(!empty($args['row'])){
3527
-				// maybe close
3528
-				if(!empty($args['row']['close'])){
3529
-					echo "))";
3530
-				}
3526
+			    if(!empty($args['row'])){
3527
+				    // maybe close
3528
+				    if(!empty($args['row']['close'])){
3529
+					    echo "))";
3530
+				    }
3531 3531
 
3532
-				echo "),";
3533
-			}
3534
-		}
3532
+				    echo "),";
3533
+			    }
3534
+		    }
3535 3535
 
3536
-		public function block_tab_start($key, $args){
3536
+		    public function block_tab_start($key, $args){
3537 3537
 
3538
-			// check for row
3539
-			if(!empty($args['tab'])){
3538
+			    // check for row
3539
+			    if(!empty($args['tab'])){
3540 3540
 
3541
-				if(!empty($args['tab']['tabs_open'])){
3541
+				    if(!empty($args['tab']['tabs_open'])){
3542 3542
 
3543
-					if(false){?><script><?php }?>
3543
+					    if(false){?><script><?php }?>
3544 3544
 
3545 3545
 el('div',{className: 'bsui'},
3546 3546
 
@@ -3553,12 +3553,12 @@  discard block
 block discarded – undo
3553 3553
 										tabs: [
3554 3554
 
3555 3555
 					<?php
3556
-					if(false){?></script><?php }
3557
-				}
3556
+					    if(false){?></script><?php }
3557
+				    }
3558 3558
 
3559
-				if(!empty($args['tab']['open'])){
3559
+				    if(!empty($args['tab']['open'])){
3560 3560
 
3561
-					if(false){?><script><?php }?>
3561
+					    if(false){?><script><?php }?>
3562 3562
 							{
3563 3563
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3564 3564
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3567,125 +3567,125 @@  discard block
 block discarded – undo
3567 3567
 									className: 'components-base-control__help mb-0',
3568 3568
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3569 3569
 								}),<?php }
3570
-					if(false){?></script><?php }
3571
-				}
3570
+					    if(false){?></script><?php }
3571
+				    }
3572 3572
 
3573
-			}
3573
+			    }
3574 3574
 
3575
-		}
3575
+		    }
3576 3576
 
3577
-		public function block_tab_end($key, $args){
3577
+		    public function block_tab_end($key, $args){
3578 3578
 
3579
-			if(!empty($args['tab'])){
3580
-				// maybe close
3581
-				if(!empty($args['tab']['close'])){
3582
-					echo ")}, /* tab close */";
3583
-				}
3579
+			    if(!empty($args['tab'])){
3580
+				    // maybe close
3581
+				    if(!empty($args['tab']['close'])){
3582
+					    echo ")}, /* tab close */";
3583
+				    }
3584 3584
 
3585
-				if(!empty($args['tab']['tabs_close'])){
3586
-					if(false){?><script><?php }?>
3585
+				    if(!empty($args['tab']['tabs_close'])){
3586
+					    if(false){?><script><?php }?>
3587 3587
 						]}, ( tab ) => {
3588 3588
 								return tab.content;
3589 3589
 							}
3590 3590
 						)), /* tabs close */
3591 3591
 					<?php if(false){ ?></script><?php }
3592
-				}
3593
-			}
3594
-		}
3595
-
3596
-		public function build_block_arguments( $key, $args ) {
3597
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
-			$options           = '';
3599
-			$extra             = '';
3600
-			$require           = '';
3601
-			$inside_elements   = '';
3602
-			$after_elements	   = '';
3603
-
3604
-			// `content` is a protected and special argument
3605
-			if ( $key == 'content' ) {
3606
-				return;
3607
-			}
3608
-
3609
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
-			$device_type_icon = '';
3612
-			if($device_type=='Desktop'){
3613
-				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
-			}elseif($device_type=='Tablet'){
3615
-				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
-			}elseif($device_type=='Mobile'){
3617
-				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
-			}
3619
-
3620
-			// icon
3621
-			$icon = '';
3622
-			if( !empty( $args['icon'] ) ){
3623
-				$icon .= "el('div', {";
3624
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
-									$icon .= "className: 'text-center',";
3626
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3627
-								$icon .= "}),";
3628
-
3629
-				// blank title as its added to the icon.
3630
-				$args['title'] = '';
3631
-			}
3632
-
3633
-			// require advanced
3634
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3635
-
3636
-			// element require
3637
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3638
-
3639
-
3640
-			$onchange  = "props.setAttributes({ $key: $key } )";
3641
-			$onchangecomplete  = "";
3642
-			$value     = "props.attributes.$key";
3643
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
-			if ( in_array( $args['type'], $text_type ) ) {
3645
-				$type = 'TextControl';
3646
-				// Save numbers as numbers and not strings
3647
-				if ( $args['type'] == 'number' ) {
3648
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
-				}
3650
-
3651
-				if (substr($key, 0, 9 ) === 'metadata_') {
3652
-					$real_key = str_replace('metadata_','', $key );
3653
-					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
-				}
3656
-			}
3657
-//			else if ( $args['type'] == 'popup' ) {
3658
-//				$type = 'TextControl';
3659
-//				$args['type'] == 'text';
3660
-//				$after_elements .= "el( wp.components.Button, {
3661
-//                          className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
3662
-//                          onClick: function(){
3663
-//							  aui_modal('','<input id=\'zzz\' value= />');
3664
-//							  const source = document.getElementById('zzz');
3665
-//							  source.value = props.attributes.$key;
3666
-//							  source.addEventListener('input', function(e){props.setAttributes({ $key: e.target.value });});
3667
-//                          }
3668
-//                        },
3669
-//                        'test'
3670
-//                        ),";
3671
-//
3672
-//				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673
-//			}
3674
-			else if ( $args['type'] == 'styleid' ) {
3675
-				$type = 'TextControl';
3676
-				$args['type'] == 'text';
3677
-				// Save numbers as numbers and not strings
3678
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
-			}else if ( $args['type'] == 'notice' ) {
3680
-
3681
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
-
3684
-				$notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3685
-				echo $notice_message ? $element_require . $notice : '';
3686
-				return;
3687
-			}
3688
-			/*
3592
+				    }
3593
+			    }
3594
+		    }
3595
+
3596
+		    public function build_block_arguments( $key, $args ) {
3597
+			    $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3598
+			    $options           = '';
3599
+			    $extra             = '';
3600
+			    $require           = '';
3601
+			    $inside_elements   = '';
3602
+			    $after_elements	   = '';
3603
+
3604
+			    // `content` is a protected and special argument
3605
+			    if ( $key == 'content' ) {
3606
+				    return;
3607
+			    }
3608
+
3609
+			    $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3610
+			    $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3611
+			    $device_type_icon = '';
3612
+			    if($device_type=='Desktop'){
3613
+				    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3614
+			    }elseif($device_type=='Tablet'){
3615
+				    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3616
+			    }elseif($device_type=='Mobile'){
3617
+				    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3618
+			    }
3619
+
3620
+			    // icon
3621
+			    $icon = '';
3622
+			    if( !empty( $args['icon'] ) ){
3623
+				    $icon .= "el('div', {";
3624
+									    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3625
+									    $icon .= "className: 'text-center',";
3626
+									    $icon .= "title: '".addslashes( $args['title'] )."',";
3627
+								    $icon .= "}),";
3628
+
3629
+				    // blank title as its added to the icon.
3630
+				    $args['title'] = '';
3631
+			    }
3632
+
3633
+			    // require advanced
3634
+			    $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3635
+
3636
+			    // element require
3637
+			    $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3638
+
3639
+
3640
+			    $onchange  = "props.setAttributes({ $key: $key } )";
3641
+			    $onchangecomplete  = "";
3642
+			    $value     = "props.attributes.$key";
3643
+			    $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3644
+			    if ( in_array( $args['type'], $text_type ) ) {
3645
+				    $type = 'TextControl';
3646
+				    // Save numbers as numbers and not strings
3647
+				    if ( $args['type'] == 'number' ) {
3648
+					    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3649
+				    }
3650
+
3651
+				    if (substr($key, 0, 9 ) === 'metadata_') {
3652
+					    $real_key = str_replace('metadata_','', $key );
3653
+					    $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3654
+					    $value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3655
+				    }
3656
+			    }
3657
+    //			else if ( $args['type'] == 'popup' ) {
3658
+    //				$type = 'TextControl';
3659
+    //				$args['type'] == 'text';
3660
+    //				$after_elements .= "el( wp.components.Button, {
3661
+    //                          className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
3662
+    //                          onClick: function(){
3663
+    //							  aui_modal('','<input id=\'zzz\' value= />');
3664
+    //							  const source = document.getElementById('zzz');
3665
+    //							  source.value = props.attributes.$key;
3666
+    //							  source.addEventListener('input', function(e){props.setAttributes({ $key: e.target.value });});
3667
+    //                          }
3668
+    //                        },
3669
+    //                        'test'
3670
+    //                        ),";
3671
+    //
3672
+    //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3673
+    //			}
3674
+			    else if ( $args['type'] == 'styleid' ) {
3675
+				    $type = 'TextControl';
3676
+				    $args['type'] == 'text';
3677
+				    // Save numbers as numbers and not strings
3678
+				    $value     = "props.attributes.$key ? props.attributes.$key : ''";
3679
+			    }else if ( $args['type'] == 'notice' ) {
3680
+
3681
+				    $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3682
+				    $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3683
+
3684
+				    $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3685
+				    echo $notice_message ? $element_require . $notice : '';
3686
+				    return;
3687
+			    }
3688
+			    /*
3689 3689
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3690 3690
 						elseif($args['type']=='tabs'){
3691 3691
 							?>
@@ -3738,22 +3738,22 @@  discard block
 block discarded – undo
3738 3738
 							return;
3739 3739
 						}
3740 3740
 */
3741
-			elseif ( $args['type'] == 'color' ) {
3742
-				$type = 'ColorPicker';
3743
-				$onchange = "";
3744
-				$extra = "color: $value,";
3745
-				if(!empty($args['disable_alpha'])){
3746
-					$extra .= "disableAlpha: true,";
3747
-				}
3748
-				$onchangecomplete = "onChangeComplete: function($key) {
3741
+			    elseif ( $args['type'] == 'color' ) {
3742
+				    $type = 'ColorPicker';
3743
+				    $onchange = "";
3744
+				    $extra = "color: $value,";
3745
+				    if(!empty($args['disable_alpha'])){
3746
+					    $extra .= "disableAlpha: true,";
3747
+				    }
3748
+				    $onchangecomplete = "onChangeComplete: function($key) {
3749 3749
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3750 3750
 						props.setAttributes({
3751 3751
 							$key: value
3752 3752
 						});
3753 3753
 					},";
3754
-			}elseif ( $args['type'] == 'gradient' ) {
3755
-				$type = 'GradientPicker';
3756
-				$extra .= "gradients: [{
3754
+			    }elseif ( $args['type'] == 'gradient' ) {
3755
+				    $type = 'GradientPicker';
3756
+				    $extra .= "gradients: [{
3757 3757
 			name: 'Vivid cyan blue to vivid purple',
3758 3758
 			gradient:
3759 3759
 				'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
@@ -3790,10 +3790,10 @@  discard block
 block discarded – undo
3790 3790
 			slug: 'cool-to-warm-spectrum',
3791 3791
 		}],";
3792 3792
 
3793
-			}elseif ( $args['type'] == 'image' ) {
3794
-//                print_r($args);
3793
+			    }elseif ( $args['type'] == 'image' ) {
3794
+    //                print_r($args);
3795 3795
 
3796
-				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3796
+				    $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3797 3797
 							url:  props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4='  : props.attributes.$key,
3798 3798
 							value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3799 3799
 //                            value: props.attributes.{$key}_xy,
@@ -3814,16 +3814,16 @@  discard block
 block discarded – undo
3814 3814
 						}), ";
3815 3815
 
3816 3816
 
3817
-				$value = '""';
3818
-				$type = 'MediaUpload';
3819
-				$extra .= "onSelect: function(media){
3817
+				    $value = '""';
3818
+				    $type = 'MediaUpload';
3819
+				    $extra .= "onSelect: function(media){
3820 3820
 					  return props.setAttributes({
3821 3821
 						  $key: media.url,
3822 3822
 						  {$key}_id: media.id
3823 3823
 						});
3824 3824
 					  },";
3825
-				   $extra .= "type: 'image',";
3826
-				   $extra .= "render: function (obj) {
3825
+				       $extra .= "type: 'image',";
3826
+				       $extra .= "render: function (obj) {
3827 3827
 						return el( 'div',{},
3828 3828
 						( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3829 3829
 						  className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3849,11 +3849,11 @@  discard block
 block discarded – undo
3849 3849
 
3850 3850
 
3851 3851
 					  }";
3852
-				$onchange = "";
3852
+				    $onchange = "";
3853 3853
 
3854
-				//$inside_elements = ",el('div',{},'file upload')";
3855
-			} else if ( $args['type'] == 'images' ) {
3856
-				$img_preview = "props.attributes.$key && (function() {
3854
+				    //$inside_elements = ",el('div',{},'file upload')";
3855
+			    } else if ( $args['type'] == 'images' ) {
3856
+				    $img_preview = "props.attributes.$key && (function() {
3857 3857
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3858 3858
 	let images = [];
3859 3859
 	uploads.map((upload, index) => (
@@ -3880,9 +3880,9 @@  discard block
 block discarded – undo
3880 3880
 })(),";
3881 3881
 
3882 3882
 
3883
-				$value = '""';
3884
-				$type = 'MediaUpload';
3885
-				$extra .= "onSelect: function(media){
3883
+				    $value = '""';
3884
+				    $type = 'MediaUpload';
3885
+				    $extra .= "onSelect: function(media){
3886 3886
 	let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
3887 3887
 	if(media.length){
3888 3888
 		for (var i=0; i < media.length; i++) {
@@ -3895,9 +3895,9 @@  discard block
 block discarded – undo
3895 3895
 	}
3896 3896
 	return props.setAttributes({ $key: slimImagesV});
3897 3897
 },";
3898
-				$extra .= "type: 'image',";
3899
-				$extra .= "multiple: true,";
3900
-				$extra .= "render: function (obj) {
3898
+				    $extra .= "type: 'image',";
3899
+				    $extra .= "multiple: true,";
3900
+				    $extra .= "render: function (obj) {
3901 3901
 	/* Init the sort */
3902 3902
 	enableDragSort('sd-sortable');
3903 3903
 	return el( 'div',{},
@@ -3924,40 +3924,40 @@  discard block
 block discarded – undo
3924 3924
 		)
3925 3925
 	)
3926 3926
 }";
3927
-				$onchange = "";
3928
-
3929
-				//$inside_elements = ",el('div',{},'file upload')";
3930
-			}
3931
-			elseif ( $args['type'] == 'checkbox' ) {
3932
-				$type = 'CheckboxControl';
3933
-				$extra .= "checked: props.attributes.$key,";
3934
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
-			} elseif ( $args['type'] == 'textarea' ) {
3936
-				$type = 'TextareaControl';
3937
-
3938
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
-				$type = 'SelectControl';
3940
-
3941
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
-				}else {
3946
-
3947
-					if ( ! empty( $args['options'] ) ) {
3948
-						$options .= "options: [";
3949
-						foreach ( $args['options'] as $option_val => $option_label ) {
3950
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
-						}
3952
-						$options .= "],";
3953
-					}
3954
-				}
3955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
-				}
3958
-
3959
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3927
+				    $onchange = "";
3928
+
3929
+				    //$inside_elements = ",el('div',{},'file upload')";
3930
+			    }
3931
+			    elseif ( $args['type'] == 'checkbox' ) {
3932
+				    $type = 'CheckboxControl';
3933
+				    $extra .= "checked: props.attributes.$key,";
3934
+				    $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3935
+			    } elseif ( $args['type'] == 'textarea' ) {
3936
+				    $type = 'TextareaControl';
3937
+
3938
+			    } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3939
+				    $type = 'SelectControl';
3940
+
3941
+				    if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3942
+					    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3943
+				    }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3944
+					    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3945
+				    }else {
3946
+
3947
+					    if ( ! empty( $args['options'] ) ) {
3948
+						    $options .= "options: [";
3949
+						    foreach ( $args['options'] as $option_val => $option_label ) {
3950
+							    $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3951
+						    }
3952
+						    $options .= "],";
3953
+					    }
3954
+				    }
3955
+				    if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3956
+					    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3957
+				    }
3958
+
3959
+				    if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3960
+					    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3961 3961
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3962 3962
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3963 3963
 									  onClick: function(){
@@ -3968,56 +3968,56 @@  discard block
 block discarded – undo
3968 3968
 									},
3969 3969
 									'Clear'
3970 3970
 							),";
3971
-				}
3972
-			} elseif ( $args['type'] == 'tagselect' ) {
3973
-//				$type = 'FormTokenField';
3974
-//
3975
-//				if ( ! empty( $args['options'] ) ) {
3976
-//						$options .= "suggestions: [";
3977
-//						foreach ( $args['options'] as $option_val => $option_label ) {
3978
-//							$options .= "{ value: '" . esc_attr( $option_val ) . "', title: '" . addslashes( $option_label ) . "' },";
3979
-////							$options .= "'" . esc_attr( $option_val ) . "':'" . addslashes( $option_label ) . "',";
3980
-//						}
3981
-//						$options .= "],";
3982
-//				}
3983
-//
3984
-//				$onchangex  = "{ ( selectedItems ) => {
3985
-//						// Build array of selected posts.
3986
-//						let selectedPostsArray = [];
3987
-//						selectedPosts.map(
3988
-//							( postName ) => {
3989
-//								const matchingPost = posts.find( ( post ) => {
3990
-//									return post.title.raw === postName;
3991
-//
3992
-//								} );
3993
-//								if ( matchingPost !== undefined ) {
3994
-//									selectedPostsArray.push( matchingPost.id );
3995
-//								}
3996
-//							}
3997
-//						)
3998
-//
3999
-//						setAttributes( { selectedPosts: selectedPostsArray } );
4000
-//					} } ";
4001
-//				$onchange  = '';// "props.setAttributes({ $key: [ props.attributes.$key ] } )";
4002
-//
4003
-////				$options  = "";
4004
-//				$value     = "[]";
4005
-//				$extra .= ' __experimentalExpandOnFocus: true,';
4006
-
4007
-			} else if ( $args['type'] == 'alignment' ) {
4008
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
-			} else if ( $args['type'] == 'margins' ) {
4010
-
4011
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
-				$type = 'TextControl';
4013
-				$value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
-				$args['type'] = 'text';
4015
-				$options .= 'disabled:true,';
4016
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
-				$bsvc_body = $this->block_visibility_fields( $args );
4018
-				// @TODO reset button
4019
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
4020
-				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3971
+				    }
3972
+			    } elseif ( $args['type'] == 'tagselect' ) {
3973
+    //				$type = 'FormTokenField';
3974
+    //
3975
+    //				if ( ! empty( $args['options'] ) ) {
3976
+    //						$options .= "suggestions: [";
3977
+    //						foreach ( $args['options'] as $option_val => $option_label ) {
3978
+    //							$options .= "{ value: '" . esc_attr( $option_val ) . "', title: '" . addslashes( $option_label ) . "' },";
3979
+    ////							$options .= "'" . esc_attr( $option_val ) . "':'" . addslashes( $option_label ) . "',";
3980
+    //						}
3981
+    //						$options .= "],";
3982
+    //				}
3983
+    //
3984
+    //				$onchangex  = "{ ( selectedItems ) => {
3985
+    //						// Build array of selected posts.
3986
+    //						let selectedPostsArray = [];
3987
+    //						selectedPosts.map(
3988
+    //							( postName ) => {
3989
+    //								const matchingPost = posts.find( ( post ) => {
3990
+    //									return post.title.raw === postName;
3991
+    //
3992
+    //								} );
3993
+    //								if ( matchingPost !== undefined ) {
3994
+    //									selectedPostsArray.push( matchingPost.id );
3995
+    //								}
3996
+    //							}
3997
+    //						)
3998
+    //
3999
+    //						setAttributes( { selectedPosts: selectedPostsArray } );
4000
+    //					} } ";
4001
+    //				$onchange  = '';// "props.setAttributes({ $key: [ props.attributes.$key ] } )";
4002
+    //
4003
+    ////				$options  = "";
4004
+    //				$value     = "[]";
4005
+    //				$extra .= ' __experimentalExpandOnFocus: true,';
4006
+
4007
+			    } else if ( $args['type'] == 'alignment' ) {
4008
+				    $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
4009
+			    } else if ( $args['type'] == 'margins' ) {
4010
+
4011
+			    } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
4012
+				    $type = 'TextControl';
4013
+				    $value = "(props.attributes.$key ? props.attributes.$key : '')";
4014
+				    $args['type'] = 'text';
4015
+				    $options .= 'disabled:true,';
4016
+				    $bsvc_title = esc_attr( addslashes( $args['title'] ) );
4017
+				    $bsvc_body = $this->block_visibility_fields( $args );
4018
+				    // @TODO reset button
4019
+				    $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
4020
+				    $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
4021 4021
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
4022 4022
 						onClick: function() {
4023 4023
 							var sValue = props.attributes." . $key . ";
@@ -4043,54 +4043,54 @@  discard block
 block discarded – undo
4043 4043
 					},
4044 4044
 					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
4045 4045
 				) ),";
4046
-			} else {
4047
-				return;// if we have not implemented the control then don't break the JS.
4048
-			}
4049
-
4050
-			// color input does not show the labels so we add them
4051
-			if($args['type']=='color'){
4052
-				// add show only if advanced
4053
-				echo $require_advanced;
4054
-				// add setting require if defined
4055
-				echo $element_require;
4056
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
-			}
4058
-
4059
-			// add show only if advanced
4060
-			echo $require_advanced;
4061
-			// add setting require if defined
4062
-			echo $element_require;
4063
-			echo $device_type_require;
4064
-
4065
-			// icon
4066
-			echo $icon;
4067
-			?>
4068
-			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4046
+			    } else {
4047
+				    return;// if we have not implemented the control then don't break the JS.
4048
+			    }
4049
+
4050
+			    // color input does not show the labels so we add them
4051
+			    if($args['type']=='color'){
4052
+				    // add show only if advanced
4053
+				    echo $require_advanced;
4054
+				    // add setting require if defined
4055
+				    echo $element_require;
4056
+				    echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4057
+			    }
4058
+
4059
+			    // add show only if advanced
4060
+			    echo $require_advanced;
4061
+			    // add setting require if defined
4062
+			    echo $element_require;
4063
+			    echo $device_type_require;
4064
+
4065
+			    // icon
4066
+			    echo $icon;
4067
+			    ?>
4068
+    			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4069 4069
 			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4070
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4070
+			    } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4071 4071
 			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4072 4072
 			value: <?php echo $value; ?>,
4073 4073
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4074
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4075
-			} ?>
4076
-			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
-			} ?>
4079
-			<?php echo $options; ?>
4080
-			<?php echo $extra; ?>
4081
-			<?php echo $custom_attributes; ?>
4082
-			<?php echo $onchangecomplete; ?>
4083
-			<?php if ( $onchange ) { ?>
4084
-			onChange: function ( <?php echo $key; ?> ) {
4074
+				    echo "type: '" . addslashes( $args['type'] ) . "',";
4075
+			    } ?>
4076
+    			<?php if ( ! empty( $args['placeholder'] ) ) {
4077
+				    echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4078
+			    } ?>
4079
+    			<?php echo $options; ?>
4080
+    			<?php echo $extra; ?>
4081
+    			<?php echo $custom_attributes; ?>
4082
+    			<?php echo $onchangecomplete; ?>
4083
+    			<?php if ( $onchange ) { ?>
4084
+    			onChange: function ( <?php echo $key; ?> ) {
4085 4085
 				<?php echo $onchange; ?>
4086
-			}
4086
+    			}
4087 4087
 			<?php } ?>
4088
-		} <?php echo $inside_elements; ?> ),
4088
+    		} <?php echo $inside_elements; ?> ),
4089 4089
 			<?php
4090
-			echo $after_elements;
4091
-		}
4090
+			    echo $after_elements;
4091
+		    }
4092 4092
 
4093
-		/**
4093
+		    /**
4094 4094
 		 * Convert an array of attributes to block string.
4095 4095
 		 *
4096 4096
 		 * @param $custom_attributes
@@ -4099,448 +4099,448 @@  discard block
 block discarded – undo
4099 4099
 		 *@todo there is prob a faster way to do this, also we could add some validation here.
4100 4100
 		 *
4101 4101
 		 */
4102
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4103
-			$attributes = '';
4104
-			if ( ! empty( $custom_attributes ) ) {
4102
+		    public function array_to_attributes( $custom_attributes, $html = false ) {
4103
+			    $attributes = '';
4104
+			    if ( ! empty( $custom_attributes ) ) {
4105 4105
 
4106
-				foreach ( $custom_attributes as $key => $val ) {
4107
-					if(is_array($val)){
4108
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
-					}else{
4110
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
-					}
4112
-				}
4106
+				    foreach ( $custom_attributes as $key => $val ) {
4107
+					    if(is_array($val)){
4108
+						    $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4109
+					    }else{
4110
+						    $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4111
+					    }
4112
+				    }
4113 4113
 
4114
-			}
4114
+			    }
4115 4115
 
4116
-			return $attributes;
4117
-		}
4116
+			    return $attributes;
4117
+		    }
4118 4118
 
4119 4119
 
4120 4120
 
4121
-		/**
4121
+		    /**
4122 4122
 		 * A self looping function to create the output for JS block elements.
4123 4123
 		 *
4124 4124
 		 * This is what is output in the WP Editor visual view.
4125 4125
 		 *
4126 4126
 		 * @param $args
4127 4127
 		 */
4128
-		public function block_element( $args, $save = false ) {
4129
-
4130
-//            print_r($args);echo '###';exit;
4131
-
4132
-			if ( ! empty( $args ) ) {
4133
-				foreach ( $args as $element => $new_args ) {
4134
-
4135
-					if ( is_array( $new_args ) ) { // its an element
4128
+		    public function block_element( $args, $save = false ) {
4129
+
4130
+    //            print_r($args);echo '###';exit;
4131
+
4132
+			    if ( ! empty( $args ) ) {
4133
+				    foreach ( $args as $element => $new_args ) {
4134
+
4135
+					    if ( is_array( $new_args ) ) { // its an element
4136
+
4136 4137
 
4138
+						    if ( isset( $new_args['element'] ) ) {
4137 4139
 
4138
-						if ( isset( $new_args['element'] ) ) {
4139
-
4140
-							if ( isset( $new_args['element_require'] ) ) {
4141
-								echo str_replace( array(
4142
-										"'+",
4143
-										"+'"
4144
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
-								unset( $new_args['element_require'] );
4146
-							}
4147
-
4148
-							if($new_args['element']=='InnerBlocks'){
4149
-								echo "\n el( InnerBlocks, {";
4150
-							}elseif($new_args['element']=='innerBlocksProps'){
4151
-								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
-							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153
-//                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154
-								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
-								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
-
4158
-								echo "} ), {";
4159
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
-							//    echo '###';
4161
-
4162
-							  //  echo '###';
4163
-							}elseif($new_args['element']=='BlocksProps'){
4164
-
4165
-								if ( isset($new_args['if_inner_element']) ) {
4166
-									$element = $new_args['if_inner_element'];
4167
-								}else {
4168
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
-								}
4170
-
4171
-								unset($new_args['inner_element']);
4172
-								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
-
4175
-
4176
-							   // echo "} ),";
4177
-
4178
-							}else{
4179
-								echo "\n el( '" . $new_args['element'] . "', {";
4180
-							}
4181
-
4182
-
4183
-							// get the attributes
4184
-							foreach ( $new_args as $new_key => $new_value ) {
4185
-
4186
-
4187
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
-									// do nothing
4189
-								} else {
4190
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4191
-								}
4192
-							}
4193
-
4194
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
-
4196
-							// get the content
4197
-							$first_item = 0;
4198
-							foreach ( $new_args as $new_key => $new_value ) {
4199
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
-
4201
-									if ( $new_key === 'content' ) {
4202
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
-									}else if ( $new_key === 'if_content' ) {
4204
-										echo  $this->block_props_replace(  $new_value  );
4205
-									}
4206
-
4207
-									if ( is_array( $new_value ) ) {
4208
-
4209
-										if ( isset( $new_value['element_require'] ) ) {
4210
-											echo str_replace( array(
4211
-													"'+",
4212
-													"+'"
4213
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
-											unset( $new_value['element_require'] );
4215
-										}
4216
-
4217
-										if ( isset( $new_value['element_repeat'] ) ) {
4218
-											$x = 1;
4219
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
-												$this->block_element( array( '' => $new_value ),$save );
4221
-												$x ++;
4222
-											}
4223
-										} else {
4224
-											$this->block_element( array( '' => $new_value ),$save );
4225
-										}
4226
-									}
4227
-									$first_item ++;
4228
-								}
4229
-							}
4230
-
4231
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
-								echo "))";// end content
4233
-							}else{
4234
-								echo ")";// end content
4235
-							}
4236
-
4237
-
4238
-							echo ", \n";
4239
-
4240
-						}
4241
-					} else {
4242
-
4243
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4244
-							$extra = '';
4245
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
-							}
4249
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4253
-//                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
-						} elseif ( $element == 'style' ) {
4255
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4258
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
-						} elseif ( $element == 'template' && $new_args ) {
4260
-							echo $element . ": $new_args,";
4261
-						} else {
4262
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
-						}
4264
-
4265
-					}
4266
-				}
4267
-			}
4268
-		}
4269
-
4270
-		/**
4140
+							    if ( isset( $new_args['element_require'] ) ) {
4141
+								    echo str_replace( array(
4142
+										    "'+",
4143
+										    "+'"
4144
+									    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4145
+								    unset( $new_args['element_require'] );
4146
+							    }
4147
+
4148
+							    if($new_args['element']=='InnerBlocks'){
4149
+								    echo "\n el( InnerBlocks, {";
4150
+							    }elseif($new_args['element']=='innerBlocksProps'){
4151
+								    $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4152
+							      //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4153
+    //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4154
+								    echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4155
+								    echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4156
+								    echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4157
+
4158
+								    echo "} ), {";
4159
+								    echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4160
+							    //    echo '###';
4161
+
4162
+							      //  echo '###';
4163
+							    }elseif($new_args['element']=='BlocksProps'){
4164
+
4165
+								    if ( isset($new_args['if_inner_element']) ) {
4166
+									    $element = $new_args['if_inner_element'];
4167
+								    }else {
4168
+									    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4169
+								    }
4170
+
4171
+								    unset($new_args['inner_element']);
4172
+								    echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4173
+								    echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4174
+
4175
+
4176
+							       // echo "} ),";
4177
+
4178
+							    }else{
4179
+								    echo "\n el( '" . $new_args['element'] . "', {";
4180
+							    }
4181
+
4182
+
4183
+							    // get the attributes
4184
+							    foreach ( $new_args as $new_key => $new_value ) {
4185
+
4186
+
4187
+								    if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4188
+									    // do nothing
4189
+								    } else {
4190
+									    echo $this->block_element( array( $new_key => $new_value ),$save );
4191
+								    }
4192
+							    }
4193
+
4194
+							    echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4195
+
4196
+							    // get the content
4197
+							    $first_item = 0;
4198
+							    foreach ( $new_args as $new_key => $new_value ) {
4199
+								    if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4200
+
4201
+									    if ( $new_key === 'content' ) {
4202
+										    echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4203
+									    }else if ( $new_key === 'if_content' ) {
4204
+										    echo  $this->block_props_replace(  $new_value  );
4205
+									    }
4206
+
4207
+									    if ( is_array( $new_value ) ) {
4208
+
4209
+										    if ( isset( $new_value['element_require'] ) ) {
4210
+											    echo str_replace( array(
4211
+													    "'+",
4212
+													    "+'"
4213
+												    ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4214
+											    unset( $new_value['element_require'] );
4215
+										    }
4216
+
4217
+										    if ( isset( $new_value['element_repeat'] ) ) {
4218
+											    $x = 1;
4219
+											    while ( $x <= absint( $new_value['element_repeat'] ) ) {
4220
+												    $this->block_element( array( '' => $new_value ),$save );
4221
+												    $x ++;
4222
+											    }
4223
+										    } else {
4224
+											    $this->block_element( array( '' => $new_value ),$save );
4225
+										    }
4226
+									    }
4227
+									    $first_item ++;
4228
+								    }
4229
+							    }
4230
+
4231
+							    if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4232
+								    echo "))";// end content
4233
+							    }else{
4234
+								    echo ")";// end content
4235
+							    }
4236
+
4237
+
4238
+							    echo ", \n";
4239
+
4240
+						    }
4241
+					    } else {
4242
+
4243
+						    if ( substr( $element, 0, 3 ) === "if_" ) {
4244
+							    $extra = '';
4245
+							    if( strpos($new_args, '[%WrapClass%]') !== false ){
4246
+								    $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4247
+								    $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4248
+							    }
4249
+							    echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4250
+						    } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4251
+							    $new_args = str_replace('[%WrapStyle%]','',$new_args);
4252
+							    echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4253
+    //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4254
+						    } elseif ( $element == 'style' ) {
4255
+							    echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4256
+						    } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4257
+							    $new_args = str_replace('[%WrapClass%]','',$new_args);
4258
+							    echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4259
+						    } elseif ( $element == 'template' && $new_args ) {
4260
+							    echo $element . ": $new_args,";
4261
+						    } else {
4262
+							    echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4263
+						    }
4264
+
4265
+					    }
4266
+				    }
4267
+			    }
4268
+		    }
4269
+
4270
+		    /**
4271 4271
 		 * Replace block attributes placeholders with the proper naming.
4272 4272
 		 *
4273 4273
 		 * @param $string
4274 4274
 		 *
4275 4275
 		 * @return mixed
4276 4276
 		 */
4277
-		public function block_props_replace( $string, $no_wrap = false ) {
4278
-			if ( $no_wrap ) {
4279
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
-			} else {
4281
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
-			}
4277
+		    public function block_props_replace( $string, $no_wrap = false ) {
4278
+			    if ( $no_wrap ) {
4279
+				    $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4280
+			    } else {
4281
+				    $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4282
+			    }
4283 4283
 
4284
-			return $string;
4285
-		}
4284
+			    return $string;
4285
+		    }
4286 4286
 
4287
-		/**
4287
+		    /**
4288 4288
 		 * Outputs the content of the widget
4289 4289
 		 *
4290 4290
 		 * @param array $args
4291 4291
 		 * @param array $instance
4292 4292
 		 */
4293
-		public function widget( $args, $instance ) {
4294
-			if ( ! is_array( $args ) ) {
4295
-				$args = array();
4296
-			}
4297
-
4298
-			// Get the filtered values
4299
-			$argument_values = $this->argument_values( $instance );
4300
-			$argument_values = $this->string_to_bool( $argument_values );
4301
-			$output          = $this->output( $argument_values, $args );
4302
-
4303
-			$no_wrap = false;
4304
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
-				$no_wrap = true;
4306
-			}
4307
-
4308
-			ob_start();
4309
-			if ( $output && ! $no_wrap ) {
4310
-
4311
-				$class_original = $this->options['widget_ops']['classname'];
4312
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4313
-
4314
-				// Before widget
4315
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4319
-
4320
-				// After widget
4321
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4324
-
4325
-				echo $before_widget;
4326
-				// elementor strips the widget wrapping div so we check for and add it back if needed
4327
-				if ( $this->is_elementor_widget_output() ) {
4328
-					// Filter class & attrs for elementor widget output.
4329
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4331
-
4332
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4334
-
4335
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
-				}
4337
-				echo $this->output_title( $args, $instance );
4338
-				echo $output;
4339
-				if ( $this->is_elementor_widget_output() ) {
4340
-					echo "</span>";
4341
-				}
4342
-				echo $after_widget;
4343
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
-				echo $output;
4346
-			} elseif ( $output && $no_wrap ) {
4347
-				echo $output;
4348
-			}
4349
-			$output = ob_get_clean();
4350
-
4351
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4352
-
4353
-			echo $output;
4354
-		}
4355
-
4356
-		/**
4293
+		    public function widget( $args, $instance ) {
4294
+			    if ( ! is_array( $args ) ) {
4295
+				    $args = array();
4296
+			    }
4297
+
4298
+			    // Get the filtered values
4299
+			    $argument_values = $this->argument_values( $instance );
4300
+			    $argument_values = $this->string_to_bool( $argument_values );
4301
+			    $output          = $this->output( $argument_values, $args );
4302
+
4303
+			    $no_wrap = false;
4304
+			    if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4305
+				    $no_wrap = true;
4306
+			    }
4307
+
4308
+			    ob_start();
4309
+			    if ( $output && ! $no_wrap ) {
4310
+
4311
+				    $class_original = $this->options['widget_ops']['classname'];
4312
+				    $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4313
+
4314
+				    // Before widget
4315
+				    $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4316
+				    $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4317
+				    $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4318
+				    $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4319
+
4320
+				    // After widget
4321
+				    $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4322
+				    $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4323
+				    $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4324
+
4325
+				    echo $before_widget;
4326
+				    // elementor strips the widget wrapping div so we check for and add it back if needed
4327
+				    if ( $this->is_elementor_widget_output() ) {
4328
+					    // Filter class & attrs for elementor widget output.
4329
+					    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4330
+					    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4331
+
4332
+					    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4333
+					    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4334
+
4335
+					    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4336
+				    }
4337
+				    echo $this->output_title( $args, $instance );
4338
+				    echo $output;
4339
+				    if ( $this->is_elementor_widget_output() ) {
4340
+					    echo "</span>";
4341
+				    }
4342
+				    echo $after_widget;
4343
+			    } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4344
+				    $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4345
+				    echo $output;
4346
+			    } elseif ( $output && $no_wrap ) {
4347
+				    echo $output;
4348
+			    }
4349
+			    $output = ob_get_clean();
4350
+
4351
+			    $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4352
+
4353
+			    echo $output;
4354
+		    }
4355
+
4356
+		    /**
4357 4357
 		 * Tests if the current output is inside a elementor container.
4358 4358
 		 *
4359 4359
 		 * @return bool
4360 4360
 		 *@since 1.0.4
4361 4361
 		 */
4362
-		public function is_elementor_widget_output() {
4363
-			$result = false;
4364
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
-				$result = true;
4366
-			}
4362
+		    public function is_elementor_widget_output() {
4363
+			    $result = false;
4364
+			    if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4365
+				    $result = true;
4366
+			    }
4367 4367
 
4368
-			return $result;
4369
-		}
4368
+			    return $result;
4369
+		    }
4370 4370
 
4371
-		/**
4371
+		    /**
4372 4372
 		 * Tests if the current output is inside a elementor preview.
4373 4373
 		 *
4374 4374
 		 * @return bool
4375 4375
 		 *@since 1.0.4
4376 4376
 		 */
4377
-		public function is_elementor_preview() {
4378
-			$result = false;
4379
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
-				$result = true;
4381
-			}
4377
+		    public function is_elementor_preview() {
4378
+			    $result = false;
4379
+			    if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4380
+				    $result = true;
4381
+			    }
4382 4382
 
4383
-			return $result;
4384
-		}
4383
+			    return $result;
4384
+		    }
4385 4385
 
4386
-		/**
4386
+		    /**
4387 4387
 		 * Tests if the current output is inside a Divi preview.
4388 4388
 		 *
4389 4389
 		 * @return bool
4390 4390
 		 *@since 1.0.6
4391 4391
 		 */
4392
-		public function is_divi_preview() {
4393
-			$result = false;
4394
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
-				$result = true;
4396
-			}
4392
+		    public function is_divi_preview() {
4393
+			    $result = false;
4394
+			    if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4395
+				    $result = true;
4396
+			    }
4397 4397
 
4398
-			return $result;
4399
-		}
4398
+			    return $result;
4399
+		    }
4400 4400
 
4401
-		/**
4401
+		    /**
4402 4402
 		 * Tests if the current output is inside a Beaver builder preview.
4403 4403
 		 *
4404 4404
 		 * @return bool
4405 4405
 		 *@since 1.0.6
4406 4406
 		 */
4407
-		public function is_beaver_preview() {
4408
-			$result = false;
4409
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
-				$result = true;
4411
-			}
4407
+		    public function is_beaver_preview() {
4408
+			    $result = false;
4409
+			    if ( isset( $_REQUEST['fl_builder'] ) ) {
4410
+				    $result = true;
4411
+			    }
4412 4412
 
4413
-			return $result;
4414
-		}
4413
+			    return $result;
4414
+		    }
4415 4415
 
4416
-		/**
4416
+		    /**
4417 4417
 		 * Tests if the current output is inside a siteorigin builder preview.
4418 4418
 		 *
4419 4419
 		 * @return bool
4420 4420
 		 *@since 1.0.6
4421 4421
 		 */
4422
-		public function is_siteorigin_preview() {
4423
-			$result = false;
4424
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
-				$result = true;
4426
-			}
4422
+		    public function is_siteorigin_preview() {
4423
+			    $result = false;
4424
+			    if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4425
+				    $result = true;
4426
+			    }
4427 4427
 
4428
-			return $result;
4429
-		}
4428
+			    return $result;
4429
+		    }
4430 4430
 
4431
-		/**
4431
+		    /**
4432 4432
 		 * Tests if the current output is inside a cornerstone builder preview.
4433 4433
 		 *
4434 4434
 		 * @return bool
4435 4435
 		 *@since 1.0.8
4436 4436
 		 */
4437
-		public function is_cornerstone_preview() {
4438
-			$result = false;
4439
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
-				$result = true;
4441
-			}
4437
+		    public function is_cornerstone_preview() {
4438
+			    $result = false;
4439
+			    if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4440
+				    $result = true;
4441
+			    }
4442 4442
 
4443
-			return $result;
4444
-		}
4443
+			    return $result;
4444
+		    }
4445 4445
 
4446
-		/**
4446
+		    /**
4447 4447
 		 * Tests if the current output is inside a fusion builder preview.
4448 4448
 		 *
4449 4449
 		 * @return bool
4450 4450
 		 *@since 1.1.0
4451 4451
 		 */
4452
-		public function is_fusion_preview() {
4453
-			$result = false;
4454
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
-				$result = true;
4456
-			}
4452
+		    public function is_fusion_preview() {
4453
+			    $result = false;
4454
+			    if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4455
+				    $result = true;
4456
+			    }
4457 4457
 
4458
-			return $result;
4459
-		}
4458
+			    return $result;
4459
+		    }
4460 4460
 
4461
-		/**
4461
+		    /**
4462 4462
 		 * Tests if the current output is inside a Oxygen builder preview.
4463 4463
 		 *
4464 4464
 		 * @return bool
4465 4465
 		 *@since 1.0.18
4466 4466
 		 */
4467
-		public function is_oxygen_preview() {
4468
-			$result = false;
4469
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
-				$result = true;
4471
-			}
4467
+		    public function is_oxygen_preview() {
4468
+			    $result = false;
4469
+			    if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4470
+				    $result = true;
4471
+			    }
4472 4472
 
4473
-			return $result;
4474
-		}
4473
+			    return $result;
4474
+		    }
4475 4475
 
4476
-		/**
4476
+		    /**
4477 4477
 		 * Check for Kallyas theme Zion builder preview.
4478 4478
 		 *
4479 4479
 		 * @since 1.1.22
4480 4480
 		 *
4481 4481
 		 * @return bool True when preview page otherwise false.
4482 4482
 		 */
4483
-		public function is_kallyas_zion_preview() {
4484
-			$result = false;
4483
+		    public function is_kallyas_zion_preview() {
4484
+			    $result = false;
4485 4485
 
4486
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
-				$result = true;
4488
-			}
4486
+			    if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4487
+				    $result = true;
4488
+			    }
4489 4489
 
4490
-			return $result;
4491
-		}
4490
+			    return $result;
4491
+		    }
4492 4492
 
4493
-		/**
4493
+		    /**
4494 4494
 		 * Check for Bricks theme builder preview.
4495 4495
 		 *
4496 4496
 		 * @since 1.1.31
4497 4497
 		 *
4498 4498
 		 * @return bool True when preview page otherwise false.
4499 4499
 		 */
4500
-		public function is_bricks_preview() {
4501
-			$result = false;
4500
+		    public function is_bricks_preview() {
4501
+			    $result = false;
4502 4502
 
4503
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
-				$result = true;
4505
-			}
4503
+			    if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4504
+				    $result = true;
4505
+			    }
4506 4506
 
4507
-			return $result;
4508
-		}
4507
+			    return $result;
4508
+		    }
4509 4509
 
4510
-		/**
4510
+		    /**
4511 4511
 		 * General function to check if we are in a preview situation.
4512 4512
 		 *
4513 4513
 		 * @return bool
4514 4514
 		 *@since 1.0.6
4515 4515
 		 */
4516
-		public function is_preview() {
4517
-			$preview = false;
4518
-			if ( $this->is_divi_preview() ) {
4519
-				$preview = true;
4520
-			} elseif ( $this->is_elementor_preview() ) {
4521
-				$preview = true;
4522
-			} elseif ( $this->is_beaver_preview() ) {
4523
-				$preview = true;
4524
-			} elseif ( $this->is_siteorigin_preview() ) {
4525
-				$preview = true;
4526
-			} elseif ( $this->is_cornerstone_preview() ) {
4527
-				$preview = true;
4528
-			} elseif ( $this->is_fusion_preview() ) {
4529
-				$preview = true;
4530
-			} elseif ( $this->is_oxygen_preview() ) {
4531
-				$preview = true;
4532
-			} elseif( $this->is_kallyas_zion_preview() ) {
4533
-				$preview = true;
4534
-			} elseif( $this->is_block_content_call() ) {
4535
-				$preview = true;
4536
-			} elseif( $this->is_bricks_preview() ) {
4537
-				$preview = true;
4538
-			}
4539
-
4540
-			return $preview;
4541
-		}
4542
-
4543
-		/**
4516
+		    public function is_preview() {
4517
+			    $preview = false;
4518
+			    if ( $this->is_divi_preview() ) {
4519
+				    $preview = true;
4520
+			    } elseif ( $this->is_elementor_preview() ) {
4521
+				    $preview = true;
4522
+			    } elseif ( $this->is_beaver_preview() ) {
4523
+				    $preview = true;
4524
+			    } elseif ( $this->is_siteorigin_preview() ) {
4525
+				    $preview = true;
4526
+			    } elseif ( $this->is_cornerstone_preview() ) {
4527
+				    $preview = true;
4528
+			    } elseif ( $this->is_fusion_preview() ) {
4529
+				    $preview = true;
4530
+			    } elseif ( $this->is_oxygen_preview() ) {
4531
+				    $preview = true;
4532
+			    } elseif( $this->is_kallyas_zion_preview() ) {
4533
+				    $preview = true;
4534
+			    } elseif( $this->is_block_content_call() ) {
4535
+				    $preview = true;
4536
+			    } elseif( $this->is_bricks_preview() ) {
4537
+				    $preview = true;
4538
+			    }
4539
+
4540
+			    return $preview;
4541
+		    }
4542
+
4543
+		    /**
4544 4544
 		 * Output the super title.
4545 4545
 		 *
4546 4546
 		 * @param $args
@@ -4548,174 +4548,174 @@  discard block
 block discarded – undo
4548 4548
 		 *
4549 4549
 		 * @return string
4550 4550
 		 */
4551
-		public function output_title( $args, $instance = array() ) {
4552
-			$output = '';
4553
-			if ( ! empty( $instance['title'] ) ) {
4554
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
-
4557
-				if ( empty( $instance['widget_title_tag'] ) ) {
4558
-					if ( ! isset( $args['before_title'] ) ) {
4559
-						$args['before_title'] = '';
4560
-					}
4561
-
4562
-					if ( ! isset( $args['after_title'] ) ) {
4563
-						$args['after_title'] = '';
4564
-					}
4565
-
4566
-					$output = $args['before_title'] . $title . $args['after_title'];
4567
-				} else {
4568
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4569
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
-
4572
-					// classes
4573
-					$title_classes = array();
4574
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
-
4588
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
4590
-				}
4591
-
4592
-			}
4593
-
4594
-			return $output;
4595
-		}
4596
-
4597
-		/**
4551
+		    public function output_title( $args, $instance = array() ) {
4552
+			    $output = '';
4553
+			    if ( ! empty( $instance['title'] ) ) {
4554
+				    /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4555
+				    $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4556
+
4557
+				    if ( empty( $instance['widget_title_tag'] ) ) {
4558
+					    if ( ! isset( $args['before_title'] ) ) {
4559
+						    $args['before_title'] = '';
4560
+					    }
4561
+
4562
+					    if ( ! isset( $args['after_title'] ) ) {
4563
+						    $args['after_title'] = '';
4564
+					    }
4565
+
4566
+					    $output = $args['before_title'] . $title . $args['after_title'];
4567
+				    } else {
4568
+					    $tag 			= esc_attr( $instance['widget_title_tag'] );
4569
+					    $allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4570
+					    $title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4571
+
4572
+					    // classes
4573
+					    $title_classes = array();
4574
+					    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4575
+					    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4576
+					    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4577
+					    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4578
+					    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4579
+					    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4580
+					    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4581
+					    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4582
+					    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4583
+					    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4584
+					    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4585
+					    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4586
+					    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4587
+
4588
+					    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4589
+					    $output = "<$title_tag class='$class' >$title</$title_tag>";
4590
+				    }
4591
+
4592
+			    }
4593
+
4594
+			    return $output;
4595
+		    }
4596
+
4597
+		    /**
4598 4598
 		 * Outputs the options form inputs for the widget.
4599 4599
 		 *
4600 4600
 		 * @param array $instance The widget options.
4601 4601
 		 */
4602
-		public function form( $instance ) {
4602
+		    public function form( $instance ) {
4603 4603
 
4604
-			// set widget instance
4605
-			$this->instance = $instance;
4604
+			    // set widget instance
4605
+			    $this->instance = $instance;
4606 4606
 
4607
-			// set it as a SD widget
4608
-			echo $this->widget_advanced_toggle();
4607
+			    // set it as a SD widget
4608
+			    echo $this->widget_advanced_toggle();
4609 4609
 
4610
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
-			$arguments_raw = $this->get_arguments();
4610
+			    echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4611
+			    $arguments_raw = $this->get_arguments();
4612 4612
 
4613
-			if ( is_array( $arguments_raw ) ) {
4613
+			    if ( is_array( $arguments_raw ) ) {
4614 4614
 
4615
-				$arguments = $this->group_arguments( $arguments_raw );
4615
+				    $arguments = $this->group_arguments( $arguments_raw );
4616 4616
 
4617
-				// Do we have sections?
4618
-				$has_sections = $arguments == $arguments_raw ? false : true;
4617
+				    // Do we have sections?
4618
+				    $has_sections = $arguments == $arguments_raw ? false : true;
4619 4619
 
4620 4620
 
4621
-				if ( $has_sections ) {
4622
-					$panel_count = 0;
4623
-					foreach ( $arguments as $key => $args ) {
4621
+				    if ( $has_sections ) {
4622
+					    $panel_count = 0;
4623
+					    foreach ( $arguments as $key => $args ) {
4624 4624
 
4625
-						?>
4625
+						    ?>
4626 4626
 						<script>
4627 4627
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
4628 4628
 						</script>
4629 4629
 						<?php
4630 4630
 
4631
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
4632
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4631
+						    $hide       = $panel_count ? ' style="display:none;" ' : '';
4632
+						    $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4633
+						    echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4634
+						    echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4635 4635
 
4636
-						foreach ( $args as $k => $a ) {
4636
+						    foreach ( $args as $k => $a ) {
4637 4637
 
4638
-							$this->widget_inputs_row_start($k, $a);
4639
-							$this->widget_inputs( $a, $instance );
4640
-							$this->widget_inputs_row_end($k, $a);
4638
+							    $this->widget_inputs_row_start($k, $a);
4639
+							    $this->widget_inputs( $a, $instance );
4640
+							    $this->widget_inputs_row_end($k, $a);
4641 4641
 
4642
-						}
4642
+						    }
4643 4643
 
4644
-						echo "</div>";
4644
+						    echo "</div>";
4645 4645
 
4646
-						$panel_count ++;
4646
+						    $panel_count ++;
4647 4647
 
4648
-					}
4649
-				} else {
4650
-					foreach ( $arguments as $key => $args ) {
4651
-						$this->widget_inputs_row_start($key, $args);
4652
-						$this->widget_inputs( $args, $instance );
4653
-						$this->widget_inputs_row_end($key, $args);
4654
-					}
4655
-				}
4648
+					    }
4649
+				    } else {
4650
+					    foreach ( $arguments as $key => $args ) {
4651
+						    $this->widget_inputs_row_start($key, $args);
4652
+						    $this->widget_inputs( $args, $instance );
4653
+						    $this->widget_inputs_row_end($key, $args);
4654
+					    }
4655
+				    }
4656 4656
 
4657
-			}
4658
-		}
4657
+			    }
4658
+		    }
4659 4659
 
4660
-		public function widget_inputs_row_start( $key, $args ) {
4661
-			if ( ! empty( $args['row'] ) ) {
4662
-				// Maybe open
4663
-				if ( ! empty( $args['row']['open'] ) ) {
4664
-					?>
4665
-					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4660
+		    public function widget_inputs_row_start( $key, $args ) {
4661
+			    if ( ! empty( $args['row'] ) ) {
4662
+				    // Maybe open
4663
+				    if ( ! empty( $args['row']['open'] ) ) {
4664
+					    ?>
4665
+    					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4666 4666
 					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4667
-					<?php
4668
-						if ( isset( $args['row']['icon'] ) ) {
4669
-							$args['row']['icon'] = '';
4670
-						}
4671
-
4672
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
-							$args['row']['device_type'] = $args['device_type'];
4674
-						}
4675
-					?>
4676
-					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4667
+    					<?php
4668
+						    if ( isset( $args['row']['icon'] ) ) {
4669
+							    $args['row']['icon'] = '';
4670
+						    }
4671
+
4672
+						    if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4673
+							    $args['row']['device_type'] = $args['device_type'];
4674
+						    }
4675
+					    ?>
4676
+    					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4677 4677
 					<?php } ?>
4678
-					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4678
+    					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4679 4679
 					<div class='col pr-2'>
4680 4680
 					<?php
4681
-				} else if ( ! empty( $args['row']['close'] ) ) {
4682
-					echo "<div class='col pl-0 ps-0'>";
4683
-				} else {
4684
-					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
-				}
4686
-			}
4687
-		}
4688
-
4689
-		public function widget_inputs_row_end( $key, $args ) {
4690
-			if ( ! empty( $args['row'] ) ) {
4691
-				// Maybe close
4692
-				if ( ! empty( $args['row']['close'] ) ) {
4693
-					echo "</div></div>";
4694
-				}
4695
-				echo "</div>";
4696
-			}
4697
-		}
4698
-
4699
-		/**
4681
+				    } else if ( ! empty( $args['row']['close'] ) ) {
4682
+					    echo "<div class='col pl-0 ps-0'>";
4683
+				    } else {
4684
+					    echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4685
+				    }
4686
+			    }
4687
+		    }
4688
+
4689
+		    public function widget_inputs_row_end( $key, $args ) {
4690
+			    if ( ! empty( $args['row'] ) ) {
4691
+				    // Maybe close
4692
+				    if ( ! empty( $args['row']['close'] ) ) {
4693
+					    echo "</div></div>";
4694
+				    }
4695
+				    echo "</div>";
4696
+			    }
4697
+		    }
4698
+
4699
+		    /**
4700 4700
 		 * Get the hidden input that when added makes the advanced button show on widget settings.
4701 4701
 		 *
4702 4702
 		 * @return string
4703 4703
 		 */
4704
-		public function widget_advanced_toggle() {
4704
+		    public function widget_advanced_toggle() {
4705 4705
 
4706
-			$output = '';
4707
-			if ( $this->block_show_advanced() ) {
4708
-				$val = 1;
4709
-			} else {
4710
-				$val = 0;
4711
-			}
4706
+			    $output = '';
4707
+			    if ( $this->block_show_advanced() ) {
4708
+				    $val = 1;
4709
+			    } else {
4710
+				    $val = 0;
4711
+			    }
4712 4712
 
4713
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4713
+			    $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4714 4714
 
4715
-			return $output;
4716
-		}
4715
+			    return $output;
4716
+		    }
4717 4717
 
4718
-		/**
4718
+		    /**
4719 4719
 		 * Convert require element.
4720 4720
 		 *
4721 4721
 		 * @param string $input Input element.
@@ -4724,67 +4724,67 @@  discard block
 block discarded – undo
4724 4724
 		 *@since 1.0.0
4725 4725
 		 *
4726 4726
 		 */
4727
-		public function convert_element_require( $input ) {
4728
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4727
+		    public function convert_element_require( $input ) {
4728
+			    $input = str_replace( "'", '"', $input );// we only want double quotes
4729 4729
 
4730
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
-				"jQuery(form).find('[data-argument=\"",
4732
-				"\"]').find('input,select,textarea').val()",
4733
-				"\"]').find('input:checked').val()"
4734
-			), $input ) );
4730
+			    $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4731
+				    "jQuery(form).find('[data-argument=\"",
4732
+				    "\"]').find('input,select,textarea').val()",
4733
+				    "\"]').find('input:checked').val()"
4734
+			    ), $input ) );
4735 4735
 
4736
-			return $output;
4737
-		}
4736
+			    return $output;
4737
+		    }
4738 4738
 
4739
-		/**
4739
+		    /**
4740 4740
 		 * Builds the inputs for the widget options.
4741 4741
 		 *
4742 4742
 		 * @param $args
4743 4743
 		 * @param $instance
4744 4744
 		 */
4745
-		public function widget_inputs( $args, $instance ) {
4746
-
4747
-			$class             = "";
4748
-			$element_require   = "";
4749
-			$custom_attributes = "";
4750
-
4751
-			// get value
4752
-			if ( isset( $instance[ $args['name'] ] ) ) {
4753
-				$value = $instance[ $args['name'] ];
4754
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
-			} else {
4757
-				$value = '';
4758
-			}
4759
-
4760
-			// get placeholder
4761
-			if ( ! empty( $args['placeholder'] ) ) {
4762
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
-			} else {
4764
-				$placeholder = '';
4765
-			}
4766
-
4767
-			// get if advanced
4768
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
-				$class .= " sd-advanced-setting ";
4770
-			}
4771
-
4772
-			// element_require
4773
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
-				$element_require = $args['element_require'];
4775
-			}
4776
-
4777
-			// custom_attributes
4778
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
-			}
4781
-
4782
-			// before wrapper
4783
-			?>
4784
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4745
+		    public function widget_inputs( $args, $instance ) {
4746
+
4747
+			    $class             = "";
4748
+			    $element_require   = "";
4749
+			    $custom_attributes = "";
4750
+
4751
+			    // get value
4752
+			    if ( isset( $instance[ $args['name'] ] ) ) {
4753
+				    $value = $instance[ $args['name'] ];
4754
+			    } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4755
+				    $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4756
+			    } else {
4757
+				    $value = '';
4758
+			    }
4759
+
4760
+			    // get placeholder
4761
+			    if ( ! empty( $args['placeholder'] ) ) {
4762
+				    $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4763
+			    } else {
4764
+				    $placeholder = '';
4765
+			    }
4766
+
4767
+			    // get if advanced
4768
+			    if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4769
+				    $class .= " sd-advanced-setting ";
4770
+			    }
4771
+
4772
+			    // element_require
4773
+			    if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4774
+				    $element_require = $args['element_require'];
4775
+			    }
4776
+
4777
+			    // custom_attributes
4778
+			    if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4779
+				    $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4780
+			    }
4781
+
4782
+			    // before wrapper
4783
+			    ?>
4784
+    			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4785 4785
 			<?php
4786
-			switch ( $args['type'] ) {
4787
-				//array('text','password','number','email','tel','url','color')
4786
+			    switch ( $args['type'] ) {
4787
+				    //array('text','password','number','email','tel','url','color')
4788 4788
 				case "text":
4789 4789
 				case "password":
4790 4790
 				case "number":
@@ -4848,7 +4848,7 @@  discard block
 block discarded – undo
4848 4848
 					break;
4849 4849
 				default:
4850 4850
 					echo "No input type found!"; // @todo we need to add more input types.
4851
-			}
4851
+			    }
4852 4852
 			// after wrapper
4853 4853
 			?></p><?php
4854 4854
 		}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+                    foreach ( $tabs as $key => $label ) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+                echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,46 +50,46 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+				echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>");
76 76
 
77 77
 					}
78 78
 				?>
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.
includes/class-getpaid-daily-maintenance.php 2 patches
Indentation   +137 added lines, -137 removed lines patch added patch discarded remove patch
@@ -12,142 +12,142 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Daily_Maintenance {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 */
18
-	public function __construct() {
19
-
20
-		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
-
23
-		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
-
26
-		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
-
33
-	}
34
-
35
-	/**
36
-	 * Schedules a cron to run every day at 7 a.m
37
-	 *
38
-	 */
39
-	public function maybe_create_scheduled_event() {
40
-
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
-		}
45
-
46
-	}
47
-
48
-	/**
49
-	 * Clears deprecated events.
50
-	 *
51
-	 */
52
-	public function maybe_clear_deprecated_events() {
53
-
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
58
-		}
59
-
60
-	}
61
-
62
-	/**
63
-	 * Fires the old hook for backwards compatibility.
64
-	 *
65
-	 */
66
-	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
68
-	}
69
-
70
-	/**
71
-	 * Checks for subscriptions that are scheduled to renew.
72
-	 *
73
-	 */
74
-	public function check_renewing_subscriptions() {
75
-
76
-		// Fetch subscriptions that expire today.
77
-		$args  = array(
78
-			'number'             => -1,
79
-			'count_total'        => false,
80
-			'status'             => 'trialling active',
81
-			'date_expires_query' => array(
82
-				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
86
-					'compare' => '=',
87
-				),
88
-			),
89
-		);
90
-
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
92
-
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
94
-			/** @var WPInv_Subscription $subscription */
95
-			if ( $subscription->is_last_renewal() ) {
96
-				$subscription->complete();
97
-			} else {
98
-				do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
99
-			}
100
-		}
101
-	}
102
-
103
-	/**
104
-	 * Expires expired subscriptions.
105
-	 *
106
-	 */
107
-	public function maybe_expire_subscriptions() {
108
-
109
-		// Fetch expired subscriptions (skips those that expire today).
110
-		$args  = array(
111
-			'number'             => -1,
112
-			'count_total'        => false,
113
-			'status'             => 'trialling active failing cancelled',
114
-			'date_expires_query' => array(
115
-				'before'    => 'yesterday',
116
-				'inclusive' => false,
117
-			),
118
-		);
119
-
120
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
121
-
122
-		foreach ( $subscriptions->get_results() as $subscription ) {
123
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
-				$subscription->set_status( 'expired' );
125
-				$subscription->save();
126
-			}
127
-		}
128
-
129
-	}
130
-
131
-	/**
132
-	 * Logs cron runs.
133
-	 *
134
-	 */
135
-	public function log_cron_run() {
136
-		wpinv_error_log( 'GetPaid Daily Cron', false );
137
-	}
138
-
139
-	/**
140
-	 * Updates GeoIP databases.
141
-	 *
142
-	 */
143
-	public function maybe_update_geoip_databases() {
144
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
145
-
146
-		if ( false === $updated ) {
147
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
-			do_action( 'getpaid_update_geoip_databases' );
149
-		}
150
-
151
-	}
15
+    /**
16
+     * Class constructor.
17
+     */
18
+    public function __construct() {
19
+
20
+        // Clear deprecated events.
21
+        add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
22
+
23
+        // (Maybe) schedule a cron that runs daily.
24
+        add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
25
+
26
+        // Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
+        add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
+        add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
+        add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
+        add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
32
+
33
+    }
34
+
35
+    /**
36
+     * Schedules a cron to run every day at 7 a.m
37
+     *
38
+     */
39
+    public function maybe_create_scheduled_event() {
40
+
41
+        if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
+            $timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
+            wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
44
+        }
45
+
46
+    }
47
+
48
+    /**
49
+     * Clears deprecated events.
50
+     *
51
+     */
52
+    public function maybe_clear_deprecated_events() {
53
+
54
+        if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
+            wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
+            update_option( 'wpinv_cleared_old_events', 1 );
58
+        }
59
+
60
+    }
61
+
62
+    /**
63
+     * Fires the old hook for backwards compatibility.
64
+     *
65
+     */
66
+    public function backwards_compat() {
67
+        do_action( 'wpinv_register_schedule_event_daily' );
68
+    }
69
+
70
+    /**
71
+     * Checks for subscriptions that are scheduled to renew.
72
+     *
73
+     */
74
+    public function check_renewing_subscriptions() {
75
+
76
+        // Fetch subscriptions that expire today.
77
+        $args  = array(
78
+            'number'             => -1,
79
+            'count_total'        => false,
80
+            'status'             => 'trialling active',
81
+            'date_expires_query' => array(
82
+                array(
83
+                    'year'    => gmdate( 'Y' ),
84
+                    'month'   => gmdate( 'n' ),
85
+                    'day'     => gmdate( 'j' ),
86
+                    'compare' => '=',
87
+                ),
88
+            ),
89
+        );
90
+
91
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
92
+
93
+        foreach ( $subscriptions->get_results() as $subscription ) {
94
+            /** @var WPInv_Subscription $subscription */
95
+            if ( $subscription->is_last_renewal() ) {
96
+                $subscription->complete();
97
+            } else {
98
+                do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
99
+            }
100
+        }
101
+    }
102
+
103
+    /**
104
+     * Expires expired subscriptions.
105
+     *
106
+     */
107
+    public function maybe_expire_subscriptions() {
108
+
109
+        // Fetch expired subscriptions (skips those that expire today).
110
+        $args  = array(
111
+            'number'             => -1,
112
+            'count_total'        => false,
113
+            'status'             => 'trialling active failing cancelled',
114
+            'date_expires_query' => array(
115
+                'before'    => 'yesterday',
116
+                'inclusive' => false,
117
+            ),
118
+        );
119
+
120
+        $subscriptions = new GetPaid_Subscriptions_Query( $args );
121
+
122
+        foreach ( $subscriptions->get_results() as $subscription ) {
123
+            if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
+                $subscription->set_status( 'expired' );
125
+                $subscription->save();
126
+            }
127
+        }
128
+
129
+    }
130
+
131
+    /**
132
+     * Logs cron runs.
133
+     *
134
+     */
135
+    public function log_cron_run() {
136
+        wpinv_error_log( 'GetPaid Daily Cron', false );
137
+    }
138
+
139
+    /**
140
+     * Updates GeoIP databases.
141
+     *
142
+     */
143
+    public function maybe_update_geoip_databases() {
144
+        $updated = get_transient( 'getpaid_updated_geoip_databases' );
145
+
146
+        if ( false === $updated ) {
147
+            set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
+            do_action( 'getpaid_update_geoip_databases' );
149
+        }
150
+
151
+    }
152 152
 
153 153
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Daily maintenance class.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	public function __construct() {
19 19
 
20 20
 		// Clear deprecated events.
21
-		add_action( 'wp', array( $this, 'maybe_clear_deprecated_events' ) );
21
+		add_action('wp', array($this, 'maybe_clear_deprecated_events'));
22 22
 
23 23
 		// (Maybe) schedule a cron that runs daily.
24
-		add_action( 'wp', array( $this, 'maybe_create_scheduled_event' ) );
24
+		add_action('wp', array($this, 'maybe_create_scheduled_event'));
25 25
 
26 26
 		// Fired everyday at 7 a.m (this might vary for sites with few visitors)
27
-		add_action( 'getpaid_daily_maintenance', array( $this, 'log_cron_run' ) );
28
-		add_action( 'getpaid_daily_maintenance', array( $this, 'backwards_compat' ) );
29
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_expire_subscriptions' ) );
30
-		add_action( 'getpaid_daily_maintenance', array( $this, 'check_renewing_subscriptions' ) );
31
-		add_action( 'getpaid_daily_maintenance', array( $this, 'maybe_update_geoip_databases' ) );
27
+		add_action('getpaid_daily_maintenance', array($this, 'log_cron_run'));
28
+		add_action('getpaid_daily_maintenance', array($this, 'backwards_compat'));
29
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_expire_subscriptions'));
30
+		add_action('getpaid_daily_maintenance', array($this, 'check_renewing_subscriptions'));
31
+		add_action('getpaid_daily_maintenance', array($this, 'maybe_update_geoip_databases'));
32 32
 
33 33
 	}
34 34
 
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	public function maybe_create_scheduled_event() {
40 40
 
41
-		if ( ! wp_next_scheduled( 'getpaid_daily_maintenance' ) ) {
42
-			$timestamp = strtotime( 'tomorrow 07:00:00', current_time( 'timestamp' ) );
43
-			wp_schedule_event( $timestamp, 'daily', 'getpaid_daily_maintenance' );
41
+		if (!wp_next_scheduled('getpaid_daily_maintenance')) {
42
+			$timestamp = strtotime('tomorrow 07:00:00', current_time('timestamp'));
43
+			wp_schedule_event($timestamp, 'daily', 'getpaid_daily_maintenance');
44 44
 		}
45 45
 
46 46
 	}
@@ -51,10 +51,10 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	public function maybe_clear_deprecated_events() {
53 53
 
54
-		if ( ! get_option( 'wpinv_cleared_old_events' ) ) {
55
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_twicedaily' );
56
-			wp_clear_scheduled_hook( 'wpinv_register_schedule_event_daily' );
57
-			update_option( 'wpinv_cleared_old_events', 1 );
54
+		if (!get_option('wpinv_cleared_old_events')) {
55
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_twicedaily');
56
+			wp_clear_scheduled_hook('wpinv_register_schedule_event_daily');
57
+			update_option('wpinv_cleared_old_events', 1);
58 58
 		}
59 59
 
60 60
 	}
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
 	 *
65 65
 	 */
66 66
 	public function backwards_compat() {
67
-		do_action( 'wpinv_register_schedule_event_daily' );
67
+		do_action('wpinv_register_schedule_event_daily');
68 68
 	}
69 69
 
70 70
 	/**
@@ -74,28 +74,28 @@  discard block
 block discarded – undo
74 74
 	public function check_renewing_subscriptions() {
75 75
 
76 76
 		// Fetch subscriptions that expire today.
77
-		$args  = array(
77
+		$args = array(
78 78
 			'number'             => -1,
79 79
 			'count_total'        => false,
80 80
 			'status'             => 'trialling active',
81 81
 			'date_expires_query' => array(
82 82
 				array(
83
-					'year'    => gmdate( 'Y' ),
84
-					'month'   => gmdate( 'n' ),
85
-					'day'     => gmdate( 'j' ),
83
+					'year'    => gmdate('Y'),
84
+					'month'   => gmdate('n'),
85
+					'day'     => gmdate('j'),
86 86
 					'compare' => '=',
87 87
 				),
88 88
 			),
89 89
 		);
90 90
 
91
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
91
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
92 92
 
93
-		foreach ( $subscriptions->get_results() as $subscription ) {
93
+		foreach ($subscriptions->get_results() as $subscription) {
94 94
 			/** @var WPInv_Subscription $subscription */
95
-			if ( $subscription->is_last_renewal() ) {
95
+			if ($subscription->is_last_renewal()) {
96 96
 				$subscription->complete();
97 97
 			} else {
98
-				do_action( 'getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice() );
98
+				do_action('getpaid_should_renew_subscription', $subscription, $subscription->get_parent_invoice());
99 99
 			}
100 100
 		}
101 101
 	}
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 	public function maybe_expire_subscriptions() {
108 108
 
109 109
 		// Fetch expired subscriptions (skips those that expire today).
110
-		$args  = array(
110
+		$args = array(
111 111
 			'number'             => -1,
112 112
 			'count_total'        => false,
113 113
 			'status'             => 'trialling active failing cancelled',
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 			),
118 118
 		);
119 119
 
120
-		$subscriptions = new GetPaid_Subscriptions_Query( $args );
120
+		$subscriptions = new GetPaid_Subscriptions_Query($args);
121 121
 
122
-		foreach ( $subscriptions->get_results() as $subscription ) {
123
-			if ( apply_filters( 'getpaid_daily_maintenance_should_expire_subscription', false, $subscription ) ) {
124
-				$subscription->set_status( 'expired' );
122
+		foreach ($subscriptions->get_results() as $subscription) {
123
+			if (apply_filters('getpaid_daily_maintenance_should_expire_subscription', false, $subscription)) {
124
+				$subscription->set_status('expired');
125 125
 				$subscription->save();
126 126
 			}
127 127
 		}
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 */
135 135
 	public function log_cron_run() {
136
-		wpinv_error_log( 'GetPaid Daily Cron', false );
136
+		wpinv_error_log('GetPaid Daily Cron', false);
137 137
 	}
138 138
 
139 139
 	/**
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 */
143 143
 	public function maybe_update_geoip_databases() {
144
-		$updated = get_transient( 'getpaid_updated_geoip_databases' );
144
+		$updated = get_transient('getpaid_updated_geoip_databases');
145 145
 
146
-		if ( false === $updated ) {
147
-			set_transient( 'getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS );
148
-			do_action( 'getpaid_update_geoip_databases' );
146
+		if (false === $updated) {
147
+			set_transient('getpaid_updated_geoip_databases', 1, 15 * DAY_IN_SECONDS);
148
+			do_action('getpaid_update_geoip_databases');
149 149
 		}
150 150
 
151 151
 	}
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2740 added lines, -2740 removed lines patch added patch discarded remove patch
@@ -14,31 +14,31 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'              => 0,
38
-		'customer_id'            => 0,
39
-		'status'                 => 'wpi-pending',
40
-		'version'                => '',
41
-		'date_created'           => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'              => 0,
38
+        'customer_id'            => 0,
39
+        'status'                 => 'wpi-pending',
40
+        'version'                => '',
41
+        'date_created'           => null,
42 42
         'date_modified'          => null,
43 43
         'due_date'               => null,
44 44
         'completed_date'         => null,
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
         'state'                  => null,
62 62
         'zip'                    => null,
63 63
         'company'                => null,
64
-		'company_id'             => null,
64
+        'company_id'             => null,
65 65
         'vat_number'             => null,
66 66
         'vat_rate'               => null,
67 67
         'address'                => null,
68 68
         'address_confirmed'      => false,
69 69
         'shipping'               => null,
70
-		'subtotal'               => 0,
70
+        'subtotal'               => 0,
71 71
         'total_discount'         => 0,
72 72
         'total_tax'              => 0,
73
-		'total_fees'             => 0,
74
-		'total'                  => 0,
73
+        'total_fees'             => 0,
74
+        'total'                  => 0,
75 75
         'fees'                   => array(),
76 76
         'discounts'              => array(),
77 77
         'taxes'                  => array(),
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
         'transaction_id'         => '',
84 84
         'currency'               => '',
85 85
         'disable_taxes'          => false,
86
-		'subscription_id'        => null,
87
-		'remote_subscription_id' => null,
88
-		'is_viewed'              => false,
89
-		'email_cc'               => '',
90
-		'template'               => 'quantity', // hours, amount only
91
-		'created_via'            => null,
86
+        'subscription_id'        => null,
87
+        'remote_subscription_id' => null,
88
+        'is_viewed'              => false,
89
+        'email_cc'               => '',
90
+        'template'               => 'quantity', // hours, amount only
91
+        'created_via'            => null,
92 92
     );
93 93
 
94 94
     /**
95
-	 * Stores meta in cache for future reads.
96
-	 *
97
-	 * A group must be set to to enable caching.
98
-	 *
99
-	 * @var string
100
-	 */
101
-	protected $cache_group = 'getpaid_invoices';
95
+     * Stores meta in cache for future reads.
96
+     *
97
+     * A group must be set to to enable caching.
98
+     *
99
+     * @var string
100
+     */
101
+    protected $cache_group = 'getpaid_invoices';
102 102
 
103 103
     /**
104 104
      * Stores a reference to the original WP_Post object
@@ -112,122 +112,122 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @var int
114 114
      */
115
-	protected $recurring_item = null;
115
+    protected $recurring_item = null;
116 116
 
117
-	/**
117
+    /**
118 118
      * Stores an array of item totals.
119
-	 *
120
-	 * e.g $totals['discount'] = array(
121
-	 *      'initial'   => 10,
122
-	 *      'recurring' => 10,
123
-	 * )
119
+     *
120
+     * e.g $totals['discount'] = array(
121
+     *      'initial'   => 10,
122
+     *      'recurring' => 10,
123
+     * )
124 124
      *
125 125
      * @var array
126 126
      */
127
-	protected $totals = array();
127
+    protected $totals = array();
128 128
 
129
-	/**
129
+    /**
130 130
      * Tax rate.
131
-	 *
131
+     *
132 132
      * @var float
133 133
      */
134
-	protected $tax_rate = 0;
134
+    protected $tax_rate = 0;
135 135
 
136
-	/**
137
-	 * Stores the status transition information.
138
-	 *
139
-	 * @since 1.0.19
140
-	 * @var bool|array
141
-	 */
142
-	protected $status_transition = false;
136
+    /**
137
+     * Stores the status transition information.
138
+     *
139
+     * @since 1.0.19
140
+     * @var bool|array
141
+     */
142
+    protected $status_transition = false;
143 143
 
144 144
     /**
145
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
146
-	 *
147
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148
-	 */
145
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
146
+     *
147
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148
+     */
149 149
     public function __construct( $invoice = 0 ) {
150 150
 
151 151
         parent::__construct( $invoice );
152 152
 
153
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
-			$this->set_id( (int) $invoice );
155
-		} elseif ( $invoice instanceof self ) {
156
-			$this->set_id( $invoice->get_id() );
157
-		} elseif ( ! empty( $invoice->ID ) ) {
158
-			$this->set_id( $invoice->ID );
159
-		} elseif ( is_array( $invoice ) ) {
160
-			$this->set_props( $invoice );
161
-
162
-			if ( isset( $invoice['ID'] ) ) {
163
-				$this->set_id( $invoice['ID'] );
164
-			}
153
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
+            $this->set_id( (int) $invoice );
155
+        } elseif ( $invoice instanceof self ) {
156
+            $this->set_id( $invoice->get_id() );
157
+        } elseif ( ! empty( $invoice->ID ) ) {
158
+            $this->set_id( $invoice->ID );
159
+        } elseif ( is_array( $invoice ) ) {
160
+            $this->set_props( $invoice );
161
+
162
+            if ( isset( $invoice['ID'] ) ) {
163
+                $this->set_id( $invoice['ID'] );
164
+            }
165 165
 } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
171
-		} else {
172
-			$this->set_object_read( true );
173
-		}
166
+            $this->set_id( $invoice_id );
167
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
+            $this->set_id( $invoice_id );
169
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
+            $this->set_id( $invoice_id );
171
+        } else {
172
+            $this->set_object_read( true );
173
+        }
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
177 177
 
178
-		if ( $this->get_id() > 0 ) {
178
+        if ( $this->get_id() > 0 ) {
179 179
             $this->post = get_post( $this->get_id() );
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+            $this->data_store->read( $this );
182 182
         }
183 183
 
184 184
     }
185 185
 
186 186
     /**
187
-	 * Given an invoice key/number, it returns its id.
188
-	 *
189
-	 *
190
-	 * @static
191
-	 * @param string $value The invoice key or number
192
-	 * @param string $field Either key, transaction_id or number.
193
-	 * @since 1.0.15
194
-	 * @return int
195
-	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187
+     * Given an invoice key/number, it returns its id.
188
+     *
189
+     *
190
+     * @static
191
+     * @param string $value The invoice key or number
192
+     * @param string $field Either key, transaction_id or number.
193
+     * @since 1.0.15
194
+     * @return int
195
+     */
196
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
197 197
         global $wpdb;
198 198
 
199
-		// Trim the value.
200
-		$value = trim( $value );
199
+        // Trim the value.
200
+        $value = trim( $value );
201 201
 
202
-		if ( empty( $value ) ) {
203
-			return 0;
204
-		}
202
+        if ( empty( $value ) ) {
203
+            return 0;
204
+        }
205 205
 
206 206
         // Valid fields.
207 207
         $fields = array( 'key', 'number', 'transaction_id' );
208 208
 
209
-		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
-			return 0;
212
-		}
209
+        // Ensure a field has been passed.
210
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
+            return 0;
212
+        }
213 213
 
214
-		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
217
-			return $invoice_id;
218
-		}
214
+        // Maybe retrieve from the cache.
215
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        if ( false !== $invoice_id ) {
217
+            return $invoice_id;
218
+        }
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
222
-		$db_field    = 'key' === $field ? 'invoice_key' : $field;
222
+        $db_field    = 'key' === $field ? 'invoice_key' : $field;
223 223
         $invoice_id  = (int) $wpdb->get_var(
224 224
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value )
225 225
         );
226 226
 
227
-		// Update the cache with our data
228
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227
+        // Update the cache with our data
228
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
229 229
 
230
-		return $invoice_id;
230
+        return $invoice_id;
231 231
     }
232 232
 
233 233
     /**
@@ -253,83 +253,83 @@  discard block
 block discarded – undo
253 253
     */
254 254
 
255 255
     /**
256
-	 * Get parent invoice ID.
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return int
261
-	 */
262
-	public function get_parent_id( $context = 'view' ) {
263
-		return (int) $this->get_prop( 'parent_id', $context );
256
+     * Get parent invoice ID.
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return int
261
+     */
262
+    public function get_parent_id( $context = 'view' ) {
263
+        return (int) $this->get_prop( 'parent_id', $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get parent invoice.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @return WPInv_Invoice
271
-	 */
267
+     * Get parent invoice.
268
+     *
269
+     * @since 1.0.19
270
+     * @return WPInv_Invoice
271
+     */
272 272
     public function get_parent_payment() {
273 273
         return new WPInv_Invoice( $this->get_parent_id() );
274 274
     }
275 275
 
276 276
     /**
277
-	 * Alias for self::get_parent_payment().
278
-	 *
279
-	 * @since 1.0.19
280
-	 * @return WPInv_Invoice
281
-	 */
277
+     * Alias for self::get_parent_payment().
278
+     *
279
+     * @since 1.0.19
280
+     * @return WPInv_Invoice
281
+     */
282 282
     public function get_parent() {
283 283
         return $this->get_parent_payment();
284 284
     }
285 285
 
286 286
     /**
287
-	 * Get invoice status.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @param  string $context View or edit context.
291
-	 * @return string
292
-	 */
293
-	public function get_status( $context = 'view' ) {
294
-		return $this->get_prop( 'status', $context );
295
-	}
287
+     * Get invoice status.
288
+     *
289
+     * @since 1.0.19
290
+     * @param  string $context View or edit context.
291
+     * @return string
292
+     */
293
+    public function get_status( $context = 'view' ) {
294
+        return $this->get_prop( 'status', $context );
295
+    }
296 296
 
297
-	/**
298
-	 * Retrieves an array of possible invoice statuses.
299
-	 *
300
-	 * @since 1.0.19
301
-	 * @return array
302
-	 */
303
-	public function get_all_statuses() {
304
-		return wpinv_get_invoice_statuses( true, true, $this );
297
+    /**
298
+     * Retrieves an array of possible invoice statuses.
299
+     *
300
+     * @since 1.0.19
301
+     * @return array
302
+     */
303
+    public function get_all_statuses() {
304
+        return wpinv_get_invoice_statuses( true, true, $this );
305 305
     }
306 306
 
307 307
     /**
308
-	 * Get invoice status nice name.
309
-	 *
310
-	 * @since 1.0.19
311
-	 * @return string
312
-	 */
308
+     * Get invoice status nice name.
309
+     *
310
+     * @since 1.0.19
311
+     * @return string
312
+     */
313 313
     public function get_status_nicename() {
314
-		$statuses = $this->get_all_statuses();
314
+        $statuses = $this->get_all_statuses();
315 315
 
316 316
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
317 317
 
318 318
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
319 319
     }
320 320
 
321
-	/**
322
-	 * Retrieves the invoice status class
323
-	 *
324
-	 * @since  1.0.19
325
-	 * @return string
326
-	 */
327
-	public function get_status_class() {
328
-		$statuses = getpaid_get_invoice_status_classes();
329
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
330
-	}
321
+    /**
322
+     * Retrieves the invoice status class
323
+     *
324
+     * @since  1.0.19
325
+     * @return string
326
+     */
327
+    public function get_status_class() {
328
+        $statuses = getpaid_get_invoice_status_classes();
329
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
330
+    }
331 331
 
332
-	/**
332
+    /**
333 333
      * Retrieves the invoice status label html
334 334
      *
335 335
      * @since  1.0.0
@@ -337,263 +337,263 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function get_status_label_html() {
339 339
 
340
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
341
-		$status       = sanitize_html_class( $this->get_status() );
342
-		$class        = esc_attr( $this->get_status_class() );
343
-
344
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
345
-	}
346
-
347
-    /**
348
-	 * Get plugin version when the invoice was created.
349
-	 *
350
-	 * @since 1.0.19
351
-	 * @param  string $context View or edit context.
352
-	 * @return string
353
-	 */
354
-	public function get_version( $context = 'view' ) {
355
-		return $this->get_prop( 'version', $context );
356
-	}
357
-
358
-	/**
359
-	 * @deprecated
360
-	 */
361
-	public function get_invoice_date( $format = true ) {
362
-		$date      = getpaid_format_date( $this->get_date_completed() );
363
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
364
-		$formatted = getpaid_format_date( $date );
365
-
366
-		if ( $format ) {
367
-			return $formatted;
368
-		}
369
-
370
-		return empty( $formatted ) ? '' : $date;
371
-
372
-    }
373
-
374
-    /**
375
-	 * Get date when the invoice was created.
376
-	 *
377
-	 * @since 1.0.19
378
-	 * @param  string $context View or edit context.
379
-	 * @return string
380
-	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_prop( 'date_created', $context );
383
-	}
384
-
385
-	/**
386
-	 * Alias for self::get_date_created().
387
-	 *
388
-	 * @since 1.0.19
389
-	 * @param  string $context View or edit context.
390
-	 * @return string
391
-	 */
392
-	public function get_created_date( $context = 'view' ) {
393
-		return $this->get_date_created( $context );
394
-    }
395
-
396
-    /**
397
-	 * Get GMT date when the invoice was created.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
340
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
341
+        $status       = sanitize_html_class( $this->get_status() );
342
+        $class        = esc_attr( $this->get_status_class() );
343
+
344
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
345
+    }
346
+
347
+    /**
348
+     * Get plugin version when the invoice was created.
349
+     *
350
+     * @since 1.0.19
351
+     * @param  string $context View or edit context.
352
+     * @return string
353
+     */
354
+    public function get_version( $context = 'view' ) {
355
+        return $this->get_prop( 'version', $context );
356
+    }
357
+
358
+    /**
359
+     * @deprecated
360
+     */
361
+    public function get_invoice_date( $format = true ) {
362
+        $date      = getpaid_format_date( $this->get_date_completed() );
363
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
364
+        $formatted = getpaid_format_date( $date );
365
+
366
+        if ( $format ) {
367
+            return $formatted;
368
+        }
369
+
370
+        return empty( $formatted ) ? '' : $date;
371
+
372
+    }
373
+
374
+    /**
375
+     * Get date when the invoice was created.
376
+     *
377
+     * @since 1.0.19
378
+     * @param  string $context View or edit context.
379
+     * @return string
380
+     */
381
+    public function get_date_created( $context = 'view' ) {
382
+        return $this->get_prop( 'date_created', $context );
383
+    }
384
+
385
+    /**
386
+     * Alias for self::get_date_created().
387
+     *
388
+     * @since 1.0.19
389
+     * @param  string $context View or edit context.
390
+     * @return string
391
+     */
392
+    public function get_created_date( $context = 'view' ) {
393
+        return $this->get_date_created( $context );
394
+    }
395
+
396
+    /**
397
+     * Get GMT date when the invoice was created.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_created_gmt( $context = 'view' ) {
404 404
         $date = $this->get_date_created( $context );
405 405
 
406 406
         if ( $date ) {
407 407
             $date = get_gmt_from_date( $date );
408 408
         }
409
-		return $date;
410
-    }
411
-
412
-    /**
413
-	 * Get date when the invoice was last modified.
414
-	 *
415
-	 * @since 1.0.19
416
-	 * @param  string $context View or edit context.
417
-	 * @return string
418
-	 */
419
-	public function get_date_modified( $context = 'view' ) {
420
-		return $this->get_prop( 'date_modified', $context );
421
-	}
422
-
423
-	/**
424
-	 * Alias for self::get_date_modified().
425
-	 *
426
-	 * @since 1.0.19
427
-	 * @param  string $context View or edit context.
428
-	 * @return string
429
-	 */
430
-	public function get_modified_date( $context = 'view' ) {
431
-		return $this->get_date_modified( $context );
432
-    }
433
-
434
-    /**
435
-	 * Get GMT date when the invoice was last modified.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return string
440
-	 */
441
-	public function get_date_modified_gmt( $context = 'view' ) {
409
+        return $date;
410
+    }
411
+
412
+    /**
413
+     * Get date when the invoice was last modified.
414
+     *
415
+     * @since 1.0.19
416
+     * @param  string $context View or edit context.
417
+     * @return string
418
+     */
419
+    public function get_date_modified( $context = 'view' ) {
420
+        return $this->get_prop( 'date_modified', $context );
421
+    }
422
+
423
+    /**
424
+     * Alias for self::get_date_modified().
425
+     *
426
+     * @since 1.0.19
427
+     * @param  string $context View or edit context.
428
+     * @return string
429
+     */
430
+    public function get_modified_date( $context = 'view' ) {
431
+        return $this->get_date_modified( $context );
432
+    }
433
+
434
+    /**
435
+     * Get GMT date when the invoice was last modified.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return string
440
+     */
441
+    public function get_date_modified_gmt( $context = 'view' ) {
442 442
         $date = $this->get_date_modified( $context );
443 443
 
444 444
         if ( $date ) {
445 445
             $date = get_gmt_from_date( $date );
446 446
         }
447
-		return $date;
447
+        return $date;
448 448
     }
449 449
 
450 450
     /**
451
-	 * Get the invoice due date.
452
-	 *
453
-	 * @since 1.0.19
454
-	 * @param  string $context View or edit context.
455
-	 * @return string
456
-	 */
457
-	public function get_due_date( $context = 'view' ) {
458
-		return $this->get_prop( 'due_date', $context );
451
+     * Get the invoice due date.
452
+     *
453
+     * @since 1.0.19
454
+     * @param  string $context View or edit context.
455
+     * @return string
456
+     */
457
+    public function get_due_date( $context = 'view' ) {
458
+        return $this->get_prop( 'due_date', $context );
459 459
     }
460 460
 
461 461
     /**
462
-	 * Alias for self::get_due_date().
463
-	 *
464
-	 * @since 1.0.19
465
-	 * @param  string $context View or edit context.
466
-	 * @return string
467
-	 */
468
-	public function get_date_due( $context = 'view' ) {
469
-		return $this->get_due_date( $context );
462
+     * Alias for self::get_due_date().
463
+     *
464
+     * @since 1.0.19
465
+     * @param  string $context View or edit context.
466
+     * @return string
467
+     */
468
+    public function get_date_due( $context = 'view' ) {
469
+        return $this->get_due_date( $context );
470 470
     }
471 471
 
472 472
     /**
473
-	 * Get the invoice GMT due date.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
479
-	public function get_due_date_gmt( $context = 'view' ) {
473
+     * Get the invoice GMT due date.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479
+    public function get_due_date_gmt( $context = 'view' ) {
480 480
         $date = $this->get_due_date( $context );
481 481
 
482 482
         if ( $date ) {
483 483
             $date = get_gmt_from_date( $date );
484 484
         }
485
-		return $date;
485
+        return $date;
486 486
     }
487 487
 
488 488
     /**
489
-	 * Alias for self::get_due_date_gmt().
490
-	 *
491
-	 * @since 1.0.19
492
-	 * @param  string $context View or edit context.
493
-	 * @return string
494
-	 */
495
-	public function get_gmt_date_due( $context = 'view' ) {
496
-		return $this->get_due_date_gmt( $context );
489
+     * Alias for self::get_due_date_gmt().
490
+     *
491
+     * @since 1.0.19
492
+     * @param  string $context View or edit context.
493
+     * @return string
494
+     */
495
+    public function get_gmt_date_due( $context = 'view' ) {
496
+        return $this->get_due_date_gmt( $context );
497 497
     }
498 498
 
499 499
     /**
500
-	 * Get date when the invoice was completed.
501
-	 *
502
-	 * @since 1.0.19
503
-	 * @param  string $context View or edit context.
504
-	 * @return string
505
-	 */
506
-	public function get_completed_date( $context = 'view' ) {
507
-		return $this->get_prop( 'completed_date', $context );
500
+     * Get date when the invoice was completed.
501
+     *
502
+     * @since 1.0.19
503
+     * @param  string $context View or edit context.
504
+     * @return string
505
+     */
506
+    public function get_completed_date( $context = 'view' ) {
507
+        return $this->get_prop( 'completed_date', $context );
508 508
     }
509 509
 
510 510
     /**
511
-	 * Alias for self::get_completed_date().
512
-	 *
513
-	 * @since 1.0.19
514
-	 * @param  string $context View or edit context.
515
-	 * @return string
516
-	 */
517
-	public function get_date_completed( $context = 'view' ) {
518
-		return $this->get_completed_date( $context );
511
+     * Alias for self::get_completed_date().
512
+     *
513
+     * @since 1.0.19
514
+     * @param  string $context View or edit context.
515
+     * @return string
516
+     */
517
+    public function get_date_completed( $context = 'view' ) {
518
+        return $this->get_completed_date( $context );
519 519
     }
520 520
 
521 521
     /**
522
-	 * Get GMT date when the invoice was was completed.
523
-	 *
524
-	 * @since 1.0.19
525
-	 * @param  string $context View or edit context.
526
-	 * @return string
527
-	 */
528
-	public function get_completed_date_gmt( $context = 'view' ) {
522
+     * Get GMT date when the invoice was was completed.
523
+     *
524
+     * @since 1.0.19
525
+     * @param  string $context View or edit context.
526
+     * @return string
527
+     */
528
+    public function get_completed_date_gmt( $context = 'view' ) {
529 529
         $date = $this->get_completed_date( $context );
530 530
 
531 531
         if ( $date ) {
532 532
             $date = get_gmt_from_date( $date );
533 533
         }
534
-		return $date;
534
+        return $date;
535 535
     }
536 536
 
537 537
     /**
538
-	 * Alias for self::get_completed_date_gmt().
539
-	 *
540
-	 * @since 1.0.19
541
-	 * @param  string $context View or edit context.
542
-	 * @return string
543
-	 */
544
-	public function get_gmt_completed_date( $context = 'view' ) {
545
-		return $this->get_completed_date_gmt( $context );
538
+     * Alias for self::get_completed_date_gmt().
539
+     *
540
+     * @since 1.0.19
541
+     * @param  string $context View or edit context.
542
+     * @return string
543
+     */
544
+    public function get_gmt_completed_date( $context = 'view' ) {
545
+        return $this->get_completed_date_gmt( $context );
546 546
     }
547 547
 
548 548
     /**
549
-	 * Get the invoice number.
550
-	 *
551
-	 * @since 1.0.19
552
-	 * @param  string $context View or edit context.
553
-	 * @return string
554
-	 */
555
-	public function get_number( $context = 'view' ) {
556
-		$number = $this->get_prop( 'number', $context );
549
+     * Get the invoice number.
550
+     *
551
+     * @since 1.0.19
552
+     * @param  string $context View or edit context.
553
+     * @return string
554
+     */
555
+    public function get_number( $context = 'view' ) {
556
+        $number = $this->get_prop( 'number', $context );
557 557
 
558
-		if ( empty( $number ) ) {
559
-			$number = $this->generate_number();
560
-			$this->set_number( $this->generate_number() );
561
-		}
558
+        if ( empty( $number ) ) {
559
+            $number = $this->generate_number();
560
+            $this->set_number( $this->generate_number() );
561
+        }
562 562
 
563
-		return $number;
563
+        return $number;
564 564
     }
565 565
 
566
-	/**
567
-	 * Set the invoice number.
568
-	 *
569
-	 * @since 1.0.19
570
-	 */
571
-	public function maybe_set_number() {
566
+    /**
567
+     * Set the invoice number.
568
+     *
569
+     * @since 1.0.19
570
+     */
571
+    public function maybe_set_number() {
572 572
         $number = $this->get_number();
573 573
 
574 574
         if ( empty( $number ) || $this->get_id() == $number ) {
575
-			$this->set_number( $this->generate_number() );
575
+            $this->set_number( $this->generate_number() );
576 576
         }
577 577
 
578
-	}
578
+    }
579 579
 
580 580
     /**
581
-	 * Get the invoice key.
582
-	 *
583
-	 * @since 1.0.19
584
-	 * @param  string $context View or edit context.
585
-	 * @return string
586
-	 */
587
-	public function get_key( $context = 'view' ) {
581
+     * Get the invoice key.
582
+     *
583
+     * @since 1.0.19
584
+     * @param  string $context View or edit context.
585
+     * @return string
586
+     */
587
+    public function get_key( $context = 'view' ) {
588 588
         return $this->get_prop( 'key', $context );
589
-	}
590
-
591
-	/**
592
-	 * Set the invoice key.
593
-	 *
594
-	 * @since 1.0.19
595
-	 */
596
-	public function maybe_set_key() {
589
+    }
590
+
591
+    /**
592
+     * Set the invoice key.
593
+     *
594
+     * @since 1.0.19
595
+     */
596
+    public function maybe_set_key() {
597 597
         $key = $this->get_key();
598 598
 
599 599
         if ( empty( $key ) ) {
@@ -604,140 +604,140 @@  discard block
 block discarded – undo
604 604
     }
605 605
 
606 606
     /**
607
-	 * Get the invoice type.
608
-	 *
609
-	 * @since 1.0.19
610
-	 * @param  string $context View or edit context.
611
-	 * @return string
612
-	 */
613
-	public function get_type( $context = 'view' ) {
607
+     * Get the invoice type.
608
+     *
609
+     * @since 1.0.19
610
+     * @param  string $context View or edit context.
611
+     * @return string
612
+     */
613
+    public function get_type( $context = 'view' ) {
614 614
         return $this->get_prop( 'type', $context );
615
-	}
616
-
617
-	/**
618
-	 * Returns the post type name.
619
-	 *
620
-	 * @since 1.0.19
621
-	 * @return string
622
-	 */
623
-	public function get_invoice_quote_type() {
615
+    }
616
+
617
+    /**
618
+     * Returns the post type name.
619
+     *
620
+     * @since 1.0.19
621
+     * @return string
622
+     */
623
+    public function get_invoice_quote_type() {
624 624
         return getpaid_get_post_type_label( $this->get_post_type(), false );
625 625
     }
626 626
 
627 627
     /**
628
-	 * Get the invoice post type label.
629
-	 *
630
-	 * @since 1.0.19
631
-	 * @param  string $context View or edit context.
632
-	 * @return string
633
-	 */
634
-	public function get_label( $context = 'view' ) {
628
+     * Get the invoice post type label.
629
+     *
630
+     * @since 1.0.19
631
+     * @param  string $context View or edit context.
632
+     * @return string
633
+     */
634
+    public function get_label( $context = 'view' ) {
635 635
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
636
-	}
637
-
638
-	/**
639
-	 * Get the invoice post type.
640
-	 *
641
-	 * @since 1.0.19
642
-	 * @param  string $context View or edit context.
643
-	 * @return string
644
-	 */
645
-	public function get_post_type( $context = 'view' ) {
636
+    }
637
+
638
+    /**
639
+     * Get the invoice post type.
640
+     *
641
+     * @since 1.0.19
642
+     * @param  string $context View or edit context.
643
+     * @return string
644
+     */
645
+    public function get_post_type( $context = 'view' ) {
646 646
         return $this->get_prop( 'post_type', $context );
647 647
     }
648 648
 
649 649
     /**
650
-	 * Get the invoice mode.
651
-	 *
652
-	 * @since 1.0.19
653
-	 * @param  string $context View or edit context.
654
-	 * @return string
655
-	 */
656
-	public function get_mode( $context = 'view' ) {
650
+     * Get the invoice mode.
651
+     *
652
+     * @since 1.0.19
653
+     * @param  string $context View or edit context.
654
+     * @return string
655
+     */
656
+    public function get_mode( $context = 'view' ) {
657 657
         return $this->get_prop( 'mode', $context );
658 658
     }
659 659
 
660 660
     /**
661
-	 * Get the invoice path.
662
-	 *
663
-	 * @since 1.0.19
664
-	 * @param  string $context View or edit context.
665
-	 * @return string
666
-	 */
667
-	public function get_path( $context = 'view' ) {
661
+     * Get the invoice path.
662
+     *
663
+     * @since 1.0.19
664
+     * @param  string $context View or edit context.
665
+     * @return string
666
+     */
667
+    public function get_path( $context = 'view' ) {
668 668
         $path   = $this->get_prop( 'path', $context );
669
-		$prefix = $this->get_type();
669
+        $prefix = $this->get_type();
670 670
 
671
-		if ( 0 !== strpos( $path, $prefix ) ) {
672
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
673
-			$this->set_path( $path );
674
-		}
671
+        if ( 0 !== strpos( $path, $prefix ) ) {
672
+            $path = sanitize_title( $prefix . '-' . $this->get_id() );
673
+            $this->set_path( $path );
674
+        }
675 675
 
676
-		return $path;
676
+        return $path;
677 677
     }
678 678
 
679 679
     /**
680
-	 * Get the invoice name/title.
681
-	 *
682
-	 * @since 1.0.19
683
-	 * @param  string $context View or edit context.
684
-	 * @return string
685
-	 */
686
-	public function get_name( $context = 'view' ) {
680
+     * Get the invoice name/title.
681
+     *
682
+     * @since 1.0.19
683
+     * @param  string $context View or edit context.
684
+     * @return string
685
+     */
686
+    public function get_name( $context = 'view' ) {
687 687
         return $this->get_prop( 'title', $context );
688 688
     }
689 689
 
690 690
     /**
691
-	 * Alias of self::get_name().
692
-	 *
693
-	 * @since 1.0.19
694
-	 * @param  string $context View or edit context.
695
-	 * @return string
696
-	 */
697
-	public function get_title( $context = 'view' ) {
698
-		return $this->get_name( $context );
691
+     * Alias of self::get_name().
692
+     *
693
+     * @since 1.0.19
694
+     * @param  string $context View or edit context.
695
+     * @return string
696
+     */
697
+    public function get_title( $context = 'view' ) {
698
+        return $this->get_name( $context );
699 699
     }
700 700
 
701 701
     /**
702
-	 * Get the invoice description.
703
-	 *
704
-	 * @since 1.0.19
705
-	 * @param  string $context View or edit context.
706
-	 * @return string
707
-	 */
708
-	public function get_description( $context = 'view' ) {
709
-		return $this->get_prop( 'description', $context );
702
+     * Get the invoice description.
703
+     *
704
+     * @since 1.0.19
705
+     * @param  string $context View or edit context.
706
+     * @return string
707
+     */
708
+    public function get_description( $context = 'view' ) {
709
+        return $this->get_prop( 'description', $context );
710 710
     }
711 711
 
712 712
     /**
713
-	 * Alias of self::get_description().
714
-	 *
715
-	 * @since 1.0.19
716
-	 * @param  string $context View or edit context.
717
-	 * @return string
718
-	 */
719
-	public function get_excerpt( $context = 'view' ) {
720
-		return $this->get_description( $context );
713
+     * Alias of self::get_description().
714
+     *
715
+     * @since 1.0.19
716
+     * @param  string $context View or edit context.
717
+     * @return string
718
+     */
719
+    public function get_excerpt( $context = 'view' ) {
720
+        return $this->get_description( $context );
721 721
     }
722 722
 
723 723
     /**
724
-	 * Alias of self::get_description().
725
-	 *
726
-	 * @since 1.0.19
727
-	 * @param  string $context View or edit context.
728
-	 * @return string
729
-	 */
730
-	public function get_summary( $context = 'view' ) {
731
-		return $this->get_description( $context );
724
+     * Alias of self::get_description().
725
+     *
726
+     * @since 1.0.19
727
+     * @param  string $context View or edit context.
728
+     * @return string
729
+     */
730
+    public function get_summary( $context = 'view' ) {
731
+        return $this->get_description( $context );
732 732
     }
733 733
 
734 734
     /**
735
-	 * Returns the user info.
736
-	 *
737
-	 * @since 1.0.19
735
+     * Returns the user info.
736
+     *
737
+     * @since 1.0.19
738 738
      * @param  string $context View or edit context.
739
-	 * @return array
740
-	 */
739
+     * @return array
740
+     */
741 741
     public function get_user_info( $context = 'view' ) {
742 742
 
743 743
         $user_info = array(
@@ -752,683 +752,683 @@  discard block
 block discarded – undo
752 752
             'state'      => $this->get_state( $context ),
753 753
             'zip'        => $this->get_zip( $context ),
754 754
             'company'    => $this->get_company( $context ),
755
-			'company_id' => $this->get_company_id( $context ),
755
+            'company_id' => $this->get_company_id( $context ),
756 756
             'vat_number' => $this->get_vat_number( $context ),
757 757
             'discount'   => $this->get_discount_code( $context ),
758
-		);
758
+        );
759 759
 
760
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
760
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
761 761
 
762 762
     }
763 763
 
764 764
     /**
765
-	 * Get the user id.
766
-	 *
767
-	 * @since 1.0.19
768
-	 * @param  string $context View or edit context.
769
-	 * @return int
770
-	 */
771
-	public function get_author( $context = 'view' ) {
772
-		return (int) $this->get_prop( 'author', $context );
765
+     * Get the user id.
766
+     *
767
+     * @since 1.0.19
768
+     * @param  string $context View or edit context.
769
+     * @return int
770
+     */
771
+    public function get_author( $context = 'view' ) {
772
+        return (int) $this->get_prop( 'author', $context );
773 773
     }
774 774
 
775 775
     /**
776
-	 * Alias of self::get_author().
777
-	 *
778
-	 * @since 1.0.19
779
-	 * @param  string $context View or edit context.
780
-	 * @return int
781
-	 */
782
-	public function get_user_id( $context = 'view' ) {
783
-		return $this->get_author( $context );
776
+     * Alias of self::get_author().
777
+     *
778
+     * @since 1.0.19
779
+     * @param  string $context View or edit context.
780
+     * @return int
781
+     */
782
+    public function get_user_id( $context = 'view' ) {
783
+        return $this->get_author( $context );
784 784
     }
785 785
 
786
-     /**
787
-	 * Get customer ID.
788
-	 *
789
-	 * @since 1.0.19
790
-	 * @param  string $context View or edit context.
791
-	 * @return int
792
-	 */
793
-	public function get_customer_id( $context = 'view' ) {
794
-		return (int) $this->get_prop( 'customer_id', $context );
786
+        /**
787
+         * Get customer ID.
788
+         *
789
+         * @since 1.0.19
790
+         * @param  string $context View or edit context.
791
+         * @return int
792
+         */
793
+    public function get_customer_id( $context = 'view' ) {
794
+        return (int) $this->get_prop( 'customer_id', $context );
795 795
     }
796 796
 
797 797
     /**
798
-	 * Get the customer's ip.
799
-	 *
800
-	 * @since 1.0.19
801
-	 * @param  string $context View or edit context.
802
-	 * @return string
803
-	 */
804
-	public function get_ip( $context = 'view' ) {
805
-		return $this->get_prop( 'user_ip', $context );
798
+     * Get the customer's ip.
799
+     *
800
+     * @since 1.0.19
801
+     * @param  string $context View or edit context.
802
+     * @return string
803
+     */
804
+    public function get_ip( $context = 'view' ) {
805
+        return $this->get_prop( 'user_ip', $context );
806 806
     }
807 807
 
808 808
     /**
809
-	 * Alias of self::get_ip().
810
-	 *
811
-	 * @since 1.0.19
812
-	 * @param  string $context View or edit context.
813
-	 * @return string
814
-	 */
815
-	public function get_user_ip( $context = 'view' ) {
816
-		return $this->get_ip( $context );
809
+     * Alias of self::get_ip().
810
+     *
811
+     * @since 1.0.19
812
+     * @param  string $context View or edit context.
813
+     * @return string
814
+     */
815
+    public function get_user_ip( $context = 'view' ) {
816
+        return $this->get_ip( $context );
817 817
     }
818 818
 
819
-     /**
820
-	 * Alias of self::get_ip().
821
-	 *
822
-	 * @since 1.0.19
823
-	 * @param  string $context View or edit context.
824
-	 * @return string
825
-	 */
826
-	public function get_customer_ip( $context = 'view' ) {
827
-		return $this->get_ip( $context );
819
+        /**
820
+         * Alias of self::get_ip().
821
+         *
822
+         * @since 1.0.19
823
+         * @param  string $context View or edit context.
824
+         * @return string
825
+         */
826
+    public function get_customer_ip( $context = 'view' ) {
827
+        return $this->get_ip( $context );
828 828
     }
829 829
 
830 830
     /**
831
-	 * Get the customer's first name.
832
-	 *
833
-	 * @since 1.0.19
834
-	 * @param  string $context View or edit context.
835
-	 * @return string
836
-	 */
837
-	public function get_first_name( $context = 'view' ) {
838
-		return $this->get_prop( 'first_name', $context );
831
+     * Get the customer's first name.
832
+     *
833
+     * @since 1.0.19
834
+     * @param  string $context View or edit context.
835
+     * @return string
836
+     */
837
+    public function get_first_name( $context = 'view' ) {
838
+        return $this->get_prop( 'first_name', $context );
839 839
     }
840 840
 
841 841
     /**
842
-	 * Alias of self::get_first_name().
843
-	 *
844
-	 * @since 1.0.19
845
-	 * @param  string $context View or edit context.
846
-	 * @return string
847
-	 */
848
-	public function get_user_first_name( $context = 'view' ) {
849
-		return $this->get_first_name( $context );
842
+     * Alias of self::get_first_name().
843
+     *
844
+     * @since 1.0.19
845
+     * @param  string $context View or edit context.
846
+     * @return string
847
+     */
848
+    public function get_user_first_name( $context = 'view' ) {
849
+        return $this->get_first_name( $context );
850 850
     }
851 851
 
852
-     /**
853
-	 * Alias of self::get_first_name().
854
-	 *
855
-	 * @since 1.0.19
856
-	 * @param  string $context View or edit context.
857
-	 * @return string
858
-	 */
859
-	public function get_customer_first_name( $context = 'view' ) {
860
-		return $this->get_first_name( $context );
852
+        /**
853
+         * Alias of self::get_first_name().
854
+         *
855
+         * @since 1.0.19
856
+         * @param  string $context View or edit context.
857
+         * @return string
858
+         */
859
+    public function get_customer_first_name( $context = 'view' ) {
860
+        return $this->get_first_name( $context );
861 861
     }
862 862
 
863 863
     /**
864
-	 * Get the customer's last name.
865
-	 *
866
-	 * @since 1.0.19
867
-	 * @param  string $context View or edit context.
868
-	 * @return string
869
-	 */
870
-	public function get_last_name( $context = 'view' ) {
871
-		return $this->get_prop( 'last_name', $context );
864
+     * Get the customer's last name.
865
+     *
866
+     * @since 1.0.19
867
+     * @param  string $context View or edit context.
868
+     * @return string
869
+     */
870
+    public function get_last_name( $context = 'view' ) {
871
+        return $this->get_prop( 'last_name', $context );
872 872
     }
873 873
 
874 874
     /**
875
-	 * Alias of self::get_last_name().
876
-	 *
877
-	 * @since 1.0.19
878
-	 * @param  string $context View or edit context.
879
-	 * @return string
880
-	 */
881
-	public function get_user_last_name( $context = 'view' ) {
882
-		return $this->get_last_name( $context );
875
+     * Alias of self::get_last_name().
876
+     *
877
+     * @since 1.0.19
878
+     * @param  string $context View or edit context.
879
+     * @return string
880
+     */
881
+    public function get_user_last_name( $context = 'view' ) {
882
+        return $this->get_last_name( $context );
883 883
     }
884 884
 
885 885
     /**
886
-	 * Alias of self::get_last_name().
887
-	 *
888
-	 * @since 1.0.19
889
-	 * @param  string $context View or edit context.
890
-	 * @return string
891
-	 */
892
-	public function get_customer_last_name( $context = 'view' ) {
893
-		return $this->get_last_name( $context );
886
+     * Alias of self::get_last_name().
887
+     *
888
+     * @since 1.0.19
889
+     * @param  string $context View or edit context.
890
+     * @return string
891
+     */
892
+    public function get_customer_last_name( $context = 'view' ) {
893
+        return $this->get_last_name( $context );
894 894
     }
895 895
 
896 896
     /**
897
-	 * Get the customer's full name.
898
-	 *
899
-	 * @since 1.0.19
900
-	 * @param  string $context View or edit context.
901
-	 * @return string
902
-	 */
903
-	public function get_full_name( $context = 'view' ) {
904
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
897
+     * Get the customer's full name.
898
+     *
899
+     * @since 1.0.19
900
+     * @param  string $context View or edit context.
901
+     * @return string
902
+     */
903
+    public function get_full_name( $context = 'view' ) {
904
+        $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
905 905
 
906
-		if ( ! $name ) {
907
-			$user = get_userdata( $this->get_author( $context ) );
906
+        if ( ! $name ) {
907
+            $user = get_userdata( $this->get_author( $context ) );
908 908
 
909
-			if ( $user ) {
910
-				$name = $user->display_name;
911
-			}
912
-		}
909
+            if ( $user ) {
910
+                $name = $user->display_name;
911
+            }
912
+        }
913 913
 
914
-		if ( ! $name ) {
915
-			$name = $this->get_email( $context );
916
-		}
914
+        if ( ! $name ) {
915
+            $name = $this->get_email( $context );
916
+        }
917 917
 
918
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
918
+        return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
919 919
     }
920 920
 
921 921
     /**
922
-	 * Alias of self::get_full_name().
923
-	 *
924
-	 * @since 1.0.19
925
-	 * @param  string $context View or edit context.
926
-	 * @return string
927
-	 */
928
-	public function get_user_full_name( $context = 'view' ) {
929
-		return $this->get_full_name( $context );
930
-    }
922
+     * Alias of self::get_full_name().
923
+     *
924
+     * @since 1.0.19
925
+     * @param  string $context View or edit context.
926
+     * @return string
927
+     */
928
+    public function get_user_full_name( $context = 'view' ) {
929
+        return $this->get_full_name( $context );
930
+    }
931
+
932
+    /**
933
+     * Alias of self::get_full_name().
934
+     *
935
+     * @since 1.0.19
936
+     * @param  string $context View or edit context.
937
+     * @return string
938
+     */
939
+    public function get_customer_full_name( $context = 'view' ) {
940
+        return $this->get_full_name( $context );
941
+    }
942
+
943
+    /**
944
+     * Get the customer's phone number.
945
+     *
946
+     * @since 1.0.19
947
+     * @param  string $context View or edit context.
948
+     * @return string
949
+     */
950
+    public function get_phone( $context = 'view' ) {
951
+        return $this->get_prop( 'phone', $context );
952
+    }
953
+
954
+    /**
955
+     * Alias of self::get_phone().
956
+     *
957
+     * @since 1.0.19
958
+     * @param  string $context View or edit context.
959
+     * @return string
960
+     */
961
+    public function get_phone_number( $context = 'view' ) {
962
+        return $this->get_phone( $context );
963
+    }
964
+
965
+    /**
966
+     * Alias of self::get_phone().
967
+     *
968
+     * @since 1.0.19
969
+     * @param  string $context View or edit context.
970
+     * @return string
971
+     */
972
+    public function get_user_phone( $context = 'view' ) {
973
+        return $this->get_phone( $context );
974
+    }
975
+
976
+    /**
977
+     * Alias of self::get_phone().
978
+     *
979
+     * @since 1.0.19
980
+     * @param  string $context View or edit context.
981
+     * @return string
982
+     */
983
+    public function get_customer_phone( $context = 'view' ) {
984
+        return $this->get_phone( $context );
985
+    }
986
+
987
+    /**
988
+     * Get the customer's email address.
989
+     *
990
+     * @since 1.0.19
991
+     * @param  string $context View or edit context.
992
+     * @return string
993
+     */
994
+    public function get_email( $context = 'view' ) {
995
+        return $this->get_prop( 'email', $context );
996
+    }
997
+
998
+    /**
999
+     * Alias of self::get_email().
1000
+     *
1001
+     * @since 1.0.19
1002
+     * @param  string $context View or edit context.
1003
+     * @return string
1004
+     */
1005
+    public function get_email_address( $context = 'view' ) {
1006
+        return $this->get_email( $context );
1007
+    }
1008
+
1009
+    /**
1010
+     * Alias of self::get_email().
1011
+     *
1012
+     * @since 1.0.19
1013
+     * @param  string $context View or edit context.
1014
+     * @return string
1015
+     */
1016
+    public function get_user_email( $context = 'view' ) {
1017
+        return $this->get_email( $context );
1018
+    }
1019
+
1020
+    /**
1021
+     * Alias of self::get_email().
1022
+     *
1023
+     * @since 1.0.19
1024
+     * @param  string $context View or edit context.
1025
+     * @return string
1026
+     */
1027
+    public function get_customer_email( $context = 'view' ) {
1028
+        return $this->get_email( $context );
1029
+    }
1030
+
1031
+    /**
1032
+     * Get the customer's country.
1033
+     *
1034
+     * @since 1.0.19
1035
+     * @param  string $context View or edit context.
1036
+     * @return string
1037
+     */
1038
+    public function get_country( $context = 'view' ) {
1039
+        $country = $this->get_prop( 'country', $context );
1040
+        return empty( $country ) ? wpinv_get_default_country() : $country;
1041
+    }
1042
+
1043
+    /**
1044
+     * Alias of self::get_country().
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  string $context View or edit context.
1048
+     * @return string
1049
+     */
1050
+    public function get_user_country( $context = 'view' ) {
1051
+        return $this->get_country( $context );
1052
+    }
1053
+
1054
+    /**
1055
+     * Alias of self::get_country().
1056
+     *
1057
+     * @since 1.0.19
1058
+     * @param  string $context View or edit context.
1059
+     * @return string
1060
+     */
1061
+    public function get_customer_country( $context = 'view' ) {
1062
+        return $this->get_country( $context );
1063
+    }
1064
+
1065
+    /**
1066
+     * Get the customer's state.
1067
+     *
1068
+     * @since 1.0.19
1069
+     * @param  string $context View or edit context.
1070
+     * @return string
1071
+     */
1072
+    public function get_state( $context = 'view' ) {
1073
+        $state = $this->get_prop( 'state', $context );
1074
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1075
+    }
931 1076
 
932 1077
     /**
933
-	 * Alias of self::get_full_name().
934
-	 *
935
-	 * @since 1.0.19
936
-	 * @param  string $context View or edit context.
937
-	 * @return string
938
-	 */
939
-	public function get_customer_full_name( $context = 'view' ) {
940
-		return $this->get_full_name( $context );
1078
+     * Alias of self::get_state().
1079
+     *
1080
+     * @since 1.0.19
1081
+     * @param  string $context View or edit context.
1082
+     * @return string
1083
+     */
1084
+    public function get_user_state( $context = 'view' ) {
1085
+        return $this->get_state( $context );
941 1086
     }
942 1087
 
943 1088
     /**
944
-	 * Get the customer's phone number.
945
-	 *
946
-	 * @since 1.0.19
947
-	 * @param  string $context View or edit context.
948
-	 * @return string
949
-	 */
950
-	public function get_phone( $context = 'view' ) {
951
-		return $this->get_prop( 'phone', $context );
1089
+     * Alias of self::get_state().
1090
+     *
1091
+     * @since 1.0.19
1092
+     * @param  string $context View or edit context.
1093
+     * @return string
1094
+     */
1095
+    public function get_customer_state( $context = 'view' ) {
1096
+        return $this->get_state( $context );
952 1097
     }
953 1098
 
954 1099
     /**
955
-	 * Alias of self::get_phone().
956
-	 *
957
-	 * @since 1.0.19
958
-	 * @param  string $context View or edit context.
959
-	 * @return string
960
-	 */
961
-	public function get_phone_number( $context = 'view' ) {
962
-		return $this->get_phone( $context );
1100
+     * Get the customer's city.
1101
+     *
1102
+     * @since 1.0.19
1103
+     * @param  string $context View or edit context.
1104
+     * @return string
1105
+     */
1106
+    public function get_city( $context = 'view' ) {
1107
+        return $this->get_prop( 'city', $context );
963 1108
     }
964 1109
 
965 1110
     /**
966
-	 * Alias of self::get_phone().
967
-	 *
968
-	 * @since 1.0.19
969
-	 * @param  string $context View or edit context.
970
-	 * @return string
971
-	 */
972
-	public function get_user_phone( $context = 'view' ) {
973
-		return $this->get_phone( $context );
1111
+     * Alias of self::get_city().
1112
+     *
1113
+     * @since 1.0.19
1114
+     * @param  string $context View or edit context.
1115
+     * @return string
1116
+     */
1117
+    public function get_user_city( $context = 'view' ) {
1118
+        return $this->get_city( $context );
974 1119
     }
975 1120
 
976 1121
     /**
977
-	 * Alias of self::get_phone().
978
-	 *
979
-	 * @since 1.0.19
980
-	 * @param  string $context View or edit context.
981
-	 * @return string
982
-	 */
983
-	public function get_customer_phone( $context = 'view' ) {
984
-		return $this->get_phone( $context );
1122
+     * Alias of self::get_city().
1123
+     *
1124
+     * @since 1.0.19
1125
+     * @param  string $context View or edit context.
1126
+     * @return string
1127
+     */
1128
+    public function get_customer_city( $context = 'view' ) {
1129
+        return $this->get_city( $context );
985 1130
     }
986 1131
 
987 1132
     /**
988
-	 * Get the customer's email address.
989
-	 *
990
-	 * @since 1.0.19
991
-	 * @param  string $context View or edit context.
992
-	 * @return string
993
-	 */
994
-	public function get_email( $context = 'view' ) {
995
-		return $this->get_prop( 'email', $context );
1133
+     * Get the customer's zip.
1134
+     *
1135
+     * @since 1.0.19
1136
+     * @param  string $context View or edit context.
1137
+     * @return string
1138
+     */
1139
+    public function get_zip( $context = 'view' ) {
1140
+        return $this->get_prop( 'zip', $context );
996 1141
     }
997 1142
 
998 1143
     /**
999
-	 * Alias of self::get_email().
1000
-	 *
1001
-	 * @since 1.0.19
1002
-	 * @param  string $context View or edit context.
1003
-	 * @return string
1004
-	 */
1005
-	public function get_email_address( $context = 'view' ) {
1006
-		return $this->get_email( $context );
1144
+     * Alias of self::get_zip().
1145
+     *
1146
+     * @since 1.0.19
1147
+     * @param  string $context View or edit context.
1148
+     * @return string
1149
+     */
1150
+    public function get_user_zip( $context = 'view' ) {
1151
+        return $this->get_zip( $context );
1007 1152
     }
1008 1153
 
1009 1154
     /**
1010
-	 * Alias of self::get_email().
1011
-	 *
1012
-	 * @since 1.0.19
1013
-	 * @param  string $context View or edit context.
1014
-	 * @return string
1015
-	 */
1016
-	public function get_user_email( $context = 'view' ) {
1017
-		return $this->get_email( $context );
1155
+     * Alias of self::get_zip().
1156
+     *
1157
+     * @since 1.0.19
1158
+     * @param  string $context View or edit context.
1159
+     * @return string
1160
+     */
1161
+    public function get_customer_zip( $context = 'view' ) {
1162
+        return $this->get_zip( $context );
1018 1163
     }
1019 1164
 
1020 1165
     /**
1021
-	 * Alias of self::get_email().
1022
-	 *
1023
-	 * @since 1.0.19
1024
-	 * @param  string $context View or edit context.
1025
-	 * @return string
1026
-	 */
1027
-	public function get_customer_email( $context = 'view' ) {
1028
-		return $this->get_email( $context );
1166
+     * Get the customer's company.
1167
+     *
1168
+     * @since 1.0.19
1169
+     * @param  string $context View or edit context.
1170
+     * @return string
1171
+     */
1172
+    public function get_company( $context = 'view' ) {
1173
+        return $this->get_prop( 'company', $context );
1029 1174
     }
1030 1175
 
1031 1176
     /**
1032
-	 * Get the customer's country.
1033
-	 *
1034
-	 * @since 1.0.19
1035
-	 * @param  string $context View or edit context.
1036
-	 * @return string
1037
-	 */
1038
-	public function get_country( $context = 'view' ) {
1039
-		$country = $this->get_prop( 'country', $context );
1040
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1177
+     * Alias of self::get_company().
1178
+     *
1179
+     * @since 1.0.19
1180
+     * @param  string $context View or edit context.
1181
+     * @return string
1182
+     */
1183
+    public function get_user_company( $context = 'view' ) {
1184
+        return $this->get_company( $context );
1041 1185
     }
1042 1186
 
1043 1187
     /**
1044
-	 * Alias of self::get_country().
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  string $context View or edit context.
1048
-	 * @return string
1049
-	 */
1050
-	public function get_user_country( $context = 'view' ) {
1051
-		return $this->get_country( $context );
1188
+     * Alias of self::get_company().
1189
+     *
1190
+     * @since 1.0.19
1191
+     * @param  string $context View or edit context.
1192
+     * @return string
1193
+     */
1194
+    public function get_customer_company( $context = 'view' ) {
1195
+        return $this->get_company( $context );
1052 1196
     }
1053 1197
 
1054 1198
     /**
1055
-	 * Alias of self::get_country().
1056
-	 *
1057
-	 * @since 1.0.19
1058
-	 * @param  string $context View or edit context.
1059
-	 * @return string
1060
-	 */
1061
-	public function get_customer_country( $context = 'view' ) {
1062
-		return $this->get_country( $context );
1199
+     * Get the customer's company id.
1200
+     *
1201
+     * @since 1.0.19
1202
+     * @param  string $context View or edit context.
1203
+     * @return string
1204
+     */
1205
+    public function get_company_id( $context = 'view' ) {
1206
+        return $this->get_prop( 'company_id', $context );
1063 1207
     }
1064 1208
 
1065 1209
     /**
1066
-	 * Get the customer's state.
1067
-	 *
1068
-	 * @since 1.0.19
1069
-	 * @param  string $context View or edit context.
1070
-	 * @return string
1071
-	 */
1072
-	public function get_state( $context = 'view' ) {
1073
-		$state = $this->get_prop( 'state', $context );
1074
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1210
+     * Get the customer's vat number.
1211
+     *
1212
+     * @since 1.0.19
1213
+     * @param  string $context View or edit context.
1214
+     * @return string
1215
+     */
1216
+    public function get_vat_number( $context = 'view' ) {
1217
+        return $this->get_prop( 'vat_number', $context );
1075 1218
     }
1076 1219
 
1077 1220
     /**
1078
-	 * Alias of self::get_state().
1079
-	 *
1080
-	 * @since 1.0.19
1081
-	 * @param  string $context View or edit context.
1082
-	 * @return string
1083
-	 */
1084
-	public function get_user_state( $context = 'view' ) {
1085
-		return $this->get_state( $context );
1221
+     * Alias of self::get_vat_number().
1222
+     *
1223
+     * @since 1.0.19
1224
+     * @param  string $context View or edit context.
1225
+     * @return string
1226
+     */
1227
+    public function get_user_vat_number( $context = 'view' ) {
1228
+        return $this->get_vat_number( $context );
1086 1229
     }
1087 1230
 
1088 1231
     /**
1089
-	 * Alias of self::get_state().
1090
-	 *
1091
-	 * @since 1.0.19
1092
-	 * @param  string $context View or edit context.
1093
-	 * @return string
1094
-	 */
1095
-	public function get_customer_state( $context = 'view' ) {
1096
-		return $this->get_state( $context );
1232
+     * Alias of self::get_vat_number().
1233
+     *
1234
+     * @since 1.0.19
1235
+     * @param  string $context View or edit context.
1236
+     * @return string
1237
+     */
1238
+    public function get_customer_vat_number( $context = 'view' ) {
1239
+        return $this->get_vat_number( $context );
1097 1240
     }
1098 1241
 
1099 1242
     /**
1100
-	 * Get the customer's city.
1101
-	 *
1102
-	 * @since 1.0.19
1103
-	 * @param  string $context View or edit context.
1104
-	 * @return string
1105
-	 */
1106
-	public function get_city( $context = 'view' ) {
1107
-		return $this->get_prop( 'city', $context );
1243
+     * Get the customer's vat rate.
1244
+     *
1245
+     * @since 1.0.19
1246
+     * @param  string $context View or edit context.
1247
+     * @return string
1248
+     */
1249
+    public function get_vat_rate( $context = 'view' ) {
1250
+        return $this->get_prop( 'vat_rate', $context );
1108 1251
     }
1109 1252
 
1110 1253
     /**
1111
-	 * Alias of self::get_city().
1112
-	 *
1113
-	 * @since 1.0.19
1114
-	 * @param  string $context View or edit context.
1115
-	 * @return string
1116
-	 */
1117
-	public function get_user_city( $context = 'view' ) {
1118
-		return $this->get_city( $context );
1254
+     * Alias of self::get_vat_rate().
1255
+     *
1256
+     * @since 1.0.19
1257
+     * @param  string $context View or edit context.
1258
+     * @return string
1259
+     */
1260
+    public function get_user_vat_rate( $context = 'view' ) {
1261
+        return $this->get_vat_rate( $context );
1262
+    }
1263
+
1264
+    /**
1265
+     * Alias of self::get_vat_rate().
1266
+     *
1267
+     * @since 1.0.19
1268
+     * @param  string $context View or edit context.
1269
+     * @return string
1270
+     */
1271
+    public function get_customer_vat_rate( $context = 'view' ) {
1272
+        return $this->get_vat_rate( $context );
1273
+    }
1274
+
1275
+    /**
1276
+     * Get the customer's address.
1277
+     *
1278
+     * @since 1.0.19
1279
+     * @param  string $context View or edit context.
1280
+     * @return string
1281
+     */
1282
+    public function get_address( $context = 'view' ) {
1283
+        return $this->get_prop( 'address', $context );
1284
+    }
1285
+
1286
+    /**
1287
+     * Alias of self::get_address().
1288
+     *
1289
+     * @since 1.0.19
1290
+     * @param  string $context View or edit context.
1291
+     * @return string
1292
+     */
1293
+    public function get_user_address( $context = 'view' ) {
1294
+        return $this->get_address( $context );
1119 1295
     }
1120 1296
 
1121 1297
     /**
1122
-	 * Alias of self::get_city().
1123
-	 *
1124
-	 * @since 1.0.19
1125
-	 * @param  string $context View or edit context.
1126
-	 * @return string
1127
-	 */
1128
-	public function get_customer_city( $context = 'view' ) {
1129
-		return $this->get_city( $context );
1298
+     * Alias of self::get_address().
1299
+     *
1300
+     * @since 1.0.19
1301
+     * @param  string $context View or edit context.
1302
+     * @return string
1303
+     */
1304
+    public function get_customer_address( $context = 'view' ) {
1305
+        return $this->get_address( $context );
1130 1306
     }
1131 1307
 
1132 1308
     /**
1133
-	 * Get the customer's zip.
1134
-	 *
1135
-	 * @since 1.0.19
1136
-	 * @param  string $context View or edit context.
1137
-	 * @return string
1138
-	 */
1139
-	public function get_zip( $context = 'view' ) {
1140
-		return $this->get_prop( 'zip', $context );
1309
+     * Get whether the customer has viewed the invoice or not.
1310
+     *
1311
+     * @since 1.0.19
1312
+     * @param  string $context View or edit context.
1313
+     * @return bool
1314
+     */
1315
+    public function get_is_viewed( $context = 'view' ) {
1316
+        return (bool) $this->get_prop( 'is_viewed', $context );
1141 1317
     }
1142 1318
 
1143 1319
     /**
1144
-	 * Alias of self::get_zip().
1145
-	 *
1146
-	 * @since 1.0.19
1147
-	 * @param  string $context View or edit context.
1148
-	 * @return string
1149
-	 */
1150
-	public function get_user_zip( $context = 'view' ) {
1151
-		return $this->get_zip( $context );
1320
+     * Get other recipients for invoice communications.
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return bool
1325
+     */
1326
+    public function get_email_cc( $context = 'view' ) {
1327
+        return $this->get_prop( 'email_cc', $context );
1152 1328
     }
1153 1329
 
1154 1330
     /**
1155
-	 * Alias of self::get_zip().
1156
-	 *
1157
-	 * @since 1.0.19
1158
-	 * @param  string $context View or edit context.
1159
-	 * @return string
1160
-	 */
1161
-	public function get_customer_zip( $context = 'view' ) {
1162
-		return $this->get_zip( $context );
1331
+     * Get invoice template.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return bool
1336
+     */
1337
+    public function get_template( $context = 'view' ) {
1338
+        return $this->get_prop( 'template', $context );
1163 1339
     }
1164 1340
 
1165 1341
     /**
1166
-	 * Get the customer's company.
1167
-	 *
1168
-	 * @since 1.0.19
1169
-	 * @param  string $context View or edit context.
1170
-	 * @return string
1171
-	 */
1172
-	public function get_company( $context = 'view' ) {
1173
-		return $this->get_prop( 'company', $context );
1342
+     * Get invoice source.
1343
+     *
1344
+     * @since 1.0.19
1345
+     * @param  string $context View or edit context.
1346
+     * @return bool
1347
+     */
1348
+    public function get_created_via( $context = 'view' ) {
1349
+        return $this->get_prop( 'created_via', $context );
1174 1350
     }
1175 1351
 
1176 1352
     /**
1177
-	 * Alias of self::get_company().
1178
-	 *
1179
-	 * @since 1.0.19
1180
-	 * @param  string $context View or edit context.
1181
-	 * @return string
1182
-	 */
1183
-	public function get_user_company( $context = 'view' ) {
1184
-		return $this->get_company( $context );
1353
+     * Get whether the customer has confirmed their address.
1354
+     *
1355
+     * @since 1.0.19
1356
+     * @param  string $context View or edit context.
1357
+     * @return bool
1358
+     */
1359
+    public function get_address_confirmed( $context = 'view' ) {
1360
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1185 1361
     }
1186 1362
 
1187 1363
     /**
1188
-	 * Alias of self::get_company().
1189
-	 *
1190
-	 * @since 1.0.19
1191
-	 * @param  string $context View or edit context.
1192
-	 * @return string
1193
-	 */
1194
-	public function get_customer_company( $context = 'view' ) {
1195
-		return $this->get_company( $context );
1364
+     * Alias of self::get_address_confirmed().
1365
+     *
1366
+     * @since 1.0.19
1367
+     * @param  string $context View or edit context.
1368
+     * @return bool
1369
+     */
1370
+    public function get_user_address_confirmed( $context = 'view' ) {
1371
+        return $this->get_address_confirmed( $context );
1196 1372
     }
1197 1373
 
1198
-	/**
1199
-	 * Get the customer's company id.
1200
-	 *
1201
-	 * @since 1.0.19
1202
-	 * @param  string $context View or edit context.
1203
-	 * @return string
1204
-	 */
1205
-	public function get_company_id( $context = 'view' ) {
1206
-		return $this->get_prop( 'company_id', $context );
1374
+    /**
1375
+     * Alias of self::get_address().
1376
+     *
1377
+     * @since 1.0.19
1378
+     * @param  string $context View or edit context.
1379
+     * @return bool
1380
+     */
1381
+    public function get_customer_address_confirmed( $context = 'view' ) {
1382
+        return $this->get_address_confirmed( $context );
1207 1383
     }
1208 1384
 
1209 1385
     /**
1210
-	 * Get the customer's vat number.
1211
-	 *
1212
-	 * @since 1.0.19
1213
-	 * @param  string $context View or edit context.
1214
-	 * @return string
1215
-	 */
1216
-	public function get_vat_number( $context = 'view' ) {
1217
-		return $this->get_prop( 'vat_number', $context );
1386
+     * Get the shipping address.
1387
+     *
1388
+     * @since 1.0.19
1389
+     * @return array|false
1390
+     */
1391
+    public function get_shipping_address() {
1392
+
1393
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1394
+        return is_array( $shipping_address ) ? $shipping_address : false;
1218 1395
     }
1219 1396
 
1220 1397
     /**
1221
-	 * Alias of self::get_vat_number().
1222
-	 *
1223
-	 * @since 1.0.19
1224
-	 * @param  string $context View or edit context.
1225
-	 * @return string
1226
-	 */
1227
-	public function get_user_vat_number( $context = 'view' ) {
1228
-		return $this->get_vat_number( $context );
1398
+     * Check if the invoice has a shipping address.
1399
+     */
1400
+    public function has_shipping_address() {
1401
+        return false !== $this->get_shipping_address();
1229 1402
     }
1230 1403
 
1231 1404
     /**
1232
-	 * Alias of self::get_vat_number().
1233
-	 *
1234
-	 * @since 1.0.19
1235
-	 * @param  string $context View or edit context.
1236
-	 * @return string
1237
-	 */
1238
-	public function get_customer_vat_number( $context = 'view' ) {
1239
-		return $this->get_vat_number( $context );
1405
+     * Get the shipping amount.
1406
+     *
1407
+     * @since 1.0.19
1408
+     * @param  string $context View or edit context.
1409
+     * @return float
1410
+     */
1411
+    public function get_shipping( $context = 'view' ) {
1412
+
1413
+        if ( $context = 'view' ) {
1414
+            return floatval( $this->get_prop( 'shipping', $context ) );
1415
+        }
1416
+
1417
+        return $this->get_prop( 'shipping', $context );
1240 1418
     }
1241 1419
 
1242
-    /**
1243
-	 * Get the customer's vat rate.
1244
-	 *
1245
-	 * @since 1.0.19
1246
-	 * @param  string $context View or edit context.
1247
-	 * @return string
1248
-	 */
1249
-	public function get_vat_rate( $context = 'view' ) {
1250
-		return $this->get_prop( 'vat_rate', $context );
1251
-    }
1252
-
1253
-    /**
1254
-	 * Alias of self::get_vat_rate().
1255
-	 *
1256
-	 * @since 1.0.19
1257
-	 * @param  string $context View or edit context.
1258
-	 * @return string
1259
-	 */
1260
-	public function get_user_vat_rate( $context = 'view' ) {
1261
-		return $this->get_vat_rate( $context );
1262
-    }
1263
-
1264
-    /**
1265
-	 * Alias of self::get_vat_rate().
1266
-	 *
1267
-	 * @since 1.0.19
1268
-	 * @param  string $context View or edit context.
1269
-	 * @return string
1270
-	 */
1271
-	public function get_customer_vat_rate( $context = 'view' ) {
1272
-		return $this->get_vat_rate( $context );
1273
-    }
1274
-
1275
-    /**
1276
-	 * Get the customer's address.
1277
-	 *
1278
-	 * @since 1.0.19
1279
-	 * @param  string $context View or edit context.
1280
-	 * @return string
1281
-	 */
1282
-	public function get_address( $context = 'view' ) {
1283
-		return $this->get_prop( 'address', $context );
1284
-    }
1285
-
1286
-    /**
1287
-	 * Alias of self::get_address().
1288
-	 *
1289
-	 * @since 1.0.19
1290
-	 * @param  string $context View or edit context.
1291
-	 * @return string
1292
-	 */
1293
-	public function get_user_address( $context = 'view' ) {
1294
-		return $this->get_address( $context );
1295
-    }
1296
-
1297
-    /**
1298
-	 * Alias of self::get_address().
1299
-	 *
1300
-	 * @since 1.0.19
1301
-	 * @param  string $context View or edit context.
1302
-	 * @return string
1303
-	 */
1304
-	public function get_customer_address( $context = 'view' ) {
1305
-		return $this->get_address( $context );
1306
-    }
1307
-
1308
-    /**
1309
-	 * Get whether the customer has viewed the invoice or not.
1310
-	 *
1311
-	 * @since 1.0.19
1312
-	 * @param  string $context View or edit context.
1313
-	 * @return bool
1314
-	 */
1315
-	public function get_is_viewed( $context = 'view' ) {
1316
-		return (bool) $this->get_prop( 'is_viewed', $context );
1317
-	}
1318
-
1319
-	/**
1320
-	 * Get other recipients for invoice communications.
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return bool
1325
-	 */
1326
-	public function get_email_cc( $context = 'view' ) {
1327
-		return $this->get_prop( 'email_cc', $context );
1328
-	}
1329
-
1330
-	/**
1331
-	 * Get invoice template.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return bool
1336
-	 */
1337
-	public function get_template( $context = 'view' ) {
1338
-		return $this->get_prop( 'template', $context );
1339
-	}
1340
-
1341
-	/**
1342
-	 * Get invoice source.
1343
-	 *
1344
-	 * @since 1.0.19
1345
-	 * @param  string $context View or edit context.
1346
-	 * @return bool
1347
-	 */
1348
-	public function get_created_via( $context = 'view' ) {
1349
-		return $this->get_prop( 'created_via', $context );
1350
-	}
1351
-
1352
-	/**
1353
-	 * Get whether the customer has confirmed their address.
1354
-	 *
1355
-	 * @since 1.0.19
1356
-	 * @param  string $context View or edit context.
1357
-	 * @return bool
1358
-	 */
1359
-	public function get_address_confirmed( $context = 'view' ) {
1360
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1361
-    }
1362
-
1363
-    /**
1364
-	 * Alias of self::get_address_confirmed().
1365
-	 *
1366
-	 * @since 1.0.19
1367
-	 * @param  string $context View or edit context.
1368
-	 * @return bool
1369
-	 */
1370
-	public function get_user_address_confirmed( $context = 'view' ) {
1371
-		return $this->get_address_confirmed( $context );
1372
-    }
1373
-
1374
-    /**
1375
-	 * Alias of self::get_address().
1376
-	 *
1377
-	 * @since 1.0.19
1378
-	 * @param  string $context View or edit context.
1379
-	 * @return bool
1380
-	 */
1381
-	public function get_customer_address_confirmed( $context = 'view' ) {
1382
-		return $this->get_address_confirmed( $context );
1383
-    }
1384
-
1385
-	/**
1386
-	 * Get the shipping address.
1387
-	 *
1388
-	 * @since 1.0.19
1389
-	 * @return array|false
1390
-	 */
1391
-	public function get_shipping_address() {
1392
-
1393
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1394
-		return is_array( $shipping_address ) ? $shipping_address : false;
1395
-    }
1396
-
1397
-	/**
1398
-	 * Check if the invoice has a shipping address.
1399
-	 */
1400
-	public function has_shipping_address() {
1401
-		return false !== $this->get_shipping_address();
1402
-    }
1403
-
1404
-	/**
1405
-	 * Get the shipping amount.
1406
-	 *
1407
-	 * @since 1.0.19
1408
-	 * @param  string $context View or edit context.
1409
-	 * @return float
1410
-	 */
1411
-	public function get_shipping( $context = 'view' ) {
1412
-
1413
-		if ( $context = 'view' ) {
1414
-			return floatval( $this->get_prop( 'shipping', $context ) );
1415
-		}
1416
-
1417
-		return $this->get_prop( 'shipping', $context );
1418
-    }
1419
-
1420
-	public function has_shipping() {
1421
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1422
-    }
1423
-
1424
-    /**
1425
-	 * Get the invoice subtotal.
1426
-	 *
1427
-	 * @since 1.0.19
1428
-	 * @param  string $context View or edit context.
1429
-	 * @return float
1430
-	 */
1431
-	public function get_subtotal( $context = 'view' ) {
1420
+    public function has_shipping() {
1421
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1422
+    }
1423
+
1424
+    /**
1425
+     * Get the invoice subtotal.
1426
+     *
1427
+     * @since 1.0.19
1428
+     * @param  string $context View or edit context.
1429
+     * @return float
1430
+     */
1431
+    public function get_subtotal( $context = 'view' ) {
1432 1432
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1433 1433
 
1434 1434
         // Backwards compatibility.
@@ -1440,198 +1440,198 @@  discard block
 block discarded – undo
1440 1440
     }
1441 1441
 
1442 1442
     /**
1443
-	 * Get the invoice discount total.
1444
-	 *
1445
-	 * @since 1.0.19
1446
-	 * @param  string $context View or edit context.
1447
-	 * @return float
1448
-	 */
1449
-	public function get_total_discount( $context = 'view' ) {
1450
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1443
+     * Get the invoice discount total.
1444
+     *
1445
+     * @since 1.0.19
1446
+     * @param  string $context View or edit context.
1447
+     * @return float
1448
+     */
1449
+    public function get_total_discount( $context = 'view' ) {
1450
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1451 1451
     }
1452 1452
 
1453 1453
     /**
1454
-	 * Get the invoice tax total.
1455
-	 *
1456
-	 * @since 1.0.19
1457
-	 * @param  string $context View or edit context.
1458
-	 * @return float
1459
-	 */
1460
-	public function get_total_tax( $context = 'view' ) {
1461
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1462
-	}
1454
+     * Get the invoice tax total.
1455
+     *
1456
+     * @since 1.0.19
1457
+     * @param  string $context View or edit context.
1458
+     * @return float
1459
+     */
1460
+    public function get_total_tax( $context = 'view' ) {
1461
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1462
+    }
1463 1463
 
1464
-	/**
1465
-	 * @deprecated
1466
-	 */
1467
-	public function get_final_tax( $currency = false ) {
1468
-		$tax = $this->get_total_tax();
1464
+    /**
1465
+     * @deprecated
1466
+     */
1467
+    public function get_final_tax( $currency = false ) {
1468
+        $tax = $this->get_total_tax();
1469 1469
 
1470 1470
         if ( $currency ) {
1471
-			return wpinv_price( $tax, $this->get_currency() );
1471
+            return wpinv_price( $tax, $this->get_currency() );
1472 1472
         }
1473 1473
 
1474 1474
         return $tax;
1475 1475
     }
1476 1476
 
1477 1477
     /**
1478
-	 * Get the invoice fees total.
1479
-	 *
1480
-	 * @since 1.0.19
1481
-	 * @param  string $context View or edit context.
1482
-	 * @return float
1483
-	 */
1484
-	public function get_total_fees( $context = 'view' ) {
1485
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1478
+     * Get the invoice fees total.
1479
+     *
1480
+     * @since 1.0.19
1481
+     * @param  string $context View or edit context.
1482
+     * @return float
1483
+     */
1484
+    public function get_total_fees( $context = 'view' ) {
1485
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1486 1486
     }
1487 1487
 
1488 1488
     /**
1489
-	 * Alias for self::get_total_fees().
1490
-	 *
1491
-	 * @since 1.0.19
1492
-	 * @param  string $context View or edit context.
1493
-	 * @return float
1494
-	 */
1495
-	public function get_fees_total( $context = 'view' ) {
1496
-		return $this->get_total_fees( $context );
1489
+     * Alias for self::get_total_fees().
1490
+     *
1491
+     * @since 1.0.19
1492
+     * @param  string $context View or edit context.
1493
+     * @return float
1494
+     */
1495
+    public function get_fees_total( $context = 'view' ) {
1496
+        return $this->get_total_fees( $context );
1497 1497
     }
1498 1498
 
1499 1499
     /**
1500
-	 * Get the invoice total.
1501
-	 *
1502
-	 * @since 1.0.19
1500
+     * Get the invoice total.
1501
+     *
1502
+     * @since 1.0.19
1503 1503
      * @return float
1504
-	 */
1505
-	public function get_total( $context = 'view' ) {
1506
-		$total = $this->get_prop( 'total', $context );
1507
-
1508
-		if ( $this->has_shipping() && $context == 'view' ) {
1509
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1510
-		}
1511
-
1512
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1513
-	}
1514
-
1515
-	/**
1516
-	 * Retrieves the non-recurring total of items.
1517
-	 *
1518
-	 * @since 2.3.0
1519
-	 * @return float
1520
-	 */
1521
-	public function get_non_recurring_total() {
1522
-
1523
-		$subtotal = 0;
1524
-		foreach ( $this->get_items() as $item ) {
1525
-			if ( ! $item->is_recurring() ) {
1526
-				$subtotal += $item->get_sub_total();
1527
-			}
1528
-		}
1529
-
1530
-		foreach ( $this->get_fees() as $fee ) {
1531
-			if ( empty( $fee['recurring_fee'] ) ) {
1532
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1533
-			}
1534
-		}
1535
-
1536
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1504
+     */
1505
+    public function get_total( $context = 'view' ) {
1506
+        $total = $this->get_prop( 'total', $context );
1507
+
1508
+        if ( $this->has_shipping() && $context == 'view' ) {
1509
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1510
+        }
1511
+
1512
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1513
+    }
1514
+
1515
+    /**
1516
+     * Retrieves the non-recurring total of items.
1517
+     *
1518
+     * @since 2.3.0
1519
+     * @return float
1520
+     */
1521
+    public function get_non_recurring_total() {
1522
+
1523
+        $subtotal = 0;
1524
+        foreach ( $this->get_items() as $item ) {
1525
+            if ( ! $item->is_recurring() ) {
1526
+                $subtotal += $item->get_sub_total();
1527
+            }
1528
+        }
1529
+
1530
+        foreach ( $this->get_fees() as $fee ) {
1531
+            if ( empty( $fee['recurring_fee'] ) ) {
1532
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1533
+            }
1534
+        }
1535
+
1536
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1537 1537
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1538 1538
 
1539 1539
     }
1540 1540
 
1541
-	/**
1542
-	 * Get the invoice totals.
1543
-	 *
1544
-	 * @since 1.0.19
1541
+    /**
1542
+     * Get the invoice totals.
1543
+     *
1544
+     * @since 1.0.19
1545 1545
      * @return array
1546
-	 */
1547
-	public function get_totals() {
1548
-		return $this->totals;
1546
+     */
1547
+    public function get_totals() {
1548
+        return $this->totals;
1549 1549
     }
1550 1550
 
1551 1551
     /**
1552
-	 * Get the initial invoice total.
1553
-	 *
1554
-	 * @since 1.0.19
1552
+     * Get the initial invoice total.
1553
+     *
1554
+     * @since 1.0.19
1555 1555
      * @param  string $context View or edit context.
1556 1556
      * @return float
1557
-	 */
1557
+     */
1558 1558
     public function get_initial_total() {
1559 1559
 
1560
-		if ( empty( $this->totals ) ) {
1561
-			$this->recalculate_total();
1562
-		}
1560
+        if ( empty( $this->totals ) ) {
1561
+            $this->recalculate_total();
1562
+        }
1563 1563
 
1564
-		$tax      = $this->totals['tax']['initial'];
1565
-		$fee      = $this->totals['fee']['initial'];
1566
-		$discount = $this->totals['discount']['initial'];
1567
-		$subtotal = $this->totals['subtotal']['initial'];
1568
-		$total    = $tax + $fee - $discount + $subtotal;
1564
+        $tax      = $this->totals['tax']['initial'];
1565
+        $fee      = $this->totals['fee']['initial'];
1566
+        $discount = $this->totals['discount']['initial'];
1567
+        $subtotal = $this->totals['subtotal']['initial'];
1568
+        $total    = $tax + $fee - $discount + $subtotal;
1569 1569
 
1570
-		if ( 0 > $total ) {
1571
-			$total = 0;
1572
-		}
1570
+        if ( 0 > $total ) {
1571
+            $total = 0;
1572
+        }
1573 1573
 
1574
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1574
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1575 1575
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1576
-	}
1576
+    }
1577 1577
 
1578
-	/**
1579
-	 * Get the recurring invoice total.
1580
-	 *
1581
-	 * @since 1.0.19
1578
+    /**
1579
+     * Get the recurring invoice total.
1580
+     *
1581
+     * @since 1.0.19
1582 1582
      * @param  string $context View or edit context.
1583 1583
      * @return float
1584
-	 */
1584
+     */
1585 1585
     public function get_recurring_total() {
1586 1586
 
1587
-		if ( empty( $this->totals ) ) {
1588
-			$this->recalculate_total();
1589
-		}
1587
+        if ( empty( $this->totals ) ) {
1588
+            $this->recalculate_total();
1589
+        }
1590 1590
 
1591
-		$tax      = $this->totals['tax']['recurring'];
1592
-		$fee      = $this->totals['fee']['recurring'];
1593
-		$discount = $this->totals['discount']['recurring'];
1594
-		$subtotal = $this->totals['subtotal']['recurring'];
1595
-		$total    = $tax + $fee - $discount + $subtotal;
1591
+        $tax      = $this->totals['tax']['recurring'];
1592
+        $fee      = $this->totals['fee']['recurring'];
1593
+        $discount = $this->totals['discount']['recurring'];
1594
+        $subtotal = $this->totals['subtotal']['recurring'];
1595
+        $total    = $tax + $fee - $discount + $subtotal;
1596 1596
 
1597
-		if ( 0 > $total ) {
1598
-			$total = 0;
1599
-		}
1597
+        if ( 0 > $total ) {
1598
+            $total = 0;
1599
+        }
1600 1600
 
1601
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1601
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1602 1602
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1603
-	}
1603
+    }
1604 1604
 
1605
-	/**
1606
-	 * Returns recurring payment details.
1607
-	 *
1608
-	 * @since 1.0.19
1605
+    /**
1606
+     * Returns recurring payment details.
1607
+     *
1608
+     * @since 1.0.19
1609 1609
      * @param  string $field Optionally provide a field to return.
1610
-	 * @param string $currency Whether to include the currency.
1610
+     * @param string $currency Whether to include the currency.
1611 1611
      * @return float|string
1612
-	 */
1612
+     */
1613 1613
     public function get_recurring_details( $field = '', $currency = false ) {
1614 1614
 
1615
-		// Maybe recalculate totals.
1616
-		if ( empty( $this->totals ) ) {
1617
-			$this->recalculate_total();
1618
-		}
1615
+        // Maybe recalculate totals.
1616
+        if ( empty( $this->totals ) ) {
1617
+            $this->recalculate_total();
1618
+        }
1619 1619
 
1620
-		// Prepare recurring totals.
1620
+        // Prepare recurring totals.
1621 1621
         $data = apply_filters(
1622
-			'wpinv_get_invoice_recurring_details',
1623
-			array(
1624
-				'cart_details' => $this->get_cart_details(),
1625
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1626
-				'discount'     => $this->totals['discount']['recurring'],
1627
-				'tax'          => $this->totals['tax']['recurring'],
1628
-				'fee'          => $this->totals['fee']['recurring'],
1629
-				'total'        => $this->get_recurring_total(),
1630
-			),
1631
-			$this,
1632
-			$field,
1633
-			$currency
1634
-		);
1622
+            'wpinv_get_invoice_recurring_details',
1623
+            array(
1624
+                'cart_details' => $this->get_cart_details(),
1625
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1626
+                'discount'     => $this->totals['discount']['recurring'],
1627
+                'tax'          => $this->totals['tax']['recurring'],
1628
+                'fee'          => $this->totals['fee']['recurring'],
1629
+                'total'        => $this->get_recurring_total(),
1630
+            ),
1631
+            $this,
1632
+            $field,
1633
+            $currency
1634
+        );
1635 1635
 
1636 1636
         if ( isset( $data[ $field ] ) ) {
1637 1637
             return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
@@ -1641,166 +1641,166 @@  discard block
 block discarded – undo
1641 1641
     }
1642 1642
 
1643 1643
     /**
1644
-	 * Get the invoice fees.
1645
-	 *
1646
-	 * @since 1.0.19
1647
-	 * @param  string $context View or edit context.
1648
-	 * @return array
1649
-	 */
1650
-	public function get_fees( $context = 'view' ) {
1651
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1644
+     * Get the invoice fees.
1645
+     *
1646
+     * @since 1.0.19
1647
+     * @param  string $context View or edit context.
1648
+     * @return array
1649
+     */
1650
+    public function get_fees( $context = 'view' ) {
1651
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1652 1652
     }
1653 1653
 
1654 1654
     /**
1655
-	 * Get the invoice discounts.
1656
-	 *
1657
-	 * @since 1.0.19
1658
-	 * @param  string $context View or edit context.
1659
-	 * @return array
1660
-	 */
1661
-	public function get_discounts( $context = 'view' ) {
1662
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1655
+     * Get the invoice discounts.
1656
+     *
1657
+     * @since 1.0.19
1658
+     * @param  string $context View or edit context.
1659
+     * @return array
1660
+     */
1661
+    public function get_discounts( $context = 'view' ) {
1662
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1663 1663
     }
1664 1664
 
1665 1665
     /**
1666
-	 * Get the invoice taxes.
1667
-	 *
1668
-	 * @since 1.0.19
1669
-	 * @param  string $context View or edit context.
1670
-	 * @return array
1671
-	 */
1672
-	public function get_taxes( $context = 'view' ) {
1673
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1666
+     * Get the invoice taxes.
1667
+     *
1668
+     * @since 1.0.19
1669
+     * @param  string $context View or edit context.
1670
+     * @return array
1671
+     */
1672
+    public function get_taxes( $context = 'view' ) {
1673
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1674 1674
     }
1675 1675
 
1676 1676
     /**
1677
-	 * Get the invoice items.
1678
-	 *
1679
-	 * @since 1.0.19
1680
-	 * @param  string $context View or edit context.
1681
-	 * @return GetPaid_Form_Item[]
1682
-	 */
1683
-	public function get_items( $context = 'view' ) {
1677
+     * Get the invoice items.
1678
+     *
1679
+     * @since 1.0.19
1680
+     * @param  string $context View or edit context.
1681
+     * @return GetPaid_Form_Item[]
1682
+     */
1683
+    public function get_items( $context = 'view' ) {
1684 1684
         return $this->get_prop( 'items', $context );
1685
-	}
1685
+    }
1686 1686
 
1687
-	/**
1688
-	 * Get the invoice item ids.
1689
-	 *
1690
-	 * @since 1.0.19
1691
-	 * @return string
1692
-	 */
1693
-	public function get_item_ids() {
1694
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1687
+    /**
1688
+     * Get the invoice item ids.
1689
+     *
1690
+     * @since 1.0.19
1691
+     * @return string
1692
+     */
1693
+    public function get_item_ids() {
1694
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1695 1695
     }
1696 1696
 
1697 1697
     /**
1698
-	 * Get the invoice's payment form.
1699
-	 *
1700
-	 * @since 1.0.19
1701
-	 * @param  string $context View or edit context.
1702
-	 * @return int
1703
-	 */
1704
-	public function get_payment_form( $context = 'view' ) {
1705
-		return intval( $this->get_prop( 'payment_form', $context ) );
1698
+     * Get the invoice's payment form.
1699
+     *
1700
+     * @since 1.0.19
1701
+     * @param  string $context View or edit context.
1702
+     * @return int
1703
+     */
1704
+    public function get_payment_form( $context = 'view' ) {
1705
+        return intval( $this->get_prop( 'payment_form', $context ) );
1706 1706
     }
1707 1707
 
1708 1708
     /**
1709
-	 * Get the invoice's submission id.
1710
-	 *
1711
-	 * @since 1.0.19
1712
-	 * @param  string $context View or edit context.
1713
-	 * @return string
1714
-	 */
1715
-	public function get_submission_id( $context = 'view' ) {
1716
-		return $this->get_prop( 'submission_id', $context );
1709
+     * Get the invoice's submission id.
1710
+     *
1711
+     * @since 1.0.19
1712
+     * @param  string $context View or edit context.
1713
+     * @return string
1714
+     */
1715
+    public function get_submission_id( $context = 'view' ) {
1716
+        return $this->get_prop( 'submission_id', $context );
1717 1717
     }
1718 1718
 
1719 1719
     /**
1720
-	 * Get the invoice's discount code.
1721
-	 *
1722
-	 * @since 1.0.19
1723
-	 * @param  string $context View or edit context.
1724
-	 * @return string
1725
-	 */
1726
-	public function get_discount_code( $context = 'view' ) {
1727
-		return $this->get_prop( 'discount_code', $context );
1720
+     * Get the invoice's discount code.
1721
+     *
1722
+     * @since 1.0.19
1723
+     * @param  string $context View or edit context.
1724
+     * @return string
1725
+     */
1726
+    public function get_discount_code( $context = 'view' ) {
1727
+        return $this->get_prop( 'discount_code', $context );
1728 1728
     }
1729 1729
 
1730 1730
     /**
1731
-	 * Get the invoice's gateway.
1732
-	 *
1733
-	 * @since 1.0.19
1734
-	 * @param  string $context View or edit context.
1735
-	 * @return string
1736
-	 */
1737
-	public function get_gateway( $context = 'view' ) {
1738
-		return $this->get_prop( 'gateway', $context );
1731
+     * Get the invoice's gateway.
1732
+     *
1733
+     * @since 1.0.19
1734
+     * @param  string $context View or edit context.
1735
+     * @return string
1736
+     */
1737
+    public function get_gateway( $context = 'view' ) {
1738
+        return $this->get_prop( 'gateway', $context );
1739 1739
     }
1740 1740
 
1741 1741
     /**
1742
-	 * Get the invoice's gateway display title.
1743
-	 *
1744
-	 * @since 1.0.19
1745
-	 * @return string
1746
-	 */
1742
+     * Get the invoice's gateway display title.
1743
+     *
1744
+     * @since 1.0.19
1745
+     * @return string
1746
+     */
1747 1747
     public function get_gateway_title() {
1748 1748
         $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1749 1749
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1750 1750
     }
1751 1751
 
1752 1752
     /**
1753
-	 * Get the invoice's transaction id.
1754
-	 *
1755
-	 * @since 1.0.19
1756
-	 * @param  string $context View or edit context.
1757
-	 * @return string
1758
-	 */
1759
-	public function get_transaction_id( $context = 'view' ) {
1760
-		return $this->get_prop( 'transaction_id', $context );
1753
+     * Get the invoice's transaction id.
1754
+     *
1755
+     * @since 1.0.19
1756
+     * @param  string $context View or edit context.
1757
+     * @return string
1758
+     */
1759
+    public function get_transaction_id( $context = 'view' ) {
1760
+        return $this->get_prop( 'transaction_id', $context );
1761 1761
     }
1762 1762
 
1763 1763
     /**
1764
-	 * Get the invoice's currency.
1765
-	 *
1766
-	 * @since 1.0.19
1767
-	 * @param  string $context View or edit context.
1768
-	 * @return string
1769
-	 */
1770
-	public function get_currency( $context = 'view' ) {
1764
+     * Get the invoice's currency.
1765
+     *
1766
+     * @since 1.0.19
1767
+     * @param  string $context View or edit context.
1768
+     * @return string
1769
+     */
1770
+    public function get_currency( $context = 'view' ) {
1771 1771
         $currency = $this->get_prop( 'currency', $context );
1772 1772
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1773 1773
     }
1774 1774
 
1775 1775
     /**
1776
-	 * Checks if we are charging taxes for this invoice.
1777
-	 *
1778
-	 * @since 1.0.19
1779
-	 * @param  string $context View or edit context.
1780
-	 * @return bool
1781
-	 */
1782
-	public function get_disable_taxes( $context = 'view' ) {
1776
+     * Checks if we are charging taxes for this invoice.
1777
+     *
1778
+     * @since 1.0.19
1779
+     * @param  string $context View or edit context.
1780
+     * @return bool
1781
+     */
1782
+    public function get_disable_taxes( $context = 'view' ) {
1783 1783
         return (bool) $this->get_prop( 'disable_taxes', $context );
1784 1784
     }
1785 1785
 
1786 1786
     /**
1787
-	 * Retrieves the subscription id for an invoice.
1788
-	 *
1789
-	 * @since 1.0.19
1790
-	 * @param  string $context View or edit context.
1791
-	 * @return int
1792
-	 */
1787
+     * Retrieves the subscription id for an invoice.
1788
+     *
1789
+     * @since 1.0.19
1790
+     * @param  string $context View or edit context.
1791
+     * @return int
1792
+     */
1793 1793
     public function get_subscription_id( $context = 'view' ) {
1794
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1795
-	}
1796
-
1797
-	/**
1798
-	 * Retrieves the remote subscription id for an invoice.
1799
-	 *
1800
-	 * @since 1.0.19
1801
-	 * @param  string $context View or edit context.
1802
-	 * @return int
1803
-	 */
1794
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1795
+    }
1796
+
1797
+    /**
1798
+     * Retrieves the remote subscription id for an invoice.
1799
+     *
1800
+     * @since 1.0.19
1801
+     * @param  string $context View or edit context.
1802
+     * @return int
1803
+     */
1804 1804
     public function get_remote_subscription_id( $context = 'view' ) {
1805 1805
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1806 1806
 
@@ -1813,12 +1813,12 @@  discard block
 block discarded – undo
1813 1813
     }
1814 1814
 
1815 1815
     /**
1816
-	 * Retrieves the payment meta for an invoice.
1817
-	 *
1818
-	 * @since 1.0.19
1819
-	 * @param  string $context View or edit context.
1820
-	 * @return array
1821
-	 */
1816
+     * Retrieves the payment meta for an invoice.
1817
+     *
1818
+     * @since 1.0.19
1819
+     * @param  string $context View or edit context.
1820
+     * @return array
1821
+     */
1822 1822
     public function get_payment_meta( $context = 'view' ) {
1823 1823
 
1824 1824
         return array(
@@ -1838,31 +1838,31 @@  discard block
 block discarded – undo
1838 1838
     }
1839 1839
 
1840 1840
     /**
1841
-	 * Retrieves the cart details for an invoice.
1842
-	 *
1843
-	 * @since 1.0.19
1844
-	 * @return array
1845
-	 */
1841
+     * Retrieves the cart details for an invoice.
1842
+     *
1843
+     * @since 1.0.19
1844
+     * @return array
1845
+     */
1846 1846
     public function get_cart_details() {
1847 1847
         $items        = $this->get_items();
1848 1848
         $cart_details = array();
1849 1849
 
1850 1850
         foreach ( $items as $item ) {
1851
-			$item->invoice_id = $this->get_id();
1851
+            $item->invoice_id = $this->get_id();
1852 1852
             $cart_details[]   = $item->prepare_data_for_saving();
1853 1853
         }
1854 1854
 
1855 1855
         return $cart_details;
1856
-	}
1856
+    }
1857 1857
 
1858
-	/**
1859
-	 * Retrieves the recurring item.
1860
-	 *
1861
-	 * @return null|GetPaid_Form_Item|int
1862
-	 */
1863
-	public function get_recurring( $object = false ) {
1858
+    /**
1859
+     * Retrieves the recurring item.
1860
+     *
1861
+     * @return null|GetPaid_Form_Item|int
1862
+     */
1863
+    public function get_recurring( $object = false ) {
1864 1864
 
1865
-		// Are we returning an object?
1865
+        // Are we returning an object?
1866 1866
         if ( $object ) {
1867 1867
             return $this->get_item( $this->recurring_item );
1868 1868
         }
@@ -1870,130 +1870,130 @@  discard block
 block discarded – undo
1870 1870
         return $this->recurring_item;
1871 1871
     }
1872 1872
 
1873
-	/**
1874
-	 * Retrieves the subscription name.
1875
-	 *
1876
-	 * @since 1.0.19
1877
-	 * @return string
1878
-	 */
1879
-	public function get_subscription_name() {
1873
+    /**
1874
+     * Retrieves the subscription name.
1875
+     *
1876
+     * @since 1.0.19
1877
+     * @return string
1878
+     */
1879
+    public function get_subscription_name() {
1880 1880
 
1881
-		// Retrieve the recurring name
1881
+        // Retrieve the recurring name
1882 1882
         $item = $this->get_recurring( true );
1883 1883
 
1884
-		// Abort if it does not exist.
1884
+        // Abort if it does not exist.
1885 1885
         if ( empty( $item ) ) {
1886 1886
             return '';
1887 1887
         }
1888 1888
 
1889
-		// Return the item name.
1889
+        // Return the item name.
1890 1890
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1891
-	}
1892
-
1893
-	/**
1894
-	 * Retrieves the view url.
1895
-	 *
1896
-	 * @since 1.0.19
1897
-	 * @return string
1898
-	 */
1899
-	public function get_view_url() {
1891
+    }
1892
+
1893
+    /**
1894
+     * Retrieves the view url.
1895
+     *
1896
+     * @since 1.0.19
1897
+     * @return string
1898
+     */
1899
+    public function get_view_url() {
1900 1900
         $invoice_url = get_permalink( $this->get_id() );
1901
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1901
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1902 1902
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1903
-	}
1903
+    }
1904 1904
 
1905
-	/**
1906
-	 * Retrieves the payment url.
1907
-	 *
1908
-	 * @since 1.0.19
1909
-	 * @return string
1910
-	 */
1911
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1905
+    /**
1906
+     * Retrieves the payment url.
1907
+     *
1908
+     * @since 1.0.19
1909
+     * @return string
1910
+     */
1911
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1912 1912
 
1913
-		// Retrieve the checkout url.
1913
+        // Retrieve the checkout url.
1914 1914
         $pay_url = wpinv_get_checkout_uri();
1915 1915
 
1916
-		// Maybe force ssl.
1916
+        // Maybe force ssl.
1917 1917
         if ( is_ssl() ) {
1918 1918
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1919 1919
         }
1920 1920
 
1921
-		// Add the invoice key.
1922
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1921
+        // Add the invoice key.
1922
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1923 1923
 
1924
-		// (Maybe?) add a secret
1924
+        // (Maybe?) add a secret
1925 1925
         if ( $secret ) {
1926 1926
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1927 1927
         }
1928 1928
 
1929 1929
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1930
-	}
1930
+    }
1931 1931
 
1932
-	/**
1933
-	 * Retrieves the receipt url.
1934
-	 *
1935
-	 * @since 1.0.19
1936
-	 * @return string
1937
-	 */
1938
-	public function get_receipt_url() {
1932
+    /**
1933
+     * Retrieves the receipt url.
1934
+     *
1935
+     * @since 1.0.19
1936
+     * @return string
1937
+     */
1938
+    public function get_receipt_url() {
1939 1939
 
1940
-		// Retrieve the checkout url.
1940
+        // Retrieve the checkout url.
1941 1941
         $receipt_url = wpinv_get_success_page_uri();
1942 1942
 
1943
-		// Maybe force ssl.
1943
+        // Maybe force ssl.
1944 1944
         if ( is_ssl() ) {
1945 1945
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1946 1946
         }
1947 1947
 
1948
-		// Add the invoice key.
1949
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1948
+        // Add the invoice key.
1949
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1950 1950
 
1951 1951
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1952
-	}
1953
-
1954
-	/**
1955
-	 * Retrieves the remote transaction url.
1956
-	 *
1957
-	 * @since 1.6.0
1958
-	 * @return string
1959
-	 */
1960
-	public function get_transaction_url() {
1961
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1962
-	}
1963
-
1964
-	/**
1965
-	 * Retrieves the default status.
1966
-	 *
1967
-	 * @since 1.0.19
1968
-	 * @return string
1969
-	 */
1970
-	public function get_default_status() {
1971
-
1972
-		$type   = $this->get_type();
1973
-		$status = "wpi-$type-pending";
1974
-		return str_replace( '-invoice', '', $status );
1975
-
1976
-	}
1977
-
1978
-    /**
1979
-	 * Magic method for accessing invoice properties.
1980
-	 *
1981
-	 * @since 1.0.15
1982
-	 * @access public
1983
-	 *
1984
-	 * @param string $key Discount data to retrieve
1985
-	 * @param  string $context View or edit context.
1986
-	 * @return mixed Value of the given invoice property (if set).
1987
-	 */
1988
-	public function get( $key, $context = 'view' ) {
1989
-		$method = "get_$key";
1990
-
1991
-		if ( is_callable( array( $this, $method ) ) ) {
1992
-			return $this->$method( $context );
1993
-		}
1952
+    }
1953
+
1954
+    /**
1955
+     * Retrieves the remote transaction url.
1956
+     *
1957
+     * @since 1.6.0
1958
+     * @return string
1959
+     */
1960
+    public function get_transaction_url() {
1961
+        return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1962
+    }
1963
+
1964
+    /**
1965
+     * Retrieves the default status.
1966
+     *
1967
+     * @since 1.0.19
1968
+     * @return string
1969
+     */
1970
+    public function get_default_status() {
1971
+
1972
+        $type   = $this->get_type();
1973
+        $status = "wpi-$type-pending";
1974
+        return str_replace( '-invoice', '', $status );
1975
+
1976
+    }
1977
+
1978
+    /**
1979
+     * Magic method for accessing invoice properties.
1980
+     *
1981
+     * @since 1.0.15
1982
+     * @access public
1983
+     *
1984
+     * @param string $key Discount data to retrieve
1985
+     * @param  string $context View or edit context.
1986
+     * @return mixed Value of the given invoice property (if set).
1987
+     */
1988
+    public function get( $key, $context = 'view' ) {
1989
+        $method = "get_$key";
1990
+
1991
+        if ( is_callable( array( $this, $method ) ) ) {
1992
+            return $this->$method( $context );
1993
+        }
1994 1994
 
1995 1995
         return $this->get_prop( $key, $context );
1996
-	}
1996
+    }
1997 1997
 
1998 1998
     /*
1999 1999
 	|--------------------------------------------------------------------------
@@ -2006,129 +2006,129 @@  discard block
 block discarded – undo
2006 2006
     */
2007 2007
 
2008 2008
     /**
2009
-	 * Magic method for setting invoice properties.
2010
-	 *
2011
-	 * @since 1.0.19
2012
-	 * @access public
2013
-	 *
2014
-	 * @param string $key Discount data to retrieve
2015
-	 * @param  mixed $value new value.
2016
-	 * @return mixed Value of the given invoice property (if set).
2017
-	 */
2018
-	public function set( $key, $value ) {
2009
+     * Magic method for setting invoice properties.
2010
+     *
2011
+     * @since 1.0.19
2012
+     * @access public
2013
+     *
2014
+     * @param string $key Discount data to retrieve
2015
+     * @param  mixed $value new value.
2016
+     * @return mixed Value of the given invoice property (if set).
2017
+     */
2018
+    public function set( $key, $value ) {
2019 2019
 
2020 2020
         $setter = "set_$key";
2021 2021
         if ( is_callable( array( $this, $setter ) ) ) {
2022 2022
             $this->{$setter}( $value );
2023 2023
         }
2024 2024
 
2025
-	}
2026
-
2027
-	/**
2028
-	 * Sets item status.
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 * @param string $new_status    New status.
2032
-	 * @param string $note          Optional note to add.
2033
-	 * @param bool   $manual_update Is this a manual status change?.
2034
-	 * @return array details of change.
2035
-	 */
2036
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2037
-		$old_status = $this->get_status();
2038
-
2039
-		$statuses = $this->get_all_statuses();
2040
-
2041
-		if ( isset( $statuses['draft'] ) ) {
2042
-			unset( $statuses['draft'] );
2043
-		}
2044
-
2045
-		$this->set_prop( 'status', $new_status );
2046
-
2047
-		// If setting the status, ensure it's set to a valid status.
2048
-		if ( true === $this->object_read ) {
2049
-
2050
-			// Only allow valid new status.
2051
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2052
-				$new_status = $this->get_default_status();
2053
-			}
2054
-
2055
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2056
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2057
-				$old_status = $this->get_default_status();
2058
-			}
2059
-
2060
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2061
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2062
-				$old_status = 'wpi-pending';
2063
-			}
2064
-
2065
-			if ( $old_status !== $new_status ) {
2066
-				$this->status_transition = array(
2067
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2068
-					'to'     => $new_status,
2069
-					'note'   => $note,
2070
-					'manual' => (bool) $manual_update,
2071
-				);
2072
-
2073
-				if ( $manual_update ) {
2074
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2075
-				}
2076
-
2077
-				$this->maybe_set_date_paid();
2078
-
2079
-			}
2080
-		}
2081
-
2082
-		return array(
2083
-			'from' => $old_status,
2084
-			'to'   => $new_status,
2085
-		);
2086
-	}
2087
-
2088
-	/**
2089
-	 * Maybe set date paid.
2090
-	 *
2091
-	 * Sets the date paid variable when transitioning to the payment complete
2092
-	 * order status.
2093
-	 *
2094
-	 * @since 1.0.19
2095
-	 */
2096
-	public function maybe_set_date_paid() {
2097
-
2098
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2099
-			$this->set_date_completed( current_time( 'mysql' ) );
2100
-		}
2101
-	}
2102
-
2103
-    /**
2104
-	 * Set parent invoice ID.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 */
2108
-	public function set_parent_id( $value ) {
2109
-		if ( $value && ( $value === $this->get_id() ) ) {
2110
-			return;
2111
-		}
2112
-		$this->set_prop( 'parent_id', absint( $value ) );
2113
-    }
2114
-
2115
-    /**
2116
-	 * Set plugin version when the invoice was created.
2117
-	 *
2118
-	 * @since 1.0.19
2119
-	 */
2120
-	public function set_version( $value ) {
2121
-		$this->set_prop( 'version', $value );
2122
-    }
2123
-
2124
-    /**
2125
-	 * Set date when the invoice was created.
2126
-	 *
2127
-	 * @since 1.0.19
2128
-	 * @param string $value Value to set.
2025
+    }
2026
+
2027
+    /**
2028
+     * Sets item status.
2029
+     *
2030
+     * @since 1.0.19
2031
+     * @param string $new_status    New status.
2032
+     * @param string $note          Optional note to add.
2033
+     * @param bool   $manual_update Is this a manual status change?.
2034
+     * @return array details of change.
2035
+     */
2036
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2037
+        $old_status = $this->get_status();
2038
+
2039
+        $statuses = $this->get_all_statuses();
2040
+
2041
+        if ( isset( $statuses['draft'] ) ) {
2042
+            unset( $statuses['draft'] );
2043
+        }
2044
+
2045
+        $this->set_prop( 'status', $new_status );
2046
+
2047
+        // If setting the status, ensure it's set to a valid status.
2048
+        if ( true === $this->object_read ) {
2049
+
2050
+            // Only allow valid new status.
2051
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2052
+                $new_status = $this->get_default_status();
2053
+            }
2054
+
2055
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2056
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2057
+                $old_status = $this->get_default_status();
2058
+            }
2059
+
2060
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2061
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2062
+                $old_status = 'wpi-pending';
2063
+            }
2064
+
2065
+            if ( $old_status !== $new_status ) {
2066
+                $this->status_transition = array(
2067
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2068
+                    'to'     => $new_status,
2069
+                    'note'   => $note,
2070
+                    'manual' => (bool) $manual_update,
2071
+                );
2072
+
2073
+                if ( $manual_update ) {
2074
+                    do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2075
+                }
2076
+
2077
+                $this->maybe_set_date_paid();
2078
+
2079
+            }
2080
+        }
2081
+
2082
+        return array(
2083
+            'from' => $old_status,
2084
+            'to'   => $new_status,
2085
+        );
2086
+    }
2087
+
2088
+    /**
2089
+     * Maybe set date paid.
2090
+     *
2091
+     * Sets the date paid variable when transitioning to the payment complete
2092
+     * order status.
2093
+     *
2094
+     * @since 1.0.19
2095
+     */
2096
+    public function maybe_set_date_paid() {
2097
+
2098
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2099
+            $this->set_date_completed( current_time( 'mysql' ) );
2100
+        }
2101
+    }
2102
+
2103
+    /**
2104
+     * Set parent invoice ID.
2105
+     *
2106
+     * @since 1.0.19
2107
+     */
2108
+    public function set_parent_id( $value ) {
2109
+        if ( $value && ( $value === $this->get_id() ) ) {
2110
+            return;
2111
+        }
2112
+        $this->set_prop( 'parent_id', absint( $value ) );
2113
+    }
2114
+
2115
+    /**
2116
+     * Set plugin version when the invoice was created.
2117
+     *
2118
+     * @since 1.0.19
2119
+     */
2120
+    public function set_version( $value ) {
2121
+        $this->set_prop( 'version', $value );
2122
+    }
2123
+
2124
+    /**
2125
+     * Set date when the invoice was created.
2126
+     *
2127
+     * @since 1.0.19
2128
+     * @param string $value Value to set.
2129 2129
      * @return bool Whether or not the date was set.
2130
-	 */
2131
-	public function set_date_created( $value ) {
2130
+     */
2131
+    public function set_date_created( $value ) {
2132 2132
         $date = strtotime( $value );
2133 2133
 
2134 2134
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2136,19 +2136,19 @@  discard block
 block discarded – undo
2136 2136
             return true;
2137 2137
         }
2138 2138
 
2139
-		$this->set_prop( 'date_created', '' );
2140
-		return false;
2139
+        $this->set_prop( 'date_created', '' );
2140
+        return false;
2141 2141
 
2142 2142
     }
2143 2143
 
2144 2144
     /**
2145
-	 * Set date invoice due date.
2146
-	 *
2147
-	 * @since 1.0.19
2148
-	 * @param string $value Value to set.
2145
+     * Set date invoice due date.
2146
+     *
2147
+     * @since 1.0.19
2148
+     * @param string $value Value to set.
2149 2149
      * @return bool Whether or not the date was set.
2150
-	 */
2151
-	public function set_due_date( $value ) {
2150
+     */
2151
+    public function set_due_date( $value ) {
2152 2152
         $date = strtotime( $value );
2153 2153
 
2154 2154
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2156,29 +2156,29 @@  discard block
 block discarded – undo
2156 2156
             return true;
2157 2157
         }
2158 2158
 
2159
-		$this->set_prop( 'due_date', '' );
2159
+        $this->set_prop( 'due_date', '' );
2160 2160
         return false;
2161 2161
 
2162 2162
     }
2163 2163
 
2164 2164
     /**
2165
-	 * Alias of self::set_due_date().
2166
-	 *
2167
-	 * @since 1.0.19
2168
-	 * @param  string $value New name.
2169
-	 */
2170
-	public function set_date_due( $value ) {
2171
-		$this->set_due_date( $value );
2165
+     * Alias of self::set_due_date().
2166
+     *
2167
+     * @since 1.0.19
2168
+     * @param  string $value New name.
2169
+     */
2170
+    public function set_date_due( $value ) {
2171
+        $this->set_due_date( $value );
2172 2172
     }
2173 2173
 
2174 2174
     /**
2175
-	 * Set date invoice was completed.
2176
-	 *
2177
-	 * @since 1.0.19
2178
-	 * @param string $value Value to set.
2175
+     * Set date invoice was completed.
2176
+     *
2177
+     * @since 1.0.19
2178
+     * @param string $value Value to set.
2179 2179
      * @return bool Whether or not the date was set.
2180
-	 */
2181
-	public function set_completed_date( $value ) {
2180
+     */
2181
+    public function set_completed_date( $value ) {
2182 2182
         $date = strtotime( $value );
2183 2183
 
2184 2184
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2186,29 +2186,29 @@  discard block
 block discarded – undo
2186 2186
             return true;
2187 2187
         }
2188 2188
 
2189
-		$this->set_prop( 'completed_date', '' );
2189
+        $this->set_prop( 'completed_date', '' );
2190 2190
         return false;
2191 2191
 
2192 2192
     }
2193 2193
 
2194 2194
     /**
2195
-	 * Alias of self::set_completed_date().
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  string $value New name.
2199
-	 */
2200
-	public function set_date_completed( $value ) {
2201
-		$this->set_completed_date( $value );
2195
+     * Alias of self::set_completed_date().
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  string $value New name.
2199
+     */
2200
+    public function set_date_completed( $value ) {
2201
+        $this->set_completed_date( $value );
2202 2202
     }
2203 2203
 
2204 2204
     /**
2205
-	 * Set date when the invoice was last modified.
2206
-	 *
2207
-	 * @since 1.0.19
2208
-	 * @param string $value Value to set.
2205
+     * Set date when the invoice was last modified.
2206
+     *
2207
+     * @since 1.0.19
2208
+     * @param string $value Value to set.
2209 2209
      * @return bool Whether or not the date was set.
2210
-	 */
2211
-	public function set_date_modified( $value ) {
2210
+     */
2211
+    public function set_date_modified( $value ) {
2212 2212
         $date = strtotime( $value );
2213 2213
 
2214 2214
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2216,813 +2216,813 @@  discard block
 block discarded – undo
2216 2216
             return true;
2217 2217
         }
2218 2218
 
2219
-		$this->set_prop( 'date_modified', '' );
2219
+        $this->set_prop( 'date_modified', '' );
2220 2220
         return false;
2221 2221
 
2222 2222
     }
2223 2223
 
2224 2224
     /**
2225
-	 * Set the invoice number.
2226
-	 *
2227
-	 * @since 1.0.19
2228
-	 * @param  string $value New number.
2229
-	 */
2230
-	public function set_number( $value ) {
2225
+     * Set the invoice number.
2226
+     *
2227
+     * @since 1.0.19
2228
+     * @param  string $value New number.
2229
+     */
2230
+    public function set_number( $value ) {
2231 2231
         $number = sanitize_text_field( $value );
2232
-		$this->set_prop( 'number', $number );
2232
+        $this->set_prop( 'number', $number );
2233 2233
     }
2234 2234
 
2235 2235
     /**
2236
-	 * Set the invoice type.
2237
-	 *
2238
-	 * @since 1.0.19
2239
-	 * @param  string $value Type.
2240
-	 */
2241
-	public function set_type( $value ) {
2236
+     * Set the invoice type.
2237
+     *
2238
+     * @since 1.0.19
2239
+     * @param  string $value Type.
2240
+     */
2241
+    public function set_type( $value ) {
2242 2242
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2243
-		$this->set_prop( 'type', $type );
2244
-	}
2243
+        $this->set_prop( 'type', $type );
2244
+    }
2245 2245
 
2246 2246
     /**
2247
-	 * Set the invoice post type.
2248
-	 *
2249
-	 * @since 1.0.19
2250
-	 * @param  string $value Post type.
2251
-	 */
2252
-	public function set_post_type( $value ) {
2247
+     * Set the invoice post type.
2248
+     *
2249
+     * @since 1.0.19
2250
+     * @param  string $value Post type.
2251
+     */
2252
+    public function set_post_type( $value ) {
2253 2253
         if ( getpaid_is_invoice_post_type( $value ) ) {
2254
-			$this->set_type( $value );
2254
+            $this->set_type( $value );
2255 2255
             $this->set_prop( 'post_type', $value );
2256 2256
         }
2257 2257
     }
2258 2258
 
2259 2259
     /**
2260
-	 * Set the invoice key.
2261
-	 *
2262
-	 * @since 1.0.19
2263
-	 * @param  string $value New key.
2264
-	 */
2265
-	public function set_key( $value ) {
2260
+     * Set the invoice key.
2261
+     *
2262
+     * @since 1.0.19
2263
+     * @param  string $value New key.
2264
+     */
2265
+    public function set_key( $value ) {
2266 2266
         $key = sanitize_text_field( $value );
2267
-		$this->set_prop( 'key', $key );
2267
+        $this->set_prop( 'key', $key );
2268 2268
     }
2269 2269
 
2270 2270
     /**
2271
-	 * Set the invoice mode.
2272
-	 *
2273
-	 * @since 1.0.19
2274
-	 * @param  string $value mode.
2275
-	 */
2276
-	public function set_mode( $value ) {
2271
+     * Set the invoice mode.
2272
+     *
2273
+     * @since 1.0.19
2274
+     * @param  string $value mode.
2275
+     */
2276
+    public function set_mode( $value ) {
2277 2277
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2278 2278
             $this->set_prop( 'mode', $value );
2279 2279
         }
2280 2280
     }
2281 2281
 
2282 2282
     /**
2283
-	 * Set the invoice path.
2284
-	 *
2285
-	 * @since 1.0.19
2286
-	 * @param  string $value path.
2287
-	 */
2288
-	public function set_path( $value ) {
2283
+     * Set the invoice path.
2284
+     *
2285
+     * @since 1.0.19
2286
+     * @param  string $value path.
2287
+     */
2288
+    public function set_path( $value ) {
2289 2289
         $this->set_prop( 'path', $value );
2290 2290
     }
2291 2291
 
2292 2292
     /**
2293
-	 * Set the invoice name.
2294
-	 *
2295
-	 * @since 1.0.19
2296
-	 * @param  string $value New name.
2297
-	 */
2298
-	public function set_name( $value ) {
2293
+     * Set the invoice name.
2294
+     *
2295
+     * @since 1.0.19
2296
+     * @param  string $value New name.
2297
+     */
2298
+    public function set_name( $value ) {
2299 2299
         $name = sanitize_text_field( $value );
2300
-		$this->set_prop( 'name', $name );
2300
+        $this->set_prop( 'name', $name );
2301 2301
     }
2302 2302
 
2303 2303
     /**
2304
-	 * Alias of self::set_name().
2305
-	 *
2306
-	 * @since 1.0.19
2307
-	 * @param  string $value New name.
2308
-	 */
2309
-	public function set_title( $value ) {
2310
-		$this->set_name( $value );
2304
+     * Alias of self::set_name().
2305
+     *
2306
+     * @since 1.0.19
2307
+     * @param  string $value New name.
2308
+     */
2309
+    public function set_title( $value ) {
2310
+        $this->set_name( $value );
2311 2311
     }
2312 2312
 
2313 2313
     /**
2314
-	 * Set the invoice description.
2315
-	 *
2316
-	 * @since 1.0.19
2317
-	 * @param  string $value New description.
2318
-	 */
2319
-	public function set_description( $value ) {
2314
+     * Set the invoice description.
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value New description.
2318
+     */
2319
+    public function set_description( $value ) {
2320 2320
         $description = wp_kses_post( $value );
2321
-		$this->set_prop( 'description', $description );
2321
+        $this->set_prop( 'description', $description );
2322
+    }
2323
+
2324
+    /**
2325
+     * Alias of self::set_description().
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  string $value New description.
2329
+     */
2330
+    public function set_excerpt( $value ) {
2331
+        $this->set_description( $value );
2332
+    }
2333
+
2334
+    /**
2335
+     * Alias of self::set_description().
2336
+     *
2337
+     * @since 1.0.19
2338
+     * @param  string $value New description.
2339
+     */
2340
+    public function set_summary( $value ) {
2341
+        $this->set_description( $value );
2342
+    }
2343
+
2344
+    /**
2345
+     * Set the receiver of the invoice.
2346
+     *
2347
+     * @since 1.0.19
2348
+     * @param  int $value New author.
2349
+     */
2350
+    public function set_author( $value ) {
2351
+        $user = get_user_by( 'id', (int) $value );
2352
+
2353
+        if ( $user && $user->ID ) {
2354
+            $this->set_prop( 'author', $user->ID );
2355
+            $this->set_prop( 'email', $user->user_email );
2356
+        }
2357
+
2358
+    }
2359
+
2360
+    /**
2361
+     * Alias of self::set_author().
2362
+     *
2363
+     * @since 1.0.19
2364
+     * @param  int $value New user id.
2365
+     */
2366
+    public function set_user_id( $value ) {
2367
+        $this->set_author( $value );
2368
+    }
2369
+
2370
+    /**
2371
+     * Sets the customer ID.
2372
+     *
2373
+     * @since 1.0.19
2374
+     * @param  int $value New user id.
2375
+     */
2376
+    public function set_customer_id( $value ) {
2377
+        $this->set_prop( 'customer_id', (int) $value );
2378
+    }
2379
+
2380
+    /**
2381
+     * Set the customer's ip.
2382
+     *
2383
+     * @since 1.0.19
2384
+     * @param  string $value ip address.
2385
+     */
2386
+    public function set_ip( $value ) {
2387
+        $this->set_prop( 'ip', $value );
2388
+    }
2389
+
2390
+    /**
2391
+     * Alias of self::set_ip().
2392
+     *
2393
+     * @since 1.0.19
2394
+     * @param  string $value ip address.
2395
+     */
2396
+    public function set_user_ip( $value ) {
2397
+        $this->set_ip( $value );
2398
+    }
2399
+
2400
+    /**
2401
+     * Set the customer's first name.
2402
+     *
2403
+     * @since 1.0.19
2404
+     * @param  string $value first name.
2405
+     */
2406
+    public function set_first_name( $value ) {
2407
+        $this->set_prop( 'first_name', $value );
2408
+    }
2409
+
2410
+    /**
2411
+     * Alias of self::set_first_name().
2412
+     *
2413
+     * @since 1.0.19
2414
+     * @param  string $value first name.
2415
+     */
2416
+    public function set_user_first_name( $value ) {
2417
+        $this->set_first_name( $value );
2418
+    }
2419
+
2420
+    /**
2421
+     * Alias of self::set_first_name().
2422
+     *
2423
+     * @since 1.0.19
2424
+     * @param  string $value first name.
2425
+     */
2426
+    public function set_customer_first_name( $value ) {
2427
+        $this->set_first_name( $value );
2428
+    }
2429
+
2430
+    /**
2431
+     * Set the customer's last name.
2432
+     *
2433
+     * @since 1.0.19
2434
+     * @param  string $value last name.
2435
+     */
2436
+    public function set_last_name( $value ) {
2437
+        $this->set_prop( 'last_name', $value );
2438
+    }
2439
+
2440
+    /**
2441
+     * Alias of self::set_last_name().
2442
+     *
2443
+     * @since 1.0.19
2444
+     * @param  string $value last name.
2445
+     */
2446
+    public function set_user_last_name( $value ) {
2447
+        $this->set_last_name( $value );
2322 2448
     }
2323 2449
 
2324 2450
     /**
2325
-	 * Alias of self::set_description().
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  string $value New description.
2329
-	 */
2330
-	public function set_excerpt( $value ) {
2331
-		$this->set_description( $value );
2451
+     * Alias of self::set_last_name().
2452
+     *
2453
+     * @since 1.0.19
2454
+     * @param  string $value last name.
2455
+     */
2456
+    public function set_customer_last_name( $value ) {
2457
+        $this->set_last_name( $value );
2458
+    }
2459
+
2460
+    /**
2461
+     * Set the customer's phone number.
2462
+     *
2463
+     * @since 1.0.19
2464
+     * @param  string $value phone.
2465
+     */
2466
+    public function set_phone( $value ) {
2467
+        $this->set_prop( 'phone', $value );
2468
+    }
2469
+
2470
+    /**
2471
+     * Alias of self::set_phone().
2472
+     *
2473
+     * @since 1.0.19
2474
+     * @param  string $value phone.
2475
+     */
2476
+    public function set_user_phone( $value ) {
2477
+        $this->set_phone( $value );
2332 2478
     }
2333 2479
 
2334 2480
     /**
2335
-	 * Alias of self::set_description().
2336
-	 *
2337
-	 * @since 1.0.19
2338
-	 * @param  string $value New description.
2339
-	 */
2340
-	public function set_summary( $value ) {
2341
-		$this->set_description( $value );
2481
+     * Alias of self::set_phone().
2482
+     *
2483
+     * @since 1.0.19
2484
+     * @param  string $value phone.
2485
+     */
2486
+    public function set_customer_phone( $value ) {
2487
+        $this->set_phone( $value );
2342 2488
     }
2343 2489
 
2344 2490
     /**
2345
-	 * Set the receiver of the invoice.
2346
-	 *
2347
-	 * @since 1.0.19
2348
-	 * @param  int $value New author.
2349
-	 */
2350
-	public function set_author( $value ) {
2351
-		$user = get_user_by( 'id', (int) $value );
2491
+     * Alias of self::set_phone().
2492
+     *
2493
+     * @since 1.0.19
2494
+     * @param  string $value phone.
2495
+     */
2496
+    public function set_phone_number( $value ) {
2497
+        $this->set_phone( $value );
2498
+    }
2352 2499
 
2353
-		if ( $user && $user->ID ) {
2354
-			$this->set_prop( 'author', $user->ID );
2355
-			$this->set_prop( 'email', $user->user_email );
2356
-		}
2500
+    /**
2501
+     * Set the customer's email address.
2502
+     *
2503
+     * @since 1.0.19
2504
+     * @param  string $value email address.
2505
+     */
2506
+    public function set_email( $value ) {
2507
+        $this->set_prop( 'email', $value );
2508
+    }
2357 2509
 
2510
+    /**
2511
+     * Alias of self::set_email().
2512
+     *
2513
+     * @since 1.0.19
2514
+     * @param  string $value email address.
2515
+     */
2516
+    public function set_user_email( $value ) {
2517
+        $this->set_email( $value );
2358 2518
     }
2359 2519
 
2360 2520
     /**
2361
-	 * Alias of self::set_author().
2362
-	 *
2363
-	 * @since 1.0.19
2364
-	 * @param  int $value New user id.
2365
-	 */
2366
-	public function set_user_id( $value ) {
2367
-		$this->set_author( $value );
2521
+     * Alias of self::set_email().
2522
+     *
2523
+     * @since 1.0.19
2524
+     * @param  string $value email address.
2525
+     */
2526
+    public function set_email_address( $value ) {
2527
+        $this->set_email( $value );
2368 2528
     }
2369 2529
 
2370 2530
     /**
2371
-	 * Sets the customer ID.
2372
-	 *
2373
-	 * @since 1.0.19
2374
-	 * @param  int $value New user id.
2375
-	 */
2376
-	public function set_customer_id( $value ) {
2377
-		$this->set_prop( 'customer_id', (int) $value );
2531
+     * Alias of self::set_email().
2532
+     *
2533
+     * @since 1.0.19
2534
+     * @param  string $value email address.
2535
+     */
2536
+    public function set_customer_email( $value ) {
2537
+        $this->set_email( $value );
2378 2538
     }
2379 2539
 
2380 2540
     /**
2381
-	 * Set the customer's ip.
2382
-	 *
2383
-	 * @since 1.0.19
2384
-	 * @param  string $value ip address.
2385
-	 */
2386
-	public function set_ip( $value ) {
2387
-		$this->set_prop( 'ip', $value );
2541
+     * Set the customer's country.
2542
+     *
2543
+     * @since 1.0.19
2544
+     * @param  string $value country.
2545
+     */
2546
+    public function set_country( $value ) {
2547
+        $this->set_prop( 'country', $value );
2388 2548
     }
2389 2549
 
2390 2550
     /**
2391
-	 * Alias of self::set_ip().
2392
-	 *
2393
-	 * @since 1.0.19
2394
-	 * @param  string $value ip address.
2395
-	 */
2396
-	public function set_user_ip( $value ) {
2397
-		$this->set_ip( $value );
2551
+     * Alias of self::set_country().
2552
+     *
2553
+     * @since 1.0.19
2554
+     * @param  string $value country.
2555
+     */
2556
+    public function set_user_country( $value ) {
2557
+        $this->set_country( $value );
2398 2558
     }
2399 2559
 
2400 2560
     /**
2401
-	 * Set the customer's first name.
2402
-	 *
2403
-	 * @since 1.0.19
2404
-	 * @param  string $value first name.
2405
-	 */
2406
-	public function set_first_name( $value ) {
2407
-		$this->set_prop( 'first_name', $value );
2561
+     * Alias of self::set_country().
2562
+     *
2563
+     * @since 1.0.19
2564
+     * @param  string $value country.
2565
+     */
2566
+    public function set_customer_country( $value ) {
2567
+        $this->set_country( $value );
2408 2568
     }
2409 2569
 
2410 2570
     /**
2411
-	 * Alias of self::set_first_name().
2412
-	 *
2413
-	 * @since 1.0.19
2414
-	 * @param  string $value first name.
2415
-	 */
2416
-	public function set_user_first_name( $value ) {
2417
-		$this->set_first_name( $value );
2571
+     * Set the customer's state.
2572
+     *
2573
+     * @since 1.0.19
2574
+     * @param  string $value state.
2575
+     */
2576
+    public function set_state( $value ) {
2577
+        $this->set_prop( 'state', $value );
2418 2578
     }
2419 2579
 
2420 2580
     /**
2421
-	 * Alias of self::set_first_name().
2422
-	 *
2423
-	 * @since 1.0.19
2424
-	 * @param  string $value first name.
2425
-	 */
2426
-	public function set_customer_first_name( $value ) {
2427
-		$this->set_first_name( $value );
2581
+     * Alias of self::set_state().
2582
+     *
2583
+     * @since 1.0.19
2584
+     * @param  string $value state.
2585
+     */
2586
+    public function set_user_state( $value ) {
2587
+        $this->set_state( $value );
2428 2588
     }
2429 2589
 
2430 2590
     /**
2431
-	 * Set the customer's last name.
2432
-	 *
2433
-	 * @since 1.0.19
2434
-	 * @param  string $value last name.
2435
-	 */
2436
-	public function set_last_name( $value ) {
2437
-		$this->set_prop( 'last_name', $value );
2591
+     * Alias of self::set_state().
2592
+     *
2593
+     * @since 1.0.19
2594
+     * @param  string $value state.
2595
+     */
2596
+    public function set_customer_state( $value ) {
2597
+        $this->set_state( $value );
2438 2598
     }
2439 2599
 
2440 2600
     /**
2441
-	 * Alias of self::set_last_name().
2442
-	 *
2443
-	 * @since 1.0.19
2444
-	 * @param  string $value last name.
2445
-	 */
2446
-	public function set_user_last_name( $value ) {
2447
-		$this->set_last_name( $value );
2601
+     * Set the customer's city.
2602
+     *
2603
+     * @since 1.0.19
2604
+     * @param  string $value city.
2605
+     */
2606
+    public function set_city( $value ) {
2607
+        $this->set_prop( 'city', $value );
2448 2608
     }
2449 2609
 
2450 2610
     /**
2451
-	 * Alias of self::set_last_name().
2452
-	 *
2453
-	 * @since 1.0.19
2454
-	 * @param  string $value last name.
2455
-	 */
2456
-	public function set_customer_last_name( $value ) {
2457
-		$this->set_last_name( $value );
2611
+     * Alias of self::set_city().
2612
+     *
2613
+     * @since 1.0.19
2614
+     * @param  string $value city.
2615
+     */
2616
+    public function set_user_city( $value ) {
2617
+        $this->set_city( $value );
2458 2618
     }
2459 2619
 
2460 2620
     /**
2461
-	 * Set the customer's phone number.
2462
-	 *
2463
-	 * @since 1.0.19
2464
-	 * @param  string $value phone.
2465
-	 */
2466
-	public function set_phone( $value ) {
2467
-		$this->set_prop( 'phone', $value );
2621
+     * Alias of self::set_city().
2622
+     *
2623
+     * @since 1.0.19
2624
+     * @param  string $value city.
2625
+     */
2626
+    public function set_customer_city( $value ) {
2627
+        $this->set_city( $value );
2468 2628
     }
2469 2629
 
2470 2630
     /**
2471
-	 * Alias of self::set_phone().
2472
-	 *
2473
-	 * @since 1.0.19
2474
-	 * @param  string $value phone.
2475
-	 */
2476
-	public function set_user_phone( $value ) {
2477
-		$this->set_phone( $value );
2631
+     * Set the customer's zip code.
2632
+     *
2633
+     * @since 1.0.19
2634
+     * @param  string $value zip.
2635
+     */
2636
+    public function set_zip( $value ) {
2637
+        $this->set_prop( 'zip', $value );
2478 2638
     }
2479 2639
 
2480 2640
     /**
2481
-	 * Alias of self::set_phone().
2482
-	 *
2483
-	 * @since 1.0.19
2484
-	 * @param  string $value phone.
2485
-	 */
2486
-	public function set_customer_phone( $value ) {
2487
-		$this->set_phone( $value );
2641
+     * Alias of self::set_zip().
2642
+     *
2643
+     * @since 1.0.19
2644
+     * @param  string $value zip.
2645
+     */
2646
+    public function set_user_zip( $value ) {
2647
+        $this->set_zip( $value );
2488 2648
     }
2489 2649
 
2490 2650
     /**
2491
-	 * Alias of self::set_phone().
2492
-	 *
2493
-	 * @since 1.0.19
2494
-	 * @param  string $value phone.
2495
-	 */
2496
-	public function set_phone_number( $value ) {
2497
-		$this->set_phone( $value );
2651
+     * Alias of self::set_zip().
2652
+     *
2653
+     * @since 1.0.19
2654
+     * @param  string $value zip.
2655
+     */
2656
+    public function set_customer_zip( $value ) {
2657
+        $this->set_zip( $value );
2498 2658
     }
2499 2659
 
2500 2660
     /**
2501
-	 * Set the customer's email address.
2502
-	 *
2503
-	 * @since 1.0.19
2504
-	 * @param  string $value email address.
2505
-	 */
2506
-	public function set_email( $value ) {
2507
-		$this->set_prop( 'email', $value );
2661
+     * Set the customer's company.
2662
+     *
2663
+     * @since 1.0.19
2664
+     * @param  string $value company.
2665
+     */
2666
+    public function set_company( $value ) {
2667
+        $this->set_prop( 'company', $value );
2508 2668
     }
2509 2669
 
2510 2670
     /**
2511
-	 * Alias of self::set_email().
2512
-	 *
2513
-	 * @since 1.0.19
2514
-	 * @param  string $value email address.
2515
-	 */
2516
-	public function set_user_email( $value ) {
2517
-		$this->set_email( $value );
2671
+     * Alias of self::set_company().
2672
+     *
2673
+     * @since 1.0.19
2674
+     * @param  string $value company.
2675
+     */
2676
+    public function set_user_company( $value ) {
2677
+        $this->set_company( $value );
2518 2678
     }
2519 2679
 
2520 2680
     /**
2521
-	 * Alias of self::set_email().
2522
-	 *
2523
-	 * @since 1.0.19
2524
-	 * @param  string $value email address.
2525
-	 */
2526
-	public function set_email_address( $value ) {
2527
-		$this->set_email( $value );
2681
+     * Alias of self::set_company().
2682
+     *
2683
+     * @since 1.0.19
2684
+     * @param  string $value company.
2685
+     */
2686
+    public function set_customer_company( $value ) {
2687
+        $this->set_company( $value );
2528 2688
     }
2529 2689
 
2530 2690
     /**
2531
-	 * Alias of self::set_email().
2532
-	 *
2533
-	 * @since 1.0.19
2534
-	 * @param  string $value email address.
2535
-	 */
2536
-	public function set_customer_email( $value ) {
2537
-		$this->set_email( $value );
2691
+     * Set the customer's company id.
2692
+     *
2693
+     * @since 1.0.19
2694
+     * @param  string $value company id.
2695
+     */
2696
+    public function set_company_id( $value ) {
2697
+        $this->set_prop( 'company_id', $value );
2538 2698
     }
2539 2699
 
2540 2700
     /**
2541
-	 * Set the customer's country.
2542
-	 *
2543
-	 * @since 1.0.19
2544
-	 * @param  string $value country.
2545
-	 */
2546
-	public function set_country( $value ) {
2547
-		$this->set_prop( 'country', $value );
2701
+     * Set the customer's var number.
2702
+     *
2703
+     * @since 1.0.19
2704
+     * @param  string $value var number.
2705
+     */
2706
+    public function set_vat_number( $value ) {
2707
+        $this->set_prop( 'vat_number', $value );
2548 2708
     }
2549 2709
 
2550 2710
     /**
2551
-	 * Alias of self::set_country().
2552
-	 *
2553
-	 * @since 1.0.19
2554
-	 * @param  string $value country.
2555
-	 */
2556
-	public function set_user_country( $value ) {
2557
-		$this->set_country( $value );
2711
+     * Alias of self::set_vat_number().
2712
+     *
2713
+     * @since 1.0.19
2714
+     * @param  string $value var number.
2715
+     */
2716
+    public function set_user_vat_number( $value ) {
2717
+        $this->set_vat_number( $value );
2558 2718
     }
2559 2719
 
2560 2720
     /**
2561
-	 * Alias of self::set_country().
2562
-	 *
2563
-	 * @since 1.0.19
2564
-	 * @param  string $value country.
2565
-	 */
2566
-	public function set_customer_country( $value ) {
2567
-		$this->set_country( $value );
2721
+     * Alias of self::set_vat_number().
2722
+     *
2723
+     * @since 1.0.19
2724
+     * @param  string $value var number.
2725
+     */
2726
+    public function set_customer_vat_number( $value ) {
2727
+        $this->set_vat_number( $value );
2568 2728
     }
2569 2729
 
2570 2730
     /**
2571
-	 * Set the customer's state.
2572
-	 *
2573
-	 * @since 1.0.19
2574
-	 * @param  string $value state.
2575
-	 */
2576
-	public function set_state( $value ) {
2577
-		$this->set_prop( 'state', $value );
2731
+     * Set the customer's vat rate.
2732
+     *
2733
+     * @since 1.0.19
2734
+     * @param  string $value var rate.
2735
+     */
2736
+    public function set_vat_rate( $value ) {
2737
+        $this->set_prop( 'vat_rate', $value );
2578 2738
     }
2579 2739
 
2580 2740
     /**
2581
-	 * Alias of self::set_state().
2582
-	 *
2583
-	 * @since 1.0.19
2584
-	 * @param  string $value state.
2585
-	 */
2586
-	public function set_user_state( $value ) {
2587
-		$this->set_state( $value );
2741
+     * Alias of self::set_vat_rate().
2742
+     *
2743
+     * @since 1.0.19
2744
+     * @param  string $value var number.
2745
+     */
2746
+    public function set_user_vat_rate( $value ) {
2747
+        $this->set_vat_rate( $value );
2588 2748
     }
2589 2749
 
2590 2750
     /**
2591
-	 * Alias of self::set_state().
2592
-	 *
2593
-	 * @since 1.0.19
2594
-	 * @param  string $value state.
2595
-	 */
2596
-	public function set_customer_state( $value ) {
2597
-		$this->set_state( $value );
2751
+     * Alias of self::set_vat_rate().
2752
+     *
2753
+     * @since 1.0.19
2754
+     * @param  string $value var number.
2755
+     */
2756
+    public function set_customer_vat_rate( $value ) {
2757
+        $this->set_vat_rate( $value );
2598 2758
     }
2599 2759
 
2600 2760
     /**
2601
-	 * Set the customer's city.
2602
-	 *
2603
-	 * @since 1.0.19
2604
-	 * @param  string $value city.
2605
-	 */
2606
-	public function set_city( $value ) {
2607
-		$this->set_prop( 'city', $value );
2761
+     * Set the customer's address.
2762
+     *
2763
+     * @since 1.0.19
2764
+     * @param  string $value address.
2765
+     */
2766
+    public function set_address( $value ) {
2767
+        $this->set_prop( 'address', $value );
2608 2768
     }
2609 2769
 
2610 2770
     /**
2611
-	 * Alias of self::set_city().
2612
-	 *
2613
-	 * @since 1.0.19
2614
-	 * @param  string $value city.
2615
-	 */
2616
-	public function set_user_city( $value ) {
2617
-		$this->set_city( $value );
2771
+     * Alias of self::set_address().
2772
+     *
2773
+     * @since 1.0.19
2774
+     * @param  string $value address.
2775
+     */
2776
+    public function set_user_address( $value ) {
2777
+        $this->set_address( $value );
2618 2778
     }
2619 2779
 
2620 2780
     /**
2621
-	 * Alias of self::set_city().
2622
-	 *
2623
-	 * @since 1.0.19
2624
-	 * @param  string $value city.
2625
-	 */
2626
-	public function set_customer_city( $value ) {
2627
-		$this->set_city( $value );
2781
+     * Alias of self::set_address().
2782
+     *
2783
+     * @since 1.0.19
2784
+     * @param  string $value address.
2785
+     */
2786
+    public function set_customer_address( $value ) {
2787
+        $this->set_address( $value );
2628 2788
     }
2629 2789
 
2630 2790
     /**
2631
-	 * Set the customer's zip code.
2632
-	 *
2633
-	 * @since 1.0.19
2634
-	 * @param  string $value zip.
2635
-	 */
2636
-	public function set_zip( $value ) {
2637
-		$this->set_prop( 'zip', $value );
2791
+     * Set whether the customer has viewed the invoice or not.
2792
+     *
2793
+     * @since 1.0.19
2794
+     * @param  int|bool $value confirmed.
2795
+     */
2796
+    public function set_is_viewed( $value ) {
2797
+        $this->set_prop( 'is_viewed', $value );
2638 2798
     }
2639 2799
 
2640 2800
     /**
2641
-	 * Alias of self::set_zip().
2642
-	 *
2643
-	 * @since 1.0.19
2644
-	 * @param  string $value zip.
2645
-	 */
2646
-	public function set_user_zip( $value ) {
2647
-		$this->set_zip( $value );
2801
+     * Set extra email recipients.
2802
+     *
2803
+     * @since 1.0.19
2804
+     * @param  string $value email recipients.
2805
+     */
2806
+    public function set_email_cc( $value ) {
2807
+        $this->set_prop( 'email_cc', $value );
2648 2808
     }
2649 2809
 
2650 2810
     /**
2651
-	 * Alias of self::set_zip().
2652
-	 *
2653
-	 * @since 1.0.19
2654
-	 * @param  string $value zip.
2655
-	 */
2656
-	public function set_customer_zip( $value ) {
2657
-		$this->set_zip( $value );
2811
+     * Set the invoice template.
2812
+     *
2813
+     * @since 1.0.19
2814
+     * @param  string $value template.
2815
+     */
2816
+    public function set_template( $value ) {
2817
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2818
+            $this->set_prop( 'template', $value );
2819
+        }
2658 2820
     }
2659 2821
 
2660 2822
     /**
2661
-	 * Set the customer's company.
2662
-	 *
2663
-	 * @since 1.0.19
2664
-	 * @param  string $value company.
2665
-	 */
2666
-	public function set_company( $value ) {
2667
-		$this->set_prop( 'company', $value );
2823
+     * Set the invoice source.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  string $value source.
2827
+     * @deprecated
2828
+     */
2829
+    public function created_via( $value ) {
2830
+        $this->set_created_via( sanitize_text_field( $value ) );
2668 2831
     }
2669 2832
 
2670 2833
     /**
2671
-	 * Alias of self::set_company().
2672
-	 *
2673
-	 * @since 1.0.19
2674
-	 * @param  string $value company.
2675
-	 */
2676
-	public function set_user_company( $value ) {
2677
-		$this->set_company( $value );
2834
+     * Set the invoice source.
2835
+     *
2836
+     * @since 1.0.19
2837
+     * @param  string $value source.
2838
+     */
2839
+    public function set_created_via( $value ) {
2840
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2678 2841
     }
2679 2842
 
2680 2843
     /**
2681
-	 * Alias of self::set_company().
2682
-	 *
2683
-	 * @since 1.0.19
2684
-	 * @param  string $value company.
2685
-	 */
2686
-	public function set_customer_company( $value ) {
2687
-		$this->set_company( $value );
2688
-    }
2689
-
2690
-	/**
2691
-	 * Set the customer's company id.
2692
-	 *
2693
-	 * @since 1.0.19
2694
-	 * @param  string $value company id.
2695
-	 */
2696
-	public function set_company_id( $value ) {
2697
-		$this->set_prop( 'company_id', $value );
2844
+     * Set the customer's address confirmed status.
2845
+     *
2846
+     * @since 1.0.19
2847
+     * @param  int|bool $value confirmed.
2848
+     */
2849
+    public function set_address_confirmed( $value ) {
2850
+        $this->set_prop( 'address_confirmed', $value );
2698 2851
     }
2699 2852
 
2700 2853
     /**
2701
-	 * Set the customer's var number.
2702
-	 *
2703
-	 * @since 1.0.19
2704
-	 * @param  string $value var number.
2705
-	 */
2706
-	public function set_vat_number( $value ) {
2707
-		$this->set_prop( 'vat_number', $value );
2854
+     * Alias of self::set_address_confirmed().
2855
+     *
2856
+     * @since 1.0.19
2857
+     * @param  int|bool $value confirmed.
2858
+     */
2859
+    public function set_user_address_confirmed( $value ) {
2860
+        $this->set_address_confirmed( $value );
2708 2861
     }
2709 2862
 
2710 2863
     /**
2711
-	 * Alias of self::set_vat_number().
2712
-	 *
2713
-	 * @since 1.0.19
2714
-	 * @param  string $value var number.
2715
-	 */
2716
-	public function set_user_vat_number( $value ) {
2717
-		$this->set_vat_number( $value );
2864
+     * Alias of self::set_address_confirmed().
2865
+     *
2866
+     * @since 1.0.19
2867
+     * @param  int|bool $value confirmed.
2868
+     */
2869
+    public function set_customer_address_confirmed( $value ) {
2870
+        $this->set_address_confirmed( $value );
2718 2871
     }
2719 2872
 
2720 2873
     /**
2721
-	 * Alias of self::set_vat_number().
2722
-	 *
2723
-	 * @since 1.0.19
2724
-	 * @param  string $value var number.
2725
-	 */
2726
-	public function set_customer_vat_number( $value ) {
2727
-		$this->set_vat_number( $value );
2874
+     * Set the shipping fee
2875
+     *
2876
+     * @since 1.0.19
2877
+     * @param  float $value shipping amount.
2878
+     */
2879
+    public function set_shipping( $value ) {
2880
+
2881
+        if ( ! is_numeric( $value ) ) {
2882
+            return $this->set_prop( 'shipping', null );
2883
+        }
2884
+
2885
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2728 2886
     }
2729 2887
 
2730 2888
     /**
2731
-	 * Set the customer's vat rate.
2732
-	 *
2733
-	 * @since 1.0.19
2734
-	 * @param  string $value var rate.
2735
-	 */
2736
-	public function set_vat_rate( $value ) {
2737
-		$this->set_prop( 'vat_rate', $value );
2889
+     * Set the invoice sub total.
2890
+     *
2891
+     * @since 1.0.19
2892
+     * @param  float $value sub total.
2893
+     */
2894
+    public function set_subtotal( $value ) {
2895
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2738 2896
     }
2739 2897
 
2740
-    /**
2741
-	 * Alias of self::set_vat_rate().
2742
-	 *
2743
-	 * @since 1.0.19
2744
-	 * @param  string $value var number.
2745
-	 */
2746
-	public function set_user_vat_rate( $value ) {
2747
-		$this->set_vat_rate( $value );
2748
-    }
2749
-
2750
-    /**
2751
-	 * Alias of self::set_vat_rate().
2752
-	 *
2753
-	 * @since 1.0.19
2754
-	 * @param  string $value var number.
2755
-	 */
2756
-	public function set_customer_vat_rate( $value ) {
2757
-		$this->set_vat_rate( $value );
2758
-    }
2759
-
2760
-    /**
2761
-	 * Set the customer's address.
2762
-	 *
2763
-	 * @since 1.0.19
2764
-	 * @param  string $value address.
2765
-	 */
2766
-	public function set_address( $value ) {
2767
-		$this->set_prop( 'address', $value );
2768
-    }
2769
-
2770
-    /**
2771
-	 * Alias of self::set_address().
2772
-	 *
2773
-	 * @since 1.0.19
2774
-	 * @param  string $value address.
2775
-	 */
2776
-	public function set_user_address( $value ) {
2777
-		$this->set_address( $value );
2778
-    }
2779
-
2780
-    /**
2781
-	 * Alias of self::set_address().
2782
-	 *
2783
-	 * @since 1.0.19
2784
-	 * @param  string $value address.
2785
-	 */
2786
-	public function set_customer_address( $value ) {
2787
-		$this->set_address( $value );
2788
-    }
2789
-
2790
-    /**
2791
-	 * Set whether the customer has viewed the invoice or not.
2792
-	 *
2793
-	 * @since 1.0.19
2794
-	 * @param  int|bool $value confirmed.
2795
-	 */
2796
-	public function set_is_viewed( $value ) {
2797
-		$this->set_prop( 'is_viewed', $value );
2798
-	}
2799
-
2800
-	/**
2801
-	 * Set extra email recipients.
2802
-	 *
2803
-	 * @since 1.0.19
2804
-	 * @param  string $value email recipients.
2805
-	 */
2806
-	public function set_email_cc( $value ) {
2807
-		$this->set_prop( 'email_cc', $value );
2808
-	}
2809
-
2810
-	/**
2811
-	 * Set the invoice template.
2812
-	 *
2813
-	 * @since 1.0.19
2814
-	 * @param  string $value template.
2815
-	 */
2816
-	public function set_template( $value ) {
2817
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2818
-			$this->set_prop( 'template', $value );
2819
-		}
2820
-	}
2821
-
2822
-	/**
2823
-	 * Set the invoice source.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  string $value source.
2827
-	 * @deprecated
2828
-	 */
2829
-	public function created_via( $value ) {
2830
-		$this->set_created_via( sanitize_text_field( $value ) );
2831
-	}
2832
-
2833
-	/**
2834
-	 * Set the invoice source.
2835
-	 *
2836
-	 * @since 1.0.19
2837
-	 * @param  string $value source.
2838
-	 */
2839
-	public function set_created_via( $value ) {
2840
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2841
-	}
2842
-
2843
-	/**
2844
-	 * Set the customer's address confirmed status.
2845
-	 *
2846
-	 * @since 1.0.19
2847
-	 * @param  int|bool $value confirmed.
2848
-	 */
2849
-	public function set_address_confirmed( $value ) {
2850
-		$this->set_prop( 'address_confirmed', $value );
2851
-    }
2852
-
2853
-    /**
2854
-	 * Alias of self::set_address_confirmed().
2855
-	 *
2856
-	 * @since 1.0.19
2857
-	 * @param  int|bool $value confirmed.
2858
-	 */
2859
-	public function set_user_address_confirmed( $value ) {
2860
-		$this->set_address_confirmed( $value );
2861
-    }
2862
-
2863
-    /**
2864
-	 * Alias of self::set_address_confirmed().
2865
-	 *
2866
-	 * @since 1.0.19
2867
-	 * @param  int|bool $value confirmed.
2868
-	 */
2869
-	public function set_customer_address_confirmed( $value ) {
2870
-		$this->set_address_confirmed( $value );
2871
-    }
2872
-
2873
-    /**
2874
-	 * Set the shipping fee
2875
-	 *
2876
-	 * @since 1.0.19
2877
-	 * @param  float $value shipping amount.
2878
-	 */
2879
-	public function set_shipping( $value ) {
2880
-
2881
-		if ( ! is_numeric( $value ) ) {
2882
-			return $this->set_prop( 'shipping', null );
2883
-		}
2884
-
2885
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2886
-	}
2887
-
2888
-	/**
2889
-	 * Set the invoice sub total.
2890
-	 *
2891
-	 * @since 1.0.19
2892
-	 * @param  float $value sub total.
2893
-	 */
2894
-	public function set_subtotal( $value ) {
2895
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2896
-	}
2897
-
2898
-	/**
2899
-	 * Set the invoice total.
2900
-	 *
2901
-	 * @since 1.0.19
2902
-	 * @param  float $value sub total.
2903
-	 */
2904
-	public function set_total( $value ) {
2905
-		$this->set_prop( 'total', max( 0, $value ) );
2898
+    /**
2899
+     * Set the invoice total.
2900
+     *
2901
+     * @since 1.0.19
2902
+     * @param  float $value sub total.
2903
+     */
2904
+    public function set_total( $value ) {
2905
+        $this->set_prop( 'total', max( 0, $value ) );
2906 2906
     }
2907 2907
 
2908 2908
     /**
2909
-	 * Set the invoice discount amount.
2910
-	 *
2911
-	 * @since 1.0.19
2912
-	 * @param  float $value discount total.
2913
-	 */
2914
-	public function set_total_discount( $value ) {
2915
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2909
+     * Set the invoice discount amount.
2910
+     *
2911
+     * @since 1.0.19
2912
+     * @param  float $value discount total.
2913
+     */
2914
+    public function set_total_discount( $value ) {
2915
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919
-	 * Alias of self::set_total_discount().
2920
-	 *
2921
-	 * @since 1.0.19
2922
-	 * @param  float $value discount total.
2923
-	 */
2924
-	public function set_discount( $value ) {
2925
-		$this->set_total_discount( $value );
2919
+     * Alias of self::set_total_discount().
2920
+     *
2921
+     * @since 1.0.19
2922
+     * @param  float $value discount total.
2923
+     */
2924
+    public function set_discount( $value ) {
2925
+        $this->set_total_discount( $value );
2926 2926
     }
2927 2927
 
2928 2928
     /**
2929
-	 * Set the invoice tax amount.
2930
-	 *
2931
-	 * @since 1.0.19
2932
-	 * @param  float $value tax total.
2933
-	 */
2934
-	public function set_total_tax( $value ) {
2935
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2929
+     * Set the invoice tax amount.
2930
+     *
2931
+     * @since 1.0.19
2932
+     * @param  float $value tax total.
2933
+     */
2934
+    public function set_total_tax( $value ) {
2935
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2936 2936
     }
2937 2937
 
2938 2938
     /**
2939
-	 * Alias of self::set_total_tax().
2940
-	 *
2941
-	 * @since 1.0.19
2942
-	 * @param  float $value tax total.
2943
-	 */
2944
-	public function set_tax_total( $value ) {
2945
-		$this->set_total_tax( $value );
2939
+     * Alias of self::set_total_tax().
2940
+     *
2941
+     * @since 1.0.19
2942
+     * @param  float $value tax total.
2943
+     */
2944
+    public function set_tax_total( $value ) {
2945
+        $this->set_total_tax( $value );
2946 2946
     }
2947 2947
 
2948 2948
     /**
2949
-	 * Set the invoice fees amount.
2950
-	 *
2951
-	 * @since 1.0.19
2952
-	 * @param  float $value fees total.
2953
-	 */
2954
-	public function set_total_fees( $value ) {
2955
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2949
+     * Set the invoice fees amount.
2950
+     *
2951
+     * @since 1.0.19
2952
+     * @param  float $value fees total.
2953
+     */
2954
+    public function set_total_fees( $value ) {
2955
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2956 2956
     }
2957 2957
 
2958 2958
     /**
2959
-	 * Alias of self::set_total_fees().
2960
-	 *
2961
-	 * @since 1.0.19
2962
-	 * @param  float $value fees total.
2963
-	 */
2964
-	public function set_fees_total( $value ) {
2965
-		$this->set_total_fees( $value );
2959
+     * Alias of self::set_total_fees().
2960
+     *
2961
+     * @since 1.0.19
2962
+     * @param  float $value fees total.
2963
+     */
2964
+    public function set_fees_total( $value ) {
2965
+        $this->set_total_fees( $value );
2966 2966
     }
2967 2967
 
2968 2968
     /**
2969
-	 * Set the invoice fees.
2970
-	 *
2971
-	 * @since 1.0.19
2972
-	 * @param  array $value fees.
2973
-	 */
2974
-	public function set_fees( $value ) {
2969
+     * Set the invoice fees.
2970
+     *
2971
+     * @since 1.0.19
2972
+     * @param  array $value fees.
2973
+     */
2974
+    public function set_fees( $value ) {
2975 2975
 
2976
-		if ( ! is_array( $value ) ) {
2977
-			$value = array();
2978
-		}
2976
+        if ( ! is_array( $value ) ) {
2977
+            $value = array();
2978
+        }
2979 2979
 
2980
-		$this->set_prop( 'fees', $value );
2980
+        $this->set_prop( 'fees', $value );
2981 2981
 
2982 2982
     }
2983 2983
 
2984 2984
     /**
2985
-	 * Set the invoice taxes.
2986
-	 *
2987
-	 * @since 1.0.19
2988
-	 * @param  array $value taxes.
2989
-	 */
2990
-	public function set_taxes( $value ) {
2985
+     * Set the invoice taxes.
2986
+     *
2987
+     * @since 1.0.19
2988
+     * @param  array $value taxes.
2989
+     */
2990
+    public function set_taxes( $value ) {
2991 2991
 
2992
-		if ( ! is_array( $value ) ) {
2993
-			$value = array();
2994
-		}
2992
+        if ( ! is_array( $value ) ) {
2993
+            $value = array();
2994
+        }
2995 2995
 
2996
-		$this->set_prop( 'taxes', $value );
2996
+        $this->set_prop( 'taxes', $value );
2997 2997
 
2998 2998
     }
2999 2999
 
3000 3000
     /**
3001
-	 * Set the invoice discounts.
3002
-	 *
3003
-	 * @since 1.0.19
3004
-	 * @param  array $value discounts.
3005
-	 */
3006
-	public function set_discounts( $value ) {
3001
+     * Set the invoice discounts.
3002
+     *
3003
+     * @since 1.0.19
3004
+     * @param  array $value discounts.
3005
+     */
3006
+    public function set_discounts( $value ) {
3007 3007
 
3008
-		if ( ! is_array( $value ) ) {
3009
-			$value = array();
3010
-		}
3008
+        if ( ! is_array( $value ) ) {
3009
+            $value = array();
3010
+        }
3011 3011
 
3012
-		$this->set_prop( 'discounts', $value );
3012
+        $this->set_prop( 'discounts', $value );
3013 3013
     }
3014 3014
 
3015 3015
     /**
3016
-	 * Set the invoice items.
3017
-	 *
3018
-	 * @since 1.0.19
3019
-	 * @param  GetPaid_Form_Item[] $value items.
3020
-	 */
3021
-	public function set_items( $value ) {
3016
+     * Set the invoice items.
3017
+     *
3018
+     * @since 1.0.19
3019
+     * @param  GetPaid_Form_Item[] $value items.
3020
+     */
3021
+    public function set_items( $value ) {
3022 3022
 
3023 3023
         // Remove existing items.
3024 3024
         $this->set_prop( 'items', array() );
3025
-		$this->recurring_item = null;
3025
+        $this->recurring_item = null;
3026 3026
 
3027 3027
         // Ensure that we have an array.
3028 3028
         if ( ! is_array( $value ) ) {
@@ -3036,95 +3036,95 @@  discard block
 block discarded – undo
3036 3036
     }
3037 3037
 
3038 3038
     /**
3039
-	 * Set the payment form.
3040
-	 *
3041
-	 * @since 1.0.19
3042
-	 * @param  int $value payment form.
3043
-	 */
3044
-	public function set_payment_form( $value ) {
3045
-		$this->set_prop( 'payment_form', $value );
3039
+     * Set the payment form.
3040
+     *
3041
+     * @since 1.0.19
3042
+     * @param  int $value payment form.
3043
+     */
3044
+    public function set_payment_form( $value ) {
3045
+        $this->set_prop( 'payment_form', $value );
3046 3046
     }
3047 3047
 
3048 3048
     /**
3049
-	 * Set the submission id.
3050
-	 *
3051
-	 * @since 1.0.19
3052
-	 * @param  string $value submission id.
3053
-	 */
3054
-	public function set_submission_id( $value ) {
3055
-		$this->set_prop( 'submission_id', $value );
3049
+     * Set the submission id.
3050
+     *
3051
+     * @since 1.0.19
3052
+     * @param  string $value submission id.
3053
+     */
3054
+    public function set_submission_id( $value ) {
3055
+        $this->set_prop( 'submission_id', $value );
3056 3056
     }
3057 3057
 
3058 3058
     /**
3059
-	 * Set the discount code.
3060
-	 *
3061
-	 * @since 1.0.19
3062
-	 * @param  string $value discount code.
3063
-	 */
3064
-	public function set_discount_code( $value ) {
3065
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3059
+     * Set the discount code.
3060
+     *
3061
+     * @since 1.0.19
3062
+     * @param  string $value discount code.
3063
+     */
3064
+    public function set_discount_code( $value ) {
3065
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3066 3066
     }
3067 3067
 
3068 3068
     /**
3069
-	 * Set the gateway.
3070
-	 *
3071
-	 * @since 1.0.19
3072
-	 * @param  string $value gateway.
3073
-	 */
3074
-	public function set_gateway( $value ) {
3075
-		$this->set_prop( 'gateway', $value );
3069
+     * Set the gateway.
3070
+     *
3071
+     * @since 1.0.19
3072
+     * @param  string $value gateway.
3073
+     */
3074
+    public function set_gateway( $value ) {
3075
+        $this->set_prop( 'gateway', $value );
3076 3076
     }
3077 3077
 
3078 3078
     /**
3079
-	 * Set the transaction id.
3080
-	 *
3081
-	 * @since 1.0.19
3082
-	 * @param  string $value transaction id.
3083
-	 */
3084
-	public function set_transaction_id( $value ) {
3085
-		if ( ! empty( $value ) ) {
3086
-			$this->set_prop( 'transaction_id', $value );
3087
-		}
3079
+     * Set the transaction id.
3080
+     *
3081
+     * @since 1.0.19
3082
+     * @param  string $value transaction id.
3083
+     */
3084
+    public function set_transaction_id( $value ) {
3085
+        if ( ! empty( $value ) ) {
3086
+            $this->set_prop( 'transaction_id', $value );
3087
+        }
3088 3088
     }
3089 3089
 
3090 3090
     /**
3091
-	 * Set the currency id.
3092
-	 *
3093
-	 * @since 1.0.19
3094
-	 * @param  string $value currency id.
3095
-	 */
3096
-	public function set_currency( $value ) {
3097
-		$this->set_prop( 'currency', $value );
3091
+     * Set the currency id.
3092
+     *
3093
+     * @since 1.0.19
3094
+     * @param  string $value currency id.
3095
+     */
3096
+    public function set_currency( $value ) {
3097
+        $this->set_prop( 'currency', $value );
3098 3098
     }
3099 3099
 
3100
-	/**
3101
-	 * Set whether to disable taxes.
3102
-	 *
3103
-	 * @since 1.0.19
3104
-	 * @param  bool $value value.
3105
-	 */
3106
-	public function set_disable_taxes( $value ) {
3107
-		$this->set_prop( 'disable_taxes', (bool) $value );
3108
-	}
3100
+    /**
3101
+     * Set whether to disable taxes.
3102
+     *
3103
+     * @since 1.0.19
3104
+     * @param  bool $value value.
3105
+     */
3106
+    public function set_disable_taxes( $value ) {
3107
+        $this->set_prop( 'disable_taxes', (bool) $value );
3108
+    }
3109 3109
 
3110 3110
     /**
3111
-	 * Set the subscription id.
3112
-	 *
3113
-	 * @since 1.0.19
3114
-	 * @param  string $value subscription id.
3115
-	 */
3116
-	public function set_subscription_id( $value ) {
3117
-		$this->set_prop( 'subscription_id', $value );
3118
-	}
3111
+     * Set the subscription id.
3112
+     *
3113
+     * @since 1.0.19
3114
+     * @param  string $value subscription id.
3115
+     */
3116
+    public function set_subscription_id( $value ) {
3117
+        $this->set_prop( 'subscription_id', $value );
3118
+    }
3119 3119
 
3120
-	/**
3121
-	 * Set the remote subscription id.
3122
-	 *
3123
-	 * @since 1.0.19
3124
-	 * @param  string $value subscription id.
3125
-	 */
3126
-	public function set_remote_subscription_id( $value ) {
3127
-		$this->set_prop( 'remote_subscription_id', $value );
3120
+    /**
3121
+     * Set the remote subscription id.
3122
+     *
3123
+     * @since 1.0.19
3124
+     * @param  string $value subscription id.
3125
+     */
3126
+    public function set_remote_subscription_id( $value ) {
3127
+        $this->set_prop( 'remote_subscription_id', $value );
3128 3128
     }
3129 3129
 
3130 3130
     /*
@@ -3163,24 +3163,24 @@  discard block
 block discarded – undo
3163 3163
      */
3164 3164
     public function is_taxable() {
3165 3165
         return ! $this->get_disable_taxes();
3166
-	}
3166
+    }
3167 3167
 
3168
-	/**
3169
-	 * @deprecated
3170
-	 */
3171
-	public function has_vat() {
3168
+    /**
3169
+     * @deprecated
3170
+     */
3171
+    public function has_vat() {
3172 3172
         return $this->is_taxable();
3173
-	}
3173
+    }
3174 3174
 
3175
-	/**
3176
-	 * Checks to see if the invoice requires payment.
3177
-	 */
3178
-	public function is_free() {
3175
+    /**
3176
+     * Checks to see if the invoice requires payment.
3177
+     */
3178
+    public function is_free() {
3179 3179
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3180 3180
 
3181
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3182
-			$is_free = false;
3183
-		}
3181
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3182
+            $is_free = false;
3183
+        }
3184 3184
 
3185 3185
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3186 3186
     }
@@ -3191,46 +3191,46 @@  discard block
 block discarded – undo
3191 3191
     public function is_paid() {
3192 3192
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3193 3193
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3194
-	}
3194
+    }
3195 3195
 
3196
-	/**
3196
+    /**
3197 3197
      * Checks if the invoice needs payment.
3198 3198
      */
3199
-	public function needs_payment() {
3200
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3199
+    public function needs_payment() {
3200
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3201 3201
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3202 3202
     }
3203 3203
 
3204
-	/**
3204
+    /**
3205 3205
      * Checks if the invoice is refunded.
3206 3206
      */
3207
-	public function is_refunded() {
3207
+    public function is_refunded() {
3208 3208
         $is_refunded = $this->has_status( 'wpi-refunded' );
3209 3209
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3210
-	}
3210
+    }
3211 3211
 
3212
-	/**
3212
+    /**
3213 3213
      * Checks if the invoice is held.
3214 3214
      */
3215
-	public function is_held() {
3215
+    public function is_held() {
3216 3216
         $is_held = $this->has_status( 'wpi-onhold' );
3217 3217
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3218
-	}
3218
+    }
3219 3219
 
3220
-	/**
3220
+    /**
3221 3221
      * Checks if the invoice is due.
3222 3222
      */
3223
-	public function is_due() {
3224
-		$due_date = $this->get_due_date();
3225
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3226
-	}
3223
+    public function is_due() {
3224
+        $due_date = $this->get_due_date();
3225
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3226
+    }
3227 3227
 
3228
-	/**
3228
+    /**
3229 3229
      * Checks if the invoice is draft.
3230 3230
      */
3231
-	public function is_draft() {
3231
+    public function is_draft() {
3232 3232
         return $this->has_status( 'draft, auto-draft' );
3233
-	}
3233
+    }
3234 3234
 
3235 3235
     /**
3236 3236
      * Checks if the invoice has a given status.
@@ -3238,9 +3238,9 @@  discard block
 block discarded – undo
3238 3238
     public function has_status( $status ) {
3239 3239
         $status = wpinv_parse_list( $status );
3240 3240
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3241
-	}
3241
+    }
3242 3242
 
3243
-	/**
3243
+    /**
3244 3244
      * Checks if the invoice is of a given type.
3245 3245
      */
3246 3246
     public function is_type( $type ) {
@@ -3263,25 +3263,25 @@  discard block
 block discarded – undo
3263 3263
      */
3264 3264
     public function has_free_trial() {
3265 3265
         return $this->is_recurring() && 0 == $this->get_initial_total();
3266
-	}
3266
+    }
3267 3267
 
3268
-	/**
3268
+    /**
3269 3269
      * @deprecated
3270 3270
      */
3271 3271
     public function is_free_trial() {
3272 3272
         return $this->has_free_trial();
3273 3273
     }
3274 3274
 
3275
-	/**
3275
+    /**
3276 3276
      * Check if the initial payment if 0.
3277 3277
      *
3278 3278
      */
3279
-	public function is_initial_free() {
3279
+    public function is_initial_free() {
3280 3280
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3281 3281
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3282 3282
     }
3283 3283
 
3284
-	/**
3284
+    /**
3285 3285
      * Check if the recurring item has a free trial.
3286 3286
      *
3287 3287
      */
@@ -3294,21 +3294,21 @@  discard block
 block discarded – undo
3294 3294
 
3295 3295
         $item = $this->get_recurring( true );
3296 3296
         return $item->has_free_trial();
3297
-	}
3297
+    }
3298 3298
 
3299
-	/**
3299
+    /**
3300 3300
      * Check if the free trial is a result of a discount.
3301 3301
      */
3302 3302
     public function is_free_trial_from_discount() {
3303
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3304
-	}
3303
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3304
+    }
3305 3305
 
3306
-	/**
3306
+    /**
3307 3307
      * @deprecated
3308 3308
      */
3309 3309
     public function discount_first_payment_only() {
3310 3310
 
3311
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3311
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3312 3312
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3313 3313
             return true;
3314 3314
         }
@@ -3333,146 +3333,146 @@  discard block
 block discarded – undo
3333 3333
      */
3334 3334
     public function add_item( $item ) {
3335 3335
 
3336
-		if ( is_array( $item ) ) {
3337
-			$item = $this->process_array_item( $item );
3338
-		}
3336
+        if ( is_array( $item ) ) {
3337
+            $item = $this->process_array_item( $item );
3338
+        }
3339 3339
 
3340
-		if ( is_numeric( $item ) ) {
3341
-			$item = new GetPaid_Form_Item( $item );
3342
-		}
3340
+        if ( is_numeric( $item ) ) {
3341
+            $item = new GetPaid_Form_Item( $item );
3342
+        }
3343 3343
 
3344 3344
         // Make sure that it is available for purchase.
3345
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3346
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3345
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3346
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3347 3347
         }
3348 3348
 
3349 3349
         // Do we have a recurring item?
3350
-		if ( $item->is_recurring() ) {
3351
-			$this->recurring_item = $item->get_id();
3350
+        if ( $item->is_recurring() ) {
3351
+            $this->recurring_item = $item->get_id();
3352 3352
         }
3353 3353
 
3354 3354
         // Invoice id.
3355 3355
         $item->invoice_id = (int) $this->get_id();
3356 3356
 
3357
-		// Remove duplicates.
3358
-		$this->remove_item( $item->get_id() );
3357
+        // Remove duplicates.
3358
+        $this->remove_item( $item->get_id() );
3359 3359
 
3360
-		if ( 0 == $item->get_quantity() ) {
3361
-			return;
3362
-		}
3360
+        if ( 0 == $item->get_quantity() ) {
3361
+            return;
3362
+        }
3363 3363
 
3364
-		// Retrieve all items.
3364
+        // Retrieve all items.
3365 3365
         $items   = $this->get_items();
3366 3366
 
3367
-		// Add new item.
3367
+        // Add new item.
3368 3368
         $items[] = $item;
3369 3369
 
3370 3370
         $this->set_prop( 'items', $items );
3371 3371
 
3372
-		return true;
3373
-	}
3372
+        return true;
3373
+    }
3374 3374
 
3375
-	/**
3376
-	 * Converts an array to an item.
3377
-	 *
3378
-	 * @since 1.0.19
3379
-	 * @return GetPaid_Form_Item
3380
-	 */
3381
-	protected function process_array_item( $array ) {
3375
+    /**
3376
+     * Converts an array to an item.
3377
+     *
3378
+     * @since 1.0.19
3379
+     * @return GetPaid_Form_Item
3380
+     */
3381
+    protected function process_array_item( $array ) {
3382 3382
 
3383
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3384
-		$item    = new GetPaid_Form_Item( $item_id );
3383
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3384
+        $item    = new GetPaid_Form_Item( $item_id );
3385 3385
 
3386
-		// Set item data.
3387
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3388
-			if ( isset( $array[ "item_$key" ] ) ) {
3389
-				$method = "set_$key";
3390
-				$item->$method( $array[ "item_$key" ] );
3391
-			}
3392
-		}
3386
+        // Set item data.
3387
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3388
+            if ( isset( $array[ "item_$key" ] ) ) {
3389
+                $method = "set_$key";
3390
+                $item->$method( $array[ "item_$key" ] );
3391
+            }
3392
+        }
3393 3393
 
3394
-		if ( isset( $array['quantity'] ) ) {
3395
-			$item->set_quantity( $array['quantity'] );
3396
-		}
3394
+        if ( isset( $array['quantity'] ) ) {
3395
+            $item->set_quantity( $array['quantity'] );
3396
+        }
3397 3397
 
3398
-		// Set item meta.
3399
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3400
-			$item->set_item_meta( $array['meta'] );
3401
-		}
3398
+        // Set item meta.
3399
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3400
+            $item->set_item_meta( $array['meta'] );
3401
+        }
3402 3402
 
3403
-		return $item;
3403
+        return $item;
3404 3404
 
3405
-	}
3405
+    }
3406 3406
 
3407 3407
     /**
3408
-	 * Retrieves a specific item.
3409
-	 *
3410
-	 * @since 1.0.19
3411
-	 * @return GetPaid_Form_Item|null
3412
-	 */
3413
-	public function get_item( $item_id ) {
3408
+     * Retrieves a specific item.
3409
+     *
3410
+     * @since 1.0.19
3411
+     * @return GetPaid_Form_Item|null
3412
+     */
3413
+    public function get_item( $item_id ) {
3414 3414
 
3415
-		foreach ( $this->get_items() as $item ) {
3416
-			if ( (int) $item_id == $item->get_id() ) {
3417
-				return $item;
3418
-			}
3419
-		}
3415
+        foreach ( $this->get_items() as $item ) {
3416
+            if ( (int) $item_id == $item->get_id() ) {
3417
+                return $item;
3418
+            }
3419
+        }
3420 3420
 
3421
-		return null;
3421
+        return null;
3422 3422
     }
3423 3423
 
3424 3424
     /**
3425
-	 * Removes a specific item.
3426
-	 *
3427
-	 * @since 1.0.19
3428
-	 */
3429
-	public function remove_item( $item_id ) {
3430
-		$items   = $this->get_items();
3431
-		$item_id = (int) $item_id;
3425
+     * Removes a specific item.
3426
+     *
3427
+     * @since 1.0.19
3428
+     */
3429
+    public function remove_item( $item_id ) {
3430
+        $items   = $this->get_items();
3431
+        $item_id = (int) $item_id;
3432 3432
 
3433
-		foreach ( $items as $index => $item ) {
3434
-			if ( (int) $item_id == $item->get_id() ) {
3435
-				unset( $items[ $index ] );
3436
-				$this->set_prop( 'items', $items );
3433
+        foreach ( $items as $index => $item ) {
3434
+            if ( (int) $item_id == $item->get_id() ) {
3435
+                unset( $items[ $index ] );
3436
+                $this->set_prop( 'items', $items );
3437 3437
 
3438
-				if ( $item_id == $this->recurring_item ) {
3439
-					$this->recurring_item = null;
3440
-				}
3438
+                if ( $item_id == $this->recurring_item ) {
3439
+                    $this->recurring_item = null;
3440
+                }
3441 3441
 }
3442
-		}
3442
+        }
3443 3443
 
3444 3444
     }
3445 3445
 
3446 3446
     /**
3447
-	 * Adds a fee to the invoice.
3448
-	 *
3449
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3450
-	 * @since 1.0.19
3451
-	 */
3447
+     * Adds a fee to the invoice.
3448
+     *
3449
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3450
+     * @since 1.0.19
3451
+     */
3452 3452
     public function add_fee( $fee ) {
3453 3453
 
3454
-		$fees                 = $this->get_fees();
3455
-		$fees[ $fee['name'] ] = $fee;
3456
-		$this->set_prop( 'fees', $fees );
3454
+        $fees                 = $this->get_fees();
3455
+        $fees[ $fee['name'] ] = $fee;
3456
+        $this->set_prop( 'fees', $fees );
3457 3457
 
3458 3458
     }
3459 3459
 
3460 3460
     /**
3461
-	 * Retrieves a specific fee.
3462
-	 *
3463
-	 * @since 1.0.19
3464
-	 */
3465
-	public function get_fee( $fee ) {
3461
+     * Retrieves a specific fee.
3462
+     *
3463
+     * @since 1.0.19
3464
+     */
3465
+    public function get_fee( $fee ) {
3466 3466
         $fees = $this->get_fees();
3467
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3467
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3468 3468
     }
3469 3469
 
3470 3470
     /**
3471
-	 * Removes a specific fee.
3472
-	 *
3473
-	 * @since 1.0.19
3474
-	 */
3475
-	public function remove_fee( $fee ) {
3471
+     * Removes a specific fee.
3472
+     *
3473
+     * @since 1.0.19
3474
+     */
3475
+    public function remove_fee( $fee ) {
3476 3476
         $fees = $this->get_fees();
3477 3477
         if ( isset( $fees[ $fee ] ) ) {
3478 3478
             unset( $fees[ $fee ] );
@@ -3480,55 +3480,55 @@  discard block
 block discarded – undo
3480 3480
         }
3481 3481
     }
3482 3482
 
3483
-	/**
3484
-	 * Adds a discount to the invoice.
3485
-	 *
3486
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3487
-	 * @since 1.0.19
3488
-	 */
3489
-	public function add_discount( $discount ) {
3483
+    /**
3484
+     * Adds a discount to the invoice.
3485
+     *
3486
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3487
+     * @since 1.0.19
3488
+     */
3489
+    public function add_discount( $discount ) {
3490 3490
 
3491
-		$discounts = $this->get_discounts();
3492
-		$discounts[ $discount['name'] ] = $discount;
3493
-		$this->set_prop( 'discounts', $discounts );
3491
+        $discounts = $this->get_discounts();
3492
+        $discounts[ $discount['name'] ] = $discount;
3493
+        $this->set_prop( 'discounts', $discounts );
3494 3494
 
3495
-	}
3495
+    }
3496 3496
 
3497 3497
     /**
3498
-	 * Retrieves a specific discount.
3499
-	 *
3500
-	 * @since 1.0.19
3501
-	 * @return float
3502
-	 */
3503
-	public function get_discount( $discount = false ) {
3498
+     * Retrieves a specific discount.
3499
+     *
3500
+     * @since 1.0.19
3501
+     * @return float
3502
+     */
3503
+    public function get_discount( $discount = false ) {
3504 3504
 
3505
-		// Backwards compatibility.
3506
-		if ( empty( $discount ) ) {
3507
-			return $this->get_total_discount();
3508
-		}
3505
+        // Backwards compatibility.
3506
+        if ( empty( $discount ) ) {
3507
+            return $this->get_total_discount();
3508
+        }
3509 3509
 
3510 3510
         $discounts = $this->get_discounts();
3511
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3511
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3512 3512
     }
3513 3513
 
3514 3514
     /**
3515
-	 * Removes a specific discount.
3516
-	 *
3517
-	 * @since 1.0.19
3518
-	 */
3519
-	public function remove_discount( $discount ) {
3515
+     * Removes a specific discount.
3516
+     *
3517
+     * @since 1.0.19
3518
+     */
3519
+    public function remove_discount( $discount ) {
3520 3520
         $discounts = $this->get_discounts();
3521 3521
         if ( isset( $discounts[ $discount ] ) ) {
3522 3522
             unset( $discounts[ $discount ] );
3523 3523
             $this->set_prop( 'discounts', $discounts );
3524 3524
         }
3525 3525
 
3526
-		if ( 'discount_code' == $discount ) {
3527
-			foreach ( $this->get_items() as $item ) {
3528
-				$item->item_discount           = 0;
3529
-				$item->recurring_item_discount = 0;
3530
-			}
3531
-		}
3526
+        if ( 'discount_code' == $discount ) {
3527
+            foreach ( $this->get_items() as $item ) {
3528
+                $item->item_discount           = 0;
3529
+                $item->recurring_item_discount = 0;
3530
+            }
3531
+        }
3532 3532
 
3533 3533
     }
3534 3534
 
@@ -3541,116 +3541,116 @@  discard block
 block discarded – undo
3541 3541
         if ( $this->is_taxable() ) {
3542 3542
 
3543 3543
             $taxes                 = $this->get_taxes();
3544
-			$taxes[ $tax['name'] ] = $tax;
3545
-			$this->set_prop( 'taxes', $tax );
3544
+            $taxes[ $tax['name'] ] = $tax;
3545
+            $this->set_prop( 'taxes', $tax );
3546 3546
 
3547 3547
         }
3548 3548
     }
3549 3549
 
3550 3550
     /**
3551
-	 * Retrieves a specific tax.
3552
-	 *
3553
-	 * @since 1.0.19
3554
-	 */
3555
-	public function get_tax( $tax = null ) {
3551
+     * Retrieves a specific tax.
3552
+     *
3553
+     * @since 1.0.19
3554
+     */
3555
+    public function get_tax( $tax = null ) {
3556 3556
 
3557
-		// Backwards compatibility.
3558
-		if ( empty( $tax ) ) {
3559
-			return $this->get_total_tax();
3560
-		}
3557
+        // Backwards compatibility.
3558
+        if ( empty( $tax ) ) {
3559
+            return $this->get_total_tax();
3560
+        }
3561 3561
 
3562 3562
         $taxes = $this->get_taxes();
3563
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3563
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3564 3564
     }
3565 3565
 
3566
-	public function get_tax_total_by_name( $name ) {
3567
-		if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3568
-			$name = str_replace( 'tax__', '', $name );
3569
-		}
3566
+    public function get_tax_total_by_name( $name ) {
3567
+        if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3568
+            $name = str_replace( 'tax__', '', $name );
3569
+        }
3570 3570
 
3571
-		if ( empty( $name ) ) {
3572
-			return 0;
3573
-		}
3571
+        if ( empty( $name ) ) {
3572
+            return 0;
3573
+        }
3574 3574
 
3575
-		$tax = $this->get_tax( $name );
3575
+        $tax = $this->get_tax( $name );
3576 3576
 
3577
-		if ( empty( $tax ) ) {
3578
-			return 0;
3579
-		}
3577
+        if ( empty( $tax ) ) {
3578
+            return 0;
3579
+        }
3580 3580
 
3581 3581
         return $this->is_renewal() ? $tax['recurring_tax'] : $tax['initial_tax'];
3582 3582
     }
3583 3583
 
3584
-	/**
3585
-	 * Get tax item name.
3586
-	 *
3587
-	 * @since 2.8.8
3588
-	 */
3589
-	public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3590
-		$tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3584
+    /**
3585
+     * Get tax item name.
3586
+     *
3587
+     * @since 2.8.8
3588
+     */
3589
+    public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3590
+        $tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3591 3591
 
3592
-		if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3593
-			$tax_name = __( $tax_item['name'], 'invoicing' );
3594
-		}
3592
+        if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3593
+            $tax_name = __( $tax_item['name'], 'invoicing' );
3594
+        }
3595 3595
 
3596
-		if ( $suffix ) {
3597
-			$tax_name .= $suffix;
3598
-		}
3596
+        if ( $suffix ) {
3597
+            $tax_name .= $suffix;
3598
+        }
3599 3599
 
3600
-		return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3601
-	}
3600
+        return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3601
+    }
3602 3602
 
3603
-	/**
3604
-	 * Get tax item amount.
3605
-	 *
3606
-	 * @since 2.8.8
3607
-	 */
3608
-	public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3609
-		$tax_amount = $this->get_tax_total_by_name( $tax_key );
3603
+    /**
3604
+     * Get tax item amount.
3605
+     *
3606
+     * @since 2.8.8
3607
+     */
3608
+    public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3609
+        $tax_amount = $this->get_tax_total_by_name( $tax_key );
3610 3610
 
3611
-		if ( $with_currency ) {
3612
-			$tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3613
-		}
3611
+        if ( $with_currency ) {
3612
+            $tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3613
+        }
3614 3614
 
3615
-		return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3616
-	}
3615
+        return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3616
+    }
3617 3617
 
3618
-	public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3619
-		$taxes = $this->get_taxes();
3618
+    public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3619
+        $taxes = $this->get_taxes();
3620 3620
 
3621
-		if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3622
-			$names = array();
3621
+        if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3622
+            $names = array();
3623 3623
 
3624
-			foreach ( $taxes as $key => $tax ) {
3625
-				if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3626
-					$name = __( $tax['name'], 'invoicing' );
3624
+            foreach ( $taxes as $key => $tax ) {
3625
+                if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3626
+                    $name = __( $tax['name'], 'invoicing' );
3627 3627
 
3628
-					$names[] = $name;
3629
-				}
3630
-			}
3628
+                    $names[] = $name;
3629
+                }
3630
+            }
3631 3631
 
3632
-			if ( ! empty( $names ) ) {
3633
-				$names = array_unique( $names );
3632
+            if ( ! empty( $names ) ) {
3633
+                $names = array_unique( $names );
3634 3634
 
3635
-				$tax_name = implode( $sep, $names );
3636
-			}
3635
+                $tax_name = implode( $sep, $names );
3636
+            }
3637 3637
 
3638
-			if ( $percentage ) {
3639
-				$tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3640
-			}
3641
-		} else {
3642
-			$tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3643
-		}
3638
+            if ( $percentage ) {
3639
+                $tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3640
+            }
3641
+        } else {
3642
+            $tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3643
+        }
3644 3644
 
3645
-		return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3646
-	}
3645
+        return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3646
+    }
3647 3647
 
3648 3648
     /**
3649
-	 * Removes a specific tax.
3650
-	 *
3651
-	 * @since 1.0.19
3652
-	 */
3653
-	public function remove_tax( $tax ) {
3649
+     * Removes a specific tax.
3650
+     *
3651
+     * @since 1.0.19
3652
+     */
3653
+    public function remove_tax( $tax ) {
3654 3654
         $taxes = $this->get_taxes();
3655 3655
         if ( isset( $taxes[ $tax ] ) ) {
3656 3656
             unset( $taxes[ $tax ] );
@@ -3659,193 +3659,193 @@  discard block
 block discarded – undo
3659 3659
     }
3660 3660
 
3661 3661
     /**
3662
-	 * Recalculates the invoice subtotal.
3663
-	 *
3664
-	 * @since 1.0.19
3665
-	 * @return float The recalculated subtotal
3666
-	 */
3667
-	public function recalculate_subtotal() {
3662
+     * Recalculates the invoice subtotal.
3663
+     *
3664
+     * @since 1.0.19
3665
+     * @return float The recalculated subtotal
3666
+     */
3667
+    public function recalculate_subtotal() {
3668 3668
         $items     = $this->get_items();
3669
-		$subtotal  = 0;
3670
-		$recurring = 0;
3669
+        $subtotal  = 0;
3670
+        $recurring = 0;
3671 3671
 
3672 3672
         foreach ( $items as $item ) {
3673
-			$subtotal  += $item->get_sub_total( 'edit' );
3674
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3673
+            $subtotal  += $item->get_sub_total( 'edit' );
3674
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3675 3675
         }
3676 3676
 
3677
-		if ( wpinv_prices_include_tax() ) {
3678
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3679
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3680
-		}
3677
+        if ( wpinv_prices_include_tax() ) {
3678
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3679
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3680
+        }
3681 3681
 
3682
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3683
-		$this->set_subtotal( $current );
3682
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3683
+        $this->set_subtotal( $current );
3684 3684
 
3685
-		$this->totals['subtotal'] = array(
3686
-			'initial'   => $subtotal,
3687
-			'recurring' => $recurring,
3688
-		);
3685
+        $this->totals['subtotal'] = array(
3686
+            'initial'   => $subtotal,
3687
+            'recurring' => $recurring,
3688
+        );
3689 3689
 
3690 3690
         return $current;
3691 3691
     }
3692 3692
 
3693 3693
     /**
3694
-	 * Recalculates the invoice discount total.
3695
-	 *
3696
-	 * @since 1.0.19
3697
-	 * @return float The recalculated discount
3698
-	 */
3699
-	public function recalculate_total_discount() {
3700
-		// Fix renewal invoice amount when tax + recurring discount applied.
3701
-		if ( $this->is_renewal() && $this->get_discount_code() ) {
3702
-			// Maybe recalculate discount (Pre-GetPaid Fix).
3703
-			$discount = new WPInv_Discount( $this->get_discount_code() );
3704
-
3705
-			if ( $discount->exists() && $discount->is_recurring() ) {
3706
-				getpaid_calculate_invoice_discount( $this, $discount );
3707
-			}
3708
-		}
3694
+     * Recalculates the invoice discount total.
3695
+     *
3696
+     * @since 1.0.19
3697
+     * @return float The recalculated discount
3698
+     */
3699
+    public function recalculate_total_discount() {
3700
+        // Fix renewal invoice amount when tax + recurring discount applied.
3701
+        if ( $this->is_renewal() && $this->get_discount_code() ) {
3702
+            // Maybe recalculate discount (Pre-GetPaid Fix).
3703
+            $discount = new WPInv_Discount( $this->get_discount_code() );
3704
+
3705
+            if ( $discount->exists() && $discount->is_recurring() ) {
3706
+                getpaid_calculate_invoice_discount( $this, $discount );
3707
+            }
3708
+        }
3709 3709
 
3710
-		$discounts = $this->get_discounts();
3711
-		$discount  = 0;
3712
-		$recurring = 0;
3710
+        $discounts = $this->get_discounts();
3711
+        $discount  = 0;
3712
+        $recurring = 0;
3713 3713
 
3714 3714
         foreach ( $discounts as $data ) {
3715
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3716
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3717
-		}
3715
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3716
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3717
+        }
3718 3718
 
3719
-		$current = $this->is_renewal() ? $recurring : $discount;
3719
+        $current = $this->is_renewal() ? $recurring : $discount;
3720 3720
 
3721
-		$this->set_total_discount( $current );
3721
+        $this->set_total_discount( $current );
3722 3722
 
3723
-		$this->totals['discount'] = array(
3724
-			'initial'   => $discount,
3725
-			'recurring' => $recurring,
3726
-		);
3723
+        $this->totals['discount'] = array(
3724
+            'initial'   => $discount,
3725
+            'recurring' => $recurring,
3726
+        );
3727 3727
 
3728
-		return $current;
3728
+        return $current;
3729 3729
 
3730 3730
     }
3731 3731
 
3732 3732
     /**
3733
-	 * Recalculates the invoice tax total.
3734
-	 *
3735
-	 * @since 1.0.19
3736
-	 * @return float The recalculated tax
3737
-	 */
3738
-	public function recalculate_total_tax() {
3733
+     * Recalculates the invoice tax total.
3734
+     *
3735
+     * @since 1.0.19
3736
+     * @return float The recalculated tax
3737
+     */
3738
+    public function recalculate_total_tax() {
3739 3739
 
3740
-		// Maybe disable taxes.
3741
-		$vat_number = $this->get_vat_number();
3742
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3740
+        // Maybe disable taxes.
3741
+        $vat_number = $this->get_vat_number();
3742
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3743 3743
 
3744
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3745
-			$skip_tax = false;
3746
-		}
3744
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3745
+            $skip_tax = false;
3746
+        }
3747 3747
 
3748
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3748
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3749 3749
 
3750
-			$this->totals['tax'] = array(
3751
-				'initial'   => 0,
3752
-				'recurring' => 0,
3753
-			);
3750
+            $this->totals['tax'] = array(
3751
+                'initial'   => 0,
3752
+                'recurring' => 0,
3753
+            );
3754 3754
 
3755
-			$this->tax_rate = 0;
3755
+            $this->tax_rate = 0;
3756 3756
 
3757
-			$this->set_taxes( array() );
3758
-			$current = 0;
3759
-		} else {
3757
+            $this->set_taxes( array() );
3758
+            $current = 0;
3759
+        } else {
3760 3760
 
3761
-			$item_taxes = array();
3761
+            $item_taxes = array();
3762 3762
 
3763
-			foreach ( $this->get_items() as $item ) {
3764
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3765
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3766
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3767
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3768
-				foreach ( $taxes as $name => $amount ) {
3769
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3770
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3763
+            foreach ( $this->get_items() as $item ) {
3764
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3765
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3766
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3767
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3768
+                foreach ( $taxes as $name => $amount ) {
3769
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3770
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3771 3771
 
3772
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3773
-						$item_taxes[ $name ] = $tax;
3774
-						continue;
3775
-					}
3772
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3773
+                        $item_taxes[ $name ] = $tax;
3774
+                        continue;
3775
+                    }
3776 3776
 
3777
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3778
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3777
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3778
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3779 3779
 
3780
-				}
3781
-			}
3780
+                }
3781
+            }
3782 3782
 
3783
-			$this->set_taxes( $item_taxes );
3783
+            $this->set_taxes( $item_taxes );
3784 3784
 
3785
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3786
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3785
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3786
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3787 3787
 
3788
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3788
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3789 3789
 
3790
-			$this->totals['tax'] = array(
3791
-				'initial'   => $initial_tax,
3792
-				'recurring' => $recurring_tax,
3793
-			);
3790
+            $this->totals['tax'] = array(
3791
+                'initial'   => $initial_tax,
3792
+                'recurring' => $recurring_tax,
3793
+            );
3794 3794
 
3795
-		}
3795
+        }
3796 3796
 
3797
-		$this->set_total_tax( $current );
3797
+        $this->set_total_tax( $current );
3798 3798
 
3799
-		return $current;
3799
+        return $current;
3800 3800
 
3801 3801
     }
3802 3802
 
3803 3803
     /**
3804
-	 * Recalculates the invoice fees total.
3805
-	 *
3806
-	 * @since 1.0.19
3807
-	 * @return float The recalculated fee
3808
-	 */
3809
-	public function recalculate_total_fees() {
3810
-		$fees      = $this->get_fees();
3811
-		$fee       = 0;
3812
-		$recurring = 0;
3804
+     * Recalculates the invoice fees total.
3805
+     *
3806
+     * @since 1.0.19
3807
+     * @return float The recalculated fee
3808
+     */
3809
+    public function recalculate_total_fees() {
3810
+        $fees      = $this->get_fees();
3811
+        $fee       = 0;
3812
+        $recurring = 0;
3813 3813
 
3814 3814
         foreach ( $fees as $data ) {
3815
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3816
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3817
-		}
3815
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3816
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3817
+        }
3818 3818
 
3819
-		$current = $this->is_renewal() ? $recurring : $fee;
3820
-		$this->set_total_fees( $current );
3819
+        $current = $this->is_renewal() ? $recurring : $fee;
3820
+        $this->set_total_fees( $current );
3821 3821
 
3822
-		$this->totals['fee'] = array(
3823
-			'initial'   => $fee,
3824
-			'recurring' => $recurring,
3825
-		);
3822
+        $this->totals['fee'] = array(
3823
+            'initial'   => $fee,
3824
+            'recurring' => $recurring,
3825
+        );
3826 3826
 
3827 3827
         $this->set_total_fees( $fee );
3828 3828
         return $current;
3829 3829
     }
3830 3830
 
3831 3831
     /**
3832
-	 * Recalculates the invoice total.
3833
-	 *
3834
-	 * @since 1.0.19
3832
+     * Recalculates the invoice total.
3833
+     *
3834
+     * @since 1.0.19
3835 3835
      * @return float The invoice total
3836
-	 */
3837
-	public function recalculate_total() {
3836
+     */
3837
+    public function recalculate_total() {
3838 3838
         $this->recalculate_total_fees();
3839 3839
         $this->recalculate_total_discount();
3840
-		$this->recalculate_total_tax();
3841
-		$this->recalculate_subtotal();
3842
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3843
-		return $this->get_total();
3844
-	}
3845
-
3846
-	/**
3847
-	 * @deprecated
3848
-	 */
3840
+        $this->recalculate_total_tax();
3841
+        $this->recalculate_subtotal();
3842
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3843
+        return $this->get_total();
3844
+    }
3845
+
3846
+    /**
3847
+     * @deprecated
3848
+     */
3849 3849
     public function recalculate_totals() {
3850 3850
         $this->recalculate_total();
3851 3851
         $this->save( true );
@@ -3859,22 +3859,22 @@  discard block
 block discarded – undo
3859 3859
         return $this->get_data();
3860 3860
     }
3861 3861
 
3862
-	/**
3862
+    /**
3863 3863
      * Adds a system note to an invoice.
3864 3864
      *
3865 3865
      * @param string $note The note being added.
3866
-	 * @return int|false The new note's ID on success, false on failure.
3866
+     * @return int|false The new note's ID on success, false on failure.
3867 3867
      *
3868 3868
      */
3869 3869
     public function add_system_note( $note ) {
3870
-		return $this->add_note( $note, false, false, true );
3871
-	}
3870
+        return $this->add_note( $note, false, false, true );
3871
+    }
3872 3872
 
3873 3873
     /**
3874 3874
      * Adds a note to an invoice.
3875 3875
      *
3876 3876
      * @param string $note The note being added.
3877
-	 * @return int|false The new note's ID on success, false on failure.
3877
+     * @return int|false The new note's ID on success, false on failure.
3878 3878
      *
3879 3879
      */
3880 3880
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3884,21 +3884,21 @@  discard block
 block discarded – undo
3884 3884
             return false;
3885 3885
         }
3886 3886
 
3887
-		$author       = 'System';
3888
-		$author_email = '[email protected]';
3887
+        $author       = 'System';
3888
+        $author_email = '[email protected]';
3889 3889
 
3890
-		// If this is an admin comment or it has been added by the user.
3891
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3892
-			$user         = get_user_by( 'id', get_current_user_id() );
3890
+        // If this is an admin comment or it has been added by the user.
3891
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3892
+            $user         = get_user_by( 'id', get_current_user_id() );
3893 3893
             $author       = $user->display_name;
3894 3894
             $author_email = $user->user_email;
3895
-		}
3895
+        }
3896 3896
 
3897
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3897
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3898 3898
 
3899
-	}
3899
+    }
3900 3900
 
3901
-	/**
3901
+    /**
3902 3902
      * Generates a unique key for the invoice.
3903 3903
      */
3904 3904
     public function generate_key( $string = '' ) {
@@ -3918,113 +3918,113 @@  discard block
 block discarded – undo
3918 3918
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3919 3919
         }
3920 3920
 
3921
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3922
-
3923
-	}
3924
-
3925
-	/**
3926
-	 * Handle the status transition.
3927
-	 */
3928
-	protected function status_transition() {
3929
-		$status_transition = $this->status_transition;
3930
-
3931
-		// Reset status transition variable.
3932
-		$this->status_transition = false;
3933
-
3934
-		if ( $status_transition ) {
3935
-			try {
3936
-
3937
-				// Fire a hook for the status change.
3938
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3939
-
3940
-				// @deprecated this is deprecated and will be removed in the future.
3941
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3942
-
3943
-				if ( ! empty( $status_transition['from'] ) ) {
3944
-
3945
-					/* translators: 1: old invoice status 2: new invoice status */
3946
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3947
-
3948
-					// Fire another hook.
3949
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3950
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3921
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3951 3922
 
3952
-					// @deprecated this is deprecated and will be removed in the future.
3953
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3954
-
3955
-					// Note the transition occurred.
3956
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3957
-
3958
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3959
-					if (
3960
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3961
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3962
-					) {
3963
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3964
-					}
3965
-
3966
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3967
-					if (
3968
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3969
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3970
-					) {
3971
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3972
-					}
3973
-				} else {
3974
-					/* translators: %s: new invoice status */
3975
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3976
-
3977
-					// Note the transition occurred.
3978
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3923
+    }
3979 3924
 
3980
-				}
3981
-			} catch ( Exception $e ) {
3982
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3983
-			}
3984
-		}
3985
-	}
3925
+    /**
3926
+     * Handle the status transition.
3927
+     */
3928
+    protected function status_transition() {
3929
+        $status_transition = $this->status_transition;
3930
+
3931
+        // Reset status transition variable.
3932
+        $this->status_transition = false;
3933
+
3934
+        if ( $status_transition ) {
3935
+            try {
3936
+
3937
+                // Fire a hook for the status change.
3938
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3939
+
3940
+                // @deprecated this is deprecated and will be removed in the future.
3941
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3942
+
3943
+                if ( ! empty( $status_transition['from'] ) ) {
3944
+
3945
+                    /* translators: 1: old invoice status 2: new invoice status */
3946
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3947
+
3948
+                    // Fire another hook.
3949
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3950
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3951
+
3952
+                    // @deprecated this is deprecated and will be removed in the future.
3953
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3954
+
3955
+                    // Note the transition occurred.
3956
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3957
+
3958
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3959
+                    if (
3960
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3961
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3962
+                    ) {
3963
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3964
+                    }
3965
+
3966
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3967
+                    if (
3968
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3969
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3970
+                    ) {
3971
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3972
+                    }
3973
+                } else {
3974
+                    /* translators: %s: new invoice status */
3975
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3976
+
3977
+                    // Note the transition occurred.
3978
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3979
+
3980
+                }
3981
+            } catch ( Exception $e ) {
3982
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3983
+            }
3984
+        }
3985
+    }
3986 3986
 
3987
-	/**
3988
-	 * Updates an invoice status.
3989
-	 */
3990
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3987
+    /**
3988
+     * Updates an invoice status.
3989
+     */
3990
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3991 3991
 
3992
-		// Fires before updating a status.
3993
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3992
+        // Fires before updating a status.
3993
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3994 3994
 
3995
-		// Update the status.
3996
-		$this->set_status( $new_status, $note, $manual );
3995
+        // Update the status.
3996
+        $this->set_status( $new_status, $note, $manual );
3997 3997
 
3998
-		// Save the order.
3999
-		return $this->save();
3998
+        // Save the order.
3999
+        return $this->save();
4000 4000
 
4001
-	}
4001
+    }
4002 4002
 
4003
-	/**
4004
-	 * @deprecated
4005
-	 */
4006
-	public function refresh_item_ids() {
4003
+    /**
4004
+     * @deprecated
4005
+     */
4006
+    public function refresh_item_ids() {
4007 4007
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
4008 4008
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
4009
-	}
4009
+    }
4010 4010
 
4011
-	/**
4012
-	 * @deprecated
4013
-	 */
4014
-	public function update_items( $temp = false ) {
4011
+    /**
4012
+     * @deprecated
4013
+     */
4014
+    public function update_items( $temp = false ) {
4015 4015
 
4016
-		$this->set_items( $this->get_items() );
4016
+        $this->set_items( $this->get_items() );
4017 4017
 
4018
-		if ( ! $temp ) {
4019
-			$this->save();
4020
-		}
4018
+        if ( ! $temp ) {
4019
+            $this->save();
4020
+        }
4021 4021
 
4022 4022
         return $this;
4023
-	}
4023
+    }
4024 4024
 
4025
-	/**
4026
-	 * @deprecated
4027
-	 */
4025
+    /**
4026
+     * @deprecated
4027
+     */
4028 4028
     public function validate_discount() {
4029 4029
 
4030 4030
         $discount_code = $this->get_discount_code();
@@ -4040,101 +4040,101 @@  discard block
 block discarded – undo
4040 4040
 
4041 4041
     }
4042 4042
 
4043
-	/**
4044
-	 * Refunds an invoice.
4045
-	 */
4043
+    /**
4044
+     * Refunds an invoice.
4045
+     */
4046 4046
     public function refund() {
4047
-		$this->set_status( 'wpi-refunded' );
4047
+        $this->set_status( 'wpi-refunded' );
4048 4048
         $this->save();
4049
-	}
4049
+    }
4050 4050
 
4051
-	/**
4052
-	 * Marks an invoice as paid.
4053
-	 *
4054
-	 * @param string $transaction_id
4055
-	 */
4051
+    /**
4052
+     * Marks an invoice as paid.
4053
+     *
4054
+     * @param string $transaction_id
4055
+     */
4056 4056
     public function mark_paid( $transaction_id = null, $note = '' ) {
4057 4057
 
4058
-		// Set the transaction id.
4059
-		if ( empty( $transaction_id ) ) {
4060
-			$transaction_id = $this->generate_key( 'trans_' );
4061
-		}
4058
+        // Set the transaction id.
4059
+        if ( empty( $transaction_id ) ) {
4060
+            $transaction_id = $this->generate_key( 'trans_' );
4061
+        }
4062 4062
 
4063
-		if ( ! $this->get_transaction_id() ) {
4064
-			$this->set_transaction_id( $transaction_id );
4065
-		}
4063
+        if ( ! $this->get_transaction_id() ) {
4064
+            $this->set_transaction_id( $transaction_id );
4065
+        }
4066 4066
 
4067
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4068
-			return $this->save();
4069
-		}
4067
+        if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4068
+            return $this->save();
4069
+        }
4070 4070
 
4071
-		// Set the completed date.
4072
-		$this->set_date_completed( current_time( 'mysql' ) );
4071
+        // Set the completed date.
4072
+        $this->set_date_completed( current_time( 'mysql' ) );
4073 4073
 
4074
-		// Set the new status.
4075
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
4076
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
4074
+        // Set the new status.
4075
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
4076
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
4077 4077
 
4078
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4079
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4078
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4079
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
4080 4080
 
4081
-			if ( 'none' == $this->get_gateway() ) {
4082
-				$_note = $note;
4083
-			}
4081
+            if ( 'none' == $this->get_gateway() ) {
4082
+                $_note = $note;
4083
+            }
4084 4084
 
4085
-			$this->set_status( 'wpi-renewal', $_note );
4085
+            $this->set_status( 'wpi-renewal', $_note );
4086 4086
 
4087
-		} else {
4087
+        } else {
4088 4088
 
4089
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4090
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4089
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4090
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
4091 4091
 
4092
-			if ( 'none' == $this->get_gateway() ) {
4093
-				$_note = $note;
4094
-			}
4092
+            if ( 'none' == $this->get_gateway() ) {
4093
+                $_note = $note;
4094
+            }
4095 4095
 
4096
-			$this->set_status( 'publish', $_note );
4096
+            $this->set_status( 'publish', $_note );
4097 4097
 
4098
-		}
4098
+        }
4099 4099
 
4100
-		// Set checkout mode.
4101
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4102
-		$this->set_mode( $mode );
4100
+        // Set checkout mode.
4101
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4102
+        $this->set_mode( $mode );
4103 4103
 
4104
-		// Save the invoice.
4104
+        // Save the invoice.
4105 4105
         $this->save();
4106
-	}
4107
-
4108
-	/**
4109
-	 * Save data to the database.
4110
-	 *
4111
-	 * @since 1.0.19
4112
-	 * @return int invoice ID
4113
-	 */
4114
-	public function save() {
4115
-		$this->maybe_set_date_paid();
4116
-		$this->maybe_set_key();
4117
-		parent::save();
4118
-		$this->clear_cache();
4119
-		$this->status_transition();
4120
-		return $this->get_id();
4121
-	}
4122
-
4123
-	/**
4106
+    }
4107
+
4108
+    /**
4109
+     * Save data to the database.
4110
+     *
4111
+     * @since 1.0.19
4112
+     * @return int invoice ID
4113
+     */
4114
+    public function save() {
4115
+        $this->maybe_set_date_paid();
4116
+        $this->maybe_set_key();
4117
+        parent::save();
4118
+        $this->clear_cache();
4119
+        $this->status_transition();
4120
+        return $this->get_id();
4121
+    }
4122
+
4123
+    /**
4124 4124
      * Clears the subscription's cache.
4125 4125
      */
4126 4126
     public function clear_cache() {
4127
-		if ( $this->get_key() ) {
4128
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4129
-		}
4130
-
4131
-		if ( $this->get_number() ) {
4132
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4133
-		}
4134
-
4135
-		if ( $this->get_transaction_id() ) {
4136
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4137
-		}
4138
-	}
4127
+        if ( $this->get_key() ) {
4128
+            wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4129
+        }
4130
+
4131
+        if ( $this->get_number() ) {
4132
+            wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4133
+        }
4134
+
4135
+        if ( $this->get_transaction_id() ) {
4136
+            wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4137
+        }
4138
+    }
4139 4139
 
4140 4140
 }
Please login to merge, or discard this patch.
Spacing   +850 added lines, -850 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -146,39 +146,39 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
148 148
 	 */
149
-    public function __construct( $invoice = 0 ) {
149
+    public function __construct($invoice = 0) {
150 150
 
151
-        parent::__construct( $invoice );
151
+        parent::__construct($invoice);
152 152
 
153
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
154
-			$this->set_id( (int) $invoice );
155
-		} elseif ( $invoice instanceof self ) {
156
-			$this->set_id( $invoice->get_id() );
157
-		} elseif ( ! empty( $invoice->ID ) ) {
158
-			$this->set_id( $invoice->ID );
159
-		} elseif ( is_array( $invoice ) ) {
160
-			$this->set_props( $invoice );
153
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
154
+			$this->set_id((int) $invoice);
155
+		} elseif ($invoice instanceof self) {
156
+			$this->set_id($invoice->get_id());
157
+		} elseif (!empty($invoice->ID)) {
158
+			$this->set_id($invoice->ID);
159
+		} elseif (is_array($invoice)) {
160
+			$this->set_props($invoice);
161 161
 
162
-			if ( isset( $invoice['ID'] ) ) {
163
-				$this->set_id( $invoice['ID'] );
162
+			if (isset($invoice['ID'])) {
163
+				$this->set_id($invoice['ID']);
164 164
 			}
165
-} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
165
+} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
166
+			$this->set_id($invoice_id);
167
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
168
+			$this->set_id($invoice_id);
169
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
170
+			$this->set_id($invoice_id);
171 171
 		} else {
172
-			$this->set_object_read( true );
172
+			$this->set_object_read(true);
173 173
 		}
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
177 177
 
178
-		if ( $this->get_id() > 0 ) {
179
-            $this->post = get_post( $this->get_id() );
178
+		if ($this->get_id() > 0) {
179
+            $this->post = get_post($this->get_id());
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+			$this->data_store->read($this);
182 182
         }
183 183
 
184 184
     }
@@ -193,39 +193,39 @@  discard block
 block discarded – undo
193 193
 	 * @since 1.0.15
194 194
 	 * @return int
195 195
 	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196
+	public static function get_invoice_id_by_field($value, $field = 'key') {
197 197
         global $wpdb;
198 198
 
199 199
 		// Trim the value.
200
-		$value = trim( $value );
200
+		$value = trim($value);
201 201
 
202
-		if ( empty( $value ) ) {
202
+		if (empty($value)) {
203 203
 			return 0;
204 204
 		}
205 205
 
206 206
         // Valid fields.
207
-        $fields = array( 'key', 'number', 'transaction_id' );
207
+        $fields = array('key', 'number', 'transaction_id');
208 208
 
209 209
 		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+		if (empty($field) || !in_array($field, $fields)) {
211 211
 			return 0;
212 212
 		}
213 213
 
214 214
 		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
215
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
216
+		if (false !== $invoice_id) {
217 217
 			return $invoice_id;
218 218
 		}
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
222
-		$db_field    = 'key' === $field ? 'invoice_key' : $field;
222
+		$db_field = 'key' === $field ? 'invoice_key' : $field;
223 223
         $invoice_id  = (int) $wpdb->get_var(
224
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value )
224
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$db_field`=%s LIMIT 1", $value)
225 225
         );
226 226
 
227 227
 		// Update the cache with our data
228
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
228
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
229 229
 
230 230
 		return $invoice_id;
231 231
     }
@@ -233,8 +233,8 @@  discard block
 block discarded – undo
233 233
     /**
234 234
      * Checks if an invoice key is set.
235 235
      */
236
-    public function _isset( $key ) {
237
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
236
+    public function _isset($key) {
237
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
238 238
     }
239 239
 
240 240
     /*
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return int
261 261
 	 */
262
-	public function get_parent_id( $context = 'view' ) {
263
-		return (int) $this->get_prop( 'parent_id', $context );
262
+	public function get_parent_id($context = 'view') {
263
+		return (int) $this->get_prop('parent_id', $context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return WPInv_Invoice
271 271
 	 */
272 272
     public function get_parent_payment() {
273
-        return new WPInv_Invoice( $this->get_parent_id() );
273
+        return new WPInv_Invoice($this->get_parent_id());
274 274
     }
275 275
 
276 276
     /**
@@ -290,8 +290,8 @@  discard block
 block discarded – undo
290 290
 	 * @param  string $context View or edit context.
291 291
 	 * @return string
292 292
 	 */
293
-	public function get_status( $context = 'view' ) {
294
-		return $this->get_prop( 'status', $context );
293
+	public function get_status($context = 'view') {
294
+		return $this->get_prop('status', $context);
295 295
 	}
296 296
 
297 297
 	/**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	 * @return array
302 302
 	 */
303 303
 	public function get_all_statuses() {
304
-		return wpinv_get_invoice_statuses( true, true, $this );
304
+		return wpinv_get_invoice_statuses(true, true, $this);
305 305
     }
306 306
 
307 307
     /**
@@ -313,9 +313,9 @@  discard block
 block discarded – undo
313 313
     public function get_status_nicename() {
314 314
 		$statuses = $this->get_all_statuses();
315 315
 
316
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
317 317
 
318
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
318
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
319 319
     }
320 320
 
321 321
 	/**
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function get_status_class() {
328 328
 		$statuses = getpaid_get_invoice_status_classes();
329
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark text-white';
329
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark text-white';
330 330
 	}
331 331
 
332 332
 	/**
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
      */
338 338
     public function get_status_label_html() {
339 339
 
340
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
341
-		$status       = sanitize_html_class( $this->get_status() );
342
-		$class        = esc_attr( $this->get_status_class() );
340
+		$status_label = sanitize_text_field($this->get_status_nicename());
341
+		$status       = sanitize_html_class($this->get_status());
342
+		$class        = esc_attr($this->get_status_class());
343 343
 
344 344
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
345 345
 	}
@@ -351,23 +351,23 @@  discard block
 block discarded – undo
351 351
 	 * @param  string $context View or edit context.
352 352
 	 * @return string
353 353
 	 */
354
-	public function get_version( $context = 'view' ) {
355
-		return $this->get_prop( 'version', $context );
354
+	public function get_version($context = 'view') {
355
+		return $this->get_prop('version', $context);
356 356
 	}
357 357
 
358 358
 	/**
359 359
 	 * @deprecated
360 360
 	 */
361
-	public function get_invoice_date( $format = true ) {
362
-		$date      = getpaid_format_date( $this->get_date_completed() );
363
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
364
-		$formatted = getpaid_format_date( $date );
361
+	public function get_invoice_date($format = true) {
362
+		$date      = getpaid_format_date($this->get_date_completed());
363
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
364
+		$formatted = getpaid_format_date($date);
365 365
 
366
-		if ( $format ) {
366
+		if ($format) {
367 367
 			return $formatted;
368 368
 		}
369 369
 
370
-		return empty( $formatted ) ? '' : $date;
370
+		return empty($formatted) ? '' : $date;
371 371
 
372 372
     }
373 373
 
@@ -378,8 +378,8 @@  discard block
 block discarded – undo
378 378
 	 * @param  string $context View or edit context.
379 379
 	 * @return string
380 380
 	 */
381
-	public function get_date_created( $context = 'view' ) {
382
-		return $this->get_prop( 'date_created', $context );
381
+	public function get_date_created($context = 'view') {
382
+		return $this->get_prop('date_created', $context);
383 383
 	}
384 384
 
385 385
 	/**
@@ -389,8 +389,8 @@  discard block
 block discarded – undo
389 389
 	 * @param  string $context View or edit context.
390 390
 	 * @return string
391 391
 	 */
392
-	public function get_created_date( $context = 'view' ) {
393
-		return $this->get_date_created( $context );
392
+	public function get_created_date($context = 'view') {
393
+		return $this->get_date_created($context);
394 394
     }
395 395
 
396 396
     /**
@@ -400,11 +400,11 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_created_gmt( $context = 'view' ) {
404
-        $date = $this->get_date_created( $context );
403
+	public function get_date_created_gmt($context = 'view') {
404
+        $date = $this->get_date_created($context);
405 405
 
406
-        if ( $date ) {
407
-            $date = get_gmt_from_date( $date );
406
+        if ($date) {
407
+            $date = get_gmt_from_date($date);
408 408
         }
409 409
 		return $date;
410 410
     }
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param  string $context View or edit context.
417 417
 	 * @return string
418 418
 	 */
419
-	public function get_date_modified( $context = 'view' ) {
420
-		return $this->get_prop( 'date_modified', $context );
419
+	public function get_date_modified($context = 'view') {
420
+		return $this->get_prop('date_modified', $context);
421 421
 	}
422 422
 
423 423
 	/**
@@ -427,8 +427,8 @@  discard block
 block discarded – undo
427 427
 	 * @param  string $context View or edit context.
428 428
 	 * @return string
429 429
 	 */
430
-	public function get_modified_date( $context = 'view' ) {
431
-		return $this->get_date_modified( $context );
430
+	public function get_modified_date($context = 'view') {
431
+		return $this->get_date_modified($context);
432 432
     }
433 433
 
434 434
     /**
@@ -438,11 +438,11 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return string
440 440
 	 */
441
-	public function get_date_modified_gmt( $context = 'view' ) {
442
-        $date = $this->get_date_modified( $context );
441
+	public function get_date_modified_gmt($context = 'view') {
442
+        $date = $this->get_date_modified($context);
443 443
 
444
-        if ( $date ) {
445
-            $date = get_gmt_from_date( $date );
444
+        if ($date) {
445
+            $date = get_gmt_from_date($date);
446 446
         }
447 447
 		return $date;
448 448
     }
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param  string $context View or edit context.
455 455
 	 * @return string
456 456
 	 */
457
-	public function get_due_date( $context = 'view' ) {
458
-		return $this->get_prop( 'due_date', $context );
457
+	public function get_due_date($context = 'view') {
458
+		return $this->get_prop('due_date', $context);
459 459
     }
460 460
 
461 461
     /**
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
 	 * @param  string $context View or edit context.
466 466
 	 * @return string
467 467
 	 */
468
-	public function get_date_due( $context = 'view' ) {
469
-		return $this->get_due_date( $context );
468
+	public function get_date_due($context = 'view') {
469
+		return $this->get_due_date($context);
470 470
     }
471 471
 
472 472
     /**
@@ -476,11 +476,11 @@  discard block
 block discarded – undo
476 476
 	 * @param  string $context View or edit context.
477 477
 	 * @return string
478 478
 	 */
479
-	public function get_due_date_gmt( $context = 'view' ) {
480
-        $date = $this->get_due_date( $context );
479
+	public function get_due_date_gmt($context = 'view') {
480
+        $date = $this->get_due_date($context);
481 481
 
482
-        if ( $date ) {
483
-            $date = get_gmt_from_date( $date );
482
+        if ($date) {
483
+            $date = get_gmt_from_date($date);
484 484
         }
485 485
 		return $date;
486 486
     }
@@ -492,8 +492,8 @@  discard block
 block discarded – undo
492 492
 	 * @param  string $context View or edit context.
493 493
 	 * @return string
494 494
 	 */
495
-	public function get_gmt_date_due( $context = 'view' ) {
496
-		return $this->get_due_date_gmt( $context );
495
+	public function get_gmt_date_due($context = 'view') {
496
+		return $this->get_due_date_gmt($context);
497 497
     }
498 498
 
499 499
     /**
@@ -503,8 +503,8 @@  discard block
 block discarded – undo
503 503
 	 * @param  string $context View or edit context.
504 504
 	 * @return string
505 505
 	 */
506
-	public function get_completed_date( $context = 'view' ) {
507
-		return $this->get_prop( 'completed_date', $context );
506
+	public function get_completed_date($context = 'view') {
507
+		return $this->get_prop('completed_date', $context);
508 508
     }
509 509
 
510 510
     /**
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 	 * @param  string $context View or edit context.
515 515
 	 * @return string
516 516
 	 */
517
-	public function get_date_completed( $context = 'view' ) {
518
-		return $this->get_completed_date( $context );
517
+	public function get_date_completed($context = 'view') {
518
+		return $this->get_completed_date($context);
519 519
     }
520 520
 
521 521
     /**
@@ -525,11 +525,11 @@  discard block
 block discarded – undo
525 525
 	 * @param  string $context View or edit context.
526 526
 	 * @return string
527 527
 	 */
528
-	public function get_completed_date_gmt( $context = 'view' ) {
529
-        $date = $this->get_completed_date( $context );
528
+	public function get_completed_date_gmt($context = 'view') {
529
+        $date = $this->get_completed_date($context);
530 530
 
531
-        if ( $date ) {
532
-            $date = get_gmt_from_date( $date );
531
+        if ($date) {
532
+            $date = get_gmt_from_date($date);
533 533
         }
534 534
 		return $date;
535 535
     }
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
 	 * @param  string $context View or edit context.
542 542
 	 * @return string
543 543
 	 */
544
-	public function get_gmt_completed_date( $context = 'view' ) {
545
-		return $this->get_completed_date_gmt( $context );
544
+	public function get_gmt_completed_date($context = 'view') {
545
+		return $this->get_completed_date_gmt($context);
546 546
     }
547 547
 
548 548
     /**
@@ -552,12 +552,12 @@  discard block
 block discarded – undo
552 552
 	 * @param  string $context View or edit context.
553 553
 	 * @return string
554 554
 	 */
555
-	public function get_number( $context = 'view' ) {
556
-		$number = $this->get_prop( 'number', $context );
555
+	public function get_number($context = 'view') {
556
+		$number = $this->get_prop('number', $context);
557 557
 
558
-		if ( empty( $number ) ) {
558
+		if (empty($number)) {
559 559
 			$number = $this->generate_number();
560
-			$this->set_number( $this->generate_number() );
560
+			$this->set_number($this->generate_number());
561 561
 		}
562 562
 
563 563
 		return $number;
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 	public function maybe_set_number() {
572 572
         $number = $this->get_number();
573 573
 
574
-        if ( empty( $number ) || $this->get_id() == $number ) {
575
-			$this->set_number( $this->generate_number() );
574
+        if (empty($number) || $this->get_id() == $number) {
575
+			$this->set_number($this->generate_number());
576 576
         }
577 577
 
578 578
 	}
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
 	 * @param  string $context View or edit context.
585 585
 	 * @return string
586 586
 	 */
587
-	public function get_key( $context = 'view' ) {
588
-        return $this->get_prop( 'key', $context );
587
+	public function get_key($context = 'view') {
588
+        return $this->get_prop('key', $context);
589 589
 	}
590 590
 
591 591
 	/**
@@ -596,9 +596,9 @@  discard block
 block discarded – undo
596 596
 	public function maybe_set_key() {
597 597
         $key = $this->get_key();
598 598
 
599
-        if ( empty( $key ) ) {
600
-            $key = $this->generate_key( $this->get_type() . '_' );
601
-            $this->set_key( $key );
599
+        if (empty($key)) {
600
+            $key = $this->generate_key($this->get_type() . '_');
601
+            $this->set_key($key);
602 602
         }
603 603
 
604 604
     }
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
 	 * @param  string $context View or edit context.
611 611
 	 * @return string
612 612
 	 */
613
-	public function get_type( $context = 'view' ) {
614
-        return $this->get_prop( 'type', $context );
613
+	public function get_type($context = 'view') {
614
+        return $this->get_prop('type', $context);
615 615
 	}
616 616
 
617 617
 	/**
@@ -621,7 +621,7 @@  discard block
 block discarded – undo
621 621
 	 * @return string
622 622
 	 */
623 623
 	public function get_invoice_quote_type() {
624
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
624
+        return getpaid_get_post_type_label($this->get_post_type(), false);
625 625
     }
626 626
 
627 627
     /**
@@ -631,8 +631,8 @@  discard block
 block discarded – undo
631 631
 	 * @param  string $context View or edit context.
632 632
 	 * @return string
633 633
 	 */
634
-	public function get_label( $context = 'view' ) {
635
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
634
+	public function get_label($context = 'view') {
635
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
636 636
 	}
637 637
 
638 638
 	/**
@@ -642,8 +642,8 @@  discard block
 block discarded – undo
642 642
 	 * @param  string $context View or edit context.
643 643
 	 * @return string
644 644
 	 */
645
-	public function get_post_type( $context = 'view' ) {
646
-        return $this->get_prop( 'post_type', $context );
645
+	public function get_post_type($context = 'view') {
646
+        return $this->get_prop('post_type', $context);
647 647
     }
648 648
 
649 649
     /**
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param  string $context View or edit context.
654 654
 	 * @return string
655 655
 	 */
656
-	public function get_mode( $context = 'view' ) {
657
-        return $this->get_prop( 'mode', $context );
656
+	public function get_mode($context = 'view') {
657
+        return $this->get_prop('mode', $context);
658 658
     }
659 659
 
660 660
     /**
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
 	 * @param  string $context View or edit context.
665 665
 	 * @return string
666 666
 	 */
667
-	public function get_path( $context = 'view' ) {
668
-        $path   = $this->get_prop( 'path', $context );
667
+	public function get_path($context = 'view') {
668
+        $path = $this->get_prop('path', $context);
669 669
 		$prefix = $this->get_type();
670 670
 
671
-		if ( 0 !== strpos( $path, $prefix ) ) {
672
-			$path = sanitize_title( $prefix . '-' . $this->get_id() );
673
-			$this->set_path( $path );
671
+		if (0 !== strpos($path, $prefix)) {
672
+			$path = sanitize_title($prefix . '-' . $this->get_id());
673
+			$this->set_path($path);
674 674
 		}
675 675
 
676 676
 		return $path;
@@ -683,8 +683,8 @@  discard block
 block discarded – undo
683 683
 	 * @param  string $context View or edit context.
684 684
 	 * @return string
685 685
 	 */
686
-	public function get_name( $context = 'view' ) {
687
-        return $this->get_prop( 'title', $context );
686
+	public function get_name($context = 'view') {
687
+        return $this->get_prop('title', $context);
688 688
     }
689 689
 
690 690
     /**
@@ -694,8 +694,8 @@  discard block
 block discarded – undo
694 694
 	 * @param  string $context View or edit context.
695 695
 	 * @return string
696 696
 	 */
697
-	public function get_title( $context = 'view' ) {
698
-		return $this->get_name( $context );
697
+	public function get_title($context = 'view') {
698
+		return $this->get_name($context);
699 699
     }
700 700
 
701 701
     /**
@@ -705,8 +705,8 @@  discard block
 block discarded – undo
705 705
 	 * @param  string $context View or edit context.
706 706
 	 * @return string
707 707
 	 */
708
-	public function get_description( $context = 'view' ) {
709
-		return $this->get_prop( 'description', $context );
708
+	public function get_description($context = 'view') {
709
+		return $this->get_prop('description', $context);
710 710
     }
711 711
 
712 712
     /**
@@ -716,8 +716,8 @@  discard block
 block discarded – undo
716 716
 	 * @param  string $context View or edit context.
717 717
 	 * @return string
718 718
 	 */
719
-	public function get_excerpt( $context = 'view' ) {
720
-		return $this->get_description( $context );
719
+	public function get_excerpt($context = 'view') {
720
+		return $this->get_description($context);
721 721
     }
722 722
 
723 723
     /**
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * @param  string $context View or edit context.
728 728
 	 * @return string
729 729
 	 */
730
-	public function get_summary( $context = 'view' ) {
731
-		return $this->get_description( $context );
730
+	public function get_summary($context = 'view') {
731
+		return $this->get_description($context);
732 732
     }
733 733
 
734 734
     /**
@@ -738,26 +738,26 @@  discard block
 block discarded – undo
738 738
      * @param  string $context View or edit context.
739 739
 	 * @return array
740 740
 	 */
741
-    public function get_user_info( $context = 'view' ) {
741
+    public function get_user_info($context = 'view') {
742 742
 
743 743
         $user_info = array(
744
-            'user_id'    => $this->get_user_id( $context ),
745
-            'email'      => $this->get_email( $context ),
746
-            'first_name' => $this->get_first_name( $context ),
747
-            'last_name'  => $this->get_last_name( $context ),
748
-            'address'    => $this->get_address( $context ),
749
-            'phone'      => $this->get_phone( $context ),
750
-            'city'       => $this->get_city( $context ),
751
-            'country'    => $this->get_country( $context ),
752
-            'state'      => $this->get_state( $context ),
753
-            'zip'        => $this->get_zip( $context ),
754
-            'company'    => $this->get_company( $context ),
755
-			'company_id' => $this->get_company_id( $context ),
756
-            'vat_number' => $this->get_vat_number( $context ),
757
-            'discount'   => $this->get_discount_code( $context ),
744
+            'user_id'    => $this->get_user_id($context),
745
+            'email'      => $this->get_email($context),
746
+            'first_name' => $this->get_first_name($context),
747
+            'last_name'  => $this->get_last_name($context),
748
+            'address'    => $this->get_address($context),
749
+            'phone'      => $this->get_phone($context),
750
+            'city'       => $this->get_city($context),
751
+            'country'    => $this->get_country($context),
752
+            'state'      => $this->get_state($context),
753
+            'zip'        => $this->get_zip($context),
754
+            'company'    => $this->get_company($context),
755
+			'company_id' => $this->get_company_id($context),
756
+            'vat_number' => $this->get_vat_number($context),
757
+            'discount'   => $this->get_discount_code($context),
758 758
 		);
759 759
 
760
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
760
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
761 761
 
762 762
     }
763 763
 
@@ -768,8 +768,8 @@  discard block
 block discarded – undo
768 768
 	 * @param  string $context View or edit context.
769 769
 	 * @return int
770 770
 	 */
771
-	public function get_author( $context = 'view' ) {
772
-		return (int) $this->get_prop( 'author', $context );
771
+	public function get_author($context = 'view') {
772
+		return (int) $this->get_prop('author', $context);
773 773
     }
774 774
 
775 775
     /**
@@ -779,8 +779,8 @@  discard block
 block discarded – undo
779 779
 	 * @param  string $context View or edit context.
780 780
 	 * @return int
781 781
 	 */
782
-	public function get_user_id( $context = 'view' ) {
783
-		return $this->get_author( $context );
782
+	public function get_user_id($context = 'view') {
783
+		return $this->get_author($context);
784 784
     }
785 785
 
786 786
      /**
@@ -790,8 +790,8 @@  discard block
 block discarded – undo
790 790
 	 * @param  string $context View or edit context.
791 791
 	 * @return int
792 792
 	 */
793
-	public function get_customer_id( $context = 'view' ) {
794
-		return (int) $this->get_prop( 'customer_id', $context );
793
+	public function get_customer_id($context = 'view') {
794
+		return (int) $this->get_prop('customer_id', $context);
795 795
     }
796 796
 
797 797
     /**
@@ -801,8 +801,8 @@  discard block
 block discarded – undo
801 801
 	 * @param  string $context View or edit context.
802 802
 	 * @return string
803 803
 	 */
804
-	public function get_ip( $context = 'view' ) {
805
-		return $this->get_prop( 'user_ip', $context );
804
+	public function get_ip($context = 'view') {
805
+		return $this->get_prop('user_ip', $context);
806 806
     }
807 807
 
808 808
     /**
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 	 * @param  string $context View or edit context.
813 813
 	 * @return string
814 814
 	 */
815
-	public function get_user_ip( $context = 'view' ) {
816
-		return $this->get_ip( $context );
815
+	public function get_user_ip($context = 'view') {
816
+		return $this->get_ip($context);
817 817
     }
818 818
 
819 819
      /**
@@ -823,8 +823,8 @@  discard block
 block discarded – undo
823 823
 	 * @param  string $context View or edit context.
824 824
 	 * @return string
825 825
 	 */
826
-	public function get_customer_ip( $context = 'view' ) {
827
-		return $this->get_ip( $context );
826
+	public function get_customer_ip($context = 'view') {
827
+		return $this->get_ip($context);
828 828
     }
829 829
 
830 830
     /**
@@ -834,8 +834,8 @@  discard block
 block discarded – undo
834 834
 	 * @param  string $context View or edit context.
835 835
 	 * @return string
836 836
 	 */
837
-	public function get_first_name( $context = 'view' ) {
838
-		return $this->get_prop( 'first_name', $context );
837
+	public function get_first_name($context = 'view') {
838
+		return $this->get_prop('first_name', $context);
839 839
     }
840 840
 
841 841
     /**
@@ -845,8 +845,8 @@  discard block
 block discarded – undo
845 845
 	 * @param  string $context View or edit context.
846 846
 	 * @return string
847 847
 	 */
848
-	public function get_user_first_name( $context = 'view' ) {
849
-		return $this->get_first_name( $context );
848
+	public function get_user_first_name($context = 'view') {
849
+		return $this->get_first_name($context);
850 850
     }
851 851
 
852 852
      /**
@@ -856,8 +856,8 @@  discard block
 block discarded – undo
856 856
 	 * @param  string $context View or edit context.
857 857
 	 * @return string
858 858
 	 */
859
-	public function get_customer_first_name( $context = 'view' ) {
860
-		return $this->get_first_name( $context );
859
+	public function get_customer_first_name($context = 'view') {
860
+		return $this->get_first_name($context);
861 861
     }
862 862
 
863 863
     /**
@@ -867,8 +867,8 @@  discard block
 block discarded – undo
867 867
 	 * @param  string $context View or edit context.
868 868
 	 * @return string
869 869
 	 */
870
-	public function get_last_name( $context = 'view' ) {
871
-		return $this->get_prop( 'last_name', $context );
870
+	public function get_last_name($context = 'view') {
871
+		return $this->get_prop('last_name', $context);
872 872
     }
873 873
 
874 874
     /**
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
 	 * @param  string $context View or edit context.
879 879
 	 * @return string
880 880
 	 */
881
-	public function get_user_last_name( $context = 'view' ) {
882
-		return $this->get_last_name( $context );
881
+	public function get_user_last_name($context = 'view') {
882
+		return $this->get_last_name($context);
883 883
     }
884 884
 
885 885
     /**
@@ -889,8 +889,8 @@  discard block
 block discarded – undo
889 889
 	 * @param  string $context View or edit context.
890 890
 	 * @return string
891 891
 	 */
892
-	public function get_customer_last_name( $context = 'view' ) {
893
-		return $this->get_last_name( $context );
892
+	public function get_customer_last_name($context = 'view') {
893
+		return $this->get_last_name($context);
894 894
     }
895 895
 
896 896
     /**
@@ -900,22 +900,22 @@  discard block
 block discarded – undo
900 900
 	 * @param  string $context View or edit context.
901 901
 	 * @return string
902 902
 	 */
903
-	public function get_full_name( $context = 'view' ) {
904
-		$name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
903
+	public function get_full_name($context = 'view') {
904
+		$name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
905 905
 
906
-		if ( ! $name ) {
907
-			$user = get_userdata( $this->get_author( $context ) );
906
+		if (!$name) {
907
+			$user = get_userdata($this->get_author($context));
908 908
 
909
-			if ( $user ) {
909
+			if ($user) {
910 910
 				$name = $user->display_name;
911 911
 			}
912 912
 		}
913 913
 
914
-		if ( ! $name ) {
915
-			$name = $this->get_email( $context );
914
+		if (!$name) {
915
+			$name = $this->get_email($context);
916 916
 		}
917 917
 
918
-		return apply_filters( 'wpinv_invoice_user_full_name', $name, $this );
918
+		return apply_filters('wpinv_invoice_user_full_name', $name, $this);
919 919
     }
920 920
 
921 921
     /**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 * @param  string $context View or edit context.
926 926
 	 * @return string
927 927
 	 */
928
-	public function get_user_full_name( $context = 'view' ) {
929
-		return $this->get_full_name( $context );
928
+	public function get_user_full_name($context = 'view') {
929
+		return $this->get_full_name($context);
930 930
     }
931 931
 
932 932
     /**
@@ -936,8 +936,8 @@  discard block
 block discarded – undo
936 936
 	 * @param  string $context View or edit context.
937 937
 	 * @return string
938 938
 	 */
939
-	public function get_customer_full_name( $context = 'view' ) {
940
-		return $this->get_full_name( $context );
939
+	public function get_customer_full_name($context = 'view') {
940
+		return $this->get_full_name($context);
941 941
     }
942 942
 
943 943
     /**
@@ -947,8 +947,8 @@  discard block
 block discarded – undo
947 947
 	 * @param  string $context View or edit context.
948 948
 	 * @return string
949 949
 	 */
950
-	public function get_phone( $context = 'view' ) {
951
-		return $this->get_prop( 'phone', $context );
950
+	public function get_phone($context = 'view') {
951
+		return $this->get_prop('phone', $context);
952 952
     }
953 953
 
954 954
     /**
@@ -958,8 +958,8 @@  discard block
 block discarded – undo
958 958
 	 * @param  string $context View or edit context.
959 959
 	 * @return string
960 960
 	 */
961
-	public function get_phone_number( $context = 'view' ) {
962
-		return $this->get_phone( $context );
961
+	public function get_phone_number($context = 'view') {
962
+		return $this->get_phone($context);
963 963
     }
964 964
 
965 965
     /**
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 	 * @param  string $context View or edit context.
970 970
 	 * @return string
971 971
 	 */
972
-	public function get_user_phone( $context = 'view' ) {
973
-		return $this->get_phone( $context );
972
+	public function get_user_phone($context = 'view') {
973
+		return $this->get_phone($context);
974 974
     }
975 975
 
976 976
     /**
@@ -980,8 +980,8 @@  discard block
 block discarded – undo
980 980
 	 * @param  string $context View or edit context.
981 981
 	 * @return string
982 982
 	 */
983
-	public function get_customer_phone( $context = 'view' ) {
984
-		return $this->get_phone( $context );
983
+	public function get_customer_phone($context = 'view') {
984
+		return $this->get_phone($context);
985 985
     }
986 986
 
987 987
     /**
@@ -991,8 +991,8 @@  discard block
 block discarded – undo
991 991
 	 * @param  string $context View or edit context.
992 992
 	 * @return string
993 993
 	 */
994
-	public function get_email( $context = 'view' ) {
995
-		return $this->get_prop( 'email', $context );
994
+	public function get_email($context = 'view') {
995
+		return $this->get_prop('email', $context);
996 996
     }
997 997
 
998 998
     /**
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 	 * @param  string $context View or edit context.
1003 1003
 	 * @return string
1004 1004
 	 */
1005
-	public function get_email_address( $context = 'view' ) {
1006
-		return $this->get_email( $context );
1005
+	public function get_email_address($context = 'view') {
1006
+		return $this->get_email($context);
1007 1007
     }
1008 1008
 
1009 1009
     /**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	 * @param  string $context View or edit context.
1014 1014
 	 * @return string
1015 1015
 	 */
1016
-	public function get_user_email( $context = 'view' ) {
1017
-		return $this->get_email( $context );
1016
+	public function get_user_email($context = 'view') {
1017
+		return $this->get_email($context);
1018 1018
     }
1019 1019
 
1020 1020
     /**
@@ -1024,8 +1024,8 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  string $context View or edit context.
1025 1025
 	 * @return string
1026 1026
 	 */
1027
-	public function get_customer_email( $context = 'view' ) {
1028
-		return $this->get_email( $context );
1027
+	public function get_customer_email($context = 'view') {
1028
+		return $this->get_email($context);
1029 1029
     }
1030 1030
 
1031 1031
     /**
@@ -1035,9 +1035,9 @@  discard block
 block discarded – undo
1035 1035
 	 * @param  string $context View or edit context.
1036 1036
 	 * @return string
1037 1037
 	 */
1038
-	public function get_country( $context = 'view' ) {
1039
-		$country = $this->get_prop( 'country', $context );
1040
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1038
+	public function get_country($context = 'view') {
1039
+		$country = $this->get_prop('country', $context);
1040
+		return empty($country) ? wpinv_get_default_country() : $country;
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @param  string $context View or edit context.
1048 1048
 	 * @return string
1049 1049
 	 */
1050
-	public function get_user_country( $context = 'view' ) {
1051
-		return $this->get_country( $context );
1050
+	public function get_user_country($context = 'view') {
1051
+		return $this->get_country($context);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
 	 * @param  string $context View or edit context.
1059 1059
 	 * @return string
1060 1060
 	 */
1061
-	public function get_customer_country( $context = 'view' ) {
1062
-		return $this->get_country( $context );
1061
+	public function get_customer_country($context = 'view') {
1062
+		return $this->get_country($context);
1063 1063
     }
1064 1064
 
1065 1065
     /**
@@ -1069,9 +1069,9 @@  discard block
 block discarded – undo
1069 1069
 	 * @param  string $context View or edit context.
1070 1070
 	 * @return string
1071 1071
 	 */
1072
-	public function get_state( $context = 'view' ) {
1073
-		$state = $this->get_prop( 'state', $context );
1074
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1072
+	public function get_state($context = 'view') {
1073
+		$state = $this->get_prop('state', $context);
1074
+		return empty($state) ? wpinv_get_default_state() : $state;
1075 1075
     }
1076 1076
 
1077 1077
     /**
@@ -1081,8 +1081,8 @@  discard block
 block discarded – undo
1081 1081
 	 * @param  string $context View or edit context.
1082 1082
 	 * @return string
1083 1083
 	 */
1084
-	public function get_user_state( $context = 'view' ) {
1085
-		return $this->get_state( $context );
1084
+	public function get_user_state($context = 'view') {
1085
+		return $this->get_state($context);
1086 1086
     }
1087 1087
 
1088 1088
     /**
@@ -1092,8 +1092,8 @@  discard block
 block discarded – undo
1092 1092
 	 * @param  string $context View or edit context.
1093 1093
 	 * @return string
1094 1094
 	 */
1095
-	public function get_customer_state( $context = 'view' ) {
1096
-		return $this->get_state( $context );
1095
+	public function get_customer_state($context = 'view') {
1096
+		return $this->get_state($context);
1097 1097
     }
1098 1098
 
1099 1099
     /**
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
 	 * @param  string $context View or edit context.
1104 1104
 	 * @return string
1105 1105
 	 */
1106
-	public function get_city( $context = 'view' ) {
1107
-		return $this->get_prop( 'city', $context );
1106
+	public function get_city($context = 'view') {
1107
+		return $this->get_prop('city', $context);
1108 1108
     }
1109 1109
 
1110 1110
     /**
@@ -1114,8 +1114,8 @@  discard block
 block discarded – undo
1114 1114
 	 * @param  string $context View or edit context.
1115 1115
 	 * @return string
1116 1116
 	 */
1117
-	public function get_user_city( $context = 'view' ) {
1118
-		return $this->get_city( $context );
1117
+	public function get_user_city($context = 'view') {
1118
+		return $this->get_city($context);
1119 1119
     }
1120 1120
 
1121 1121
     /**
@@ -1125,8 +1125,8 @@  discard block
 block discarded – undo
1125 1125
 	 * @param  string $context View or edit context.
1126 1126
 	 * @return string
1127 1127
 	 */
1128
-	public function get_customer_city( $context = 'view' ) {
1129
-		return $this->get_city( $context );
1128
+	public function get_customer_city($context = 'view') {
1129
+		return $this->get_city($context);
1130 1130
     }
1131 1131
 
1132 1132
     /**
@@ -1136,8 +1136,8 @@  discard block
 block discarded – undo
1136 1136
 	 * @param  string $context View or edit context.
1137 1137
 	 * @return string
1138 1138
 	 */
1139
-	public function get_zip( $context = 'view' ) {
1140
-		return $this->get_prop( 'zip', $context );
1139
+	public function get_zip($context = 'view') {
1140
+		return $this->get_prop('zip', $context);
1141 1141
     }
1142 1142
 
1143 1143
     /**
@@ -1147,8 +1147,8 @@  discard block
 block discarded – undo
1147 1147
 	 * @param  string $context View or edit context.
1148 1148
 	 * @return string
1149 1149
 	 */
1150
-	public function get_user_zip( $context = 'view' ) {
1151
-		return $this->get_zip( $context );
1150
+	public function get_user_zip($context = 'view') {
1151
+		return $this->get_zip($context);
1152 1152
     }
1153 1153
 
1154 1154
     /**
@@ -1158,8 +1158,8 @@  discard block
 block discarded – undo
1158 1158
 	 * @param  string $context View or edit context.
1159 1159
 	 * @return string
1160 1160
 	 */
1161
-	public function get_customer_zip( $context = 'view' ) {
1162
-		return $this->get_zip( $context );
1161
+	public function get_customer_zip($context = 'view') {
1162
+		return $this->get_zip($context);
1163 1163
     }
1164 1164
 
1165 1165
     /**
@@ -1169,8 +1169,8 @@  discard block
 block discarded – undo
1169 1169
 	 * @param  string $context View or edit context.
1170 1170
 	 * @return string
1171 1171
 	 */
1172
-	public function get_company( $context = 'view' ) {
1173
-		return $this->get_prop( 'company', $context );
1172
+	public function get_company($context = 'view') {
1173
+		return $this->get_prop('company', $context);
1174 1174
     }
1175 1175
 
1176 1176
     /**
@@ -1180,8 +1180,8 @@  discard block
 block discarded – undo
1180 1180
 	 * @param  string $context View or edit context.
1181 1181
 	 * @return string
1182 1182
 	 */
1183
-	public function get_user_company( $context = 'view' ) {
1184
-		return $this->get_company( $context );
1183
+	public function get_user_company($context = 'view') {
1184
+		return $this->get_company($context);
1185 1185
     }
1186 1186
 
1187 1187
     /**
@@ -1191,8 +1191,8 @@  discard block
 block discarded – undo
1191 1191
 	 * @param  string $context View or edit context.
1192 1192
 	 * @return string
1193 1193
 	 */
1194
-	public function get_customer_company( $context = 'view' ) {
1195
-		return $this->get_company( $context );
1194
+	public function get_customer_company($context = 'view') {
1195
+		return $this->get_company($context);
1196 1196
     }
1197 1197
 
1198 1198
 	/**
@@ -1202,8 +1202,8 @@  discard block
 block discarded – undo
1202 1202
 	 * @param  string $context View or edit context.
1203 1203
 	 * @return string
1204 1204
 	 */
1205
-	public function get_company_id( $context = 'view' ) {
1206
-		return $this->get_prop( 'company_id', $context );
1205
+	public function get_company_id($context = 'view') {
1206
+		return $this->get_prop('company_id', $context);
1207 1207
     }
1208 1208
 
1209 1209
     /**
@@ -1213,8 +1213,8 @@  discard block
 block discarded – undo
1213 1213
 	 * @param  string $context View or edit context.
1214 1214
 	 * @return string
1215 1215
 	 */
1216
-	public function get_vat_number( $context = 'view' ) {
1217
-		return $this->get_prop( 'vat_number', $context );
1216
+	public function get_vat_number($context = 'view') {
1217
+		return $this->get_prop('vat_number', $context);
1218 1218
     }
1219 1219
 
1220 1220
     /**
@@ -1224,8 +1224,8 @@  discard block
 block discarded – undo
1224 1224
 	 * @param  string $context View or edit context.
1225 1225
 	 * @return string
1226 1226
 	 */
1227
-	public function get_user_vat_number( $context = 'view' ) {
1228
-		return $this->get_vat_number( $context );
1227
+	public function get_user_vat_number($context = 'view') {
1228
+		return $this->get_vat_number($context);
1229 1229
     }
1230 1230
 
1231 1231
     /**
@@ -1235,8 +1235,8 @@  discard block
 block discarded – undo
1235 1235
 	 * @param  string $context View or edit context.
1236 1236
 	 * @return string
1237 1237
 	 */
1238
-	public function get_customer_vat_number( $context = 'view' ) {
1239
-		return $this->get_vat_number( $context );
1238
+	public function get_customer_vat_number($context = 'view') {
1239
+		return $this->get_vat_number($context);
1240 1240
     }
1241 1241
 
1242 1242
     /**
@@ -1246,8 +1246,8 @@  discard block
 block discarded – undo
1246 1246
 	 * @param  string $context View or edit context.
1247 1247
 	 * @return string
1248 1248
 	 */
1249
-	public function get_vat_rate( $context = 'view' ) {
1250
-		return $this->get_prop( 'vat_rate', $context );
1249
+	public function get_vat_rate($context = 'view') {
1250
+		return $this->get_prop('vat_rate', $context);
1251 1251
     }
1252 1252
 
1253 1253
     /**
@@ -1257,8 +1257,8 @@  discard block
 block discarded – undo
1257 1257
 	 * @param  string $context View or edit context.
1258 1258
 	 * @return string
1259 1259
 	 */
1260
-	public function get_user_vat_rate( $context = 'view' ) {
1261
-		return $this->get_vat_rate( $context );
1260
+	public function get_user_vat_rate($context = 'view') {
1261
+		return $this->get_vat_rate($context);
1262 1262
     }
1263 1263
 
1264 1264
     /**
@@ -1268,8 +1268,8 @@  discard block
 block discarded – undo
1268 1268
 	 * @param  string $context View or edit context.
1269 1269
 	 * @return string
1270 1270
 	 */
1271
-	public function get_customer_vat_rate( $context = 'view' ) {
1272
-		return $this->get_vat_rate( $context );
1271
+	public function get_customer_vat_rate($context = 'view') {
1272
+		return $this->get_vat_rate($context);
1273 1273
     }
1274 1274
 
1275 1275
     /**
@@ -1279,8 +1279,8 @@  discard block
 block discarded – undo
1279 1279
 	 * @param  string $context View or edit context.
1280 1280
 	 * @return string
1281 1281
 	 */
1282
-	public function get_address( $context = 'view' ) {
1283
-		return $this->get_prop( 'address', $context );
1282
+	public function get_address($context = 'view') {
1283
+		return $this->get_prop('address', $context);
1284 1284
     }
1285 1285
 
1286 1286
     /**
@@ -1290,8 +1290,8 @@  discard block
 block discarded – undo
1290 1290
 	 * @param  string $context View or edit context.
1291 1291
 	 * @return string
1292 1292
 	 */
1293
-	public function get_user_address( $context = 'view' ) {
1294
-		return $this->get_address( $context );
1293
+	public function get_user_address($context = 'view') {
1294
+		return $this->get_address($context);
1295 1295
     }
1296 1296
 
1297 1297
     /**
@@ -1301,8 +1301,8 @@  discard block
 block discarded – undo
1301 1301
 	 * @param  string $context View or edit context.
1302 1302
 	 * @return string
1303 1303
 	 */
1304
-	public function get_customer_address( $context = 'view' ) {
1305
-		return $this->get_address( $context );
1304
+	public function get_customer_address($context = 'view') {
1305
+		return $this->get_address($context);
1306 1306
     }
1307 1307
 
1308 1308
     /**
@@ -1312,8 +1312,8 @@  discard block
 block discarded – undo
1312 1312
 	 * @param  string $context View or edit context.
1313 1313
 	 * @return bool
1314 1314
 	 */
1315
-	public function get_is_viewed( $context = 'view' ) {
1316
-		return (bool) $this->get_prop( 'is_viewed', $context );
1315
+	public function get_is_viewed($context = 'view') {
1316
+		return (bool) $this->get_prop('is_viewed', $context);
1317 1317
 	}
1318 1318
 
1319 1319
 	/**
@@ -1323,8 +1323,8 @@  discard block
 block discarded – undo
1323 1323
 	 * @param  string $context View or edit context.
1324 1324
 	 * @return bool
1325 1325
 	 */
1326
-	public function get_email_cc( $context = 'view' ) {
1327
-		return $this->get_prop( 'email_cc', $context );
1326
+	public function get_email_cc($context = 'view') {
1327
+		return $this->get_prop('email_cc', $context);
1328 1328
 	}
1329 1329
 
1330 1330
 	/**
@@ -1334,8 +1334,8 @@  discard block
 block discarded – undo
1334 1334
 	 * @param  string $context View or edit context.
1335 1335
 	 * @return bool
1336 1336
 	 */
1337
-	public function get_template( $context = 'view' ) {
1338
-		return $this->get_prop( 'template', $context );
1337
+	public function get_template($context = 'view') {
1338
+		return $this->get_prop('template', $context);
1339 1339
 	}
1340 1340
 
1341 1341
 	/**
@@ -1345,8 +1345,8 @@  discard block
 block discarded – undo
1345 1345
 	 * @param  string $context View or edit context.
1346 1346
 	 * @return bool
1347 1347
 	 */
1348
-	public function get_created_via( $context = 'view' ) {
1349
-		return $this->get_prop( 'created_via', $context );
1348
+	public function get_created_via($context = 'view') {
1349
+		return $this->get_prop('created_via', $context);
1350 1350
 	}
1351 1351
 
1352 1352
 	/**
@@ -1356,8 +1356,8 @@  discard block
 block discarded – undo
1356 1356
 	 * @param  string $context View or edit context.
1357 1357
 	 * @return bool
1358 1358
 	 */
1359
-	public function get_address_confirmed( $context = 'view' ) {
1360
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1359
+	public function get_address_confirmed($context = 'view') {
1360
+		return (bool) $this->get_prop('address_confirmed', $context);
1361 1361
     }
1362 1362
 
1363 1363
     /**
@@ -1367,8 +1367,8 @@  discard block
 block discarded – undo
1367 1367
 	 * @param  string $context View or edit context.
1368 1368
 	 * @return bool
1369 1369
 	 */
1370
-	public function get_user_address_confirmed( $context = 'view' ) {
1371
-		return $this->get_address_confirmed( $context );
1370
+	public function get_user_address_confirmed($context = 'view') {
1371
+		return $this->get_address_confirmed($context);
1372 1372
     }
1373 1373
 
1374 1374
     /**
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	 * @param  string $context View or edit context.
1379 1379
 	 * @return bool
1380 1380
 	 */
1381
-	public function get_customer_address_confirmed( $context = 'view' ) {
1382
-		return $this->get_address_confirmed( $context );
1381
+	public function get_customer_address_confirmed($context = 'view') {
1382
+		return $this->get_address_confirmed($context);
1383 1383
     }
1384 1384
 
1385 1385
 	/**
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 	 */
1391 1391
 	public function get_shipping_address() {
1392 1392
 
1393
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1394
-		return is_array( $shipping_address ) ? $shipping_address : false;
1393
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1394
+		return is_array($shipping_address) ? $shipping_address : false;
1395 1395
     }
1396 1396
 
1397 1397
 	/**
@@ -1408,17 +1408,17 @@  discard block
 block discarded – undo
1408 1408
 	 * @param  string $context View or edit context.
1409 1409
 	 * @return float
1410 1410
 	 */
1411
-	public function get_shipping( $context = 'view' ) {
1411
+	public function get_shipping($context = 'view') {
1412 1412
 
1413
-		if ( $context = 'view' ) {
1414
-			return floatval( $this->get_prop( 'shipping', $context ) );
1413
+		if ($context = 'view') {
1414
+			return floatval($this->get_prop('shipping', $context));
1415 1415
 		}
1416 1416
 
1417
-		return $this->get_prop( 'shipping', $context );
1417
+		return $this->get_prop('shipping', $context);
1418 1418
     }
1419 1419
 
1420 1420
 	public function has_shipping() {
1421
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && $this->get_prop( 'shipping', 'edit' );
1421
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && $this->get_prop('shipping', 'edit');
1422 1422
     }
1423 1423
 
1424 1424
     /**
@@ -1428,12 +1428,12 @@  discard block
 block discarded – undo
1428 1428
 	 * @param  string $context View or edit context.
1429 1429
 	 * @return float
1430 1430
 	 */
1431
-	public function get_subtotal( $context = 'view' ) {
1432
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1431
+	public function get_subtotal($context = 'view') {
1432
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1433 1433
 
1434 1434
         // Backwards compatibility.
1435
-        if ( is_bool( $context ) && $context ) {
1436
-            return wpinv_price( $subtotal, $this->get_currency() );
1435
+        if (is_bool($context) && $context) {
1436
+            return wpinv_price($subtotal, $this->get_currency());
1437 1437
         }
1438 1438
 
1439 1439
         return $subtotal;
@@ -1446,8 +1446,8 @@  discard block
 block discarded – undo
1446 1446
 	 * @param  string $context View or edit context.
1447 1447
 	 * @return float
1448 1448
 	 */
1449
-	public function get_total_discount( $context = 'view' ) {
1450
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1449
+	public function get_total_discount($context = 'view') {
1450
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1451 1451
     }
1452 1452
 
1453 1453
     /**
@@ -1457,18 +1457,18 @@  discard block
 block discarded – undo
1457 1457
 	 * @param  string $context View or edit context.
1458 1458
 	 * @return float
1459 1459
 	 */
1460
-	public function get_total_tax( $context = 'view' ) {
1461
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1460
+	public function get_total_tax($context = 'view') {
1461
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1462 1462
 	}
1463 1463
 
1464 1464
 	/**
1465 1465
 	 * @deprecated
1466 1466
 	 */
1467
-	public function get_final_tax( $currency = false ) {
1467
+	public function get_final_tax($currency = false) {
1468 1468
 		$tax = $this->get_total_tax();
1469 1469
 
1470
-        if ( $currency ) {
1471
-			return wpinv_price( $tax, $this->get_currency() );
1470
+        if ($currency) {
1471
+			return wpinv_price($tax, $this->get_currency());
1472 1472
         }
1473 1473
 
1474 1474
         return $tax;
@@ -1481,8 +1481,8 @@  discard block
 block discarded – undo
1481 1481
 	 * @param  string $context View or edit context.
1482 1482
 	 * @return float
1483 1483
 	 */
1484
-	public function get_total_fees( $context = 'view' ) {
1485
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1484
+	public function get_total_fees($context = 'view') {
1485
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1486 1486
     }
1487 1487
 
1488 1488
     /**
@@ -1492,8 +1492,8 @@  discard block
 block discarded – undo
1492 1492
 	 * @param  string $context View or edit context.
1493 1493
 	 * @return float
1494 1494
 	 */
1495
-	public function get_fees_total( $context = 'view' ) {
1496
-		return $this->get_total_fees( $context );
1495
+	public function get_fees_total($context = 'view') {
1496
+		return $this->get_total_fees($context);
1497 1497
     }
1498 1498
 
1499 1499
     /**
@@ -1502,14 +1502,14 @@  discard block
 block discarded – undo
1502 1502
 	 * @since 1.0.19
1503 1503
      * @return float
1504 1504
 	 */
1505
-	public function get_total( $context = 'view' ) {
1506
-		$total = $this->get_prop( 'total', $context );
1505
+	public function get_total($context = 'view') {
1506
+		$total = $this->get_prop('total', $context);
1507 1507
 
1508
-		if ( $this->has_shipping() && $context == 'view' ) {
1509
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1508
+		if ($this->has_shipping() && $context == 'view') {
1509
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1510 1510
 		}
1511 1511
 
1512
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1512
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1513 1513
 	}
1514 1514
 
1515 1515
 	/**
@@ -1521,20 +1521,20 @@  discard block
 block discarded – undo
1521 1521
 	public function get_non_recurring_total() {
1522 1522
 
1523 1523
 		$subtotal = 0;
1524
-		foreach ( $this->get_items() as $item ) {
1525
-			if ( ! $item->is_recurring() ) {
1524
+		foreach ($this->get_items() as $item) {
1525
+			if (!$item->is_recurring()) {
1526 1526
 				$subtotal += $item->get_sub_total();
1527 1527
 			}
1528 1528
 		}
1529 1529
 
1530
-		foreach ( $this->get_fees() as $fee ) {
1531
-			if ( empty( $fee['recurring_fee'] ) ) {
1532
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1530
+		foreach ($this->get_fees() as $fee) {
1531
+			if (empty($fee['recurring_fee'])) {
1532
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1533 1533
 			}
1534 1534
 		}
1535 1535
 
1536
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1537
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1536
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1537
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1538 1538
 
1539 1539
     }
1540 1540
 
@@ -1557,7 +1557,7 @@  discard block
 block discarded – undo
1557 1557
 	 */
1558 1558
     public function get_initial_total() {
1559 1559
 
1560
-		if ( empty( $this->totals ) ) {
1560
+		if (empty($this->totals)) {
1561 1561
 			$this->recalculate_total();
1562 1562
 		}
1563 1563
 
@@ -1567,12 +1567,12 @@  discard block
 block discarded – undo
1567 1567
 		$subtotal = $this->totals['subtotal']['initial'];
1568 1568
 		$total    = $tax + $fee - $discount + $subtotal;
1569 1569
 
1570
-		if ( 0 > $total ) {
1570
+		if (0 > $total) {
1571 1571
 			$total = 0;
1572 1572
 		}
1573 1573
 
1574
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1575
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1574
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1575
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1576 1576
 	}
1577 1577
 
1578 1578
 	/**
@@ -1584,7 +1584,7 @@  discard block
 block discarded – undo
1584 1584
 	 */
1585 1585
     public function get_recurring_total() {
1586 1586
 
1587
-		if ( empty( $this->totals ) ) {
1587
+		if (empty($this->totals)) {
1588 1588
 			$this->recalculate_total();
1589 1589
 		}
1590 1590
 
@@ -1594,12 +1594,12 @@  discard block
 block discarded – undo
1594 1594
 		$subtotal = $this->totals['subtotal']['recurring'];
1595 1595
 		$total    = $tax + $fee - $discount + $subtotal;
1596 1596
 
1597
-		if ( 0 > $total ) {
1597
+		if (0 > $total) {
1598 1598
 			$total = 0;
1599 1599
 		}
1600 1600
 
1601
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1602
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1601
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1602
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1603 1603
 	}
1604 1604
 
1605 1605
 	/**
@@ -1610,10 +1610,10 @@  discard block
 block discarded – undo
1610 1610
 	 * @param string $currency Whether to include the currency.
1611 1611
      * @return float|string
1612 1612
 	 */
1613
-    public function get_recurring_details( $field = '', $currency = false ) {
1613
+    public function get_recurring_details($field = '', $currency = false) {
1614 1614
 
1615 1615
 		// Maybe recalculate totals.
1616
-		if ( empty( $this->totals ) ) {
1616
+		if (empty($this->totals)) {
1617 1617
 			$this->recalculate_total();
1618 1618
 		}
1619 1619
 
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
 			$currency
1634 1634
 		);
1635 1635
 
1636
-        if ( isset( $data[ $field ] ) ) {
1637
-            return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] );
1636
+        if (isset($data[$field])) {
1637
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1638 1638
         }
1639 1639
 
1640 1640
         return $data;
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
 	 * @param  string $context View or edit context.
1648 1648
 	 * @return array
1649 1649
 	 */
1650
-	public function get_fees( $context = 'view' ) {
1651
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1650
+	public function get_fees($context = 'view') {
1651
+		return wpinv_parse_list($this->get_prop('fees', $context));
1652 1652
     }
1653 1653
 
1654 1654
     /**
@@ -1658,8 +1658,8 @@  discard block
 block discarded – undo
1658 1658
 	 * @param  string $context View or edit context.
1659 1659
 	 * @return array
1660 1660
 	 */
1661
-	public function get_discounts( $context = 'view' ) {
1662
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1661
+	public function get_discounts($context = 'view') {
1662
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1663 1663
     }
1664 1664
 
1665 1665
     /**
@@ -1669,8 +1669,8 @@  discard block
 block discarded – undo
1669 1669
 	 * @param  string $context View or edit context.
1670 1670
 	 * @return array
1671 1671
 	 */
1672
-	public function get_taxes( $context = 'view' ) {
1673
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1672
+	public function get_taxes($context = 'view') {
1673
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1674 1674
     }
1675 1675
 
1676 1676
     /**
@@ -1680,8 +1680,8 @@  discard block
 block discarded – undo
1680 1680
 	 * @param  string $context View or edit context.
1681 1681
 	 * @return GetPaid_Form_Item[]
1682 1682
 	 */
1683
-	public function get_items( $context = 'view' ) {
1684
-        return $this->get_prop( 'items', $context );
1683
+	public function get_items($context = 'view') {
1684
+        return $this->get_prop('items', $context);
1685 1685
 	}
1686 1686
 
1687 1687
 	/**
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
 	 * @return string
1692 1692
 	 */
1693 1693
 	public function get_item_ids() {
1694
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1694
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1695 1695
     }
1696 1696
 
1697 1697
     /**
@@ -1701,8 +1701,8 @@  discard block
 block discarded – undo
1701 1701
 	 * @param  string $context View or edit context.
1702 1702
 	 * @return int
1703 1703
 	 */
1704
-	public function get_payment_form( $context = 'view' ) {
1705
-		return intval( $this->get_prop( 'payment_form', $context ) );
1704
+	public function get_payment_form($context = 'view') {
1705
+		return intval($this->get_prop('payment_form', $context));
1706 1706
     }
1707 1707
 
1708 1708
     /**
@@ -1712,8 +1712,8 @@  discard block
 block discarded – undo
1712 1712
 	 * @param  string $context View or edit context.
1713 1713
 	 * @return string
1714 1714
 	 */
1715
-	public function get_submission_id( $context = 'view' ) {
1716
-		return $this->get_prop( 'submission_id', $context );
1715
+	public function get_submission_id($context = 'view') {
1716
+		return $this->get_prop('submission_id', $context);
1717 1717
     }
1718 1718
 
1719 1719
     /**
@@ -1723,8 +1723,8 @@  discard block
 block discarded – undo
1723 1723
 	 * @param  string $context View or edit context.
1724 1724
 	 * @return string
1725 1725
 	 */
1726
-	public function get_discount_code( $context = 'view' ) {
1727
-		return $this->get_prop( 'discount_code', $context );
1726
+	public function get_discount_code($context = 'view') {
1727
+		return $this->get_prop('discount_code', $context);
1728 1728
     }
1729 1729
 
1730 1730
     /**
@@ -1734,8 +1734,8 @@  discard block
 block discarded – undo
1734 1734
 	 * @param  string $context View or edit context.
1735 1735
 	 * @return string
1736 1736
 	 */
1737
-	public function get_gateway( $context = 'view' ) {
1738
-		return $this->get_prop( 'gateway', $context );
1737
+	public function get_gateway($context = 'view') {
1738
+		return $this->get_prop('gateway', $context);
1739 1739
     }
1740 1740
 
1741 1741
     /**
@@ -1745,8 +1745,8 @@  discard block
 block discarded – undo
1745 1745
 	 * @return string
1746 1746
 	 */
1747 1747
     public function get_gateway_title() {
1748
-        $title = wpinv_get_gateway_checkout_label( $this->get_gateway() );
1749
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1748
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1749
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1750 1750
     }
1751 1751
 
1752 1752
     /**
@@ -1756,8 +1756,8 @@  discard block
 block discarded – undo
1756 1756
 	 * @param  string $context View or edit context.
1757 1757
 	 * @return string
1758 1758
 	 */
1759
-	public function get_transaction_id( $context = 'view' ) {
1760
-		return $this->get_prop( 'transaction_id', $context );
1759
+	public function get_transaction_id($context = 'view') {
1760
+		return $this->get_prop('transaction_id', $context);
1761 1761
     }
1762 1762
 
1763 1763
     /**
@@ -1767,9 +1767,9 @@  discard block
 block discarded – undo
1767 1767
 	 * @param  string $context View or edit context.
1768 1768
 	 * @return string
1769 1769
 	 */
1770
-	public function get_currency( $context = 'view' ) {
1771
-        $currency = $this->get_prop( 'currency', $context );
1772
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1770
+	public function get_currency($context = 'view') {
1771
+        $currency = $this->get_prop('currency', $context);
1772
+        return empty($currency) ? wpinv_get_currency() : $currency;
1773 1773
     }
1774 1774
 
1775 1775
     /**
@@ -1779,8 +1779,8 @@  discard block
 block discarded – undo
1779 1779
 	 * @param  string $context View or edit context.
1780 1780
 	 * @return bool
1781 1781
 	 */
1782
-	public function get_disable_taxes( $context = 'view' ) {
1783
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1782
+	public function get_disable_taxes($context = 'view') {
1783
+        return (bool) $this->get_prop('disable_taxes', $context);
1784 1784
     }
1785 1785
 
1786 1786
     /**
@@ -1790,8 +1790,8 @@  discard block
 block discarded – undo
1790 1790
 	 * @param  string $context View or edit context.
1791 1791
 	 * @return int
1792 1792
 	 */
1793
-    public function get_subscription_id( $context = 'view' ) {
1794
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1793
+    public function get_subscription_id($context = 'view') {
1794
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1795 1795
 	}
1796 1796
 
1797 1797
 	/**
@@ -1801,12 +1801,12 @@  discard block
 block discarded – undo
1801 1801
 	 * @param  string $context View or edit context.
1802 1802
 	 * @return int
1803 1803
 	 */
1804
-    public function get_remote_subscription_id( $context = 'view' ) {
1805
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1804
+    public function get_remote_subscription_id($context = 'view') {
1805
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1806 1806
 
1807
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1807
+        if (empty($subscription_id) && $this->is_renewal()) {
1808 1808
             $parent = $this->get_parent();
1809
-            return $parent->get_remote_subscription_id( $context );
1809
+            return $parent->get_remote_subscription_id($context);
1810 1810
         }
1811 1811
 
1812 1812
         return $subscription_id;
@@ -1819,20 +1819,20 @@  discard block
 block discarded – undo
1819 1819
 	 * @param  string $context View or edit context.
1820 1820
 	 * @return array
1821 1821
 	 */
1822
-    public function get_payment_meta( $context = 'view' ) {
1822
+    public function get_payment_meta($context = 'view') {
1823 1823
 
1824 1824
         return array(
1825
-            'price'        => $this->get_total( $context ),
1826
-            'date'         => $this->get_date_created( $context ),
1827
-            'user_email'   => $this->get_email( $context ),
1828
-            'invoice_key'  => $this->get_key( $context ),
1829
-            'currency'     => $this->get_currency( $context ),
1830
-            'items'        => $this->get_items( $context ),
1831
-            'user_info'    => $this->get_user_info( $context ),
1825
+            'price'        => $this->get_total($context),
1826
+            'date'         => $this->get_date_created($context),
1827
+            'user_email'   => $this->get_email($context),
1828
+            'invoice_key'  => $this->get_key($context),
1829
+            'currency'     => $this->get_currency($context),
1830
+            'items'        => $this->get_items($context),
1831
+            'user_info'    => $this->get_user_info($context),
1832 1832
             'cart_details' => $this->get_cart_details(),
1833
-            'status'       => $this->get_status( $context ),
1834
-            'fees'         => $this->get_fees( $context ),
1835
-            'taxes'        => $this->get_taxes( $context ),
1833
+            'status'       => $this->get_status($context),
1834
+            'fees'         => $this->get_fees($context),
1835
+            'taxes'        => $this->get_taxes($context),
1836 1836
         );
1837 1837
 
1838 1838
     }
@@ -1847,9 +1847,9 @@  discard block
 block discarded – undo
1847 1847
         $items        = $this->get_items();
1848 1848
         $cart_details = array();
1849 1849
 
1850
-        foreach ( $items as $item ) {
1850
+        foreach ($items as $item) {
1851 1851
 			$item->invoice_id = $this->get_id();
1852
-            $cart_details[]   = $item->prepare_data_for_saving();
1852
+            $cart_details[] = $item->prepare_data_for_saving();
1853 1853
         }
1854 1854
 
1855 1855
         return $cart_details;
@@ -1860,11 +1860,11 @@  discard block
 block discarded – undo
1860 1860
 	 *
1861 1861
 	 * @return null|GetPaid_Form_Item|int
1862 1862
 	 */
1863
-	public function get_recurring( $object = false ) {
1863
+	public function get_recurring($object = false) {
1864 1864
 
1865 1865
 		// Are we returning an object?
1866
-        if ( $object ) {
1867
-            return $this->get_item( $this->recurring_item );
1866
+        if ($object) {
1867
+            return $this->get_item($this->recurring_item);
1868 1868
         }
1869 1869
 
1870 1870
         return $this->recurring_item;
@@ -1879,15 +1879,15 @@  discard block
 block discarded – undo
1879 1879
 	public function get_subscription_name() {
1880 1880
 
1881 1881
 		// Retrieve the recurring name
1882
-        $item = $this->get_recurring( true );
1882
+        $item = $this->get_recurring(true);
1883 1883
 
1884 1884
 		// Abort if it does not exist.
1885
-        if ( empty( $item ) ) {
1885
+        if (empty($item)) {
1886 1886
             return '';
1887 1887
         }
1888 1888
 
1889 1889
 		// Return the item name.
1890
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1890
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1891 1891
 	}
1892 1892
 
1893 1893
 	/**
@@ -1897,9 +1897,9 @@  discard block
 block discarded – undo
1897 1897
 	 * @return string
1898 1898
 	 */
1899 1899
 	public function get_view_url() {
1900
-        $invoice_url = get_permalink( $this->get_id() );
1901
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1902
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1900
+        $invoice_url = get_permalink($this->get_id());
1901
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1902
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1903 1903
 	}
1904 1904
 
1905 1905
 	/**
@@ -1908,25 +1908,25 @@  discard block
 block discarded – undo
1908 1908
 	 * @since 1.0.19
1909 1909
 	 * @return string
1910 1910
 	 */
1911
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1911
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1912 1912
 
1913 1913
 		// Retrieve the checkout url.
1914 1914
         $pay_url = wpinv_get_checkout_uri();
1915 1915
 
1916 1916
 		// Maybe force ssl.
1917
-        if ( is_ssl() ) {
1918
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1917
+        if (is_ssl()) {
1918
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1919 1919
         }
1920 1920
 
1921 1921
 		// Add the invoice key.
1922
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1922
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1923 1923
 
1924 1924
 		// (Maybe?) add a secret
1925
-        if ( $secret ) {
1926
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1925
+        if ($secret) {
1926
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1927 1927
         }
1928 1928
 
1929
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1929
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1930 1930
 	}
1931 1931
 
1932 1932
 	/**
@@ -1941,14 +1941,14 @@  discard block
 block discarded – undo
1941 1941
         $receipt_url = wpinv_get_success_page_uri();
1942 1942
 
1943 1943
 		// Maybe force ssl.
1944
-        if ( is_ssl() ) {
1945
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1944
+        if (is_ssl()) {
1945
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1946 1946
         }
1947 1947
 
1948 1948
 		// Add the invoice key.
1949
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1949
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1950 1950
 
1951
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1951
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1952 1952
 	}
1953 1953
 
1954 1954
 	/**
@@ -1958,7 +1958,7 @@  discard block
 block discarded – undo
1958 1958
 	 * @return string
1959 1959
 	 */
1960 1960
 	public function get_transaction_url() {
1961
-		return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this );
1961
+		return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this);
1962 1962
 	}
1963 1963
 
1964 1964
 	/**
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
 
1972 1972
 		$type   = $this->get_type();
1973 1973
 		$status = "wpi-$type-pending";
1974
-		return str_replace( '-invoice', '', $status );
1974
+		return str_replace('-invoice', '', $status);
1975 1975
 
1976 1976
 	}
1977 1977
 
@@ -1985,14 +1985,14 @@  discard block
 block discarded – undo
1985 1985
 	 * @param  string $context View or edit context.
1986 1986
 	 * @return mixed Value of the given invoice property (if set).
1987 1987
 	 */
1988
-	public function get( $key, $context = 'view' ) {
1988
+	public function get($key, $context = 'view') {
1989 1989
 		$method = "get_$key";
1990 1990
 
1991
-		if ( is_callable( array( $this, $method ) ) ) {
1992
-			return $this->$method( $context );
1991
+		if (is_callable(array($this, $method))) {
1992
+			return $this->$method($context);
1993 1993
 		}
1994 1994
 
1995
-        return $this->get_prop( $key, $context );
1995
+        return $this->get_prop($key, $context);
1996 1996
 	}
1997 1997
 
1998 1998
     /*
@@ -2015,11 +2015,11 @@  discard block
 block discarded – undo
2015 2015
 	 * @param  mixed $value new value.
2016 2016
 	 * @return mixed Value of the given invoice property (if set).
2017 2017
 	 */
2018
-	public function set( $key, $value ) {
2018
+	public function set($key, $value) {
2019 2019
 
2020 2020
         $setter = "set_$key";
2021
-        if ( is_callable( array( $this, $setter ) ) ) {
2022
-            $this->{$setter}( $value );
2021
+        if (is_callable(array($this, $setter))) {
2022
+            $this->{$setter}($value);
2023 2023
         }
2024 2024
 
2025 2025
 	}
@@ -2033,45 +2033,45 @@  discard block
 block discarded – undo
2033 2033
 	 * @param bool   $manual_update Is this a manual status change?.
2034 2034
 	 * @return array details of change.
2035 2035
 	 */
2036
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2036
+	public function set_status($new_status, $note = '', $manual_update = false) {
2037 2037
 		$old_status = $this->get_status();
2038 2038
 
2039 2039
 		$statuses = $this->get_all_statuses();
2040 2040
 
2041
-		if ( isset( $statuses['draft'] ) ) {
2042
-			unset( $statuses['draft'] );
2041
+		if (isset($statuses['draft'])) {
2042
+			unset($statuses['draft']);
2043 2043
 		}
2044 2044
 
2045
-		$this->set_prop( 'status', $new_status );
2045
+		$this->set_prop('status', $new_status);
2046 2046
 
2047 2047
 		// If setting the status, ensure it's set to a valid status.
2048
-		if ( true === $this->object_read ) {
2048
+		if (true === $this->object_read) {
2049 2049
 
2050 2050
 			// Only allow valid new status.
2051
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2051
+			if (!array_key_exists($new_status, $statuses)) {
2052 2052
 				$new_status = $this->get_default_status();
2053 2053
 			}
2054 2054
 
2055 2055
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2056
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2056
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2057 2057
 				$old_status = $this->get_default_status();
2058 2058
 			}
2059 2059
 
2060 2060
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2061
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2061
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2062 2062
 				$old_status = 'wpi-pending';
2063 2063
 			}
2064 2064
 
2065
-			if ( $old_status !== $new_status ) {
2065
+			if ($old_status !== $new_status) {
2066 2066
 				$this->status_transition = array(
2067
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2067
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2068 2068
 					'to'     => $new_status,
2069 2069
 					'note'   => $note,
2070 2070
 					'manual' => (bool) $manual_update,
2071 2071
 				);
2072 2072
 
2073
-				if ( $manual_update ) {
2074
-					do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status );
2073
+				if ($manual_update) {
2074
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2075 2075
 				}
2076 2076
 
2077 2077
 				$this->maybe_set_date_paid();
@@ -2095,8 +2095,8 @@  discard block
 block discarded – undo
2095 2095
 	 */
2096 2096
 	public function maybe_set_date_paid() {
2097 2097
 
2098
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2099
-			$this->set_date_completed( current_time( 'mysql' ) );
2098
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2099
+			$this->set_date_completed(current_time('mysql'));
2100 2100
 		}
2101 2101
 	}
2102 2102
 
@@ -2105,11 +2105,11 @@  discard block
 block discarded – undo
2105 2105
 	 *
2106 2106
 	 * @since 1.0.19
2107 2107
 	 */
2108
-	public function set_parent_id( $value ) {
2109
-		if ( $value && ( $value === $this->get_id() ) ) {
2108
+	public function set_parent_id($value) {
2109
+		if ($value && ($value === $this->get_id())) {
2110 2110
 			return;
2111 2111
 		}
2112
-		$this->set_prop( 'parent_id', absint( $value ) );
2112
+		$this->set_prop('parent_id', absint($value));
2113 2113
     }
2114 2114
 
2115 2115
     /**
@@ -2117,8 +2117,8 @@  discard block
 block discarded – undo
2117 2117
 	 *
2118 2118
 	 * @since 1.0.19
2119 2119
 	 */
2120
-	public function set_version( $value ) {
2121
-		$this->set_prop( 'version', $value );
2120
+	public function set_version($value) {
2121
+		$this->set_prop('version', $value);
2122 2122
     }
2123 2123
 
2124 2124
     /**
@@ -2128,15 +2128,15 @@  discard block
 block discarded – undo
2128 2128
 	 * @param string $value Value to set.
2129 2129
      * @return bool Whether or not the date was set.
2130 2130
 	 */
2131
-	public function set_date_created( $value ) {
2132
-        $date = strtotime( $value );
2131
+	public function set_date_created($value) {
2132
+        $date = strtotime($value);
2133 2133
 
2134
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2135
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2134
+        if ($date && $value !== '0000-00-00 00:00:00') {
2135
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2136 2136
             return true;
2137 2137
         }
2138 2138
 
2139
-		$this->set_prop( 'date_created', '' );
2139
+		$this->set_prop('date_created', '');
2140 2140
 		return false;
2141 2141
 
2142 2142
     }
@@ -2148,15 +2148,15 @@  discard block
 block discarded – undo
2148 2148
 	 * @param string $value Value to set.
2149 2149
      * @return bool Whether or not the date was set.
2150 2150
 	 */
2151
-	public function set_due_date( $value ) {
2152
-        $date = strtotime( $value );
2151
+	public function set_due_date($value) {
2152
+        $date = strtotime($value);
2153 2153
 
2154
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2155
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2154
+        if ($date && $value !== '0000-00-00 00:00:00') {
2155
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2156 2156
             return true;
2157 2157
         }
2158 2158
 
2159
-		$this->set_prop( 'due_date', '' );
2159
+		$this->set_prop('due_date', '');
2160 2160
         return false;
2161 2161
 
2162 2162
     }
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
 	 * @since 1.0.19
2168 2168
 	 * @param  string $value New name.
2169 2169
 	 */
2170
-	public function set_date_due( $value ) {
2171
-		$this->set_due_date( $value );
2170
+	public function set_date_due($value) {
2171
+		$this->set_due_date($value);
2172 2172
     }
2173 2173
 
2174 2174
     /**
@@ -2178,15 +2178,15 @@  discard block
 block discarded – undo
2178 2178
 	 * @param string $value Value to set.
2179 2179
      * @return bool Whether or not the date was set.
2180 2180
 	 */
2181
-	public function set_completed_date( $value ) {
2182
-        $date = strtotime( $value );
2181
+	public function set_completed_date($value) {
2182
+        $date = strtotime($value);
2183 2183
 
2184
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2185
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2184
+        if ($date && $value !== '0000-00-00 00:00:00') {
2185
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2186 2186
             return true;
2187 2187
         }
2188 2188
 
2189
-		$this->set_prop( 'completed_date', '' );
2189
+		$this->set_prop('completed_date', '');
2190 2190
         return false;
2191 2191
 
2192 2192
     }
@@ -2197,8 +2197,8 @@  discard block
 block discarded – undo
2197 2197
 	 * @since 1.0.19
2198 2198
 	 * @param  string $value New name.
2199 2199
 	 */
2200
-	public function set_date_completed( $value ) {
2201
-		$this->set_completed_date( $value );
2200
+	public function set_date_completed($value) {
2201
+		$this->set_completed_date($value);
2202 2202
     }
2203 2203
 
2204 2204
     /**
@@ -2208,15 +2208,15 @@  discard block
 block discarded – undo
2208 2208
 	 * @param string $value Value to set.
2209 2209
      * @return bool Whether or not the date was set.
2210 2210
 	 */
2211
-	public function set_date_modified( $value ) {
2212
-        $date = strtotime( $value );
2211
+	public function set_date_modified($value) {
2212
+        $date = strtotime($value);
2213 2213
 
2214
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2215
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2214
+        if ($date && $value !== '0000-00-00 00:00:00') {
2215
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2216 2216
             return true;
2217 2217
         }
2218 2218
 
2219
-		$this->set_prop( 'date_modified', '' );
2219
+		$this->set_prop('date_modified', '');
2220 2220
         return false;
2221 2221
 
2222 2222
     }
@@ -2227,9 +2227,9 @@  discard block
 block discarded – undo
2227 2227
 	 * @since 1.0.19
2228 2228
 	 * @param  string $value New number.
2229 2229
 	 */
2230
-	public function set_number( $value ) {
2231
-        $number = sanitize_text_field( $value );
2232
-		$this->set_prop( 'number', $number );
2230
+	public function set_number($value) {
2231
+        $number = sanitize_text_field($value);
2232
+		$this->set_prop('number', $number);
2233 2233
     }
2234 2234
 
2235 2235
     /**
@@ -2238,9 +2238,9 @@  discard block
 block discarded – undo
2238 2238
 	 * @since 1.0.19
2239 2239
 	 * @param  string $value Type.
2240 2240
 	 */
2241
-	public function set_type( $value ) {
2242
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2243
-		$this->set_prop( 'type', $type );
2241
+	public function set_type($value) {
2242
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2243
+		$this->set_prop('type', $type);
2244 2244
 	}
2245 2245
 
2246 2246
     /**
@@ -2249,10 +2249,10 @@  discard block
 block discarded – undo
2249 2249
 	 * @since 1.0.19
2250 2250
 	 * @param  string $value Post type.
2251 2251
 	 */
2252
-	public function set_post_type( $value ) {
2253
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2254
-			$this->set_type( $value );
2255
-            $this->set_prop( 'post_type', $value );
2252
+	public function set_post_type($value) {
2253
+        if (getpaid_is_invoice_post_type($value)) {
2254
+			$this->set_type($value);
2255
+            $this->set_prop('post_type', $value);
2256 2256
         }
2257 2257
     }
2258 2258
 
@@ -2262,9 +2262,9 @@  discard block
 block discarded – undo
2262 2262
 	 * @since 1.0.19
2263 2263
 	 * @param  string $value New key.
2264 2264
 	 */
2265
-	public function set_key( $value ) {
2266
-        $key = sanitize_text_field( $value );
2267
-		$this->set_prop( 'key', $key );
2265
+	public function set_key($value) {
2266
+        $key = sanitize_text_field($value);
2267
+		$this->set_prop('key', $key);
2268 2268
     }
2269 2269
 
2270 2270
     /**
@@ -2273,9 +2273,9 @@  discard block
 block discarded – undo
2273 2273
 	 * @since 1.0.19
2274 2274
 	 * @param  string $value mode.
2275 2275
 	 */
2276
-	public function set_mode( $value ) {
2277
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2278
-            $this->set_prop( 'mode', $value );
2276
+	public function set_mode($value) {
2277
+        if (in_array($value, array('live', 'test'))) {
2278
+            $this->set_prop('mode', $value);
2279 2279
         }
2280 2280
     }
2281 2281
 
@@ -2285,8 +2285,8 @@  discard block
 block discarded – undo
2285 2285
 	 * @since 1.0.19
2286 2286
 	 * @param  string $value path.
2287 2287
 	 */
2288
-	public function set_path( $value ) {
2289
-        $this->set_prop( 'path', $value );
2288
+	public function set_path($value) {
2289
+        $this->set_prop('path', $value);
2290 2290
     }
2291 2291
 
2292 2292
     /**
@@ -2295,9 +2295,9 @@  discard block
 block discarded – undo
2295 2295
 	 * @since 1.0.19
2296 2296
 	 * @param  string $value New name.
2297 2297
 	 */
2298
-	public function set_name( $value ) {
2299
-        $name = sanitize_text_field( $value );
2300
-		$this->set_prop( 'name', $name );
2298
+	public function set_name($value) {
2299
+        $name = sanitize_text_field($value);
2300
+		$this->set_prop('name', $name);
2301 2301
     }
2302 2302
 
2303 2303
     /**
@@ -2306,8 +2306,8 @@  discard block
 block discarded – undo
2306 2306
 	 * @since 1.0.19
2307 2307
 	 * @param  string $value New name.
2308 2308
 	 */
2309
-	public function set_title( $value ) {
2310
-		$this->set_name( $value );
2309
+	public function set_title($value) {
2310
+		$this->set_name($value);
2311 2311
     }
2312 2312
 
2313 2313
     /**
@@ -2316,9 +2316,9 @@  discard block
 block discarded – undo
2316 2316
 	 * @since 1.0.19
2317 2317
 	 * @param  string $value New description.
2318 2318
 	 */
2319
-	public function set_description( $value ) {
2320
-        $description = wp_kses_post( $value );
2321
-		$this->set_prop( 'description', $description );
2319
+	public function set_description($value) {
2320
+        $description = wp_kses_post($value);
2321
+		$this->set_prop('description', $description);
2322 2322
     }
2323 2323
 
2324 2324
     /**
@@ -2327,8 +2327,8 @@  discard block
 block discarded – undo
2327 2327
 	 * @since 1.0.19
2328 2328
 	 * @param  string $value New description.
2329 2329
 	 */
2330
-	public function set_excerpt( $value ) {
2331
-		$this->set_description( $value );
2330
+	public function set_excerpt($value) {
2331
+		$this->set_description($value);
2332 2332
     }
2333 2333
 
2334 2334
     /**
@@ -2337,8 +2337,8 @@  discard block
 block discarded – undo
2337 2337
 	 * @since 1.0.19
2338 2338
 	 * @param  string $value New description.
2339 2339
 	 */
2340
-	public function set_summary( $value ) {
2341
-		$this->set_description( $value );
2340
+	public function set_summary($value) {
2341
+		$this->set_description($value);
2342 2342
     }
2343 2343
 
2344 2344
     /**
@@ -2347,12 +2347,12 @@  discard block
 block discarded – undo
2347 2347
 	 * @since 1.0.19
2348 2348
 	 * @param  int $value New author.
2349 2349
 	 */
2350
-	public function set_author( $value ) {
2351
-		$user = get_user_by( 'id', (int) $value );
2350
+	public function set_author($value) {
2351
+		$user = get_user_by('id', (int) $value);
2352 2352
 
2353
-		if ( $user && $user->ID ) {
2354
-			$this->set_prop( 'author', $user->ID );
2355
-			$this->set_prop( 'email', $user->user_email );
2353
+		if ($user && $user->ID) {
2354
+			$this->set_prop('author', $user->ID);
2355
+			$this->set_prop('email', $user->user_email);
2356 2356
 		}
2357 2357
 
2358 2358
     }
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  int $value New user id.
2365 2365
 	 */
2366
-	public function set_user_id( $value ) {
2367
-		$this->set_author( $value );
2366
+	public function set_user_id($value) {
2367
+		$this->set_author($value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  int $value New user id.
2375 2375
 	 */
2376
-	public function set_customer_id( $value ) {
2377
-		$this->set_prop( 'customer_id', (int) $value );
2376
+	public function set_customer_id($value) {
2377
+		$this->set_prop('customer_id', (int) $value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value ip address.
2385 2385
 	 */
2386
-	public function set_ip( $value ) {
2387
-		$this->set_prop( 'ip', $value );
2386
+	public function set_ip($value) {
2387
+		$this->set_prop('ip', $value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value ip address.
2395 2395
 	 */
2396
-	public function set_user_ip( $value ) {
2397
-		$this->set_ip( $value );
2396
+	public function set_user_ip($value) {
2397
+		$this->set_ip($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value first name.
2405 2405
 	 */
2406
-	public function set_first_name( $value ) {
2407
-		$this->set_prop( 'first_name', $value );
2406
+	public function set_first_name($value) {
2407
+		$this->set_prop('first_name', $value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value first name.
2415 2415
 	 */
2416
-	public function set_user_first_name( $value ) {
2417
-		$this->set_first_name( $value );
2416
+	public function set_user_first_name($value) {
2417
+		$this->set_first_name($value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value first name.
2425 2425
 	 */
2426
-	public function set_customer_first_name( $value ) {
2427
-		$this->set_first_name( $value );
2426
+	public function set_customer_first_name($value) {
2427
+		$this->set_first_name($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value last name.
2435 2435
 	 */
2436
-	public function set_last_name( $value ) {
2437
-		$this->set_prop( 'last_name', $value );
2436
+	public function set_last_name($value) {
2437
+		$this->set_prop('last_name', $value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value last name.
2445 2445
 	 */
2446
-	public function set_user_last_name( $value ) {
2447
-		$this->set_last_name( $value );
2446
+	public function set_user_last_name($value) {
2447
+		$this->set_last_name($value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value last name.
2455 2455
 	 */
2456
-	public function set_customer_last_name( $value ) {
2457
-		$this->set_last_name( $value );
2456
+	public function set_customer_last_name($value) {
2457
+		$this->set_last_name($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value phone.
2465 2465
 	 */
2466
-	public function set_phone( $value ) {
2467
-		$this->set_prop( 'phone', $value );
2466
+	public function set_phone($value) {
2467
+		$this->set_prop('phone', $value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value phone.
2475 2475
 	 */
2476
-	public function set_user_phone( $value ) {
2477
-		$this->set_phone( $value );
2476
+	public function set_user_phone($value) {
2477
+		$this->set_phone($value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value phone.
2485 2485
 	 */
2486
-	public function set_customer_phone( $value ) {
2487
-		$this->set_phone( $value );
2486
+	public function set_customer_phone($value) {
2487
+		$this->set_phone($value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value phone.
2495 2495
 	 */
2496
-	public function set_phone_number( $value ) {
2497
-		$this->set_phone( $value );
2496
+	public function set_phone_number($value) {
2497
+		$this->set_phone($value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value email address.
2505 2505
 	 */
2506
-	public function set_email( $value ) {
2507
-		$this->set_prop( 'email', $value );
2506
+	public function set_email($value) {
2507
+		$this->set_prop('email', $value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value email address.
2515 2515
 	 */
2516
-	public function set_user_email( $value ) {
2517
-		$this->set_email( $value );
2516
+	public function set_user_email($value) {
2517
+		$this->set_email($value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value email address.
2525 2525
 	 */
2526
-	public function set_email_address( $value ) {
2527
-		$this->set_email( $value );
2526
+	public function set_email_address($value) {
2527
+		$this->set_email($value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value email address.
2535 2535
 	 */
2536
-	public function set_customer_email( $value ) {
2537
-		$this->set_email( $value );
2536
+	public function set_customer_email($value) {
2537
+		$this->set_email($value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value country.
2545 2545
 	 */
2546
-	public function set_country( $value ) {
2547
-		$this->set_prop( 'country', $value );
2546
+	public function set_country($value) {
2547
+		$this->set_prop('country', $value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value country.
2555 2555
 	 */
2556
-	public function set_user_country( $value ) {
2557
-		$this->set_country( $value );
2556
+	public function set_user_country($value) {
2557
+		$this->set_country($value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value country.
2565 2565
 	 */
2566
-	public function set_customer_country( $value ) {
2567
-		$this->set_country( $value );
2566
+	public function set_customer_country($value) {
2567
+		$this->set_country($value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value state.
2575 2575
 	 */
2576
-	public function set_state( $value ) {
2577
-		$this->set_prop( 'state', $value );
2576
+	public function set_state($value) {
2577
+		$this->set_prop('state', $value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  string $value state.
2585 2585
 	 */
2586
-	public function set_user_state( $value ) {
2587
-		$this->set_state( $value );
2586
+	public function set_user_state($value) {
2587
+		$this->set_state($value);
2588 2588
     }
2589 2589
 
2590 2590
     /**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value state.
2595 2595
 	 */
2596
-	public function set_customer_state( $value ) {
2597
-		$this->set_state( $value );
2596
+	public function set_customer_state($value) {
2597
+		$this->set_state($value);
2598 2598
     }
2599 2599
 
2600 2600
     /**
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value city.
2605 2605
 	 */
2606
-	public function set_city( $value ) {
2607
-		$this->set_prop( 'city', $value );
2606
+	public function set_city($value) {
2607
+		$this->set_prop('city', $value);
2608 2608
     }
2609 2609
 
2610 2610
     /**
@@ -2613,8 +2613,8 @@  discard block
 block discarded – undo
2613 2613
 	 * @since 1.0.19
2614 2614
 	 * @param  string $value city.
2615 2615
 	 */
2616
-	public function set_user_city( $value ) {
2617
-		$this->set_city( $value );
2616
+	public function set_user_city($value) {
2617
+		$this->set_city($value);
2618 2618
     }
2619 2619
 
2620 2620
     /**
@@ -2623,8 +2623,8 @@  discard block
 block discarded – undo
2623 2623
 	 * @since 1.0.19
2624 2624
 	 * @param  string $value city.
2625 2625
 	 */
2626
-	public function set_customer_city( $value ) {
2627
-		$this->set_city( $value );
2626
+	public function set_customer_city($value) {
2627
+		$this->set_city($value);
2628 2628
     }
2629 2629
 
2630 2630
     /**
@@ -2633,8 +2633,8 @@  discard block
 block discarded – undo
2633 2633
 	 * @since 1.0.19
2634 2634
 	 * @param  string $value zip.
2635 2635
 	 */
2636
-	public function set_zip( $value ) {
2637
-		$this->set_prop( 'zip', $value );
2636
+	public function set_zip($value) {
2637
+		$this->set_prop('zip', $value);
2638 2638
     }
2639 2639
 
2640 2640
     /**
@@ -2643,8 +2643,8 @@  discard block
 block discarded – undo
2643 2643
 	 * @since 1.0.19
2644 2644
 	 * @param  string $value zip.
2645 2645
 	 */
2646
-	public function set_user_zip( $value ) {
2647
-		$this->set_zip( $value );
2646
+	public function set_user_zip($value) {
2647
+		$this->set_zip($value);
2648 2648
     }
2649 2649
 
2650 2650
     /**
@@ -2653,8 +2653,8 @@  discard block
 block discarded – undo
2653 2653
 	 * @since 1.0.19
2654 2654
 	 * @param  string $value zip.
2655 2655
 	 */
2656
-	public function set_customer_zip( $value ) {
2657
-		$this->set_zip( $value );
2656
+	public function set_customer_zip($value) {
2657
+		$this->set_zip($value);
2658 2658
     }
2659 2659
 
2660 2660
     /**
@@ -2663,8 +2663,8 @@  discard block
 block discarded – undo
2663 2663
 	 * @since 1.0.19
2664 2664
 	 * @param  string $value company.
2665 2665
 	 */
2666
-	public function set_company( $value ) {
2667
-		$this->set_prop( 'company', $value );
2666
+	public function set_company($value) {
2667
+		$this->set_prop('company', $value);
2668 2668
     }
2669 2669
 
2670 2670
     /**
@@ -2673,8 +2673,8 @@  discard block
 block discarded – undo
2673 2673
 	 * @since 1.0.19
2674 2674
 	 * @param  string $value company.
2675 2675
 	 */
2676
-	public function set_user_company( $value ) {
2677
-		$this->set_company( $value );
2676
+	public function set_user_company($value) {
2677
+		$this->set_company($value);
2678 2678
     }
2679 2679
 
2680 2680
     /**
@@ -2683,8 +2683,8 @@  discard block
 block discarded – undo
2683 2683
 	 * @since 1.0.19
2684 2684
 	 * @param  string $value company.
2685 2685
 	 */
2686
-	public function set_customer_company( $value ) {
2687
-		$this->set_company( $value );
2686
+	public function set_customer_company($value) {
2687
+		$this->set_company($value);
2688 2688
     }
2689 2689
 
2690 2690
 	/**
@@ -2693,8 +2693,8 @@  discard block
 block discarded – undo
2693 2693
 	 * @since 1.0.19
2694 2694
 	 * @param  string $value company id.
2695 2695
 	 */
2696
-	public function set_company_id( $value ) {
2697
-		$this->set_prop( 'company_id', $value );
2696
+	public function set_company_id($value) {
2697
+		$this->set_prop('company_id', $value);
2698 2698
     }
2699 2699
 
2700 2700
     /**
@@ -2703,8 +2703,8 @@  discard block
 block discarded – undo
2703 2703
 	 * @since 1.0.19
2704 2704
 	 * @param  string $value var number.
2705 2705
 	 */
2706
-	public function set_vat_number( $value ) {
2707
-		$this->set_prop( 'vat_number', $value );
2706
+	public function set_vat_number($value) {
2707
+		$this->set_prop('vat_number', $value);
2708 2708
     }
2709 2709
 
2710 2710
     /**
@@ -2713,8 +2713,8 @@  discard block
 block discarded – undo
2713 2713
 	 * @since 1.0.19
2714 2714
 	 * @param  string $value var number.
2715 2715
 	 */
2716
-	public function set_user_vat_number( $value ) {
2717
-		$this->set_vat_number( $value );
2716
+	public function set_user_vat_number($value) {
2717
+		$this->set_vat_number($value);
2718 2718
     }
2719 2719
 
2720 2720
     /**
@@ -2723,8 +2723,8 @@  discard block
 block discarded – undo
2723 2723
 	 * @since 1.0.19
2724 2724
 	 * @param  string $value var number.
2725 2725
 	 */
2726
-	public function set_customer_vat_number( $value ) {
2727
-		$this->set_vat_number( $value );
2726
+	public function set_customer_vat_number($value) {
2727
+		$this->set_vat_number($value);
2728 2728
     }
2729 2729
 
2730 2730
     /**
@@ -2733,8 +2733,8 @@  discard block
 block discarded – undo
2733 2733
 	 * @since 1.0.19
2734 2734
 	 * @param  string $value var rate.
2735 2735
 	 */
2736
-	public function set_vat_rate( $value ) {
2737
-		$this->set_prop( 'vat_rate', $value );
2736
+	public function set_vat_rate($value) {
2737
+		$this->set_prop('vat_rate', $value);
2738 2738
     }
2739 2739
 
2740 2740
     /**
@@ -2743,8 +2743,8 @@  discard block
 block discarded – undo
2743 2743
 	 * @since 1.0.19
2744 2744
 	 * @param  string $value var number.
2745 2745
 	 */
2746
-	public function set_user_vat_rate( $value ) {
2747
-		$this->set_vat_rate( $value );
2746
+	public function set_user_vat_rate($value) {
2747
+		$this->set_vat_rate($value);
2748 2748
     }
2749 2749
 
2750 2750
     /**
@@ -2753,8 +2753,8 @@  discard block
 block discarded – undo
2753 2753
 	 * @since 1.0.19
2754 2754
 	 * @param  string $value var number.
2755 2755
 	 */
2756
-	public function set_customer_vat_rate( $value ) {
2757
-		$this->set_vat_rate( $value );
2756
+	public function set_customer_vat_rate($value) {
2757
+		$this->set_vat_rate($value);
2758 2758
     }
2759 2759
 
2760 2760
     /**
@@ -2763,8 +2763,8 @@  discard block
 block discarded – undo
2763 2763
 	 * @since 1.0.19
2764 2764
 	 * @param  string $value address.
2765 2765
 	 */
2766
-	public function set_address( $value ) {
2767
-		$this->set_prop( 'address', $value );
2766
+	public function set_address($value) {
2767
+		$this->set_prop('address', $value);
2768 2768
     }
2769 2769
 
2770 2770
     /**
@@ -2773,8 +2773,8 @@  discard block
 block discarded – undo
2773 2773
 	 * @since 1.0.19
2774 2774
 	 * @param  string $value address.
2775 2775
 	 */
2776
-	public function set_user_address( $value ) {
2777
-		$this->set_address( $value );
2776
+	public function set_user_address($value) {
2777
+		$this->set_address($value);
2778 2778
     }
2779 2779
 
2780 2780
     /**
@@ -2783,8 +2783,8 @@  discard block
 block discarded – undo
2783 2783
 	 * @since 1.0.19
2784 2784
 	 * @param  string $value address.
2785 2785
 	 */
2786
-	public function set_customer_address( $value ) {
2787
-		$this->set_address( $value );
2786
+	public function set_customer_address($value) {
2787
+		$this->set_address($value);
2788 2788
     }
2789 2789
 
2790 2790
     /**
@@ -2793,8 +2793,8 @@  discard block
 block discarded – undo
2793 2793
 	 * @since 1.0.19
2794 2794
 	 * @param  int|bool $value confirmed.
2795 2795
 	 */
2796
-	public function set_is_viewed( $value ) {
2797
-		$this->set_prop( 'is_viewed', $value );
2796
+	public function set_is_viewed($value) {
2797
+		$this->set_prop('is_viewed', $value);
2798 2798
 	}
2799 2799
 
2800 2800
 	/**
@@ -2803,8 +2803,8 @@  discard block
 block discarded – undo
2803 2803
 	 * @since 1.0.19
2804 2804
 	 * @param  string $value email recipients.
2805 2805
 	 */
2806
-	public function set_email_cc( $value ) {
2807
-		$this->set_prop( 'email_cc', $value );
2806
+	public function set_email_cc($value) {
2807
+		$this->set_prop('email_cc', $value);
2808 2808
 	}
2809 2809
 
2810 2810
 	/**
@@ -2813,9 +2813,9 @@  discard block
 block discarded – undo
2813 2813
 	 * @since 1.0.19
2814 2814
 	 * @param  string $value template.
2815 2815
 	 */
2816
-	public function set_template( $value ) {
2817
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2818
-			$this->set_prop( 'template', $value );
2816
+	public function set_template($value) {
2817
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2818
+			$this->set_prop('template', $value);
2819 2819
 		}
2820 2820
 	}
2821 2821
 
@@ -2826,8 +2826,8 @@  discard block
 block discarded – undo
2826 2826
 	 * @param  string $value source.
2827 2827
 	 * @deprecated
2828 2828
 	 */
2829
-	public function created_via( $value ) {
2830
-		$this->set_created_via( sanitize_text_field( $value ) );
2829
+	public function created_via($value) {
2830
+		$this->set_created_via(sanitize_text_field($value));
2831 2831
 	}
2832 2832
 
2833 2833
 	/**
@@ -2836,8 +2836,8 @@  discard block
 block discarded – undo
2836 2836
 	 * @since 1.0.19
2837 2837
 	 * @param  string $value source.
2838 2838
 	 */
2839
-	public function set_created_via( $value ) {
2840
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2839
+	public function set_created_via($value) {
2840
+		$this->set_prop('created_via', sanitize_text_field($value));
2841 2841
 	}
2842 2842
 
2843 2843
 	/**
@@ -2846,8 +2846,8 @@  discard block
 block discarded – undo
2846 2846
 	 * @since 1.0.19
2847 2847
 	 * @param  int|bool $value confirmed.
2848 2848
 	 */
2849
-	public function set_address_confirmed( $value ) {
2850
-		$this->set_prop( 'address_confirmed', $value );
2849
+	public function set_address_confirmed($value) {
2850
+		$this->set_prop('address_confirmed', $value);
2851 2851
     }
2852 2852
 
2853 2853
     /**
@@ -2856,8 +2856,8 @@  discard block
 block discarded – undo
2856 2856
 	 * @since 1.0.19
2857 2857
 	 * @param  int|bool $value confirmed.
2858 2858
 	 */
2859
-	public function set_user_address_confirmed( $value ) {
2860
-		$this->set_address_confirmed( $value );
2859
+	public function set_user_address_confirmed($value) {
2860
+		$this->set_address_confirmed($value);
2861 2861
     }
2862 2862
 
2863 2863
     /**
@@ -2866,8 +2866,8 @@  discard block
 block discarded – undo
2866 2866
 	 * @since 1.0.19
2867 2867
 	 * @param  int|bool $value confirmed.
2868 2868
 	 */
2869
-	public function set_customer_address_confirmed( $value ) {
2870
-		$this->set_address_confirmed( $value );
2869
+	public function set_customer_address_confirmed($value) {
2870
+		$this->set_address_confirmed($value);
2871 2871
     }
2872 2872
 
2873 2873
     /**
@@ -2876,13 +2876,13 @@  discard block
 block discarded – undo
2876 2876
 	 * @since 1.0.19
2877 2877
 	 * @param  float $value shipping amount.
2878 2878
 	 */
2879
-	public function set_shipping( $value ) {
2879
+	public function set_shipping($value) {
2880 2880
 
2881
-		if ( ! is_numeric( $value ) ) {
2882
-			return $this->set_prop( 'shipping', null );
2881
+		if (!is_numeric($value)) {
2882
+			return $this->set_prop('shipping', null);
2883 2883
 		}
2884 2884
 
2885
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2885
+		$this->set_prop('shipping', max(0, floatval($value)));
2886 2886
 	}
2887 2887
 
2888 2888
 	/**
@@ -2891,8 +2891,8 @@  discard block
 block discarded – undo
2891 2891
 	 * @since 1.0.19
2892 2892
 	 * @param  float $value sub total.
2893 2893
 	 */
2894
-	public function set_subtotal( $value ) {
2895
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2894
+	public function set_subtotal($value) {
2895
+		$this->set_prop('subtotal', max(0, $value));
2896 2896
 	}
2897 2897
 
2898 2898
 	/**
@@ -2901,8 +2901,8 @@  discard block
 block discarded – undo
2901 2901
 	 * @since 1.0.19
2902 2902
 	 * @param  float $value sub total.
2903 2903
 	 */
2904
-	public function set_total( $value ) {
2905
-		$this->set_prop( 'total', max( 0, $value ) );
2904
+	public function set_total($value) {
2905
+		$this->set_prop('total', max(0, $value));
2906 2906
     }
2907 2907
 
2908 2908
     /**
@@ -2911,8 +2911,8 @@  discard block
 block discarded – undo
2911 2911
 	 * @since 1.0.19
2912 2912
 	 * @param  float $value discount total.
2913 2913
 	 */
2914
-	public function set_total_discount( $value ) {
2915
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2914
+	public function set_total_discount($value) {
2915
+		$this->set_prop('total_discount', max(0, $value));
2916 2916
     }
2917 2917
 
2918 2918
     /**
@@ -2921,8 +2921,8 @@  discard block
 block discarded – undo
2921 2921
 	 * @since 1.0.19
2922 2922
 	 * @param  float $value discount total.
2923 2923
 	 */
2924
-	public function set_discount( $value ) {
2925
-		$this->set_total_discount( $value );
2924
+	public function set_discount($value) {
2925
+		$this->set_total_discount($value);
2926 2926
     }
2927 2927
 
2928 2928
     /**
@@ -2931,8 +2931,8 @@  discard block
 block discarded – undo
2931 2931
 	 * @since 1.0.19
2932 2932
 	 * @param  float $value tax total.
2933 2933
 	 */
2934
-	public function set_total_tax( $value ) {
2935
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2934
+	public function set_total_tax($value) {
2935
+		$this->set_prop('total_tax', max(0, $value));
2936 2936
     }
2937 2937
 
2938 2938
     /**
@@ -2941,8 +2941,8 @@  discard block
 block discarded – undo
2941 2941
 	 * @since 1.0.19
2942 2942
 	 * @param  float $value tax total.
2943 2943
 	 */
2944
-	public function set_tax_total( $value ) {
2945
-		$this->set_total_tax( $value );
2944
+	public function set_tax_total($value) {
2945
+		$this->set_total_tax($value);
2946 2946
     }
2947 2947
 
2948 2948
     /**
@@ -2951,8 +2951,8 @@  discard block
 block discarded – undo
2951 2951
 	 * @since 1.0.19
2952 2952
 	 * @param  float $value fees total.
2953 2953
 	 */
2954
-	public function set_total_fees( $value ) {
2955
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2954
+	public function set_total_fees($value) {
2955
+		$this->set_prop('total_fees', max(0, $value));
2956 2956
     }
2957 2957
 
2958 2958
     /**
@@ -2961,8 +2961,8 @@  discard block
 block discarded – undo
2961 2961
 	 * @since 1.0.19
2962 2962
 	 * @param  float $value fees total.
2963 2963
 	 */
2964
-	public function set_fees_total( $value ) {
2965
-		$this->set_total_fees( $value );
2964
+	public function set_fees_total($value) {
2965
+		$this->set_total_fees($value);
2966 2966
     }
2967 2967
 
2968 2968
     /**
@@ -2971,13 +2971,13 @@  discard block
 block discarded – undo
2971 2971
 	 * @since 1.0.19
2972 2972
 	 * @param  array $value fees.
2973 2973
 	 */
2974
-	public function set_fees( $value ) {
2974
+	public function set_fees($value) {
2975 2975
 
2976
-		if ( ! is_array( $value ) ) {
2976
+		if (!is_array($value)) {
2977 2977
 			$value = array();
2978 2978
 		}
2979 2979
 
2980
-		$this->set_prop( 'fees', $value );
2980
+		$this->set_prop('fees', $value);
2981 2981
 
2982 2982
     }
2983 2983
 
@@ -2987,13 +2987,13 @@  discard block
 block discarded – undo
2987 2987
 	 * @since 1.0.19
2988 2988
 	 * @param  array $value taxes.
2989 2989
 	 */
2990
-	public function set_taxes( $value ) {
2990
+	public function set_taxes($value) {
2991 2991
 
2992
-		if ( ! is_array( $value ) ) {
2992
+		if (!is_array($value)) {
2993 2993
 			$value = array();
2994 2994
 		}
2995 2995
 
2996
-		$this->set_prop( 'taxes', $value );
2996
+		$this->set_prop('taxes', $value);
2997 2997
 
2998 2998
     }
2999 2999
 
@@ -3003,13 +3003,13 @@  discard block
 block discarded – undo
3003 3003
 	 * @since 1.0.19
3004 3004
 	 * @param  array $value discounts.
3005 3005
 	 */
3006
-	public function set_discounts( $value ) {
3006
+	public function set_discounts($value) {
3007 3007
 
3008
-		if ( ! is_array( $value ) ) {
3008
+		if (!is_array($value)) {
3009 3009
 			$value = array();
3010 3010
 		}
3011 3011
 
3012
-		$this->set_prop( 'discounts', $value );
3012
+		$this->set_prop('discounts', $value);
3013 3013
     }
3014 3014
 
3015 3015
     /**
@@ -3018,19 +3018,19 @@  discard block
 block discarded – undo
3018 3018
 	 * @since 1.0.19
3019 3019
 	 * @param  GetPaid_Form_Item[] $value items.
3020 3020
 	 */
3021
-	public function set_items( $value ) {
3021
+	public function set_items($value) {
3022 3022
 
3023 3023
         // Remove existing items.
3024
-        $this->set_prop( 'items', array() );
3024
+        $this->set_prop('items', array());
3025 3025
 		$this->recurring_item = null;
3026 3026
 
3027 3027
         // Ensure that we have an array.
3028
-        if ( ! is_array( $value ) ) {
3028
+        if (!is_array($value)) {
3029 3029
             return;
3030 3030
         }
3031 3031
 
3032
-        foreach ( $value as $item ) {
3033
-            $this->add_item( $item );
3032
+        foreach ($value as $item) {
3033
+            $this->add_item($item);
3034 3034
         }
3035 3035
 
3036 3036
     }
@@ -3041,8 +3041,8 @@  discard block
 block discarded – undo
3041 3041
 	 * @since 1.0.19
3042 3042
 	 * @param  int $value payment form.
3043 3043
 	 */
3044
-	public function set_payment_form( $value ) {
3045
-		$this->set_prop( 'payment_form', $value );
3044
+	public function set_payment_form($value) {
3045
+		$this->set_prop('payment_form', $value);
3046 3046
     }
3047 3047
 
3048 3048
     /**
@@ -3051,8 +3051,8 @@  discard block
 block discarded – undo
3051 3051
 	 * @since 1.0.19
3052 3052
 	 * @param  string $value submission id.
3053 3053
 	 */
3054
-	public function set_submission_id( $value ) {
3055
-		$this->set_prop( 'submission_id', $value );
3054
+	public function set_submission_id($value) {
3055
+		$this->set_prop('submission_id', $value);
3056 3056
     }
3057 3057
 
3058 3058
     /**
@@ -3061,8 +3061,8 @@  discard block
 block discarded – undo
3061 3061
 	 * @since 1.0.19
3062 3062
 	 * @param  string $value discount code.
3063 3063
 	 */
3064
-	public function set_discount_code( $value ) {
3065
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3064
+	public function set_discount_code($value) {
3065
+		$this->set_prop('discount_code', sanitize_text_field($value));
3066 3066
     }
3067 3067
 
3068 3068
     /**
@@ -3071,8 +3071,8 @@  discard block
 block discarded – undo
3071 3071
 	 * @since 1.0.19
3072 3072
 	 * @param  string $value gateway.
3073 3073
 	 */
3074
-	public function set_gateway( $value ) {
3075
-		$this->set_prop( 'gateway', $value );
3074
+	public function set_gateway($value) {
3075
+		$this->set_prop('gateway', $value);
3076 3076
     }
3077 3077
 
3078 3078
     /**
@@ -3081,9 +3081,9 @@  discard block
 block discarded – undo
3081 3081
 	 * @since 1.0.19
3082 3082
 	 * @param  string $value transaction id.
3083 3083
 	 */
3084
-	public function set_transaction_id( $value ) {
3085
-		if ( ! empty( $value ) ) {
3086
-			$this->set_prop( 'transaction_id', $value );
3084
+	public function set_transaction_id($value) {
3085
+		if (!empty($value)) {
3086
+			$this->set_prop('transaction_id', $value);
3087 3087
 		}
3088 3088
     }
3089 3089
 
@@ -3093,8 +3093,8 @@  discard block
 block discarded – undo
3093 3093
 	 * @since 1.0.19
3094 3094
 	 * @param  string $value currency id.
3095 3095
 	 */
3096
-	public function set_currency( $value ) {
3097
-		$this->set_prop( 'currency', $value );
3096
+	public function set_currency($value) {
3097
+		$this->set_prop('currency', $value);
3098 3098
     }
3099 3099
 
3100 3100
 	/**
@@ -3103,8 +3103,8 @@  discard block
 block discarded – undo
3103 3103
 	 * @since 1.0.19
3104 3104
 	 * @param  bool $value value.
3105 3105
 	 */
3106
-	public function set_disable_taxes( $value ) {
3107
-		$this->set_prop( 'disable_taxes', (bool) $value );
3106
+	public function set_disable_taxes($value) {
3107
+		$this->set_prop('disable_taxes', (bool) $value);
3108 3108
 	}
3109 3109
 
3110 3110
     /**
@@ -3113,8 +3113,8 @@  discard block
 block discarded – undo
3113 3113
 	 * @since 1.0.19
3114 3114
 	 * @param  string $value subscription id.
3115 3115
 	 */
3116
-	public function set_subscription_id( $value ) {
3117
-		$this->set_prop( 'subscription_id', $value );
3116
+	public function set_subscription_id($value) {
3117
+		$this->set_prop('subscription_id', $value);
3118 3118
 	}
3119 3119
 
3120 3120
 	/**
@@ -3123,8 +3123,8 @@  discard block
 block discarded – undo
3123 3123
 	 * @since 1.0.19
3124 3124
 	 * @param  string $value subscription id.
3125 3125
 	 */
3126
-	public function set_remote_subscription_id( $value ) {
3127
-		$this->set_prop( 'remote_subscription_id', $value );
3126
+	public function set_remote_subscription_id($value) {
3127
+		$this->set_prop('remote_subscription_id', $value);
3128 3128
     }
3129 3129
 
3130 3130
     /*
@@ -3141,28 +3141,28 @@  discard block
 block discarded – undo
3141 3141
      */
3142 3142
     public function is_parent() {
3143 3143
         $parent = $this->get_parent_id();
3144
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3144
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3145 3145
     }
3146 3146
 
3147 3147
     /**
3148 3148
      * Checks if this is a renewal invoice.
3149 3149
      */
3150 3150
     public function is_renewal() {
3151
-        return $this->is_recurring() && ! $this->is_parent();
3151
+        return $this->is_recurring() && !$this->is_parent();
3152 3152
     }
3153 3153
 
3154 3154
     /**
3155 3155
      * Checks if this is a recurring invoice.
3156 3156
      */
3157 3157
     public function is_recurring() {
3158
-        return ! empty( $this->recurring_item );
3158
+        return !empty($this->recurring_item);
3159 3159
     }
3160 3160
 
3161 3161
     /**
3162 3162
      * Checks if this is a taxable invoice.
3163 3163
      */
3164 3164
     public function is_taxable() {
3165
-        return ! $this->get_disable_taxes();
3165
+        return !$this->get_disable_taxes();
3166 3166
 	}
3167 3167
 
3168 3168
 	/**
@@ -3176,45 +3176,45 @@  discard block
 block discarded – undo
3176 3176
 	 * Checks to see if the invoice requires payment.
3177 3177
 	 */
3178 3178
 	public function is_free() {
3179
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3179
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3180 3180
 
3181
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3181
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3182 3182
 			$is_free = false;
3183 3183
 		}
3184 3184
 
3185
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3185
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3186 3186
     }
3187 3187
 
3188 3188
     /**
3189 3189
      * Checks if the invoice is paid.
3190 3190
      */
3191 3191
     public function is_paid() {
3192
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3193
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3192
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3193
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3194 3194
 	}
3195 3195
 
3196 3196
 	/**
3197 3197
      * Checks if the invoice needs payment.
3198 3198
      */
3199 3199
 	public function needs_payment() {
3200
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3201
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3200
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3201
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3202 3202
     }
3203 3203
 
3204 3204
 	/**
3205 3205
      * Checks if the invoice is refunded.
3206 3206
      */
3207 3207
 	public function is_refunded() {
3208
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3209
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3208
+        $is_refunded = $this->has_status('wpi-refunded');
3209
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3210 3210
 	}
3211 3211
 
3212 3212
 	/**
3213 3213
      * Checks if the invoice is held.
3214 3214
      */
3215 3215
 	public function is_held() {
3216
-        $is_held = $this->has_status( 'wpi-onhold' );
3217
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3216
+        $is_held = $this->has_status('wpi-onhold');
3217
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3218 3218
 	}
3219 3219
 
3220 3220
 	/**
@@ -3222,30 +3222,30 @@  discard block
 block discarded – undo
3222 3222
      */
3223 3223
 	public function is_due() {
3224 3224
 		$due_date = $this->get_due_date();
3225
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3225
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3226 3226
 	}
3227 3227
 
3228 3228
 	/**
3229 3229
      * Checks if the invoice is draft.
3230 3230
      */
3231 3231
 	public function is_draft() {
3232
-        return $this->has_status( 'draft, auto-draft' );
3232
+        return $this->has_status('draft, auto-draft');
3233 3233
 	}
3234 3234
 
3235 3235
     /**
3236 3236
      * Checks if the invoice has a given status.
3237 3237
      */
3238
-    public function has_status( $status ) {
3239
-        $status = wpinv_parse_list( $status );
3240
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3238
+    public function has_status($status) {
3239
+        $status = wpinv_parse_list($status);
3240
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3241 3241
 	}
3242 3242
 
3243 3243
 	/**
3244 3244
      * Checks if the invoice is of a given type.
3245 3245
      */
3246
-    public function is_type( $type ) {
3247
-        $type = wpinv_parse_list( $type );
3248
-        return in_array( $this->get_type(), $type );
3246
+    public function is_type($type) {
3247
+        $type = wpinv_parse_list($type);
3248
+        return in_array($this->get_type(), $type);
3249 3249
     }
3250 3250
 
3251 3251
     /**
@@ -3277,8 +3277,8 @@  discard block
 block discarded – undo
3277 3277
      *
3278 3278
      */
3279 3279
 	public function is_initial_free() {
3280
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3281
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3280
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3281
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3282 3282
     }
3283 3283
 
3284 3284
 	/**
@@ -3288,11 +3288,11 @@  discard block
 block discarded – undo
3288 3288
     public function item_has_free_trial() {
3289 3289
 
3290 3290
         // Ensure we have a recurring item.
3291
-        if ( ! $this->is_recurring() ) {
3291
+        if (!$this->is_recurring()) {
3292 3292
             return false;
3293 3293
         }
3294 3294
 
3295
-        $item = $this->get_recurring( true );
3295
+        $item = $this->get_recurring(true);
3296 3296
         return $item->has_free_trial();
3297 3297
 	}
3298 3298
 
@@ -3300,7 +3300,7 @@  discard block
 block discarded – undo
3300 3300
      * Check if the free trial is a result of a discount.
3301 3301
      */
3302 3302
     public function is_free_trial_from_discount() {
3303
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3303
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3304 3304
 	}
3305 3305
 
3306 3306
 	/**
@@ -3308,12 +3308,12 @@  discard block
 block discarded – undo
3308 3308
      */
3309 3309
     public function discount_first_payment_only() {
3310 3310
 
3311
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3312
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3311
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3312
+        if (!$discount->exists() || !$this->is_recurring()) {
3313 3313
             return true;
3314 3314
         }
3315 3315
 
3316
-        return ! $discount->get_is_recurring();
3316
+        return !$discount->get_is_recurring();
3317 3317
     }
3318 3318
 
3319 3319
     /*
@@ -3331,23 +3331,23 @@  discard block
 block discarded – undo
3331 3331
      * @param GetPaid_Form_Item|array $item
3332 3332
      * @return WP_Error|Bool
3333 3333
      */
3334
-    public function add_item( $item ) {
3334
+    public function add_item($item) {
3335 3335
 
3336
-		if ( is_array( $item ) ) {
3337
-			$item = $this->process_array_item( $item );
3336
+		if (is_array($item)) {
3337
+			$item = $this->process_array_item($item);
3338 3338
 		}
3339 3339
 
3340
-		if ( is_numeric( $item ) ) {
3341
-			$item = new GetPaid_Form_Item( $item );
3340
+		if (is_numeric($item)) {
3341
+			$item = new GetPaid_Form_Item($item);
3342 3342
 		}
3343 3343
 
3344 3344
         // Make sure that it is available for purchase.
3345
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3346
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3345
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3346
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3347 3347
         }
3348 3348
 
3349 3349
         // Do we have a recurring item?
3350
-		if ( $item->is_recurring() ) {
3350
+		if ($item->is_recurring()) {
3351 3351
 			$this->recurring_item = $item->get_id();
3352 3352
         }
3353 3353
 
@@ -3355,9 +3355,9 @@  discard block
 block discarded – undo
3355 3355
         $item->invoice_id = (int) $this->get_id();
3356 3356
 
3357 3357
 		// Remove duplicates.
3358
-		$this->remove_item( $item->get_id() );
3358
+		$this->remove_item($item->get_id());
3359 3359
 
3360
-		if ( 0 == $item->get_quantity() ) {
3360
+		if (0 == $item->get_quantity()) {
3361 3361
 			return;
3362 3362
 		}
3363 3363
 
@@ -3367,7 +3367,7 @@  discard block
 block discarded – undo
3367 3367
 		// Add new item.
3368 3368
         $items[] = $item;
3369 3369
 
3370
-        $this->set_prop( 'items', $items );
3370
+        $this->set_prop('items', $items);
3371 3371
 
3372 3372
 		return true;
3373 3373
 	}
@@ -3378,26 +3378,26 @@  discard block
 block discarded – undo
3378 3378
 	 * @since 1.0.19
3379 3379
 	 * @return GetPaid_Form_Item
3380 3380
 	 */
3381
-	protected function process_array_item( $array ) {
3381
+	protected function process_array_item($array) {
3382 3382
 
3383
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3384
-		$item    = new GetPaid_Form_Item( $item_id );
3383
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3384
+		$item    = new GetPaid_Form_Item($item_id);
3385 3385
 
3386 3386
 		// Set item data.
3387
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3388
-			if ( isset( $array[ "item_$key" ] ) ) {
3387
+		foreach (array('name', 'price', 'description') as $key) {
3388
+			if (isset($array["item_$key"])) {
3389 3389
 				$method = "set_$key";
3390
-				$item->$method( $array[ "item_$key" ] );
3390
+				$item->$method($array["item_$key"]);
3391 3391
 			}
3392 3392
 		}
3393 3393
 
3394
-		if ( isset( $array['quantity'] ) ) {
3395
-			$item->set_quantity( $array['quantity'] );
3394
+		if (isset($array['quantity'])) {
3395
+			$item->set_quantity($array['quantity']);
3396 3396
 		}
3397 3397
 
3398 3398
 		// Set item meta.
3399
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3400
-			$item->set_item_meta( $array['meta'] );
3399
+		if (isset($array['meta']) && is_array($array['meta'])) {
3400
+			$item->set_item_meta($array['meta']);
3401 3401
 		}
3402 3402
 
3403 3403
 		return $item;
@@ -3410,10 +3410,10 @@  discard block
 block discarded – undo
3410 3410
 	 * @since 1.0.19
3411 3411
 	 * @return GetPaid_Form_Item|null
3412 3412
 	 */
3413
-	public function get_item( $item_id ) {
3413
+	public function get_item($item_id) {
3414 3414
 
3415
-		foreach ( $this->get_items() as $item ) {
3416
-			if ( (int) $item_id == $item->get_id() ) {
3415
+		foreach ($this->get_items() as $item) {
3416
+			if ((int) $item_id == $item->get_id()) {
3417 3417
 				return $item;
3418 3418
 			}
3419 3419
 		}
@@ -3426,16 +3426,16 @@  discard block
 block discarded – undo
3426 3426
 	 *
3427 3427
 	 * @since 1.0.19
3428 3428
 	 */
3429
-	public function remove_item( $item_id ) {
3429
+	public function remove_item($item_id) {
3430 3430
 		$items   = $this->get_items();
3431 3431
 		$item_id = (int) $item_id;
3432 3432
 
3433
-		foreach ( $items as $index => $item ) {
3434
-			if ( (int) $item_id == $item->get_id() ) {
3435
-				unset( $items[ $index ] );
3436
-				$this->set_prop( 'items', $items );
3433
+		foreach ($items as $index => $item) {
3434
+			if ((int) $item_id == $item->get_id()) {
3435
+				unset($items[$index]);
3436
+				$this->set_prop('items', $items);
3437 3437
 
3438
-				if ( $item_id == $this->recurring_item ) {
3438
+				if ($item_id == $this->recurring_item) {
3439 3439
 					$this->recurring_item = null;
3440 3440
 				}
3441 3441
 }
@@ -3449,11 +3449,11 @@  discard block
 block discarded – undo
3449 3449
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3450 3450
 	 * @since 1.0.19
3451 3451
 	 */
3452
-    public function add_fee( $fee ) {
3452
+    public function add_fee($fee) {
3453 3453
 
3454 3454
 		$fees                 = $this->get_fees();
3455
-		$fees[ $fee['name'] ] = $fee;
3456
-		$this->set_prop( 'fees', $fees );
3455
+		$fees[$fee['name']] = $fee;
3456
+		$this->set_prop('fees', $fees);
3457 3457
 
3458 3458
     }
3459 3459
 
@@ -3462,9 +3462,9 @@  discard block
 block discarded – undo
3462 3462
 	 *
3463 3463
 	 * @since 1.0.19
3464 3464
 	 */
3465
-	public function get_fee( $fee ) {
3465
+	public function get_fee($fee) {
3466 3466
         $fees = $this->get_fees();
3467
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3467
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3468 3468
     }
3469 3469
 
3470 3470
     /**
@@ -3472,11 +3472,11 @@  discard block
 block discarded – undo
3472 3472
 	 *
3473 3473
 	 * @since 1.0.19
3474 3474
 	 */
3475
-	public function remove_fee( $fee ) {
3475
+	public function remove_fee($fee) {
3476 3476
         $fees = $this->get_fees();
3477
-        if ( isset( $fees[ $fee ] ) ) {
3478
-            unset( $fees[ $fee ] );
3479
-            $this->set_prop( 'fees', $fees );
3477
+        if (isset($fees[$fee])) {
3478
+            unset($fees[$fee]);
3479
+            $this->set_prop('fees', $fees);
3480 3480
         }
3481 3481
     }
3482 3482
 
@@ -3486,11 +3486,11 @@  discard block
 block discarded – undo
3486 3486
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3487 3487
 	 * @since 1.0.19
3488 3488
 	 */
3489
-	public function add_discount( $discount ) {
3489
+	public function add_discount($discount) {
3490 3490
 
3491 3491
 		$discounts = $this->get_discounts();
3492
-		$discounts[ $discount['name'] ] = $discount;
3493
-		$this->set_prop( 'discounts', $discounts );
3492
+		$discounts[$discount['name']] = $discount;
3493
+		$this->set_prop('discounts', $discounts);
3494 3494
 
3495 3495
 	}
3496 3496
 
@@ -3500,15 +3500,15 @@  discard block
 block discarded – undo
3500 3500
 	 * @since 1.0.19
3501 3501
 	 * @return float
3502 3502
 	 */
3503
-	public function get_discount( $discount = false ) {
3503
+	public function get_discount($discount = false) {
3504 3504
 
3505 3505
 		// Backwards compatibility.
3506
-		if ( empty( $discount ) ) {
3506
+		if (empty($discount)) {
3507 3507
 			return $this->get_total_discount();
3508 3508
 		}
3509 3509
 
3510 3510
         $discounts = $this->get_discounts();
3511
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3511
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3512 3512
     }
3513 3513
 
3514 3514
     /**
@@ -3516,15 +3516,15 @@  discard block
 block discarded – undo
3516 3516
 	 *
3517 3517
 	 * @since 1.0.19
3518 3518
 	 */
3519
-	public function remove_discount( $discount ) {
3519
+	public function remove_discount($discount) {
3520 3520
         $discounts = $this->get_discounts();
3521
-        if ( isset( $discounts[ $discount ] ) ) {
3522
-            unset( $discounts[ $discount ] );
3523
-            $this->set_prop( 'discounts', $discounts );
3521
+        if (isset($discounts[$discount])) {
3522
+            unset($discounts[$discount]);
3523
+            $this->set_prop('discounts', $discounts);
3524 3524
         }
3525 3525
 
3526
-		if ( 'discount_code' == $discount ) {
3527
-			foreach ( $this->get_items() as $item ) {
3526
+		if ('discount_code' == $discount) {
3527
+			foreach ($this->get_items() as $item) {
3528 3528
 				$item->item_discount           = 0;
3529 3529
 				$item->recurring_item_discount = 0;
3530 3530
 			}
@@ -3537,12 +3537,12 @@  discard block
 block discarded – undo
3537 3537
      *
3538 3538
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3539 3539
      */
3540
-    public function add_tax( $tax ) {
3541
-        if ( $this->is_taxable() ) {
3540
+    public function add_tax($tax) {
3541
+        if ($this->is_taxable()) {
3542 3542
 
3543
-            $taxes                 = $this->get_taxes();
3544
-			$taxes[ $tax['name'] ] = $tax;
3545
-			$this->set_prop( 'taxes', $tax );
3543
+            $taxes = $this->get_taxes();
3544
+			$taxes[$tax['name']] = $tax;
3545
+			$this->set_prop('taxes', $tax);
3546 3546
 
3547 3547
         }
3548 3548
     }
@@ -3552,29 +3552,29 @@  discard block
 block discarded – undo
3552 3552
 	 *
3553 3553
 	 * @since 1.0.19
3554 3554
 	 */
3555
-	public function get_tax( $tax = null ) {
3555
+	public function get_tax($tax = null) {
3556 3556
 
3557 3557
 		// Backwards compatibility.
3558
-		if ( empty( $tax ) ) {
3558
+		if (empty($tax)) {
3559 3559
 			return $this->get_total_tax();
3560 3560
 		}
3561 3561
 
3562 3562
         $taxes = $this->get_taxes();
3563
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3563
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3564 3564
     }
3565 3565
 
3566
-	public function get_tax_total_by_name( $name ) {
3567
-		if ( $name && 0 === strpos( $name, 'tax__' ) ) {
3568
-			$name = str_replace( 'tax__', '', $name );
3566
+	public function get_tax_total_by_name($name) {
3567
+		if ($name && 0 === strpos($name, 'tax__')) {
3568
+			$name = str_replace('tax__', '', $name);
3569 3569
 		}
3570 3570
 
3571
-		if ( empty( $name ) ) {
3571
+		if (empty($name)) {
3572 3572
 			return 0;
3573 3573
 		}
3574 3574
 
3575
-		$tax = $this->get_tax( $name );
3575
+		$tax = $this->get_tax($name);
3576 3576
 
3577
-		if ( empty( $tax ) ) {
3577
+		if (empty($tax)) {
3578 3578
 			return 0;
3579 3579
 		}
3580 3580
 
@@ -3586,18 +3586,18 @@  discard block
 block discarded – undo
3586 3586
 	 *
3587 3587
 	 * @since 2.8.8
3588 3588
 	 */
3589
-	public function get_tax_item_name( $tax_key, $tax_item, $suffix = '' ) {
3590
-		$tax_name = _x( 'Tax', 'Tax name', 'invoicing' );
3589
+	public function get_tax_item_name($tax_key, $tax_item, $suffix = '') {
3590
+		$tax_name = _x('Tax', 'Tax name', 'invoicing');
3591 3591
 
3592
-		if ( ! empty( $tax_item ) && is_array( $tax_item ) && ! empty( $tax_item['name'] ) ) {
3593
-			$tax_name = __( $tax_item['name'], 'invoicing' );
3592
+		if (!empty($tax_item) && is_array($tax_item) && !empty($tax_item['name'])) {
3593
+			$tax_name = __($tax_item['name'], 'invoicing');
3594 3594
 		}
3595 3595
 
3596
-		if ( $suffix ) {
3596
+		if ($suffix) {
3597 3597
 			$tax_name .= $suffix;
3598 3598
 		}
3599 3599
 
3600
-		return apply_filters( 'wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix );
3600
+		return apply_filters('wpinv_invoice_get_tax_name', $tax_name, $this, $tax_key, $tax_item, $suffix);
3601 3601
 	}
3602 3602
 
3603 3603
 	/**
@@ -3605,44 +3605,44 @@  discard block
 block discarded – undo
3605 3605
 	 *
3606 3606
 	 * @since 2.8.8
3607 3607
 	 */
3608
-	public function get_tax_item_amount( $tax_key, $tax_item, $with_currency = false ) {
3609
-		$tax_amount = $this->get_tax_total_by_name( $tax_key );
3608
+	public function get_tax_item_amount($tax_key, $tax_item, $with_currency = false) {
3609
+		$tax_amount = $this->get_tax_total_by_name($tax_key);
3610 3610
 
3611
-		if ( $with_currency ) {
3612
-			$tax_amount = wpinv_price( $tax_amount, $this->get_currency() );
3611
+		if ($with_currency) {
3612
+			$tax_amount = wpinv_price($tax_amount, $this->get_currency());
3613 3613
 		}
3614 3614
 
3615
-		return apply_filters( 'wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency );
3615
+		return apply_filters('wpinv_invoice_get_tax_amount', $tax_amount, $this, $tax_item, $with_currency);
3616 3616
 	}
3617 3617
 
3618
-	public function get_item_tax_name( $percentage = true, $sep = ' + ' ) {
3618
+	public function get_item_tax_name($percentage = true, $sep = ' + ') {
3619 3619
 		$taxes = $this->get_taxes();
3620 3620
 
3621
-		if ( ! empty( $taxes ) && is_array( $taxes ) && count( $taxes ) == 1 && wpinv_display_individual_tax_rates() ) {
3621
+		if (!empty($taxes) && is_array($taxes) && count($taxes) == 1 && wpinv_display_individual_tax_rates()) {
3622 3622
 			$names = array();
3623 3623
 
3624
-			foreach ( $taxes as $key => $tax ) {
3625
-				if ( ! empty( $tax ) && ! empty( $tax['name'] ) ) {
3626
-					$name = __( $tax['name'], 'invoicing' );
3624
+			foreach ($taxes as $key => $tax) {
3625
+				if (!empty($tax) && !empty($tax['name'])) {
3626
+					$name = __($tax['name'], 'invoicing');
3627 3627
 
3628 3628
 					$names[] = $name;
3629 3629
 				}
3630 3630
 			}
3631 3631
 
3632
-			if ( ! empty( $names ) ) {
3633
-				$names = array_unique( $names );
3632
+			if (!empty($names)) {
3633
+				$names = array_unique($names);
3634 3634
 
3635
-				$tax_name = implode( $sep, $names );
3635
+				$tax_name = implode($sep, $names);
3636 3636
 			}
3637 3637
 
3638
-			if ( $percentage ) {
3639
-				$tax_name = wp_sprintf( _x( '%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing' ), $tax_name );
3638
+			if ($percentage) {
3639
+				$tax_name = wp_sprintf(_x('%s (%%)', 'Tax name with %. Ex: Tax (%)', 'invoicing'), $tax_name);
3640 3640
 			}
3641 3641
 		} else {
3642
-			$tax_name = $percentage ? __( 'Tax (%)', 'invoicing' ) : _x( 'Tax', 'Tax name', 'invoicing' );
3642
+			$tax_name = $percentage ? __('Tax (%)', 'invoicing') : _x('Tax', 'Tax name', 'invoicing');
3643 3643
 		}
3644 3644
 
3645
-		return apply_filters( 'wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep );
3645
+		return apply_filters('wpinv_invoice_get_item_tax_name', $tax_name, $this, $percentage, $sep);
3646 3646
 	}
3647 3647
 
3648 3648
     /**
@@ -3650,11 +3650,11 @@  discard block
 block discarded – undo
3650 3650
 	 *
3651 3651
 	 * @since 1.0.19
3652 3652
 	 */
3653
-	public function remove_tax( $tax ) {
3653
+	public function remove_tax($tax) {
3654 3654
         $taxes = $this->get_taxes();
3655
-        if ( isset( $taxes[ $tax ] ) ) {
3656
-            unset( $taxes[ $tax ] );
3657
-            $this->set_prop( 'taxes', $taxes );
3655
+        if (isset($taxes[$tax])) {
3656
+            unset($taxes[$tax]);
3657
+            $this->set_prop('taxes', $taxes);
3658 3658
         }
3659 3659
     }
3660 3660
 
@@ -3665,22 +3665,22 @@  discard block
 block discarded – undo
3665 3665
 	 * @return float The recalculated subtotal
3666 3666
 	 */
3667 3667
 	public function recalculate_subtotal() {
3668
-        $items     = $this->get_items();
3668
+        $items = $this->get_items();
3669 3669
 		$subtotal  = 0;
3670 3670
 		$recurring = 0;
3671 3671
 
3672
-        foreach ( $items as $item ) {
3673
-			$subtotal  += $item->get_sub_total( 'edit' );
3674
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3672
+        foreach ($items as $item) {
3673
+			$subtotal  += $item->get_sub_total('edit');
3674
+			$recurring += $item->get_recurring_sub_total('edit');
3675 3675
         }
3676 3676
 
3677
-		if ( wpinv_prices_include_tax() ) {
3678
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3679
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3677
+		if (wpinv_prices_include_tax()) {
3678
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3679
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3680 3680
 		}
3681 3681
 
3682 3682
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3683
-		$this->set_subtotal( $current );
3683
+		$this->set_subtotal($current);
3684 3684
 
3685 3685
 		$this->totals['subtotal'] = array(
3686 3686
 			'initial'   => $subtotal,
@@ -3698,12 +3698,12 @@  discard block
 block discarded – undo
3698 3698
 	 */
3699 3699
 	public function recalculate_total_discount() {
3700 3700
 		// Fix renewal invoice amount when tax + recurring discount applied.
3701
-		if ( $this->is_renewal() && $this->get_discount_code() ) {
3701
+		if ($this->is_renewal() && $this->get_discount_code()) {
3702 3702
 			// Maybe recalculate discount (Pre-GetPaid Fix).
3703
-			$discount = new WPInv_Discount( $this->get_discount_code() );
3703
+			$discount = new WPInv_Discount($this->get_discount_code());
3704 3704
 
3705
-			if ( $discount->exists() && $discount->is_recurring() ) {
3706
-				getpaid_calculate_invoice_discount( $this, $discount );
3705
+			if ($discount->exists() && $discount->is_recurring()) {
3706
+				getpaid_calculate_invoice_discount($this, $discount);
3707 3707
 			}
3708 3708
 		}
3709 3709
 
@@ -3711,14 +3711,14 @@  discard block
 block discarded – undo
3711 3711
 		$discount  = 0;
3712 3712
 		$recurring = 0;
3713 3713
 
3714
-        foreach ( $discounts as $data ) {
3715
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3716
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3714
+        foreach ($discounts as $data) {
3715
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3716
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3717 3717
 		}
3718 3718
 
3719 3719
 		$current = $this->is_renewal() ? $recurring : $discount;
3720 3720
 
3721
-		$this->set_total_discount( $current );
3721
+		$this->set_total_discount($current);
3722 3722
 
3723 3723
 		$this->totals['discount'] = array(
3724 3724
 			'initial'   => $discount,
@@ -3739,13 +3739,13 @@  discard block
 block discarded – undo
3739 3739
 
3740 3740
 		// Maybe disable taxes.
3741 3741
 		$vat_number = $this->get_vat_number();
3742
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3742
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3743 3743
 
3744
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' === wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3744
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' === wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3745 3745
 			$skip_tax = false;
3746 3746
 		}
3747 3747
 
3748
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) {
3748
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3749 3749
 
3750 3750
 			$this->totals['tax'] = array(
3751 3751
 				'initial'   => 0,
@@ -3754,36 +3754,36 @@  discard block
 block discarded – undo
3754 3754
 
3755 3755
 			$this->tax_rate = 0;
3756 3756
 
3757
-			$this->set_taxes( array() );
3757
+			$this->set_taxes(array());
3758 3758
 			$current = 0;
3759 3759
 		} else {
3760 3760
 
3761 3761
 			$item_taxes = array();
3762 3762
 
3763
-			foreach ( $this->get_items() as $item ) {
3764
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3765
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3766
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3767
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3768
-				foreach ( $taxes as $name => $amount ) {
3769
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3770
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3771
-
3772
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3773
-						$item_taxes[ $name ] = $tax;
3763
+			foreach ($this->get_items() as $item) {
3764
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3765
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3766
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3767
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3768
+				foreach ($taxes as $name => $amount) {
3769
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3770
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3771
+
3772
+					if (!isset($item_taxes[$name])) {
3773
+						$item_taxes[$name] = $tax;
3774 3774
 						continue;
3775 3775
 					}
3776 3776
 
3777
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3778
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3777
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3778
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3779 3779
 
3780 3780
 				}
3781 3781
 			}
3782 3782
 
3783
-			$this->set_taxes( $item_taxes );
3783
+			$this->set_taxes($item_taxes);
3784 3784
 
3785
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3786
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3785
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3786
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3787 3787
 
3788 3788
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3789 3789
 
@@ -3794,7 +3794,7 @@  discard block
 block discarded – undo
3794 3794
 
3795 3795
 		}
3796 3796
 
3797
-		$this->set_total_tax( $current );
3797
+		$this->set_total_tax($current);
3798 3798
 
3799 3799
 		return $current;
3800 3800
 
@@ -3811,20 +3811,20 @@  discard block
 block discarded – undo
3811 3811
 		$fee       = 0;
3812 3812
 		$recurring = 0;
3813 3813
 
3814
-        foreach ( $fees as $data ) {
3815
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3816
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3814
+        foreach ($fees as $data) {
3815
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3816
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3817 3817
 		}
3818 3818
 
3819 3819
 		$current = $this->is_renewal() ? $recurring : $fee;
3820
-		$this->set_total_fees( $current );
3820
+		$this->set_total_fees($current);
3821 3821
 
3822 3822
 		$this->totals['fee'] = array(
3823 3823
 			'initial'   => $fee,
3824 3824
 			'recurring' => $recurring,
3825 3825
 		);
3826 3826
 
3827
-        $this->set_total_fees( $fee );
3827
+        $this->set_total_fees($fee);
3828 3828
         return $current;
3829 3829
     }
3830 3830
 
@@ -3839,7 +3839,7 @@  discard block
 block discarded – undo
3839 3839
         $this->recalculate_total_discount();
3840 3840
 		$this->recalculate_total_tax();
3841 3841
 		$this->recalculate_subtotal();
3842
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3842
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3843 3843
 		return $this->get_total();
3844 3844
 	}
3845 3845
 
@@ -3848,7 +3848,7 @@  discard block
 block discarded – undo
3848 3848
 	 */
3849 3849
     public function recalculate_totals() {
3850 3850
         $this->recalculate_total();
3851
-        $this->save( true );
3851
+        $this->save(true);
3852 3852
         return $this;
3853 3853
     }
3854 3854
 
@@ -3866,8 +3866,8 @@  discard block
 block discarded – undo
3866 3866
 	 * @return int|false The new note's ID on success, false on failure.
3867 3867
      *
3868 3868
      */
3869
-    public function add_system_note( $note ) {
3870
-		return $this->add_note( $note, false, false, true );
3869
+    public function add_system_note($note) {
3870
+		return $this->add_note($note, false, false, true);
3871 3871
 	}
3872 3872
 
3873 3873
     /**
@@ -3877,10 +3877,10 @@  discard block
 block discarded – undo
3877 3877
 	 * @return int|false The new note's ID on success, false on failure.
3878 3878
      *
3879 3879
      */
3880
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3880
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3881 3881
 
3882 3882
         // Bail if no note specified or this invoice is not yet saved.
3883
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3883
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3884 3884
             return false;
3885 3885
         }
3886 3886
 
@@ -3888,23 +3888,23 @@  discard block
 block discarded – undo
3888 3888
 		$author_email = '[email protected]';
3889 3889
 
3890 3890
 		// If this is an admin comment or it has been added by the user.
3891
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3892
-			$user         = get_user_by( 'id', get_current_user_id() );
3891
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3892
+			$user = get_user_by('id', get_current_user_id());
3893 3893
             $author       = $user->display_name;
3894 3894
             $author_email = $user->user_email;
3895 3895
 		}
3896 3896
 
3897
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3897
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3898 3898
 
3899 3899
 	}
3900 3900
 
3901 3901
 	/**
3902 3902
      * Generates a unique key for the invoice.
3903 3903
      */
3904
-    public function generate_key( $string = '' ) {
3905
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3904
+    public function generate_key($string = '') {
3905
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3906 3906
         return strtolower(
3907
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3907
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3908 3908
         );
3909 3909
     }
3910 3910
 
@@ -3914,11 +3914,11 @@  discard block
 block discarded – undo
3914 3914
     public function generate_number() {
3915 3915
         $number = $this->get_id();
3916 3916
 
3917
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3918
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3917
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3918
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3919 3919
         }
3920 3920
 
3921
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3921
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3922 3922
 
3923 3923
 	}
3924 3924
 
@@ -3931,55 +3931,55 @@  discard block
 block discarded – undo
3931 3931
 		// Reset status transition variable.
3932 3932
 		$this->status_transition = false;
3933 3933
 
3934
-		if ( $status_transition ) {
3934
+		if ($status_transition) {
3935 3935
 			try {
3936 3936
 
3937 3937
 				// Fire a hook for the status change.
3938
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3938
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3939 3939
 
3940 3940
 				// @deprecated this is deprecated and will be removed in the future.
3941
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3941
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3942 3942
 
3943
-				if ( ! empty( $status_transition['from'] ) ) {
3943
+				if (!empty($status_transition['from'])) {
3944 3944
 
3945 3945
 					/* translators: 1: old invoice status 2: new invoice status */
3946
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) );
3946
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
3947 3947
 
3948 3948
 					// Fire another hook.
3949
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3950
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3949
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3950
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3951 3951
 
3952 3952
 					// @deprecated this is deprecated and will be removed in the future.
3953
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3953
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3954 3954
 
3955 3955
 					// Note the transition occurred.
3956
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3956
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3957 3957
 
3958 3958
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3959 3959
 					if (
3960
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3961
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3960
+						in_array($status_transition['from'], array('wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3961
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3962 3962
 					) {
3963
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3963
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3964 3964
 					}
3965 3965
 
3966 3966
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3967 3967
 					if (
3968
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3969
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3968
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3969
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'pending', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3970 3970
 					) {
3971
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3971
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3972 3972
 					}
3973 3973
 				} else {
3974 3974
 					/* translators: %s: new invoice status */
3975
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) );
3975
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3976 3976
 
3977 3977
 					// Note the transition occurred.
3978
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3978
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3979 3979
 
3980 3980
 				}
3981
-			} catch ( Exception $e ) {
3982
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3981
+			} catch (Exception $e) {
3982
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3983 3983
 			}
3984 3984
 		}
3985 3985
 	}
@@ -3987,13 +3987,13 @@  discard block
 block discarded – undo
3987 3987
 	/**
3988 3988
 	 * Updates an invoice status.
3989 3989
 	 */
3990
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3990
+	public function update_status($new_status = false, $note = '', $manual = false) {
3991 3991
 
3992 3992
 		// Fires before updating a status.
3993
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3993
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3994 3994
 
3995 3995
 		// Update the status.
3996
-		$this->set_status( $new_status, $note, $manual );
3996
+		$this->set_status($new_status, $note, $manual);
3997 3997
 
3998 3998
 		// Save the order.
3999 3999
 		return $this->save();
@@ -4004,18 +4004,18 @@  discard block
 block discarded – undo
4004 4004
 	 * @deprecated
4005 4005
 	 */
4006 4006
 	public function refresh_item_ids() {
4007
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
4008
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
4007
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
4008
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
4009 4009
 	}
4010 4010
 
4011 4011
 	/**
4012 4012
 	 * @deprecated
4013 4013
 	 */
4014
-	public function update_items( $temp = false ) {
4014
+	public function update_items($temp = false) {
4015 4015
 
4016
-		$this->set_items( $this->get_items() );
4016
+		$this->set_items($this->get_items());
4017 4017
 
4018
-		if ( ! $temp ) {
4018
+		if (!$temp) {
4019 4019
 			$this->save();
4020 4020
 		}
4021 4021
 
@@ -4029,11 +4029,11 @@  discard block
 block discarded – undo
4029 4029
 
4030 4030
         $discount_code = $this->get_discount_code();
4031 4031
 
4032
-        if ( empty( $discount_code ) ) {
4032
+        if (empty($discount_code)) {
4033 4033
             return false;
4034 4034
         }
4035 4035
 
4036
-        $discount = wpinv_get_discount_obj( $discount_code );
4036
+        $discount = wpinv_get_discount_obj($discount_code);
4037 4037
 
4038 4038
         // Ensure it is active.
4039 4039
         return $discount->exists();
@@ -4044,7 +4044,7 @@  discard block
 block discarded – undo
4044 4044
 	 * Refunds an invoice.
4045 4045
 	 */
4046 4046
     public function refund() {
4047
-		$this->set_status( 'wpi-refunded' );
4047
+		$this->set_status('wpi-refunded');
4048 4048
         $this->save();
4049 4049
 	}
4050 4050
 
@@ -4053,53 +4053,53 @@  discard block
 block discarded – undo
4053 4053
 	 *
4054 4054
 	 * @param string $transaction_id
4055 4055
 	 */
4056
-    public function mark_paid( $transaction_id = null, $note = '' ) {
4056
+    public function mark_paid($transaction_id = null, $note = '') {
4057 4057
 
4058 4058
 		// Set the transaction id.
4059
-		if ( empty( $transaction_id ) ) {
4060
-			$transaction_id = $this->generate_key( 'trans_' );
4059
+		if (empty($transaction_id)) {
4060
+			$transaction_id = $this->generate_key('trans_');
4061 4061
 		}
4062 4062
 
4063
-		if ( ! $this->get_transaction_id() ) {
4064
-			$this->set_transaction_id( $transaction_id );
4063
+		if (!$this->get_transaction_id()) {
4064
+			$this->set_transaction_id($transaction_id);
4065 4065
 		}
4066 4066
 
4067
-		if ( $this->is_paid() && 'wpi-processing' !== $this->get_status() ) {
4067
+		if ($this->is_paid() && 'wpi-processing' !== $this->get_status()) {
4068 4068
 			return $this->save();
4069 4069
 		}
4070 4070
 
4071 4071
 		// Set the completed date.
4072
-		$this->set_date_completed( current_time( 'mysql' ) );
4072
+		$this->set_date_completed(current_time('mysql'));
4073 4073
 
4074 4074
 		// Set the new status.
4075
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
4076
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
4075
+		$gateway = sanitize_text_field($this->get_gateway_title());
4076
+		if ($this->is_renewal() || !$this->is_parent()) {
4077 4077
 
4078
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
4079
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4078
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
4079
+			$_note = $_note . empty($note) ? '' : " ($note)";
4080 4080
 
4081
-			if ( 'none' == $this->get_gateway() ) {
4081
+			if ('none' == $this->get_gateway()) {
4082 4082
 				$_note = $note;
4083 4083
 			}
4084 4084
 
4085
-			$this->set_status( 'wpi-renewal', $_note );
4085
+			$this->set_status('wpi-renewal', $_note);
4086 4086
 
4087 4087
 		} else {
4088 4088
 
4089
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
4090
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
4089
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
4090
+			$_note = $_note . empty($note) ? '' : " ($note)";
4091 4091
 
4092
-			if ( 'none' == $this->get_gateway() ) {
4092
+			if ('none' == $this->get_gateway()) {
4093 4093
 				$_note = $note;
4094 4094
 			}
4095 4095
 
4096
-			$this->set_status( 'publish', $_note );
4096
+			$this->set_status('publish', $_note);
4097 4097
 
4098 4098
 		}
4099 4099
 
4100 4100
 		// Set checkout mode.
4101
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
4102
-		$this->set_mode( $mode );
4101
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
4102
+		$this->set_mode($mode);
4103 4103
 
4104 4104
 		// Save the invoice.
4105 4105
         $this->save();
@@ -4124,16 +4124,16 @@  discard block
 block discarded – undo
4124 4124
      * Clears the subscription's cache.
4125 4125
      */
4126 4126
     public function clear_cache() {
4127
-		if ( $this->get_key() ) {
4128
-			wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4127
+		if ($this->get_key()) {
4128
+			wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4129 4129
 		}
4130 4130
 
4131
-		if ( $this->get_number() ) {
4132
-			wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4131
+		if ($this->get_number()) {
4132
+			wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4133 4133
 		}
4134 4134
 
4135
-		if ( $this->get_transaction_id() ) {
4136
-			wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4135
+		if ($this->get_transaction_id()) {
4136
+			wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4137 4137
 		}
4138 4138
 	}
4139 4139
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +282 added lines, -282 removed lines patch added patch discarded remove patch
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Bank_Transfer_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'bank_transfer';
21 21
 
22
-	/**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
27
-	protected $supports = array(
28
-		'subscription',
29
-		'addons',
30
-		'single_subscription_group',
31
-		'multiple_subscription_groups',
32
-		'subscription_date_change',
33
-		'subscription_bill_times_change',
34
-	);
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array(
28
+        'subscription',
29
+        'addons',
30
+        'single_subscription_group',
31
+        'multiple_subscription_groups',
32
+        'subscription_date_change',
33
+        'subscription_bill_times_change',
34
+    );
35
+
36
+    /**
37
+     * Payment method order.
38
+     *
39
+     * @var int
40
+     */
41
+    public $order = 8;
35 42
 
36 43
     /**
37
-	 * Payment method order.
38
-	 *
39
-	 * @var int
40
-	 */
41
-	public $order = 8;
42
-
43
-	/**
44
-	 * Bank transfer instructions.
45
-	 */
46
-	public $instructions;
47
-
48
-	/**
49
-	 * Locale array.
50
-	 */
51
-	public $locale;
44
+     * Bank transfer instructions.
45
+     */
46
+    public $instructions;
52 47
 
53 48
     /**
54
-	 * Class constructor.
55
-	 */
56
-	public function __construct() {
49
+     * Locale array.
50
+     */
51
+    public $locale;
52
+
53
+    /**
54
+     * Class constructor.
55
+     */
56
+    public function __construct() {
57 57
         parent::__construct();
58 58
 
59 59
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -61,24 +61,24 @@  discard block
 block discarded – undo
61 61
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62 62
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
64
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
70 70
 
71 71
     }
72 72
 
73 73
     /**
74
-	 * Process Payment.
75
-	 *
76
-	 * @param WPInv_Invoice $invoice Invoice.
77
-	 * @param array $submission_data Posted checkout fields.
78
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
-	 * @return array
80
-	 */
81
-	public function process_payment( $invoice, $submission_data, $submission ) {
74
+     * Process Payment.
75
+     *
76
+     * @param WPInv_Invoice $invoice Invoice.
77
+     * @param array $submission_data Posted checkout fields.
78
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79
+     * @return array
80
+     */
81
+    public function process_payment( $invoice, $submission_data, $submission ) {
82 82
 
83 83
         // Add a transaction id.
84 84
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -99,66 +99,66 @@  discard block
 block discarded – undo
99 99
     }
100 100
 
101 101
     /**
102
-	 * Output for the order received page.
103
-	 *
104
-	 * @param WPInv_Invoice $invoice Invoice.
105
-	 */
106
-	public function thankyou_page( $invoice ) {
102
+     * Output for the order received page.
103
+     *
104
+     * @param WPInv_Invoice $invoice Invoice.
105
+     */
106
+    public function thankyou_page( $invoice ) {
107 107
 
108 108
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
109 109
 
110
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
110
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
111 111
 
112 112
             if ( ! empty( $this->instructions ) ) {
113 113
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
114
-			}
114
+            }
115 115
 
116
-			$this->bank_details( $invoice );
116
+            $this->bank_details( $invoice );
117 117
 
118
-			echo '</div>';
118
+            echo '</div>';
119 119
 
120 120
         }
121 121
 
122
-	}
122
+    }
123 123
 
124 124
     /**
125
-	 * Add content to the WPI emails.
126
-	 *
127
-	 * @param WPInv_Invoice $invoice Invoice.
128
-	 * @param string     $email_type Email format: plain text or HTML.
129
-	 * @param bool     $sent_to_admin Sent to admin.
130
-	 */
131
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
125
+     * Add content to the WPI emails.
126
+     *
127
+     * @param WPInv_Invoice $invoice Invoice.
128
+     * @param string     $email_type Email format: plain text or HTML.
129
+     * @param bool     $sent_to_admin Sent to admin.
130
+     */
131
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
132 132
 
133
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
133
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
134 134
 
135
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
135
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
136 136
 
137
-			if ( $this->instructions ) {
138
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
137
+            if ( $this->instructions ) {
138
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
139 139
             }
140 140
 
141
-			$this->bank_details( $invoice );
141
+            $this->bank_details( $invoice );
142 142
 
143
-			echo '</div>';
143
+            echo '</div>';
144 144
 
145
-		}
145
+        }
146 146
 
147 147
     }
148 148
 
149 149
     /**
150
-	 * Get bank details and place into a list format.
151
-	 *
152
-	 * @param WPInv_Invoice $invoice Invoice.
153
-	 */
154
-	protected function bank_details( $invoice ) {
150
+     * Get bank details and place into a list format.
151
+     *
152
+     * @param WPInv_Invoice $invoice Invoice.
153
+     */
154
+    protected function bank_details( $invoice ) {
155 155
 
156
-		// Get the invoice country and country $locale.
157
-		$country = $invoice->get_country();
158
-		$locale  = $this->get_country_locale();
156
+        // Get the invoice country and country $locale.
157
+        $country = $invoice->get_country();
158
+        $locale  = $this->get_country_locale();
159 159
 
160
-		// Get shortcode label in the $locale array and use appropriate one.
161
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
160
+        // Get shortcode label in the $locale array and use appropriate one.
161
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
162 162
 
163 163
         $bank_fields = array(
164 164
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 
178 178
             if ( ! empty( $value ) ) {
179 179
                 $bank_info[ $field ] = array(
180
-					'label' => $label,
181
-					'value' => $value,
182
-				);
180
+                    'label' => $label,
181
+                    'value' => $value,
182
+                );
183 183
             }
184
-		}
184
+        }
185 185
 
186 186
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
187 187
 
@@ -189,139 +189,139 @@  discard block
 block discarded – undo
189 189
             return;
190 190
         }
191 191
 
192
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
192
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
193 193
 
194
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
194
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
195 195
 
196
-		foreach ( $bank_info as $key => $data ) {
197
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
-		}
196
+        foreach ( $bank_info as $key => $data ) {
197
+            echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
198
+        }
199 199
 
200
-		echo '</table>';
200
+        echo '</table>';
201 201
 
202 202
     }
203 203
 
204 204
     /**
205
-	 * Get country locale if localized.
206
-	 *
207
-	 * @return array
208
-	 */
209
-	public function get_country_locale() {
210
-
211
-		if ( empty( $this->locale ) ) {
212
-
213
-			// Locale information to be used - only those that are not 'Sort Code'.
214
-			$this->locale = apply_filters(
215
-				'getpaid_get_bank_transfer_locale',
216
-				array(
217
-					'AU' => array(
218
-						'sortcode' => array(
219
-							'label' => __( 'BSB', 'invoicing' ),
220
-						),
221
-					),
222
-					'CA' => array(
223
-						'sortcode' => array(
224
-							'label' => __( 'Bank transit number', 'invoicing' ),
225
-						),
226
-					),
227
-					'IN' => array(
228
-						'sortcode' => array(
229
-							'label' => __( 'IFSC', 'invoicing' ),
230
-						),
231
-					),
232
-					'IT' => array(
233
-						'sortcode' => array(
234
-							'label' => __( 'Branch sort', 'invoicing' ),
235
-						),
236
-					),
237
-					'NZ' => array(
238
-						'sortcode' => array(
239
-							'label' => __( 'Bank code', 'invoicing' ),
240
-						),
241
-					),
242
-					'SE' => array(
243
-						'sortcode' => array(
244
-							'label' => __( 'Bank code', 'invoicing' ),
245
-						),
246
-					),
247
-					'US' => array(
248
-						'sortcode' => array(
249
-							'label' => __( 'Routing number', 'invoicing' ),
250
-						),
251
-					),
252
-					'ZA' => array(
253
-						'sortcode' => array(
254
-							'label' => __( 'Branch code', 'invoicing' ),
255
-						),
256
-					),
257
-				)
258
-			);
259
-
260
-		}
261
-
262
-		return $this->locale;
263
-
264
-	}
265
-
266
-	/**
267
-	 * Filters the gateway settings.
268
-	 *
269
-	 * @param array $admin_settings
270
-	 */
271
-	public function admin_settings( $admin_settings ) {
205
+     * Get country locale if localized.
206
+     *
207
+     * @return array
208
+     */
209
+    public function get_country_locale() {
210
+
211
+        if ( empty( $this->locale ) ) {
212
+
213
+            // Locale information to be used - only those that are not 'Sort Code'.
214
+            $this->locale = apply_filters(
215
+                'getpaid_get_bank_transfer_locale',
216
+                array(
217
+                    'AU' => array(
218
+                        'sortcode' => array(
219
+                            'label' => __( 'BSB', 'invoicing' ),
220
+                        ),
221
+                    ),
222
+                    'CA' => array(
223
+                        'sortcode' => array(
224
+                            'label' => __( 'Bank transit number', 'invoicing' ),
225
+                        ),
226
+                    ),
227
+                    'IN' => array(
228
+                        'sortcode' => array(
229
+                            'label' => __( 'IFSC', 'invoicing' ),
230
+                        ),
231
+                    ),
232
+                    'IT' => array(
233
+                        'sortcode' => array(
234
+                            'label' => __( 'Branch sort', 'invoicing' ),
235
+                        ),
236
+                    ),
237
+                    'NZ' => array(
238
+                        'sortcode' => array(
239
+                            'label' => __( 'Bank code', 'invoicing' ),
240
+                        ),
241
+                    ),
242
+                    'SE' => array(
243
+                        'sortcode' => array(
244
+                            'label' => __( 'Bank code', 'invoicing' ),
245
+                        ),
246
+                    ),
247
+                    'US' => array(
248
+                        'sortcode' => array(
249
+                            'label' => __( 'Routing number', 'invoicing' ),
250
+                        ),
251
+                    ),
252
+                    'ZA' => array(
253
+                        'sortcode' => array(
254
+                            'label' => __( 'Branch code', 'invoicing' ),
255
+                        ),
256
+                    ),
257
+                )
258
+            );
259
+
260
+        }
261
+
262
+        return $this->locale;
263
+
264
+    }
265
+
266
+    /**
267
+     * Filters the gateway settings.
268
+     *
269
+     * @param array $admin_settings
270
+     */
271
+    public function admin_settings( $admin_settings ) {
272 272
 
273 273
         $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
274
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
274
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
275 275
 
276
-		$locale  = $this->get_country_locale();
276
+        $locale  = $this->get_country_locale();
277 277
 
278
-		// Get sortcode label in the $locale array and use appropriate one.
279
-		$country  = wpinv_default_billing_country();
280
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
278
+        // Get sortcode label in the $locale array and use appropriate one.
279
+        $country  = wpinv_default_billing_country();
280
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
281 281
 
282
-		$admin_settings['bank_transfer_ac_name'] = array(
282
+        $admin_settings['bank_transfer_ac_name'] = array(
283 283
             'type' => 'text',
284 284
             'id'   => 'bank_transfer_ac_name',
285 285
             'name' => __( 'Account Name', 'invoicing' ),
286
-		);
286
+        );
287 287
 
288
-		$admin_settings['bank_transfer_ac_no'] = array(
288
+        $admin_settings['bank_transfer_ac_no'] = array(
289 289
             'type' => 'text',
290 290
             'id'   => 'bank_transfer_ac_no',
291 291
             'name' => __( 'Account Number', 'invoicing' ),
292
-		);
292
+        );
293 293
 
294
-		$admin_settings['bank_transfer_bank_name'] = array(
294
+        $admin_settings['bank_transfer_bank_name'] = array(
295 295
             'type' => 'text',
296 296
             'id'   => 'bank_transfer_bank_name',
297 297
             'name' => __( 'Bank Name', 'invoicing' ),
298
-		);
298
+        );
299 299
 
300
-		$admin_settings['bank_transfer_ifsc'] = array(
300
+        $admin_settings['bank_transfer_ifsc'] = array(
301 301
             'type' => 'text',
302 302
             'id'   => 'bank_transfer_ifsc',
303 303
             'name' => __( 'IFSC Code', 'invoicing' ),
304
-		);
304
+        );
305 305
 
306
-		$admin_settings['bank_transfer_iban'] = array(
306
+        $admin_settings['bank_transfer_iban'] = array(
307 307
             'type' => 'text',
308 308
             'id'   => 'bank_transfer_iban',
309 309
             'name' => __( 'IBAN', 'invoicing' ),
310
-		);
310
+        );
311 311
 
312
-		$admin_settings['bank_transfer_bic'] = array(
312
+        $admin_settings['bank_transfer_bic'] = array(
313 313
             'type' => 'text',
314 314
             'id'   => 'bank_transfer_bic',
315 315
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
316
-		);
316
+        );
317 317
 
318
-		$admin_settings['bank_transfer_sort_code'] = array(
319
-			'type' => 'text',
320
-			'id'   => 'bank_transfer_sort_code',
321
-			'name' => $sortcode,
322
-		);
318
+        $admin_settings['bank_transfer_sort_code'] = array(
319
+            'type' => 'text',
320
+            'id'   => 'bank_transfer_sort_code',
321
+            'name' => $sortcode,
322
+        );
323 323
 
324
-		$admin_settings['bank_transfer_info'] = array(
324
+        $admin_settings['bank_transfer_info'] = array(
325 325
             'id'   => 'bank_transfer_info',
326 326
             'name' => __( 'Instructions', 'invoicing' ),
327 327
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
             'rows' => 5,
332 332
         );
333 333
 
334
-		return $admin_settings;
335
-	}
334
+        return $admin_settings;
335
+    }
336 336
 
337
-	/**
338
-	 * Processes invoice addons.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice
341
-	 * @param GetPaid_Form_Item[] $items
342
-	 * @return WPInv_Invoice
343
-	 */
344
-	public function process_addons( $invoice, $items ) {
337
+    /**
338
+     * Processes invoice addons.
339
+     *
340
+     * @param WPInv_Invoice $invoice
341
+     * @param GetPaid_Form_Item[] $items
342
+     * @return WPInv_Invoice
343
+     */
344
+    public function process_addons( $invoice, $items ) {
345 345
 
346 346
         foreach ( $items as $item ) {
347 347
             $invoice->add_item( $item );
@@ -349,98 +349,98 @@  discard block
 block discarded – undo
349 349
 
350 350
         $invoice->recalculate_total();
351 351
         $invoice->save();
352
-	}
353
-
354
-	/**
355
-	 * (Maybe) renews a bank transfer subscription profile.
356
-	 *
357
-	 *
358
-	 * @param WPInv_Subscription $subscription
359
-	 */
360
-	public function maybe_renew_subscription( $subscription, $parent_invoice ) {
361
-		// Ensure its our subscription && it's active.
362
-		if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
363
-			add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
364
-
365
-			$invoice = $subscription->create_payment();
366
-
367
-			if ( ! empty( $invoice ) ) {
368
-				$is_logged_in = is_user_logged_in();
369
-
370
-				// Cron run.
371
-				if ( ! $is_logged_in ) {
372
-					$note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
373
-
374
-					$invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
375
-				}
376
-			}
377
-
378
-			remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
379
-		}
380
-	}
381
-
382
-	/**
383
-	 * Process a bank transfer payment.
384
-	 *
385
-	 *
352
+    }
353
+
354
+    /**
355
+     * (Maybe) renews a bank transfer subscription profile.
356
+     *
357
+     *
358
+     * @param WPInv_Subscription $subscription
359
+     */
360
+    public function maybe_renew_subscription( $subscription, $parent_invoice ) {
361
+        // Ensure its our subscription && it's active.
362
+        if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
363
+            add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
364
+
365
+            $invoice = $subscription->create_payment();
366
+
367
+            if ( ! empty( $invoice ) ) {
368
+                $is_logged_in = is_user_logged_in();
369
+
370
+                // Cron run.
371
+                if ( ! $is_logged_in ) {
372
+                    $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
373
+
374
+                    $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
375
+                }
376
+            }
377
+
378
+            remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
379
+        }
380
+    }
381
+
382
+    /**
383
+     * Process a bank transfer payment.
384
+     *
385
+     *
386 386
      * @param WPInv_Invoice $invoice
387
-	 */
388
-	public function invoice_paid( $invoice ) {
389
-
390
-		// Abort if not paid by bank transfer.
391
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
392
-			return;
393
-		}
394
-
395
-		// Is it a parent payment?
396
-		if ( 0 == $invoice->get_parent_id() ) {
397
-
398
-			// (Maybe) activate subscriptions.
399
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
400
-
401
-			if ( ! empty( $subscriptions ) ) {
402
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
403
-
404
-				foreach ( $subscriptions as $subscription ) {
405
-					if ( $subscription->exists() ) {
406
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
407
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
408
-
409
-						$subscription->set_next_renewal_date( $expiry );
410
-						$subscription->set_date_created( current_time( 'mysql' ) );
411
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
412
-						$subscription->activate();
413
-					}
414
-				}
415
-			}
416
-		} else {
417
-
418
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
419
-
420
-			// Renew the subscription.
421
-			if ( $subscription && $subscription->exists() ) {
422
-				$subscription->add_payment( array(), $invoice );
423
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
424
-			}
425
-		}
387
+     */
388
+    public function invoice_paid( $invoice ) {
389
+
390
+        // Abort if not paid by bank transfer.
391
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
392
+            return;
393
+        }
394
+
395
+        // Is it a parent payment?
396
+        if ( 0 == $invoice->get_parent_id() ) {
397
+
398
+            // (Maybe) activate subscriptions.
399
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
400
+
401
+            if ( ! empty( $subscriptions ) ) {
402
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
403
+
404
+                foreach ( $subscriptions as $subscription ) {
405
+                    if ( $subscription->exists() ) {
406
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
407
+                        $expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
408
+
409
+                        $subscription->set_next_renewal_date( $expiry );
410
+                        $subscription->set_date_created( current_time( 'mysql' ) );
411
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
412
+                        $subscription->activate();
413
+                    }
414
+                }
415
+            }
416
+        } else {
417
+
418
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
419
+
420
+            // Renew the subscription.
421
+            if ( $subscription && $subscription->exists() ) {
422
+                $subscription->add_payment( array(), $invoice );
423
+                $subscription->renew( strtotime( $invoice->get_date_created() ) );
424
+            }
425
+        }
426 426
 
427 427
     }
428 428
 
429
-	/**
430
-	 * Force created from payment false to allow email for auto renewal generation invoice.
431
-	 *
432
-	 * @since 2.8.11
433
-	 *
434
-	 * @param bool $is_payment_form_invoice True when invoice created via payment form else false.
435
-	 * @param int  $invoice Invoice ID.
436
-	 * @return bool True when invoice created via payment form else false.
437
-	 */
438
-	public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
439
-		if ( $is_payment_form_invoice ) {
440
-			$is_payment_form_invoice = false;
441
-		}
442
-
443
-		return $is_payment_form_invoice;
444
-	}
429
+    /**
430
+     * Force created from payment false to allow email for auto renewal generation invoice.
431
+     *
432
+     * @since 2.8.11
433
+     *
434
+     * @param bool $is_payment_form_invoice True when invoice created via payment form else false.
435
+     * @param int  $invoice Invoice ID.
436
+     * @return bool True when invoice created via payment form else false.
437
+     */
438
+    public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
439
+        if ( $is_payment_form_invoice ) {
440
+            $is_payment_form_invoice = false;
441
+        }
442
+
443
+        return $is_payment_form_invoice;
444
+    }
445 445
 
446 446
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Bank transfer Payment Gateway class.
@@ -56,17 +56,17 @@  discard block
 block discarded – undo
56 56
 	public function __construct() {
57 57
         parent::__construct();
58 58
 
59
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
60
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
61
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
62
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
59
+        $this->title                = __('Direct bank transfer', 'invoicing');
60
+        $this->method_title         = __('Bank transfer', 'invoicing');
61
+        $this->checkout_button_text = __('Proceed', 'invoicing');
62
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
63 63
 
64
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
65
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
66
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
67
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
68
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 );
69
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
64
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
65
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
66
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
67
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
68
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 12, 2);
69
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
70 70
 
71 71
     }
72 72
 
@@ -78,23 +78,23 @@  discard block
 block discarded – undo
78 78
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
79 79
 	 * @return array
80 80
 	 */
81
-	public function process_payment( $invoice, $submission_data, $submission ) {
81
+	public function process_payment($invoice, $submission_data, $submission) {
82 82
 
83 83
         // Add a transaction id.
84
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
84
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
85 85
 
86 86
         // Set it as pending payment.
87
-        if ( ! $invoice->needs_payment() ) {
87
+        if (!$invoice->needs_payment()) {
88 88
             $invoice->mark_paid();
89
-        } elseif ( ! $invoice->is_paid() ) {
90
-            $invoice->set_status( 'wpi-onhold' );
89
+        } elseif (!$invoice->is_paid()) {
90
+            $invoice->set_status('wpi-onhold');
91 91
         }
92 92
 
93 93
         // Save it.
94 94
         $invoice->save();
95 95
 
96 96
         // Send to the success page.
97
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
97
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
98 98
 
99 99
     }
100 100
 
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 *
104 104
 	 * @param WPInv_Invoice $invoice Invoice.
105 105
 	 */
106
-	public function thankyou_page( $invoice ) {
106
+	public function thankyou_page($invoice) {
107 107
 
108
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
108
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
109 109
 
110 110
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
111 111
 
112
-            if ( ! empty( $this->instructions ) ) {
113
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
112
+            if (!empty($this->instructions)) {
113
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
114 114
 			}
115 115
 
116
-			$this->bank_details( $invoice );
116
+			$this->bank_details($invoice);
117 117
 
118 118
 			echo '</div>';
119 119
 
@@ -128,17 +128,17 @@  discard block
 block discarded – undo
128 128
 	 * @param string     $email_type Email format: plain text or HTML.
129 129
 	 * @param bool     $sent_to_admin Sent to admin.
130 130
 	 */
131
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
131
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
132 132
 
133
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
133
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
134 134
 
135 135
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
136 136
 
137
-			if ( $this->instructions ) {
138
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
137
+			if ($this->instructions) {
138
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
139 139
             }
140 140
 
141
-			$this->bank_details( $invoice );
141
+			$this->bank_details($invoice);
142 142
 
143 143
 			echo '</div>';
144 144
 
@@ -151,50 +151,50 @@  discard block
 block discarded – undo
151 151
 	 *
152 152
 	 * @param WPInv_Invoice $invoice Invoice.
153 153
 	 */
154
-	protected function bank_details( $invoice ) {
154
+	protected function bank_details($invoice) {
155 155
 
156 156
 		// Get the invoice country and country $locale.
157 157
 		$country = $invoice->get_country();
158 158
 		$locale  = $this->get_country_locale();
159 159
 
160 160
 		// Get shortcode label in the $locale array and use appropriate one.
161
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
161
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
162 162
 
163 163
         $bank_fields = array(
164
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
165
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
166
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
167
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
168
-            'iban'      => __( 'IBAN', 'invoicing' ),
169
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
164
+            'ac_name'   => __('Account Name', 'invoicing'),
165
+            'ac_no'     => __('Account Number', 'invoicing'),
166
+            'bank_name' => __('Bank Name', 'invoicing'),
167
+            'ifsc'      => __('IFSC code', 'invoicing'),
168
+            'iban'      => __('IBAN', 'invoicing'),
169
+            'bic'       => __('BIC/Swift code', 'invoicing'),
170 170
             'sort_code' => $sortcode,
171 171
         );
172 172
 
173 173
         $bank_info = array();
174 174
 
175
-        foreach ( $bank_fields as $field => $label ) {
176
-            $value = $this->get_option( $field );
175
+        foreach ($bank_fields as $field => $label) {
176
+            $value = $this->get_option($field);
177 177
 
178
-            if ( ! empty( $value ) ) {
179
-                $bank_info[ $field ] = array(
178
+            if (!empty($value)) {
179
+                $bank_info[$field] = array(
180 180
 					'label' => $label,
181 181
 					'value' => $value,
182 182
 				);
183 183
             }
184 184
 		}
185 185
 
186
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
186
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice);
187 187
 
188
-        if ( empty( $bank_info ) ) {
188
+        if (empty($bank_info)) {
189 189
             return;
190 190
         }
191 191
 
192
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
192
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL;
193 193
 
194 194
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
195 195
 
196
-		foreach ( $bank_info as $key => $data ) {
197
-			echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL;
196
+		foreach ($bank_info as $key => $data) {
197
+			echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL;
198 198
 		}
199 199
 
200 200
 		echo '</table>';
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 	 */
209 209
 	public function get_country_locale() {
210 210
 
211
-		if ( empty( $this->locale ) ) {
211
+		if (empty($this->locale)) {
212 212
 
213 213
 			// Locale information to be used - only those that are not 'Sort Code'.
214 214
 			$this->locale = apply_filters(
@@ -216,42 +216,42 @@  discard block
 block discarded – undo
216 216
 				array(
217 217
 					'AU' => array(
218 218
 						'sortcode' => array(
219
-							'label' => __( 'BSB', 'invoicing' ),
219
+							'label' => __('BSB', 'invoicing'),
220 220
 						),
221 221
 					),
222 222
 					'CA' => array(
223 223
 						'sortcode' => array(
224
-							'label' => __( 'Bank transit number', 'invoicing' ),
224
+							'label' => __('Bank transit number', 'invoicing'),
225 225
 						),
226 226
 					),
227 227
 					'IN' => array(
228 228
 						'sortcode' => array(
229
-							'label' => __( 'IFSC', 'invoicing' ),
229
+							'label' => __('IFSC', 'invoicing'),
230 230
 						),
231 231
 					),
232 232
 					'IT' => array(
233 233
 						'sortcode' => array(
234
-							'label' => __( 'Branch sort', 'invoicing' ),
234
+							'label' => __('Branch sort', 'invoicing'),
235 235
 						),
236 236
 					),
237 237
 					'NZ' => array(
238 238
 						'sortcode' => array(
239
-							'label' => __( 'Bank code', 'invoicing' ),
239
+							'label' => __('Bank code', 'invoicing'),
240 240
 						),
241 241
 					),
242 242
 					'SE' => array(
243 243
 						'sortcode' => array(
244
-							'label' => __( 'Bank code', 'invoicing' ),
244
+							'label' => __('Bank code', 'invoicing'),
245 245
 						),
246 246
 					),
247 247
 					'US' => array(
248 248
 						'sortcode' => array(
249
-							'label' => __( 'Routing number', 'invoicing' ),
249
+							'label' => __('Routing number', 'invoicing'),
250 250
 						),
251 251
 					),
252 252
 					'ZA' => array(
253 253
 						'sortcode' => array(
254
-							'label' => __( 'Branch code', 'invoicing' ),
254
+							'label' => __('Branch code', 'invoicing'),
255 255
 						),
256 256
 					),
257 257
 				)
@@ -268,51 +268,51 @@  discard block
 block discarded – undo
268 268
 	 *
269 269
 	 * @param array $admin_settings
270 270
 	 */
271
-	public function admin_settings( $admin_settings ) {
271
+	public function admin_settings($admin_settings) {
272 272
 
273
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
274
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
273
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
274
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
275 275
 
276
-		$locale  = $this->get_country_locale();
276
+		$locale = $this->get_country_locale();
277 277
 
278 278
 		// Get sortcode label in the $locale array and use appropriate one.
279 279
 		$country  = wpinv_default_billing_country();
280
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
280
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
281 281
 
282 282
 		$admin_settings['bank_transfer_ac_name'] = array(
283 283
             'type' => 'text',
284 284
             'id'   => 'bank_transfer_ac_name',
285
-            'name' => __( 'Account Name', 'invoicing' ),
285
+            'name' => __('Account Name', 'invoicing'),
286 286
 		);
287 287
 
288 288
 		$admin_settings['bank_transfer_ac_no'] = array(
289 289
             'type' => 'text',
290 290
             'id'   => 'bank_transfer_ac_no',
291
-            'name' => __( 'Account Number', 'invoicing' ),
291
+            'name' => __('Account Number', 'invoicing'),
292 292
 		);
293 293
 
294 294
 		$admin_settings['bank_transfer_bank_name'] = array(
295 295
             'type' => 'text',
296 296
             'id'   => 'bank_transfer_bank_name',
297
-            'name' => __( 'Bank Name', 'invoicing' ),
297
+            'name' => __('Bank Name', 'invoicing'),
298 298
 		);
299 299
 
300 300
 		$admin_settings['bank_transfer_ifsc'] = array(
301 301
             'type' => 'text',
302 302
             'id'   => 'bank_transfer_ifsc',
303
-            'name' => __( 'IFSC Code', 'invoicing' ),
303
+            'name' => __('IFSC Code', 'invoicing'),
304 304
 		);
305 305
 
306 306
 		$admin_settings['bank_transfer_iban'] = array(
307 307
             'type' => 'text',
308 308
             'id'   => 'bank_transfer_iban',
309
-            'name' => __( 'IBAN', 'invoicing' ),
309
+            'name' => __('IBAN', 'invoicing'),
310 310
 		);
311 311
 
312 312
 		$admin_settings['bank_transfer_bic'] = array(
313 313
             'type' => 'text',
314 314
             'id'   => 'bank_transfer_bic',
315
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
315
+            'name' => __('BIC/Swift Code', 'invoicing'),
316 316
 		);
317 317
 
318 318
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 
324 324
 		$admin_settings['bank_transfer_info'] = array(
325 325
             'id'   => 'bank_transfer_info',
326
-            'name' => __( 'Instructions', 'invoicing' ),
327
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
326
+            'name' => __('Instructions', 'invoicing'),
327
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
328 328
             'type' => 'textarea',
329
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
329
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
330 330
             'cols' => 50,
331 331
             'rows' => 5,
332 332
         );
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 	 * @param GetPaid_Form_Item[] $items
342 342
 	 * @return WPInv_Invoice
343 343
 	 */
344
-	public function process_addons( $invoice, $items ) {
344
+	public function process_addons($invoice, $items) {
345 345
 
346
-        foreach ( $items as $item ) {
347
-            $invoice->add_item( $item );
346
+        foreach ($items as $item) {
347
+            $invoice->add_item($item);
348 348
         }
349 349
 
350 350
         $invoice->recalculate_total();
@@ -357,25 +357,25 @@  discard block
 block discarded – undo
357 357
 	 *
358 358
 	 * @param WPInv_Subscription $subscription
359 359
 	 */
360
-	public function maybe_renew_subscription( $subscription, $parent_invoice ) {
360
+	public function maybe_renew_subscription($subscription, $parent_invoice) {
361 361
 		// Ensure its our subscription && it's active.
362
-		if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
363
-			add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
362
+		if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) {
363
+			add_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2);
364 364
 
365 365
 			$invoice = $subscription->create_payment();
366 366
 
367
-			if ( ! empty( $invoice ) ) {
367
+			if (!empty($invoice)) {
368 368
 				$is_logged_in = is_user_logged_in();
369 369
 
370 370
 				// Cron run.
371
-				if ( ! $is_logged_in ) {
372
-					$note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) );
371
+				if (!$is_logged_in) {
372
+					$note = wp_sprintf(__('Renewal %1$s created with the status "%2$s".', 'invoicing'), $invoice->get_invoice_quote_type(), wpinv_status_nicename($invoice->get_status(), $invoice));
373 373
 
374
-					$invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in );
374
+					$invoice->add_note($note, false, $is_logged_in, !$is_logged_in);
375 375
 				}
376 376
 			}
377 377
 
378
-			remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 );
378
+			remove_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2);
379 379
 		}
380 380
 	}
381 381
 
@@ -385,42 +385,42 @@  discard block
 block discarded – undo
385 385
 	 *
386 386
      * @param WPInv_Invoice $invoice
387 387
 	 */
388
-	public function invoice_paid( $invoice ) {
388
+	public function invoice_paid($invoice) {
389 389
 
390 390
 		// Abort if not paid by bank transfer.
391
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
391
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
392 392
 			return;
393 393
 		}
394 394
 
395 395
 		// Is it a parent payment?
396
-		if ( 0 == $invoice->get_parent_id() ) {
396
+		if (0 == $invoice->get_parent_id()) {
397 397
 
398 398
 			// (Maybe) activate subscriptions.
399
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
399
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
400 400
 
401
-			if ( ! empty( $subscriptions ) ) {
402
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
401
+			if (!empty($subscriptions)) {
402
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
403 403
 
404
-				foreach ( $subscriptions as $subscription ) {
405
-					if ( $subscription->exists() ) {
406
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
407
-						$expiry   = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
404
+				foreach ($subscriptions as $subscription) {
405
+					if ($subscription->exists()) {
406
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
407
+						$expiry   = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration));
408 408
 
409
-						$subscription->set_next_renewal_date( $expiry );
410
-						$subscription->set_date_created( current_time( 'mysql' ) );
411
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
409
+						$subscription->set_next_renewal_date($expiry);
410
+						$subscription->set_date_created(current_time('mysql'));
411
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
412 412
 						$subscription->activate();
413 413
 					}
414 414
 				}
415 415
 			}
416 416
 		} else {
417 417
 
418
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
418
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
419 419
 
420 420
 			// Renew the subscription.
421
-			if ( $subscription && $subscription->exists() ) {
422
-				$subscription->add_payment( array(), $invoice );
423
-				$subscription->renew( strtotime( $invoice->get_date_created() ) );
421
+			if ($subscription && $subscription->exists()) {
422
+				$subscription->add_payment(array(), $invoice);
423
+				$subscription->renew(strtotime($invoice->get_date_created()));
424 424
 			}
425 425
 		}
426 426
 
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param int  $invoice Invoice ID.
436 436
 	 * @return bool True when invoice created via payment form else false.
437 437
 	 */
438
-	public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) {
439
-		if ( $is_payment_form_invoice ) {
438
+	public function force_is_payment_form_invoice($is_payment_form_invoice, $invoice) {
439
+		if ($is_payment_form_invoice) {
440 440
 			$is_payment_form_invoice = false;
441 441
 		}
442 442
 
Please login to merge, or discard this patch.