Passed
Push — master ( b8256f...a40007 )
by Brian
04:17
created
templates/payment-forms/elements/number.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
     $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20 20
     array(
21
-        'name'        => esc_attr( $id ),
22
-        'id'          => esc_attr( $element_id ),
23
-        'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
24
-        'required'    => ! empty( $required ),
21
+        'name'        => esc_attr($id),
22
+        'id'          => esc_attr($element_id),
23
+        'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder),
24
+        'required'    => !empty($required),
25 25
         'label'       => $label,
26 26
         'label_type'  => 'vertical',
27
-        'help_text'   => empty( $description ) ? '' : wp_kses_post( $description ),
27
+        'help_text'   => empty($description) ? '' : wp_kses_post($description),
28 28
         'type'        => 'number',
29 29
         'class'       => $label_class,
30 30
         'value'       => $query_value,
Please login to merge, or discard this patch.
templates/payment-forms/elements/website.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,27 +7,27 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
     $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19
-$current_url = ! empty( $_GET['current_url'] ) ? esc_url_raw( urldecode( $_GET['current_url'] ) ) : get_permalink();
19
+$current_url = !empty($_GET['current_url']) ? esc_url_raw(urldecode($_GET['current_url'])) : get_permalink();
20 20
 aui()->input(
21 21
     array(
22
-        'name'        => esc_attr( $id ),
23
-        'id'          => esc_attr( $element_id ),
24
-        'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
25
-        'required'    => ! empty( $required ),
22
+        'name'        => esc_attr($id),
23
+        'id'          => esc_attr($element_id),
24
+        'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder),
25
+        'required'    => !empty($required),
26 26
         'label'       => $label,
27 27
         'label_type'  => 'vertical',
28
-        'help_text'   => empty( $description ) ? '' : wp_kses_post( $description ),
28
+        'help_text'   => empty($description) ? '' : wp_kses_post($description),
29 29
         'type'        => 'url',
30
-        'value'       => ! empty( $default_current_post ) ? $current_url : $query_value,
30
+        'value'       => !empty($default_current_post) ? $current_url : $query_value,
31 31
         'class'       => $label_class,
32 32
     ),
33 33
     true
Please login to merge, or discard this patch.
templates/payment-forms/elements/price_select.php 1 patch
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -7,36 +7,36 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Ensure that we have options.
13
-if ( empty( $options ) ) {
13
+if (empty($options)) {
14 14
     return;
15 15
 }
16 16
 
17 17
 // Prepare price options.
18
-$options = getpaid_convert_price_string_to_options( $options );
19
-$keys    = array_keys( $options );
20
-$value   = empty( $options ) ? '' : $keys[0];
18
+$options = getpaid_convert_price_string_to_options($options);
19
+$keys    = array_keys($options);
20
+$value   = empty($options) ? '' : $keys[0];
21 21
 
22
-if ( ! empty( $query_value ) ) {
22
+if (!empty($query_value)) {
23 23
     $value = $query_value;
24 24
 }
25 25
 
26
-$select_type = empty( $select_type ) ? 'select' : $select_type;
26
+$select_type = empty($select_type) ? 'select' : $select_type;
27 27
 
28 28
 // Item select;
29
-if ( $select_type == 'select' ) {
29
+if ($select_type == 'select') {
30 30
     aui()->select(
31 31
         array(
32 32
             'name'        => $id,
33
-            'id'          => esc_attr( $element_id ),
34
-            'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
33
+            'id'          => esc_attr($element_id),
34
+            'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder),
35 35
             'value'       => $value,
36
-            'label'       => empty( $label ) ? '' : esc_html( $label ),
36
+            'label'       => empty($label) ? '' : esc_html($label),
37 37
             'label_type'  => 'vertical',
38 38
             'class'       => 'getpaid-price-select-dropdown getpaid-refresh-on-change',
39
-            'help_text'   => empty( $description ) ? '' : wp_kses_post( $description ),
39
+            'help_text'   => empty($description) ? '' : wp_kses_post($description),
40 40
             'options'     => $options,
41 41
         ),
42 42
         true
@@ -45,18 +45,18 @@  discard block
 block discarded – undo
45 45
 }
46 46
 
47 47
 // Item radios;
48
-if ( $select_type == 'radios' ) {
48
+if ($select_type == 'radios') {
49 49
     aui()->radio(
50 50
         array(
51
-            'name'       => esc_attr( $id ),
52
-            'id'         => esc_attr( $id ) . uniqid( '_' ),
53
-            'label'      => empty( $label ) ? '' : esc_html( $label ),
51
+            'name'       => esc_attr($id),
52
+            'id'         => esc_attr($id) . uniqid('_'),
53
+            'label'      => empty($label) ? '' : esc_html($label),
54 54
             'label_type' => 'vertical',
55 55
             'class'      => 'getpaid-price-select-radio getpaid-refresh-on-change w-100',
56 56
             'value'      => $value,
57 57
             'inline'     => false,
58 58
             'options'    => $options,
59
-            'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
59
+            'help_text'  => empty($description) ? '' : wp_kses_post($description),
60 60
         ),
61 61
         true
62 62
     );
@@ -65,32 +65,32 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
 // Display the label.
68
-if ( ! empty( $label ) ) {
69
-    echo '<label>' . esc_html( $label ) . '</label>';
68
+if (!empty($label)) {
69
+    echo '<label>' . esc_html($label) . '</label>';
70 70
 }
71 71
 
72 72
 // Item buttons;
73
-if ( $select_type == 'buttons' || $select_type == 'circles' ) {
73
+if ($select_type == 'buttons' || $select_type == 'circles') {
74 74
 
75 75
     $class = 'getpaid-price-buttons';
76 76
 
77
-    if ( $select_type == 'circles' ) {
77
+    if ($select_type == 'circles') {
78 78
         $class .= ' getpaid-price-circles';
79 79
     }
80
-    echo "<div class='" . esc_attr( $class ) . "'>";
80
+    echo "<div class='" . esc_attr($class) . "'>";
81 81
 
82
-    foreach ( $options as $price => $label ) {
83
-        $_id = $id . uniqid( '_' );
82
+    foreach ($options as $price => $label) {
83
+        $_id = $id . uniqid('_');
84 84
 
85 85
         $class = 'rounded';
86 86
 
87
-        if ( $select_type == 'circles' ) {
87
+        if ($select_type == 'circles') {
88 88
             $class = '';
89 89
         }
90 90
         echo "
91 91
             <span class='d-inline-block'>
92
-                <input type='radio' class='getpaid-price-select-button getpaid-refresh-on-change w-auto' id='" . esc_attr( $_id ) . "' value='" . esc_attr( $price ) . "' name='" . esc_attr( $id ) . "' " . checked( $price, $value, false ) . " />
93
-                <label for='" . esc_attr( $_id ) . "' class='" . esc_attr( $class ) . "'><span>" . esc_html( $label ) . '</span></label>
92
+                <input type='radio' class='getpaid-price-select-button getpaid-refresh-on-change w-auto' id='" . esc_attr($_id) . "' value='" . esc_attr($price) . "' name='" . esc_attr($id) . "' " . checked($price, $value, false) . " />
93
+                <label for='" . esc_attr($_id) . "' class='" . esc_attr($class) . "'><span>" . esc_html($label) . '</span></label>
94 94
             </span>
95 95
             ';
96 96
     }
@@ -100,14 +100,14 @@  discard block
 block discarded – undo
100 100
 }
101 101
 
102 102
 // Item checkboxes;
103
-if ( $select_type == 'checkboxes' ) {
103
+if ($select_type == 'checkboxes') {
104 104
     echo '<div class="form-group">';
105 105
 
106
-    foreach ( $options as $price => $label ) {
106
+    foreach ($options as $price => $label) {
107 107
         echo "
108 108
             <label class='d-block'>
109
-                <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change w-auto' name='" . esc_attr( $id ) . "[]' value='" . esc_attr( $price ) . "' " . checked( $price, $value, false ) . ' />
110
-                <span>' . esc_html( $label ) . '</span>
109
+                <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change w-auto' name='" . esc_attr($id) . "[]' value='" . esc_attr($price) . "' " . checked($price, $value, false) . ' />
110
+                <span>' . esc_html($label) . '</span>
111 111
             </label>
112 112
             ';
113 113
     }
@@ -116,6 +116,6 @@  discard block
 block discarded – undo
116 116
 
117 117
 }
118 118
 
119
-if ( ! empty( $description ) ) {
120
-    echo "<small class='form-text text-muted'>" . wp_kses_post( $description ) . '</small>';
119
+if (!empty($description)) {
120
+    echo "<small class='form-text text-muted'>" . wp_kses_post($description) . '</small>';
121 121
 }
Please login to merge, or discard this patch.
templates/payment-forms/elements/radio.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,26 +7,26 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
     $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->radio(
20 20
     array(
21
-        'name'       => esc_attr( $id ),
22
-        'id'         => esc_attr( $element_id ),
23
-        'required'   => ! empty( $required ),
21
+        'name'       => esc_attr($id),
22
+        'id'         => esc_attr($element_id),
23
+        'required'   => !empty($required),
24 24
         'label'      => $label,
25 25
         'label_type' => 'vertical',
26 26
         'class'      => 'w-auto',
27 27
         'inline'     => false,
28
-        'options'    => empty( $options ) ? array() : array_combine( $options, $options ),
29
-        'help_text'  => empty( $description ) ? '' : wp_kses_post( $description ),
28
+        'options'    => empty($options) ? array() : array_combine($options, $options),
29
+        'help_text'  => empty($description) ? '' : wp_kses_post($description),
30 30
         'class'      => $label_class,
31 31
         'value'      => $query_value,
32 32
     ),
Please login to merge, or discard this patch.
templates/payment-forms/elements/text.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -7,25 +7,25 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$label = empty( $label ) ? '' : wp_kses_post( $label );
13
-$label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
12
+$label = empty($label) ? '' : wp_kses_post($label);
13
+$label_class = sanitize_key(preg_replace('/[^A-Za-z0-9_-]/', '-', $label));
14 14
 
15
-if ( ! empty( $required ) ) {
15
+if (!empty($required)) {
16 16
     $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20 20
     array(
21
-        'name'        => esc_attr( $id ),
22
-        'id'          => esc_attr( $element_id ),
23
-        'placeholder' => empty( $placeholder ) ? '' : esc_attr( $placeholder ),
24
-        'required'    => ! empty( $required ),
21
+        'name'        => esc_attr($id),
22
+        'id'          => esc_attr($element_id),
23
+        'placeholder' => empty($placeholder) ? '' : esc_attr($placeholder),
24
+        'required'    => !empty($required),
25 25
         'label'       => $label,
26 26
         'label_type'  => 'vertical',
27
-        'help_text'   => empty( $description ) ? '' : wp_kses_post( $description ),
28
-        'class'       => esc_attr( $label_class ),
27
+        'help_text'   => empty($description) ? '' : wp_kses_post($description),
28
+        'class'       => esc_attr($label_class),
29 29
         'value'       => $query_value,
30 30
     ),
31 31
     true
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 2 patches
Indentation   +163 added lines, -163 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Payment_Meta {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -42,167 +42,167 @@  discard block
 block discarded – undo
42 42
 
43 43
                         if ( $invoice->is_draft() ) {
44 44
 
45
-							// Set gateway.
46
-							aui()->select(
47
-								array(
48
-									'id'               => 'wpinv_gateway',
49
-									'name'             => 'wpinv_gateway',
50
-									'label'            => __( 'Gateway:', 'invoicing' ),
51
-									'label_type'       => 'vertical',
52
-									'placeholder'      => __( 'Select Gateway', 'invoicing' ),
53
-									'value'            => wpinv_get_default_gateway(),
54
-									'select2'          => true,
55
-									'data-allow-clear' => 'false',
56
-									'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
57
-								),
58
-								true
59
-							);
45
+                            // Set gateway.
46
+                            aui()->select(
47
+                                array(
48
+                                    'id'               => 'wpinv_gateway',
49
+                                    'name'             => 'wpinv_gateway',
50
+                                    'label'            => __( 'Gateway:', 'invoicing' ),
51
+                                    'label_type'       => 'vertical',
52
+                                    'placeholder'      => __( 'Select Gateway', 'invoicing' ),
53
+                                    'value'            => wpinv_get_default_gateway(),
54
+                                    'select2'          => true,
55
+                                    'data-allow-clear' => 'false',
56
+                                    'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
57
+                                ),
58
+                                true
59
+                            );
60 60
 
61 61
                         } else {
62 62
 
63
-							// Invoice key.
64
-							aui()->input(
65
-								array(
66
-									'type'             => 'text',
67
-									'id'               => 'wpinv_key',
68
-									'name'             => 'wpinv_key',
69
-									'label'            => sprintf(
70
-										// translators: %s: Invoice type.
71
-										__( '%s Key:', 'invoicing' ),
72
-										ucfirst( $invoice->get_invoice_quote_type() )
73
-									),
74
-									'label_type'       => 'vertical',
75
-									'class'            => 'form-control-sm',
76
-									'value'            => $invoice->get_key( 'edit' ),
77
-									'extra_attributes' => array(
78
-										'onclick'  => 'this.select();',
79
-										'readonly' => 'true',
80
-									),
81
-								),
82
-								true
83
-							);
84
-
85
-							// View URL.
86
-							aui()->input(
87
-								array(
88
-									'type'             => 'text',
89
-									'id'               => 'wpinv_view_url',
90
-									'name'             => 'wpinv_view_url',
91
-									'label'            => sprintf(
92
-										// translators: %s: Invoice type.
93
-										__( '%s URL:', 'invoicing' ),
94
-										ucfirst( $invoice->get_invoice_quote_type() )
95
-									) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
96
-									'label_type'       => 'vertical',
97
-									'class'            => 'form-control-sm',
98
-									'value'            => $invoice->get_view_url(),
99
-									'extra_attributes' => array(
100
-										'onclick'  => 'this.select();',
101
-										'readonly' => 'true',
102
-									),
103
-								),
104
-								true
105
-							);
106
-
107
-							// If the invoice is paid...
108
-							if ( $invoice->is_paid() || $invoice->is_refunded() ) {
109
-
110
-								// Gateway.
111
-								aui()->input(
112
-									array(
113
-										'type'             => 'text',
114
-										'id'               => 'wpinv_gateway',
115
-										'name'             => '',
116
-										'label'            => __( 'Gateway:', 'invoicing' ),
117
-										'label_type'       => 'vertical',
118
-										'class'            => 'form-control-sm',
119
-										'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
120
-										'extra_attributes' => array(
121
-											'onclick'  => 'this.select();',
122
-											'readonly' => 'true',
123
-										),
124
-									),
125
-									true
126
-								);
127
-
128
-								// Transaction ID.
129
-								$transaction_url = $invoice->get_transaction_url();
130
-								aui()->input(
131
-									array(
132
-										'type'             => 'text',
133
-										'id'               => 'wpinv_transaction_id',
134
-										'name'             => 'wpinv_transaction_id',
135
-										'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
136
-										'label_type'       => 'vertical',
137
-										'class'            => 'form-control-sm',
138
-										'value'            => $invoice->get_transaction_id( 'edit' ),
139
-										'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
140
-										'extra_attributes' => array(
141
-											'onclick'  => 'this.select();',
142
-											'readonly' => 'true',
143
-										),
144
-									),
145
-									true
146
-								);
147
-
148
-								// Currency.
149
-								aui()->input(
150
-									array(
151
-										'type'             => 'text',
152
-										'id'               => 'wpinv_currency',
153
-										'name'             => 'wpinv_currency',
154
-										'label'            => __( 'Currency:', 'invoicing' ),
155
-										'label_type'       => 'vertical',
156
-										'class'            => 'form-control-sm',
157
-										'value'            => $invoice->get_currency( 'edit' ),
158
-										'extra_attributes' => array(
159
-											'onclick'  => 'this.select();',
160
-											'readonly' => 'true',
161
-										),
162
-									),
163
-									true
164
-								);
165
-
166
-							} else {
167
-
168
-								if ( 'wpi_invoice' === $invoice->get_post_type() ) {
169
-
170
-									// Payment URL.
171
-									aui()->input(
172
-										array(
173
-											'type'             => 'text',
174
-											'id'               => 'wpinv_payment_url',
175
-											'name'             => 'wpinv_payment_url',
176
-											'label'            => __( 'Payment URL:', 'invoicing' ),
177
-											'label_type'       => 'vertical',
178
-											'class'            => 'form-control-sm',
179
-											'value'            => $invoice->get_checkout_payment_url(),
180
-											'extra_attributes' => array(
181
-												'onclick'  => 'this.select();',
182
-												'readonly' => 'true',
183
-											),
184
-										),
185
-										true
186
-									);
187
-
188
-									// Set gateway.
189
-									aui()->select(
190
-										array(
191
-											'id'               => 'wpinv_gateway',
192
-											'name'             => 'wpinv_gateway',
193
-											'label'            => __( 'Gateway:', 'invoicing' ),
194
-											'label_type'       => 'vertical',
195
-											'placeholder'      => __( 'Select Gateway', 'invoicing' ),
196
-											'value'            => $invoice->get_gateway( 'edit' ),
197
-											'select2'          => true,
198
-											'data-allow-clear' => 'false',
199
-											'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
200
-										),
201
-										true
202
-									);
203
-
204
-								}
205
-							}
63
+                            // Invoice key.
64
+                            aui()->input(
65
+                                array(
66
+                                    'type'             => 'text',
67
+                                    'id'               => 'wpinv_key',
68
+                                    'name'             => 'wpinv_key',
69
+                                    'label'            => sprintf(
70
+                                        // translators: %s: Invoice type.
71
+                                        __( '%s Key:', 'invoicing' ),
72
+                                        ucfirst( $invoice->get_invoice_quote_type() )
73
+                                    ),
74
+                                    'label_type'       => 'vertical',
75
+                                    'class'            => 'form-control-sm',
76
+                                    'value'            => $invoice->get_key( 'edit' ),
77
+                                    'extra_attributes' => array(
78
+                                        'onclick'  => 'this.select();',
79
+                                        'readonly' => 'true',
80
+                                    ),
81
+                                ),
82
+                                true
83
+                            );
84
+
85
+                            // View URL.
86
+                            aui()->input(
87
+                                array(
88
+                                    'type'             => 'text',
89
+                                    'id'               => 'wpinv_view_url',
90
+                                    'name'             => 'wpinv_view_url',
91
+                                    'label'            => sprintf(
92
+                                        // translators: %s: Invoice type.
93
+                                        __( '%s URL:', 'invoicing' ),
94
+                                        ucfirst( $invoice->get_invoice_quote_type() )
95
+                                    ) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
96
+                                    'label_type'       => 'vertical',
97
+                                    'class'            => 'form-control-sm',
98
+                                    'value'            => $invoice->get_view_url(),
99
+                                    'extra_attributes' => array(
100
+                                        'onclick'  => 'this.select();',
101
+                                        'readonly' => 'true',
102
+                                    ),
103
+                                ),
104
+                                true
105
+                            );
106
+
107
+                            // If the invoice is paid...
108
+                            if ( $invoice->is_paid() || $invoice->is_refunded() ) {
109
+
110
+                                // Gateway.
111
+                                aui()->input(
112
+                                    array(
113
+                                        'type'             => 'text',
114
+                                        'id'               => 'wpinv_gateway',
115
+                                        'name'             => '',
116
+                                        'label'            => __( 'Gateway:', 'invoicing' ),
117
+                                        'label_type'       => 'vertical',
118
+                                        'class'            => 'form-control-sm',
119
+                                        'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
120
+                                        'extra_attributes' => array(
121
+                                            'onclick'  => 'this.select();',
122
+                                            'readonly' => 'true',
123
+                                        ),
124
+                                    ),
125
+                                    true
126
+                                );
127
+
128
+                                // Transaction ID.
129
+                                $transaction_url = $invoice->get_transaction_url();
130
+                                aui()->input(
131
+                                    array(
132
+                                        'type'             => 'text',
133
+                                        'id'               => 'wpinv_transaction_id',
134
+                                        'name'             => 'wpinv_transaction_id',
135
+                                        'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
136
+                                        'label_type'       => 'vertical',
137
+                                        'class'            => 'form-control-sm',
138
+                                        'value'            => $invoice->get_transaction_id( 'edit' ),
139
+                                        'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
140
+                                        'extra_attributes' => array(
141
+                                            'onclick'  => 'this.select();',
142
+                                            'readonly' => 'true',
143
+                                        ),
144
+                                    ),
145
+                                    true
146
+                                );
147
+
148
+                                // Currency.
149
+                                aui()->input(
150
+                                    array(
151
+                                        'type'             => 'text',
152
+                                        'id'               => 'wpinv_currency',
153
+                                        'name'             => 'wpinv_currency',
154
+                                        'label'            => __( 'Currency:', 'invoicing' ),
155
+                                        'label_type'       => 'vertical',
156
+                                        'class'            => 'form-control-sm',
157
+                                        'value'            => $invoice->get_currency( 'edit' ),
158
+                                        'extra_attributes' => array(
159
+                                            'onclick'  => 'this.select();',
160
+                                            'readonly' => 'true',
161
+                                        ),
162
+                                    ),
163
+                                    true
164
+                                );
165
+
166
+                            } else {
167
+
168
+                                if ( 'wpi_invoice' === $invoice->get_post_type() ) {
169
+
170
+                                    // Payment URL.
171
+                                    aui()->input(
172
+                                        array(
173
+                                            'type'             => 'text',
174
+                                            'id'               => 'wpinv_payment_url',
175
+                                            'name'             => 'wpinv_payment_url',
176
+                                            'label'            => __( 'Payment URL:', 'invoicing' ),
177
+                                            'label_type'       => 'vertical',
178
+                                            'class'            => 'form-control-sm',
179
+                                            'value'            => $invoice->get_checkout_payment_url(),
180
+                                            'extra_attributes' => array(
181
+                                                'onclick'  => 'this.select();',
182
+                                                'readonly' => 'true',
183
+                                            ),
184
+                                        ),
185
+                                        true
186
+                                    );
187
+
188
+                                    // Set gateway.
189
+                                    aui()->select(
190
+                                        array(
191
+                                            'id'               => 'wpinv_gateway',
192
+                                            'name'             => 'wpinv_gateway',
193
+                                            'label'            => __( 'Gateway:', 'invoicing' ),
194
+                                            'label_type'       => 'vertical',
195
+                                            'placeholder'      => __( 'Select Gateway', 'invoicing' ),
196
+                                            'value'            => $invoice->get_gateway( 'edit' ),
197
+                                            'select2'          => true,
198
+                                            'data-allow-clear' => 'false',
199
+                                            'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
200
+                                        ),
201
+                                        true
202
+                                    );
203
+
204
+                                }
205
+                            }
206 206
                         }
207 207
                     ?>
208 208
                     </div>
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         ?>
30 30
 
@@ -40,20 +40,20 @@  discard block
 block discarded – undo
40 40
 
41 41
                     <?php
42 42
 
43
-                        if ( $invoice->is_draft() ) {
43
+                        if ($invoice->is_draft()) {
44 44
 
45 45
 							// Set gateway.
46 46
 							aui()->select(
47 47
 								array(
48 48
 									'id'               => 'wpinv_gateway',
49 49
 									'name'             => 'wpinv_gateway',
50
-									'label'            => __( 'Gateway:', 'invoicing' ),
50
+									'label'            => __('Gateway:', 'invoicing'),
51 51
 									'label_type'       => 'vertical',
52
-									'placeholder'      => __( 'Select Gateway', 'invoicing' ),
52
+									'placeholder'      => __('Select Gateway', 'invoicing'),
53 53
 									'value'            => wpinv_get_default_gateway(),
54 54
 									'select2'          => true,
55 55
 									'data-allow-clear' => 'false',
56
-									'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
56
+									'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
57 57
 								),
58 58
 								true
59 59
 							);
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 									'name'             => 'wpinv_key',
69 69
 									'label'            => sprintf(
70 70
 										// translators: %s: Invoice type.
71
-										__( '%s Key:', 'invoicing' ),
72
-										ucfirst( $invoice->get_invoice_quote_type() )
71
+										__('%s Key:', 'invoicing'),
72
+										ucfirst($invoice->get_invoice_quote_type())
73 73
 									),
74 74
 									'label_type'       => 'vertical',
75 75
 									'class'            => 'form-control-sm',
76
-									'value'            => $invoice->get_key( 'edit' ),
76
+									'value'            => $invoice->get_key('edit'),
77 77
 									'extra_attributes' => array(
78 78
 										'onclick'  => 'this.select();',
79 79
 										'readonly' => 'true',
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 									'name'             => 'wpinv_view_url',
91 91
 									'label'            => sprintf(
92 92
 										// translators: %s: Invoice type.
93
-										__( '%s URL:', 'invoicing' ),
94
-										ucfirst( $invoice->get_invoice_quote_type() )
95
-									) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
93
+										__('%s URL:', 'invoicing'),
94
+										ucfirst($invoice->get_invoice_quote_type())
95
+									) . '&nbsp;<a href="' . esc_url_raw($invoice->get_view_url()) . '" title="' . __('View invoice', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
96 96
 									'label_type'       => 'vertical',
97 97
 									'class'            => 'form-control-sm',
98 98
 									'value'            => $invoice->get_view_url(),
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 							);
106 106
 
107 107
 							// If the invoice is paid...
108
-							if ( $invoice->is_paid() || $invoice->is_refunded() ) {
108
+							if ($invoice->is_paid() || $invoice->is_refunded()) {
109 109
 
110 110
 								// Gateway.
111 111
 								aui()->input(
@@ -113,10 +113,10 @@  discard block
 block discarded – undo
113 113
 										'type'             => 'text',
114 114
 										'id'               => 'wpinv_gateway',
115 115
 										'name'             => '',
116
-										'label'            => __( 'Gateway:', 'invoicing' ),
116
+										'label'            => __('Gateway:', 'invoicing'),
117 117
 										'label_type'       => 'vertical',
118 118
 										'class'            => 'form-control-sm',
119
-										'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
119
+										'value'            => wpinv_get_gateway_admin_label($invoice->get_gateway('edit')),
120 120
 										'extra_attributes' => array(
121 121
 											'onclick'  => 'this.select();',
122 122
 											'readonly' => 'true',
@@ -132,11 +132,11 @@  discard block
 block discarded – undo
132 132
 										'type'             => 'text',
133 133
 										'id'               => 'wpinv_transaction_id',
134 134
 										'name'             => 'wpinv_transaction_id',
135
-										'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
135
+										'label'            => __('Transaction ID:', 'invoicing') . ($transaction_url ? '&nbsp;<a href="' . esc_url($transaction_url) . '" title="' . __('View details', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : ''),
136 136
 										'label_type'       => 'vertical',
137 137
 										'class'            => 'form-control-sm',
138
-										'value'            => $invoice->get_transaction_id( 'edit' ),
139
-										'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
138
+										'value'            => $invoice->get_transaction_id('edit'),
139
+										'help_text'        => apply_filters('wpinv_invoice_transaction_link_' . $invoice->get_gateway('edit'), '', $invoice->get_transaction_id(), $invoice),
140 140
 										'extra_attributes' => array(
141 141
 											'onclick'  => 'this.select();',
142 142
 											'readonly' => 'true',
@@ -151,10 +151,10 @@  discard block
 block discarded – undo
151 151
 										'type'             => 'text',
152 152
 										'id'               => 'wpinv_currency',
153 153
 										'name'             => 'wpinv_currency',
154
-										'label'            => __( 'Currency:', 'invoicing' ),
154
+										'label'            => __('Currency:', 'invoicing'),
155 155
 										'label_type'       => 'vertical',
156 156
 										'class'            => 'form-control-sm',
157
-										'value'            => $invoice->get_currency( 'edit' ),
157
+										'value'            => $invoice->get_currency('edit'),
158 158
 										'extra_attributes' => array(
159 159
 											'onclick'  => 'this.select();',
160 160
 											'readonly' => 'true',
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
 
166 166
 							} else {
167 167
 
168
-								if ( 'wpi_invoice' === $invoice->get_post_type() ) {
168
+								if ('wpi_invoice' === $invoice->get_post_type()) {
169 169
 
170 170
 									// Payment URL.
171 171
 									aui()->input(
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 											'type'             => 'text',
174 174
 											'id'               => 'wpinv_payment_url',
175 175
 											'name'             => 'wpinv_payment_url',
176
-											'label'            => __( 'Payment URL:', 'invoicing' ),
176
+											'label'            => __('Payment URL:', 'invoicing'),
177 177
 											'label_type'       => 'vertical',
178 178
 											'class'            => 'form-control-sm',
179 179
 											'value'            => $invoice->get_checkout_payment_url(),
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 										array(
191 191
 											'id'               => 'wpinv_gateway',
192 192
 											'name'             => 'wpinv_gateway',
193
-											'label'            => __( 'Gateway:', 'invoicing' ),
193
+											'label'            => __('Gateway:', 'invoicing'),
194 194
 											'label_type'       => 'vertical',
195
-											'placeholder'      => __( 'Select Gateway', 'invoicing' ),
196
-											'value'            => $invoice->get_gateway( 'edit' ),
195
+											'placeholder'      => __('Select Gateway', 'invoicing'),
196
+											'value'            => $invoice->get_gateway('edit'),
197 197
 											'select2'          => true,
198 198
 											'data-allow-clear' => 'false',
199
-											'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
199
+											'options'          => wp_list_pluck(wpinv_get_enabled_payment_gateways(true), 'admin_label'),
200 200
 										),
201 201
 										true
202 202
 									);
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
Indentation   +589 added lines, -589 removed lines patch added patch discarded remove patch
@@ -14,91 +14,91 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
29
-
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29
+
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct() {
38
+     * Class constructor.
39
+     */
40
+    public function __construct() {
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68 68
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
78
-
79
-		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
82
-				case 'gp-setup':
83
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
84
-					break;
85
-			}
86
-		}
87
-
88
-    }
89
-
90
-    /**
91
-	 * Register admin scripts
92
-	 *
93
-	 */
94
-	public function enqeue_scripts() {
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
+        do_action( 'getpaid_init_admin_hooks', $this );
78
+
79
+        // Setup/welcome
80
+        if ( ! empty( $_GET['page'] ) ) {
81
+            switch ( sanitize_text_field( $_GET['page'] ) ) {
82
+                case 'gp-setup':
83
+                    include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
84
+                    break;
85
+            }
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Register admin scripts
92
+     *
93
+     */
94
+    public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
98
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
98
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100 100
         if ( ! empty( $current_screen->post_type ) ) {
101
-			$page = $current_screen->post_type;
101
+            $page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
@@ -119,53 +119,53 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+        if ( 'wpi_payment_form' == $page && $editing ) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
128
-		}
126
+        if ( $page == 'wpinv-subscriptions' ) {
127
+            wp_enqueue_script( 'postbox' );
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Returns admin js translations.
134
-	 *
135
-	 */
136
-	protected function get_admin_i18() {
133
+     * Returns admin js translations.
134
+     *
135
+     */
136
+    protected function get_admin_i18() {
137 137
         global $post;
138 138
 
139
-		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
141
-		);
139
+        $date_range = array(
140
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
141
+        );
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+        if ( $date_range['period'] == 'custom' ) {
144 144
 
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['from'] ) ) {
146
+                $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
+            }
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
-			}
149
+            if ( isset( $_GET['to'] ) ) {
150
+                $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
+            }
152 152
 }
153 153
 
154 154
         $i18n = array(
155 155
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156 156
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
160
-			'date_range'                => $date_range,
157
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
+            'rest_root'                 => esc_url_raw( rest_url() ),
160
+            'date_range'                => $date_range,
161 161
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162 162
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163 163
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164 164
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167
-			'currency_symbol'           => wpinv_currency_symbol(),
168
-			'currency'                  => wpinv_get_currency(),
167
+            'currency_symbol'           => wpinv_currency_symbol(),
168
+            'currency'                  => wpinv_get_currency(),
169 169
             'currency_pos'              => wpinv_currency_position(),
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -185,118 +185,118 @@  discard block
 block discarded – undo
185 185
             'item_description'          => __( 'Item Description', 'invoicing' ),
186 186
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187 187
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
192
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
188
+            'searching'                 => __( 'Searching', 'invoicing' ),
189
+            'loading'                   => __( 'Loading...', 'invoicing' ),
190
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
192
+            'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
198
-			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
201
-			);
197
+            $invoice              = new WPInv_Invoice( $post );
198
+            $i18n['save_invoice'] = sprintf(
199
+                __( 'Save %s', 'invoicing' ),
200
+                ucfirst( $invoice->get_invoice_quote_type() )
201
+            );
202 202
 
203
-			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
206
-			);
203
+            $i18n['invoice_description'] = sprintf(
204
+                __( '%s Description', 'invoicing' ),
205
+                ucfirst( $invoice->get_invoice_quote_type() )
206
+            );
207 207
 
208
-		}
209
-		return $i18n;
210
-	}
208
+        }
209
+        return $i18n;
210
+    }
211 211
 
212
-	/**
213
-	 * Change the admin footer text on GetPaid admin pages.
214
-	 *
215
-	 * @since  2.0.0
216
-	 * @param  string $footer_text
217
-	 * @return string
218
-	 */
219
-	public function admin_footer_text( $footer_text ) {
220
-		global $current_screen;
212
+    /**
213
+     * Change the admin footer text on GetPaid admin pages.
214
+     *
215
+     * @since  2.0.0
216
+     * @param  string $footer_text
217
+     * @return string
218
+     */
219
+    public function admin_footer_text( $footer_text ) {
220
+        global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
222
+        $page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
223 223
 
224 224
         if ( ! empty( $current_screen->post_type ) ) {
225
-			$page = $current_screen->post_type;
225
+            $page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229 229
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
230 230
 
231
-			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
231
+            // Change the footer text
232
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233 233
 
234
-				$rating_url  = esc_url(
235
-					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
-						'getpaid-nonce',
238
-						'getpaid-nonce'
234
+                $rating_url  = esc_url(
235
+                    wp_nonce_url(
236
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
+                        'getpaid-nonce',
238
+                        'getpaid-nonce'
239 239
                     )
240
-				);
240
+                );
241 241
 
242
-				$footer_text = sprintf(
243
-					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
-				);
242
+                $footer_text = sprintf(
243
+                    /* translators: %s: five stars */
244
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
+                );
247 247
 
248
-			} else {
248
+            } else {
249 249
 
250
-				$footer_text = sprintf(
251
-					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
253
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
-				);
250
+                $footer_text = sprintf(
251
+                    /* translators: %s: GetPaid */
252
+                    __( 'Thank you for using %s!', 'invoicing' ),
253
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
+                );
255 255
 
256
-			}
256
+            }
257 257
 }
258 258
 
259
-		return $footer_text;
260
-	}
261
-
262
-	/**
263
-	 * Redirects to wp.org to rate the plugin.
264
-	 *
265
-	 * @since  2.0.0
266
-	 */
267
-	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
-		exit;
271
-	}
272
-
273
-    /**
274
-	 * Loads payment form js.
275
-	 *
276
-	 */
277
-	protected function load_payment_form_scripts() {
259
+        return $footer_text;
260
+    }
261
+
262
+    /**
263
+     * Redirects to wp.org to rate the plugin.
264
+     *
265
+     * @since  2.0.0
266
+     */
267
+    public function redirect_to_wordpress_rating_page() {
268
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
270
+        exit;
271
+    }
272
+
273
+    /**
274
+     * Loads payment form js.
275
+     *
276
+     */
277
+    protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280 280
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
281
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
284
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
286 286
 
287
-		wp_localize_script(
287
+        wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
-				'currency'      => wpinv_currency_symbol(),
294
-				'position'      => wpinv_currency_position(),
295
-				'decimals'      => (int) wpinv_decimals(),
296
-				'thousands_sep' => wpinv_thousands_separator(),
297
-				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
291
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
293
+                'currency'      => wpinv_currency_symbol(),
294
+                'position'      => wpinv_currency_position(),
295
+                'decimals'      => (int) wpinv_decimals(),
296
+                'thousands_sep' => wpinv_thousands_separator(),
297
+                'decimals_sep'  => wpinv_decimal_separator(),
298
+                'form_items'    => gepaid_get_form_items( $post->ID ),
299
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
@@ -305,19 +305,19 @@  discard block
 block discarded – undo
305 305
     }
306 306
 
307 307
     /**
308
-	 * Add our classes to admin pages.
308
+     * Add our classes to admin pages.
309 309
      *
310 310
      * @param string $classes
311 311
      * @return string
312
-	 *
313
-	 */
312
+     *
313
+     */
314 314
     public function admin_body_class( $classes ) {
315
-		global $pagenow, $post, $current_screen;
315
+        global $pagenow, $post, $current_screen;
316 316
 
317 317
         $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
318 318
 
319 319
         if ( ! empty( $current_screen->post_type ) ) {
320
-			$page = $current_screen->post_type;
320
+            $page = $current_screen->post_type;
321 321
         }
322 322
 
323 323
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -326,70 +326,70 @@  discard block
 block discarded – undo
326 326
 
327 327
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329
-		}
329
+        }
330 330
 
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+        if ( getpaid_is_invoice_post_type( $page ) ) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
335
-		return $classes;
335
+        return $classes;
336 336
     }
337 337
 
338 338
     /**
339
-	 * Maybe show the AyeCode Connect Notice.
340
-	 */
341
-	public function init_ayecode_connect_helper() {
339
+     * Maybe show the AyeCode Connect Notice.
340
+     */
341
+    public function init_ayecode_connect_helper() {
342 342
 
343
-		// Register with the deactivation survey class.
344
-		AyeCode_Deactivation_Survey::instance(
343
+        // Register with the deactivation survey class.
344
+        AyeCode_Deactivation_Survey::instance(
345 345
             array(
346
-				'slug'              => 'invoicing',
347
-				'version'           => WPINV_VERSION,
348
-				'support_url'       => 'https://wpgetpaid.com/support/',
349
-				'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
346
+                'slug'              => 'invoicing',
347
+                'version'           => WPINV_VERSION,
348
+                'support_url'       => 'https://wpgetpaid.com/support/',
349
+                'documentation_url' => 'https://docs.wpgetpaid.com/',
350
+                'activated'         => (int) get_option( 'gepaid_installed_on' ),
351 351
             )
352 352
         );
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
357
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
358
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
359
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
360
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
361
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
362
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
356
+                'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
357
+                'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
358
+                'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
359
+                'connect_button'    => __( 'Connect Site', 'invoicing' ),
360
+                'connecting_button' => __( 'Connecting...', 'invoicing' ),
361
+                'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
362
+                'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
363 363
             ),
364 364
             array( 'wpi-addons' )
365 365
         );
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Redirect users to settings on activation.
371
-	 *
372
-	 * @return void
373
-	 */
374
-	public function activation_redirect() {
369
+    /**
370
+     * Redirect users to settings on activation.
371
+     *
372
+     * @return void
373
+     */
374
+    public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
-			return;
380
-		}
378
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
+            return;
380
+        }
381 381
 
382
-		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
-			return;
385
-		}
382
+        // Bail if activating from network, or bulk
383
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
+            return;
385
+        }
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+        update_option( 'wpinv_redirected_to_settings', 1 );
388 388
 
389 389
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
390 390
         exit;
391 391
 
392
-	}
392
+    }
393 393
 
394 394
     /**
395 395
      * Fires an admin action after verifying that a user can fire them.
@@ -403,525 +403,525 @@  discard block
 block discarded – undo
403 403
 
404 404
     }
405 405
 
406
-	/**
406
+    /**
407 407
      * Duplicate invoice.
408
-	 *
409
-	 * @param array $args
408
+     *
409
+     * @param array $args
410 410
      */
411 411
     public function duplicate_invoice( $args ) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
414
-			return;
415
-		}
413
+        if ( empty( $args['invoice_id'] ) ) {
414
+            return;
415
+        }
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418 418
 
419
-		if ( ! $invoice->exists() ) {
420
-			return;
421
-		}
419
+        if ( ! $invoice->exists() ) {
420
+            return;
421
+        }
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
424
-		$new_invoice->save();
423
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
424
+        $new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+        if ( $new_invoice->exists() ) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
429 429
 
430
-			wp_safe_redirect(
431
-				add_query_arg(
432
-					array(
433
-						'action' => 'edit',
434
-						'post'   => $new_invoice->get_id(),
435
-					),
436
-					admin_url( 'post.php' )
437
-				)
438
-			);
439
-			exit;
430
+            wp_safe_redirect(
431
+                add_query_arg(
432
+                    array(
433
+                        'action' => 'edit',
434
+                        'post'   => $new_invoice->get_id(),
435
+                    ),
436
+                    admin_url( 'post.php' )
437
+                )
438
+            );
439
+            exit;
440 440
 
441
-		}
441
+        }
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
444 444
 
445
-	}
445
+    }
446 446
 
447
-	/**
447
+    /**
448 448
      * Sends a payment reminder to a customer.
449
-	 *
450
-	 * @param array $args
449
+     *
450
+     * @param array $args
451 451
      */
452 452
     public function duplicate_payment_form( $args ) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
455
-			return;
456
-		}
457
-
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
454
+        if ( empty( $args['form_id'] ) ) {
455
+            return;
456
+        }
459 457
 
460
-		if ( ! $form->exists() ) {
461
-			return;
462
-		}
458
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
463 459
 
464
-		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
469
-		$new_form->save();
460
+        if ( ! $form->exists() ) {
461
+            return;
462
+        }
470 463
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
-		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
-		}
464
+        $new_form = new GetPaid_Payment_Form();
465
+        $new_form->set_author( $form->get_author( 'edit' ) );
466
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
468
+        $new_form->set_items( $form->get_items( 'edit' ) );
469
+        $new_form->save();
470
+
471
+        if ( $new_form->exists() ) {
472
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
+        } else {
475
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
+        }
478 478
 
479
-		wp_redirect( $url );
480
-		exit;
481
-	}
479
+        wp_redirect( $url );
480
+        exit;
481
+    }
482 482
 
483
-	/**
483
+    /**
484 484
      * Sends a payment reminder to a customer.
485
-	 *
486
-	 * @param array $args
485
+     *
486
+     * @param array $args
487 487
      */
488 488
     public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
-		exit;
492
-	}
489
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
+        exit;
492
+    }
493 493
 
494
-	/**
494
+    /**
495 495
      * Sends a payment reminder to a customer.
496
-	 *
497
-	 * @param array $args
496
+     *
497
+     * @param array $args
498 498
      */
499 499
     public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
500
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
-		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
-		}
502
+        if ( $sent ) {
503
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
+        } else {
505
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
+        }
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
-		exit;
510
-	}
508
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
+        exit;
510
+    }
511 511
 
512
-	/**
512
+    /**
513 513
      * Resets tax rates.
514
-	 *
514
+     *
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
-		exit;
518
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
+        exit;
521 521
 
522
-	}
522
+    }
523 523
 
524
-	/**
524
+    /**
525 525
      * Resets admin pages.
526
-	 *
526
+     *
527 527
      */
528 528
     public function admin_create_missing_pages() {
529
-		$installer = new GetPaid_Installer();
530
-		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
-		exit;
534
-	}
535
-
536
-	/**
529
+        $installer = new GetPaid_Installer();
530
+        $installer->create_pages();
531
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
+        exit;
534
+    }
535
+
536
+    /**
537 537
      * Creates an missing admin tables.
538
-	 *
538
+     *
539 539
      */
540 540
     public function admin_create_missing_tables() {
541
-		global $wpdb;
542
-		$installer = new GetPaid_Installer();
541
+        global $wpdb;
542
+        $installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
-			$installer->create_subscriptions_table();
544
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
+            $installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
-			}
550
-		}
547
+            if ( $wpdb->last_error !== '' ) {
548
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
+            }
550
+        }
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
-			$installer->create_invoices_table();
552
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
+            $installer->create_invoices_table();
554 554
 
555
-			if ( '' !== $wpdb->last_error ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
-			}
558
-		}
555
+            if ( '' !== $wpdb->last_error ) {
556
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
+            }
558
+        }
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
-			$installer->create_invoice_items_table();
560
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
+            $installer->create_invoice_items_table();
562 562
 
563
-			if ( '' !== $wpdb->last_error ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
-			}
566
-		}
563
+            if ( '' !== $wpdb->last_error ) {
564
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
+            }
566
+        }
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
-		}
568
+        if ( ! $this->has_notices() ) {
569
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
+        }
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
-		exit;
574
-	}
572
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
+        exit;
574
+    }
575 575
 
576
-	/**
576
+    /**
577 577
      * Migrates old invoices to the new database tables.
578
-	 *
578
+     *
579 579
      */
580 580
     public function admin_migrate_old_invoices() {
581 581
 
582
-		// Migrate the invoices.
583
-		$installer = new GetPaid_Installer();
584
-		$installer->migrate_old_invoices();
582
+        // Migrate the invoices.
583
+        $installer = new GetPaid_Installer();
584
+        $installer->migrate_old_invoices();
585 585
 
586
-		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
586
+        // Show an admin message.
587
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
588 588
 
589
-		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
-		exit;
589
+        // Redirect the admin.
590
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
+        exit;
592 592
 
593
-	}
593
+    }
594 594
 
595
-	/**
595
+    /**
596 596
      * Download customers.
597
-	 *
597
+     *
598 598
      */
599 599
     public function admin_download_customers() {
600
-		global $wpdb;
601
-
602
-		$output = fopen( 'php://output', 'w' );
603
-
604
-		if ( false === $output ) {
605
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
606
-		}
600
+        global $wpdb;
607 601
 
608
-		header( 'Content-Type:text/csv' );
609
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
602
+        $output = fopen( 'php://output', 'w' );
610 603
 
611
-		$post_types = '';
604
+        if ( false === $output ) {
605
+            wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
606
+        }
612 607
 
613
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
614
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
615
-		}
608
+        header( 'Content-Type:text/csv' );
609
+        header( 'Content-Disposition:attachment;filename=customers.csv' );
616 610
 
617
-		$post_types = rtrim( $post_types, ' OR' );
611
+        $post_types = '';
618 612
 
619
-		$customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" );
613
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
614
+            $post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
615
+        }
620 616
 
621
-		$columns = array(
622
-			'name'       => __( 'Name', 'invoicing' ),
623
-			'email'      => __( 'Email', 'invoicing' ),
624
-			'country'    => __( 'Country', 'invoicing' ),
625
-			'state'      => __( 'State', 'invoicing' ),
626
-			'city'       => __( 'City', 'invoicing' ),
627
-			'zip'        => __( 'ZIP', 'invoicing' ),
628
-			'address'    => __( 'Address', 'invoicing' ),
629
-			'phone'      => __( 'Phone', 'invoicing' ),
630
-			'company'    => __( 'Company', 'invoicing' ),
631
-			'company_id' => __( 'Company ID', 'invoicing' ),
632
-			'invoices'   => __( 'Invoices', 'invoicing' ),
633
-			'total_raw'  => __( 'Total Spend', 'invoicing' ),
634
-			'signup'     => __( 'Date created', 'invoicing' ),
635
-		);
617
+        $post_types = rtrim( $post_types, ' OR' );
618
+
619
+        $customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" );
620
+
621
+        $columns = array(
622
+            'name'       => __( 'Name', 'invoicing' ),
623
+            'email'      => __( 'Email', 'invoicing' ),
624
+            'country'    => __( 'Country', 'invoicing' ),
625
+            'state'      => __( 'State', 'invoicing' ),
626
+            'city'       => __( 'City', 'invoicing' ),
627
+            'zip'        => __( 'ZIP', 'invoicing' ),
628
+            'address'    => __( 'Address', 'invoicing' ),
629
+            'phone'      => __( 'Phone', 'invoicing' ),
630
+            'company'    => __( 'Company', 'invoicing' ),
631
+            'company_id' => __( 'Company ID', 'invoicing' ),
632
+            'invoices'   => __( 'Invoices', 'invoicing' ),
633
+            'total_raw'  => __( 'Total Spend', 'invoicing' ),
634
+            'signup'     => __( 'Date created', 'invoicing' ),
635
+        );
636 636
 
637
-		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
637
+        // Output the csv column headers.
638
+        fputcsv( $output, array_values( $columns ) );
639 639
 
640
-		// Loop through
641
-		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
640
+        // Loop through
641
+        $table = new WPInv_Customers_Table();
642
+        foreach ( $customers as $customer_id ) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
645
-			$row  = array();
646
-			if ( empty( $user ) ) {
647
-				continue;
648
-			}
644
+            $user = get_user_by( 'id', $customer_id );
645
+            $row  = array();
646
+            if ( empty( $user ) ) {
647
+                continue;
648
+            }
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+            foreach ( array_keys( $columns ) as $column ) {
651 651
 
652
-				$method = 'column_' . $column;
652
+                $method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} elseif ( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} elseif ( is_callable( array( $table, $method ) ) ) {
659
-					$value = wp_strip_all_tags( $table->$method( $user ) );
660
-				}
654
+                if ( 'name' == $column ) {
655
+                    $value = esc_html( $user->display_name );
656
+                } elseif ( 'email' == $column ) {
657
+                    $value = sanitize_email( $user->user_email );
658
+                } elseif ( is_callable( array( $table, $method ) ) ) {
659
+                    $value = wp_strip_all_tags( $table->$method( $user ) );
660
+                }
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
-				}
662
+                if ( empty( $value ) ) {
663
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
+                }
665 665
 
666
-				$row[] = $value;
666
+                $row[] = $value;
667 667
 
668
-			}
668
+            }
669 669
 
670
-			fputcsv( $output, $row );
671
-		}
670
+            fputcsv( $output, $row );
671
+        }
672 672
 
673
-		fclose( $output );
674
-		exit;
673
+        fclose( $output );
674
+        exit;
675 675
 
676
-	}
676
+    }
677 677
 
678
-	/**
678
+    /**
679 679
      * Installs a plugin.
680
-	 *
681
-	 * @param array $data
680
+     *
681
+     * @param array $data
682 682
      */
683 683
     public function admin_install_plugin( $data ) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
686
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
-			wp_cache_flush();
685
+        if ( ! empty( $data['plugins'] ) ) {
686
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
+            wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+            foreach ( $data['plugins'] as $slug => $file ) {
690
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
+                $installed  = $upgrader->install( $plugin_zip );
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
696
-				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
-				}
694
+                if ( ! is_wp_error( $installed ) && $installed ) {
695
+                    activate_plugin( $file, '', false, true );
696
+                } else {
697
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
+                }
699 699
 }
700 700
 }
701 701
 
702
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
703
-		wp_safe_redirect( $redirect );
704
-		exit;
702
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
703
+        wp_safe_redirect( $redirect );
704
+        exit;
705 705
 
706
-	}
706
+    }
707 707
 
708
-	/**
708
+    /**
709 709
      * Connects a gateway.
710
-	 *
711
-	 * @param array $data
710
+     *
711
+     * @param array $data
712 712
      */
713 713
     public function admin_connect_gateway( $data ) {
714 714
 
715
-		if ( ! empty( $data['plugin'] ) ) {
715
+        if ( ! empty( $data['plugin'] ) ) {
716 716
 
717
-			$gateway     = sanitize_key( $data['plugin'] );
718
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
717
+            $gateway     = sanitize_key( $data['plugin'] );
718
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
719 719
 
720
-			if ( ! empty( $connect_url ) ) {
721
-				wp_redirect( $connect_url );
722
-				exit;
723
-			}
720
+            if ( ! empty( $connect_url ) ) {
721
+                wp_redirect( $connect_url );
722
+                exit;
723
+            }
724 724
 
725
-			if ( 'stripe' == $data['plugin'] ) {
726
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
727
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728
-				wp_cache_flush();
725
+            if ( 'stripe' == $data['plugin'] ) {
726
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
727
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728
+                wp_cache_flush();
729 729
 
730
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
731
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
732
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
-					$upgrader->install( $plugin_zip );
734
-				}
730
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
731
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
732
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
+                    $upgrader->install( $plugin_zip );
734
+                }
735 735
 
736
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
737
-			}
736
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
737
+            }
738 738
 
739
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
740
-			if ( ! empty( $connect_url ) ) {
741
-				wp_redirect( $connect_url );
742
-				exit;
743
-			}
739
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
740
+            if ( ! empty( $connect_url ) ) {
741
+                wp_redirect( $connect_url );
742
+                exit;
743
+            }
744 744
 }
745 745
 
746
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
747
-		wp_safe_redirect( $redirect );
748
-		exit;
746
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
747
+        wp_safe_redirect( $redirect );
748
+        exit;
749 749
 
750
-	}
750
+    }
751 751
 
752
-	/**
752
+    /**
753 753
      * Recalculates discounts.
754
-	 *
754
+     *
755 755
      */
756 756
     public function admin_recalculate_discounts() {
757
-		global $wpdb;
757
+        global $wpdb;
758 758
 
759
-		// Fetch all invoices that have discount codes.
760
-		$table    = $wpdb->prefix . 'getpaid_invoices';
761
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
759
+        // Fetch all invoices that have discount codes.
760
+        $table    = $wpdb->prefix . 'getpaid_invoices';
761
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
762 762
 
763
-		foreach ( $invoices as $invoice ) {
763
+        foreach ( $invoices as $invoice ) {
764 764
 
765
-			$invoice = new WPInv_Invoice( $invoice );
765
+            $invoice = new WPInv_Invoice( $invoice );
766 766
 
767
-			if ( ! $invoice->exists() ) {
768
-				continue;
769
-			}
767
+            if ( ! $invoice->exists() ) {
768
+                continue;
769
+            }
770 770
 
771
-			// Abort if the discount does not exist or does not apply here.
772
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
773
-			if ( ! $discount->exists() ) {
774
-				continue;
775
-			}
771
+            // Abort if the discount does not exist or does not apply here.
772
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
773
+            if ( ! $discount->exists() ) {
774
+                continue;
775
+            }
776 776
 
777
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
778
-			$invoice->recalculate_total();
777
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
778
+            $invoice->recalculate_total();
779 779
 
780
-			if ( $invoice->get_total_discount() > 0 ) {
781
-				$invoice->save();
782
-			}
780
+            if ( $invoice->get_total_discount() > 0 ) {
781
+                $invoice->save();
782
+            }
783 783
 }
784 784
 
785
-		// Show an admin message.
786
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
785
+        // Show an admin message.
786
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
787 787
 
788
-		// Redirect the admin.
789
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
790
-		exit;
788
+        // Redirect the admin.
789
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
790
+        exit;
791 791
 
792
-	}
792
+    }
793 793
 
794 794
     /**
795
-	 * Returns an array of admin notices.
796
-	 *
797
-	 * @since       1.0.19
795
+     * Returns an array of admin notices.
796
+     *
797
+     * @since       1.0.19
798 798
      * @return array
799
-	 */
800
-	public function get_notices() {
801
-		$notices = get_option( 'wpinv_admin_notices' );
799
+     */
800
+    public function get_notices() {
801
+        $notices = get_option( 'wpinv_admin_notices' );
802 802
         return is_array( $notices ) ? $notices : array();
803
-	}
803
+    }
804 804
 
805
-	/**
806
-	 * Checks if we have any admin notices.
807
-	 *
808
-	 * @since       2.0.4
805
+    /**
806
+     * Checks if we have any admin notices.
807
+     *
808
+     * @since       2.0.4
809 809
      * @return array
810
-	 */
811
-	public function has_notices() {
812
-		return count( $this->get_notices() ) > 0;
813
-	}
814
-
815
-	/**
816
-	 * Clears all admin notices
817
-	 *
818
-	 * @access      public
819
-	 * @since       1.0.19
820
-	 */
821
-	public function clear_notices() {
822
-		delete_option( 'wpinv_admin_notices' );
823
-	}
824
-
825
-	/**
826
-	 * Saves a new admin notice
827
-	 *
828
-	 * @access      public
829
-	 * @since       1.0.19
830
-	 */
831
-	public function save_notice( $type, $message ) {
832
-		$notices = $this->get_notices();
833
-
834
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
835
-			$notices[ $type ] = array();
836
-		}
837
-
838
-		$notices[ $type ][] = $message;
839
-
840
-		update_option( 'wpinv_admin_notices', $notices );
841
-	}
842
-
843
-	/**
844
-	 * Displays a success notice
845
-	 *
846
-	 * @param       string $msg The message to qeue.
847
-	 * @access      public
848
-	 * @since       1.0.19
849
-	 */
850
-	public function show_success( $msg ) {
851
-		$this->save_notice( 'success', $msg );
852
-	}
853
-
854
-	/**
855
-	 * Displays a error notice
856
-	 *
857
-	 * @access      public
858
-	 * @param       string $msg The message to qeue.
859
-	 * @since       1.0.19
860
-	 */
861
-	public function show_error( $msg ) {
862
-		$this->save_notice( 'error', $msg );
863
-	}
864
-
865
-	/**
866
-	 * Displays a warning notice
867
-	 *
868
-	 * @access      public
869
-	 * @param       string $msg The message to qeue.
870
-	 * @since       1.0.19
871
-	 */
872
-	public function show_warning( $msg ) {
873
-		$this->save_notice( 'warning', $msg );
874
-	}
875
-
876
-	/**
877
-	 * Displays a info notice
878
-	 *
879
-	 * @access      public
880
-	 * @param       string $msg The message to qeue.
881
-	 * @since       1.0.19
882
-	 */
883
-	public function show_info( $msg ) {
884
-		$this->save_notice( 'info', $msg );
885
-	}
886
-
887
-	/**
888
-	 * Show notices
889
-	 *
890
-	 * @access      public
891
-	 * @since       1.0.19
892
-	 */
893
-	public function show_notices() {
810
+     */
811
+    public function has_notices() {
812
+        return count( $this->get_notices() ) > 0;
813
+    }
814
+
815
+    /**
816
+     * Clears all admin notices
817
+     *
818
+     * @access      public
819
+     * @since       1.0.19
820
+     */
821
+    public function clear_notices() {
822
+        delete_option( 'wpinv_admin_notices' );
823
+    }
824
+
825
+    /**
826
+     * Saves a new admin notice
827
+     *
828
+     * @access      public
829
+     * @since       1.0.19
830
+     */
831
+    public function save_notice( $type, $message ) {
832
+        $notices = $this->get_notices();
833
+
834
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
835
+            $notices[ $type ] = array();
836
+        }
837
+
838
+        $notices[ $type ][] = $message;
839
+
840
+        update_option( 'wpinv_admin_notices', $notices );
841
+    }
842
+
843
+    /**
844
+     * Displays a success notice
845
+     *
846
+     * @param       string $msg The message to qeue.
847
+     * @access      public
848
+     * @since       1.0.19
849
+     */
850
+    public function show_success( $msg ) {
851
+        $this->save_notice( 'success', $msg );
852
+    }
853
+
854
+    /**
855
+     * Displays a error notice
856
+     *
857
+     * @access      public
858
+     * @param       string $msg The message to qeue.
859
+     * @since       1.0.19
860
+     */
861
+    public function show_error( $msg ) {
862
+        $this->save_notice( 'error', $msg );
863
+    }
864
+
865
+    /**
866
+     * Displays a warning notice
867
+     *
868
+     * @access      public
869
+     * @param       string $msg The message to qeue.
870
+     * @since       1.0.19
871
+     */
872
+    public function show_warning( $msg ) {
873
+        $this->save_notice( 'warning', $msg );
874
+    }
875
+
876
+    /**
877
+     * Displays a info notice
878
+     *
879
+     * @access      public
880
+     * @param       string $msg The message to qeue.
881
+     * @since       1.0.19
882
+     */
883
+    public function show_info( $msg ) {
884
+        $this->save_notice( 'info', $msg );
885
+    }
886
+
887
+    /**
888
+     * Show notices
889
+     *
890
+     * @access      public
891
+     * @since       1.0.19
892
+     */
893
+    public function show_notices() {
894 894
 
895 895
         $notices = $this->get_notices();
896 896
         $this->clear_notices();
897 897
 
898
-		foreach ( $notices as $type => $messages ) {
898
+        foreach ( $notices as $type => $messages ) {
899 899
 
900
-			if ( ! is_array( $messages ) ) {
901
-				continue;
902
-			}
900
+            if ( ! is_array( $messages ) ) {
901
+                continue;
902
+            }
903 903
 
904 904
             $type  = esc_attr( $type );
905
-			foreach ( $messages as $message ) {
906
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
905
+            foreach ( $messages as $message ) {
906
+                echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
907 907
             }
908 908
 }
909 909
 
910
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
911
-
912
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
913
-				$url     = wp_nonce_url(
914
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
915
-					'getpaid-nonce',
916
-					'getpaid-nonce'
917
-				);
918
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
919
-				$message2 = __( 'Generate Pages', 'invoicing' );
920
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
921
-				break;
922
-			}
910
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
911
+
912
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
913
+                $url     = wp_nonce_url(
914
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
915
+                    'getpaid-nonce',
916
+                    'getpaid-nonce'
917
+                );
918
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
919
+                $message2 = __( 'Generate Pages', 'invoicing' );
920
+                echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
921
+                break;
922
+            }
923 923
 }
924 924
 
925
-	}
925
+    }
926 926
 
927 927
 }
Please login to merge, or discard this patch.
Spacing   +280 added lines, -280 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
  * The main admin class.
@@ -39,11 +39,11 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect' ) );
61
-        add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68
-        add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
61
+        add_action('admin_init', array($this, 'maybe_do_admin_action'));
62
+		add_action('admin_notices', array($this, 'show_notices'));
63
+		add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page'));
64
+		add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form'));
65
+		add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice'));
66
+		add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice'));
67
+		add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder'));
68
+        add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates'));
69
+		add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages'));
70
+		add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables'));
71
+		add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices'));
72
+		add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers'));
73
+		add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts'));
74
+		add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
75
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
76
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
77
+		do_action('getpaid_init_admin_hooks', $this);
78 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( sanitize_text_field( $_GET['page'] ) ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch (sanitize_text_field($_GET['page'])) {
82 82
 				case 'gp-setup':
83
-					include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php';
83
+					include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php';
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
97
+		$page    = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+		if ('wpi_payment_form' == $page && $editing) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,31 +137,31 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days',
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days',
141 141
 		);
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+		if ($date_range['period'] == 'custom') {
144 144
 
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
145
+			if (isset($_GET['from'])) {
146
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
147 147
 			}
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
149
+			if (isset($_GET['to'])) {
150
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
151 151
 			}
152 152
 }
153 153
 
154 154
         $i18n = array(
155
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
156
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
157
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
158
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
159
-			'rest_root'                 => esc_url_raw( rest_url() ),
155
+            'ajax_url'                  => admin_url('admin-ajax.php'),
156
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
157
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
158
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
159
+			'rest_root'                 => esc_url_raw(rest_url()),
160 160
 			'date_range'                => $date_range,
161
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
162
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
163
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
164
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
161
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
162
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
163
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
164
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
165 165
             'tax'                       => wpinv_tax_amount(),
166 166
             'discount'                  => 0,
167 167
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -170,39 +170,39 @@  discard block
 block discarded – undo
170 170
             'thousand_sep'              => wpinv_thousands_separator(),
171 171
             'decimal_sep'               => wpinv_decimal_separator(),
172 172
             'decimals'                  => wpinv_decimals(),
173
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
174
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
175
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
176
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
177
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
178
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
179
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
180
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
181
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
182
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
183
-            'action_edit'               => __( 'Edit', 'invoicing' ),
184
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
185
-            'item_description'          => __( 'Item Description', 'invoicing' ),
186
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
187
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
188
-			'searching'                 => __( 'Searching', 'invoicing' ),
189
-			'loading'                   => __( 'Loading...', 'invoicing' ),
190
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
191
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
192
-			'graphs'                    => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ),
173
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
174
+            'status_publish'            => wpinv_status_nicename('publish'),
175
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
176
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
177
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
178
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
179
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
180
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
181
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
182
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
183
+            'action_edit'               => __('Edit', 'invoicing'),
184
+            'action_cancel'             => __('Cancel', 'invoicing'),
185
+            'item_description'          => __('Item Description', 'invoicing'),
186
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
187
+            'discount_description'      => __('Discount Description', 'invoicing'),
188
+			'searching'                 => __('Searching', 'invoicing'),
189
+			'loading'                   => __('Loading...', 'invoicing'),
190
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
191
+			'search_items'              => __('Enter item name', 'invoicing'),
192
+			'graphs'                    => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
197
+			$invoice              = new WPInv_Invoice($post);
198 198
 			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
199
+				__('Save %s', 'invoicing'),
200
+				ucfirst($invoice->get_invoice_quote_type())
201 201
 			);
202 202
 
203 203
 			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
204
+				__('%s Description', 'invoicing'),
205
+				ucfirst($invoice->get_invoice_quote_type())
206 206
 			);
207 207
 
208 208
 		}
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $footer_text
217 217
 	 * @return string
218 218
 	 */
219
-	public function admin_footer_text( $footer_text ) {
219
+	public function admin_footer_text($footer_text) {
220 220
 		global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
222
+		$page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
223 223
 
224
-        if ( ! empty( $current_screen->post_type ) ) {
224
+        if (!empty($current_screen->post_type)) {
225 225
 			$page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
230 230
 
231 231
 			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
233 233
 
234
-				$rating_url  = esc_url(
234
+				$rating_url = esc_url(
235 235
 					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
237 237
 						'getpaid-nonce',
238 238
 						'getpaid-nonce'
239 239
                     )
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 				$footer_text = sprintf(
243 243
 					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
245 245
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246 246
 				);
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				$footer_text = sprintf(
251 251
 					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
252
+					__('Thank you for using %s!', 'invoicing'),
253 253
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254 254
 				);
255 255
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 * @since  2.0.0
266 266
 	 */
267 267
 	public function redirect_to_wordpress_rating_page() {
268
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
269
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
268
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
269
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
270 270
 		exit;
271 271
 	}
272 272
 
@@ -277,30 +277,30 @@  discard block
 block discarded – undo
277 277
 	protected function load_payment_form_scripts() {
278 278
         global $post;
279 279
 
280
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
280
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION);
281
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
282
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
283 283
 
284
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
285
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), $version );
284
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
285
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), $version);
286 286
 
287 287
 		wp_localize_script(
288 288
             'wpinv-admin-payment-form-script',
289 289
             'wpinvPaymentFormAdmin',
290 290
             array(
291
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
292
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
291
+				'elements'      => wpinv_get_data('payment-form-elements'),
292
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
293 293
 				'currency'      => wpinv_currency_symbol(),
294 294
 				'position'      => wpinv_currency_position(),
295 295
 				'decimals'      => (int) wpinv_decimals(),
296 296
 				'thousands_sep' => wpinv_thousands_separator(),
297 297
 				'decimals_sep'  => wpinv_decimal_separator(),
298
-				'form_items'    => gepaid_get_form_items( $post->ID ),
298
+				'form_items'    => gepaid_get_form_items($post->ID),
299 299
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
300 300
             )
301 301
         );
302 302
 
303
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
303
+        wp_enqueue_script('wpinv-admin-payment-form-script');
304 304
 
305 305
     }
306 306
 
@@ -311,24 +311,24 @@  discard block
 block discarded – undo
311 311
      * @return string
312 312
 	 *
313 313
 	 */
314
-    public function admin_body_class( $classes ) {
314
+    public function admin_body_class($classes) {
315 315
 		global $pagenow, $post, $current_screen;
316 316
 
317
-        $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : '';
317
+        $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : '';
318 318
 
319
-        if ( ! empty( $current_screen->post_type ) ) {
319
+        if (!empty($current_screen->post_type)) {
320 320
 			$page = $current_screen->post_type;
321 321
         }
322 322
 
323
-        if ( false !== stripos( $page, 'wpi' ) ) {
324
-            $classes .= ' wpi-' . sanitize_key( $page );
323
+        if (false !== stripos($page, 'wpi')) {
324
+            $classes .= ' wpi-' . sanitize_key($page);
325 325
         }
326 326
 
327
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
327
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329 329
 		}
330 330
 
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+		if (getpaid_is_invoice_post_type($page)) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
@@ -347,21 +347,21 @@  discard block
 block discarded – undo
347 347
 				'version'           => WPINV_VERSION,
348 348
 				'support_url'       => 'https://wpgetpaid.com/support/',
349 349
 				'documentation_url' => 'https://docs.wpgetpaid.com/',
350
-				'activated'         => (int) get_option( 'gepaid_installed_on' ),
350
+				'activated'         => (int) get_option('gepaid_installed_on'),
351 351
             )
352 352
         );
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title'     => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ),
357
-				'connect_external'  => __( 'Please confirm you wish to connect your site?', 'invoicing' ),
358
-				'connect'           => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ),
359
-				'connect_button'    => __( 'Connect Site', 'invoicing' ),
360
-				'connecting_button' => __( 'Connecting...', 'invoicing' ),
361
-				'error_localhost'   => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ),
362
-				'error'             => __( 'Something went wrong, please refresh and try again.', 'invoicing' ),
356
+				'connect_title'     => __('WP Invoicing - an AyeCode product!', 'invoicing'),
357
+				'connect_external'  => __('Please confirm you wish to connect your site?', 'invoicing'),
358
+				'connect'           => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'),
359
+				'connect_button'    => __('Connect Site', 'invoicing'),
360
+				'connecting_button' => __('Connecting...', 'invoicing'),
361
+				'error_localhost'   => __('This service will only work with a live domain, not a localhost.', 'invoicing'),
362
+				'error'             => __('Something went wrong, please refresh and try again.', 'invoicing'),
363 363
             ),
364
-            array( 'wpi-addons' )
364
+            array('wpi-addons')
365 365
         );
366 366
 
367 367
     }
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	 */
374 374
 	public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+		$redirected = get_option('wpinv_redirected_to_settings');
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
378
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+	    update_option('wpinv_redirected_to_settings', 1);
388 388
 
389
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
390 390
         exit;
391 391
 
392 392
 	}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function maybe_do_admin_action() {
398 398
 
399
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
399
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
400
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
401
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
402 402
         }
403 403
 
404 404
     }
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 *
409 409
 	 * @param array $args
410 410
      */
411
-    public function duplicate_invoice( $args ) {
411
+    public function duplicate_invoice($args) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
413
+		if (empty($args['invoice_id'])) {
414 414
 			return;
415 415
 		}
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+		$invoice = new WPInv_Invoice((int) $args['invoice_id']);
418 418
 
419
-		if ( ! $invoice->exists() ) {
419
+		if (!$invoice->exists()) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
423
+		$new_invoice = getpaid_duplicate_invoice($invoice);
424 424
 		$new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+		if ($new_invoice->exists()) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+			getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'newsletter-optin-box'));
429 429
 
430 430
 			wp_safe_redirect(
431 431
 				add_query_arg(
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						'action' => 'edit',
434 434
 						'post'   => $new_invoice->get_id(),
435 435
 					),
436
-					admin_url( 'post.php' )
436
+					admin_url('post.php')
437 437
 				)
438 438
 			);
439 439
 			exit;
440 440
 
441 441
 		}
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+		getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box'));
444 444
 
445 445
 	}
446 446
 
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 	 *
450 450
 	 * @param array $args
451 451
      */
452
-    public function duplicate_payment_form( $args ) {
452
+    public function duplicate_payment_form($args) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
454
+		if (empty($args['form_id'])) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
458
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
459 459
 
460
-		if ( ! $form->exists() ) {
460
+		if (!$form->exists()) {
461 461
 			return;
462 462
 		}
463 463
 
464 464
 		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
465
+		$new_form->set_author($form->get_author('edit'));
466
+		$new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing'));
467
+		$new_form->set_elements($form->get_elements('edit'));
468
+		$new_form->set_items($form->get_items('edit'));
469 469
 		$new_form->save();
470 470
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
471
+		if ($new_form->exists()) {
472
+			$this->show_success(__('Form duplicated successfully', 'invoicing'));
473
+			$url = get_edit_post_link($new_form->get_id(), 'edit');
474 474
 		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
475
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
476
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
477 477
 		}
478 478
 
479
-		wp_redirect( $url );
479
+		wp_redirect($url);
480 480
 		exit;
481 481
 	}
482 482
 
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 *
486 486
 	 * @param array $args
487 487
      */
488
-    public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
488
+    public function send_customer_invoice($args) {
489
+		getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
490
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
491 491
 		exit;
492 492
 	}
493 493
 
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 	 *
497 497
 	 * @param array $args
498 498
      */
499
-    public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
499
+    public function send_customer_payment_reminder($args) {
500
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
502
+		if ($sent) {
503
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
504 504
 		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
505
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
506 506
 		}
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
508
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
509 509
 		exit;
510 510
 	}
511 511
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
518
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
519
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
520 520
 		exit;
521 521
 
522 522
 	}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
     public function admin_create_missing_pages() {
529 529
 		$installer = new GetPaid_Installer();
530 530
 		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
531
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
532
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
533 533
 		exit;
534 534
 	}
535 535
 
@@ -541,35 +541,35 @@  discard block
 block discarded – undo
541 541
 		global $wpdb;
542 542
 		$installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
544
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
545 545
 			$installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
547
+			if ($wpdb->last_error !== '') {
548
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
552
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
553 553
 			$installer->create_invoices_table();
554 554
 
555
-			if ( '' !== $wpdb->last_error ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
555
+			if ('' !== $wpdb->last_error) {
556
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
557 557
 			}
558 558
 		}
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
560
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
561 561
 			$installer->create_invoice_items_table();
562 562
 
563
-			if ( '' !== $wpdb->last_error ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
563
+			if ('' !== $wpdb->last_error) {
564
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
565 565
 			}
566 566
 		}
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
568
+		if (!$this->has_notices()) {
569
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
570 570
 		}
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
572
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
573 573
 		exit;
574 574
 	}
575 575
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 		$installer->migrate_old_invoices();
585 585
 
586 586
 		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
587
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
588 588
 
589 589
 		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
590
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
591 591
 		exit;
592 592
 
593 593
 	}
@@ -599,78 +599,78 @@  discard block
 block discarded – undo
599 599
     public function admin_download_customers() {
600 600
 		global $wpdb;
601 601
 
602
-		$output = fopen( 'php://output', 'w' );
602
+		$output = fopen('php://output', 'w');
603 603
 
604
-		if ( false === $output ) {
605
-			wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 );
604
+		if (false === $output) {
605
+			wp_die(esc_html__('Unsupported server', 'invoicing'), 500);
606 606
 		}
607 607
 
608
-		header( 'Content-Type:text/csv' );
609
-		header( 'Content-Disposition:attachment;filename=customers.csv' );
608
+		header('Content-Type:text/csv');
609
+		header('Content-Disposition:attachment;filename=customers.csv');
610 610
 
611 611
 		$post_types = '';
612 612
 
613
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
614
-			$post_types .= $wpdb->prepare( 'post_type=%s OR ', $post_type );
613
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
614
+			$post_types .= $wpdb->prepare('post_type=%s OR ', $post_type);
615 615
 		}
616 616
 
617
-		$post_types = rtrim( $post_types, ' OR' );
617
+		$post_types = rtrim($post_types, ' OR');
618 618
 
619
-		$customers = $wpdb->get_col( "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types" );
619
+		$customers = $wpdb->get_col("SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types");
620 620
 
621 621
 		$columns = array(
622
-			'name'       => __( 'Name', 'invoicing' ),
623
-			'email'      => __( 'Email', 'invoicing' ),
624
-			'country'    => __( 'Country', 'invoicing' ),
625
-			'state'      => __( 'State', 'invoicing' ),
626
-			'city'       => __( 'City', 'invoicing' ),
627
-			'zip'        => __( 'ZIP', 'invoicing' ),
628
-			'address'    => __( 'Address', 'invoicing' ),
629
-			'phone'      => __( 'Phone', 'invoicing' ),
630
-			'company'    => __( 'Company', 'invoicing' ),
631
-			'company_id' => __( 'Company ID', 'invoicing' ),
632
-			'invoices'   => __( 'Invoices', 'invoicing' ),
633
-			'total_raw'  => __( 'Total Spend', 'invoicing' ),
634
-			'signup'     => __( 'Date created', 'invoicing' ),
622
+			'name'       => __('Name', 'invoicing'),
623
+			'email'      => __('Email', 'invoicing'),
624
+			'country'    => __('Country', 'invoicing'),
625
+			'state'      => __('State', 'invoicing'),
626
+			'city'       => __('City', 'invoicing'),
627
+			'zip'        => __('ZIP', 'invoicing'),
628
+			'address'    => __('Address', 'invoicing'),
629
+			'phone'      => __('Phone', 'invoicing'),
630
+			'company'    => __('Company', 'invoicing'),
631
+			'company_id' => __('Company ID', 'invoicing'),
632
+			'invoices'   => __('Invoices', 'invoicing'),
633
+			'total_raw'  => __('Total Spend', 'invoicing'),
634
+			'signup'     => __('Date created', 'invoicing'),
635 635
 		);
636 636
 
637 637
 		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
638
+		fputcsv($output, array_values($columns));
639 639
 
640 640
 		// Loop through
641 641
 		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
642
+		foreach ($customers as $customer_id) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
644
+			$user = get_user_by('id', $customer_id);
645 645
 			$row  = array();
646
-			if ( empty( $user ) ) {
646
+			if (empty($user)) {
647 647
 				continue;
648 648
 			}
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+			foreach (array_keys($columns) as $column) {
651 651
 
652 652
 				$method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} elseif ( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} elseif ( is_callable( array( $table, $method ) ) ) {
659
-					$value = wp_strip_all_tags( $table->$method( $user ) );
654
+				if ('name' == $column) {
655
+					$value = esc_html($user->display_name);
656
+				} elseif ('email' == $column) {
657
+					$value = sanitize_email($user->user_email);
658
+				} elseif (is_callable(array($table, $method))) {
659
+					$value = wp_strip_all_tags($table->$method($user));
660 660
 				}
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
662
+				if (empty($value)) {
663
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
664 664
 				}
665 665
 
666 666
 				$row[] = $value;
667 667
 
668 668
 			}
669 669
 
670
-			fputcsv( $output, $row );
670
+			fputcsv($output, $row);
671 671
 		}
672 672
 
673
-		fclose( $output );
673
+		fclose($output);
674 674
 		exit;
675 675
 
676 676
 	}
@@ -680,27 +680,27 @@  discard block
 block discarded – undo
680 680
 	 *
681 681
 	 * @param array $data
682 682
      */
683
-    public function admin_install_plugin( $data ) {
683
+    public function admin_install_plugin($data) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
685
+		if (!empty($data['plugins'])) {
686 686
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687 687
 			wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+			foreach ($data['plugins'] as $slug => $file) {
690
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
691
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
692
+				$installed  = $upgrader->install($plugin_zip);
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
694
+				if (!is_wp_error($installed) && $installed) {
695
+					activate_plugin($file, '', false, true);
696 696
 				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
697
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
698 698
 				}
699 699
 }
700 700
 }
701 701
 
702
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
703
-		wp_safe_redirect( $redirect );
702
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
703
+		wp_safe_redirect($redirect);
704 704
 		exit;
705 705
 
706 706
 	}
@@ -710,41 +710,41 @@  discard block
 block discarded – undo
710 710
 	 *
711 711
 	 * @param array $data
712 712
      */
713
-    public function admin_connect_gateway( $data ) {
713
+    public function admin_connect_gateway($data) {
714 714
 
715
-		if ( ! empty( $data['plugin'] ) ) {
715
+		if (!empty($data['plugin'])) {
716 716
 
717
-			$gateway     = sanitize_key( $data['plugin'] );
718
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
717
+			$gateway     = sanitize_key($data['plugin']);
718
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
719 719
 
720
-			if ( ! empty( $connect_url ) ) {
721
-				wp_redirect( $connect_url );
720
+			if (!empty($connect_url)) {
721
+				wp_redirect($connect_url);
722 722
 				exit;
723 723
 			}
724 724
 
725
-			if ( 'stripe' == $data['plugin'] ) {
725
+			if ('stripe' == $data['plugin']) {
726 726
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
727 727
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
728 728
 				wp_cache_flush();
729 729
 
730
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
731
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
732
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
733
-					$upgrader->install( $plugin_zip );
730
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
731
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
732
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
733
+					$upgrader->install($plugin_zip);
734 734
 				}
735 735
 
736
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
736
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
737 737
 			}
738 738
 
739
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
740
-			if ( ! empty( $connect_url ) ) {
741
-				wp_redirect( $connect_url );
739
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
740
+			if (!empty($connect_url)) {
741
+				wp_redirect($connect_url);
742 742
 				exit;
743 743
 			}
744 744
 }
745 745
 
746
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
747
-		wp_safe_redirect( $redirect );
746
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
747
+		wp_safe_redirect($redirect);
748 748
 		exit;
749 749
 
750 750
 	}
@@ -758,35 +758,35 @@  discard block
 block discarded – undo
758 758
 
759 759
 		// Fetch all invoices that have discount codes.
760 760
 		$table    = $wpdb->prefix . 'getpaid_invoices';
761
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
761
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
762 762
 
763
-		foreach ( $invoices as $invoice ) {
763
+		foreach ($invoices as $invoice) {
764 764
 
765
-			$invoice = new WPInv_Invoice( $invoice );
765
+			$invoice = new WPInv_Invoice($invoice);
766 766
 
767
-			if ( ! $invoice->exists() ) {
767
+			if (!$invoice->exists()) {
768 768
 				continue;
769 769
 			}
770 770
 
771 771
 			// Abort if the discount does not exist or does not apply here.
772
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
773
-			if ( ! $discount->exists() ) {
772
+			$discount = new WPInv_Discount($invoice->get_discount_code());
773
+			if (!$discount->exists()) {
774 774
 				continue;
775 775
 			}
776 776
 
777
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
777
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
778 778
 			$invoice->recalculate_total();
779 779
 
780
-			if ( $invoice->get_total_discount() > 0 ) {
780
+			if ($invoice->get_total_discount() > 0) {
781 781
 				$invoice->save();
782 782
 			}
783 783
 }
784 784
 
785 785
 		// Show an admin message.
786
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
786
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
787 787
 
788 788
 		// Redirect the admin.
789
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
789
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
790 790
 		exit;
791 791
 
792 792
 	}
@@ -798,8 +798,8 @@  discard block
 block discarded – undo
798 798
      * @return array
799 799
 	 */
800 800
 	public function get_notices() {
801
-		$notices = get_option( 'wpinv_admin_notices' );
802
-        return is_array( $notices ) ? $notices : array();
801
+		$notices = get_option('wpinv_admin_notices');
802
+        return is_array($notices) ? $notices : array();
803 803
 	}
804 804
 
805 805
 	/**
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
      * @return array
810 810
 	 */
811 811
 	public function has_notices() {
812
-		return count( $this->get_notices() ) > 0;
812
+		return count($this->get_notices()) > 0;
813 813
 	}
814 814
 
815 815
 	/**
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 	 * @since       1.0.19
820 820
 	 */
821 821
 	public function clear_notices() {
822
-		delete_option( 'wpinv_admin_notices' );
822
+		delete_option('wpinv_admin_notices');
823 823
 	}
824 824
 
825 825
 	/**
@@ -828,16 +828,16 @@  discard block
 block discarded – undo
828 828
 	 * @access      public
829 829
 	 * @since       1.0.19
830 830
 	 */
831
-	public function save_notice( $type, $message ) {
831
+	public function save_notice($type, $message) {
832 832
 		$notices = $this->get_notices();
833 833
 
834
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) {
835
-			$notices[ $type ] = array();
834
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
835
+			$notices[$type] = array();
836 836
 		}
837 837
 
838
-		$notices[ $type ][] = $message;
838
+		$notices[$type][] = $message;
839 839
 
840
-		update_option( 'wpinv_admin_notices', $notices );
840
+		update_option('wpinv_admin_notices', $notices);
841 841
 	}
842 842
 
843 843
 	/**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 * @access      public
848 848
 	 * @since       1.0.19
849 849
 	 */
850
-	public function show_success( $msg ) {
851
-		$this->save_notice( 'success', $msg );
850
+	public function show_success($msg) {
851
+		$this->save_notice('success', $msg);
852 852
 	}
853 853
 
854 854
 	/**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param       string $msg The message to qeue.
859 859
 	 * @since       1.0.19
860 860
 	 */
861
-	public function show_error( $msg ) {
862
-		$this->save_notice( 'error', $msg );
861
+	public function show_error($msg) {
862
+		$this->save_notice('error', $msg);
863 863
 	}
864 864
 
865 865
 	/**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param       string $msg The message to qeue.
870 870
 	 * @since       1.0.19
871 871
 	 */
872
-	public function show_warning( $msg ) {
873
-		$this->save_notice( 'warning', $msg );
872
+	public function show_warning($msg) {
873
+		$this->save_notice('warning', $msg);
874 874
 	}
875 875
 
876 876
 	/**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param       string $msg The message to qeue.
881 881
 	 * @since       1.0.19
882 882
 	 */
883
-	public function show_info( $msg ) {
884
-		$this->save_notice( 'info', $msg );
883
+	public function show_info($msg) {
884
+		$this->save_notice('info', $msg);
885 885
 	}
886 886
 
887 887
 	/**
@@ -895,29 +895,29 @@  discard block
 block discarded – undo
895 895
         $notices = $this->get_notices();
896 896
         $this->clear_notices();
897 897
 
898
-		foreach ( $notices as $type => $messages ) {
898
+		foreach ($notices as $type => $messages) {
899 899
 
900
-			if ( ! is_array( $messages ) ) {
900
+			if (!is_array($messages)) {
901 901
 				continue;
902 902
 			}
903 903
 
904
-            $type  = esc_attr( $type );
905
-			foreach ( $messages as $message ) {
906
-				echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" );
904
+            $type = esc_attr($type);
905
+			foreach ($messages as $message) {
906
+				echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>");
907 907
             }
908 908
 }
909 909
 
910
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
910
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
911 911
 
912
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
913
-				$url     = wp_nonce_url(
914
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
912
+			if (!is_numeric(wpinv_get_option($page, false))) {
913
+				$url = wp_nonce_url(
914
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
915 915
 					'getpaid-nonce',
916 916
 					'getpaid-nonce'
917 917
 				);
918
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
919
-				$message2 = __( 'Generate Pages', 'invoicing' );
920
-				echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" );
918
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
919
+				$message2 = __('Generate Pages', 'invoicing');
920
+				echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>");
921 921
 				break;
922 922
 			}
923 923
 }
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/ayecode-ui-loader.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,40 +7,40 @@
 block discarded – undo
7 7
  * Bail if we are not in WP.
8 8
  */
9 9
 if ( ! defined( 'ABSPATH' ) ) {
10
-	exit;
10
+    exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16 16
 add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
18
-	$this_version = "0.1.71";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
22
-	}
17
+    global $ayecode_ui_version,$ayecode_ui_file_key;
18
+    $this_version = "0.1.71";
19
+    if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
+        $ayecode_ui_version = $this_version ;
21
+        $ayecode_ui_file_key = wp_hash( __FILE__ );
22
+    }
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28 28
 add_action('after_setup_theme', function () {
29
-	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
-	}
29
+    global $ayecode_ui_file_key;
30
+    if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
+        include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
+        include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
33
+    }
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39 39
 if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
42
-			return false;
43
-		}
44
-		return AUI::instance();
45
-	}
40
+    function aui(){
41
+        if(!class_exists("AUI",false)){
42
+            return false;
43
+        }
44
+        return AUI::instance();
45
+    }
46 46
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,39 +6,39 @@
 block discarded – undo
6 6
 /**
7 7
  * Bail if we are not in WP.
8 8
  */
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit;
11 11
 }
12 12
 
13 13
 /**
14 14
  * Set the version only if its the current newest while loading.
15 15
  */
16
-add_action('after_setup_theme', function () {
17
-	global $ayecode_ui_version,$ayecode_ui_file_key;
16
+add_action('after_setup_theme', function() {
17
+	global $ayecode_ui_version, $ayecode_ui_file_key;
18 18
 	$this_version = "0.1.71";
19
-	if(empty($ayecode_ui_version) || version_compare($this_version , $ayecode_ui_version, '>')){
20
-		$ayecode_ui_version = $this_version ;
21
-		$ayecode_ui_file_key = wp_hash( __FILE__ );
19
+	if (empty($ayecode_ui_version) || version_compare($this_version, $ayecode_ui_version, '>')) {
20
+		$ayecode_ui_version = $this_version;
21
+		$ayecode_ui_file_key = wp_hash(__FILE__);
22 22
 	}
23 23
 },0);
24 24
 
25 25
 /**
26 26
  * Load this version of WP Bootstrap Settings only if the file hash is the current one.
27 27
  */
28
-add_action('after_setup_theme', function () {
28
+add_action('after_setup_theme', function() {
29 29
 	global $ayecode_ui_file_key;
30
-	if($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash( __FILE__ )){
31
-		include_once( dirname( __FILE__ ) . '/includes/class-aui.php' );
32
-		include_once( dirname( __FILE__ ) . '/includes/ayecode-ui-settings.php' );
30
+	if ($ayecode_ui_file_key && $ayecode_ui_file_key == wp_hash(__FILE__)) {
31
+		include_once(dirname(__FILE__) . '/includes/class-aui.php');
32
+		include_once(dirname(__FILE__) . '/includes/ayecode-ui-settings.php');
33 33
 	}
34 34
 },1);
35 35
 
36 36
 /**
37 37
  * Add the function that calls the class.
38 38
  */
39
-if(!function_exists('aui')){
40
-	function aui(){
41
-		if(!class_exists("AUI",false)){
39
+if (!function_exists('aui')) {
40
+	function aui() {
41
+		if (!class_exists("AUI", false)) {
42 42
 			return false;
43 43
 		}
44 44
 		return AUI::instance();
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 2 patches
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  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( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
22
+    /**
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27
+    protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 8;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 8;
35 35
 
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title                = __( 'Direct bank transfer', 'invoicing' );
@@ -44,24 +44,24 @@  discard block
 block discarded – undo
44 44
         $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45 45
         $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+        add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
+        add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
+        add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
+        add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
+        add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
+        add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
53 53
 
54 54
     }
55 55
 
56 56
     /**
57
-	 * Process Payment.
58
-	 *
59
-	 * @param WPInv_Invoice $invoice Invoice.
60
-	 * @param array $submission_data Posted checkout fields.
61
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
-	 * @return array
63
-	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
57
+     * Process Payment.
58
+     *
59
+     * @param WPInv_Invoice $invoice Invoice.
60
+     * @param array $submission_data Posted checkout fields.
61
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62
+     * @return array
63
+     */
64
+    public function process_payment( $invoice, $submission_data, $submission ) {
65 65
 
66 66
         // Add a transaction id.
67 67
         $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
@@ -82,66 +82,66 @@  discard block
 block discarded – undo
82 82
     }
83 83
 
84 84
     /**
85
-	 * Output for the order received page.
86
-	 *
87
-	 * @param WPInv_Invoice $invoice Invoice.
88
-	 */
89
-	public function thankyou_page( $invoice ) {
85
+     * Output for the order received page.
86
+     *
87
+     * @param WPInv_Invoice $invoice Invoice.
88
+     */
89
+    public function thankyou_page( $invoice ) {
90 90
 
91 91
         if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
92 92
 
93
-			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93
+            echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95 95
             if ( ! empty( $this->instructions ) ) {
96 96
                 echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
97
-			}
97
+            }
98 98
 
99
-			$this->bank_details( $invoice );
99
+            $this->bank_details( $invoice );
100 100
 
101
-			echo '</div>';
101
+            echo '</div>';
102 102
 
103 103
         }
104 104
 
105
-	}
105
+    }
106 106
 
107 107
     /**
108
-	 * Add content to the WPI emails.
109
-	 *
110
-	 * @param WPInv_Invoice $invoice Invoice.
111
-	 * @param string     $email_type Email format: plain text or HTML.
112
-	 * @param bool     $sent_to_admin Sent to admin.
113
-	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
108
+     * Add content to the WPI emails.
109
+     *
110
+     * @param WPInv_Invoice $invoice Invoice.
111
+     * @param string     $email_type Email format: plain text or HTML.
112
+     * @param bool     $sent_to_admin Sent to admin.
113
+     */
114
+    public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+        if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
117 117
 
118
-			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118
+            echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+            if ( $this->instructions ) {
121
+                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+            $this->bank_details( $invoice );
125 125
 
126
-			echo '</div>';
126
+            echo '</div>';
127 127
 
128
-		}
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Get bank details and place into a list format.
134
-	 *
135
-	 * @param WPInv_Invoice $invoice Invoice.
136
-	 */
137
-	protected function bank_details( $invoice ) {
133
+     * Get bank details and place into a list format.
134
+     *
135
+     * @param WPInv_Invoice $invoice Invoice.
136
+     */
137
+    protected function bank_details( $invoice ) {
138 138
 
139
-		// Get the invoice country and country $locale.
140
-		$country = $invoice->get_country();
141
-		$locale  = $this->get_country_locale();
139
+        // Get the invoice country and country $locale.
140
+        $country = $invoice->get_country();
141
+        $locale  = $this->get_country_locale();
142 142
 
143
-		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+        // Get sortcode label in the $locale array and use appropriate one.
144
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
145 145
 
146 146
         $bank_fields = array(
147 147
             'ac_name'   => __( 'Account Name', 'invoicing' ),
@@ -160,11 +160,11 @@  discard block
 block discarded – undo
160 160
 
161 161
             if ( ! empty( $value ) ) {
162 162
                 $bank_info[ $field ] = array(
163
-					'label' => $label,
164
-					'value' => $value,
165
-				);
163
+                    'label' => $label,
164
+                    'value' => $value,
165
+                );
166 166
             }
167
-		}
167
+        }
168 168
 
169 169
         $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
170 170
 
@@ -172,139 +172,139 @@  discard block
 block discarded – undo
172 172
             return;
173 173
         }
174 174
 
175
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
175
+        echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
176
+
177
+        echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
178
+
179
+        foreach ( $bank_info as $key => $data ) {
180
+            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;
181
+        }
182
+
183
+        echo '</table>';
176 184
 
177
-		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
185
+    }
178 186
 
179
-		foreach ( $bank_info as $key => $data ) {
180
-			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;
181
-		}
187
+    /**
188
+     * Get country locale if localized.
189
+     *
190
+     * @return array
191
+     */
192
+    public function get_country_locale() {
193
+
194
+        if ( empty( $this->locale ) ) {
195
+
196
+            // Locale information to be used - only those that are not 'Sort Code'.
197
+            $this->locale = apply_filters(
198
+                'getpaid_get_bank_transfer_locale',
199
+                array(
200
+                    'AU' => array(
201
+                        'sortcode' => array(
202
+                            'label' => __( 'BSB', 'invoicing' ),
203
+                        ),
204
+                    ),
205
+                    'CA' => array(
206
+                        'sortcode' => array(
207
+                            'label' => __( 'Bank transit number', 'invoicing' ),
208
+                        ),
209
+                    ),
210
+                    'IN' => array(
211
+                        'sortcode' => array(
212
+                            'label' => __( 'IFSC', 'invoicing' ),
213
+                        ),
214
+                    ),
215
+                    'IT' => array(
216
+                        'sortcode' => array(
217
+                            'label' => __( 'Branch sort', 'invoicing' ),
218
+                        ),
219
+                    ),
220
+                    'NZ' => array(
221
+                        'sortcode' => array(
222
+                            'label' => __( 'Bank code', 'invoicing' ),
223
+                        ),
224
+                    ),
225
+                    'SE' => array(
226
+                        'sortcode' => array(
227
+                            'label' => __( 'Bank code', 'invoicing' ),
228
+                        ),
229
+                    ),
230
+                    'US' => array(
231
+                        'sortcode' => array(
232
+                            'label' => __( 'Routing number', 'invoicing' ),
233
+                        ),
234
+                    ),
235
+                    'ZA' => array(
236
+                        'sortcode' => array(
237
+                            'label' => __( 'Branch code', 'invoicing' ),
238
+                        ),
239
+                    ),
240
+                )
241
+            );
182 242
 
183
-		echo '</table>';
243
+        }
244
+
245
+        return $this->locale;
184 246
 
185 247
     }
186 248
 
187 249
     /**
188
-	 * Get country locale if localized.
189
-	 *
190
-	 * @return array
191
-	 */
192
-	public function get_country_locale() {
193
-
194
-		if ( empty( $this->locale ) ) {
195
-
196
-			// Locale information to be used - only those that are not 'Sort Code'.
197
-			$this->locale = apply_filters(
198
-				'getpaid_get_bank_transfer_locale',
199
-				array(
200
-					'AU' => array(
201
-						'sortcode' => array(
202
-							'label' => __( 'BSB', 'invoicing' ),
203
-						),
204
-					),
205
-					'CA' => array(
206
-						'sortcode' => array(
207
-							'label' => __( 'Bank transit number', 'invoicing' ),
208
-						),
209
-					),
210
-					'IN' => array(
211
-						'sortcode' => array(
212
-							'label' => __( 'IFSC', 'invoicing' ),
213
-						),
214
-					),
215
-					'IT' => array(
216
-						'sortcode' => array(
217
-							'label' => __( 'Branch sort', 'invoicing' ),
218
-						),
219
-					),
220
-					'NZ' => array(
221
-						'sortcode' => array(
222
-							'label' => __( 'Bank code', 'invoicing' ),
223
-						),
224
-					),
225
-					'SE' => array(
226
-						'sortcode' => array(
227
-							'label' => __( 'Bank code', 'invoicing' ),
228
-						),
229
-					),
230
-					'US' => array(
231
-						'sortcode' => array(
232
-							'label' => __( 'Routing number', 'invoicing' ),
233
-						),
234
-					),
235
-					'ZA' => array(
236
-						'sortcode' => array(
237
-							'label' => __( 'Branch code', 'invoicing' ),
238
-						),
239
-					),
240
-				)
241
-			);
242
-
243
-		}
244
-
245
-		return $this->locale;
246
-
247
-	}
248
-
249
-	/**
250
-	 * Filters the gateway settings.
251
-	 *
252
-	 * @param array $admin_settings
253
-	 */
254
-	public function admin_settings( $admin_settings ) {
250
+     * Filters the gateway settings.
251
+     *
252
+     * @param array $admin_settings
253
+     */
254
+    public function admin_settings( $admin_settings ) {
255 255
 
256 256
         $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' );
257
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
257
+        $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258 258
 
259
-		$locale  = $this->get_country_locale();
259
+        $locale  = $this->get_country_locale();
260 260
 
261
-		// Get sortcode label in the $locale array and use appropriate one.
262
-		$country  = wpinv_default_billing_country();
263
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
261
+        // Get sortcode label in the $locale array and use appropriate one.
262
+        $country  = wpinv_default_billing_country();
263
+        $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
264 264
 
265
-		$admin_settings['bank_transfer_ac_name'] = array(
265
+        $admin_settings['bank_transfer_ac_name'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_name',
268 268
             'name' => __( 'Account Name', 'invoicing' ),
269
-		);
269
+        );
270 270
 
271
-		$admin_settings['bank_transfer_ac_no'] = array(
271
+        $admin_settings['bank_transfer_ac_no'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_ac_no',
274 274
             'name' => __( 'Account Number', 'invoicing' ),
275
-		);
275
+        );
276 276
 
277
-		$admin_settings['bank_transfer_bank_name'] = array(
277
+        $admin_settings['bank_transfer_bank_name'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_bank_name',
280 280
             'name' => __( 'Bank Name', 'invoicing' ),
281
-		);
281
+        );
282 282
 
283
-		$admin_settings['bank_transfer_ifsc'] = array(
283
+        $admin_settings['bank_transfer_ifsc'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_ifsc',
286 286
             'name' => __( 'IFSC Code', 'invoicing' ),
287
-		);
287
+        );
288 288
 
289
-		$admin_settings['bank_transfer_iban'] = array(
289
+        $admin_settings['bank_transfer_iban'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_iban',
292 292
             'name' => __( 'IBAN', 'invoicing' ),
293
-		);
293
+        );
294 294
 
295
-		$admin_settings['bank_transfer_bic'] = array(
295
+        $admin_settings['bank_transfer_bic'] = array(
296 296
             'type' => 'text',
297 297
             'id'   => 'bank_transfer_bic',
298 298
             'name' => __( 'BIC/Swift Code', 'invoicing' ),
299
-		);
299
+        );
300 300
 
301
-		$admin_settings['bank_transfer_sort_code'] = array(
302
-			'type' => 'text',
303
-			'id'   => 'bank_transfer_sort_code',
304
-			'name' => $sortcode,
305
-		);
301
+        $admin_settings['bank_transfer_sort_code'] = array(
302
+            'type' => 'text',
303
+            'id'   => 'bank_transfer_sort_code',
304
+            'name' => $sortcode,
305
+        );
306 306
 
307
-		$admin_settings['bank_transfer_info'] = array(
307
+        $admin_settings['bank_transfer_info'] = array(
308 308
             'id'   => 'bank_transfer_info',
309 309
             'name' => __( 'Instructions', 'invoicing' ),
310 310
             'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
@@ -314,17 +314,17 @@  discard block
 block discarded – undo
314 314
             'rows' => 5,
315 315
         );
316 316
 
317
-		return $admin_settings;
318
-	}
317
+        return $admin_settings;
318
+    }
319 319
 
320
-	/**
321
-	 * Processes invoice addons.
322
-	 *
323
-	 * @param WPInv_Invoice $invoice
324
-	 * @param GetPaid_Form_Item[] $items
325
-	 * @return WPInv_Invoice
326
-	 */
327
-	public function process_addons( $invoice, $items ) {
320
+    /**
321
+     * Processes invoice addons.
322
+     *
323
+     * @param WPInv_Invoice $invoice
324
+     * @param GetPaid_Form_Item[] $items
325
+     * @return WPInv_Invoice
326
+     */
327
+    public function process_addons( $invoice, $items ) {
328 328
 
329 329
         foreach ( $items as $item ) {
330 330
             $invoice->add_item( $item );
@@ -332,66 +332,66 @@  discard block
 block discarded – undo
332 332
 
333 333
         $invoice->recalculate_total();
334 334
         $invoice->save();
335
-	}
335
+    }
336 336
 
337
-	/**
338
-	 * (Maybe) renews a bank transfer subscription profile.
339
-	 *
340
-	 *
337
+    /**
338
+     * (Maybe) renews a bank transfer subscription profile.
339
+     *
340
+     *
341 341
      * @param WPInv_Subscription $subscription
342
-	 */
343
-	public function maybe_renew_subscription( $subscription ) {
342
+     */
343
+    public function maybe_renew_subscription( $subscription ) {
344 344
 
345 345
         // Ensure its our subscription && it's active.
346 346
         if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
347
-			$subscription->create_payment();
347
+            $subscription->create_payment();
348 348
         }
349 349
 
350 350
     }
351 351
 
352
-	/**
353
-	 * Process a bank transfer payment.
354
-	 *
355
-	 *
352
+    /**
353
+     * Process a bank transfer payment.
354
+     *
355
+     *
356 356
      * @param WPInv_Invoice $invoice
357
-	 */
358
-	public function invoice_paid( $invoice ) {
359
-
360
-		// Abort if not paid by bank transfer.
361
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
362
-			return;
363
-		}
364
-
365
-		// Is it a parent payment?
366
-		if ( 0 == $invoice->get_parent_id() ) {
367
-
368
-			// (Maybe) activate subscriptions.
369
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
370
-
371
-			if ( ! empty( $subscriptions ) ) {
372
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
373
-
374
-				foreach ( $subscriptions as $subscription ) {
375
-					if ( $subscription->exists() ) {
376
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
378
-
379
-						$subscription->set_next_renewal_date( $expiry );
380
-						$subscription->set_date_created( current_time( 'mysql' ) );
381
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
382
-						$subscription->activate();
383
-					}
384
-				}
357
+     */
358
+    public function invoice_paid( $invoice ) {
359
+
360
+        // Abort if not paid by bank transfer.
361
+        if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
362
+            return;
363
+        }
364
+
365
+        // Is it a parent payment?
366
+        if ( 0 == $invoice->get_parent_id() ) {
367
+
368
+            // (Maybe) activate subscriptions.
369
+            $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
370
+
371
+            if ( ! empty( $subscriptions ) ) {
372
+                $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
373
+
374
+                foreach ( $subscriptions as $subscription ) {
375
+                    if ( $subscription->exists() ) {
376
+                        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
+                        $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
378
+
379
+                        $subscription->set_next_renewal_date( $expiry );
380
+                        $subscription->set_date_created( current_time( 'mysql' ) );
381
+                        $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
382
+                        $subscription->activate();
383
+                    }
384
+                }
385 385
 }
386 386
 } else {
387 387
 
388
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
388
+            $subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
389 389
 
390
-			// Renew the subscription.
391
-			if ( $subscription && $subscription->exists() ) {
392
-				$subscription->add_payment( array(), $invoice );
393
-				$subscription->renew();
394
-					}
390
+            // Renew the subscription.
391
+            if ( $subscription && $subscription->exists() ) {
392
+                $subscription->add_payment( array(), $invoice );
393
+                $subscription->renew();
394
+                    }
395 395
 }
396 396
 
397 397
     }
Please login to merge, or discard this patch.
Spacing   +89 added lines, -89 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.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups' );
27
+	protected $supports = array('subscription', 'addons', 'single_subscription_group', 'multiple_subscription_groups');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,17 +39,17 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
43
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
44
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
42
+        $this->title                = __('Direct bank transfer', 'invoicing');
43
+        $this->method_title         = __('Bank transfer', 'invoicing');
44
+        $this->checkout_button_text = __('Proceed', 'invoicing');
45
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
51
-		add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ) );
52
-		add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 );
47
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
48
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
49
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
50
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
51
+		add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'));
52
+		add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20);
53 53
 
54 54
     }
55 55
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
62 62
 	 * @return array
63 63
 	 */
64
-	public function process_payment( $invoice, $submission_data, $submission ) {
64
+	public function process_payment($invoice, $submission_data, $submission) {
65 65
 
66 66
         // Add a transaction id.
67
-        $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) );
67
+        $invoice->set_transaction_id($invoice->generate_key('bt_'));
68 68
 
69 69
         // Set it as pending payment.
70
-        if ( ! $invoice->needs_payment() ) {
70
+        if (!$invoice->needs_payment()) {
71 71
             $invoice->mark_paid();
72
-        } elseif ( ! $invoice->is_paid() ) {
73
-            $invoice->set_status( 'wpi-onhold' );
72
+        } elseif (!$invoice->is_paid()) {
73
+            $invoice->set_status('wpi-onhold');
74 74
         }
75 75
 
76 76
         // Save it.
77 77
         $invoice->save();
78 78
 
79 79
         // Send to the success page.
80
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
80
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
81 81
 
82 82
     }
83 83
 
@@ -86,17 +86,17 @@  discard block
 block discarded – undo
86 86
 	 *
87 87
 	 * @param WPInv_Invoice $invoice Invoice.
88 88
 	 */
89
-	public function thankyou_page( $invoice ) {
89
+	public function thankyou_page($invoice) {
90 90
 
91
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
91
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
92 92
 
93 93
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
94 94
 
95
-            if ( ! empty( $this->instructions ) ) {
96
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
95
+            if (!empty($this->instructions)) {
96
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
97 97
 			}
98 98
 
99
-			$this->bank_details( $invoice );
99
+			$this->bank_details($invoice);
100 100
 
101 101
 			echo '</div>';
102 102
 
@@ -111,17 +111,17 @@  discard block
 block discarded – undo
111 111
 	 * @param string     $email_type Email format: plain text or HTML.
112 112
 	 * @param bool     $sent_to_admin Sent to admin.
113 113
 	 */
114
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
114
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
115 115
 
116
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
116
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
117 117
 
118 118
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
119 119
 
120
-			if ( $this->instructions ) {
121
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
120
+			if ($this->instructions) {
121
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
122 122
             }
123 123
 
124
-			$this->bank_details( $invoice );
124
+			$this->bank_details($invoice);
125 125
 
126 126
 			echo '</div>';
127 127
 
@@ -134,50 +134,50 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Invoice $invoice Invoice.
136 136
 	 */
137
-	protected function bank_details( $invoice ) {
137
+	protected function bank_details($invoice) {
138 138
 
139 139
 		// Get the invoice country and country $locale.
140 140
 		$country = $invoice->get_country();
141 141
 		$locale  = $this->get_country_locale();
142 142
 
143 143
 		// Get sortcode label in the $locale array and use appropriate one.
144
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
144
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
145 145
 
146 146
         $bank_fields = array(
147
-            'ac_name'   => __( 'Account Name', 'invoicing' ),
148
-            'ac_no'     => __( 'Account Number', 'invoicing' ),
149
-            'bank_name' => __( 'Bank Name', 'invoicing' ),
150
-            'ifsc'      => __( 'IFSC code', 'invoicing' ),
151
-            'iban'      => __( 'IBAN', 'invoicing' ),
152
-            'bic'       => __( 'BIC/Swift code', 'invoicing' ),
147
+            'ac_name'   => __('Account Name', 'invoicing'),
148
+            'ac_no'     => __('Account Number', 'invoicing'),
149
+            'bank_name' => __('Bank Name', 'invoicing'),
150
+            'ifsc'      => __('IFSC code', 'invoicing'),
151
+            'iban'      => __('IBAN', 'invoicing'),
152
+            'bic'       => __('BIC/Swift code', 'invoicing'),
153 153
             'sort_code' => $sortcode,
154 154
         );
155 155
 
156 156
         $bank_info = array();
157 157
 
158
-        foreach ( $bank_fields as $field => $label ) {
159
-            $value = $this->get_option( $field );
158
+        foreach ($bank_fields as $field => $label) {
159
+            $value = $this->get_option($field);
160 160
 
161
-            if ( ! empty( $value ) ) {
162
-                $bank_info[ $field ] = array(
161
+            if (!empty($value)) {
162
+                $bank_info[$field] = array(
163 163
 					'label' => $label,
164 164
 					'value' => $value,
165 165
 				);
166 166
             }
167 167
 		}
168 168
 
169
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice );
169
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice);
170 170
 
171
-        if ( empty( $bank_info ) ) {
171
+        if (empty($bank_info)) {
172 172
             return;
173 173
         }
174 174
 
175
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL;
175
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL;
176 176
 
177 177
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
178 178
 
179
-		foreach ( $bank_info as $key => $data ) {
180
-			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;
179
+		foreach ($bank_info as $key => $data) {
180
+			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;
181 181
 		}
182 182
 
183 183
 		echo '</table>';
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 	 */
192 192
 	public function get_country_locale() {
193 193
 
194
-		if ( empty( $this->locale ) ) {
194
+		if (empty($this->locale)) {
195 195
 
196 196
 			// Locale information to be used - only those that are not 'Sort Code'.
197 197
 			$this->locale = apply_filters(
@@ -199,42 +199,42 @@  discard block
 block discarded – undo
199 199
 				array(
200 200
 					'AU' => array(
201 201
 						'sortcode' => array(
202
-							'label' => __( 'BSB', 'invoicing' ),
202
+							'label' => __('BSB', 'invoicing'),
203 203
 						),
204 204
 					),
205 205
 					'CA' => array(
206 206
 						'sortcode' => array(
207
-							'label' => __( 'Bank transit number', 'invoicing' ),
207
+							'label' => __('Bank transit number', 'invoicing'),
208 208
 						),
209 209
 					),
210 210
 					'IN' => array(
211 211
 						'sortcode' => array(
212
-							'label' => __( 'IFSC', 'invoicing' ),
212
+							'label' => __('IFSC', 'invoicing'),
213 213
 						),
214 214
 					),
215 215
 					'IT' => array(
216 216
 						'sortcode' => array(
217
-							'label' => __( 'Branch sort', 'invoicing' ),
217
+							'label' => __('Branch sort', 'invoicing'),
218 218
 						),
219 219
 					),
220 220
 					'NZ' => array(
221 221
 						'sortcode' => array(
222
-							'label' => __( 'Bank code', 'invoicing' ),
222
+							'label' => __('Bank code', 'invoicing'),
223 223
 						),
224 224
 					),
225 225
 					'SE' => array(
226 226
 						'sortcode' => array(
227
-							'label' => __( 'Bank code', 'invoicing' ),
227
+							'label' => __('Bank code', 'invoicing'),
228 228
 						),
229 229
 					),
230 230
 					'US' => array(
231 231
 						'sortcode' => array(
232
-							'label' => __( 'Routing number', 'invoicing' ),
232
+							'label' => __('Routing number', 'invoicing'),
233 233
 						),
234 234
 					),
235 235
 					'ZA' => array(
236 236
 						'sortcode' => array(
237
-							'label' => __( 'Branch code', 'invoicing' ),
237
+							'label' => __('Branch code', 'invoicing'),
238 238
 						),
239 239
 					),
240 240
 				)
@@ -251,51 +251,51 @@  discard block
 block discarded – undo
251 251
 	 *
252 252
 	 * @param array $admin_settings
253 253
 	 */
254
-	public function admin_settings( $admin_settings ) {
254
+	public function admin_settings($admin_settings) {
255 255
 
256
-        $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' );
257
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
256
+        $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');
257
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
258 258
 
259
-		$locale  = $this->get_country_locale();
259
+		$locale = $this->get_country_locale();
260 260
 
261 261
 		// Get sortcode label in the $locale array and use appropriate one.
262 262
 		$country  = wpinv_default_billing_country();
263
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
263
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
264 264
 
265 265
 		$admin_settings['bank_transfer_ac_name'] = array(
266 266
             'type' => 'text',
267 267
             'id'   => 'bank_transfer_ac_name',
268
-            'name' => __( 'Account Name', 'invoicing' ),
268
+            'name' => __('Account Name', 'invoicing'),
269 269
 		);
270 270
 
271 271
 		$admin_settings['bank_transfer_ac_no'] = array(
272 272
             'type' => 'text',
273 273
             'id'   => 'bank_transfer_ac_no',
274
-            'name' => __( 'Account Number', 'invoicing' ),
274
+            'name' => __('Account Number', 'invoicing'),
275 275
 		);
276 276
 
277 277
 		$admin_settings['bank_transfer_bank_name'] = array(
278 278
             'type' => 'text',
279 279
             'id'   => 'bank_transfer_bank_name',
280
-            'name' => __( 'Bank Name', 'invoicing' ),
280
+            'name' => __('Bank Name', 'invoicing'),
281 281
 		);
282 282
 
283 283
 		$admin_settings['bank_transfer_ifsc'] = array(
284 284
             'type' => 'text',
285 285
             'id'   => 'bank_transfer_ifsc',
286
-            'name' => __( 'IFSC Code', 'invoicing' ),
286
+            'name' => __('IFSC Code', 'invoicing'),
287 287
 		);
288 288
 
289 289
 		$admin_settings['bank_transfer_iban'] = array(
290 290
             'type' => 'text',
291 291
             'id'   => 'bank_transfer_iban',
292
-            'name' => __( 'IBAN', 'invoicing' ),
292
+            'name' => __('IBAN', 'invoicing'),
293 293
 		);
294 294
 
295 295
 		$admin_settings['bank_transfer_bic'] = array(
296 296
             'type' => 'text',
297 297
             'id'   => 'bank_transfer_bic',
298
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
298
+            'name' => __('BIC/Swift Code', 'invoicing'),
299 299
 		);
300 300
 
301 301
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -306,10 +306,10 @@  discard block
 block discarded – undo
306 306
 
307 307
 		$admin_settings['bank_transfer_info'] = array(
308 308
             'id'   => 'bank_transfer_info',
309
-            'name' => __( 'Instructions', 'invoicing' ),
310
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
309
+            'name' => __('Instructions', 'invoicing'),
310
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
311 311
             'type' => 'textarea',
312
-            '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' ),
312
+            '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'),
313 313
             'cols' => 50,
314 314
             'rows' => 5,
315 315
         );
@@ -324,10 +324,10 @@  discard block
 block discarded – undo
324 324
 	 * @param GetPaid_Form_Item[] $items
325 325
 	 * @return WPInv_Invoice
326 326
 	 */
327
-	public function process_addons( $invoice, $items ) {
327
+	public function process_addons($invoice, $items) {
328 328
 
329
-        foreach ( $items as $item ) {
330
-            $invoice->add_item( $item );
329
+        foreach ($items as $item) {
330
+            $invoice->add_item($item);
331 331
         }
332 332
 
333 333
         $invoice->recalculate_total();
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 	 *
341 341
      * @param WPInv_Subscription $subscription
342 342
 	 */
343
-	public function maybe_renew_subscription( $subscription ) {
343
+	public function maybe_renew_subscription($subscription) {
344 344
 
345 345
         // Ensure its our subscription && it's active.
346
-        if ( $this->id === $subscription->get_gateway() && $subscription->has_status( 'active trialling' ) ) {
346
+        if ($this->id === $subscription->get_gateway() && $subscription->has_status('active trialling')) {
347 347
 			$subscription->create_payment();
348 348
         }
349 349
 
@@ -355,41 +355,41 @@  discard block
 block discarded – undo
355 355
 	 *
356 356
      * @param WPInv_Invoice $invoice
357 357
 	 */
358
-	public function invoice_paid( $invoice ) {
358
+	public function invoice_paid($invoice) {
359 359
 
360 360
 		// Abort if not paid by bank transfer.
361
-		if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) {
361
+		if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) {
362 362
 			return;
363 363
 		}
364 364
 
365 365
 		// Is it a parent payment?
366
-		if ( 0 == $invoice->get_parent_id() ) {
366
+		if (0 == $invoice->get_parent_id()) {
367 367
 
368 368
 			// (Maybe) activate subscriptions.
369
-			$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
369
+			$subscriptions = getpaid_get_invoice_subscriptions($invoice);
370 370
 
371
-			if ( ! empty( $subscriptions ) ) {
372
-				$subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions );
371
+			if (!empty($subscriptions)) {
372
+				$subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions);
373 373
 
374
-				foreach ( $subscriptions as $subscription ) {
375
-					if ( $subscription->exists() ) {
376
-						$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
377
-						$expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
374
+				foreach ($subscriptions as $subscription) {
375
+					if ($subscription->exists()) {
376
+						$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
377
+						$expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
378 378
 
379
-						$subscription->set_next_renewal_date( $expiry );
380
-						$subscription->set_date_created( current_time( 'mysql' ) );
381
-						$subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() );
379
+						$subscription->set_next_renewal_date($expiry);
380
+						$subscription->set_date_created(current_time('mysql'));
381
+						$subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id());
382 382
 						$subscription->activate();
383 383
 					}
384 384
 				}
385 385
 }
386 386
 } else {
387 387
 
388
-			$subscription = getpaid_get_subscription( $invoice->get_subscription_id() );
388
+			$subscription = getpaid_get_subscription($invoice->get_subscription_id());
389 389
 
390 390
 			// Renew the subscription.
391
-			if ( $subscription && $subscription->exists() ) {
392
-				$subscription->add_payment( array(), $invoice );
391
+			if ($subscription && $subscription->exists()) {
392
+				$subscription->add_payment(array(), $invoice);
393 393
 				$subscription->renew();
394 394
 					}
395 395
 }
Please login to merge, or discard this patch.