Passed
Push — master ( c16653...06c25c )
by Brian
04:36
created
includes/admin/admin-pages.php 1 patch
Spacing   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 9999, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 9999, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_invoice' ) {
36
+    if ($post_type == 'wpi_invoice') {
37 37
         $actions = array();
38 38
     }
39 39
 
40
-    if ( $post_type == 'wpi_discount' ) {
41
-        $actions = wpinv_discount_row_actions( $post, $actions );
40
+    if ($post_type == 'wpi_discount') {
41
+        $actions = wpinv_discount_row_actions($post, $actions);
42 42
     }
43 43
 
44 44
     return $actions;
45 45
 }
46 46
 
47
-function wpinv_discount_row_actions( $discount, $row_actions ) {
48
-    $row_actions  = array();
49
-    $edit_link = get_edit_post_link( $discount->ID );
50
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
47
+function wpinv_discount_row_actions($discount, $row_actions) {
48
+    $row_actions = array();
49
+    $edit_link = get_edit_post_link($discount->ID);
50
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
51 51
 
52
-    if( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
53
-        $row_actions['deactivate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'deactivate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Deactivate', 'invoicing' ) . '</a>';
54
-    } elseif( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
55
-        $row_actions['activate'] = '<a href="' . esc_url( wp_nonce_url( add_query_arg( array( 'wpi_action' => 'activate_discount', 'discount' => $discount->ID ) ), 'wpinv_discount_nonce' ) ) . '">' . __( 'Activate', 'invoicing' ) . '</a>';
52
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
53
+        $row_actions['deactivate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'deactivate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Deactivate', 'invoicing') . '</a>';
54
+    } elseif (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
55
+        $row_actions['activate'] = '<a href="' . esc_url(wp_nonce_url(add_query_arg(array('wpi_action' => 'activate_discount', 'discount' => $discount->ID)), 'wpinv_discount_nonce')) . '">' . __('Activate', 'invoicing') . '</a>';
56 56
     }
57 57
 
58 58
     $delete_url = esc_url(
@@ -66,110 +66,110 @@  discard block
 block discarded – undo
66 66
             'wpinv_discount_nonce'
67 67
         )
68 68
     );
69
-    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __( 'Delete', 'invoicing' ) . '</a>';
69
+    $row_actions['delete'] = '<a href="' . $delete_url . '">' . __('Delete', 'invoicing') . '</a>';
70 70
 
71
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
71
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
72 72
 
73 73
     return $row_actions;
74 74
 }
75 75
 
76
-add_filter( 'list_table_primary_column', 'wpinv_table_primary_column', 10, 2 );
77
-function wpinv_table_primary_column( $default, $screen_id ) {
78
-    if ( 'edit-wpi_invoice' === $screen_id ) {
76
+add_filter('list_table_primary_column', 'wpinv_table_primary_column', 10, 2);
77
+function wpinv_table_primary_column($default, $screen_id) {
78
+    if ('edit-wpi_invoice' === $screen_id) {
79 79
         return 'name';
80 80
     }
81 81
 
82 82
     return $default;
83 83
 }
84 84
 
85
-function wpinv_discount_bulk_actions( $actions, $display = false ) {
86
-    if ( !$display ) {
85
+function wpinv_discount_bulk_actions($actions, $display = false) {
86
+    if (!$display) {
87 87
         return array();
88 88
     }
89 89
 
90 90
     $actions = array(
91
-        'activate'   => __( 'Activate', 'invoicing' ),
92
-        'deactivate' => __( 'Deactivate', 'invoicing' ),
93
-        'delete'     => __( 'Delete', 'invoicing' ),
91
+        'activate'   => __('Activate', 'invoicing'),
92
+        'deactivate' => __('Deactivate', 'invoicing'),
93
+        'delete'     => __('Delete', 'invoicing'),
94 94
     );
95 95
     $two = '';
96 96
     $which = 'top';
97 97
     echo '</div><div class="alignleft actions bulkactions">';
98
-    echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>';
99
-    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr( $which ) . "\">";
100
-    echo '<option value="-1">' . __( 'Bulk Actions' ) . "</option>";
98
+    echo '<label for="bulk-action-selector-' . esc_attr($which) . '" class="screen-reader-text">' . __('Select bulk action') . '</label>';
99
+    echo '<select name="action' . $two . '" id="bulk-action-selector-' . esc_attr($which) . "\">";
100
+    echo '<option value="-1">' . __('Bulk Actions') . "</option>";
101 101
 
102
-    foreach ( $actions as $name => $title ) {
102
+    foreach ($actions as $name => $title) {
103 103
         $class = 'edit' === $name ? ' class="hide-if-no-js"' : '';
104 104
 
105 105
         echo "" . '<option value="' . $name . '"' . $class . '>' . $title . "</option>";
106 106
     }
107 107
     echo "</select>";
108 108
 
109
-    submit_button( __( 'Apply' ), 'action', '', false, array( 'id' => "doaction$two" ) );
109
+    submit_button(__('Apply'), 'action', '', false, array('id' => "doaction$two"));
110 110
 
111 111
     echo '</div><div class="alignleft actions">';
112 112
 }
113
-add_filter( 'bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10 );
113
+add_filter('bulk_actions-edit-wpi_discount', 'wpinv_discount_bulk_actions', 10);
114 114
 
115
-function wpinv_disable_months_dropdown( $disable, $post_type ) {
116
-    if ( $post_type == 'wpi_discount' ) {
115
+function wpinv_disable_months_dropdown($disable, $post_type) {
116
+    if ($post_type == 'wpi_discount') {
117 117
         $disable = true;
118 118
     }
119 119
 
120 120
     return $disable;
121 121
 }
122
-add_filter( 'disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2 );
122
+add_filter('disable_months_dropdown', 'wpinv_disable_months_dropdown', 10, 2);
123 123
 
124 124
 function wpinv_restrict_manage_posts() {
125 125
     global $typenow;
126 126
 
127
-    if( 'wpi_discount' == $typenow ) {
127
+    if ('wpi_discount' == $typenow) {
128 128
         wpinv_discount_filters();
129 129
     }
130 130
 }
131
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
131
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
132 132
 
133 133
 function wpinv_discount_filters() {
134
-    wpinv_discount_bulk_actions( array(), true );
134
+    wpinv_discount_bulk_actions(array(), true);
135 135
 
136 136
     ?>
137 137
     <select name="discount_type" id="dropdown_wpinv_discount_type">
138
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
138
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
139 139
         <?php
140 140
             $types = wpinv_get_discount_types();
141 141
 
142
-            foreach ( $types as $name => $type ) {
143
-                echo '<option value="' . esc_attr( $name ) . '"';
142
+            foreach ($types as $name => $type) {
143
+                echo '<option value="' . esc_attr($name) . '"';
144 144
 
145
-                if ( isset( $_GET['discount_type'] ) )
146
-                    selected( $name, $_GET['discount_type'] );
145
+                if (isset($_GET['discount_type']))
146
+                    selected($name, $_GET['discount_type']);
147 147
 
148
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
148
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
149 149
             }
150 150
         ?>
151 151
     </select>
152 152
     <?php
153 153
 }
154 154
 
155
-function wpinv_request( $vars ) {
155
+function wpinv_request($vars) {
156 156
     global $typenow, $wp_query, $wp_post_statuses;
157 157
 
158
-    if ( 'wpi_invoice' === $typenow ) {
159
-        if ( !isset( $vars['post_status'] ) ) {
158
+    if ('wpi_invoice' === $typenow) {
159
+        if (!isset($vars['post_status'])) {
160 160
             $post_statuses = wpinv_get_invoice_statuses();
161 161
 
162
-            foreach ( $post_statuses as $status => $value ) {
163
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
164
-                    unset( $post_statuses[ $status ] );
162
+            foreach ($post_statuses as $status => $value) {
163
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
164
+                    unset($post_statuses[$status]);
165 165
                 }
166 166
             }
167 167
 
168
-            $vars['post_status'] = array_keys( $post_statuses );
168
+            $vars['post_status'] = array_keys($post_statuses);
169 169
         }
170 170
 
171
-        if ( isset( $vars['orderby'] ) ) {
172
-            if ( 'amount' == $vars['orderby'] ) {
171
+        if (isset($vars['orderby'])) {
172
+            if ('amount' == $vars['orderby']) {
173 173
                 $vars = array_merge(
174 174
                     $vars,
175 175
                     array(
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
                         'orderby'  => 'meta_value_num'
178 178
                     )
179 179
                 );
180
-            } else if ( 'customer' == $vars['orderby'] ) {
180
+            } else if ('customer' == $vars['orderby']) {
181 181
                 $vars = array_merge(
182 182
                     $vars,
183 183
                     array(
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
                         'orderby'  => 'meta_value'
186 186
                     )
187 187
                 );
188
-            } else if ( 'number' == $vars['orderby'] ) {
188
+            } else if ('number' == $vars['orderby']) {
189 189
                 $vars = array_merge(
190 190
                     $vars,
191 191
                     array(
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
                         'orderby'  => 'meta_value'
194 194
                     )
195 195
                 );
196
-            } else if ( 'payment_date' == $vars['orderby'] ) {
196
+            } else if ('payment_date' == $vars['orderby']) {
197 197
                 $vars = array_merge(
198 198
                     $vars,
199 199
                     array(
@@ -203,73 +203,73 @@  discard block
 block discarded – undo
203 203
                 );
204 204
             }
205 205
         }
206
-    } else if ( 'wpi_discount' == $typenow ) {
207
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
206
+    } else if ('wpi_discount' == $typenow) {
207
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
208 208
         // Filter vat rule type
209
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
209
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
210 210
             $meta_query[] = array(
211 211
                     'key'   => '_wpi_discount_type',
212
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
212
+                    'value' => sanitize_text_field($_GET['discount_type']),
213 213
                     'compare' => '='
214 214
                 );
215 215
         }
216 216
 
217
-        if ( !empty( $meta_query ) ) {
217
+        if (!empty($meta_query)) {
218 218
             $vars['meta_query'] = $meta_query;
219 219
         }
220 220
     }
221 221
 
222 222
     return $vars;
223 223
 }
224
-add_filter( 'request', 'wpinv_request' );
224
+add_filter('request', 'wpinv_request');
225 225
 
226
-function wpinv_item_type_class( $classes, $class, $post_id ) {
226
+function wpinv_item_type_class($classes, $class, $post_id) {
227 227
     global $pagenow, $typenow;
228 228
 
229
-    if ( $pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type( $post_id ) == $typenow ) {
230
-        if ( $type = get_post_meta( $post_id, '_wpinv_type', true ) ) {
231
-            $classes[] = 'wpi-type-' . sanitize_html_class( $type );
229
+    if ($pagenow == 'edit.php' && $typenow == 'wpi_item' && get_post_type($post_id) == $typenow) {
230
+        if ($type = get_post_meta($post_id, '_wpinv_type', true)) {
231
+            $classes[] = 'wpi-type-' . sanitize_html_class($type);
232 232
         }
233 233
 
234
-        if ( !wpinv_item_is_editable( $post_id ) ) {
234
+        if (!wpinv_item_is_editable($post_id)) {
235 235
             $classes[] = 'wpi-editable-n';
236 236
         }
237 237
     }
238 238
     return $classes;
239 239
 }
240
-add_filter( 'post_class', 'wpinv_item_type_class', 10, 3 );
240
+add_filter('post_class', 'wpinv_item_type_class', 10, 3);
241 241
 
242 242
 function wpinv_check_quick_edit() {
243 243
     global $pagenow, $current_screen, $wpinv_item_screen;
244 244
 
245
-    if ( $pagenow == 'edit.php' && !empty( $current_screen->post_type ) ) {
246
-        if ( empty( $wpinv_item_screen ) ) {
247
-            if ( $current_screen->post_type == 'wpi_item' ) {
245
+    if ($pagenow == 'edit.php' && !empty($current_screen->post_type)) {
246
+        if (empty($wpinv_item_screen)) {
247
+            if ($current_screen->post_type == 'wpi_item') {
248 248
                 $wpinv_item_screen = 'y';
249 249
             } else {
250 250
                 $wpinv_item_screen = 'n';
251 251
             }
252 252
         }
253 253
 
254
-        if ( $wpinv_item_screen == 'y' && $pagenow == 'edit.php' ) {
255
-            add_filter( 'post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
256
-            add_filter( 'page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2 );
254
+        if ($wpinv_item_screen == 'y' && $pagenow == 'edit.php') {
255
+            add_filter('post_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
256
+            add_filter('page_row_actions', 'wpinv_item_disable_quick_edit', 10, 2);
257 257
         }
258 258
     }
259 259
 }
260
-add_action( 'admin_head', 'wpinv_check_quick_edit', 10 );
260
+add_action('admin_head', 'wpinv_check_quick_edit', 10);
261 261
 
262
-function wpinv_item_disable_quick_edit( $actions = array(), $row = null ) {
263
-    if ( isset( $actions['inline hide-if-no-js'] ) ) {
264
-        unset( $actions['inline hide-if-no-js'] );
262
+function wpinv_item_disable_quick_edit($actions = array(), $row = null) {
263
+    if (isset($actions['inline hide-if-no-js'])) {
264
+        unset($actions['inline hide-if-no-js']);
265 265
     }
266 266
 
267
-    if ( !empty( $row->post_type ) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable( $row ) ) {
268
-        if ( isset( $actions['trash'] ) ) {
269
-            unset( $actions['trash'] );
267
+    if (!empty($row->post_type) && $row->post_type == 'wpi_item' && !wpinv_item_is_editable($row)) {
268
+        if (isset($actions['trash'])) {
269
+            unset($actions['trash']);
270 270
         }
271
-        if ( isset( $actions['delete'] ) ) {
272
-            unset( $actions['delete'] );
271
+        if (isset($actions['delete'])) {
272
+            unset($actions['delete']);
273 273
         }
274 274
     }
275 275
 
@@ -286,19 +286,19 @@  discard block
 block discarded – undo
286 286
  * @param int $post_parent (default: 0) Parent for the new page
287 287
  * @return int page ID
288 288
  */
289
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
289
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
290 290
     global $wpdb;
291 291
 
292
-    $option_value = wpinv_get_option( $option );
292
+    $option_value = wpinv_get_option($option);
293 293
 
294
-    if ( $option_value > 0 && ( $page_object = get_post( $option_value ) ) ) {
295
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
294
+    if ($option_value > 0 && ($page_object = get_post($option_value))) {
295
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
296 296
             // Valid page is already in place
297 297
             return $page_object->ID;
298 298
         }
299 299
     }
300 300
 
301
-    if(!empty($post_parent)){
301
+    if (!empty($post_parent)) {
302 302
         $page = get_page_by_path($post_parent);
303 303
         if ($page) {
304 304
             $post_parent = $page->ID;
@@ -307,40 +307,40 @@  discard block
 block discarded – undo
307 307
         }
308 308
     }
309 309
 
310
-    if ( strlen( $page_content ) > 0 ) {
310
+    if (strlen($page_content) > 0) {
311 311
         // Search for an existing page with the specified page content (typically a shortcode)
312
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
312
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
313 313
     } else {
314 314
         // Search for an existing page with the specified page slug
315
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
315
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
316 316
     }
317 317
 
318
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
318
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
319 319
 
320
-    if ( $valid_page_found ) {
321
-        if ( $option ) {
322
-            wpinv_update_option( $option, $valid_page_found );
320
+    if ($valid_page_found) {
321
+        if ($option) {
322
+            wpinv_update_option($option, $valid_page_found);
323 323
         }
324 324
         return $valid_page_found;
325 325
     }
326 326
 
327 327
     // Search for a matching valid trashed page
328
-    if ( strlen( $page_content ) > 0 ) {
328
+    if (strlen($page_content) > 0) {
329 329
         // Search for an existing page with the specified page content (typically a shortcode)
330
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
330
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
331 331
     } else {
332 332
         // Search for an existing page with the specified page slug
333
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
333
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
334 334
     }
335 335
 
336
-    if ( $trashed_page_found ) {
336
+    if ($trashed_page_found) {
337 337
         $page_id   = $trashed_page_found;
338 338
         $page_data = array(
339 339
             'ID'             => $page_id,
340 340
             'post_status'    => 'publish',
341 341
             'post_parent'    => $post_parent,
342 342
         );
343
-        wp_update_post( $page_data );
343
+        wp_update_post($page_data);
344 344
     } else {
345 345
         $page_data = array(
346 346
             'post_status'    => 'publish',
@@ -352,11 +352,11 @@  discard block
 block discarded – undo
352 352
             'post_parent'    => $post_parent,
353 353
             'comment_status' => 'closed',
354 354
         );
355
-        $page_id = wp_insert_post( $page_data );
355
+        $page_id = wp_insert_post($page_data);
356 356
     }
357 357
 
358
-    if ( $option ) {
359
-        wpinv_update_option( $option, (int)$page_id );
358
+    if ($option) {
359
+        wpinv_update_option($option, (int) $page_id);
360 360
     }
361 361
 
362 362
     return $page_id;
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * Please use GetPaid_Notification_Email_Sender
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /*
12 12
 |--------------------------------------------------------------------------
@@ -17,19 +17,19 @@  discard block
 block discarded – undo
17 17
 /**
18 18
  * Generates the email header.
19 19
  */
20
-function wpinv_email_header( $email_heading ) {
21
-    wpinv_get_template( 'emails/wpinv-email-header.php', compact( 'email_heading' ) );
20
+function wpinv_email_header($email_heading) {
21
+    wpinv_get_template('emails/wpinv-email-header.php', compact('email_heading'));
22 22
 }
23
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
23
+add_action('wpinv_email_header', 'wpinv_email_header');
24 24
 
25 25
 
26 26
 /**
27 27
  * Generates the email footer.
28 28
  */
29 29
 function wpinv_email_footer() {
30
-    wpinv_get_template( 'emails/wpinv-email-footer.php' );
30
+    wpinv_get_template('emails/wpinv-email-footer.php');
31 31
 }
32
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
32
+add_action('wpinv_email_footer', 'wpinv_email_footer');
33 33
 
34 34
 
35 35
 /**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
  * @param string $email_type
40 40
  * @param bool $sent_to_admin
41 41
  */
42
-function wpinv_email_invoice_details( $invoice,  $email_type, $sent_to_admin ) {
42
+function wpinv_email_invoice_details($invoice, $email_type, $sent_to_admin) {
43 43
 
44
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
45
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', $args );
44
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
45
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', $args);
46 46
 
47 47
 }
48
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
48
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
49 49
 
50 50
 
51 51
 /**
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
  * @param string $email_type
56 56
  * @param bool $sent_to_admin
57 57
  */
58
-function wpinv_email_invoice_items( $invoice, $email_type, $sent_to_admin ) {
58
+function wpinv_email_invoice_items($invoice, $email_type, $sent_to_admin) {
59 59
 
60 60
     // Prepare line items.
61
-    $columns = getpaid_invoice_item_columns( $invoice );
62
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
61
+    $columns = getpaid_invoice_item_columns($invoice);
62
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
63 63
 
64 64
     // Load the template.
65
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', compact( 'invoice', 'columns', 'email_type', 'sent_to_admin' ) );
65
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', compact('invoice', 'columns', 'email_type', 'sent_to_admin'));
66 66
 
67 67
 }
68
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
68
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
69 69
 
70 70
 
71 71
 /**
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
  * @param string $email_type
76 76
  * @param bool $sent_to_admin
77 77
  */
78
-function wpinv_email_billing_details( $invoice, $email_type, $sent_to_admin ) {
78
+function wpinv_email_billing_details($invoice, $email_type, $sent_to_admin) {
79 79
 
80
-    $args = compact( 'invoice', 'email_type', 'sent_to_admin' );
81
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', $args );
80
+    $args = compact('invoice', 'email_type', 'sent_to_admin');
81
+    wpinv_get_template('emails/wpinv-email-billing-details.php', $args);
82 82
 
83 83
 }
84
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
84
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
85 85
 
86 86
 /**
87 87
  * Returns email css.
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
  */
90 90
 function getpaid_get_email_css() {
91 91
 
92
-    $css = wpinv_get_template_html( 'emails/wpinv-email-styles.php' );
93
-    return apply_filters( 'wpinv_email_styles', $css );
92
+    $css = wpinv_get_template_html('emails/wpinv-email-styles.php');
93
+    return apply_filters('wpinv_email_styles', $css);
94 94
 
95 95
 }
96 96
 
@@ -101,17 +101,17 @@  discard block
 block discarded – undo
101 101
  * @return string
102 102
  * 
103 103
  */
104
-function wpinv_email_style_body( $content ) {
104
+function wpinv_email_style_body($content) {
105 105
 
106 106
     $css = getpaid_get_email_css();
107 107
 
108 108
     // Inline the css.
109 109
     try {
110
-        $emogrifier = new Emogrifier( $content, $css );
110
+        $emogrifier = new Emogrifier($content, $css);
111 111
         $_content   = $emogrifier->emogrify();
112 112
         $content    = $_content;
113
-    } catch ( Exception $e ) {
114
-        wpinv_error_log( $e->getMessage(), 'emogrifier' );
113
+    } catch (Exception $e) {
114
+        wpinv_error_log($e->getMessage(), 'emogrifier');
115 115
     }
116 116
 
117 117
     return $content;
@@ -120,37 +120,37 @@  discard block
 block discarded – undo
120 120
 
121 121
 // Backwards compatibility.
122 122
 function wpinv_init_transactional_emails() {
123
-    foreach ( apply_filters( 'wpinv_email_actions', array() ) as $action ) {
124
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
123
+    foreach (apply_filters('wpinv_email_actions', array()) as $action) {
124
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
125 125
     }
126 126
 }
127
-add_action( 'init', 'wpinv_init_transactional_emails' );
127
+add_action('init', 'wpinv_init_transactional_emails');
128 128
 
129 129
 function wpinv_send_transactional_email() {
130 130
     $args       = func_get_args();
131 131
     $function   = current_filter() . '_notification';
132
-    do_action_ref_array( $function, $args );
132
+    do_action_ref_array($function, $args);
133 133
 }
134 134
 
135 135
 function wpinv_mail_get_from_address() {
136
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
137
-    return sanitize_email( $from_address );
136
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
137
+    return sanitize_email($from_address);
138 138
 }
139 139
 
140 140
 function wpinv_mail_get_from_name() {
141
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
142
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
141
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
142
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
143 143
 }
144 144
 
145
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
146
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
147
-    return ( $active ? true : false );
145
+function wpinv_mail_admin_bcc_active($mail_type = '') {
146
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
147
+    return ($active ? true : false);
148 148
 }
149 149
     
150
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
151
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
150
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
151
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
152 152
 
153
-    switch ( $email_type ) {
153
+    switch ($email_type) {
154 154
         case 'html' :
155 155
             $content_type = 'text/html';
156 156
             break;
@@ -175,11 +175,11 @@  discard block
 block discarded – undo
175 175
  * @param array        $attachments Any files to attach to the email.
176 176
  * @param string|array $cc An email or array of extra emails to send a copy of the email to.
177 177
  */
178
-function wpinv_mail_send( $to, $subject, $message, $deprecated, $attachments = array(), $cc = array() ) {
178
+function wpinv_mail_send($to, $subject, $message, $deprecated, $attachments = array(), $cc = array()) {
179 179
 
180 180
     $mailer  = new GetPaid_Notification_Email_Sender();
181
-    $message = wpinv_email_style_body( $message );
182
-    $to      = array_merge( wpinv_parse_list( $to ), wpinv_parse_list( $cc ) );
181
+    $message = wpinv_email_style_body($message);
182
+    $to      = array_merge(wpinv_parse_list($to), wpinv_parse_list($cc));
183 183
 
184 184
 	return $mailer->send(
185 185
         $to,
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
  * @return array
197 197
  */
198 198
 function wpinv_get_emails() {
199
-    return apply_filters( 'wpinv_get_emails', wpinv_get_data( 'email-settings' ) );
199
+    return apply_filters('wpinv_get_emails', wpinv_get_data('email-settings'));
200 200
 }
201 201
 
202 202
 /**
@@ -205,172 +205,172 @@  discard block
 block discarded – undo
205 205
  * @param array $settings
206 206
  * @return array
207 207
  */
208
-function wpinv_settings_emails( $settings = array() ) {
209
-    $settings = array_merge( $settings, wpinv_get_emails() );
210
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
208
+function wpinv_settings_emails($settings = array()) {
209
+    $settings = array_merge($settings, wpinv_get_emails());
210
+    return apply_filters('wpinv_settings_get_emails', $settings);
211 211
 }
212
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
212
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
213 213
 
214 214
 /**
215 215
  * Filter email section names.
216 216
  * 
217 217
  */
218
-function wpinv_settings_sections_emails( $settings ) {
219
-    foreach  ( wpinv_get_emails() as $key => $email) {
220
-        $settings[$key] = ! empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : strip_tags( $key );
218
+function wpinv_settings_sections_emails($settings) {
219
+    foreach (wpinv_get_emails() as $key => $email) {
220
+        $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : strip_tags($key);
221 221
     }
222 222
 
223 223
     return $settings;    
224 224
 }
225
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
225
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
226 226
 
227
-function wpinv_email_is_enabled( $email_type ) {
227
+function wpinv_email_is_enabled($email_type) {
228 228
     $emails = wpinv_get_emails();
229
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
229
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
230 230
 
231
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
231
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
232 232
 }
233 233
 
234
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
235
-    switch ( $email_type ) {
234
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
235
+    switch ($email_type) {
236 236
         case 'new_invoice':
237 237
         case 'cancelled_invoice':
238 238
         case 'failed_invoice':
239 239
             $recipient  = wpinv_get_admin_email();
240 240
         break;
241 241
         default:
242
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
243
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
242
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
243
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
244 244
         break;
245 245
     }
246 246
 
247
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
247
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
248 248
 }
249 249
 
250 250
 /**
251 251
  * Returns invoice CC recipients
252 252
  */
253
-function wpinv_email_get_cc_recipients( $email_type = '', $invoice_id = 0, $invoice = array() ) {
254
-    switch ( $email_type ) {
253
+function wpinv_email_get_cc_recipients($email_type = '', $invoice_id = 0, $invoice = array()) {
254
+    switch ($email_type) {
255 255
         case 'new_invoice':
256 256
         case 'cancelled_invoice':
257 257
         case 'failed_invoice':
258 258
             return array();
259 259
         break;
260 260
         default:
261
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
262
-            $recipient  = empty( $invoice ) ? '' : get_post_meta( $invoice->ID, 'wpinv_email_cc', true );
263
-            if ( empty( $recipient ) ) {
261
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
262
+            $recipient  = empty($invoice) ? '' : get_post_meta($invoice->ID, 'wpinv_email_cc', true);
263
+            if (empty($recipient)) {
264 264
                 return array();
265 265
             }
266
-            return  array_filter( array_map( 'trim', explode( ',', $recipient ) ) );
266
+            return  array_filter(array_map('trim', explode(',', $recipient)));
267 267
         break;
268 268
     }
269 269
 
270 270
 }
271 271
 
272
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
273
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
274
-    $subject    = __( $subject, 'invoicing' );
272
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
273
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
274
+    $subject    = __($subject, 'invoicing');
275 275
 
276
-    $subject    = wpinv_email_format_text( $subject, $invoice );
276
+    $subject    = wpinv_email_format_text($subject, $invoice);
277 277
 
278
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
278
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
279 279
 }
280 280
 
281
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
282
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
283
-    $email_heading = __( $email_heading, 'invoicing' );
281
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
282
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
283
+    $email_heading = __($email_heading, 'invoicing');
284 284
 
285
-    $email_heading = wpinv_email_format_text( $email_heading, $invoice );
285
+    $email_heading = wpinv_email_format_text($email_heading, $invoice);
286 286
 
287
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
287
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
288 288
 }
289 289
 
290
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
291
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
292
-    $content    = __( $content, 'invoicing' );
290
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
291
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
292
+    $content    = __($content, 'invoicing');
293 293
 
294
-    $content    = wpinv_email_format_text( $content, $invoice );
294
+    $content    = wpinv_email_format_text($content, $invoice);
295 295
 
296
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
296
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
297 297
 }
298 298
 
299
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
299
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
300 300
     $from_name = wpinv_mail_get_from_address();
301 301
     $from_email = wpinv_mail_get_from_address();
302 302
     
303
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
303
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
304 304
     
305
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
306
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
305
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
306
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
307 307
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
308 308
     
309
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
309
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
310 310
 }
311 311
 
312
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
312
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
313 313
     $attachments = array();
314 314
     
315
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
315
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
316 316
 }
317 317
 
318 318
 /**
319 319
  * Searches for and replaces certain placeholders in an email.
320 320
  */
321
-function wpinv_email_format_text( $content, $invoice ) {
321
+function wpinv_email_format_text($content, $invoice) {
322 322
 
323 323
     $replace_array = array(
324 324
         '{site_title}'      => wpinv_get_blogname(),
325
-        '{date}'            => getpaid_format_date( current_time( 'mysql' ) ),
325
+        '{date}'            => getpaid_format_date(current_time('mysql')),
326 326
     );
327 327
 
328
-    $invoice = new WPInv_Invoice( $invoice );
328
+    $invoice = new WPInv_Invoice($invoice);
329 329
 
330
-    if ( $invoice->get_id() ) {
330
+    if ($invoice->get_id()) {
331 331
 
332 332
         $replace_array = array_merge(
333 333
             $replace_array, 
334 334
             array(
335
-                '{name}'            => sanitize_text_field( $invoice->get_user_full_name() ),
336
-                '{full_name}'       => sanitize_text_field( $invoice->get_user_full_name() ),
337
-                '{first_name}'      => sanitize_text_field( $invoice->get_first_name() ),
338
-                '{last_name}'       => sanitize_text_field( $invoice->get_last_name() ),
339
-                '{email}'           => sanitize_email( $invoice->get_email() ),
340
-                '{invoice_number}'  => sanitize_text_field( $invoice->get_number() ),
341
-                '{invoice_total}'   => wpinv_price( wpinv_format_amount( $invoice->get_total( true ) ) ),
342
-                '{invoice_link}'    => esc_url( $invoice->get_view_url() ),
343
-                '{invoice_pay_link}'=> esc_url( $invoice->get_checkout_payment_url() ),
344
-                '{invoice_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
345
-                '{invoice_due_date}'=> date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
346
-                '{invoice_quote}'   => sanitize_text_field( $invoice->get_type() ),
347
-                '{invoice_label}'   => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
348
-                '{is_was}'          => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
335
+                '{name}'            => sanitize_text_field($invoice->get_user_full_name()),
336
+                '{full_name}'       => sanitize_text_field($invoice->get_user_full_name()),
337
+                '{first_name}'      => sanitize_text_field($invoice->get_first_name()),
338
+                '{last_name}'       => sanitize_text_field($invoice->get_last_name()),
339
+                '{email}'           => sanitize_email($invoice->get_email()),
340
+                '{invoice_number}'  => sanitize_text_field($invoice->get_number()),
341
+                '{invoice_total}'   => wpinv_price(wpinv_format_amount($invoice->get_total(true))),
342
+                '{invoice_link}'    => esc_url($invoice->get_view_url()),
343
+                '{invoice_pay_link}'=> esc_url($invoice->get_checkout_payment_url()),
344
+                '{invoice_date}'    => date(get_option('date_format'), strtotime($invoice->get_date_created(), current_time('timestamp'))),
345
+                '{invoice_due_date}'=> date(get_option('date_format'), strtotime($invoice->get_due_date(), current_time('timestamp'))),
346
+                '{invoice_quote}'   => sanitize_text_field($invoice->get_type()),
347
+                '{invoice_label}'   => sanitize_text_field(ucfirst($invoice->get_type())),
348
+                '{is_was}'          => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
349 349
             )
350 350
         );
351 351
 
352 352
     }
353 353
 
354 354
     // Let third party plugins filter the arra.
355
-    $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice );
355
+    $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice);
356 356
 
357
-    foreach ( $replace_array as $key => $value ) {
358
-        $content = str_replace( $key, $value, $content );
357
+    foreach ($replace_array as $key => $value) {
358
+        $content = str_replace($key, $value, $content);
359 359
     }
360 360
 
361
-    return apply_filters( 'wpinv_email_content_replace', $content );
361
+    return apply_filters('wpinv_email_content_replace', $content);
362 362
 }
363 363
 
364 364
 
365
-function wpinv_email_wrap_message( $message ) {
365
+function wpinv_email_wrap_message($message) {
366 366
     // Buffer
367 367
     ob_start();
368 368
 
369
-    do_action( 'wpinv_email_header' );
369
+    do_action('wpinv_email_header');
370 370
 
371
-    echo wpautop( wptexturize( $message ) );
371
+    echo wpautop(wptexturize($message));
372 372
 
373
-    do_action( 'wpinv_email_footer' );
373
+    do_action('wpinv_email_footer');
374 374
 
375 375
     // Get contents
376 376
     $message = ob_get_clean();
@@ -378,21 +378,21 @@  discard block
 block discarded – undo
378 378
     return $message;
379 379
 }
380 380
 
381
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type ) {
382
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
383
-        $date_format = get_option( 'date_format' );
384
-        $time_format = get_option( 'time_format' );
381
+function wpinv_add_notes_to_invoice_email($invoice, $email_type) {
382
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
383
+        $date_format = get_option('date_format');
384
+        $time_format = get_option('time_format');
385 385
         ?>
386 386
         <div id="wpinv-email-notes">
387
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
387
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
388 388
             <ol class="wpinv-notes-lists">
389 389
         <?php
390
-        foreach ( $invoice_notes as $note ) {
391
-            $note_time = strtotime( $note->comment_date );
390
+        foreach ($invoice_notes as $note) {
391
+            $note_time = strtotime($note->comment_date);
392 392
             ?>
393 393
             <li class="comment wpinv-note">
394
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
395
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
394
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
395
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
396 396
             </li>
397 397
             <?php
398 398
         }
@@ -401,4 +401,4 @@  discard block
 block discarded – undo
401 401
         <?php
402 402
     }
403 403
 }
404
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
404
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions.php 1 patch
Spacing   +110 added lines, -110 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
  * Main Subscriptions class.
10 10
  *
@@ -14,31 +14,31 @@  discard block
 block discarded – undo
14 14
     /**
15 15
 	 * Class constructor.
16 16
 	 */
17
-    public function __construct(){
17
+    public function __construct() {
18 18
 
19 19
         // Fire gateway specific hooks when a subscription changes.
20
-        add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 );
20
+        add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3);
21 21
 
22 22
         // De-activate a subscription whenever the invoice changes payment statuses.
23
-        add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 );
24
-        add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 );
25
-        add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 );
26
-        add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 );
23
+        add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20);
24
+        add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20);
25
+        add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20);
26
+        add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20);
27 27
 
28 28
         // Handles subscription cancelations.
29
-        add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) );
29
+        add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription'));
30 30
 
31 31
         // Create a subscription whenever an invoice is created, (and update it when it is updated).
32
-        add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) );
33
-        add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) );
32
+        add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription'));
33
+        add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription'));
34 34
 
35 35
         // Handles admin subscription update actions.
36
-        add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) );
37
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) );
38
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) );
36
+        add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription'));
37
+        add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription'));
38
+        add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription'));
39 39
 
40 40
         // Filter invoice item row actions.
41
-        add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 );
41
+        add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3);
42 42
     }
43 43
 
44 44
     /**
@@ -47,19 +47,19 @@  discard block
 block discarded – undo
47 47
      * @param WPInv_Invoice $invoice
48 48
      * @return WPInv_Subscription|bool
49 49
      */
50
-    public function get_invoice_subscription( $invoice ) {
50
+    public function get_invoice_subscription($invoice) {
51 51
         $subscription_id = $invoice->get_subscription_id();
52 52
 
53 53
         // Fallback to the parent invoice if the child invoice has no subscription id.
54
-        if ( empty( $subscription_id && $invoice->is_renewal() ) ) {
54
+        if (empty($subscription_id && $invoice->is_renewal())) {
55 55
             $subscription_id = $invoice->get_parent_payment()->get_subscription_id();
56 56
         }
57 57
 
58 58
         // Fetch the subscription.
59
-        $subscription = new WPInv_Subscription( $subscription_id );
59
+        $subscription = new WPInv_Subscription($subscription_id);
60 60
 
61 61
         // Return subscription or use a fallback for backwards compatibility.
62
-        return $subscription->get_id() ? $subscription : wpinv_get_subscription( $invoice );
62
+        return $subscription->get_id() ? $subscription : wpinv_get_subscription($invoice);
63 63
     }
64 64
 
65 65
     /**
@@ -67,16 +67,16 @@  discard block
 block discarded – undo
67 67
      * 
68 68
      * @param WPInv_Invoice $invoice
69 69
      */
70
-    public function maybe_deactivate_invoice_subscription( $invoice ) {
70
+    public function maybe_deactivate_invoice_subscription($invoice) {
71 71
 
72
-        $subscription = $this->get_invoice_subscription( $invoice );
72
+        $subscription = $this->get_invoice_subscription($invoice);
73 73
 
74 74
         // Abort if the subscription is missing or not active.
75
-        if ( empty( $subscription ) || ! $subscription->is_active() ) {
75
+        if (empty($subscription) || !$subscription->is_active()) {
76 76
             return;
77 77
         }
78 78
 
79
-        $subscription->set_status( 'pending' );
79
+        $subscription->set_status('pending');
80 80
         $subscription->save();
81 81
 
82 82
     }
@@ -88,15 +88,15 @@  discard block
 block discarded – undo
88 88
      * @param string $from
89 89
      * @param string $to
90 90
 	 */
91
-    public function process_subscription_status_change( $subscription, $from, $to ) {
91
+    public function process_subscription_status_change($subscription, $from, $to) {
92 92
 
93 93
         $gateway = $subscription->get_gateway();
94 94
 
95
-        if ( ! empty( $gateway ) ) {
96
-            $gateway = sanitize_key( $gateway );
97
-            $from    = sanitize_key( $from );
98
-            $to      = sanitize_key( $to );
99
-            do_action( "getpaid_{$gateway}subscription_$to", $subscription, $from );
95
+        if (!empty($gateway)) {
96
+            $gateway = sanitize_key($gateway);
97
+            $from    = sanitize_key($from);
98
+            $to      = sanitize_key($to);
99
+            do_action("getpaid_{$gateway}subscription_$to", $subscription, $from);
100 100
         }
101 101
 
102 102
     }
@@ -108,38 +108,38 @@  discard block
 block discarded – undo
108 108
      * @param int $frequency_count The frequency of the period.
109 109
      * @return mixed|string|void
110 110
      */
111
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1, $skip_1 = false ) {
111
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1, $skip_1 = false) {
112 112
 
113 113
         $frequency = '';
114 114
 
115 115
         //Format period details
116
-        switch ( strtolower( $period ) ) {
116
+        switch (strtolower($period)) {
117 117
             case 'day' :
118 118
             case 'd' :
119
-                $frequency = sprintf( _n( '%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
119
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
120 120
                 break;
121 121
             case 'week' :
122 122
             case 'w' :
123
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
123
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
124 124
                 break;
125 125
             case 'month' :
126 126
             case 'm' :
127
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
127
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
128 128
                 break;
129 129
             case 'year' :
130 130
             case 'y' :
131
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
131
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
132 132
                 break;
133 133
             default :
134
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
134
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
135 135
                 break;
136 136
         }
137 137
 
138
-        if ( $skip_1 && 1 == $frequency_count ) {
139
-            $frequency = str_replace( '1', '', $frequency );
138
+        if ($skip_1 && 1 == $frequency_count) {
139
+            $frequency = str_replace('1', '', $frequency);
140 140
         }
141 141
 
142
-        return trim( $frequency );
142
+        return trim($frequency);
143 143
 
144 144
     }
145 145
 
@@ -150,29 +150,29 @@  discard block
 block discarded – undo
150 150
      * @since       1.0.0
151 151
      * @return      void
152 152
      */
153
-    public function user_cancel_single_subscription( $data ) {
153
+    public function user_cancel_single_subscription($data) {
154 154
 
155 155
         // Ensure there is a subscription to cancel.
156
-        if ( empty( $data['subscription'] ) ) {
156
+        if (empty($data['subscription'])) {
157 157
             return;
158 158
         }
159 159
 
160
-        $subscription = new WPInv_Subscription( (int) $data['subscription'] );
160
+        $subscription = new WPInv_Subscription((int) $data['subscription']);
161 161
 
162 162
         // Ensure that it exists and that it belongs to the current user.
163
-        if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) {
164
-            wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) );
163
+        if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) {
164
+            wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing'));
165 165
 
166 166
         // Can it be cancelled.
167
-        } else if ( ! $subscription->can_cancel() ) {
168
-            wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) );
167
+        } else if (!$subscription->can_cancel()) {
168
+            wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing'));
169 169
             
170 170
 
171 171
         // Cancel it.
172 172
         } else {
173 173
 
174 174
             $subscription->cancel();
175
-            wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' );
175
+            wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info');
176 176
         }
177 177
 
178 178
         $redirect = add_query_arg(
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
             )
183 183
         );
184 184
 
185
-        wp_safe_redirect( esc_url( $redirect ) );
185
+        wp_safe_redirect(esc_url($redirect));
186 186
         exit;
187 187
 
188 188
     }
@@ -194,15 +194,15 @@  discard block
 block discarded – undo
194 194
      * @param       WPInv_Invoice $invoice
195 195
      * @since       1.0.0
196 196
      */
197
-    public function maybe_create_invoice_subscription( $invoice ) {
197
+    public function maybe_create_invoice_subscription($invoice) {
198 198
 
199 199
         // Abort if it is not recurring.
200
-        if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) {
200
+        if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) {
201 201
             return;
202 202
         }
203 203
 
204 204
         $subscription = new WPInv_Subscription();
205
-        return $this->update_invoice_subscription( $subscription, $invoice );
205
+        return $this->update_invoice_subscription($subscription, $invoice);
206 206
 
207 207
     }
208 208
 
@@ -213,31 +213,31 @@  discard block
 block discarded – undo
213 213
      * @param       WPInv_Invoice $invoice
214 214
      * @since       1.0.19
215 215
      */
216
-    public function maybe_update_invoice_subscription( $invoice ) {
216
+    public function maybe_update_invoice_subscription($invoice) {
217 217
 
218 218
         // Do not process renewals.
219
-        if ( $invoice->is_renewal() ) {
219
+        if ($invoice->is_renewal()) {
220 220
             return;
221 221
         }
222 222
 
223 223
         // (Maybe) create a new subscription.
224
-        if ( ! $invoice->get_subscription_id() ) {
225
-            return $this->maybe_create_invoice_subscription( $invoice );
224
+        if (!$invoice->get_subscription_id()) {
225
+            return $this->maybe_create_invoice_subscription($invoice);
226 226
         }
227 227
 
228
-        $subscription = new WPInv_Subscription( $invoice->get_subscription_id() );
228
+        $subscription = new WPInv_Subscription($invoice->get_subscription_id());
229 229
 
230 230
         // In case the subscription was deleted...
231
-        if ( ! $subscription->get_id() ) {
232
-            return $this->maybe_create_invoice_subscription( $invoice );
231
+        if (!$subscription->get_id()) {
232
+            return $this->maybe_create_invoice_subscription($invoice);
233 233
         }
234 234
 
235 235
         // Abort if an invoice is paid and already has a subscription.
236
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
236
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
237 237
             return;
238 238
         }
239 239
 
240
-        return $this->update_invoice_subscription( $subscription, $invoice );
240
+        return $this->update_invoice_subscription($subscription, $invoice);
241 241
 
242 242
     }
243 243
 
@@ -249,55 +249,55 @@  discard block
 block discarded – undo
249 249
      * @param       WPInv_Invoice $invoice
250 250
      * @since       1.0.19
251 251
      */
252
-    public function update_invoice_subscription( $subscription, $invoice ) {
252
+    public function update_invoice_subscription($subscription, $invoice) {
253 253
 
254 254
         // Delete the subscription if an invoice is free or nolonger recurring.
255
-        if ( $invoice->is_free() || ! $invoice->is_recurring() ) {
255
+        if ($invoice->is_free() || !$invoice->is_recurring()) {
256 256
             return $subscription->delete();
257 257
         }
258 258
 
259
-        $subscription->set_customer_id( $invoice->get_customer_id() );
260
-        $subscription->set_parent_invoice_id( $invoice->get_id() );
261
-        $subscription->set_initial_amount( $invoice->get_initial_total() );
262
-        $subscription->set_recurring_amount( $invoice->get_recurring_total() );
263
-        $subscription->set_date_created( current_time( 'mysql' ) );
264
-        $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' );
259
+        $subscription->set_customer_id($invoice->get_customer_id());
260
+        $subscription->set_parent_invoice_id($invoice->get_id());
261
+        $subscription->set_initial_amount($invoice->get_initial_total());
262
+        $subscription->set_recurring_amount($invoice->get_recurring_total());
263
+        $subscription->set_date_created(current_time('mysql'));
264
+        $subscription->set_status($invoice->is_paid() ? 'active' : 'pending');
265 265
 
266 266
         // Get the recurring item and abort if it does not exist.
267
-        $subscription_item = $invoice->get_recurring( true );
268
-        if ( ! $subscription_item->get_id() ) {
267
+        $subscription_item = $invoice->get_recurring(true);
268
+        if (!$subscription_item->get_id()) {
269 269
             $invoice->set_subscription_id(0);
270 270
             $invoice->save();
271 271
             return $subscription->delete();
272 272
         }
273 273
 
274
-        $subscription->set_product_id( $subscription_item->get_id() );
275
-        $subscription->set_period( $subscription_item->get_recurring_period( true ) );
276
-        $subscription->set_frequency( $subscription_item->get_recurring_interval() );
277
-        $subscription->set_bill_times( $subscription_item->get_recurring_limit() );
274
+        $subscription->set_product_id($subscription_item->get_id());
275
+        $subscription->set_period($subscription_item->get_recurring_period(true));
276
+        $subscription->set_frequency($subscription_item->get_recurring_interval());
277
+        $subscription->set_bill_times($subscription_item->get_recurring_limit());
278 278
 
279 279
         // Calculate the next renewal date.
280
-        $period       = $subscription_item->get_recurring_period( true );
280
+        $period       = $subscription_item->get_recurring_period(true);
281 281
         $interval     = $subscription_item->get_recurring_interval();
282 282
 
283 283
         // If the subscription item has a trial period...
284
-        if ( $subscription_item->has_free_trial() ) {
285
-            $period   = $subscription_item->get_trial_period( true );
284
+        if ($subscription_item->has_free_trial()) {
285
+            $period   = $subscription_item->get_trial_period(true);
286 286
             $interval = $subscription_item->get_trial_interval();
287
-            $subscription->set_trial_period( $interval . ' ' . $period );
288
-            $subscription->set_status( 'trialling' );
287
+            $subscription->set_trial_period($interval . ' ' . $period);
288
+            $subscription->set_status('trialling');
289 289
         }
290 290
 
291 291
         // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial.
292
-        if ( $invoice->has_free_trial() ) {
293
-            $subscription->set_trial_period( $interval . ' ' . $period );
294
-            $subscription->set_status( 'trialling' );
292
+        if ($invoice->has_free_trial()) {
293
+            $subscription->set_trial_period($interval . ' ' . $period);
294
+            $subscription->set_status('trialling');
295 295
         }
296 296
 
297 297
         // Calculate the next renewal date.
298
-        $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) );
298
+        $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created())));
299 299
 
300
-        $subscription->set_next_renewal_date( $expiration );
300
+        $subscription->set_next_renewal_date($expiration);
301 301
         return $subscription->save();
302 302
 
303 303
     }
@@ -308,21 +308,21 @@  discard block
 block discarded – undo
308 308
      * @param       array $data
309 309
      * @since       1.0.19
310 310
      */
311
-    public function admin_update_single_subscription( $args ) {
311
+    public function admin_update_single_subscription($args) {
312 312
 
313 313
         // Ensure the subscription exists and that a status has been given.
314
-        if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) {
314
+        if (empty($args['subscription_id']) || empty($args['subscription_status'])) {
315 315
             return;
316 316
         }
317 317
 
318 318
         // Retrieve the subscriptions.
319
-        $subscription = new WPInv_Subscription( $args['subscription_id'] );
319
+        $subscription = new WPInv_Subscription($args['subscription_id']);
320 320
 
321
-        if ( $subscription->get_id() ) {
321
+        if ($subscription->get_id()) {
322 322
 
323
-            $subscription->set_status( $args['subscription_status'] );
323
+            $subscription->set_status($args['subscription_status']);
324 324
             $subscription->save();
325
-            getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) );
325
+            getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing'));
326 326
 
327 327
         }
328 328
 
@@ -334,25 +334,25 @@  discard block
 block discarded – undo
334 334
      * @param       array $data
335 335
      * @since       1.0.19
336 336
      */
337
-    public function admin_renew_single_subscription( $args ) {
337
+    public function admin_renew_single_subscription($args) {
338 338
 
339 339
         // Ensure the subscription exists and that a status has been given.
340
-        if ( empty( $args['id'] ) ) {
340
+        if (empty($args['id'])) {
341 341
             return;
342 342
         }
343 343
 
344 344
         // Retrieve the subscriptions.
345
-        $subscription = new WPInv_Subscription( $args['id'] );
345
+        $subscription = new WPInv_Subscription($args['id']);
346 346
 
347
-        if ( $subscription->get_id() ) {
347
+        if ($subscription->get_id()) {
348 348
 
349
-            $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) );
349
+            $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_'));
350 350
 
351
-            if ( $subscription->add_payment( $args ) ) {
351
+            if ($subscription->add_payment($args)) {
352 352
                 $subscription->renew();
353
-                getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) );
353
+                getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing'));
354 354
             } else {
355
-                getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) );
355
+                getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing'));
356 356
             }
357 357
     
358 358
             wp_safe_redirect(
@@ -375,20 +375,20 @@  discard block
 block discarded – undo
375 375
      * @param       array $data
376 376
      * @since       1.0.19
377 377
      */
378
-    public function admin_delete_single_subscription( $args ) {
378
+    public function admin_delete_single_subscription($args) {
379 379
 
380 380
         // Ensure the subscription exists and that a status has been given.
381
-        if ( empty( $args['id'] ) ) {
381
+        if (empty($args['id'])) {
382 382
             return;
383 383
         }
384 384
 
385 385
         // Retrieve the subscriptions.
386
-        $subscription = new WPInv_Subscription( $args['id'] );
386
+        $subscription = new WPInv_Subscription($args['id']);
387 387
 
388
-        if ( $subscription->delete() ) {
389
-            getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) );
388
+        if ($subscription->delete()) {
389
+            getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing'));
390 390
         } else {
391
-            getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) );
391
+            getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing'));
392 392
         }
393 393
     
394 394
         $redirected = wp_safe_redirect(
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
             )
402 402
         );
403 403
 
404
-        if ( $redirected ) {
404
+        if ($redirected) {
405 405
             exit;
406 406
         }
407 407
 
@@ -414,10 +414,10 @@  discard block
 block discarded – undo
414 414
      * @param WPInv_Item $item
415 415
      * @param WPInv_Invoice $invoice
416 416
      */
417
-    public function filter_invoice_line_item_actions( $actions, $item, $invoice ) {
417
+    public function filter_invoice_line_item_actions($actions, $item, $invoice) {
418 418
 
419 419
         // Fetch item subscription.
420
-        $args  = array(
420
+        $args = array(
421 421
             'invoice_in'  => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(),
422 422
             'item_in'     => $item->get_id(),
423 423
             'number'      => 1,
@@ -425,13 +425,13 @@  discard block
 block discarded – undo
425 425
             'fields'      => 'id',
426 426
         );
427 427
 
428
-        $subscription = new GetPaid_Subscriptions_Query( $args );
428
+        $subscription = new GetPaid_Subscriptions_Query($args);
429 429
         $subscription = $subscription->get_results();
430 430
 
431 431
         // In case we found a match...
432
-        if ( ! empty( $subscription ) ) {
433
-            $url                     = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) );
434
-            $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'getpaid-license-manager' ) . '</a>';
432
+        if (!empty($subscription)) {
433
+            $url                     = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page'))));
434
+            $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'getpaid-license-manager') . '</a>';
435 435
         }
436 436
 
437 437
         return $actions;
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Spacing   +518 added lines, -518 removed lines patch added patch discarded remove patch
@@ -4,99 +4,99 @@  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
  * Displays an invoice.
11 11
  * 
12 12
  * @param WPInv_Invoice $invoice.
13 13
  */
14
-function getpaid_invoice( $invoice ) {
15
-    if ( ! empty( $invoice ) ) {
16
-        wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) );
14
+function getpaid_invoice($invoice) {
15
+    if (!empty($invoice)) {
16
+        wpinv_get_template('invoice/invoice.php', compact('invoice'));
17 17
     }
18 18
 }
19
-add_action( 'getpaid_invoice', 'getpaid_invoice', 10 );
19
+add_action('getpaid_invoice', 'getpaid_invoice', 10);
20 20
 
21 21
 /**
22 22
  * Displays the invoice footer.
23 23
  */
24
-function getpaid_invoice_footer( $invoice ) {
25
-    if ( ! empty( $invoice ) ) {
26
-        wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) );
24
+function getpaid_invoice_footer($invoice) {
25
+    if (!empty($invoice)) {
26
+        wpinv_get_template('invoice/footer.php', compact('invoice'));
27 27
     }
28 28
 }
29
-add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 );
29
+add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10);
30 30
 
31 31
 /**
32 32
  * Displays the invoice top bar.
33 33
  */
34
-function getpaid_invoice_header( $invoice ) {
35
-    if ( ! empty( $invoice ) ) {
36
-        wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) );
34
+function getpaid_invoice_header($invoice) {
35
+    if (!empty($invoice)) {
36
+        wpinv_get_template('invoice/header.php', compact('invoice'));
37 37
     }
38 38
 }
39
-add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 );
39
+add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10);
40 40
 
41 41
 /**
42 42
  * Displays actions on the left side of the header.
43 43
  */
44
-function getpaid_invoice_header_left_actions( $invoice ) {
45
-    if ( ! empty( $invoice ) ) {
46
-        wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) );
44
+function getpaid_invoice_header_left_actions($invoice) {
45
+    if (!empty($invoice)) {
46
+        wpinv_get_template('invoice/header-left-actions.php', compact('invoice'));
47 47
     }
48 48
 }
49
-add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 );
49
+add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10);
50 50
 
51 51
 /**
52 52
  * Displays actions on the right side of the invoice top bar.
53 53
  */
54
-function getpaid_invoice_header_right_actions( $invoice ) {
55
-    if ( ! empty( $invoice ) ) {
56
-        wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) );
54
+function getpaid_invoice_header_right_actions($invoice) {
55
+    if (!empty($invoice)) {
56
+        wpinv_get_template('invoice/header-right-actions.php', compact('invoice'));
57 57
     }
58 58
 }
59
-add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 );
59
+add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10);
60 60
 
61 61
 /**
62 62
  * Displays the invoice title, watermark, logo etc.
63 63
  */
64
-function getpaid_invoice_details_top( $invoice ) {
65
-    if ( ! empty( $invoice ) ) {
66
-        wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) );
64
+function getpaid_invoice_details_top($invoice) {
65
+    if (!empty($invoice)) {
66
+        wpinv_get_template('invoice/details-top.php', compact('invoice'));
67 67
     }
68 68
 }
69
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 );
69
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10);
70 70
 
71 71
 /**
72 72
  * Displays the company logo.
73 73
  */
74
-function getpaid_invoice_logo( $invoice ) {
75
-    if ( ! empty( $invoice ) ) {
76
-        wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) );
74
+function getpaid_invoice_logo($invoice) {
75
+    if (!empty($invoice)) {
76
+        wpinv_get_template('invoice/invoice-logo.php', compact('invoice'));
77 77
     }
78 78
 }
79
-add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' );
79
+add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo');
80 80
 
81 81
 /**
82 82
  * Displays the type of invoice.
83 83
  */
84
-function getpaid_invoice_type( $invoice ) {
85
-    if ( ! empty( $invoice ) ) {
86
-        wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) );
84
+function getpaid_invoice_type($invoice) {
85
+    if (!empty($invoice)) {
86
+        wpinv_get_template('invoice/invoice-type.php', compact('invoice'));
87 87
     }
88 88
 }
89
-add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' );
89
+add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type');
90 90
 
91 91
 /**
92 92
  * Displays the invoice details.
93 93
  */
94
-function getpaid_invoice_details_main( $invoice ) {
95
-    if ( ! empty( $invoice ) ) {
96
-        wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) );
94
+function getpaid_invoice_details_main($invoice) {
95
+    if (!empty($invoice)) {
96
+        wpinv_get_template('invoice/details.php', compact('invoice'));
97 97
     }
98 98
 }
99
-add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 );
99
+add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50);
100 100
 
101 101
 /**
102 102
  * Returns a path to the templates directory.
@@ -125,8 +125,8 @@  discard block
 block discarded – undo
125 125
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
126 126
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
127 127
  */
128
-function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
129
-    return getpaid_template()->display_template( $template_name, $args, $template_path, $default_path );
128
+function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
129
+    return getpaid_template()->display_template($template_name, $args, $template_path, $default_path);
130 130
 }
131 131
 
132 132
 /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
  * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'.
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142
-function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
142
+function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') {
143
+	return getpaid_template()->get_template($template_name, $args, $template_path, $default_path);
144 144
 }
145 145
 
146 146
 /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
  * @return string
150 150
  */
151 151
 function wpinv_template_path() {
152
-    return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() );
152
+    return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name());
153 153
 }
154 154
 
155 155
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+	return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing'));
162 162
 }
163 163
 
164 164
 /**
@@ -170,56 +170,56 @@  discard block
 block discarded – undo
170 170
  * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'.
171 171
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
172 172
  */
173
-function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) {
174
-    return getpaid_template()->locate_template( $template_name, $template_path, $default_path );
173
+function wpinv_locate_template($template_name, $template_path = '', $default_path = '') {
174
+    return getpaid_template()->locate_template($template_name, $template_path, $default_path);
175 175
 }
176 176
 
177
-function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
177
+function wpinv_get_template_part($slug, $name = null, $load = true) {
178
+	do_action('get_template_part_' . $slug, $slug, $name);
179 179
 
180 180
 	// Setup possible parts
181 181
 	$templates = array();
182
-	if ( isset( $name ) )
182
+	if (isset($name))
183 183
 		$templates[] = $slug . '-' . $name . '.php';
184 184
 	$templates[] = $slug . '.php';
185 185
 
186 186
 	// Allow template parts to be filtered
187
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+	$templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name);
188 188
 
189 189
 	// Return the part that is found
190
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+	return wpinv_locate_tmpl($templates, $load, false);
191 191
 }
192 192
 
193
-function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
193
+function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) {
194 194
 	// No file found yet
195 195
 	$located = false;
196 196
 
197 197
 	// Try to find a template file
198
-	foreach ( (array)$template_names as $template_name ) {
198
+	foreach ((array) $template_names as $template_name) {
199 199
 
200 200
 		// Continue if template is empty
201
-		if ( empty( $template_name ) )
201
+		if (empty($template_name))
202 202
 			continue;
203 203
 
204 204
 		// Trim off any slashes from the template name
205
-		$template_name = ltrim( $template_name, '/' );
205
+		$template_name = ltrim($template_name, '/');
206 206
 
207 207
 		// try locating this template file by looping through the template paths
208
-		foreach( wpinv_get_theme_template_paths() as $template_path ) {
208
+		foreach (wpinv_get_theme_template_paths() as $template_path) {
209 209
 
210
-			if( file_exists( $template_path . $template_name ) ) {
210
+			if (file_exists($template_path . $template_name)) {
211 211
 				$located = $template_path . $template_name;
212 212
 				break;
213 213
 			}
214 214
 		}
215 215
 
216
-		if( !empty( $located ) ) {
216
+		if (!empty($located)) {
217 217
 			break;
218 218
 		}
219 219
 	}
220 220
 
221
-	if ( ( true == $load ) && ! empty( $located ) )
222
-		load_template( $located, $require_once );
221
+	if ((true == $load) && !empty($located))
222
+		load_template($located, $require_once);
223 223
 
224 224
 	return $located;
225 225
 }
@@ -228,155 +228,155 @@  discard block
 block discarded – undo
228 228
 	$template_dir = wpinv_get_theme_template_dir_name();
229 229
 
230 230
 	$file_paths = array(
231
-		1 => trailingslashit( get_stylesheet_directory() ) . $template_dir,
232
-		10 => trailingslashit( get_template_directory() ) . $template_dir,
231
+		1 => trailingslashit(get_stylesheet_directory()) . $template_dir,
232
+		10 => trailingslashit(get_template_directory()) . $template_dir,
233 233
 		100 => wpinv_get_templates_dir()
234 234
 	);
235 235
 
236
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
236
+	$file_paths = apply_filters('wpinv_template_paths', $file_paths);
237 237
 
238 238
 	// sort the file paths based on priority
239
-	ksort( $file_paths, SORT_NUMERIC );
239
+	ksort($file_paths, SORT_NUMERIC);
240 240
 
241
-	return array_map( 'trailingslashit', $file_paths );
241
+	return array_map('trailingslashit', $file_paths);
242 242
 }
243 243
 
244 244
 function wpinv_checkout_meta_tags() {
245 245
 
246 246
 	$pages   = array();
247
-	$pages[] = wpinv_get_option( 'success_page' );
248
-	$pages[] = wpinv_get_option( 'failure_page' );
249
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
250
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
247
+	$pages[] = wpinv_get_option('success_page');
248
+	$pages[] = wpinv_get_option('failure_page');
249
+	$pages[] = wpinv_get_option('invoice_history_page');
250
+	$pages[] = wpinv_get_option('invoice_subscription_page');
251 251
 
252
-	if( !wpinv_is_checkout() && !is_page( $pages ) ) {
252
+	if (!wpinv_is_checkout() && !is_page($pages)) {
253 253
 		return;
254 254
 	}
255 255
 
256 256
 	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
257 257
 }
258
-add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
258
+add_action('wp_head', 'wpinv_checkout_meta_tags');
259 259
 
260
-function wpinv_add_body_classes( $class ) {
261
-	$classes = (array)$class;
260
+function wpinv_add_body_classes($class) {
261
+	$classes = (array) $class;
262 262
 
263
-	if( wpinv_is_checkout() ) {
263
+	if (wpinv_is_checkout()) {
264 264
 		$classes[] = 'wpinv-checkout';
265 265
 		$classes[] = 'wpinv-page';
266 266
 	}
267 267
 
268
-	if( wpinv_is_success_page() ) {
268
+	if (wpinv_is_success_page()) {
269 269
 		$classes[] = 'wpinv-success';
270 270
 		$classes[] = 'wpinv-page';
271 271
 	}
272 272
 
273
-	if( wpinv_is_failed_transaction_page() ) {
273
+	if (wpinv_is_failed_transaction_page()) {
274 274
 		$classes[] = 'wpinv-failed-transaction';
275 275
 		$classes[] = 'wpinv-page';
276 276
 	}
277 277
 
278
-	if( wpinv_is_invoice_history_page() ) {
278
+	if (wpinv_is_invoice_history_page()) {
279 279
 		$classes[] = 'wpinv-history';
280 280
 		$classes[] = 'wpinv-page';
281 281
 	}
282 282
 
283
-	if( wpinv_is_subscriptions_history_page() ) {
283
+	if (wpinv_is_subscriptions_history_page()) {
284 284
 		$classes[] = 'wpinv-subscription';
285 285
 		$classes[] = 'wpinv-page';
286 286
 	}
287 287
 
288
-	if( wpinv_is_test_mode() ) {
288
+	if (wpinv_is_test_mode()) {
289 289
 		$classes[] = 'wpinv-test-mode';
290 290
 		$classes[] = 'wpinv-page';
291 291
 	}
292 292
 
293
-	return array_unique( $classes );
293
+	return array_unique($classes);
294 294
 }
295
-add_filter( 'body_class', 'wpinv_add_body_classes' );
295
+add_filter('body_class', 'wpinv_add_body_classes');
296 296
 
297
-function wpinv_html_dropdown( $name = 'wpinv_discounts', $selected = 0, $status = '' ) {
298
-    $args = array( 'nopaging' => true );
297
+function wpinv_html_dropdown($name = 'wpinv_discounts', $selected = 0, $status = '') {
298
+    $args = array('nopaging' => true);
299 299
 
300
-    if ( ! empty( $status ) )
300
+    if (!empty($status))
301 301
         $args['post_status'] = $status;
302 302
 
303
-    $discounts = wpinv_get_discounts( $args );
303
+    $discounts = wpinv_get_discounts($args);
304 304
     $options   = array();
305 305
 
306
-    if ( $discounts ) {
307
-        foreach ( $discounts as $discount ) {
308
-            $options[ absint( $discount->ID ) ] = esc_html( get_the_title( $discount->ID ) );
306
+    if ($discounts) {
307
+        foreach ($discounts as $discount) {
308
+            $options[absint($discount->ID)] = esc_html(get_the_title($discount->ID));
309 309
         }
310 310
     } else {
311
-        $options[0] = __( 'No discounts found', 'invoicing' );
311
+        $options[0] = __('No discounts found', 'invoicing');
312 312
     }
313 313
 
314
-    $output = wpinv_html_select( array(
314
+    $output = wpinv_html_select(array(
315 315
         'name'             => $name,
316 316
         'selected'         => $selected,
317 317
         'options'          => $options,
318 318
         'show_option_all'  => false,
319 319
         'show_option_none' => false,
320
-    ) );
320
+    ));
321 321
 
322 322
     return $output;
323 323
 }
324 324
 
325
-function wpinv_html_year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
326
-    $current     = date( 'Y' );
327
-    $start_year  = $current - absint( $years_before );
328
-    $end_year    = $current + absint( $years_after );
329
-    $selected    = empty( $selected ) ? date( 'Y' ) : $selected;
325
+function wpinv_html_year_dropdown($name = 'year', $selected = 0, $years_before = 5, $years_after = 0) {
326
+    $current     = date('Y');
327
+    $start_year  = $current - absint($years_before);
328
+    $end_year    = $current + absint($years_after);
329
+    $selected    = empty($selected) ? date('Y') : $selected;
330 330
     $options     = array();
331 331
 
332
-    while ( $start_year <= $end_year ) {
333
-        $options[ absint( $start_year ) ] = $start_year;
332
+    while ($start_year <= $end_year) {
333
+        $options[absint($start_year)] = $start_year;
334 334
         $start_year++;
335 335
     }
336 336
 
337
-    $output = wpinv_html_select( array(
337
+    $output = wpinv_html_select(array(
338 338
         'name'             => $name,
339 339
         'selected'         => $selected,
340 340
         'options'          => $options,
341 341
         'show_option_all'  => false,
342 342
         'show_option_none' => false
343
-    ) );
343
+    ));
344 344
 
345 345
     return $output;
346 346
 }
347 347
 
348
-function wpinv_html_month_dropdown( $name = 'month', $selected = 0 ) {
348
+function wpinv_html_month_dropdown($name = 'month', $selected = 0) {
349 349
 
350 350
     $options = array(
351
-        '1'  => __( 'January', 'invoicing' ),
352
-        '2'  => __( 'February', 'invoicing' ),
353
-        '3'  => __( 'March', 'invoicing' ),
354
-        '4'  => __( 'April', 'invoicing' ),
355
-        '5'  => __( 'May', 'invoicing' ),
356
-        '6'  => __( 'June', 'invoicing' ),
357
-        '7'  => __( 'July', 'invoicing' ),
358
-        '8'  => __( 'August', 'invoicing' ),
359
-        '9'  => __( 'September', 'invoicing' ),
360
-        '10' => __( 'October', 'invoicing' ),
361
-        '11' => __( 'November', 'invoicing' ),
362
-        '12' => __( 'December', 'invoicing' ),
351
+        '1'  => __('January', 'invoicing'),
352
+        '2'  => __('February', 'invoicing'),
353
+        '3'  => __('March', 'invoicing'),
354
+        '4'  => __('April', 'invoicing'),
355
+        '5'  => __('May', 'invoicing'),
356
+        '6'  => __('June', 'invoicing'),
357
+        '7'  => __('July', 'invoicing'),
358
+        '8'  => __('August', 'invoicing'),
359
+        '9'  => __('September', 'invoicing'),
360
+        '10' => __('October', 'invoicing'),
361
+        '11' => __('November', 'invoicing'),
362
+        '12' => __('December', 'invoicing'),
363 363
     );
364 364
 
365 365
     // If no month is selected, default to the current month
366
-    $selected = empty( $selected ) ? date( 'n' ) : $selected;
366
+    $selected = empty($selected) ? date('n') : $selected;
367 367
 
368
-    $output = wpinv_html_select( array(
368
+    $output = wpinv_html_select(array(
369 369
         'name'             => $name,
370 370
         'selected'         => $selected,
371 371
         'options'          => $options,
372 372
         'show_option_all'  => false,
373 373
         'show_option_none' => false
374
-    ) );
374
+    ));
375 375
 
376 376
     return $output;
377 377
 }
378 378
 
379
-function wpinv_html_select( $args = array() ) {
379
+function wpinv_html_select($args = array()) {
380 380
     $defaults = array(
381 381
         'options'          => array(),
382 382
         'name'             => null,
@@ -385,8 +385,8 @@  discard block
 block discarded – undo
385 385
         'selected'         => 0,
386 386
         'placeholder'      => null,
387 387
         'multiple'         => false,
388
-        'show_option_all'  => _x( 'All', 'all dropdown items', 'invoicing' ),
389
-        'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ),
388
+        'show_option_all'  => _x('All', 'all dropdown items', 'invoicing'),
389
+        'show_option_none' => _x('None', 'no dropdown items', 'invoicing'),
390 390
         'data'             => array(),
391 391
         'onchange'         => null,
392 392
         'required'         => false,
@@ -394,74 +394,74 @@  discard block
 block discarded – undo
394 394
         'readonly'         => false,
395 395
     );
396 396
 
397
-    $args = wp_parse_args( $args, $defaults );
397
+    $args = wp_parse_args($args, $defaults);
398 398
 
399 399
     $data_elements = '';
400
-    foreach ( $args['data'] as $key => $value ) {
401
-        $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
400
+    foreach ($args['data'] as $key => $value) {
401
+        $data_elements .= ' data-' . esc_attr($key) . '="' . esc_attr($value) . '"';
402 402
     }
403 403
 
404
-    if( $args['multiple'] ) {
404
+    if ($args['multiple']) {
405 405
         $multiple = ' MULTIPLE';
406 406
     } else {
407 407
         $multiple = '';
408 408
     }
409 409
 
410
-    if( $args['placeholder'] ) {
410
+    if ($args['placeholder']) {
411 411
         $placeholder = $args['placeholder'];
412 412
     } else {
413 413
         $placeholder = '';
414 414
     }
415 415
     
416 416
     $options = '';
417
-    if( !empty( $args['onchange'] ) ) {
418
-        $options .= ' onchange="' . esc_attr( $args['onchange'] ) . '"';
417
+    if (!empty($args['onchange'])) {
418
+        $options .= ' onchange="' . esc_attr($args['onchange']) . '"';
419 419
     }
420 420
     
421
-    if( !empty( $args['required'] ) ) {
421
+    if (!empty($args['required'])) {
422 422
         $options .= ' required="required"';
423 423
     }
424 424
     
425
-    if( !empty( $args['disabled'] ) ) {
425
+    if (!empty($args['disabled'])) {
426 426
         $options .= ' disabled';
427 427
     }
428 428
     
429
-    if( !empty( $args['readonly'] ) ) {
429
+    if (!empty($args['readonly'])) {
430 430
         $options .= ' readonly';
431 431
     }
432 432
 
433
-    $class  = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
434
-    $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim( $options ) . $data_elements . '>';
433
+    $class  = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
434
+    $output = '<select name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" class="wpinv-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '" ' . trim($options) . $data_elements . '>';
435 435
 
436
-    if ( $args['show_option_all'] ) {
437
-        if( $args['multiple'] ) {
438
-            $selected = selected( true, in_array( 0, $args['selected'] ), false );
436
+    if ($args['show_option_all']) {
437
+        if ($args['multiple']) {
438
+            $selected = selected(true, in_array(0, $args['selected']), false);
439 439
         } else {
440
-            $selected = selected( $args['selected'], 0, false );
440
+            $selected = selected($args['selected'], 0, false);
441 441
         }
442
-        $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
442
+        $output .= '<option value="all"' . $selected . '>' . esc_html($args['show_option_all']) . '</option>';
443 443
     }
444 444
 
445
-    if ( !empty( $args['options'] ) ) {
445
+    if (!empty($args['options'])) {
446 446
 
447
-        if ( $args['show_option_none'] ) {
448
-            if( $args['multiple'] ) {
449
-                $selected = selected( true, in_array( "", $args['selected'] ), false );
447
+        if ($args['show_option_none']) {
448
+            if ($args['multiple']) {
449
+                $selected = selected(true, in_array("", $args['selected']), false);
450 450
             } else {
451
-                $selected = selected( $args['selected'] === "", true, false );
451
+                $selected = selected($args['selected'] === "", true, false);
452 452
             }
453
-            $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
453
+            $output .= '<option value=""' . $selected . '>' . esc_html($args['show_option_none']) . '</option>';
454 454
         }
455 455
 
456
-        foreach( $args['options'] as $key => $option ) {
456
+        foreach ($args['options'] as $key => $option) {
457 457
 
458
-            if( $args['multiple'] && is_array( $args['selected'] ) ) {
459
-                $selected = selected( true, (bool)in_array( $key, $args['selected'] ), false );
458
+            if ($args['multiple'] && is_array($args['selected'])) {
459
+                $selected = selected(true, (bool) in_array($key, $args['selected']), false);
460 460
             } else {
461
-                $selected = selected( $args['selected'], $key, false );
461
+                $selected = selected($args['selected'], $key, false);
462 462
             }
463 463
 
464
-            $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
464
+            $output .= '<option value="' . esc_attr($key) . '"' . $selected . '>' . esc_html($option) . '</option>';
465 465
         }
466 466
     }
467 467
 
@@ -470,7 +470,7 @@  discard block
 block discarded – undo
470 470
     return $output;
471 471
 }
472 472
 
473
-function wpinv_item_dropdown( $args = array() ) {
473
+function wpinv_item_dropdown($args = array()) {
474 474
     $defaults = array(
475 475
         'name'              => 'wpi_item',
476 476
         'id'                => 'wpi_item',
@@ -478,14 +478,14 @@  discard block
 block discarded – undo
478 478
         'multiple'          => false,
479 479
         'selected'          => 0,
480 480
         'number'            => 100,
481
-        'placeholder'       => __( 'Choose a item', 'invoicing' ),
482
-        'data'              => array( 'search-type' => 'item' ),
481
+        'placeholder'       => __('Choose a item', 'invoicing'),
482
+        'data'              => array('search-type' => 'item'),
483 483
         'show_option_all'   => false,
484 484
         'show_option_none'  => false,
485 485
         'show_recurring'    => false,
486 486
     );
487 487
 
488
-    $args = wp_parse_args( $args, $defaults );
488
+    $args = wp_parse_args($args, $defaults);
489 489
 
490 490
     $item_args = array(
491 491
         'post_type'      => 'wpi_item',
@@ -494,44 +494,44 @@  discard block
 block discarded – undo
494 494
         'posts_per_page' => $args['number']
495 495
     );
496 496
 
497
-    $item_args  = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults );
497
+    $item_args  = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults);
498 498
 
499
-    $items      = get_posts( $item_args );
499
+    $items      = get_posts($item_args);
500 500
     $options    = array();
501
-    if ( $items ) {
502
-        foreach ( $items as $item ) {
503
-            $title = esc_html( $item->post_title );
501
+    if ($items) {
502
+        foreach ($items as $item) {
503
+            $title = esc_html($item->post_title);
504 504
             
505
-            if ( !empty( $args['show_recurring'] ) ) {
506
-                $title .= wpinv_get_item_suffix( $item->ID, false );
505
+            if (!empty($args['show_recurring'])) {
506
+                $title .= wpinv_get_item_suffix($item->ID, false);
507 507
             }
508 508
             
509
-            $options[ absint( $item->ID ) ] = $title;
509
+            $options[absint($item->ID)] = $title;
510 510
         }
511 511
     }
512 512
 
513 513
     // This ensures that any selected items are included in the drop down
514
-    if( is_array( $args['selected'] ) ) {
515
-        foreach( $args['selected'] as $item ) {
516
-            if( ! in_array( $item, $options ) ) {
517
-                $title = get_the_title( $item );
518
-                if ( !empty( $args['show_recurring'] ) ) {
519
-                    $title .= wpinv_get_item_suffix( $item, false );
514
+    if (is_array($args['selected'])) {
515
+        foreach ($args['selected'] as $item) {
516
+            if (!in_array($item, $options)) {
517
+                $title = get_the_title($item);
518
+                if (!empty($args['show_recurring'])) {
519
+                    $title .= wpinv_get_item_suffix($item, false);
520 520
                 }
521 521
                 $options[$item] = $title;
522 522
             }
523 523
         }
524
-    } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) {
525
-        if ( ! in_array( $args['selected'], $options ) ) {
526
-            $title = get_the_title( $args['selected'] );
527
-            if ( !empty( $args['show_recurring'] ) ) {
528
-                $title .= wpinv_get_item_suffix( $args['selected'], false );
524
+    } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) {
525
+        if (!in_array($args['selected'], $options)) {
526
+            $title = get_the_title($args['selected']);
527
+            if (!empty($args['show_recurring'])) {
528
+                $title .= wpinv_get_item_suffix($args['selected'], false);
529 529
             }
530
-            $options[$args['selected']] = get_the_title( $args['selected'] );
530
+            $options[$args['selected']] = get_the_title($args['selected']);
531 531
         }
532 532
     }
533 533
 
534
-    $output = wpinv_html_select( array(
534
+    $output = wpinv_html_select(array(
535 535
         'name'             => $args['name'],
536 536
         'selected'         => $args['selected'],
537 537
         'id'               => $args['id'],
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
         'show_option_all'  => $args['show_option_all'],
543 543
         'show_option_none' => $args['show_option_none'],
544 544
         'data'             => $args['data'],
545
-    ) );
545
+    ));
546 546
 
547 547
     return $output;
548 548
 }
@@ -562,16 +562,16 @@  discard block
 block discarded – undo
562 562
     );
563 563
 
564 564
     $options = array();
565
-    if ( $items ) {
566
-        foreach ( $items as $item ) {
567
-            $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false );
565
+    if ($items) {
566
+        foreach ($items as $item) {
567
+            $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false);
568 568
         }
569 569
     }
570 570
 
571 571
     return $options;
572 572
 }
573 573
 
574
-function wpinv_html_checkbox( $args = array() ) {
574
+function wpinv_html_checkbox($args = array()) {
575 575
     $defaults = array(
576 576
         'name'     => null,
577 577
         'current'  => null,
@@ -582,17 +582,17 @@  discard block
 block discarded – undo
582 582
         )
583 583
     );
584 584
 
585
-    $args = wp_parse_args( $args, $defaults );
585
+    $args = wp_parse_args($args, $defaults);
586 586
 
587
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
587
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
588 588
     $options = '';
589
-    if ( ! empty( $args['options']['disabled'] ) ) {
589
+    if (!empty($args['options']['disabled'])) {
590 590
         $options .= ' disabled="disabled"';
591
-    } elseif ( ! empty( $args['options']['readonly'] ) ) {
591
+    } elseif (!empty($args['options']['readonly'])) {
592 592
         $options .= ' readonly';
593 593
     }
594 594
 
595
-    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />';
595
+    $output = '<input type="checkbox"' . $options . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . $class . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />';
596 596
 
597 597
     return $output;
598 598
 }
@@ -600,30 +600,30 @@  discard block
 block discarded – undo
600 600
 /**
601 601
  * Displays a hidden field.
602 602
  */
603
-function getpaid_hidden_field( $name, $value ) {
604
-    $name  = sanitize_text_field( $name );
605
-    $value = esc_attr( $value );
603
+function getpaid_hidden_field($name, $value) {
604
+    $name  = sanitize_text_field($name);
605
+    $value = esc_attr($value);
606 606
 
607 607
     echo "<input type='hidden' name='$name' value='$value' />";
608 608
 }
609 609
 
610
-function wpinv_html_text( $args = array() ) {
610
+function wpinv_html_text($args = array()) {
611 611
     // Backwards compatibility
612
-    if ( func_num_args() > 1 ) {
612
+    if (func_num_args() > 1) {
613 613
         $args = func_get_args();
614 614
 
615 615
         $name  = $args[0];
616
-        $value = isset( $args[1] ) ? $args[1] : '';
617
-        $label = isset( $args[2] ) ? $args[2] : '';
618
-        $desc  = isset( $args[3] ) ? $args[3] : '';
616
+        $value = isset($args[1]) ? $args[1] : '';
617
+        $label = isset($args[2]) ? $args[2] : '';
618
+        $desc  = isset($args[3]) ? $args[3] : '';
619 619
     }
620 620
 
621 621
     $defaults = array(
622 622
         'id'           => '',
623
-        'name'         => isset( $name )  ? $name  : 'text',
624
-        'value'        => isset( $value ) ? $value : null,
625
-        'label'        => isset( $label ) ? $label : null,
626
-        'desc'         => isset( $desc )  ? $desc  : null,
623
+        'name'         => isset($name) ? $name : 'text',
624
+        'value'        => isset($value) ? $value : null,
625
+        'label'        => isset($label) ? $label : null,
626
+        'desc'         => isset($desc) ? $desc : null,
627 627
         'placeholder'  => '',
628 628
         'class'        => 'regular-text',
629 629
         'disabled'     => false,
@@ -633,51 +633,51 @@  discard block
 block discarded – undo
633 633
         'data'         => false
634 634
     );
635 635
 
636
-    $args = wp_parse_args( $args, $defaults );
636
+    $args = wp_parse_args($args, $defaults);
637 637
 
638
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
638
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
639 639
     $options = '';
640
-    if( $args['required'] ) {
640
+    if ($args['required']) {
641 641
         $options .= ' required="required"';
642 642
     }
643
-    if( $args['readonly'] ) {
643
+    if ($args['readonly']) {
644 644
         $options .= ' readonly';
645 645
     }
646
-    if( $args['readonly'] ) {
646
+    if ($args['readonly']) {
647 647
         $options .= ' readonly';
648 648
     }
649 649
 
650 650
     $data = '';
651
-    if ( !empty( $args['data'] ) ) {
652
-        foreach ( $args['data'] as $key => $value ) {
653
-            $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
651
+    if (!empty($args['data'])) {
652
+        foreach ($args['data'] as $key => $value) {
653
+            $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" ';
654 654
         }
655 655
     }
656 656
 
657
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
658
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
659
-    if ( ! empty( $args['desc'] ) ) {
660
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
657
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
658
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>';
659
+    if (!empty($args['desc'])) {
660
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
661 661
     }
662 662
 
663
-    $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] )  . '" autocomplete="' . esc_attr( $args['autocomplete'] )  . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>';
663
+    $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>';
664 664
 
665 665
     $output .= '</span>';
666 666
 
667 667
     return $output;
668 668
 }
669 669
 
670
-function wpinv_html_date_field( $args = array() ) {
671
-    if( empty( $args['class'] ) ) {
670
+function wpinv_html_date_field($args = array()) {
671
+    if (empty($args['class'])) {
672 672
         $args['class'] = 'wpiDatepicker';
673
-    } elseif( ! strpos( $args['class'], 'wpiDatepicker' ) ) {
673
+    } elseif (!strpos($args['class'], 'wpiDatepicker')) {
674 674
         $args['class'] .= ' wpiDatepicker';
675 675
     }
676 676
 
677
-    return wpinv_html_text( $args );
677
+    return wpinv_html_text($args);
678 678
 }
679 679
 
680
-function wpinv_html_textarea( $args = array() ) {
680
+function wpinv_html_textarea($args = array()) {
681 681
     $defaults = array(
682 682
         'name'        => 'textarea',
683 683
         'value'       => null,
@@ -688,31 +688,31 @@  discard block
 block discarded – undo
688 688
         'placeholder' => '',
689 689
     );
690 690
 
691
-    $args = wp_parse_args( $args, $defaults );
691
+    $args = wp_parse_args($args, $defaults);
692 692
 
693
-    $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
693
+    $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class'])));
694 694
     $disabled = '';
695
-    if( $args['disabled'] ) {
695
+    if ($args['disabled']) {
696 696
         $disabled = ' disabled="disabled"';
697 697
     }
698 698
 
699
-    $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">';
700
-    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
701
-    $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
699
+    $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">';
700
+    $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>';
701
+    $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>';
702 702
 
703
-    if ( ! empty( $args['desc'] ) ) {
704
-        $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>';
703
+    if (!empty($args['desc'])) {
704
+        $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>';
705 705
     }
706 706
     $output .= '</span>';
707 707
 
708 708
     return $output;
709 709
 }
710 710
 
711
-function wpinv_html_ajax_user_search( $args = array() ) {
711
+function wpinv_html_ajax_user_search($args = array()) {
712 712
     $defaults = array(
713 713
         'name'        => 'user_id',
714 714
         'value'       => null,
715
-        'placeholder' => __( 'Enter username', 'invoicing' ),
715
+        'placeholder' => __('Enter username', 'invoicing'),
716 716
         'label'       => null,
717 717
         'desc'        => null,
718 718
         'class'       => '',
@@ -721,13 +721,13 @@  discard block
 block discarded – undo
721 721
         'data'        => false
722 722
     );
723 723
 
724
-    $args = wp_parse_args( $args, $defaults );
724
+    $args = wp_parse_args($args, $defaults);
725 725
 
726 726
     $args['class'] = 'wpinv-ajax-user-search ' . $args['class'];
727 727
 
728 728
     $output  = '<span class="wpinv_user_search_wrap">';
729
-        $output .= wpinv_html_text( $args );
730
-        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>';
729
+        $output .= wpinv_html_text($args);
730
+        $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>';
731 731
     $output .= '</span>';
732 732
 
733 733
     return $output;
@@ -743,20 +743,20 @@  discard block
 block discarded – undo
743 743
  * 
744 744
  * @param string $template the template that is currently being used.
745 745
  */
746
-function wpinv_template( $template ) {
746
+function wpinv_template($template) {
747 747
     global $post;
748 748
 
749
-    if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) {
749
+    if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) {
750 750
 
751 751
         // If the user can view this invoice, display it.
752
-        if ( wpinv_user_can_view_invoice( $post->ID ) ) {
752
+        if (wpinv_user_can_view_invoice($post->ID)) {
753 753
 
754
-            return wpinv_get_template_part( 'wpinv-invoice-print', false, false );
754
+            return wpinv_get_template_part('wpinv-invoice-print', false, false);
755 755
 
756 756
         // Else display an error message.
757 757
         } else {
758 758
 
759
-            return wpinv_get_template_part( 'wpinv-invalid-access', false, false );
759
+            return wpinv_get_template_part('wpinv-invalid-access', false, false);
760 760
 
761 761
         }
762 762
 
@@ -764,46 +764,46 @@  discard block
 block discarded – undo
764 764
 
765 765
     return $template;
766 766
 }
767
-add_filter( 'template_include', 'wpinv_template', 10, 1 );
767
+add_filter('template_include', 'wpinv_template', 10, 1);
768 768
 
769 769
 function wpinv_get_business_address() {
770 770
     $business_address   = wpinv_store_address();
771
-    $business_address   = !empty( $business_address ) ? wpautop( wp_kses_post( $business_address ) ) : '';
771
+    $business_address   = !empty($business_address) ? wpautop(wp_kses_post($business_address)) : '';
772 772
     
773 773
     $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : '';
774 774
     
775
-    return apply_filters( 'wpinv_get_business_address', $business_address );
775
+    return apply_filters('wpinv_get_business_address', $business_address);
776 776
 }
777 777
 
778 778
 /**
779 779
  * Displays the company address.
780 780
  */
781 781
 function wpinv_display_from_address() {
782
-    wpinv_get_template( 'invoice/company-address.php' );
782
+    wpinv_get_template('invoice/company-address.php');
783 783
 }
784
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 );
784
+add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10);
785 785
 
786
-function wpinv_watermark( $id = 0 ) {
787
-    $output = wpinv_get_watermark( $id );
788
-    return apply_filters( 'wpinv_get_watermark', $output, $id );
786
+function wpinv_watermark($id = 0) {
787
+    $output = wpinv_get_watermark($id);
788
+    return apply_filters('wpinv_get_watermark', $output, $id);
789 789
 }
790 790
 
791
-function wpinv_get_watermark( $id ) {
792
-    if ( !$id > 0 ) {
791
+function wpinv_get_watermark($id) {
792
+    if (!$id > 0) {
793 793
         return NULL;
794 794
     }
795 795
 
796
-    $invoice = wpinv_get_invoice( $id );
796
+    $invoice = wpinv_get_invoice($id);
797 797
     
798
-    if ( !empty( $invoice ) && "wpi_invoice" === $invoice->post_type ) {
799
-        if ( $invoice->is_paid() ) {
800
-            return __( 'Paid', 'invoicing' );
798
+    if (!empty($invoice) && "wpi_invoice" === $invoice->post_type) {
799
+        if ($invoice->is_paid()) {
800
+            return __('Paid', 'invoicing');
801 801
         }
802
-        if ( $invoice->is_refunded() ) {
803
-            return __( 'Refunded', 'invoicing' );
802
+        if ($invoice->is_refunded()) {
803
+            return __('Refunded', 'invoicing');
804 804
         }
805
-        if ( $invoice->has_status( array( 'wpi-cancelled' ) ) ) {
806
-            return __( 'Cancelled', 'invoicing' );
805
+        if ($invoice->has_status(array('wpi-cancelled'))) {
806
+            return __('Cancelled', 'invoicing');
807 807
         }
808 808
     }
809 809
     
@@ -813,140 +813,140 @@  discard block
 block discarded – undo
813 813
 /**
814 814
  * @deprecated
815 815
  */
816
-function wpinv_display_invoice_details( $invoice ) {
817
-    return getpaid_invoice_meta( $invoice );
816
+function wpinv_display_invoice_details($invoice) {
817
+    return getpaid_invoice_meta($invoice);
818 818
 }
819 819
 
820 820
 /**
821 821
  * Displays invoice meta.
822 822
  */
823
-function getpaid_invoice_meta( $invoice ) {
823
+function getpaid_invoice_meta($invoice) {
824 824
 
825
-    $invoice = new WPInv_Invoice( $invoice );
825
+    $invoice = new WPInv_Invoice($invoice);
826 826
 
827 827
     // Ensure that we have an invoice.
828
-    if ( 0 == $invoice->get_id() ) {
828
+    if (0 == $invoice->get_id()) {
829 829
         return;
830 830
     }
831 831
 
832 832
     // Load the invoice meta.
833
-    $meta    = array(
833
+    $meta = array(
834 834
 
835 835
         'number' => array(
836 836
             'label' => sprintf(
837
-                __( '%s Number', 'invoicing' ),
838
-                ucfirst( $invoice->get_type() )
837
+                __('%s Number', 'invoicing'),
838
+                ucfirst($invoice->get_type())
839 839
             ),
840
-            'value' => sanitize_text_field( $invoice->get_number() ),
840
+            'value' => sanitize_text_field($invoice->get_number()),
841 841
         ),
842 842
 
843 843
         'status' => array(
844 844
             'label' => sprintf(
845
-                __( '%s Status', 'invoicing' ),
846
-                ucfirst( $invoice->get_type() )
845
+                __('%s Status', 'invoicing'),
846
+                ucfirst($invoice->get_type())
847 847
             ),
848 848
             'value' => $invoice->get_status_label_html(),
849 849
         ),
850 850
 
851 851
         'date' => array(
852 852
             'label' => sprintf(
853
-                __( '%s Date', 'invoicing' ),
854
-                ucfirst( $invoice->get_type() )
853
+                __('%s Date', 'invoicing'),
854
+                ucfirst($invoice->get_type())
855 855
             ),
856
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
856
+            'value' => getpaid_format_date($invoice->get_created_date()),
857 857
         ),
858 858
 
859 859
         'date_paid' => array(
860
-            'label' => __( 'Paid On', 'invoicing' ),
861
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
860
+            'label' => __('Paid On', 'invoicing'),
861
+            'value' => getpaid_format_date($invoice->get_completed_date()),
862 862
         ),
863 863
 
864 864
         'gateway'   => array(
865
-            'label' => __( 'Payment Method', 'invoicing' ),
866
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
865
+            'label' => __('Payment Method', 'invoicing'),
866
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
867 867
         ),
868 868
 
869 869
         'transaction_id' => array(
870
-            'label' => __( 'Transaction ID', 'invoicing' ),
871
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
870
+            'label' => __('Transaction ID', 'invoicing'),
871
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
872 872
         ),
873 873
 
874 874
         'due_date'  => array(
875
-            'label' => __( 'Due Date', 'invoicing' ),
876
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
875
+            'label' => __('Due Date', 'invoicing'),
876
+            'value' => getpaid_format_date($invoice->get_due_date()),
877 877
         ),
878 878
 
879 879
         'vat_number' => array(
880 880
             'label' => sprintf(
881
-                __( '%s Number', 'invoicing' ),
881
+                __('%s Number', 'invoicing'),
882 882
                 getpaid_tax()->get_vat_name()
883 883
             ),
884
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
884
+            'value' => sanitize_text_field($invoice->get_vat_number()),
885 885
         ),
886 886
 
887 887
     );
888 888
 
889 889
     // If it is not paid, remove the date of payment.
890
-    if ( ! $invoice->is_paid() ) {
891
-        unset( $meta[ 'date_paid' ] );
892
-        unset( $meta[ 'transaction_id' ] );
890
+    if (!$invoice->is_paid()) {
891
+        unset($meta['date_paid']);
892
+        unset($meta['transaction_id']);
893 893
     }
894 894
 
895
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
896
-        unset( $meta[ 'gateway' ] );
895
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
896
+        unset($meta['gateway']);
897 897
     }
898 898
 
899 899
     // Only display the due date if due dates are enabled.
900
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
901
-        unset( $meta[ 'due_date' ] );
900
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
901
+        unset($meta['due_date']);
902 902
     }
903 903
 
904 904
     // Only display the vat number if taxes are enabled.
905
-    if ( ! wpinv_use_taxes() ) {
906
-        unset( $meta[ 'vat_number' ] );
905
+    if (!wpinv_use_taxes()) {
906
+        unset($meta['vat_number']);
907 907
     }
908 908
 
909
-    if ( $invoice->is_recurring() ) {
909
+    if ($invoice->is_recurring()) {
910 910
 
911 911
         // Link to the parent invoice.
912
-        if ( $invoice->is_renewal() ) {
912
+        if ($invoice->is_renewal()) {
913 913
 
914
-            $meta[ 'parent' ] = array(
914
+            $meta['parent'] = array(
915 915
 
916 916
                 'label' => sprintf(
917
-                    __( 'Parent %s', 'invoicing' ),
918
-                    ucfirst( $invoice->get_type() )
917
+                    __('Parent %s', 'invoicing'),
918
+                    ucfirst($invoice->get_type())
919 919
                 ),
920 920
 
921
-                'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
921
+                'value' => wpinv_invoice_link($invoice->get_parent_id()),
922 922
 
923 923
             );
924 924
 
925 925
         }
926 926
 
927
-        $subscription = wpinv_get_subscription( $invoice );
927
+        $subscription = wpinv_get_subscription($invoice);
928 928
 
929
-        if ( ! empty ( $subscription ) ) {
929
+        if (!empty ($subscription)) {
930 930
 
931 931
             // Display the renewal date.
932
-            if ( $subscription->is_active() && 'cancelled' != $subscription->status ) {
932
+            if ($subscription->is_active() && 'cancelled' != $subscription->status) {
933 933
 
934
-                $meta[ 'renewal_date' ] = array(
934
+                $meta['renewal_date'] = array(
935 935
 
936
-                    'label' => __( 'Renews On', 'invoicing' ),
937
-                    'value' => getpaid_format_date( $subscription->expiration ),
936
+                    'label' => __('Renews On', 'invoicing'),
937
+                    'value' => getpaid_format_date($subscription->expiration),
938 938
         
939 939
                 );
940 940
 
941 941
             }
942 942
 
943
-            if ( $invoice->is_parent() ) {
943
+            if ($invoice->is_parent()) {
944 944
 
945 945
                 // Display the recurring amount.
946
-                $meta[ 'recurring_total' ] = array(
946
+                $meta['recurring_total'] = array(
947 947
 
948
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
949
-                    'value' => wpinv_price( wpinv_format_amount( $subscription->recurring_amount ), $invoice->get_currency() ),
948
+                    'label' => __('Recurring Amount', 'invoicing'),
949
+                    'value' => wpinv_price(wpinv_format_amount($subscription->recurring_amount), $invoice->get_currency()),
950 950
         
951 951
                 );
952 952
 
@@ -956,20 +956,20 @@  discard block
 block discarded – undo
956 956
     }
957 957
 
958 958
     // Add the invoice total to the meta.
959
-    $meta[ 'invoice_total' ] = array(
959
+    $meta['invoice_total'] = array(
960 960
 
961
-        'label' => __( 'Total Amount', 'invoicing' ),
962
-        'value' => wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ),
961
+        'label' => __('Total Amount', 'invoicing'),
962
+        'value' => wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()),
963 963
 
964 964
     );
965 965
 
966 966
     // Provide a way for third party plugins to filter the meta.
967
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
967
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
968 968
 
969
-    wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) );
969
+    wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta'));
970 970
 
971 971
 }
972
-add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 );
972
+add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10);
973 973
 
974 974
 /**
975 975
  * Retrieves the address markup to use on Invoices.
@@ -981,29 +981,29 @@  discard block
 block discarded – undo
981 981
  * @param  string $separator How to separate address lines.
982 982
  * @return string
983 983
  */
984
-function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) {
984
+function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') {
985 985
 
986 986
     // Retrieve the address markup...
987
-    $country= empty( $billing_details['country'] ) ? '' : $billing_details['country'];
988
-    $format = wpinv_get_full_address_format( $country );
987
+    $country = empty($billing_details['country']) ? '' : $billing_details['country'];
988
+    $format = wpinv_get_full_address_format($country);
989 989
 
990 990
     // ... and the replacements.
991
-    $replacements = wpinv_get_invoice_address_replacements( $billing_details );
991
+    $replacements = wpinv_get_invoice_address_replacements($billing_details);
992 992
 
993
-    $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
993
+    $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format);
994 994
     
995 995
 	// Remove unavailable tags.
996
-    $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address );
996
+    $formatted_address = preg_replace("/\{\{\w+\}\}/", '', $formatted_address);
997 997
 
998 998
     // Clean up white space.
999
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
1000
-    $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
999
+	$formatted_address = preg_replace('/  +/', ' ', trim($formatted_address));
1000
+    $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address);
1001 1001
     
1002 1002
     // Break newlines apart and remove empty lines/trim commas and white space.
1003
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
1003
+	$formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address)));
1004 1004
 
1005 1005
     // Add html breaks.
1006
-	$formatted_address = implode( $separator, $formatted_address );
1006
+	$formatted_address = implode($separator, $formatted_address);
1007 1007
 
1008 1008
 	// We're done!
1009 1009
 	return $formatted_address;
@@ -1015,88 +1015,88 @@  discard block
 block discarded – undo
1015 1015
  * 
1016 1016
  * @param WPInv_Invoice $invoice
1017 1017
  */
1018
-function wpinv_display_to_address( $invoice = 0 ) {
1019
-    if ( ! empty( $invoice ) ) {
1020
-        wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) );
1018
+function wpinv_display_to_address($invoice = 0) {
1019
+    if (!empty($invoice)) {
1020
+        wpinv_get_template('invoice/billing-address.php', compact('invoice'));
1021 1021
     }
1022 1022
 }
1023
-add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 );
1023
+add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40);
1024 1024
 
1025 1025
 
1026 1026
 /**
1027 1027
  * Displays invoice line items.
1028 1028
  */
1029
-function wpinv_display_line_items( $invoice_id = 0 ) {
1029
+function wpinv_display_line_items($invoice_id = 0) {
1030 1030
 
1031 1031
     // Prepare the invoice.
1032
-    $invoice = new WPInv_Invoice( $invoice_id );
1032
+    $invoice = new WPInv_Invoice($invoice_id);
1033 1033
 
1034 1034
     // Abort if there is no invoice.
1035
-    if ( 0 == $invoice->get_id() ) {
1035
+    if (0 == $invoice->get_id()) {
1036 1036
         return;
1037 1037
     }
1038 1038
 
1039 1039
     // Line item columns.
1040
-    $columns = getpaid_invoice_item_columns( $invoice );
1041
-    $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice );
1040
+    $columns = getpaid_invoice_item_columns($invoice);
1041
+    $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice);
1042 1042
 
1043
-    wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) );
1043
+    wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns'));
1044 1044
 }
1045
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 );
1045
+add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10);
1046 1046
 
1047 1047
 /**
1048 1048
  * Displays invoice notices on invoices.
1049 1049
  */
1050 1050
 function wpinv_display_invoice_notice() {
1051 1051
 
1052
-    $label  = wpinv_get_option( 'vat_invoice_notice_label' );
1053
-    $notice = wpinv_get_option( 'vat_invoice_notice' );
1052
+    $label  = wpinv_get_option('vat_invoice_notice_label');
1053
+    $notice = wpinv_get_option('vat_invoice_notice');
1054 1054
 
1055
-    if ( empty( $label ) && empty( $notice ) ) {
1055
+    if (empty($label) && empty($notice)) {
1056 1056
         return;
1057 1057
     }
1058 1058
 
1059 1059
     echo '<div class="mt-4 mb-4 wpinv-vat-notice">';
1060 1060
 
1061
-    if ( ! empty( $label ) ) {
1062
-        $label = sanitize_text_field( $label );
1061
+    if (!empty($label)) {
1062
+        $label = sanitize_text_field($label);
1063 1063
         echo "<h5>$label</h5>";
1064 1064
     }
1065 1065
 
1066
-    if ( ! empty( $notice ) ) {
1067
-        echo '<small class="form-text text-muted">' . wpautop( wptexturize( $notice ) ) . '</small>';
1066
+    if (!empty($notice)) {
1067
+        echo '<small class="form-text text-muted">' . wpautop(wptexturize($notice)) . '</small>';
1068 1068
     }
1069 1069
 
1070 1070
     echo '</div>';
1071 1071
 }
1072
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 );
1072
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100);
1073 1073
 
1074 1074
 /**
1075 1075
  * @param WPInv_Invoice $invoice
1076 1076
  */
1077
-function wpinv_display_invoice_notes( $invoice ) {
1077
+function wpinv_display_invoice_notes($invoice) {
1078 1078
 
1079 1079
     // Retrieve the notes.
1080
-    $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' );
1080
+    $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer');
1081 1081
 
1082 1082
     // Abort if we have non.
1083
-    if ( empty( $notes ) ) {
1083
+    if (empty($notes)) {
1084 1084
         return;
1085 1085
     }
1086 1086
 
1087 1087
     // Echo the note.
1088 1088
     echo '<div class="getpaid-invoice-notes-wrapper border position-relative w-100 mb-4 p-0">';
1089
-    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __( 'Notes', 'invoicing' ) .'</h3>';
1089
+    echo '<h3 class="getpaid-invoice-notes-title text-dark bg-light border-bottom m-0 d-block">' . __('Notes', 'invoicing') . '</h3>';
1090 1090
     echo '<ul class="getpaid-invoice-notes mt-4 p-0">';
1091 1091
 
1092
-    foreach( $notes as $note ) {
1093
-        wpinv_get_invoice_note_line_item( $note );
1092
+    foreach ($notes as $note) {
1093
+        wpinv_get_invoice_note_line_item($note);
1094 1094
     }
1095 1095
 
1096 1096
     echo '</ul>';
1097 1097
     echo '</div>';
1098 1098
 }
1099
-add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 );
1099
+add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60);
1100 1100
 
1101 1101
 /**
1102 1102
  * Loads scripts on our invoice templates.
@@ -1104,32 +1104,32 @@  discard block
 block discarded – undo
1104 1104
 function wpinv_display_style() {
1105 1105
 
1106 1106
     // Make sure that all scripts have been loaded.
1107
-    if ( ! did_action( 'wp_enqueue_scripts' ) ) {
1108
-        do_action( 'wp_enqueue_scripts' );
1107
+    if (!did_action('wp_enqueue_scripts')) {
1108
+        do_action('wp_enqueue_scripts');
1109 1109
     }
1110 1110
 
1111 1111
     // Register the invoices style.
1112
-    wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) );
1112
+    wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css'));
1113 1113
 
1114 1114
     // Load required styles
1115
-    wp_print_styles( 'open-sans' );
1116
-    wp_print_styles( 'wpinv-single-style' );
1117
-    wp_print_styles( 'ayecode-ui' );
1115
+    wp_print_styles('open-sans');
1116
+    wp_print_styles('wpinv-single-style');
1117
+    wp_print_styles('ayecode-ui');
1118 1118
 
1119 1119
     // Maybe load custom css.
1120
-    $custom_css = wpinv_get_option( 'template_custom_css' );
1120
+    $custom_css = wpinv_get_option('template_custom_css');
1121 1121
 
1122
-    if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
1123
-        $custom_css     = wp_kses( $custom_css, array( '\'', '\"' ) );
1124
-        $custom_css     = str_replace( '&gt;', '>', $custom_css );
1122
+    if (isset($custom_css) && !empty($custom_css)) {
1123
+        $custom_css     = wp_kses($custom_css, array('\'', '\"'));
1124
+        $custom_css     = str_replace('&gt;', '>', $custom_css);
1125 1125
         echo '<style type="text/css">';
1126 1126
         echo $custom_css;
1127 1127
         echo '</style>';
1128 1128
     }
1129 1129
 
1130 1130
 }
1131
-add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' );
1132
-add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' );
1131
+add_action('wpinv_invoice_print_head', 'wpinv_display_style');
1132
+add_action('wpinv_invalid_invoice_head', 'wpinv_display_style');
1133 1133
 
1134 1134
 
1135 1135
 /**
@@ -1141,41 +1141,41 @@  discard block
 block discarded – undo
1141 1141
     // Retrieve the current invoice.
1142 1142
     $invoice_id = getpaid_get_current_invoice_id();
1143 1143
 
1144
-    if ( empty( $invoice_id ) ) {
1144
+    if (empty($invoice_id)) {
1145 1145
 
1146 1146
         return aui()->alert(
1147 1147
             array(
1148 1148
                 'type'    => 'warning',
1149
-                'content' => __( 'Invalid invoice', 'invoicing' ),
1149
+                'content' => __('Invalid invoice', 'invoicing'),
1150 1150
             )
1151 1151
         );
1152 1152
 
1153 1153
     }
1154 1154
 
1155 1155
     // Can the user view this invoice?
1156
-    if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) {
1156
+    if (!wpinv_user_can_view_invoice($invoice_id)) {
1157 1157
 
1158 1158
         return aui()->alert(
1159 1159
             array(
1160 1160
                 'type'    => 'warning',
1161
-                'content' => __( 'You are not allowed to view this invoice', 'invoicing' ),
1161
+                'content' => __('You are not allowed to view this invoice', 'invoicing'),
1162 1162
             )
1163 1163
         );
1164 1164
 
1165 1165
     }
1166 1166
 
1167 1167
     // Ensure that it is not yet paid for.
1168
-    $invoice = new WPInv_Invoice( $invoice_id );
1168
+    $invoice = new WPInv_Invoice($invoice_id);
1169 1169
 
1170 1170
     // Maybe mark it as viewed.
1171
-    getpaid_maybe_mark_invoice_as_viewed( $invoice );
1171
+    getpaid_maybe_mark_invoice_as_viewed($invoice);
1172 1172
 
1173
-    if ( $invoice->is_paid() ) {
1173
+    if ($invoice->is_paid()) {
1174 1174
 
1175 1175
         return aui()->alert(
1176 1176
             array(
1177 1177
                 'type'    => 'success',
1178
-                'content' => __( 'This invoice has already been paid.', 'invoicing' ),
1178
+                'content' => __('This invoice has already been paid.', 'invoicing'),
1179 1179
             )
1180 1180
         );
1181 1181
 
@@ -1185,14 +1185,14 @@  discard block
 block discarded – undo
1185 1185
     $wpi_checkout_id = $invoice_id;
1186 1186
 
1187 1187
     // We'll display this invoice via the default form.
1188
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1188
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1189 1189
 
1190
-    if ( 0 == $form->get_id() ) {
1190
+    if (0 == $form->get_id()) {
1191 1191
 
1192 1192
         return aui()->alert(
1193 1193
             array(
1194 1194
                 'type'    => 'warning',
1195
-                'content' => __( 'Error loading the payment form', 'invoicing' ),
1195
+                'content' => __('Error loading the payment form', 'invoicing'),
1196 1196
             )
1197 1197
         );
1198 1198
 
@@ -1200,7 +1200,7 @@  discard block
 block discarded – undo
1200 1200
 
1201 1201
     // Set the invoice.
1202 1202
     $form->invoice = $invoice;
1203
-    $form->set_items( $invoice->get_items() );
1203
+    $form->set_items($invoice->get_items());
1204 1204
 
1205 1205
     // Generate the html.
1206 1206
     return $form->get_html();
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 }
1209 1209
 
1210 1210
 function wpinv_empty_cart_message() {
1211
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1211
+	return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>');
1212 1212
 }
1213 1213
 
1214 1214
 /**
@@ -1225,38 +1225,38 @@  discard block
 block discarded – undo
1225 1225
         )
1226 1226
     );
1227 1227
 }
1228
-add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' );
1228
+add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart');
1229 1229
 
1230
-function wpinv_receipt_billing_address( $invoice_id = 0 ) {
1231
-    $invoice = wpinv_get_invoice( $invoice_id );
1230
+function wpinv_receipt_billing_address($invoice_id = 0) {
1231
+    $invoice = wpinv_get_invoice($invoice_id);
1232 1232
 
1233
-    if ( empty( $invoice ) ) {
1233
+    if (empty($invoice)) {
1234 1234
         return NULL;
1235 1235
     }
1236 1236
 
1237 1237
     $billing_details = $invoice->get_user_info();
1238
-    $address_row = wpinv_get_invoice_address_markup( $billing_details );
1238
+    $address_row = wpinv_get_invoice_address_markup($billing_details);
1239 1239
 
1240 1240
     ob_start();
1241 1241
     ?>
1242 1242
     <table class="table table-bordered table-sm wpi-billing-details">
1243 1243
         <tbody>
1244 1244
             <tr class="wpi-receipt-name">
1245
-                <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th>
1246
-                <td><?php echo esc_html( trim( $billing_details['first_name'] . ' ' . $billing_details['last_name'] ) ) ;?></td>
1245
+                <th class="text-left"><?php _e('Name', 'invoicing'); ?></th>
1246
+                <td><?php echo esc_html(trim($billing_details['first_name'] . ' ' . $billing_details['last_name'])); ?></td>
1247 1247
             </tr>
1248 1248
             <tr class="wpi-receipt-email">
1249
-                <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th>
1250
-                <td><?php echo $billing_details['email'] ;?></td>
1249
+                <th class="text-left"><?php _e('Email', 'invoicing'); ?></th>
1250
+                <td><?php echo $billing_details['email']; ?></td>
1251 1251
             </tr>
1252 1252
             <tr class="wpi-receipt-address">
1253
-                <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th>
1254
-                <td><?php echo $address_row ;?></td>
1253
+                <th class="text-left"><?php _e('Address', 'invoicing'); ?></th>
1254
+                <td><?php echo $address_row; ?></td>
1255 1255
             </tr>
1256
-            <?php if ( $billing_details['phone'] ) { ?>
1256
+            <?php if ($billing_details['phone']) { ?>
1257 1257
             <tr class="wpi-receipt-phone">
1258
-                <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th>
1259
-                <td><?php echo esc_html( $billing_details['phone'] ) ;?></td>
1258
+                <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th>
1259
+                <td><?php echo esc_html($billing_details['phone']); ?></td>
1260 1260
             </tr>
1261 1261
             <?php } ?>
1262 1262
         </tbody>
@@ -1264,7 +1264,7 @@  discard block
 block discarded – undo
1264 1264
     <?php
1265 1265
     $output = ob_get_clean();
1266 1266
     
1267
-    $output = apply_filters( 'wpinv_receipt_billing_address', $output, $invoice_id );
1267
+    $output = apply_filters('wpinv_receipt_billing_address', $output, $invoice_id);
1268 1268
 
1269 1269
     echo $output;
1270 1270
 }
@@ -1272,88 +1272,88 @@  discard block
 block discarded – undo
1272 1272
 /**
1273 1273
  * Filters the receipt page.
1274 1274
  */
1275
-function wpinv_filter_success_page_content( $content ) {
1275
+function wpinv_filter_success_page_content($content) {
1276 1276
 
1277 1277
     // Ensure this is our page.
1278
-    if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) {
1278
+    if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) {
1279 1279
 
1280
-        $gateway = sanitize_text_field( $_GET['payment-confirm'] );
1281
-        return apply_filters( "wpinv_payment_confirm_$gateway", $content );
1280
+        $gateway = sanitize_text_field($_GET['payment-confirm']);
1281
+        return apply_filters("wpinv_payment_confirm_$gateway", $content);
1282 1282
 
1283 1283
     }
1284 1284
 
1285 1285
     return $content;
1286 1286
 }
1287
-add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 );
1287
+add_filter('the_content', 'wpinv_filter_success_page_content', 99999);
1288 1288
 
1289
-function wpinv_invoice_link( $invoice_id ) {
1290
-    $invoice = wpinv_get_invoice( $invoice_id );
1289
+function wpinv_invoice_link($invoice_id) {
1290
+    $invoice = wpinv_get_invoice($invoice_id);
1291 1291
 
1292
-    if ( empty( $invoice ) ) {
1292
+    if (empty($invoice)) {
1293 1293
         return NULL;
1294 1294
     }
1295 1295
 
1296
-    $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>';
1296
+    $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>';
1297 1297
 
1298
-    return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice );
1298
+    return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice);
1299 1299
 }
1300 1300
 
1301
-function wpinv_cart_total_label( $label, $invoice ) {
1302
-    if ( empty( $invoice ) ) {
1301
+function wpinv_cart_total_label($label, $invoice) {
1302
+    if (empty($invoice)) {
1303 1303
         return $label;
1304 1304
     }
1305 1305
 
1306 1306
     $prefix_label = '';
1307
-    if ( $invoice->is_parent() && $item_id = $invoice->get_recurring() ) {
1308
-        $prefix_label   = '<span class="label label-primary label-recurring">' . __( 'Recurring Payment', 'invoicing' ) . '</span> ' . wpinv_subscription_payment_desc( $invoice );
1309
-    } else if ( $invoice->is_renewal() ) {
1310
-        $prefix_label   = '<span class="label label-primary label-renewal">' . __( 'Renewal Payment', 'invoicing' ) . '</span> ';        
1307
+    if ($invoice->is_parent() && $item_id = $invoice->get_recurring()) {
1308
+        $prefix_label   = '<span class="label label-primary label-recurring">' . __('Recurring Payment', 'invoicing') . '</span> ' . wpinv_subscription_payment_desc($invoice);
1309
+    } else if ($invoice->is_renewal()) {
1310
+        $prefix_label   = '<span class="label label-primary label-renewal">' . __('Renewal Payment', 'invoicing') . '</span> ';        
1311 1311
     }
1312 1312
 
1313
-    if ( $prefix_label != '' ) {
1314
-        $label  = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1313
+    if ($prefix_label != '') {
1314
+        $label = '<span class="wpinv-cart-sub-desc">' . $prefix_label . '</span> ' . $label;
1315 1315
     }
1316 1316
 
1317 1317
     return $label;
1318 1318
 }
1319
-add_filter( 'wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1320
-add_filter( 'wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1321
-add_filter( 'wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2 );
1319
+add_filter('wpinv_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1320
+add_filter('wpinv_email_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1321
+add_filter('wpinv_print_cart_total_label', 'wpinv_cart_total_label', 10, 2);
1322 1322
 
1323
-function wpinv_get_invoice_note_line_item( $note, $echo = true ) {
1324
-    if ( empty( $note ) ) {
1323
+function wpinv_get_invoice_note_line_item($note, $echo = true) {
1324
+    if (empty($note)) {
1325 1325
         return NULL;
1326 1326
     }
1327 1327
 
1328
-    if ( is_int( $note ) ) {
1329
-        $note = get_comment( $note );
1328
+    if (is_int($note)) {
1329
+        $note = get_comment($note);
1330 1330
     }
1331 1331
 
1332
-    if ( !( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) {
1332
+    if (!(is_object($note) && is_a($note, 'WP_Comment'))) {
1333 1333
         return NULL;
1334 1334
     }
1335 1335
 
1336
-    $note_classes   = array( 'note' );
1337
-    $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : '';
1336
+    $note_classes   = array('note');
1337
+    $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : '';
1338 1338
     $note_classes[] = $note->comment_author === 'System' ? 'system-note' : '';
1339
-    $note_classes   = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note );
1340
-    $note_classes   = !empty( $note_classes ) ? implode( ' ', $note_classes ) : '';
1339
+    $note_classes   = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note);
1340
+    $note_classes   = !empty($note_classes) ? implode(' ', $note_classes) : '';
1341 1341
 
1342 1342
     ob_start();
1343 1343
     ?>
1344
-    <li rel="<?php echo absint( $note->comment_ID ) ; ?>" class="<?php echo esc_attr( $note_classes ); ?> mt-4 pl-3 pr-3">
1344
+    <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mt-4 pl-3 pr-3">
1345 1345
         <div class="note_content bg-light border position-relative p-4">
1346 1346
 
1347
-            <?php echo wpautop( wptexturize( wp_kses_post( $note->comment_content ) ) ); ?>
1347
+            <?php echo wpautop(wptexturize(wp_kses_post($note->comment_content))); ?>
1348 1348
 
1349
-            <?php if ( ! is_admin() ) : ?>
1349
+            <?php if (!is_admin()) : ?>
1350 1350
                 <em class="meta position-absolute form-text">
1351 1351
                     <?php
1352 1352
                         printf(
1353
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1353
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1354 1354
                             $note->comment_author,
1355
-                            getpaid_format_date_value( $note->comment_date ),
1356
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1355
+                            getpaid_format_date_value($note->comment_date),
1356
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1357 1357
                         );
1358 1358
                     ?>
1359 1359
                 </em>
@@ -1361,21 +1361,21 @@  discard block
 block discarded – undo
1361 1361
 
1362 1362
         </div>
1363 1363
 
1364
-        <?php if ( is_admin() ) : ?>
1364
+        <?php if (is_admin()) : ?>
1365 1365
 
1366 1366
             <p class="meta px-4 py-2">
1367
-                <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>">
1367
+                <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>">
1368 1368
                     <?php
1369 1369
                         printf(
1370
-                            __( '%1$s - %2$s at %3$s', 'invoicing' ),
1370
+                            __('%1$s - %2$s at %3$s', 'invoicing'),
1371 1371
                             $note->comment_author,
1372
-                            getpaid_format_date_value( $note->comment_date ),
1373
-                            date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) )
1372
+                            getpaid_format_date_value($note->comment_date),
1373
+                            date_i18n(get_option('time_format'), strtotime($note->comment_date))
1374 1374
                         );
1375 1375
                     ?>
1376 1376
                 </abbr>&nbsp;&nbsp;
1377
-                <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?>
1378
-                    <a href="#" class="delete_note"><?php _e( 'Delete note', 'invoicing' ); ?></a>
1377
+                <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?>
1378
+                    <a href="#" class="delete_note"><?php _e('Delete note', 'invoicing'); ?></a>
1379 1379
                 <?php } ?>
1380 1380
             </p>
1381 1381
 
@@ -1384,9 +1384,9 @@  discard block
 block discarded – undo
1384 1384
     </li>
1385 1385
     <?php
1386 1386
     $note_content = ob_get_clean();
1387
-    $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo );
1387
+    $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo);
1388 1388
 
1389
-    if ( $echo ) {
1389
+    if ($echo) {
1390 1390
         echo $note_content;
1391 1391
     } else {
1392 1392
         return $note_content;
@@ -1396,36 +1396,36 @@  discard block
 block discarded – undo
1396 1396
 function wpinv_invalid_invoice_content() {
1397 1397
     global $post;
1398 1398
 
1399
-    $invoice = wpinv_get_invoice( $post->ID );
1399
+    $invoice = wpinv_get_invoice($post->ID);
1400 1400
 
1401
-    $error = __( 'This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing' );
1402
-    if ( !empty( $invoice->get_id() ) && $invoice->has_status( array_keys( wpinv_get_invoice_statuses() ) ) ) {
1403
-        if ( is_user_logged_in() ) {
1404
-            if ( wpinv_require_login_to_checkout() ) {
1405
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1406
-                    $error = __( 'You are not allowed to view this invoice.', 'invoicing' );
1401
+    $error = __('This invoice is only viewable by clicking on the invoice link that was sent to you via email.', 'invoicing');
1402
+    if (!empty($invoice->get_id()) && $invoice->has_status(array_keys(wpinv_get_invoice_statuses()))) {
1403
+        if (is_user_logged_in()) {
1404
+            if (wpinv_require_login_to_checkout()) {
1405
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1406
+                    $error = __('You are not allowed to view this invoice.', 'invoicing');
1407 1407
                 }
1408 1408
             }
1409 1409
         } else {
1410
-            if ( wpinv_require_login_to_checkout() ) {
1411
-                if ( isset( $_GET['invoice_key'] ) && $_GET['invoice_key'] === $invoice->get_key() ) {
1412
-                    $error = __( 'You must be logged in to view this invoice.', 'invoicing' );
1410
+            if (wpinv_require_login_to_checkout()) {
1411
+                if (isset($_GET['invoice_key']) && $_GET['invoice_key'] === $invoice->get_key()) {
1412
+                    $error = __('You must be logged in to view this invoice.', 'invoicing');
1413 1413
                 }
1414 1414
             }
1415 1415
         }
1416 1416
     } else {
1417
-        $error = __( 'This invoice is deleted or does not exist.', 'invoicing' );
1417
+        $error = __('This invoice is deleted or does not exist.', 'invoicing');
1418 1418
     }
1419 1419
     ?>
1420 1420
     <div class="row wpinv-row-invalid">
1421 1421
         <div class="col-md-6 col-md-offset-3 wpinv-message error">
1422
-            <h3><?php _e( 'Access Denied', 'invoicing' ); ?></h3>
1422
+            <h3><?php _e('Access Denied', 'invoicing'); ?></h3>
1423 1423
             <p class="wpinv-msg-text"><?php echo $error; ?></p>
1424 1424
         </div>
1425 1425
     </div>
1426 1426
     <?php
1427 1427
 }
1428
-add_action( 'wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content' );
1428
+add_action('wpinv_invalid_invoice_content', 'wpinv_invalid_invoice_content');
1429 1429
 
1430 1430
 /**
1431 1431
  * Function to get privacy policy text.
@@ -1434,21 +1434,21 @@  discard block
 block discarded – undo
1434 1434
  * @return string
1435 1435
  */
1436 1436
 function wpinv_get_policy_text() {
1437
-    $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 );
1437
+    $privacy_page_id = get_option('wp_page_for_privacy_policy', 0);
1438 1438
 
1439
-    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ));
1439
+    $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]'));
1440 1440
 
1441
-    if(!$privacy_page_id){
1442
-        $privacy_page_id = wpinv_get_option( 'privacy_page', 0 );
1441
+    if (!$privacy_page_id) {
1442
+        $privacy_page_id = wpinv_get_option('privacy_page', 0);
1443 1443
     }
1444 1444
 
1445
-    $privacy_link    = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' );
1445
+    $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing');
1446 1446
 
1447 1447
     $find_replace = array(
1448 1448
         '[wpinv_privacy_policy]' => $privacy_link,
1449 1449
     );
1450 1450
 
1451
-    $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text );
1451
+    $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text);
1452 1452
 
1453 1453
     return wp_kses_post(wpautop($privacy_text));
1454 1454
 }
@@ -1456,21 +1456,21 @@  discard block
 block discarded – undo
1456 1456
 function wpinv_oxygen_fix_conflict() {
1457 1457
     global $ct_ignore_post_types;
1458 1458
 
1459
-    if ( ! is_array( $ct_ignore_post_types ) ) {
1459
+    if (!is_array($ct_ignore_post_types)) {
1460 1460
         $ct_ignore_post_types = array();
1461 1461
     }
1462 1462
 
1463
-    $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item' );
1463
+    $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item');
1464 1464
 
1465
-    foreach ( $post_types as $post_type ) {
1465
+    foreach ($post_types as $post_type) {
1466 1466
         $ct_ignore_post_types[] = $post_type;
1467 1467
 
1468 1468
         // Ignore post type
1469
-        add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 );
1469
+        add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999);
1470 1470
     }
1471 1471
 
1472
-    remove_filter( 'template_include', 'wpinv_template', 10, 1 );
1473
-    add_filter( 'template_include', 'wpinv_template', 999, 1 );
1472
+    remove_filter('template_include', 'wpinv_template', 10, 1);
1473
+    add_filter('template_include', 'wpinv_template', 999, 1);
1474 1474
 }
1475 1475
 
1476 1476
 /**
@@ -1478,10 +1478,10 @@  discard block
 block discarded – undo
1478 1478
  * 
1479 1479
  * @param GetPaid_Payment_Form $form
1480 1480
  */
1481
-function getpaid_display_payment_form( $form ) {
1481
+function getpaid_display_payment_form($form) {
1482 1482
 
1483
-    if ( is_numeric( $form ) ) {
1484
-        $form = new GetPaid_Payment_Form( $form );
1483
+    if (is_numeric($form)) {
1484
+        $form = new GetPaid_Payment_Form($form);
1485 1485
     }
1486 1486
 
1487 1487
     $form->display();
@@ -1491,16 +1491,16 @@  discard block
 block discarded – undo
1491 1491
 /**
1492 1492
  * Helper function to display a item payment form on the frontend.
1493 1493
  */
1494
-function getpaid_display_item_payment_form( $items ) {
1494
+function getpaid_display_item_payment_form($items) {
1495 1495
 
1496
-    $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() );
1497
-    $form->set_items( $items );
1496
+    $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form());
1497
+    $form->set_items($items);
1498 1498
 
1499
-    if ( 0 == count( $form->get_items() ) ) {
1499
+    if (0 == count($form->get_items())) {
1500 1500
         echo aui()->alert(
1501 1501
 			array(
1502 1502
 				'type'    => 'warning',
1503
-				'content' => __( 'No published items found', 'invoicing' ),
1503
+				'content' => __('No published items found', 'invoicing'),
1504 1504
 			)
1505 1505
         );
1506 1506
         return;
@@ -1512,75 +1512,75 @@  discard block
 block discarded – undo
1512 1512
 /**
1513 1513
  * Helper function to display an invoice payment form on the frontend.
1514 1514
  */
1515
-function getpaid_display_invoice_payment_form( $invoice_id ) {
1515
+function getpaid_display_invoice_payment_form($invoice_id) {
1516 1516
     global $invoicing;
1517 1517
 
1518
-    $invoice = wpinv_get_invoice( $invoice_id );
1518
+    $invoice = wpinv_get_invoice($invoice_id);
1519 1519
 
1520
-    if ( empty( $invoice ) ) {
1520
+    if (empty($invoice)) {
1521 1521
 		return aui()->alert(
1522 1522
 			array(
1523 1523
 				'type'    => 'warning',
1524
-				'content' => __( 'Invoice not found', 'invoicing' ),
1524
+				'content' => __('Invoice not found', 'invoicing'),
1525 1525
 			)
1526 1526
 		);
1527 1527
     }
1528 1528
 
1529
-    if ( $invoice->is_paid() ) {
1529
+    if ($invoice->is_paid()) {
1530 1530
 		return aui()->alert(
1531 1531
 			array(
1532 1532
 				'type'    => 'warning',
1533
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1533
+				'content' => __('Invoice has already been paid', 'invoicing'),
1534 1534
 			)
1535 1535
 		);
1536 1536
     }
1537 1537
 
1538 1538
     // Get the form elements and items.
1539
-    $form     = wpinv_get_default_payment_form();
1540
-	$elements = $invoicing->form_elements->get_form_elements( $form );
1541
-	$items    = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice );
1539
+    $form = wpinv_get_default_payment_form();
1540
+	$elements = $invoicing->form_elements->get_form_elements($form);
1541
+	$items    = $invoicing->form_elements->convert_checkout_items($invoice->cart_details, $invoice);
1542 1542
 
1543 1543
 	ob_start();
1544 1544
 	echo "<form class='wpinv_payment_form'>";
1545
-	do_action( 'wpinv_payment_form_top' );
1545
+	do_action('wpinv_payment_form_top');
1546 1546
     echo "<input type='hidden' name='form_id' value='$form'/>";
1547 1547
     echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>";
1548
-	wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' );
1549
-	wp_nonce_field( 'vat_validation', '_wpi_nonce' );
1548
+	wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form');
1549
+	wp_nonce_field('vat_validation', '_wpi_nonce');
1550 1550
 
1551
-	foreach ( $elements as $element ) {
1552
-		do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form );
1553
-		do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form );
1551
+	foreach ($elements as $element) {
1552
+		do_action('wpinv_frontend_render_payment_form_element', $element, $items, $form);
1553
+		do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form);
1554 1554
 	}
1555 1555
 
1556 1556
 	echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>";
1557
-	do_action( 'wpinv_payment_form_bottom' );
1557
+	do_action('wpinv_payment_form_bottom');
1558 1558
 	echo '</form>';
1559 1559
 
1560 1560
 	$content = ob_get_clean();
1561
-	return str_replace( 'sr-only', '', $content );
1561
+	return str_replace('sr-only', '', $content);
1562 1562
 }
1563 1563
 
1564 1564
 /**
1565 1565
  * Helper function to convert item string to array.
1566 1566
  */
1567
-function getpaid_convert_items_to_array( $items ) {
1568
-    $items    = array_filter( array_map( 'trim', explode( ',', $items ) ) );
1567
+function getpaid_convert_items_to_array($items) {
1568
+    $items    = array_filter(array_map('trim', explode(',', $items)));
1569 1569
     $prepared = array();
1570 1570
 
1571
-    foreach ( $items as $item ) {
1572
-        $data = array_map( 'trim', explode( '|', $item ) );
1571
+    foreach ($items as $item) {
1572
+        $data = array_map('trim', explode('|', $item));
1573 1573
 
1574
-        if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) {
1574
+        if (empty($data[0]) || !is_numeric($data[0])) {
1575 1575
             continue;
1576 1576
         }
1577 1577
 
1578 1578
         $quantity = 1;
1579
-        if ( isset( $data[1] ) && is_numeric( $data[1] ) ) {
1579
+        if (isset($data[1]) && is_numeric($data[1])) {
1580 1580
             $quantity = (int) $data[1];
1581 1581
         }
1582 1582
 
1583
-        $prepared[ $data[0] ] = $quantity;
1583
+        $prepared[$data[0]] = $quantity;
1584 1584
 
1585 1585
     }
1586 1586
 
@@ -1590,13 +1590,13 @@  discard block
 block discarded – undo
1590 1590
 /**
1591 1591
  * Helper function to convert item array to string.
1592 1592
  */
1593
-function getpaid_convert_items_to_string( $items ) {
1593
+function getpaid_convert_items_to_string($items) {
1594 1594
     $prepared = array();
1595 1595
 
1596
-    foreach ( $items as $item => $quantity ) {
1596
+    foreach ($items as $item => $quantity) {
1597 1597
         $prepared[] = "$item|$quantity";
1598 1598
     }
1599
-    return implode( ',', $prepared );
1599
+    return implode(',', $prepared);
1600 1600
 }
1601 1601
 
1602 1602
 /**
@@ -1604,22 +1604,22 @@  discard block
 block discarded – undo
1604 1604
  * 
1605 1605
  * Provide a label and one of $form, $items or $invoice.
1606 1606
  */
1607
-function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) {
1608
-    $label = sanitize_text_field( $label );
1607
+function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) {
1608
+    $label = sanitize_text_field($label);
1609 1609
     $nonce = wp_create_nonce('getpaid_ajax_form');
1610 1610
 
1611
-    if ( ! empty( $form ) ) {
1612
-        $form  = esc_attr( $form );
1611
+    if (!empty($form)) {
1612
+        $form = esc_attr($form);
1613 1613
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; 
1614 1614
     }
1615 1615
 	
1616
-	if ( ! empty( $items ) ) {
1617
-        $items  = esc_attr( $items );
1616
+	if (!empty($items)) {
1617
+        $items = esc_attr($items);
1618 1618
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; 
1619 1619
     }
1620 1620
     
1621
-    if ( ! empty( $invoice ) ) {
1622
-        $invoice  = esc_attr( $invoice );
1621
+    if (!empty($invoice)) {
1622
+        $invoice = esc_attr($invoice);
1623 1623
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-invoice='$invoice'>$label</button>"; 
1624 1624
     }
1625 1625
 
@@ -1630,17 +1630,17 @@  discard block
 block discarded – undo
1630 1630
  *
1631 1631
  * @param WPInv_Invoice $invoice
1632 1632
  */
1633
-function getpaid_the_invoice_description( $invoice ) {
1633
+function getpaid_the_invoice_description($invoice) {
1634 1634
     $description = $invoice->get_description();
1635 1635
 
1636
-    if ( empty( $description ) ) {
1636
+    if (empty($description)) {
1637 1637
         return;
1638 1638
     }
1639 1639
 
1640
-    $description = wp_kses_post( $description );
1640
+    $description = wp_kses_post($description);
1641 1641
     echo "<small class='getpaid-invoice-description text-dark p-2 form-text'><em>$description</em></small>";
1642 1642
 }
1643
-add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 );
1643
+add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100);
1644 1644
 
1645 1645
 /**
1646 1646
  * Render element on a form.
@@ -1648,41 +1648,41 @@  discard block
 block discarded – undo
1648 1648
  * @param array $element
1649 1649
  * @param GetPaid_Payment_Form $form
1650 1650
  */
1651
-function getpaid_payment_form_element( $element, $form ) {
1651
+function getpaid_payment_form_element($element, $form) {
1652 1652
 
1653 1653
     // Set up the args.
1654
-    $element_type    = trim( $element['type'] );
1654
+    $element_type    = trim($element['type']);
1655 1655
     $element['form'] = $form;
1656
-    extract( $element );
1656
+    extract($element);
1657 1657
 
1658 1658
     // Try to locate the appropriate template.
1659
-    $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" );
1659
+    $located = wpinv_locate_template("payment-forms/elements/$element_type.php");
1660 1660
     
1661 1661
     // Abort if this is not our element.
1662
-    if ( empty( $located ) || ! file_exists( $located ) ) {
1662
+    if (empty($located) || !file_exists($located)) {
1663 1663
         return;
1664 1664
     }
1665 1665
 
1666 1666
     // Generate the class and id of the element.
1667
-    $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) );
1668
-    $id            = isset( $id ) ? $id : uniqid( 'gp' );
1667
+    $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type));
1668
+    $id            = isset($id) ? $id : uniqid('gp');
1669 1669
 
1670 1670
     // Echo the opening wrapper.
1671 1671
     echo "<div class='getpaid-payment-form-element $wrapper_class'>";
1672 1672
 
1673 1673
     // Fires before displaying a given element type's content.
1674
-    do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form );
1674
+    do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form);
1675 1675
 
1676 1676
     // Include the template for the element.
1677 1677
     include $located;
1678 1678
 
1679 1679
     // Fires after displaying a given element type's content.
1680
-    do_action( "getpaid_payment_form_{$element_type}_element", $element, $form );
1680
+    do_action("getpaid_payment_form_{$element_type}_element", $element, $form);
1681 1681
 
1682 1682
     // Echo the closing wrapper.
1683 1683
     echo '</div>';
1684 1684
 }
1685
-add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 );
1685
+add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2);
1686 1686
 
1687 1687
 /**
1688 1688
  * Shows a list of gateways that support recurring payments.
@@ -1690,17 +1690,17 @@  discard block
 block discarded – undo
1690 1690
 function wpinv_get_recurring_gateways_text() {
1691 1691
     $gateways = array();
1692 1692
 
1693
-    foreach ( wpinv_get_payment_gateways() as $key => $gateway ) {
1694
-        if ( wpinv_gateway_support_subscription( $key ) ) {
1695
-            $gateways[] = sanitize_text_field( $gateway['admin_label'] );
1693
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
1694
+        if (wpinv_gateway_support_subscription($key)) {
1695
+            $gateways[] = sanitize_text_field($gateway['admin_label']);
1696 1696
         }
1697 1697
     }
1698 1698
 
1699
-    if ( empty( $gateways ) ) {
1700
-        return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) ."</span>";
1699
+    if (empty($gateways)) {
1700
+        return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . "</span>";
1701 1701
     }
1702 1702
 
1703
-    return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) ."</span>";
1703
+    return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . "</span>";
1704 1704
 
1705 1705
 }
1706 1706
 
@@ -1710,7 +1710,7 @@  discard block
 block discarded – undo
1710 1710
  * @return GetPaid_Template
1711 1711
  */
1712 1712
 function getpaid_template() {
1713
-    return getpaid()->get( 'template' );
1713
+    return getpaid()->get('template');
1714 1714
 }
1715 1715
 
1716 1716
 /**
@@ -1719,23 +1719,23 @@  discard block
 block discarded – undo
1719 1719
  * @param array args
1720 1720
  * @return string
1721 1721
  */
1722
-function getpaid_paginate_links( $args ) {
1722
+function getpaid_paginate_links($args) {
1723 1723
 
1724 1724
     $args['type']     = 'array';
1725 1725
     $args['mid_size'] = 1;
1726
-    $pages        = paginate_links( $args );
1726
+    $pages = paginate_links($args);
1727 1727
 
1728
-    if ( ! is_array( $pages ) ) {
1728
+    if (!is_array($pages)) {
1729 1729
         return '';
1730 1730
     }
1731 1731
 
1732 1732
     $_pages = array();
1733
-    foreach ( $pages as $page ) {
1734
-        $_pages[] = str_replace( 'page-numbers', 'page-link text-decoration-none', $page );
1733
+    foreach ($pages as $page) {
1734
+        $_pages[] = str_replace('page-numbers', 'page-link text-decoration-none', $page);
1735 1735
     }
1736 1736
 
1737 1737
     $links  = "<nav>\n\t<ul class='pagination justify-content-end m-0'>\n\t\t<li class='page-item'>";
1738
-    $links .= join( "</li>\n\t\t<li class='page-item'>", $_pages );
1738
+    $links .= join("</li>\n\t\t<li class='page-item'>", $_pages);
1739 1739
     $links .= "</li>\n\t</ul>\n</nav>\n";
1740 1740
 
1741 1741
     return $links;
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2293 added lines, -2293 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87 87
     );
88 88
 
89 89
     /**
90
-	 * Stores meta in cache for future reads.
91
-	 *
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @var string
95
-	 */
96
-	protected $cache_group = 'getpaid_invoices';
90
+     * Stores meta in cache for future reads.
91
+     *
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @var string
95
+     */
96
+    protected $cache_group = 'getpaid_invoices';
97 97
 
98 98
     /**
99 99
      * Stores a reference to the original WP_Post object
@@ -107,104 +107,104 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @var int
109 109
      */
110
-	protected $recurring_item = null;
110
+    protected $recurring_item = null;
111 111
 
112
-	/**
112
+    /**
113 113
      * Stores an array of item totals.
114
-	 *
115
-	 * e.g $totals['discount'] = array(
116
-	 * 		'initial'   => 10,
117
-	 * 		'recurring' => 10,
118
-	 * )
114
+     *
115
+     * e.g $totals['discount'] = array(
116
+     * 		'initial'   => 10,
117
+     * 		'recurring' => 10,
118
+     * )
119 119
      *
120 120
      * @var array
121 121
      */
122
-	protected $totals = array();
122
+    protected $totals = array();
123 123
 
124
-	/**
125
-	 * Stores the status transition information.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @var bool
129
-	 */
130
-	protected $status_transition = false;
124
+    /**
125
+     * Stores the status transition information.
126
+     *
127
+     * @since 1.0.19
128
+     * @var bool
129
+     */
130
+    protected $status_transition = false;
131 131
 
132 132
     /**
133
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
-	 *
135
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
-	 */
133
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
+     *
135
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
+     */
137 137
     public function __construct( $invoice = false ) {
138 138
 
139 139
         parent::__construct( $invoice );
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
149
-
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
152
-			}
153
-
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
162
-		}
141
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
+            $this->set_id( $invoice );
143
+        } elseif ( $invoice instanceof self ) {
144
+            $this->set_id( $invoice->get_id() );
145
+        } elseif ( ! empty( $invoice->ID ) ) {
146
+            $this->set_id( $invoice->ID );
147
+        } elseif ( is_array( $invoice ) ) {
148
+            $this->set_props( $invoice );
149
+
150
+            if ( isset( $invoice['ID'] ) ) {
151
+                $this->set_id( $invoice['ID'] );
152
+            }
153
+
154
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
+            $this->set_id( $invoice_id );
156
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
+            $this->set_id( $invoice_id );
158
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
+            $this->set_id( $invoice_id );
160
+        }else {
161
+            $this->set_object_read( true );
162
+        }
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166 166
 
167
-		if ( $this->get_id() > 0 ) {
167
+        if ( $this->get_id() > 0 ) {
168 168
             $this->post = get_post( $this->get_id() );
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+            $this->data_store->read( $this );
171 171
         }
172 172
 
173 173
     }
174 174
 
175 175
     /**
176
-	 * Given an invoice key/number, it returns its id.
177
-	 *
178
-	 *
179
-	 * @static
180
-	 * @param string $value The invoice key or number
181
-	 * @param string $field Either key, transaction_id or number.
182
-	 * @since 1.0.15
183
-	 * @return int
184
-	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
176
+     * Given an invoice key/number, it returns its id.
177
+     *
178
+     *
179
+     * @static
180
+     * @param string $value The invoice key or number
181
+     * @param string $field Either key, transaction_id or number.
182
+     * @since 1.0.15
183
+     * @return int
184
+     */
185
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186 186
         global $wpdb;
187 187
 
188
-		// Trim the value.
189
-		$value = trim( $value );
188
+        // Trim the value.
189
+        $value = trim( $value );
190 190
 
191
-		if ( empty( $value ) ) {
192
-			return 0;
193
-		}
191
+        if ( empty( $value ) ) {
192
+            return 0;
193
+        }
194 194
 
195 195
         // Valid fields.
196 196
         $fields = array( 'key', 'number', 'transaction_id' );
197 197
 
198
-		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
-			return 0;
201
-		}
198
+        // Ensure a field has been passed.
199
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+            return 0;
201
+        }
202 202
 
203
-		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
206
-			return $invoice_id;
207
-		}
203
+        // Maybe retrieve from the cache.
204
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
+        if ( false !== $invoice_id ) {
206
+            return $invoice_id;
207
+        }
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213 213
         );
214 214
 
215
-		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        // Update the cache with our data
216
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217 217
 
218
-		return $invoice_id;
218
+        return $invoice_id;
219 219
     }
220 220
 
221 221
     /**
@@ -241,80 +241,80 @@  discard block
 block discarded – undo
241 241
     */
242 242
 
243 243
     /**
244
-	 * Get parent invoice ID.
245
-	 *
246
-	 * @since 1.0.19
247
-	 * @param  string $context View or edit context.
248
-	 * @return int
249
-	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
244
+     * Get parent invoice ID.
245
+     *
246
+     * @since 1.0.19
247
+     * @param  string $context View or edit context.
248
+     * @return int
249
+     */
250
+    public function get_parent_id( $context = 'view' ) {
251
+        return (int) $this->get_prop( 'parent_id', $context );
252 252
     }
253 253
 
254 254
     /**
255
-	 * Get parent invoice.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @return WPInv_Invoice
259
-	 */
255
+     * Get parent invoice.
256
+     *
257
+     * @since 1.0.19
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment() {
261 261
         return new WPInv_Invoice( $this->get_parent_id() );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Alias for self::get_parent_payment().
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Alias for self::get_parent_payment().
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent() {
271 271
         return $this->get_parent_payment();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Get invoice status.
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @param  string $context View or edit context.
279
-	 * @return string
280
-	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
283
-	}
275
+     * Get invoice status.
276
+     *
277
+     * @since 1.0.19
278
+     * @param  string $context View or edit context.
279
+     * @return string
280
+     */
281
+    public function get_status( $context = 'view' ) {
282
+        return $this->get_prop( 'status', $context );
283
+    }
284 284
 	
285
-	/**
286
-	 * Retrieves an array of possible invoice statuses.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @return array
290
-	 */
291
-	public function get_all_statuses() {
292
-
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
294
-
295
-		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
285
+    /**
286
+     * Retrieves an array of possible invoice statuses.
287
+     *
288
+     * @since 1.0.19
289
+     * @return array
290
+     */
291
+    public function get_all_statuses() {
292
+
293
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
294
+
295
+        // For backwards compatibility.
296
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298
-		}
298
+        }
299 299
 
300
-		return $statuses;
300
+        return $statuses;
301 301
     }
302 302
 
303 303
     /**
304
-	 * Get invoice status nice name.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return string
308
-	 */
304
+     * Get invoice status nice name.
305
+     *
306
+     * @since 1.0.19
307
+     * @return string
308
+     */
309 309
     public function get_status_nicename() {
310
-		$statuses = $this->get_all_statuses();
310
+        $statuses = $this->get_all_statuses();
311 311
 
312 312
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313 313
 
314 314
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315 315
     }
316 316
 
317
-	/**
317
+    /**
318 318
      * Retrieves the invoice status label html
319 319
      *
320 320
      * @since  1.0.0
@@ -322,262 +322,262 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
326
+        $status       = sanitize_html_class( $this->get_status() );
327 327
 
328
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
-	}
328
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
+    }
330 330
 
331 331
     /**
332
-	 * Get plugin version when the invoice was created.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  string $context View or edit context.
336
-	 * @return string
337
-	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
340
-	}
332
+     * Get plugin version when the invoice was created.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  string $context View or edit context.
336
+     * @return string
337
+     */
338
+    public function get_version( $context = 'view' ) {
339
+        return $this->get_prop( 'version', $context );
340
+    }
341 341
 
342
-	/**
343
-	 * @deprecated
344
-	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
342
+    /**
343
+     * @deprecated
344
+     */
345
+    public function get_invoice_date( $format = true ) {
346
+        $date      = getpaid_format_date( $this->get_date_completed() );
347
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
+        $formatted = getpaid_format_date( $date );
349 349
 
350
-		if ( $format ) {
351
-			return $formatted;
352
-		}
350
+        if ( $format ) {
351
+            return $formatted;
352
+        }
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+        return empty( $formatted ) ? '' : $date;
355 355
 
356 356
     }
357 357
 
358 358
     /**
359
-	 * Get date when the invoice was created.
360
-	 *
361
-	 * @since 1.0.19
362
-	 * @param  string $context View or edit context.
363
-	 * @return string
364
-	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
367
-	}
359
+     * Get date when the invoice was created.
360
+     *
361
+     * @since 1.0.19
362
+     * @param  string $context View or edit context.
363
+     * @return string
364
+     */
365
+    public function get_date_created( $context = 'view' ) {
366
+        return $this->get_prop( 'date_created', $context );
367
+    }
368 368
 	
369
-	/**
370
-	 * Alias for self::get_date_created().
371
-	 *
372
-	 * @since 1.0.19
373
-	 * @param  string $context View or edit context.
374
-	 * @return string
375
-	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
378
-    }
379
-
380
-    /**
381
-	 * Get GMT date when the invoice was created.
382
-	 *
383
-	 * @since 1.0.19
384
-	 * @param  string $context View or edit context.
385
-	 * @return string
386
-	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
369
+    /**
370
+     * Alias for self::get_date_created().
371
+     *
372
+     * @since 1.0.19
373
+     * @param  string $context View or edit context.
374
+     * @return string
375
+     */
376
+    public function get_created_date( $context = 'view' ) {
377
+        return $this->get_date_created( $context );
378
+    }
379
+
380
+    /**
381
+     * Get GMT date when the invoice was created.
382
+     *
383
+     * @since 1.0.19
384
+     * @param  string $context View or edit context.
385
+     * @return string
386
+     */
387
+    public function get_date_created_gmt( $context = 'view' ) {
388 388
         $date = $this->get_date_created( $context );
389 389
 
390 390
         if ( $date ) {
391 391
             $date = get_gmt_from_date( $date );
392 392
         }
393
-		return $date;
393
+        return $date;
394 394
     }
395 395
 
396 396
     /**
397
-	 * Get date when the invoice was last modified.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
405
-	}
397
+     * Get date when the invoice was last modified.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_modified( $context = 'view' ) {
404
+        return $this->get_prop( 'date_modified', $context );
405
+    }
406 406
 
407
-	/**
408
-	 * Alias for self::get_date_modified().
409
-	 *
410
-	 * @since 1.0.19
411
-	 * @param  string $context View or edit context.
412
-	 * @return string
413
-	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
407
+    /**
408
+     * Alias for self::get_date_modified().
409
+     *
410
+     * @since 1.0.19
411
+     * @param  string $context View or edit context.
412
+     * @return string
413
+     */
414
+    public function get_modified_date( $context = 'view' ) {
415
+        return $this->get_date_modified( $context );
416 416
     }
417 417
 
418 418
     /**
419
-	 * Get GMT date when the invoice was last modified.
420
-	 *
421
-	 * @since 1.0.19
422
-	 * @param  string $context View or edit context.
423
-	 * @return string
424
-	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
419
+     * Get GMT date when the invoice was last modified.
420
+     *
421
+     * @since 1.0.19
422
+     * @param  string $context View or edit context.
423
+     * @return string
424
+     */
425
+    public function get_date_modified_gmt( $context = 'view' ) {
426 426
         $date = $this->get_date_modified( $context );
427 427
 
428 428
         if ( $date ) {
429 429
             $date = get_gmt_from_date( $date );
430 430
         }
431
-		return $date;
431
+        return $date;
432 432
     }
433 433
 
434 434
     /**
435
-	 * Get the invoice due date.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return string
440
-	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
435
+     * Get the invoice due date.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return string
440
+     */
441
+    public function get_due_date( $context = 'view' ) {
442
+        return $this->get_prop( 'due_date', $context );
443 443
     }
444 444
 
445 445
     /**
446
-	 * Alias for self::get_due_date().
447
-	 *
448
-	 * @since 1.0.19
449
-	 * @param  string $context View or edit context.
450
-	 * @return string
451
-	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
446
+     * Alias for self::get_due_date().
447
+     *
448
+     * @since 1.0.19
449
+     * @param  string $context View or edit context.
450
+     * @return string
451
+     */
452
+    public function get_date_due( $context = 'view' ) {
453
+        return $this->get_due_date( $context );
454 454
     }
455 455
 
456 456
     /**
457
-	 * Get the invoice GMT due date.
458
-	 *
459
-	 * @since 1.0.19
460
-	 * @param  string $context View or edit context.
461
-	 * @return string
462
-	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
457
+     * Get the invoice GMT due date.
458
+     *
459
+     * @since 1.0.19
460
+     * @param  string $context View or edit context.
461
+     * @return string
462
+     */
463
+    public function get_due_date_gmt( $context = 'view' ) {
464 464
         $date = $this->get_due_date( $context );
465 465
 
466 466
         if ( $date ) {
467 467
             $date = get_gmt_from_date( $date );
468 468
         }
469
-		return $date;
469
+        return $date;
470 470
     }
471 471
 
472 472
     /**
473
-	 * Alias for self::get_due_date_gmt().
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
473
+     * Alias for self::get_due_date_gmt().
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479
+    public function get_gmt_date_due( $context = 'view' ) {
480
+        return $this->get_due_date_gmt( $context );
481 481
     }
482 482
 
483 483
     /**
484
-	 * Get date when the invoice was completed.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @param  string $context View or edit context.
488
-	 * @return string
489
-	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
484
+     * Get date when the invoice was completed.
485
+     *
486
+     * @since 1.0.19
487
+     * @param  string $context View or edit context.
488
+     * @return string
489
+     */
490
+    public function get_completed_date( $context = 'view' ) {
491
+        return $this->get_prop( 'completed_date', $context );
492 492
     }
493 493
 
494 494
     /**
495
-	 * Alias for self::get_completed_date().
496
-	 *
497
-	 * @since 1.0.19
498
-	 * @param  string $context View or edit context.
499
-	 * @return string
500
-	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
495
+     * Alias for self::get_completed_date().
496
+     *
497
+     * @since 1.0.19
498
+     * @param  string $context View or edit context.
499
+     * @return string
500
+     */
501
+    public function get_date_completed( $context = 'view' ) {
502
+        return $this->get_completed_date( $context );
503 503
     }
504 504
 
505 505
     /**
506
-	 * Get GMT date when the invoice was was completed.
507
-	 *
508
-	 * @since 1.0.19
509
-	 * @param  string $context View or edit context.
510
-	 * @return string
511
-	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
506
+     * Get GMT date when the invoice was was completed.
507
+     *
508
+     * @since 1.0.19
509
+     * @param  string $context View or edit context.
510
+     * @return string
511
+     */
512
+    public function get_completed_date_gmt( $context = 'view' ) {
513 513
         $date = $this->get_completed_date( $context );
514 514
 
515 515
         if ( $date ) {
516 516
             $date = get_gmt_from_date( $date );
517 517
         }
518
-		return $date;
518
+        return $date;
519 519
     }
520 520
 
521 521
     /**
522
-	 * Alias for self::get_completed_date_gmt().
523
-	 *
524
-	 * @since 1.0.19
525
-	 * @param  string $context View or edit context.
526
-	 * @return string
527
-	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
522
+     * Alias for self::get_completed_date_gmt().
523
+     *
524
+     * @since 1.0.19
525
+     * @param  string $context View or edit context.
526
+     * @return string
527
+     */
528
+    public function get_gmt_completed_date( $context = 'view' ) {
529
+        return $this->get_completed_date_gmt( $context );
530 530
     }
531 531
 
532 532
     /**
533
-	 * Get the invoice number.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param  string $context View or edit context.
537
-	 * @return string
538
-	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
533
+     * Get the invoice number.
534
+     *
535
+     * @since 1.0.19
536
+     * @param  string $context View or edit context.
537
+     * @return string
538
+     */
539
+    public function get_number( $context = 'view' ) {
540
+        $number = $this->get_prop( 'number', $context );
541 541
 
542
-		if ( empty( $number ) ) {
543
-			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
545
-		}
542
+        if ( empty( $number ) ) {
543
+            $number = $this->generate_number();
544
+            $this->set_number( $this->generate_number() );
545
+        }
546 546
 
547
-		return $number;
547
+        return $number;
548 548
     }
549 549
 
550
-	/**
551
-	 * Set the invoice number.
552
-	 *
553
-	 * @since 1.0.19
554
-	 */
555
-	public function maybe_set_number() {
550
+    /**
551
+     * Set the invoice number.
552
+     *
553
+     * @since 1.0.19
554
+     */
555
+    public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558 558
         if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
559
+            $this->set_number( $this->generate_number() );
560 560
         }
561 561
 
562
-	}
562
+    }
563 563
 
564 564
     /**
565
-	 * Get the invoice key.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $context View or edit context.
569
-	 * @return string
570
-	 */
571
-	public function get_key( $context = 'view' ) {
565
+     * Get the invoice key.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $context View or edit context.
569
+     * @return string
570
+     */
571
+    public function get_key( $context = 'view' ) {
572 572
         return $this->get_prop( 'key', $context );
573
-	}
574
-
575
-	/**
576
-	 * Set the invoice key.
577
-	 *
578
-	 * @since 1.0.19
579
-	 */
580
-	public function maybe_set_key() {
573
+    }
574
+
575
+    /**
576
+     * Set the invoice key.
577
+     *
578
+     * @since 1.0.19
579
+     */
580
+    public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583 583
         if ( empty( $key ) ) {
@@ -588,126 +588,126 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_type( $context = 'view' ) {
591
+     * Get the invoice type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'type', $context );
599
-	}
599
+    }
600 600
 
601
-	/**
602
-	 * @deprecated
603
-	 */
604
-	public function get_invoice_quote_type() {
601
+    /**
602
+     * @deprecated
603
+     */
604
+    public function get_invoice_quote_type() {
605 605
         ucfirst( $this->get_type() );
606 606
     }
607 607
 
608 608
     /**
609
-	 * Get the invoice post type.
610
-	 *
611
-	 * @since 1.0.19
612
-	 * @param  string $context View or edit context.
613
-	 * @return string
614
-	 */
615
-	public function get_post_type( $context = 'view' ) {
609
+     * Get the invoice post type.
610
+     *
611
+     * @since 1.0.19
612
+     * @param  string $context View or edit context.
613
+     * @return string
614
+     */
615
+    public function get_post_type( $context = 'view' ) {
616 616
         return $this->get_prop( 'post_type', $context );
617 617
     }
618 618
 
619 619
     /**
620
-	 * Get the invoice mode.
621
-	 *
622
-	 * @since 1.0.19
623
-	 * @param  string $context View or edit context.
624
-	 * @return string
625
-	 */
626
-	public function get_mode( $context = 'view' ) {
620
+     * Get the invoice mode.
621
+     *
622
+     * @since 1.0.19
623
+     * @param  string $context View or edit context.
624
+     * @return string
625
+     */
626
+    public function get_mode( $context = 'view' ) {
627 627
         return $this->get_prop( 'mode', $context );
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice path.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_path( $context = 'view' ) {
631
+     * Get the invoice path.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_path( $context = 'view' ) {
638 638
         $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
639
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
644
-		}
641
+        if ( 0 !== strpos( $path, $prefix ) ) {
642
+            $path = sanitize_title(  $prefix . $this->get_id()  );
643
+            $this->set_path( $path );
644
+        }
645 645
 
646
-		return $path;
646
+        return $path;
647 647
     }
648 648
 
649 649
     /**
650
-	 * Get the invoice name/title.
651
-	 *
652
-	 * @since 1.0.19
653
-	 * @param  string $context View or edit context.
654
-	 * @return string
655
-	 */
656
-	public function get_name( $context = 'view' ) {
650
+     * Get the invoice name/title.
651
+     *
652
+     * @since 1.0.19
653
+     * @param  string $context View or edit context.
654
+     * @return string
655
+     */
656
+    public function get_name( $context = 'view' ) {
657 657
         return $this->get_prop( 'title', $context );
658 658
     }
659 659
 
660 660
     /**
661
-	 * Alias of self::get_name().
662
-	 *
663
-	 * @since 1.0.19
664
-	 * @param  string $context View or edit context.
665
-	 * @return string
666
-	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
661
+     * Alias of self::get_name().
662
+     *
663
+     * @since 1.0.19
664
+     * @param  string $context View or edit context.
665
+     * @return string
666
+     */
667
+    public function get_title( $context = 'view' ) {
668
+        return $this->get_name( $context );
669 669
     }
670 670
 
671 671
     /**
672
-	 * Get the invoice description.
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param  string $context View or edit context.
676
-	 * @return string
677
-	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
672
+     * Get the invoice description.
673
+     *
674
+     * @since 1.0.19
675
+     * @param  string $context View or edit context.
676
+     * @return string
677
+     */
678
+    public function get_description( $context = 'view' ) {
679
+        return $this->get_prop( 'description', $context );
680 680
     }
681 681
 
682 682
     /**
683
-	 * Alias of self::get_description().
684
-	 *
685
-	 * @since 1.0.19
686
-	 * @param  string $context View or edit context.
687
-	 * @return string
688
-	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
683
+     * Alias of self::get_description().
684
+     *
685
+     * @since 1.0.19
686
+     * @param  string $context View or edit context.
687
+     * @return string
688
+     */
689
+    public function get_excerpt( $context = 'view' ) {
690
+        return $this->get_description( $context );
691 691
     }
692 692
 
693 693
     /**
694
-	 * Alias of self::get_description().
695
-	 *
696
-	 * @since 1.0.19
697
-	 * @param  string $context View or edit context.
698
-	 * @return string
699
-	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
694
+     * Alias of self::get_description().
695
+     *
696
+     * @since 1.0.19
697
+     * @param  string $context View or edit context.
698
+     * @return string
699
+     */
700
+    public function get_summary( $context = 'view' ) {
701
+        return $this->get_description( $context );
702 702
     }
703 703
 
704 704
     /**
705
-	 * Returns the user info.
706
-	 *
707
-	 * @since 1.0.19
705
+     * Returns the user info.
706
+     *
707
+     * @since 1.0.19
708 708
      * @param  string $context View or edit context.
709
-	 * @return array
710
-	 */
709
+     * @return array
710
+     */
711 711
     public function get_user_info( $context = 'view' ) {
712 712
 
713 713
         $user_info = array(
@@ -724,605 +724,605 @@  discard block
 block discarded – undo
724 724
             'company'    => $this->get_company( $context ),
725 725
             'vat_number' => $this->get_vat_number( $context ),
726 726
             'discount'   => $this->get_discount_code( $context ),
727
-		);
727
+        );
728
+
729
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
730
+
731
+    }
732
+
733
+    /**
734
+     * Get the customer id.
735
+     *
736
+     * @since 1.0.19
737
+     * @param  string $context View or edit context.
738
+     * @return int
739
+     */
740
+    public function get_author( $context = 'view' ) {
741
+        return (int) $this->get_prop( 'author', $context );
742
+    }
728 743
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
744
+    /**
745
+     * Alias of self::get_author().
746
+     *
747
+     * @since 1.0.19
748
+     * @param  string $context View or edit context.
749
+     * @return int
750
+     */
751
+    public function get_user_id( $context = 'view' ) {
752
+        return $this->get_author( $context );
753
+    }
730 754
 
755
+        /**
756
+         * Alias of self::get_author().
757
+         *
758
+         * @since 1.0.19
759
+         * @param  string $context View or edit context.
760
+         * @return int
761
+         */
762
+    public function get_customer_id( $context = 'view' ) {
763
+        return $this->get_author( $context );
731 764
     }
732 765
 
733 766
     /**
734
-	 * Get the customer id.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @param  string $context View or edit context.
738
-	 * @return int
739
-	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
767
+     * Get the customer's ip.
768
+     *
769
+     * @since 1.0.19
770
+     * @param  string $context View or edit context.
771
+     * @return string
772
+     */
773
+    public function get_ip( $context = 'view' ) {
774
+        return $this->get_prop( 'user_ip', $context );
742 775
     }
743 776
 
744 777
     /**
745
-	 * Alias of self::get_author().
746
-	 *
747
-	 * @since 1.0.19
748
-	 * @param  string $context View or edit context.
749
-	 * @return int
750
-	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
778
+     * Alias of self::get_ip().
779
+     *
780
+     * @since 1.0.19
781
+     * @param  string $context View or edit context.
782
+     * @return string
783
+     */
784
+    public function get_user_ip( $context = 'view' ) {
785
+        return $this->get_ip( $context );
753 786
     }
754 787
 
755
-     /**
756
-	 * Alias of self::get_author().
757
-	 *
758
-	 * @since 1.0.19
759
-	 * @param  string $context View or edit context.
760
-	 * @return int
761
-	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
788
+        /**
789
+         * Alias of self::get_ip().
790
+         *
791
+         * @since 1.0.19
792
+         * @param  string $context View or edit context.
793
+         * @return string
794
+         */
795
+    public function get_customer_ip( $context = 'view' ) {
796
+        return $this->get_ip( $context );
764 797
     }
765 798
 
766 799
     /**
767
-	 * Get the customer's ip.
768
-	 *
769
-	 * @since 1.0.19
770
-	 * @param  string $context View or edit context.
771
-	 * @return string
772
-	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
800
+     * Get the customer's first name.
801
+     *
802
+     * @since 1.0.19
803
+     * @param  string $context View or edit context.
804
+     * @return string
805
+     */
806
+    public function get_first_name( $context = 'view' ) {
807
+        return $this->get_prop( 'first_name', $context );
775 808
     }
776 809
 
777 810
     /**
778
-	 * Alias of self::get_ip().
779
-	 *
780
-	 * @since 1.0.19
781
-	 * @param  string $context View or edit context.
782
-	 * @return string
783
-	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
811
+     * Alias of self::get_first_name().
812
+     *
813
+     * @since 1.0.19
814
+     * @param  string $context View or edit context.
815
+     * @return int
816
+     */
817
+    public function get_user_first_name( $context = 'view' ) {
818
+        return $this->get_first_name( $context );
786 819
     }
787 820
 
788
-     /**
789
-	 * Alias of self::get_ip().
790
-	 *
791
-	 * @since 1.0.19
792
-	 * @param  string $context View or edit context.
793
-	 * @return string
794
-	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
821
+        /**
822
+         * Alias of self::get_first_name().
823
+         *
824
+         * @since 1.0.19
825
+         * @param  string $context View or edit context.
826
+         * @return int
827
+         */
828
+    public function get_customer_first_name( $context = 'view' ) {
829
+        return $this->get_first_name( $context );
797 830
     }
798 831
 
799 832
     /**
800
-	 * Get the customer's first name.
801
-	 *
802
-	 * @since 1.0.19
803
-	 * @param  string $context View or edit context.
804
-	 * @return string
805
-	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
833
+     * Get the customer's last name.
834
+     *
835
+     * @since 1.0.19
836
+     * @param  string $context View or edit context.
837
+     * @return string
838
+     */
839
+    public function get_last_name( $context = 'view' ) {
840
+        return $this->get_prop( 'last_name', $context );
808 841
     }
809 842
 
810 843
     /**
811
-	 * Alias of self::get_first_name().
812
-	 *
813
-	 * @since 1.0.19
814
-	 * @param  string $context View or edit context.
815
-	 * @return int
816
-	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
844
+     * Alias of self::get_last_name().
845
+     *
846
+     * @since 1.0.19
847
+     * @param  string $context View or edit context.
848
+     * @return int
849
+     */
850
+    public function get_user_last_name( $context = 'view' ) {
851
+        return $this->get_last_name( $context );
819 852
     }
820 853
 
821
-     /**
822
-	 * Alias of self::get_first_name().
823
-	 *
824
-	 * @since 1.0.19
825
-	 * @param  string $context View or edit context.
826
-	 * @return int
827
-	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
854
+    /**
855
+     * Alias of self::get_last_name().
856
+     *
857
+     * @since 1.0.19
858
+     * @param  string $context View or edit context.
859
+     * @return int
860
+     */
861
+    public function get_customer_last_name( $context = 'view' ) {
862
+        return $this->get_last_name( $context );
830 863
     }
831 864
 
832 865
     /**
833
-	 * Get the customer's last name.
834
-	 *
835
-	 * @since 1.0.19
836
-	 * @param  string $context View or edit context.
837
-	 * @return string
838
-	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
866
+     * Get the customer's full name.
867
+     *
868
+     * @since 1.0.19
869
+     * @param  string $context View or edit context.
870
+     * @return string
871
+     */
872
+    public function get_full_name( $context = 'view' ) {
873
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
841 874
     }
842 875
 
843 876
     /**
844
-	 * Alias of self::get_last_name().
845
-	 *
846
-	 * @since 1.0.19
847
-	 * @param  string $context View or edit context.
848
-	 * @return int
849
-	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
877
+     * Alias of self::get_full_name().
878
+     *
879
+     * @since 1.0.19
880
+     * @param  string $context View or edit context.
881
+     * @return int
882
+     */
883
+    public function get_user_full_name( $context = 'view' ) {
884
+        return $this->get_full_name( $context );
852 885
     }
853 886
 
854 887
     /**
855
-	 * Alias of self::get_last_name().
856
-	 *
857
-	 * @since 1.0.19
858
-	 * @param  string $context View or edit context.
859
-	 * @return int
860
-	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
888
+     * Alias of self::get_full_name().
889
+     *
890
+     * @since 1.0.19
891
+     * @param  string $context View or edit context.
892
+     * @return int
893
+     */
894
+    public function get_customer_full_name( $context = 'view' ) {
895
+        return $this->get_full_name( $context );
863 896
     }
864 897
 
865 898
     /**
866
-	 * Get the customer's full name.
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  string $context View or edit context.
870
-	 * @return string
871
-	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
899
+     * Get the customer's phone number.
900
+     *
901
+     * @since 1.0.19
902
+     * @param  string $context View or edit context.
903
+     * @return string
904
+     */
905
+    public function get_phone( $context = 'view' ) {
906
+        return $this->get_prop( 'phone', $context );
874 907
     }
875 908
 
876 909
     /**
877
-	 * Alias of self::get_full_name().
878
-	 *
879
-	 * @since 1.0.19
880
-	 * @param  string $context View or edit context.
881
-	 * @return int
882
-	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
910
+     * Alias of self::get_phone().
911
+     *
912
+     * @since 1.0.19
913
+     * @param  string $context View or edit context.
914
+     * @return int
915
+     */
916
+    public function get_phone_number( $context = 'view' ) {
917
+        return $this->get_phone( $context );
885 918
     }
886 919
 
887 920
     /**
888
-	 * Alias of self::get_full_name().
889
-	 *
890
-	 * @since 1.0.19
891
-	 * @param  string $context View or edit context.
892
-	 * @return int
893
-	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
921
+     * Alias of self::get_phone().
922
+     *
923
+     * @since 1.0.19
924
+     * @param  string $context View or edit context.
925
+     * @return int
926
+     */
927
+    public function get_user_phone( $context = 'view' ) {
928
+        return $this->get_phone( $context );
896 929
     }
897 930
 
898 931
     /**
899
-	 * Get the customer's phone number.
900
-	 *
901
-	 * @since 1.0.19
902
-	 * @param  string $context View or edit context.
903
-	 * @return string
904
-	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
932
+     * Alias of self::get_phone().
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $context View or edit context.
936
+     * @return int
937
+     */
938
+    public function get_customer_phone( $context = 'view' ) {
939
+        return $this->get_phone( $context );
907 940
     }
908 941
 
909 942
     /**
910
-	 * Alias of self::get_phone().
911
-	 *
912
-	 * @since 1.0.19
913
-	 * @param  string $context View or edit context.
914
-	 * @return int
915
-	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
943
+     * Get the customer's email address.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  string $context View or edit context.
947
+     * @return string
948
+     */
949
+    public function get_email( $context = 'view' ) {
950
+        return $this->get_prop( 'email', $context );
918 951
     }
919 952
 
920 953
     /**
921
-	 * Alias of self::get_phone().
922
-	 *
923
-	 * @since 1.0.19
924
-	 * @param  string $context View or edit context.
925
-	 * @return int
926
-	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
954
+     * Alias of self::get_email().
955
+     *
956
+     * @since 1.0.19
957
+     * @param  string $context View or edit context.
958
+     * @return string
959
+     */
960
+    public function get_email_address( $context = 'view' ) {
961
+        return $this->get_email( $context );
929 962
     }
930 963
 
931 964
     /**
932
-	 * Alias of self::get_phone().
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $context View or edit context.
936
-	 * @return int
937
-	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
965
+     * Alias of self::get_email().
966
+     *
967
+     * @since 1.0.19
968
+     * @param  string $context View or edit context.
969
+     * @return int
970
+     */
971
+    public function get_user_email( $context = 'view' ) {
972
+        return $this->get_email( $context );
940 973
     }
941 974
 
942 975
     /**
943
-	 * Get the customer's email address.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  string $context View or edit context.
947
-	 * @return string
948
-	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
976
+     * Alias of self::get_email().
977
+     *
978
+     * @since 1.0.19
979
+     * @param  string $context View or edit context.
980
+     * @return int
981
+     */
982
+    public function get_customer_email( $context = 'view' ) {
983
+        return $this->get_email( $context );
951 984
     }
952 985
 
953 986
     /**
954
-	 * Alias of self::get_email().
955
-	 *
956
-	 * @since 1.0.19
957
-	 * @param  string $context View or edit context.
958
-	 * @return string
959
-	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
987
+     * Get the customer's country.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $context View or edit context.
991
+     * @return string
992
+     */
993
+    public function get_country( $context = 'view' ) {
994
+        $country = $this->get_prop( 'country', $context );
995
+        return empty( $country ) ? wpinv_get_default_country() : $country;
962 996
     }
963 997
 
964 998
     /**
965
-	 * Alias of self::get_email().
966
-	 *
967
-	 * @since 1.0.19
968
-	 * @param  string $context View or edit context.
969
-	 * @return int
970
-	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
999
+     * Alias of self::get_country().
1000
+     *
1001
+     * @since 1.0.19
1002
+     * @param  string $context View or edit context.
1003
+     * @return int
1004
+     */
1005
+    public function get_user_country( $context = 'view' ) {
1006
+        return $this->get_country( $context );
973 1007
     }
974 1008
 
975 1009
     /**
976
-	 * Alias of self::get_email().
977
-	 *
978
-	 * @since 1.0.19
979
-	 * @param  string $context View or edit context.
980
-	 * @return int
981
-	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
1010
+     * Alias of self::get_country().
1011
+     *
1012
+     * @since 1.0.19
1013
+     * @param  string $context View or edit context.
1014
+     * @return int
1015
+     */
1016
+    public function get_customer_country( $context = 'view' ) {
1017
+        return $this->get_country( $context );
984 1018
     }
985 1019
 
986 1020
     /**
987
-	 * Get the customer's country.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $context View or edit context.
991
-	 * @return string
992
-	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1021
+     * Get the customer's state.
1022
+     *
1023
+     * @since 1.0.19
1024
+     * @param  string $context View or edit context.
1025
+     * @return string
1026
+     */
1027
+    public function get_state( $context = 'view' ) {
1028
+        $state = $this->get_prop( 'state', $context );
1029
+        return empty( $state ) ? wpinv_get_default_state() : $state;
996 1030
     }
997 1031
 
998 1032
     /**
999
-	 * Alias of self::get_country().
1000
-	 *
1001
-	 * @since 1.0.19
1002
-	 * @param  string $context View or edit context.
1003
-	 * @return int
1004
-	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
1033
+     * Alias of self::get_state().
1034
+     *
1035
+     * @since 1.0.19
1036
+     * @param  string $context View or edit context.
1037
+     * @return int
1038
+     */
1039
+    public function get_user_state( $context = 'view' ) {
1040
+        return $this->get_state( $context );
1007 1041
     }
1008 1042
 
1009 1043
     /**
1010
-	 * Alias of self::get_country().
1011
-	 *
1012
-	 * @since 1.0.19
1013
-	 * @param  string $context View or edit context.
1014
-	 * @return int
1015
-	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1044
+     * Alias of self::get_state().
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  string $context View or edit context.
1048
+     * @return int
1049
+     */
1050
+    public function get_customer_state( $context = 'view' ) {
1051
+        return $this->get_state( $context );
1018 1052
     }
1019 1053
 
1020 1054
     /**
1021
-	 * Get the customer's state.
1022
-	 *
1023
-	 * @since 1.0.19
1024
-	 * @param  string $context View or edit context.
1025
-	 * @return string
1026
-	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1055
+     * Get the customer's city.
1056
+     *
1057
+     * @since 1.0.19
1058
+     * @param  string $context View or edit context.
1059
+     * @return string
1060
+     */
1061
+    public function get_city( $context = 'view' ) {
1062
+        return $this->get_prop( 'city', $context );
1030 1063
     }
1031 1064
 
1032 1065
     /**
1033
-	 * Alias of self::get_state().
1034
-	 *
1035
-	 * @since 1.0.19
1036
-	 * @param  string $context View or edit context.
1037
-	 * @return int
1038
-	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1066
+     * Alias of self::get_city().
1067
+     *
1068
+     * @since 1.0.19
1069
+     * @param  string $context View or edit context.
1070
+     * @return string
1071
+     */
1072
+    public function get_user_city( $context = 'view' ) {
1073
+        return $this->get_city( $context );
1041 1074
     }
1042 1075
 
1043 1076
     /**
1044
-	 * Alias of self::get_state().
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  string $context View or edit context.
1048
-	 * @return int
1049
-	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1077
+     * Alias of self::get_city().
1078
+     *
1079
+     * @since 1.0.19
1080
+     * @param  string $context View or edit context.
1081
+     * @return string
1082
+     */
1083
+    public function get_customer_city( $context = 'view' ) {
1084
+        return $this->get_city( $context );
1085
+    }
1086
+
1087
+    /**
1088
+     * Get the customer's zip.
1089
+     *
1090
+     * @since 1.0.19
1091
+     * @param  string $context View or edit context.
1092
+     * @return string
1093
+     */
1094
+    public function get_zip( $context = 'view' ) {
1095
+        return $this->get_prop( 'zip', $context );
1096
+    }
1097
+
1098
+    /**
1099
+     * Alias of self::get_zip().
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @param  string $context View or edit context.
1103
+     * @return string
1104
+     */
1105
+    public function get_user_zip( $context = 'view' ) {
1106
+        return $this->get_zip( $context );
1107
+    }
1108
+
1109
+    /**
1110
+     * Alias of self::get_zip().
1111
+     *
1112
+     * @since 1.0.19
1113
+     * @param  string $context View or edit context.
1114
+     * @return string
1115
+     */
1116
+    public function get_customer_zip( $context = 'view' ) {
1117
+        return $this->get_zip( $context );
1052 1118
     }
1053 1119
 
1054 1120
     /**
1055
-	 * Get the customer's city.
1056
-	 *
1057
-	 * @since 1.0.19
1058
-	 * @param  string $context View or edit context.
1059
-	 * @return string
1060
-	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1121
+     * Get the customer's company.
1122
+     *
1123
+     * @since 1.0.19
1124
+     * @param  string $context View or edit context.
1125
+     * @return string
1126
+     */
1127
+    public function get_company( $context = 'view' ) {
1128
+        return $this->get_prop( 'company', $context );
1129
+    }
1130
+
1131
+    /**
1132
+     * Alias of self::get_company().
1133
+     *
1134
+     * @since 1.0.19
1135
+     * @param  string $context View or edit context.
1136
+     * @return string
1137
+     */
1138
+    public function get_user_company( $context = 'view' ) {
1139
+        return $this->get_company( $context );
1140
+    }
1141
+
1142
+    /**
1143
+     * Alias of self::get_company().
1144
+     *
1145
+     * @since 1.0.19
1146
+     * @param  string $context View or edit context.
1147
+     * @return string
1148
+     */
1149
+    public function get_customer_company( $context = 'view' ) {
1150
+        return $this->get_company( $context );
1151
+    }
1152
+
1153
+    /**
1154
+     * Get the customer's vat number.
1155
+     *
1156
+     * @since 1.0.19
1157
+     * @param  string $context View or edit context.
1158
+     * @return string
1159
+     */
1160
+    public function get_vat_number( $context = 'view' ) {
1161
+        return $this->get_prop( 'vat_number', $context );
1063 1162
     }
1064 1163
 
1065 1164
     /**
1066
-	 * Alias of self::get_city().
1067
-	 *
1068
-	 * @since 1.0.19
1069
-	 * @param  string $context View or edit context.
1070
-	 * @return string
1071
-	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1165
+     * Alias of self::get_vat_number().
1166
+     *
1167
+     * @since 1.0.19
1168
+     * @param  string $context View or edit context.
1169
+     * @return string
1170
+     */
1171
+    public function get_user_vat_number( $context = 'view' ) {
1172
+        return $this->get_vat_number( $context );
1074 1173
     }
1075 1174
 
1076 1175
     /**
1077
-	 * Alias of self::get_city().
1078
-	 *
1079
-	 * @since 1.0.19
1080
-	 * @param  string $context View or edit context.
1081
-	 * @return string
1082
-	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1176
+     * Alias of self::get_vat_number().
1177
+     *
1178
+     * @since 1.0.19
1179
+     * @param  string $context View or edit context.
1180
+     * @return string
1181
+     */
1182
+    public function get_customer_vat_number( $context = 'view' ) {
1183
+        return $this->get_vat_number( $context );
1085 1184
     }
1086 1185
 
1087 1186
     /**
1088
-	 * Get the customer's zip.
1089
-	 *
1090
-	 * @since 1.0.19
1091
-	 * @param  string $context View or edit context.
1092
-	 * @return string
1093
-	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1187
+     * Get the customer's vat rate.
1188
+     *
1189
+     * @since 1.0.19
1190
+     * @param  string $context View or edit context.
1191
+     * @return string
1192
+     */
1193
+    public function get_vat_rate( $context = 'view' ) {
1194
+        return $this->get_prop( 'vat_rate', $context );
1096 1195
     }
1097 1196
 
1098 1197
     /**
1099
-	 * Alias of self::get_zip().
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @param  string $context View or edit context.
1103
-	 * @return string
1104
-	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1198
+     * Alias of self::get_vat_rate().
1199
+     *
1200
+     * @since 1.0.19
1201
+     * @param  string $context View or edit context.
1202
+     * @return string
1203
+     */
1204
+    public function get_user_vat_rate( $context = 'view' ) {
1205
+        return $this->get_vat_rate( $context );
1107 1206
     }
1108 1207
 
1109 1208
     /**
1110
-	 * Alias of self::get_zip().
1111
-	 *
1112
-	 * @since 1.0.19
1113
-	 * @param  string $context View or edit context.
1114
-	 * @return string
1115
-	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1209
+     * Alias of self::get_vat_rate().
1210
+     *
1211
+     * @since 1.0.19
1212
+     * @param  string $context View or edit context.
1213
+     * @return string
1214
+     */
1215
+    public function get_customer_vat_rate( $context = 'view' ) {
1216
+        return $this->get_vat_rate( $context );
1118 1217
     }
1119 1218
 
1120 1219
     /**
1121
-	 * Get the customer's company.
1122
-	 *
1123
-	 * @since 1.0.19
1124
-	 * @param  string $context View or edit context.
1125
-	 * @return string
1126
-	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1220
+     * Get the customer's address.
1221
+     *
1222
+     * @since 1.0.19
1223
+     * @param  string $context View or edit context.
1224
+     * @return string
1225
+     */
1226
+    public function get_address( $context = 'view' ) {
1227
+        return $this->get_prop( 'address', $context );
1129 1228
     }
1130 1229
 
1131 1230
     /**
1132
-	 * Alias of self::get_company().
1133
-	 *
1134
-	 * @since 1.0.19
1135
-	 * @param  string $context View or edit context.
1136
-	 * @return string
1137
-	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1231
+     * Alias of self::get_address().
1232
+     *
1233
+     * @since 1.0.19
1234
+     * @param  string $context View or edit context.
1235
+     * @return string
1236
+     */
1237
+    public function get_user_address( $context = 'view' ) {
1238
+        return $this->get_address( $context );
1140 1239
     }
1141 1240
 
1142 1241
     /**
1143
-	 * Alias of self::get_company().
1144
-	 *
1145
-	 * @since 1.0.19
1146
-	 * @param  string $context View or edit context.
1147
-	 * @return string
1148
-	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1242
+     * Alias of self::get_address().
1243
+     *
1244
+     * @since 1.0.19
1245
+     * @param  string $context View or edit context.
1246
+     * @return string
1247
+     */
1248
+    public function get_customer_address( $context = 'view' ) {
1249
+        return $this->get_address( $context );
1151 1250
     }
1152 1251
 
1153 1252
     /**
1154
-	 * Get the customer's vat number.
1155
-	 *
1156
-	 * @since 1.0.19
1157
-	 * @param  string $context View or edit context.
1158
-	 * @return string
1159
-	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1253
+     * Get whether the customer has viewed the invoice or not.
1254
+     *
1255
+     * @since 1.0.19
1256
+     * @param  string $context View or edit context.
1257
+     * @return bool
1258
+     */
1259
+    public function get_is_viewed( $context = 'view' ) {
1260
+        return (bool) $this->get_prop( 'is_viewed', $context );
1162 1261
     }
1163 1262
 
1164 1263
     /**
1165
-	 * Alias of self::get_vat_number().
1166
-	 *
1167
-	 * @since 1.0.19
1168
-	 * @param  string $context View or edit context.
1169
-	 * @return string
1170
-	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1264
+     * Get other recipients for invoice communications.
1265
+     *
1266
+     * @since 1.0.19
1267
+     * @param  string $context View or edit context.
1268
+     * @return bool
1269
+     */
1270
+    public function get_email_cc( $context = 'view' ) {
1271
+        return $this->get_prop( 'email_cc', $context );
1173 1272
     }
1174 1273
 
1175 1274
     /**
1176
-	 * Alias of self::get_vat_number().
1177
-	 *
1178
-	 * @since 1.0.19
1179
-	 * @param  string $context View or edit context.
1180
-	 * @return string
1181
-	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1275
+     * Get invoice template.
1276
+     *
1277
+     * @since 1.0.19
1278
+     * @param  string $context View or edit context.
1279
+     * @return bool
1280
+     */
1281
+    public function get_template( $context = 'view' ) {
1282
+        return $this->get_prop( 'template', $context );
1184 1283
     }
1185 1284
 
1186 1285
     /**
1187
-	 * Get the customer's vat rate.
1188
-	 *
1189
-	 * @since 1.0.19
1190
-	 * @param  string $context View or edit context.
1191
-	 * @return string
1192
-	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1286
+     * Get whether the customer has confirmed their address.
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @param  string $context View or edit context.
1290
+     * @return bool
1291
+     */
1292
+    public function get_address_confirmed( $context = 'view' ) {
1293
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1195 1294
     }
1196 1295
 
1197 1296
     /**
1198
-	 * Alias of self::get_vat_rate().
1199
-	 *
1200
-	 * @since 1.0.19
1201
-	 * @param  string $context View or edit context.
1202
-	 * @return string
1203
-	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1297
+     * Alias of self::get_address_confirmed().
1298
+     *
1299
+     * @since 1.0.19
1300
+     * @param  string $context View or edit context.
1301
+     * @return bool
1302
+     */
1303
+    public function get_user_address_confirmed( $context = 'view' ) {
1304
+        return $this->get_address_confirmed( $context );
1206 1305
     }
1207 1306
 
1208 1307
     /**
1209
-	 * Alias of self::get_vat_rate().
1210
-	 *
1211
-	 * @since 1.0.19
1212
-	 * @param  string $context View or edit context.
1213
-	 * @return string
1214
-	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1308
+     * Alias of self::get_address().
1309
+     *
1310
+     * @since 1.0.19
1311
+     * @param  string $context View or edit context.
1312
+     * @return bool
1313
+     */
1314
+    public function get_customer_address_confirmed( $context = 'view' ) {
1315
+        return $this->get_address_confirmed( $context );
1217 1316
     }
1218 1317
 
1219 1318
     /**
1220
-	 * Get the customer's address.
1221
-	 *
1222
-	 * @since 1.0.19
1223
-	 * @param  string $context View or edit context.
1224
-	 * @return string
1225
-	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1228
-    }
1229
-
1230
-    /**
1231
-	 * Alias of self::get_address().
1232
-	 *
1233
-	 * @since 1.0.19
1234
-	 * @param  string $context View or edit context.
1235
-	 * @return string
1236
-	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1239
-    }
1240
-
1241
-    /**
1242
-	 * Alias of self::get_address().
1243
-	 *
1244
-	 * @since 1.0.19
1245
-	 * @param  string $context View or edit context.
1246
-	 * @return string
1247
-	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1250
-    }
1251
-
1252
-    /**
1253
-	 * Get whether the customer has viewed the invoice or not.
1254
-	 *
1255
-	 * @since 1.0.19
1256
-	 * @param  string $context View or edit context.
1257
-	 * @return bool
1258
-	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1261
-	}
1262
-
1263
-	/**
1264
-	 * Get other recipients for invoice communications.
1265
-	 *
1266
-	 * @since 1.0.19
1267
-	 * @param  string $context View or edit context.
1268
-	 * @return bool
1269
-	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1272
-	}
1273
-
1274
-	/**
1275
-	 * Get invoice template.
1276
-	 *
1277
-	 * @since 1.0.19
1278
-	 * @param  string $context View or edit context.
1279
-	 * @return bool
1280
-	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1283
-	}
1284
-
1285
-	/**
1286
-	 * Get whether the customer has confirmed their address.
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @param  string $context View or edit context.
1290
-	 * @return bool
1291
-	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1294
-    }
1295
-
1296
-    /**
1297
-	 * Alias of self::get_address_confirmed().
1298
-	 *
1299
-	 * @since 1.0.19
1300
-	 * @param  string $context View or edit context.
1301
-	 * @return bool
1302
-	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1305
-    }
1306
-
1307
-    /**
1308
-	 * Alias of self::get_address().
1309
-	 *
1310
-	 * @since 1.0.19
1311
-	 * @param  string $context View or edit context.
1312
-	 * @return bool
1313
-	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1316
-    }
1317
-
1318
-    /**
1319
-	 * Get the invoice subtotal.
1320
-	 *
1321
-	 * @since 1.0.19
1322
-	 * @param  string $context View or edit context.
1323
-	 * @return float
1324
-	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1319
+     * Get the invoice subtotal.
1320
+     *
1321
+     * @since 1.0.19
1322
+     * @param  string $context View or edit context.
1323
+     * @return float
1324
+     */
1325
+    public function get_subtotal( $context = 'view' ) {
1326 1326
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1327 1327
 
1328 1328
         // Backwards compatibility.
@@ -1334,165 +1334,165 @@  discard block
 block discarded – undo
1334 1334
     }
1335 1335
 
1336 1336
     /**
1337
-	 * Get the invoice discount total.
1338
-	 *
1339
-	 * @since 1.0.19
1340
-	 * @param  string $context View or edit context.
1341
-	 * @return float
1342
-	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1337
+     * Get the invoice discount total.
1338
+     *
1339
+     * @since 1.0.19
1340
+     * @param  string $context View or edit context.
1341
+     * @return float
1342
+     */
1343
+    public function get_total_discount( $context = 'view' ) {
1344
+        return (float) $this->get_prop( 'total_discount', $context );
1345 1345
     }
1346 1346
 
1347 1347
     /**
1348
-	 * Get the invoice tax total.
1349
-	 *
1350
-	 * @since 1.0.19
1351
-	 * @param  string $context View or edit context.
1352
-	 * @return float
1353
-	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1356
-	}
1348
+     * Get the invoice tax total.
1349
+     *
1350
+     * @since 1.0.19
1351
+     * @param  string $context View or edit context.
1352
+     * @return float
1353
+     */
1354
+    public function get_total_tax( $context = 'view' ) {
1355
+        return (float) $this->get_prop( 'total_tax', $context );
1356
+    }
1357 1357
 
1358
-	/**
1359
-	 * @deprecated
1360
-	 */
1361
-	public function get_final_tax( $currency = false ) {
1362
-		$tax = $this->get_total_tax();
1358
+    /**
1359
+     * @deprecated
1360
+     */
1361
+    public function get_final_tax( $currency = false ) {
1362
+        $tax = $this->get_total_tax();
1363 1363
 
1364 1364
         if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1365
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
1369 1369
     }
1370 1370
 
1371 1371
     /**
1372
-	 * Get the invoice fees total.
1373
-	 *
1374
-	 * @since 1.0.19
1375
-	 * @param  string $context View or edit context.
1376
-	 * @return float
1377
-	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1372
+     * Get the invoice fees total.
1373
+     *
1374
+     * @since 1.0.19
1375
+     * @param  string $context View or edit context.
1376
+     * @return float
1377
+     */
1378
+    public function get_total_fees( $context = 'view' ) {
1379
+        return (float) $this->get_prop( 'total_fees', $context );
1380 1380
     }
1381 1381
 
1382 1382
     /**
1383
-	 * Alias for self::get_total_fees().
1384
-	 *
1385
-	 * @since 1.0.19
1386
-	 * @param  string $context View or edit context.
1387
-	 * @return float
1388
-	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1383
+     * Alias for self::get_total_fees().
1384
+     *
1385
+     * @since 1.0.19
1386
+     * @param  string $context View or edit context.
1387
+     * @return float
1388
+     */
1389
+    public function get_fees_total( $context = 'view' ) {
1390
+        return $this->get_total_fees( $context );
1391 1391
     }
1392 1392
 
1393 1393
     /**
1394
-	 * Get the invoice total.
1395
-	 *
1396
-	 * @since 1.0.19
1394
+     * Get the invoice total.
1395
+     *
1396
+     * @since 1.0.19
1397 1397
      * @return float
1398
-	 */
1399
-	public function get_total() {
1400
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
-	}
1398
+     */
1399
+    public function get_total() {
1400
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
+    }
1403 1403
 	
1404
-	/**
1405
-	 * Get the invoice totals.
1406
-	 *
1407
-	 * @since 1.0.19
1404
+    /**
1405
+     * Get the invoice totals.
1406
+     *
1407
+     * @since 1.0.19
1408 1408
      * @return float
1409
-	 */
1410
-	public function get_totals() {
1411
-		return $this->totals;
1409
+     */
1410
+    public function get_totals() {
1411
+        return $this->totals;
1412 1412
     }
1413 1413
 
1414 1414
     /**
1415
-	 * Get the initial invoice total.
1416
-	 *
1417
-	 * @since 1.0.19
1415
+     * Get the initial invoice total.
1416
+     *
1417
+     * @since 1.0.19
1418 1418
      * @param  string $context View or edit context.
1419 1419
      * @return float
1420
-	 */
1420
+     */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1424
-			$this->recalculate_total();
1425
-		}
1423
+        if ( empty( $this->totals ) ) {
1424
+            $this->recalculate_total();
1425
+        }
1426 1426
 
1427
-		$tax      = $this->totals['tax']['initial'];
1428
-		$fee      = $this->totals['fee']['initial'];
1429
-		$discount = $this->totals['discount']['initial'];
1430
-		$subtotal = $this->totals['subtotal']['initial'];
1431
-		$total    = $tax + $fee - $discount + $subtotal;
1427
+        $tax      = $this->totals['tax']['initial'];
1428
+        $fee      = $this->totals['fee']['initial'];
1429
+        $discount = $this->totals['discount']['initial'];
1430
+        $subtotal = $this->totals['subtotal']['initial'];
1431
+        $total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1434
-			$total = 0;
1435
-		}
1433
+        if ( 0 > $total ) {
1434
+            $total = 0;
1435
+        }
1436 1436
 
1437 1437
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1438
-	}
1438
+    }
1439 1439
 
1440
-	/**
1441
-	 * Get the recurring invoice total.
1442
-	 *
1443
-	 * @since 1.0.19
1440
+    /**
1441
+     * Get the recurring invoice total.
1442
+     *
1443
+     * @since 1.0.19
1444 1444
      * @param  string $context View or edit context.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1450
-			$this->recalculate_total();
1451
-		}
1449
+        if ( empty( $this->totals ) ) {
1450
+            $this->recalculate_total();
1451
+        }
1452 1452
 
1453
-		$tax      = $this->totals['tax']['recurring'];
1454
-		$fee      = $this->totals['fee']['recurring'];
1455
-		$discount = $this->totals['discount']['recurring'];
1456
-		$subtotal = $this->totals['subtotal']['recurring'];
1457
-		$total    = $tax + $fee - $discount + $subtotal;
1453
+        $tax      = $this->totals['tax']['recurring'];
1454
+        $fee      = $this->totals['fee']['recurring'];
1455
+        $discount = $this->totals['discount']['recurring'];
1456
+        $subtotal = $this->totals['subtotal']['recurring'];
1457
+        $total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1460
-			$total = 0;
1461
-		}
1459
+        if ( 0 > $total ) {
1460
+            $total = 0;
1461
+        }
1462 1462
 
1463 1463
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1464
-	}
1464
+    }
1465 1465
 
1466
-	/**
1467
-	 * Returns recurring payment details.
1468
-	 *
1469
-	 * @since 1.0.19
1466
+    /**
1467
+     * Returns recurring payment details.
1468
+     *
1469
+     * @since 1.0.19
1470 1470
      * @param  string $field Optionally provide a field to return.
1471
-	 * @param string $currency Whether to include the currency.
1471
+     * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473
-	 */
1473
+     */
1474 1474
     public function get_recurring_details( $field = '', $currency = false ) {
1475 1475
 
1476
-		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1478
-			$this->recalculate_total();
1479
-		}
1476
+        // Maybe recalculate totals.
1477
+        if ( empty( $this->totals ) ) {
1478
+            $this->recalculate_total();
1479
+        }
1480 1480
 
1481
-		// Prepare recurring totals.
1481
+        // Prepare recurring totals.
1482 1482
         $data = apply_filters(
1483
-			'wpinv_get_invoice_recurring_details',
1484
-			array(
1485
-				'cart_details' => $this->get_cart_details(),
1486
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1487
-				'discount'     => $this->totals['discount']['recurring'],
1488
-				'tax'          => $this->totals['tax']['recurring'],
1489
-				'fee'          => $this->totals['fee']['recurring'],
1490
-				'total'        => $this->get_recurring_total(),
1491
-			),
1492
-			$this,
1493
-			$field,
1494
-			$currency
1495
-		);
1483
+            'wpinv_get_invoice_recurring_details',
1484
+            array(
1485
+                'cart_details' => $this->get_cart_details(),
1486
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1487
+                'discount'     => $this->totals['discount']['recurring'],
1488
+                'tax'          => $this->totals['tax']['recurring'],
1489
+                'fee'          => $this->totals['fee']['recurring'],
1490
+                'total'        => $this->get_recurring_total(),
1491
+            ),
1492
+            $this,
1493
+            $field,
1494
+            $currency
1495
+        );
1496 1496
 
1497 1497
         if ( isset( $data[$field] ) ) {
1498 1498
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1502,156 +1502,156 @@  discard block
 block discarded – undo
1502 1502
     }
1503 1503
 
1504 1504
     /**
1505
-	 * Get the invoice fees.
1506
-	 *
1507
-	 * @since 1.0.19
1508
-	 * @param  string $context View or edit context.
1509
-	 * @return array
1510
-	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1505
+     * Get the invoice fees.
1506
+     *
1507
+     * @since 1.0.19
1508
+     * @param  string $context View or edit context.
1509
+     * @return array
1510
+     */
1511
+    public function get_fees( $context = 'view' ) {
1512
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1513 1513
     }
1514 1514
 
1515 1515
     /**
1516
-	 * Get the invoice discounts.
1517
-	 *
1518
-	 * @since 1.0.19
1519
-	 * @param  string $context View or edit context.
1520
-	 * @return array
1521
-	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1516
+     * Get the invoice discounts.
1517
+     *
1518
+     * @since 1.0.19
1519
+     * @param  string $context View or edit context.
1520
+     * @return array
1521
+     */
1522
+    public function get_discounts( $context = 'view' ) {
1523
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1524 1524
     }
1525 1525
 
1526 1526
     /**
1527
-	 * Get the invoice taxes.
1528
-	 *
1529
-	 * @since 1.0.19
1530
-	 * @param  string $context View or edit context.
1531
-	 * @return array
1532
-	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1527
+     * Get the invoice taxes.
1528
+     *
1529
+     * @since 1.0.19
1530
+     * @param  string $context View or edit context.
1531
+     * @return array
1532
+     */
1533
+    public function get_taxes( $context = 'view' ) {
1534
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1535 1535
     }
1536 1536
 
1537 1537
     /**
1538
-	 * Get the invoice items.
1539
-	 *
1540
-	 * @since 1.0.19
1541
-	 * @param  string $context View or edit context.
1542
-	 * @return GetPaid_Form_Item[]
1543
-	 */
1544
-	public function get_items( $context = 'view' ) {
1538
+     * Get the invoice items.
1539
+     *
1540
+     * @since 1.0.19
1541
+     * @param  string $context View or edit context.
1542
+     * @return GetPaid_Form_Item[]
1543
+     */
1544
+    public function get_items( $context = 'view' ) {
1545 1545
         return $this->get_prop( 'items', $context );
1546 1546
     }
1547 1547
 
1548 1548
     /**
1549
-	 * Get the invoice's payment form.
1550
-	 *
1551
-	 * @since 1.0.19
1552
-	 * @param  string $context View or edit context.
1553
-	 * @return int
1554
-	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1549
+     * Get the invoice's payment form.
1550
+     *
1551
+     * @since 1.0.19
1552
+     * @param  string $context View or edit context.
1553
+     * @return int
1554
+     */
1555
+    public function get_payment_form( $context = 'view' ) {
1556
+        return intval( $this->get_prop( 'payment_form', $context ) );
1557 1557
     }
1558 1558
 
1559 1559
     /**
1560
-	 * Get the invoice's submission id.
1561
-	 *
1562
-	 * @since 1.0.19
1563
-	 * @param  string $context View or edit context.
1564
-	 * @return string
1565
-	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1560
+     * Get the invoice's submission id.
1561
+     *
1562
+     * @since 1.0.19
1563
+     * @param  string $context View or edit context.
1564
+     * @return string
1565
+     */
1566
+    public function get_submission_id( $context = 'view' ) {
1567
+        return $this->get_prop( 'submission_id', $context );
1568 1568
     }
1569 1569
 
1570 1570
     /**
1571
-	 * Get the invoice's discount code.
1572
-	 *
1573
-	 * @since 1.0.19
1574
-	 * @param  string $context View or edit context.
1575
-	 * @return string
1576
-	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1571
+     * Get the invoice's discount code.
1572
+     *
1573
+     * @since 1.0.19
1574
+     * @param  string $context View or edit context.
1575
+     * @return string
1576
+     */
1577
+    public function get_discount_code( $context = 'view' ) {
1578
+        return $this->get_prop( 'discount_code', $context );
1579 1579
     }
1580 1580
 
1581 1581
     /**
1582
-	 * Get the invoice's gateway.
1583
-	 *
1584
-	 * @since 1.0.19
1585
-	 * @param  string $context View or edit context.
1586
-	 * @return string
1587
-	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1582
+     * Get the invoice's gateway.
1583
+     *
1584
+     * @since 1.0.19
1585
+     * @param  string $context View or edit context.
1586
+     * @return string
1587
+     */
1588
+    public function get_gateway( $context = 'view' ) {
1589
+        return $this->get_prop( 'gateway', $context );
1590 1590
     }
1591 1591
 
1592 1592
     /**
1593
-	 * Get the invoice's gateway display title.
1594
-	 *
1595
-	 * @since 1.0.19
1596
-	 * @return string
1597
-	 */
1593
+     * Get the invoice's gateway display title.
1594
+     *
1595
+     * @since 1.0.19
1596
+     * @return string
1597
+     */
1598 1598
     public function get_gateway_title() {
1599 1599
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600 1600
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1601 1601
     }
1602 1602
 
1603 1603
     /**
1604
-	 * Get the invoice's transaction id.
1605
-	 *
1606
-	 * @since 1.0.19
1607
-	 * @param  string $context View or edit context.
1608
-	 * @return string
1609
-	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1604
+     * Get the invoice's transaction id.
1605
+     *
1606
+     * @since 1.0.19
1607
+     * @param  string $context View or edit context.
1608
+     * @return string
1609
+     */
1610
+    public function get_transaction_id( $context = 'view' ) {
1611
+        return $this->get_prop( 'transaction_id', $context );
1612 1612
     }
1613 1613
 
1614 1614
     /**
1615
-	 * Get the invoice's currency.
1616
-	 *
1617
-	 * @since 1.0.19
1618
-	 * @param  string $context View or edit context.
1619
-	 * @return string
1620
-	 */
1621
-	public function get_currency( $context = 'view' ) {
1615
+     * Get the invoice's currency.
1616
+     *
1617
+     * @since 1.0.19
1618
+     * @param  string $context View or edit context.
1619
+     * @return string
1620
+     */
1621
+    public function get_currency( $context = 'view' ) {
1622 1622
         $currency = $this->get_prop( 'currency', $context );
1623 1623
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
1627
-	 * Checks if we are charging taxes for this invoice.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @param  string $context View or edit context.
1631
-	 * @return bool
1632
-	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1627
+     * Checks if we are charging taxes for this invoice.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @param  string $context View or edit context.
1631
+     * @return bool
1632
+     */
1633
+    public function get_disable_taxes( $context = 'view' ) {
1634 1634
         return (bool) $this->get_prop( 'disable_taxes', $context );
1635 1635
     }
1636 1636
 
1637 1637
     /**
1638
-	 * Retrieves the subscription id for an invoice.
1639
-	 *
1640
-	 * @since 1.0.19
1641
-	 * @param  string $context View or edit context.
1642
-	 * @return int
1643
-	 */
1638
+     * Retrieves the subscription id for an invoice.
1639
+     *
1640
+     * @since 1.0.19
1641
+     * @param  string $context View or edit context.
1642
+     * @return int
1643
+     */
1644 1644
     public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
-	}
1647
-
1648
-	/**
1649
-	 * Retrieves the remote subscription id for an invoice.
1650
-	 *
1651
-	 * @since 1.0.19
1652
-	 * @param  string $context View or edit context.
1653
-	 * @return int
1654
-	 */
1645
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
+    }
1647
+
1648
+    /**
1649
+     * Retrieves the remote subscription id for an invoice.
1650
+     *
1651
+     * @since 1.0.19
1652
+     * @param  string $context View or edit context.
1653
+     * @return int
1654
+     */
1655 1655
     public function get_remote_subscription_id( $context = 'view' ) {
1656 1656
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1657 1657
 
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
     }
1665 1665
 
1666 1666
     /**
1667
-	 * Retrieves the payment meta for an invoice.
1668
-	 *
1669
-	 * @since 1.0.19
1670
-	 * @param  string $context View or edit context.
1671
-	 * @return array
1672
-	 */
1667
+     * Retrieves the payment meta for an invoice.
1668
+     *
1669
+     * @since 1.0.19
1670
+     * @param  string $context View or edit context.
1671
+     * @return array
1672
+     */
1673 1673
     public function get_payment_meta( $context = 'view' ) {
1674 1674
 
1675 1675
         return array(
@@ -1689,31 +1689,31 @@  discard block
 block discarded – undo
1689 1689
     }
1690 1690
 
1691 1691
     /**
1692
-	 * Retrieves the cart details for an invoice.
1693
-	 *
1694
-	 * @since 1.0.19
1695
-	 * @return array
1696
-	 */
1692
+     * Retrieves the cart details for an invoice.
1693
+     *
1694
+     * @since 1.0.19
1695
+     * @return array
1696
+     */
1697 1697
     public function get_cart_details() {
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701 1701
         foreach ( $items as $item_id => $item ) {
1702
-			$item->invoice_id = $this->get_id();
1702
+            $item->invoice_id = $this->get_id();
1703 1703
             $cart_details[]   = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
1707
-	}
1707
+    }
1708 1708
 
1709
-	/**
1710
-	 * Retrieves the recurring item.
1711
-	 *
1712
-	 * @return null|GetPaid_Form_Item|int
1713
-	 */
1714
-	public function get_recurring( $object = false ) {
1709
+    /**
1710
+     * Retrieves the recurring item.
1711
+     *
1712
+     * @return null|GetPaid_Form_Item|int
1713
+     */
1714
+    public function get_recurring( $object = false ) {
1715 1715
 
1716
-		// Are we returning an object?
1716
+        // Are we returning an object?
1717 1717
         if ( $object ) {
1718 1718
             return $this->get_item( $this->recurring_item );
1719 1719
         }
@@ -1721,100 +1721,100 @@  discard block
 block discarded – undo
1721 1721
         return $this->recurring_item;
1722 1722
     }
1723 1723
 
1724
-	/**
1725
-	 * Retrieves the subscription name.
1726
-	 *
1727
-	 * @since 1.0.19
1728
-	 * @return string
1729
-	 */
1730
-	public function get_subscription_name() {
1724
+    /**
1725
+     * Retrieves the subscription name.
1726
+     *
1727
+     * @since 1.0.19
1728
+     * @return string
1729
+     */
1730
+    public function get_subscription_name() {
1731 1731
 
1732
-		// Retrieve the recurring name
1732
+        // Retrieve the recurring name
1733 1733
         $item = $this->get_recurring( true );
1734 1734
 
1735
-		// Abort if it does not exist.
1735
+        // Abort if it does not exist.
1736 1736
         if ( empty( $item ) ) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740
-		// Return the item name.
1740
+        // Return the item name.
1741 1741
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1742
-	}
1743
-
1744
-	/**
1745
-	 * Retrieves the view url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_view_url() {
1742
+    }
1743
+
1744
+    /**
1745
+     * Retrieves the view url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_view_url() {
1751 1751
         $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1752
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753 1753
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1754
-	}
1754
+    }
1755 1755
 
1756
-	/**
1757
-	 * Retrieves the payment url.
1758
-	 *
1759
-	 * @since 1.0.19
1760
-	 * @return string
1761
-	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1756
+    /**
1757
+     * Retrieves the payment url.
1758
+     *
1759
+     * @since 1.0.19
1760
+     * @return string
1761
+     */
1762
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1763 1763
 
1764
-		// Retrieve the checkout url.
1764
+        // Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767
-		// Maybe force ssl.
1767
+        // Maybe force ssl.
1768 1768
         if ( is_ssl() ) {
1769 1769
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1770 1770
         }
1771 1771
 
1772
-		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1772
+        // Add the invoice key.
1773
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1774 1774
 
1775
-		// (Maybe?) add a secret
1775
+        // (Maybe?) add a secret
1776 1776
         if ( $secret ) {
1777 1777
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1778 1778
         }
1779 1779
 
1780 1780
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1781
-	}
1781
+    }
1782 1782
 	
1783
-	/**
1784
-	 * Retrieves the receipt url.
1785
-	 *
1786
-	 * @since 1.0.19
1787
-	 * @return string
1788
-	 */
1789
-	public function get_receipt_url() {
1790
-
1791
-		// Retrieve the checkout url.
1783
+    /**
1784
+     * Retrieves the receipt url.
1785
+     *
1786
+     * @since 1.0.19
1787
+     * @return string
1788
+     */
1789
+    public function get_receipt_url() {
1790
+
1791
+        // Retrieve the checkout url.
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794
-		// Maybe force ssl.
1794
+        // Maybe force ssl.
1795 1795
         if ( is_ssl() ) {
1796 1796
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1797 1797
         }
1798 1798
 
1799
-		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1799
+        // Add the invoice key.
1800
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1801 1801
 
1802 1802
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1803 1803
     }
1804 1804
 
1805 1805
     /**
1806
-	 * Magic method for accessing invoice properties.
1807
-	 *
1808
-	 * @since 1.0.15
1809
-	 * @access public
1810
-	 *
1811
-	 * @param string $key Discount data to retrieve
1812
-	 * @param  string $context View or edit context.
1813
-	 * @return mixed Value of the given invoice property (if set).
1814
-	 */
1815
-	public function get( $key, $context = 'view' ) {
1806
+     * Magic method for accessing invoice properties.
1807
+     *
1808
+     * @since 1.0.15
1809
+     * @access public
1810
+     *
1811
+     * @param string $key Discount data to retrieve
1812
+     * @param  string $context View or edit context.
1813
+     * @return mixed Value of the given invoice property (if set).
1814
+     */
1815
+    public function get( $key, $context = 'view' ) {
1816 1816
         return $this->get_prop( $key, $context );
1817
-	}
1817
+    }
1818 1818
 
1819 1819
     /*
1820 1820
 	|--------------------------------------------------------------------------
@@ -1827,130 +1827,130 @@  discard block
 block discarded – undo
1827 1827
     */
1828 1828
 
1829 1829
     /**
1830
-	 * Magic method for setting invoice properties.
1831
-	 *
1832
-	 * @since 1.0.19
1833
-	 * @access public
1834
-	 *
1835
-	 * @param string $key Discount data to retrieve
1836
-	 * @param  mixed $value new value.
1837
-	 * @return mixed Value of the given invoice property (if set).
1838
-	 */
1839
-	public function set( $key, $value ) {
1830
+     * Magic method for setting invoice properties.
1831
+     *
1832
+     * @since 1.0.19
1833
+     * @access public
1834
+     *
1835
+     * @param string $key Discount data to retrieve
1836
+     * @param  mixed $value new value.
1837
+     * @return mixed Value of the given invoice property (if set).
1838
+     */
1839
+    public function set( $key, $value ) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842 1842
         if ( is_callable( array( $this, $setter ) ) ) {
1843 1843
             $this->{$setter}( $value );
1844 1844
         }
1845 1845
 
1846
-	}
1846
+    }
1847 1847
 
1848
-	/**
1849
-	 * Sets item status.
1850
-	 *
1851
-	 * @since 1.0.19
1852
-	 * @param string $new_status    New status.
1853
-	 * @param string $note          Optional note to add.
1854
-	 * @param bool   $manual_update Is this a manual status change?.
1855
-	 * @return array details of change.
1856
-	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
-		$old_status = $this->get_status();
1848
+    /**
1849
+     * Sets item status.
1850
+     *
1851
+     * @since 1.0.19
1852
+     * @param string $new_status    New status.
1853
+     * @param string $note          Optional note to add.
1854
+     * @param bool   $manual_update Is this a manual status change?.
1855
+     * @return array details of change.
1856
+     */
1857
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
+        $old_status = $this->get_status();
1859 1859
 
1860
-		$statuses = $this->get_all_statuses();
1860
+        $statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1864
-		}
1862
+        if ( isset( $statuses[ 'draft' ] ) ) {
1863
+            unset( $statuses[ 'draft' ] );
1864
+        }
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+        $this->set_prop( 'status', $new_status );
1867 1867
 
1868
-		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1868
+        // If setting the status, ensure it's set to a valid status.
1869
+        if ( true === $this->object_read ) {
1870 1870
 
1871
-			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
-				$new_status = 'wpi-pending';
1874
-			}
1871
+            // Only allow valid new status.
1872
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
+                $new_status = 'wpi-pending';
1874
+            }
1875 1875
 
1876
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
-				$old_status = 'wpi-pending';
1879
-			}
1876
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
+                $old_status = 'wpi-pending';
1879
+            }
1880 1880
 
1881
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
-				$old_status = 'wpi-pending';
1884
-			}
1881
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1882
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
+                $old_status = 'wpi-pending';
1884
+            }
1885 1885
 
1886
-		}
1886
+        }
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1889
-			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
-				'to'     => $new_status,
1892
-				'note'   => $note,
1893
-				'manual' => (bool) $manual_update,
1894
-			);
1888
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1889
+            $this->status_transition = array(
1890
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
+                'to'     => $new_status,
1892
+                'note'   => $note,
1893
+                'manual' => (bool) $manual_update,
1894
+            );
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
-			}
1896
+            if ( $manual_update ) {
1897
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
+            }
1899 1899
 
1900
-			$this->maybe_set_date_paid();
1900
+            $this->maybe_set_date_paid();
1901 1901
 
1902
-		}
1902
+        }
1903 1903
 
1904
-		return array(
1905
-			'from' => $old_status,
1906
-			'to'   => $new_status,
1907
-		);
1908
-	}
1904
+        return array(
1905
+            'from' => $old_status,
1906
+            'to'   => $new_status,
1907
+        );
1908
+    }
1909 1909
 
1910
-	/**
1911
-	 * Maybe set date paid.
1912
-	 *
1913
-	 * Sets the date paid variable when transitioning to the payment complete
1914
-	 * order status.
1915
-	 *
1916
-	 * @since 1.0.19
1917
-	 */
1918
-	public function maybe_set_date_paid() {
1910
+    /**
1911
+     * Maybe set date paid.
1912
+     *
1913
+     * Sets the date paid variable when transitioning to the payment complete
1914
+     * order status.
1915
+     *
1916
+     * @since 1.0.19
1917
+     */
1918
+    public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1922
-		}
1923
-	}
1920
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
+            $this->set_date_completed( current_time( 'mysql' ) );
1922
+        }
1923
+    }
1924 1924
 
1925 1925
     /**
1926
-	 * Set parent invoice ID.
1927
-	 *
1928
-	 * @since 1.0.19
1929
-	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1932
-			return;
1933
-		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1926
+     * Set parent invoice ID.
1927
+     *
1928
+     * @since 1.0.19
1929
+     */
1930
+    public function set_parent_id( $value ) {
1931
+        if ( $value && ( $value === $this->get_id() ) ) {
1932
+            return;
1933
+        }
1934
+        $this->set_prop( 'parent_id', absint( $value ) );
1935 1935
     }
1936 1936
 
1937 1937
     /**
1938
-	 * Set plugin version when the invoice was created.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1938
+     * Set plugin version when the invoice was created.
1939
+     *
1940
+     * @since 1.0.19
1941
+     */
1942
+    public function set_version( $value ) {
1943
+        $this->set_prop( 'version', $value );
1944 1944
     }
1945
-
1946
-    /**
1947
-	 * Set date when the invoice was created.
1948
-	 *
1949
-	 * @since 1.0.19
1950
-	 * @param string $value Value to set.
1945
+
1946
+    /**
1947
+     * Set date when the invoice was created.
1948
+     *
1949
+     * @since 1.0.19
1950
+     * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952
-	 */
1953
-	public function set_date_created( $value ) {
1952
+     */
1953
+    public function set_date_created( $value ) {
1954 1954
         $date = strtotime( $value );
1955 1955
 
1956 1956
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1963,13 +1963,13 @@  discard block
 block discarded – undo
1963 1963
     }
1964 1964
 
1965 1965
     /**
1966
-	 * Set date invoice due date.
1967
-	 *
1968
-	 * @since 1.0.19
1969
-	 * @param string $value Value to set.
1966
+     * Set date invoice due date.
1967
+     *
1968
+     * @since 1.0.19
1969
+     * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971
-	 */
1972
-	public function set_due_date( $value ) {
1971
+     */
1972
+    public function set_due_date( $value ) {
1973 1973
         $date = strtotime( $value );
1974 1974
 
1975 1975
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1977,29 +1977,29 @@  discard block
 block discarded – undo
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+        $this->set_prop( 'due_date', '' );
1981 1981
         return false;
1982 1982
 
1983 1983
     }
1984 1984
 
1985 1985
     /**
1986
-	 * Alias of self::set_due_date().
1987
-	 *
1988
-	 * @since 1.0.19
1989
-	 * @param  string $value New name.
1990
-	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1986
+     * Alias of self::set_due_date().
1987
+     *
1988
+     * @since 1.0.19
1989
+     * @param  string $value New name.
1990
+     */
1991
+    public function set_date_due( $value ) {
1992
+        $this->set_due_date( $value );
1993 1993
     }
1994 1994
 
1995 1995
     /**
1996
-	 * Set date invoice was completed.
1997
-	 *
1998
-	 * @since 1.0.19
1999
-	 * @param string $value Value to set.
1996
+     * Set date invoice was completed.
1997
+     *
1998
+     * @since 1.0.19
1999
+     * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001
-	 */
2002
-	public function set_completed_date( $value ) {
2001
+     */
2002
+    public function set_completed_date( $value ) {
2003 2003
         $date = strtotime( $value );
2004 2004
 
2005 2005
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2007,29 +2007,29 @@  discard block
 block discarded – undo
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+        $this->set_prop( 'completed_date', '' );
2011 2011
         return false;
2012 2012
 
2013 2013
     }
2014 2014
 
2015 2015
     /**
2016
-	 * Alias of self::set_completed_date().
2017
-	 *
2018
-	 * @since 1.0.19
2019
-	 * @param  string $value New name.
2020
-	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2016
+     * Alias of self::set_completed_date().
2017
+     *
2018
+     * @since 1.0.19
2019
+     * @param  string $value New name.
2020
+     */
2021
+    public function set_date_completed( $value ) {
2022
+        $this->set_completed_date( $value );
2023 2023
     }
2024 2024
 
2025 2025
     /**
2026
-	 * Set date when the invoice was last modified.
2027
-	 *
2028
-	 * @since 1.0.19
2029
-	 * @param string $value Value to set.
2026
+     * Set date when the invoice was last modified.
2027
+     *
2028
+     * @since 1.0.19
2029
+     * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031
-	 */
2032
-	public function set_date_modified( $value ) {
2031
+     */
2032
+    public function set_date_modified( $value ) {
2033 2033
         $date = strtotime( $value );
2034 2034
 
2035 2035
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2037,706 +2037,706 @@  discard block
 block discarded – undo
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+        $this->set_prop( 'date_modified', '' );
2041 2041
         return false;
2042 2042
 
2043 2043
     }
2044 2044
 
2045 2045
     /**
2046
-	 * Set the invoice number.
2047
-	 *
2048
-	 * @since 1.0.19
2049
-	 * @param  string $value New number.
2050
-	 */
2051
-	public function set_number( $value ) {
2046
+     * Set the invoice number.
2047
+     *
2048
+     * @since 1.0.19
2049
+     * @param  string $value New number.
2050
+     */
2051
+    public function set_number( $value ) {
2052 2052
         $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2053
+        $this->set_prop( 'number', $number );
2054 2054
     }
2055 2055
 
2056 2056
     /**
2057
-	 * Set the invoice type.
2058
-	 *
2059
-	 * @since 1.0.19
2060
-	 * @param  string $value Type.
2061
-	 */
2062
-	public function set_type( $value ) {
2057
+     * Set the invoice type.
2058
+     *
2059
+     * @since 1.0.19
2060
+     * @param  string $value Type.
2061
+     */
2062
+    public function set_type( $value ) {
2063 2063
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2065
-	}
2064
+        $this->set_prop( 'type', $type );
2065
+    }
2066 2066
 
2067 2067
     /**
2068
-	 * Set the invoice post type.
2069
-	 *
2070
-	 * @since 1.0.19
2071
-	 * @param  string $value Post type.
2072
-	 */
2073
-	public function set_post_type( $value ) {
2068
+     * Set the invoice post type.
2069
+     *
2070
+     * @since 1.0.19
2071
+     * @param  string $value Post type.
2072
+     */
2073
+    public function set_post_type( $value ) {
2074 2074
         if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2075
+            $this->set_type( $value );
2076 2076
             $this->set_prop( 'post_type', $value );
2077 2077
         }
2078 2078
     }
2079 2079
 
2080 2080
     /**
2081
-	 * Set the invoice key.
2082
-	 *
2083
-	 * @since 1.0.19
2084
-	 * @param  string $value New key.
2085
-	 */
2086
-	public function set_key( $value ) {
2081
+     * Set the invoice key.
2082
+     *
2083
+     * @since 1.0.19
2084
+     * @param  string $value New key.
2085
+     */
2086
+    public function set_key( $value ) {
2087 2087
         $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2088
+        $this->set_prop( 'key', $key );
2089 2089
     }
2090 2090
 
2091 2091
     /**
2092
-	 * Set the invoice mode.
2093
-	 *
2094
-	 * @since 1.0.19
2095
-	 * @param  string $value mode.
2096
-	 */
2097
-	public function set_mode( $value ) {
2092
+     * Set the invoice mode.
2093
+     *
2094
+     * @since 1.0.19
2095
+     * @param  string $value mode.
2096
+     */
2097
+    public function set_mode( $value ) {
2098 2098
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099 2099
             $this->set_prop( 'value', $value );
2100 2100
         }
2101 2101
     }
2102 2102
 
2103 2103
     /**
2104
-	 * Set the invoice path.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 * @param  string $value path.
2108
-	 */
2109
-	public function set_path( $value ) {
2104
+     * Set the invoice path.
2105
+     *
2106
+     * @since 1.0.19
2107
+     * @param  string $value path.
2108
+     */
2109
+    public function set_path( $value ) {
2110 2110
         $this->set_prop( 'path', $value );
2111 2111
     }
2112 2112
 
2113 2113
     /**
2114
-	 * Set the invoice name.
2115
-	 *
2116
-	 * @since 1.0.19
2117
-	 * @param  string $value New name.
2118
-	 */
2119
-	public function set_name( $value ) {
2114
+     * Set the invoice name.
2115
+     *
2116
+     * @since 1.0.19
2117
+     * @param  string $value New name.
2118
+     */
2119
+    public function set_name( $value ) {
2120 2120
         $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2121
+        $this->set_prop( 'name', $name );
2122 2122
     }
2123 2123
 
2124 2124
     /**
2125
-	 * Alias of self::set_name().
2126
-	 *
2127
-	 * @since 1.0.19
2128
-	 * @param  string $value New name.
2129
-	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2125
+     * Alias of self::set_name().
2126
+     *
2127
+     * @since 1.0.19
2128
+     * @param  string $value New name.
2129
+     */
2130
+    public function set_title( $value ) {
2131
+        $this->set_name( $value );
2132 2132
     }
2133 2133
 
2134 2134
     /**
2135
-	 * Set the invoice description.
2136
-	 *
2137
-	 * @since 1.0.19
2138
-	 * @param  string $value New description.
2139
-	 */
2140
-	public function set_description( $value ) {
2135
+     * Set the invoice description.
2136
+     *
2137
+     * @since 1.0.19
2138
+     * @param  string $value New description.
2139
+     */
2140
+    public function set_description( $value ) {
2141 2141
         $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2142
+        return $this->set_prop( 'description', $description );
2143 2143
     }
2144 2144
 
2145 2145
     /**
2146
-	 * Alias of self::set_description().
2147
-	 *
2148
-	 * @since 1.0.19
2149
-	 * @param  string $value New description.
2150
-	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2146
+     * Alias of self::set_description().
2147
+     *
2148
+     * @since 1.0.19
2149
+     * @param  string $value New description.
2150
+     */
2151
+    public function set_excerpt( $value ) {
2152
+        $this->set_description( $value );
2153 2153
     }
2154 2154
 
2155 2155
     /**
2156
-	 * Alias of self::set_description().
2157
-	 *
2158
-	 * @since 1.0.19
2159
-	 * @param  string $value New description.
2160
-	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2156
+     * Alias of self::set_description().
2157
+     *
2158
+     * @since 1.0.19
2159
+     * @param  string $value New description.
2160
+     */
2161
+    public function set_summary( $value ) {
2162
+        $this->set_description( $value );
2163 2163
     }
2164 2164
 
2165 2165
     /**
2166
-	 * Set the receiver of the invoice.
2167
-	 *
2168
-	 * @since 1.0.19
2169
-	 * @param  int $value New author.
2170
-	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2166
+     * Set the receiver of the invoice.
2167
+     *
2168
+     * @since 1.0.19
2169
+     * @param  int $value New author.
2170
+     */
2171
+    public function set_author( $value ) {
2172
+        $user = get_user_by( 'id', (int) $value );
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2177
-		}
2174
+        if ( $user && $user->ID ) {
2175
+            $this->set_prop( 'author', $user->ID );
2176
+            $this->set_prop( 'email', $user->user_email );
2177
+        }
2178 2178
 		
2179 2179
     }
2180 2180
 
2181 2181
     /**
2182
-	 * Alias of self::set_author().
2183
-	 *
2184
-	 * @since 1.0.19
2185
-	 * @param  int $value New user id.
2186
-	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2182
+     * Alias of self::set_author().
2183
+     *
2184
+     * @since 1.0.19
2185
+     * @param  int $value New user id.
2186
+     */
2187
+    public function set_user_id( $value ) {
2188
+        $this->set_author( $value );
2189
+    }
2190
+
2191
+    /**
2192
+     * Alias of self::set_author().
2193
+     *
2194
+     * @since 1.0.19
2195
+     * @param  int $value New user id.
2196
+     */
2197
+    public function set_customer_id( $value ) {
2198
+        $this->set_author( $value );
2199
+    }
2200
+
2201
+    /**
2202
+     * Set the customer's ip.
2203
+     *
2204
+     * @since 1.0.19
2205
+     * @param  string $value ip address.
2206
+     */
2207
+    public function set_ip( $value ) {
2208
+        $this->set_prop( 'ip', $value );
2209
+    }
2210
+
2211
+    /**
2212
+     * Alias of self::set_ip().
2213
+     *
2214
+     * @since 1.0.19
2215
+     * @param  string $value ip address.
2216
+     */
2217
+    public function set_user_ip( $value ) {
2218
+        $this->set_ip( $value );
2189 2219
     }
2190 2220
 
2191 2221
     /**
2192
-	 * Alias of self::set_author().
2193
-	 *
2194
-	 * @since 1.0.19
2195
-	 * @param  int $value New user id.
2196
-	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2222
+     * Set the customer's first name.
2223
+     *
2224
+     * @since 1.0.19
2225
+     * @param  string $value first name.
2226
+     */
2227
+    public function set_first_name( $value ) {
2228
+        $this->set_prop( 'first_name', $value );
2199 2229
     }
2200 2230
 
2201 2231
     /**
2202
-	 * Set the customer's ip.
2203
-	 *
2204
-	 * @since 1.0.19
2205
-	 * @param  string $value ip address.
2206
-	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2232
+     * Alias of self::set_first_name().
2233
+     *
2234
+     * @since 1.0.19
2235
+     * @param  string $value first name.
2236
+     */
2237
+    public function set_user_first_name( $value ) {
2238
+        $this->set_first_name( $value );
2209 2239
     }
2210 2240
 
2211 2241
     /**
2212
-	 * Alias of self::set_ip().
2213
-	 *
2214
-	 * @since 1.0.19
2215
-	 * @param  string $value ip address.
2216
-	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2242
+     * Alias of self::set_first_name().
2243
+     *
2244
+     * @since 1.0.19
2245
+     * @param  string $value first name.
2246
+     */
2247
+    public function set_customer_first_name( $value ) {
2248
+        $this->set_first_name( $value );
2219 2249
     }
2220 2250
 
2221 2251
     /**
2222
-	 * Set the customer's first name.
2223
-	 *
2224
-	 * @since 1.0.19
2225
-	 * @param  string $value first name.
2226
-	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2252
+     * Set the customer's last name.
2253
+     *
2254
+     * @since 1.0.19
2255
+     * @param  string $value last name.
2256
+     */
2257
+    public function set_last_name( $value ) {
2258
+        $this->set_prop( 'last_name', $value );
2229 2259
     }
2230 2260
 
2231 2261
     /**
2232
-	 * Alias of self::set_first_name().
2233
-	 *
2234
-	 * @since 1.0.19
2235
-	 * @param  string $value first name.
2236
-	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2262
+     * Alias of self::set_last_name().
2263
+     *
2264
+     * @since 1.0.19
2265
+     * @param  string $value last name.
2266
+     */
2267
+    public function set_user_last_name( $value ) {
2268
+        $this->set_last_name( $value );
2239 2269
     }
2240 2270
 
2241 2271
     /**
2242
-	 * Alias of self::set_first_name().
2243
-	 *
2244
-	 * @since 1.0.19
2245
-	 * @param  string $value first name.
2246
-	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2272
+     * Alias of self::set_last_name().
2273
+     *
2274
+     * @since 1.0.19
2275
+     * @param  string $value last name.
2276
+     */
2277
+    public function set_customer_last_name( $value ) {
2278
+        $this->set_last_name( $value );
2249 2279
     }
2250 2280
 
2251 2281
     /**
2252
-	 * Set the customer's last name.
2253
-	 *
2254
-	 * @since 1.0.19
2255
-	 * @param  string $value last name.
2256
-	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2282
+     * Set the customer's phone number.
2283
+     *
2284
+     * @since 1.0.19
2285
+     * @param  string $value phone.
2286
+     */
2287
+    public function set_phone( $value ) {
2288
+        $this->set_prop( 'phone', $value );
2259 2289
     }
2260 2290
 
2261 2291
     /**
2262
-	 * Alias of self::set_last_name().
2263
-	 *
2264
-	 * @since 1.0.19
2265
-	 * @param  string $value last name.
2266
-	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2292
+     * Alias of self::set_phone().
2293
+     *
2294
+     * @since 1.0.19
2295
+     * @param  string $value phone.
2296
+     */
2297
+    public function set_user_phone( $value ) {
2298
+        $this->set_phone( $value );
2269 2299
     }
2270 2300
 
2271 2301
     /**
2272
-	 * Alias of self::set_last_name().
2273
-	 *
2274
-	 * @since 1.0.19
2275
-	 * @param  string $value last name.
2276
-	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2302
+     * Alias of self::set_phone().
2303
+     *
2304
+     * @since 1.0.19
2305
+     * @param  string $value phone.
2306
+     */
2307
+    public function set_customer_phone( $value ) {
2308
+        $this->set_phone( $value );
2279 2309
     }
2280 2310
 
2281 2311
     /**
2282
-	 * Set the customer's phone number.
2283
-	 *
2284
-	 * @since 1.0.19
2285
-	 * @param  string $value phone.
2286
-	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2312
+     * Alias of self::set_phone().
2313
+     *
2314
+     * @since 1.0.19
2315
+     * @param  string $value phone.
2316
+     */
2317
+    public function set_phone_number( $value ) {
2318
+        $this->set_phone( $value );
2289 2319
     }
2290 2320
 
2291 2321
     /**
2292
-	 * Alias of self::set_phone().
2293
-	 *
2294
-	 * @since 1.0.19
2295
-	 * @param  string $value phone.
2296
-	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2322
+     * Set the customer's email address.
2323
+     *
2324
+     * @since 1.0.19
2325
+     * @param  string $value email address.
2326
+     */
2327
+    public function set_email( $value ) {
2328
+        $this->set_prop( 'email', $value );
2299 2329
     }
2300 2330
 
2301 2331
     /**
2302
-	 * Alias of self::set_phone().
2303
-	 *
2304
-	 * @since 1.0.19
2305
-	 * @param  string $value phone.
2306
-	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2332
+     * Alias of self::set_email().
2333
+     *
2334
+     * @since 1.0.19
2335
+     * @param  string $value email address.
2336
+     */
2337
+    public function set_user_email( $value ) {
2338
+        $this->set_email( $value );
2309 2339
     }
2310 2340
 
2311 2341
     /**
2312
-	 * Alias of self::set_phone().
2313
-	 *
2314
-	 * @since 1.0.19
2315
-	 * @param  string $value phone.
2316
-	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2342
+     * Alias of self::set_email().
2343
+     *
2344
+     * @since 1.0.19
2345
+     * @param  string $value email address.
2346
+     */
2347
+    public function set_email_address( $value ) {
2348
+        $this->set_email( $value );
2319 2349
     }
2320 2350
 
2321 2351
     /**
2322
-	 * Set the customer's email address.
2323
-	 *
2324
-	 * @since 1.0.19
2325
-	 * @param  string $value email address.
2326
-	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2352
+     * Alias of self::set_email().
2353
+     *
2354
+     * @since 1.0.19
2355
+     * @param  string $value email address.
2356
+     */
2357
+    public function set_customer_email( $value ) {
2358
+        $this->set_email( $value );
2329 2359
     }
2330 2360
 
2331 2361
     /**
2332
-	 * Alias of self::set_email().
2333
-	 *
2334
-	 * @since 1.0.19
2335
-	 * @param  string $value email address.
2336
-	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2362
+     * Set the customer's country.
2363
+     *
2364
+     * @since 1.0.19
2365
+     * @param  string $value country.
2366
+     */
2367
+    public function set_country( $value ) {
2368
+        $this->set_prop( 'country', $value );
2339 2369
     }
2340 2370
 
2341 2371
     /**
2342
-	 * Alias of self::set_email().
2343
-	 *
2344
-	 * @since 1.0.19
2345
-	 * @param  string $value email address.
2346
-	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2372
+     * Alias of self::set_country().
2373
+     *
2374
+     * @since 1.0.19
2375
+     * @param  string $value country.
2376
+     */
2377
+    public function set_user_country( $value ) {
2378
+        $this->set_country( $value );
2349 2379
     }
2350 2380
 
2351 2381
     /**
2352
-	 * Alias of self::set_email().
2353
-	 *
2354
-	 * @since 1.0.19
2355
-	 * @param  string $value email address.
2356
-	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2382
+     * Alias of self::set_country().
2383
+     *
2384
+     * @since 1.0.19
2385
+     * @param  string $value country.
2386
+     */
2387
+    public function set_customer_country( $value ) {
2388
+        $this->set_country( $value );
2359 2389
     }
2360 2390
 
2361 2391
     /**
2362
-	 * Set the customer's country.
2363
-	 *
2364
-	 * @since 1.0.19
2365
-	 * @param  string $value country.
2366
-	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2392
+     * Set the customer's state.
2393
+     *
2394
+     * @since 1.0.19
2395
+     * @param  string $value state.
2396
+     */
2397
+    public function set_state( $value ) {
2398
+        $this->set_prop( 'state', $value );
2369 2399
     }
2370 2400
 
2371 2401
     /**
2372
-	 * Alias of self::set_country().
2373
-	 *
2374
-	 * @since 1.0.19
2375
-	 * @param  string $value country.
2376
-	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2402
+     * Alias of self::set_state().
2403
+     *
2404
+     * @since 1.0.19
2405
+     * @param  string $value state.
2406
+     */
2407
+    public function set_user_state( $value ) {
2408
+        $this->set_state( $value );
2379 2409
     }
2380 2410
 
2381 2411
     /**
2382
-	 * Alias of self::set_country().
2383
-	 *
2384
-	 * @since 1.0.19
2385
-	 * @param  string $value country.
2386
-	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2412
+     * Alias of self::set_state().
2413
+     *
2414
+     * @since 1.0.19
2415
+     * @param  string $value state.
2416
+     */
2417
+    public function set_customer_state( $value ) {
2418
+        $this->set_state( $value );
2389 2419
     }
2390 2420
 
2391 2421
     /**
2392
-	 * Set the customer's state.
2393
-	 *
2394
-	 * @since 1.0.19
2395
-	 * @param  string $value state.
2396
-	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2422
+     * Set the customer's city.
2423
+     *
2424
+     * @since 1.0.19
2425
+     * @param  string $value city.
2426
+     */
2427
+    public function set_city( $value ) {
2428
+        $this->set_prop( 'city', $value );
2399 2429
     }
2400 2430
 
2401 2431
     /**
2402
-	 * Alias of self::set_state().
2403
-	 *
2404
-	 * @since 1.0.19
2405
-	 * @param  string $value state.
2406
-	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2432
+     * Alias of self::set_city().
2433
+     *
2434
+     * @since 1.0.19
2435
+     * @param  string $value city.
2436
+     */
2437
+    public function set_user_city( $value ) {
2438
+        $this->set_city( $value );
2409 2439
     }
2410 2440
 
2411 2441
     /**
2412
-	 * Alias of self::set_state().
2413
-	 *
2414
-	 * @since 1.0.19
2415
-	 * @param  string $value state.
2416
-	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2442
+     * Alias of self::set_city().
2443
+     *
2444
+     * @since 1.0.19
2445
+     * @param  string $value city.
2446
+     */
2447
+    public function set_customer_city( $value ) {
2448
+        $this->set_city( $value );
2419 2449
     }
2420 2450
 
2421 2451
     /**
2422
-	 * Set the customer's city.
2423
-	 *
2424
-	 * @since 1.0.19
2425
-	 * @param  string $value city.
2426
-	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2452
+     * Set the customer's zip code.
2453
+     *
2454
+     * @since 1.0.19
2455
+     * @param  string $value zip.
2456
+     */
2457
+    public function set_zip( $value ) {
2458
+        $this->set_prop( 'zip', $value );
2429 2459
     }
2430 2460
 
2431 2461
     /**
2432
-	 * Alias of self::set_city().
2433
-	 *
2434
-	 * @since 1.0.19
2435
-	 * @param  string $value city.
2436
-	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2462
+     * Alias of self::set_zip().
2463
+     *
2464
+     * @since 1.0.19
2465
+     * @param  string $value zip.
2466
+     */
2467
+    public function set_user_zip( $value ) {
2468
+        $this->set_zip( $value );
2439 2469
     }
2440 2470
 
2441 2471
     /**
2442
-	 * Alias of self::set_city().
2443
-	 *
2444
-	 * @since 1.0.19
2445
-	 * @param  string $value city.
2446
-	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2472
+     * Alias of self::set_zip().
2473
+     *
2474
+     * @since 1.0.19
2475
+     * @param  string $value zip.
2476
+     */
2477
+    public function set_customer_zip( $value ) {
2478
+        $this->set_zip( $value );
2449 2479
     }
2450 2480
 
2451 2481
     /**
2452
-	 * Set the customer's zip code.
2453
-	 *
2454
-	 * @since 1.0.19
2455
-	 * @param  string $value zip.
2456
-	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2482
+     * Set the customer's company.
2483
+     *
2484
+     * @since 1.0.19
2485
+     * @param  string $value company.
2486
+     */
2487
+    public function set_company( $value ) {
2488
+        $this->set_prop( 'company', $value );
2459 2489
     }
2460 2490
 
2461 2491
     /**
2462
-	 * Alias of self::set_zip().
2463
-	 *
2464
-	 * @since 1.0.19
2465
-	 * @param  string $value zip.
2466
-	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2492
+     * Alias of self::set_company().
2493
+     *
2494
+     * @since 1.0.19
2495
+     * @param  string $value company.
2496
+     */
2497
+    public function set_user_company( $value ) {
2498
+        $this->set_company( $value );
2469 2499
     }
2470 2500
 
2471 2501
     /**
2472
-	 * Alias of self::set_zip().
2473
-	 *
2474
-	 * @since 1.0.19
2475
-	 * @param  string $value zip.
2476
-	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2502
+     * Alias of self::set_company().
2503
+     *
2504
+     * @since 1.0.19
2505
+     * @param  string $value company.
2506
+     */
2507
+    public function set_customer_company( $value ) {
2508
+        $this->set_company( $value );
2479 2509
     }
2480 2510
 
2481 2511
     /**
2482
-	 * Set the customer's company.
2483
-	 *
2484
-	 * @since 1.0.19
2485
-	 * @param  string $value company.
2486
-	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2512
+     * Set the customer's var number.
2513
+     *
2514
+     * @since 1.0.19
2515
+     * @param  string $value var number.
2516
+     */
2517
+    public function set_vat_number( $value ) {
2518
+        $this->set_prop( 'vat_number', $value );
2489 2519
     }
2490 2520
 
2491 2521
     /**
2492
-	 * Alias of self::set_company().
2493
-	 *
2494
-	 * @since 1.0.19
2495
-	 * @param  string $value company.
2496
-	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2522
+     * Alias of self::set_vat_number().
2523
+     *
2524
+     * @since 1.0.19
2525
+     * @param  string $value var number.
2526
+     */
2527
+    public function set_user_vat_number( $value ) {
2528
+        $this->set_vat_number( $value );
2499 2529
     }
2500 2530
 
2501 2531
     /**
2502
-	 * Alias of self::set_company().
2503
-	 *
2504
-	 * @since 1.0.19
2505
-	 * @param  string $value company.
2506
-	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2532
+     * Alias of self::set_vat_number().
2533
+     *
2534
+     * @since 1.0.19
2535
+     * @param  string $value var number.
2536
+     */
2537
+    public function set_customer_vat_number( $value ) {
2538
+        $this->set_vat_number( $value );
2509 2539
     }
2510 2540
 
2511 2541
     /**
2512
-	 * Set the customer's var number.
2513
-	 *
2514
-	 * @since 1.0.19
2515
-	 * @param  string $value var number.
2516
-	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2542
+     * Set the customer's vat rate.
2543
+     *
2544
+     * @since 1.0.19
2545
+     * @param  string $value var rate.
2546
+     */
2547
+    public function set_vat_rate( $value ) {
2548
+        $this->set_prop( 'vat_rate', $value );
2519 2549
     }
2520 2550
 
2521 2551
     /**
2522
-	 * Alias of self::set_vat_number().
2523
-	 *
2524
-	 * @since 1.0.19
2525
-	 * @param  string $value var number.
2526
-	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2552
+     * Alias of self::set_vat_rate().
2553
+     *
2554
+     * @since 1.0.19
2555
+     * @param  string $value var number.
2556
+     */
2557
+    public function set_user_vat_rate( $value ) {
2558
+        $this->set_vat_rate( $value );
2529 2559
     }
2530 2560
 
2531 2561
     /**
2532
-	 * Alias of self::set_vat_number().
2533
-	 *
2534
-	 * @since 1.0.19
2535
-	 * @param  string $value var number.
2536
-	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2562
+     * Alias of self::set_vat_rate().
2563
+     *
2564
+     * @since 1.0.19
2565
+     * @param  string $value var number.
2566
+     */
2567
+    public function set_customer_vat_rate( $value ) {
2568
+        $this->set_vat_rate( $value );
2539 2569
     }
2540 2570
 
2541 2571
     /**
2542
-	 * Set the customer's vat rate.
2543
-	 *
2544
-	 * @since 1.0.19
2545
-	 * @param  string $value var rate.
2546
-	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2572
+     * Set the customer's address.
2573
+     *
2574
+     * @since 1.0.19
2575
+     * @param  string $value address.
2576
+     */
2577
+    public function set_address( $value ) {
2578
+        $this->set_prop( 'address', $value );
2549 2579
     }
2550 2580
 
2551 2581
     /**
2552
-	 * Alias of self::set_vat_rate().
2553
-	 *
2554
-	 * @since 1.0.19
2555
-	 * @param  string $value var number.
2556
-	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2582
+     * Alias of self::set_address().
2583
+     *
2584
+     * @since 1.0.19
2585
+     * @param  string $value address.
2586
+     */
2587
+    public function set_user_address( $value ) {
2588
+        $this->set_address( $value );
2559 2589
     }
2560 2590
 
2561 2591
     /**
2562
-	 * Alias of self::set_vat_rate().
2563
-	 *
2564
-	 * @since 1.0.19
2565
-	 * @param  string $value var number.
2566
-	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2592
+     * Alias of self::set_address().
2593
+     *
2594
+     * @since 1.0.19
2595
+     * @param  string $value address.
2596
+     */
2597
+    public function set_customer_address( $value ) {
2598
+        $this->set_address( $value );
2569 2599
     }
2570 2600
 
2571 2601
     /**
2572
-	 * Set the customer's address.
2573
-	 *
2574
-	 * @since 1.0.19
2575
-	 * @param  string $value address.
2576
-	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2602
+     * Set whether the customer has viewed the invoice or not.
2603
+     *
2604
+     * @since 1.0.19
2605
+     * @param  int|bool $value confirmed.
2606
+     */
2607
+    public function set_is_viewed( $value ) {
2608
+        $this->set_prop( 'is_viewed', $value );
2579 2609
     }
2580 2610
 
2581 2611
     /**
2582
-	 * Alias of self::set_address().
2583
-	 *
2584
-	 * @since 1.0.19
2585
-	 * @param  string $value address.
2586
-	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2612
+     * Set extra email recipients.
2613
+     *
2614
+     * @since 1.0.19
2615
+     * @param  string $value email recipients.
2616
+     */
2617
+    public function set_email_cc( $value ) {
2618
+        $this->set_prop( 'email_cc', $value );
2589 2619
     }
2590 2620
 
2591 2621
     /**
2592
-	 * Alias of self::set_address().
2593
-	 *
2594
-	 * @since 1.0.19
2595
-	 * @param  string $value address.
2596
-	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2622
+     * Set the invoice template.
2623
+     *
2624
+     * @since 1.0.19
2625
+     * @param  string $value email recipients.
2626
+     */
2627
+    public function set_template( $value ) {
2628
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
+            $this->set_prop( 'template', $value );
2630
+        }
2599 2631
     }
2600 2632
 
2601 2633
     /**
2602
-	 * Set whether the customer has viewed the invoice or not.
2603
-	 *
2604
-	 * @since 1.0.19
2605
-	 * @param  int|bool $value confirmed.
2606
-	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2609
-	}
2610
-
2611
-	/**
2612
-	 * Set extra email recipients.
2613
-	 *
2614
-	 * @since 1.0.19
2615
-	 * @param  string $value email recipients.
2616
-	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2619
-	}
2620
-
2621
-	/**
2622
-	 * Set the invoice template.
2623
-	 *
2624
-	 * @since 1.0.19
2625
-	 * @param  string $value email recipients.
2626
-	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2630
-		}
2631
-	}
2632
-
2633
-	/**
2634
-	 * Set the customer's address confirmed status.
2635
-	 *
2636
-	 * @since 1.0.19
2637
-	 * @param  int|bool $value confirmed.
2638
-	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2634
+     * Set the customer's address confirmed status.
2635
+     *
2636
+     * @since 1.0.19
2637
+     * @param  int|bool $value confirmed.
2638
+     */
2639
+    public function set_address_confirmed( $value ) {
2640
+        $this->set_prop( 'address_confirmed', $value );
2641 2641
     }
2642 2642
 
2643 2643
     /**
2644
-	 * Alias of self::set_address_confirmed().
2645
-	 *
2646
-	 * @since 1.0.19
2647
-	 * @param  int|bool $value confirmed.
2648
-	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2644
+     * Alias of self::set_address_confirmed().
2645
+     *
2646
+     * @since 1.0.19
2647
+     * @param  int|bool $value confirmed.
2648
+     */
2649
+    public function set_user_address_confirmed( $value ) {
2650
+        $this->set_address_confirmed( $value );
2651 2651
     }
2652 2652
 
2653 2653
     /**
2654
-	 * Alias of self::set_address_confirmed().
2655
-	 *
2656
-	 * @since 1.0.19
2657
-	 * @param  int|bool $value confirmed.
2658
-	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2654
+     * Alias of self::set_address_confirmed().
2655
+     *
2656
+     * @since 1.0.19
2657
+     * @param  int|bool $value confirmed.
2658
+     */
2659
+    public function set_customer_address_confirmed( $value ) {
2660
+        $this->set_address_confirmed( $value );
2661 2661
     }
2662 2662
 
2663 2663
     /**
2664
-	 * Set the invoice sub total.
2665
-	 *
2666
-	 * @since 1.0.19
2667
-	 * @param  float $value sub total.
2668
-	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2664
+     * Set the invoice sub total.
2665
+     *
2666
+     * @since 1.0.19
2667
+     * @param  float $value sub total.
2668
+     */
2669
+    public function set_subtotal( $value ) {
2670
+        $this->set_prop( 'subtotal', $value );
2671 2671
     }
2672 2672
 
2673 2673
     /**
2674
-	 * Set the invoice discount amount.
2675
-	 *
2676
-	 * @since 1.0.19
2677
-	 * @param  float $value discount total.
2678
-	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2674
+     * Set the invoice discount amount.
2675
+     *
2676
+     * @since 1.0.19
2677
+     * @param  float $value discount total.
2678
+     */
2679
+    public function set_total_discount( $value ) {
2680
+        $this->set_prop( 'total_discount', $value );
2681 2681
     }
2682 2682
 
2683 2683
     /**
2684
-	 * Alias of self::set_total_discount().
2685
-	 *
2686
-	 * @since 1.0.19
2687
-	 * @param  float $value discount total.
2688
-	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2684
+     * Alias of self::set_total_discount().
2685
+     *
2686
+     * @since 1.0.19
2687
+     * @param  float $value discount total.
2688
+     */
2689
+    public function set_discount( $value ) {
2690
+        $this->set_total_discount( $value );
2691 2691
     }
2692 2692
 
2693 2693
     /**
2694
-	 * Set the invoice tax amount.
2695
-	 *
2696
-	 * @since 1.0.19
2697
-	 * @param  float $value tax total.
2698
-	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2694
+     * Set the invoice tax amount.
2695
+     *
2696
+     * @since 1.0.19
2697
+     * @param  float $value tax total.
2698
+     */
2699
+    public function set_total_tax( $value ) {
2700
+        $this->set_prop( 'total_tax', $value );
2701 2701
     }
2702 2702
 
2703 2703
     /**
2704
-	 * Alias of self::set_total_tax().
2705
-	 *
2706
-	 * @since 1.0.19
2707
-	 * @param  float $value tax total.
2708
-	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2704
+     * Alias of self::set_total_tax().
2705
+     *
2706
+     * @since 1.0.19
2707
+     * @param  float $value tax total.
2708
+     */
2709
+    public function set_tax_total( $value ) {
2710
+        $this->set_total_tax( $value );
2711 2711
     }
2712 2712
 
2713 2713
     /**
2714
-	 * Set the invoice fees amount.
2715
-	 *
2716
-	 * @since 1.0.19
2717
-	 * @param  float $value fees total.
2718
-	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2714
+     * Set the invoice fees amount.
2715
+     *
2716
+     * @since 1.0.19
2717
+     * @param  float $value fees total.
2718
+     */
2719
+    public function set_total_fees( $value ) {
2720
+        $this->set_prop( 'total_fees', $value );
2721 2721
     }
2722 2722
 
2723 2723
     /**
2724
-	 * Alias of self::set_total_fees().
2725
-	 *
2726
-	 * @since 1.0.19
2727
-	 * @param  float $value fees total.
2728
-	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2724
+     * Alias of self::set_total_fees().
2725
+     *
2726
+     * @since 1.0.19
2727
+     * @param  float $value fees total.
2728
+     */
2729
+    public function set_fees_total( $value ) {
2730
+        $this->set_total_fees( $value );
2731 2731
     }
2732 2732
 
2733 2733
     /**
2734
-	 * Set the invoice fees.
2735
-	 *
2736
-	 * @since 1.0.19
2737
-	 * @param  array $value fees.
2738
-	 */
2739
-	public function set_fees( $value ) {
2734
+     * Set the invoice fees.
2735
+     *
2736
+     * @since 1.0.19
2737
+     * @param  array $value fees.
2738
+     */
2739
+    public function set_fees( $value ) {
2740 2740
 
2741 2741
         $this->set_prop( 'fees', array() );
2742 2742
 
@@ -2754,23 +2754,23 @@  discard block
 block discarded – undo
2754 2754
     }
2755 2755
 
2756 2756
     /**
2757
-	 * Set the invoice taxes.
2758
-	 *
2759
-	 * @since 1.0.19
2760
-	 * @param  array $value taxes.
2761
-	 */
2762
-	public function set_taxes( $value ) {
2763
-		$this->set_prop( 'taxes', $value );
2757
+     * Set the invoice taxes.
2758
+     *
2759
+     * @since 1.0.19
2760
+     * @param  array $value taxes.
2761
+     */
2762
+    public function set_taxes( $value ) {
2763
+        $this->set_prop( 'taxes', $value );
2764 2764
     }
2765 2765
 
2766 2766
     /**
2767
-	 * Set the invoice discounts.
2768
-	 *
2769
-	 * @since 1.0.19
2770
-	 * @param  array $value discounts.
2771
-	 */
2772
-	public function set_discounts( $value ) {
2773
-		$this->set_prop( 'discounts', array() );
2767
+     * Set the invoice discounts.
2768
+     *
2769
+     * @since 1.0.19
2770
+     * @param  array $value discounts.
2771
+     */
2772
+    public function set_discounts( $value ) {
2773
+        $this->set_prop( 'discounts', array() );
2774 2774
 
2775 2775
         // Ensure that we have an array.
2776 2776
         if ( ! is_array( $value ) ) {
@@ -2785,12 +2785,12 @@  discard block
 block discarded – undo
2785 2785
     }
2786 2786
 
2787 2787
     /**
2788
-	 * Set the invoice items.
2789
-	 *
2790
-	 * @since 1.0.19
2791
-	 * @param  GetPaid_Form_Item[] $value items.
2792
-	 */
2793
-	public function set_items( $value ) {
2788
+     * Set the invoice items.
2789
+     *
2790
+     * @since 1.0.19
2791
+     * @param  GetPaid_Form_Item[] $value items.
2792
+     */
2793
+    public function set_items( $value ) {
2794 2794
 
2795 2795
         // Remove existing items.
2796 2796
         $this->set_prop( 'items', array() );
@@ -2807,95 +2807,95 @@  discard block
 block discarded – undo
2807 2807
     }
2808 2808
 
2809 2809
     /**
2810
-	 * Set the payment form.
2811
-	 *
2812
-	 * @since 1.0.19
2813
-	 * @param  int $value payment form.
2814
-	 */
2815
-	public function set_payment_form( $value ) {
2816
-		$this->set_prop( 'payment_form', $value );
2810
+     * Set the payment form.
2811
+     *
2812
+     * @since 1.0.19
2813
+     * @param  int $value payment form.
2814
+     */
2815
+    public function set_payment_form( $value ) {
2816
+        $this->set_prop( 'payment_form', $value );
2817 2817
     }
2818 2818
 
2819 2819
     /**
2820
-	 * Set the submission id.
2821
-	 *
2822
-	 * @since 1.0.19
2823
-	 * @param  string $value submission id.
2824
-	 */
2825
-	public function set_submission_id( $value ) {
2826
-		$this->set_prop( 'submission_id', $value );
2820
+     * Set the submission id.
2821
+     *
2822
+     * @since 1.0.19
2823
+     * @param  string $value submission id.
2824
+     */
2825
+    public function set_submission_id( $value ) {
2826
+        $this->set_prop( 'submission_id', $value );
2827 2827
     }
2828 2828
 
2829 2829
     /**
2830
-	 * Set the discount code.
2831
-	 *
2832
-	 * @since 1.0.19
2833
-	 * @param  string $value discount code.
2834
-	 */
2835
-	public function set_discount_code( $value ) {
2836
-		$this->set_prop( 'discount_code', $value );
2830
+     * Set the discount code.
2831
+     *
2832
+     * @since 1.0.19
2833
+     * @param  string $value discount code.
2834
+     */
2835
+    public function set_discount_code( $value ) {
2836
+        $this->set_prop( 'discount_code', $value );
2837 2837
     }
2838 2838
 
2839 2839
     /**
2840
-	 * Set the gateway.
2841
-	 *
2842
-	 * @since 1.0.19
2843
-	 * @param  string $value gateway.
2844
-	 */
2845
-	public function set_gateway( $value ) {
2846
-		$this->set_prop( 'gateway', $value );
2840
+     * Set the gateway.
2841
+     *
2842
+     * @since 1.0.19
2843
+     * @param  string $value gateway.
2844
+     */
2845
+    public function set_gateway( $value ) {
2846
+        $this->set_prop( 'gateway', $value );
2847 2847
     }
2848 2848
 
2849 2849
     /**
2850
-	 * Set the transaction id.
2851
-	 *
2852
-	 * @since 1.0.19
2853
-	 * @param  string $value transaction id.
2854
-	 */
2855
-	public function set_transaction_id( $value ) {
2856
-		if ( ! empty( $value ) ) {
2857
-			$this->set_prop( 'transaction_id', $value );
2858
-		}
2850
+     * Set the transaction id.
2851
+     *
2852
+     * @since 1.0.19
2853
+     * @param  string $value transaction id.
2854
+     */
2855
+    public function set_transaction_id( $value ) {
2856
+        if ( ! empty( $value ) ) {
2857
+            $this->set_prop( 'transaction_id', $value );
2858
+        }
2859 2859
     }
2860 2860
 
2861 2861
     /**
2862
-	 * Set the currency id.
2863
-	 *
2864
-	 * @since 1.0.19
2865
-	 * @param  string $value currency id.
2866
-	 */
2867
-	public function set_currency( $value ) {
2868
-		$this->set_prop( 'currency', $value );
2862
+     * Set the currency id.
2863
+     *
2864
+     * @since 1.0.19
2865
+     * @param  string $value currency id.
2866
+     */
2867
+    public function set_currency( $value ) {
2868
+        $this->set_prop( 'currency', $value );
2869 2869
     }
2870 2870
 
2871
-	/**
2872
-	 * Set whether to disable taxes.
2873
-	 *
2874
-	 * @since 1.0.19
2875
-	 * @param  bool $value value.
2876
-	 */
2877
-	public function set_disable_taxes( $value ) {
2878
-		$this->set_prop( 'disable_taxes', (bool) $value );
2879
-	}
2871
+    /**
2872
+     * Set whether to disable taxes.
2873
+     *
2874
+     * @since 1.0.19
2875
+     * @param  bool $value value.
2876
+     */
2877
+    public function set_disable_taxes( $value ) {
2878
+        $this->set_prop( 'disable_taxes', (bool) $value );
2879
+    }
2880 2880
 
2881 2881
     /**
2882
-	 * Set the subscription id.
2883
-	 *
2884
-	 * @since 1.0.19
2885
-	 * @param  string $value subscription id.
2886
-	 */
2887
-	public function set_subscription_id( $value ) {
2888
-		$this->set_prop( 'subscription_id', $value );
2889
-	}
2882
+     * Set the subscription id.
2883
+     *
2884
+     * @since 1.0.19
2885
+     * @param  string $value subscription id.
2886
+     */
2887
+    public function set_subscription_id( $value ) {
2888
+        $this->set_prop( 'subscription_id', $value );
2889
+    }
2890 2890
 	
2891
-	/**
2892
-	 * Set the remote subscription id.
2893
-	 *
2894
-	 * @since 1.0.19
2895
-	 * @param  string $value subscription id.
2896
-	 */
2897
-	public function set_remote_subscription_id( $value ) {
2898
-		$this->set_prop( 'remote_subscription_id', $value );
2891
+    /**
2892
+     * Set the remote subscription id.
2893
+     *
2894
+     * @since 1.0.19
2895
+     * @param  string $value subscription id.
2896
+     */
2897
+    public function set_remote_subscription_id( $value ) {
2898
+        $this->set_prop( 'remote_subscription_id', $value );
2899 2899
     }
2900 2900
 
2901 2901
     /*
@@ -2934,12 +2934,12 @@  discard block
 block discarded – undo
2934 2934
      */
2935 2935
     public function is_taxable() {
2936 2936
         return ! $this->get_disable_taxes();
2937
-	}
2937
+    }
2938 2938
 
2939
-	/**
2940
-	 * @deprecated
2941
-	 */
2942
-	public function has_vat() {
2939
+    /**
2940
+     * @deprecated
2941
+     */
2942
+    public function has_vat() {
2943 2943
         global $wpinv_euvat, $wpi_country;
2944 2944
 
2945 2945
         $requires_vat = false;
@@ -2950,17 +2950,17 @@  discard block
 block discarded – undo
2950 2950
         }
2951 2951
 
2952 2952
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2953
-	}
2953
+    }
2954 2954
 
2955
-	/**
2956
-	 * Checks to see if the invoice requires payment.
2957
-	 */
2958
-	public function is_free() {
2955
+    /**
2956
+     * Checks to see if the invoice requires payment.
2957
+     */
2958
+    public function is_free() {
2959 2959
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2960 2960
 
2961
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2962
-			$is_free = false;
2963
-		}
2961
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2962
+            $is_free = false;
2963
+        }
2964 2964
 
2965 2965
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2966 2966
     }
@@ -2971,46 +2971,46 @@  discard block
 block discarded – undo
2971 2971
     public function is_paid() {
2972 2972
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2973 2973
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2974
-	}
2974
+    }
2975 2975
 
2976
-	/**
2976
+    /**
2977 2977
      * Checks if the invoice needs payment.
2978 2978
      */
2979
-	public function needs_payment() {
2980
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2979
+    public function needs_payment() {
2980
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2981 2981
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2982 2982
     }
2983 2983
 
2984
-	/**
2984
+    /**
2985 2985
      * Checks if the invoice is refunded.
2986 2986
      */
2987
-	public function is_refunded() {
2987
+    public function is_refunded() {
2988 2988
         $is_refunded = $this->has_status( 'wpi-refunded' );
2989 2989
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2990
-	}
2990
+    }
2991 2991
 
2992
-	/**
2992
+    /**
2993 2993
      * Checks if the invoice is held.
2994 2994
      */
2995
-	public function is_held() {
2995
+    public function is_held() {
2996 2996
         $is_held = $this->has_status( 'wpi-onhold' );
2997 2997
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2998
-	}
2998
+    }
2999 2999
 
3000
-	/**
3000
+    /**
3001 3001
      * Checks if the invoice is due.
3002 3002
      */
3003
-	public function is_due() {
3004
-		$due_date = $this->get_due_date();
3005
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3006
-	}
3003
+    public function is_due() {
3004
+        $due_date = $this->get_due_date();
3005
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3006
+    }
3007 3007
 
3008
-	/**
3008
+    /**
3009 3009
      * Checks if the invoice is draft.
3010 3010
      */
3011
-	public function is_draft() {
3011
+    public function is_draft() {
3012 3012
         return $this->has_status( 'draft, auto-draft' );
3013
-	}
3013
+    }
3014 3014
 
3015 3015
     /**
3016 3016
      * Checks if the invoice has a given status.
@@ -3018,9 +3018,9 @@  discard block
 block discarded – undo
3018 3018
     public function has_status( $status ) {
3019 3019
         $status = wpinv_parse_list( $status );
3020 3020
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3021
-	}
3021
+    }
3022 3022
 
3023
-	/**
3023
+    /**
3024 3024
      * Checks if the invoice is of a given type.
3025 3025
      */
3026 3026
     public function is_type( $type ) {
@@ -3043,25 +3043,25 @@  discard block
 block discarded – undo
3043 3043
      */
3044 3044
     public function has_free_trial() {
3045 3045
         return $this->is_recurring() && 0 == $this->get_initial_total();
3046
-	}
3046
+    }
3047 3047
 
3048
-	/**
3048
+    /**
3049 3049
      * @deprecated
3050 3050
      */
3051 3051
     public function is_free_trial() {
3052 3052
         $this->has_free_trial();
3053 3053
     }
3054 3054
 
3055
-	/**
3055
+    /**
3056 3056
      * Check if the initial payment if 0.
3057 3057
      *
3058 3058
      */
3059
-	public function is_initial_free() {
3059
+    public function is_initial_free() {
3060 3060
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3061 3061
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3062 3062
     }
3063 3063
 	
3064
-	/**
3064
+    /**
3065 3065
      * Check if the recurring item has a free trial.
3066 3066
      *
3067 3067
      */
@@ -3074,21 +3074,21 @@  discard block
 block discarded – undo
3074 3074
 
3075 3075
         $item = $this->get_recurring( true );
3076 3076
         return $item->has_free_trial();
3077
-	}
3077
+    }
3078 3078
 
3079
-	/**
3079
+    /**
3080 3080
      * Check if the free trial is a result of a discount.
3081 3081
      */
3082 3082
     public function is_free_trial_from_discount() {
3083
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3084
-	}
3083
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3084
+    }
3085 3085
 	
3086
-	/**
3086
+    /**
3087 3087
      * @deprecated
3088 3088
      */
3089 3089
     public function discount_first_payment_only() {
3090 3090
 
3091
-		$discount_code = $this->get_discount_code();
3091
+        $discount_code = $this->get_discount_code();
3092 3092
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3093 3093
             return true;
3094 3094
         }
@@ -3119,28 +3119,28 @@  discard block
 block discarded – undo
3119 3119
      */
3120 3120
     public function add_item( $item ) {
3121 3121
 
3122
-		if ( is_array( $item ) ) {
3123
-			$item = $this->process_array_item( $item );
3124
-		}
3122
+        if ( is_array( $item ) ) {
3123
+            $item = $this->process_array_item( $item );
3124
+        }
3125 3125
 
3126
-		if ( is_numeric( $item ) ) {
3127
-			$item = new GetPaid_Form_Item( $item );
3128
-		}
3126
+        if ( is_numeric( $item ) ) {
3127
+            $item = new GetPaid_Form_Item( $item );
3128
+        }
3129 3129
 
3130 3130
         // Make sure that it is available for purchase.
3131
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3131
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3133 3133
         }
3134 3134
 
3135 3135
         // Do we have a recurring item?
3136
-		if ( $item->is_recurring() ) {
3136
+        if ( $item->is_recurring() ) {
3137 3137
 
3138
-			// An invoice can only contain one recurring item.
3139
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3141
-			}
3138
+            // An invoice can only contain one recurring item.
3139
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3141
+            }
3142 3142
 
3143
-			$this->recurring_item = $item->get_id();
3143
+            $this->recurring_item = $item->get_id();
3144 3144
         }
3145 3145
 
3146 3146
         // Invoice id.
@@ -3151,60 +3151,60 @@  discard block
 block discarded – undo
3151 3151
         $items[ (int) $item->get_id() ] = $item;
3152 3152
 
3153 3153
         $this->set_prop( 'items', $items );
3154
-		return true;
3155
-	}
3154
+        return true;
3155
+    }
3156 3156
 	
3157
-	/**
3158
-	 * Converts an array to an item.
3159
-	 *
3160
-	 * @since 1.0.19
3161
-	 * @return GetPaid_Form_Item
3162
-	 */
3163
-	protected function process_array_item( $array ) {
3164
-
3165
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
-		$item    = new GetPaid_Form_Item( $item_id );
3167
-
3168
-		// Set item data.
3169
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
-			if ( isset( $array[ "item_$key" ] ) ) {
3171
-				$method = "set_$key";
3172
-				$item->$method( $array[ "item_$key" ] );
3173
-			}
3174
-		}
3175
-
3176
-		if ( isset( $array['quantity'] ) ) {
3177
-			$item->set_quantity( $array['quantity'] );
3178
-		}
3179
-
3180
-		// Set item meta.
3181
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
-			$item->set_item_meta( $array['meta'] );
3183
-		}
3184
-
3185
-		return $item;
3186
-
3187
-	}
3188
-
3189
-    /**
3190
-	 * Retrieves a specific item.
3191
-	 *
3192
-	 * @since 1.0.19
3193
-	 */
3194
-	public function get_item( $item_id ) {
3195
-		$items   = $this->get_items();
3196
-		$item_id = (int) $item_id;
3197
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3198
-    }
3199
-
3200
-    /**
3201
-	 * Removes a specific item.
3202
-	 *
3203
-	 * @since 1.0.19
3204
-	 */
3205
-	public function remove_item( $item_id ) {
3206
-		$items   = $this->get_items();
3207
-		$item_id = (int) $item_id;
3157
+    /**
3158
+     * Converts an array to an item.
3159
+     *
3160
+     * @since 1.0.19
3161
+     * @return GetPaid_Form_Item
3162
+     */
3163
+    protected function process_array_item( $array ) {
3164
+
3165
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
+        $item    = new GetPaid_Form_Item( $item_id );
3167
+
3168
+        // Set item data.
3169
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
+            if ( isset( $array[ "item_$key" ] ) ) {
3171
+                $method = "set_$key";
3172
+                $item->$method( $array[ "item_$key" ] );
3173
+            }
3174
+        }
3175
+
3176
+        if ( isset( $array['quantity'] ) ) {
3177
+            $item->set_quantity( $array['quantity'] );
3178
+        }
3179
+
3180
+        // Set item meta.
3181
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
+            $item->set_item_meta( $array['meta'] );
3183
+        }
3184
+
3185
+        return $item;
3186
+
3187
+    }
3188
+
3189
+    /**
3190
+     * Retrieves a specific item.
3191
+     *
3192
+     * @since 1.0.19
3193
+     */
3194
+    public function get_item( $item_id ) {
3195
+        $items   = $this->get_items();
3196
+        $item_id = (int) $item_id;
3197
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3198
+    }
3199
+
3200
+    /**
3201
+     * Removes a specific item.
3202
+     *
3203
+     * @since 1.0.19
3204
+     */
3205
+    public function remove_item( $item_id ) {
3206
+        $items   = $this->get_items();
3207
+        $item_id = (int) $item_id;
3208 3208
 
3209 3209
         if ( $item_id == $this->recurring_item ) {
3210 3210
             $this->recurring_item = null;
@@ -3231,38 +3231,38 @@  discard block
 block discarded – undo
3231 3231
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3232 3232
 
3233 3233
             $amount = $fees[ $fee ]['amount'] += $amount;
3234
-			$fees[ $fee ] = array(
3235
-				'amount'    => $amount,
3234
+            $fees[ $fee ] = array(
3235
+                'amount'    => $amount,
3236 3236
                 'recurring' => (bool) $recurring,
3237 3237
             );
3238 3238
 
3239
-		} else {
3240
-			$fees[ $fee ] = array(
3239
+        } else {
3240
+            $fees[ $fee ] = array(
3241 3241
                 'amount'    => $amount,
3242 3242
                 'recurring' => (bool) $recurring,
3243 3243
             );
3244
-		}
3244
+        }
3245 3245
 
3246 3246
         $this->set_prop( 'fees', $fee );
3247 3247
 
3248 3248
     }
3249 3249
 
3250 3250
     /**
3251
-	 * Retrieves a specific fee.
3252
-	 *
3253
-	 * @since 1.0.19
3254
-	 */
3255
-	public function get_fee( $fee ) {
3251
+     * Retrieves a specific fee.
3252
+     *
3253
+     * @since 1.0.19
3254
+     */
3255
+    public function get_fee( $fee ) {
3256 3256
         $fees = $this->get_fees();
3257
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3257
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3258 3258
     }
3259 3259
 
3260 3260
     /**
3261
-	 * Removes a specific fee.
3262
-	 *
3263
-	 * @since 1.0.19
3264
-	 */
3265
-	public function remove_fee( $fee ) {
3261
+     * Removes a specific fee.
3262
+     *
3263
+     * @since 1.0.19
3264
+     */
3265
+    public function remove_fee( $fee ) {
3266 3266
         $fees = $this->get_fees();
3267 3267
         if ( isset( $fees[ $fee ] ) ) {
3268 3268
             unset( $fees[ $fee ] );
@@ -3285,44 +3285,44 @@  discard block
 block discarded – undo
3285 3285
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3286 3286
 
3287 3287
             $amount = $discounts[ $discount ]['amount'] += $amount;
3288
-			$discounts[ $discount ] = array(
3288
+            $discounts[ $discount ] = array(
3289 3289
                 'amount'    => $amount,
3290 3290
                 'recurring' => (bool) $recurring,
3291 3291
             );
3292 3292
 
3293
-		} else {
3294
-			$discounts[ $discount ] = array(
3293
+        } else {
3294
+            $discounts[ $discount ] = array(
3295 3295
                 'amount'    => $amount,
3296 3296
                 'recurring' => (bool) $recurring,
3297 3297
             );
3298
-		}
3298
+        }
3299 3299
 
3300 3300
         $this->set_prop( 'discounts', $discount );
3301 3301
 
3302 3302
     }
3303 3303
 
3304 3304
     /**
3305
-	 * Retrieves a specific discount.
3306
-	 *
3307
-	 * @since 1.0.19
3308
-	 */
3309
-	public function get_discount( $discount = false ) {
3305
+     * Retrieves a specific discount.
3306
+     *
3307
+     * @since 1.0.19
3308
+     */
3309
+    public function get_discount( $discount = false ) {
3310 3310
 
3311
-		// Backwards compatibilty.
3312
-		if ( empty( $discount ) ) {
3313
-			return $this->get_total_discount();
3314
-		}
3311
+        // Backwards compatibilty.
3312
+        if ( empty( $discount ) ) {
3313
+            return $this->get_total_discount();
3314
+        }
3315 3315
 
3316 3316
         $discounts = $this->get_discounts();
3317
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3317
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3318 3318
     }
3319 3319
 
3320 3320
     /**
3321
-	 * Removes a specific discount.
3322
-	 *
3323
-	 * @since 1.0.19
3324
-	 */
3325
-	public function remove_discount( $discount ) {
3321
+     * Removes a specific discount.
3322
+     *
3323
+     * @since 1.0.19
3324
+     */
3325
+    public function remove_discount( $discount ) {
3326 3326
         $discounts = $this->get_discounts();
3327 3327
         if ( isset( $discounts[ $discount ] ) ) {
3328 3328
             unset( $discounts[ $discount ] );
@@ -3348,44 +3348,44 @@  discard block
 block discarded – undo
3348 3348
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3349 3349
 
3350 3350
             $amount = $taxes[ $tax ]['amount'] += $amount;
3351
-			$taxes[ $tax ] = array(
3351
+            $taxes[ $tax ] = array(
3352 3352
                 'amount'    => $amount,
3353 3353
                 'recurring' => (bool) $recurring,
3354 3354
             );
3355 3355
 
3356
-		} else {
3357
-			$taxes[ $tax ] = array(
3356
+        } else {
3357
+            $taxes[ $tax ] = array(
3358 3358
                 'amount'    => $amount,
3359 3359
                 'recurring' => (bool) $recurring,
3360 3360
             );
3361
-		}
3361
+        }
3362 3362
 
3363 3363
         $this->set_prop( 'taxes', $tax );
3364 3364
 
3365 3365
     }
3366 3366
 
3367 3367
     /**
3368
-	 * Retrieves a specific tax.
3369
-	 *
3370
-	 * @since 1.0.19
3371
-	 */
3372
-	public function get_tax( $tax = null ) {
3368
+     * Retrieves a specific tax.
3369
+     *
3370
+     * @since 1.0.19
3371
+     */
3372
+    public function get_tax( $tax = null ) {
3373 3373
 
3374
-		// Backwards compatility.
3375
-		if ( empty( $tax ) ) {
3376
-			return $this->get_total_tax();
3377
-		}
3374
+        // Backwards compatility.
3375
+        if ( empty( $tax ) ) {
3376
+            return $this->get_total_tax();
3377
+        }
3378 3378
 
3379 3379
         $taxes = $this->get_taxes();
3380
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3380
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3381 3381
     }
3382 3382
 
3383 3383
     /**
3384
-	 * Removes a specific tax.
3385
-	 *
3386
-	 * @since 1.0.19
3387
-	 */
3388
-	public function remove_tax( $tax ) {
3384
+     * Removes a specific tax.
3385
+     *
3386
+     * @since 1.0.19
3387
+     */
3388
+    public function remove_tax( $tax ) {
3389 3389
         $taxes = $this->get_discounts();
3390 3390
         if ( isset( $taxes[ $tax ] ) ) {
3391 3391
             unset( $taxes[ $tax ] );
@@ -3394,160 +3394,160 @@  discard block
 block discarded – undo
3394 3394
     }
3395 3395
 
3396 3396
     /**
3397
-	 * Recalculates the invoice subtotal.
3398
-	 *
3399
-	 * @since 1.0.19
3400
-	 * @return float The recalculated subtotal
3401
-	 */
3402
-	public function recalculate_subtotal() {
3397
+     * Recalculates the invoice subtotal.
3398
+     *
3399
+     * @since 1.0.19
3400
+     * @return float The recalculated subtotal
3401
+     */
3402
+    public function recalculate_subtotal() {
3403 3403
         $items     = $this->get_items();
3404
-		$subtotal  = 0;
3405
-		$recurring = 0;
3404
+        $subtotal  = 0;
3405
+        $recurring = 0;
3406 3406
 
3407 3407
         foreach ( $items as $item ) {
3408
-			$subtotal  += $item->get_sub_total();
3409
-			$recurring += $item->get_recurring_sub_total();
3408
+            $subtotal  += $item->get_sub_total();
3409
+            $recurring += $item->get_recurring_sub_total();
3410 3410
         }
3411 3411
 
3412
-		if ( $this->is_renewal() ) {
3413
-			$this->set_subtotal( $recurring );
3414
-		} else {
3415
-			$this->set_subtotal( $subtotal );
3416
-		}
3412
+        if ( $this->is_renewal() ) {
3413
+            $this->set_subtotal( $recurring );
3414
+        } else {
3415
+            $this->set_subtotal( $subtotal );
3416
+        }
3417 3417
 
3418
-		$this->totals['subtotal'] = array(
3419
-			'initial'   => $subtotal,
3420
-			'recurring' => $recurring,
3421
-		);
3418
+        $this->totals['subtotal'] = array(
3419
+            'initial'   => $subtotal,
3420
+            'recurring' => $recurring,
3421
+        );
3422 3422
 
3423 3423
         return $this->is_renewal() ? $recurring : $subtotal;
3424 3424
     }
3425 3425
 
3426 3426
     /**
3427
-	 * Recalculates the invoice discount total.
3428
-	 *
3429
-	 * @since 1.0.19
3430
-	 * @return float The recalculated discount
3431
-	 */
3432
-	public function recalculate_total_discount() {
3427
+     * Recalculates the invoice discount total.
3428
+     *
3429
+     * @since 1.0.19
3430
+     * @return float The recalculated discount
3431
+     */
3432
+    public function recalculate_total_discount() {
3433 3433
         $discounts = $this->get_discounts();
3434
-		$discount  = 0;
3435
-		$recurring = 0;
3434
+        $discount  = 0;
3435
+        $recurring = 0;
3436 3436
 
3437 3437
         foreach ( $discounts as $data ) {
3438 3438
 
3439
-			if ( $data['recurring'] ) {
3440
-				$recurring += $data['amount'];
3441
-			} else {
3442
-				$discount += $data['amount'];
3443
-			}
3439
+            if ( $data['recurring'] ) {
3440
+                $recurring += $data['amount'];
3441
+            } else {
3442
+                $discount += $data['amount'];
3443
+            }
3444 3444
 
3445
-		}
3445
+        }
3446 3446
 
3447
-		if ( $this->is_renewal() ) {
3448
-			$this->set_total_discount( $recurring );
3449
-		} else {
3450
-			$this->set_total_discount( $discount );
3451
-		}
3447
+        if ( $this->is_renewal() ) {
3448
+            $this->set_total_discount( $recurring );
3449
+        } else {
3450
+            $this->set_total_discount( $discount );
3451
+        }
3452 3452
 
3453
-		$this->totals['discount'] = array(
3454
-			'initial'   => $discount,
3455
-			'recurring' => $recurring,
3456
-		);
3453
+        $this->totals['discount'] = array(
3454
+            'initial'   => $discount,
3455
+            'recurring' => $recurring,
3456
+        );
3457 3457
 
3458
-		return $this->is_renewal() ? $recurring : $discount;
3458
+        return $this->is_renewal() ? $recurring : $discount;
3459 3459
 
3460 3460
     }
3461 3461
 
3462 3462
     /**
3463
-	 * Recalculates the invoice tax total.
3464
-	 *
3465
-	 * @since 1.0.19
3466
-	 * @return float The recalculated tax
3467
-	 */
3468
-	public function recalculate_total_tax() {
3463
+     * Recalculates the invoice tax total.
3464
+     *
3465
+     * @since 1.0.19
3466
+     * @return float The recalculated tax
3467
+     */
3468
+    public function recalculate_total_tax() {
3469 3469
         $taxes     = $this->get_taxes();
3470
-		$tax       = 0;
3471
-		$recurring = 0;
3470
+        $tax       = 0;
3471
+        $recurring = 0;
3472 3472
 
3473 3473
         foreach ( $taxes as $data ) {
3474 3474
 
3475
-			if ( $data['recurring'] ) {
3476
-				$recurring += $data['amount'];
3477
-			} else {
3478
-				$tax += $data['amount'];
3479
-			}
3475
+            if ( $data['recurring'] ) {
3476
+                $recurring += $data['amount'];
3477
+            } else {
3478
+                $tax += $data['amount'];
3479
+            }
3480 3480
 
3481
-		}
3481
+        }
3482 3482
 
3483
-		if ( $this->is_renewal() ) {
3484
-			$this->set_total_tax( $recurring );
3485
-		} else {
3486
-			$this->set_total_tax( $tax );
3487
-		}
3483
+        if ( $this->is_renewal() ) {
3484
+            $this->set_total_tax( $recurring );
3485
+        } else {
3486
+            $this->set_total_tax( $tax );
3487
+        }
3488 3488
 
3489
-		$this->totals['tax'] = array(
3490
-			'initial'   => $tax,
3491
-			'recurring' => $recurring,
3492
-		);
3489
+        $this->totals['tax'] = array(
3490
+            'initial'   => $tax,
3491
+            'recurring' => $recurring,
3492
+        );
3493 3493
 
3494
-		return $this->is_renewal() ? $recurring : $tax;
3494
+        return $this->is_renewal() ? $recurring : $tax;
3495 3495
 
3496 3496
     }
3497 3497
 
3498 3498
     /**
3499
-	 * Recalculates the invoice fees total.
3500
-	 *
3501
-	 * @since 1.0.19
3502
-	 * @return float The recalculated fee
3503
-	 */
3504
-	public function recalculate_total_fees() {
3505
-		$fees      = $this->get_fees();
3506
-		$fee       = 0;
3507
-		$recurring = 0;
3499
+     * Recalculates the invoice fees total.
3500
+     *
3501
+     * @since 1.0.19
3502
+     * @return float The recalculated fee
3503
+     */
3504
+    public function recalculate_total_fees() {
3505
+        $fees      = $this->get_fees();
3506
+        $fee       = 0;
3507
+        $recurring = 0;
3508 3508
 
3509 3509
         foreach ( $fees as $data ) {
3510 3510
 
3511
-			if ( $data['recurring'] ) {
3512
-				$recurring += $data['amount'];
3513
-			} else {
3514
-				$fee += $data['amount'];
3515
-			}
3511
+            if ( $data['recurring'] ) {
3512
+                $recurring += $data['amount'];
3513
+            } else {
3514
+                $fee += $data['amount'];
3515
+            }
3516 3516
 
3517
-		}
3517
+        }
3518 3518
 
3519 3519
         if ( $this->is_renewal() ) {
3520
-			$this->set_total_fees( $recurring );
3521
-		} else {
3522
-			$this->set_total_fees( $fee );
3523
-		}
3520
+            $this->set_total_fees( $recurring );
3521
+        } else {
3522
+            $this->set_total_fees( $fee );
3523
+        }
3524 3524
 
3525
-		$this->totals['fee'] = array(
3526
-			'initial'   => $fee,
3527
-			'recurring' => $recurring,
3528
-		);
3525
+        $this->totals['fee'] = array(
3526
+            'initial'   => $fee,
3527
+            'recurring' => $recurring,
3528
+        );
3529 3529
 
3530 3530
         $this->set_total_fees( $fee );
3531 3531
         return $this->is_renewal() ? $recurring : $fee;
3532 3532
     }
3533 3533
 
3534 3534
     /**
3535
-	 * Recalculates the invoice total.
3536
-	 *
3537
-	 * @since 1.0.19
3535
+     * Recalculates the invoice total.
3536
+     *
3537
+     * @since 1.0.19
3538 3538
      * @return float The invoice total
3539
-	 */
3540
-	public function recalculate_total() {
3539
+     */
3540
+    public function recalculate_total() {
3541 3541
         $this->recalculate_subtotal();
3542 3542
         $this->recalculate_total_fees();
3543 3543
         $this->recalculate_total_discount();
3544 3544
         $this->recalculate_total_tax();
3545
-		return $this->get_total();
3546
-	}
3545
+        return $this->get_total();
3546
+    }
3547 3547
 
3548
-	/**
3549
-	 * @deprecated
3550
-	 */
3548
+    /**
3549
+     * @deprecated
3550
+     */
3551 3551
     public function recalculate_totals( $temp = false ) {
3552 3552
         $this->update_items( $temp );
3553 3553
         $this->save( true );
@@ -3565,7 +3565,7 @@  discard block
 block discarded – undo
3565 3565
      * Adds a note to an invoice.
3566 3566
      *
3567 3567
      * @param string $note The note being added.
3568
-	 * @return int|false The new note's ID on success, false on failure.
3568
+     * @return int|false The new note's ID on success, false on failure.
3569 3569
      *
3570 3570
      */
3571 3571
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3575,21 +3575,21 @@  discard block
 block discarded – undo
3575 3575
             return false;
3576 3576
         }
3577 3577
 
3578
-		$author       = 'System';
3579
-		$author_email = '[email protected]';
3578
+        $author       = 'System';
3579
+        $author_email = '[email protected]';
3580 3580
 
3581
-		// If this is an admin comment or it has been added by the user.
3582
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
-			$user         = get_user_by( 'id', get_current_user_id() );
3581
+        // If this is an admin comment or it has been added by the user.
3582
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
+            $user         = get_user_by( 'id', get_current_user_id() );
3584 3584
             $author       = $user->display_name;
3585 3585
             $author_email = $user->user_email;
3586
-		}
3586
+        }
3587 3587
 
3588
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3588
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3589 3589
 
3590
-	}
3590
+    }
3591 3591
 
3592
-	/**
3592
+    /**
3593 3593
      * Generates a unique key for the invoice.
3594 3594
      */
3595 3595
     public function generate_key( $string = '' ) {
@@ -3609,105 +3609,105 @@  discard block
 block discarded – undo
3609 3609
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3610 3610
         }
3611 3611
 
3612
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3612
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3613 3613
 
3614
-	}
3614
+    }
3615 3615
 
3616
-	/**
3617
-	 * Handle the status transition.
3618
-	 */
3619
-	protected function status_transition() {
3620
-		$status_transition = $this->status_transition;
3616
+    /**
3617
+     * Handle the status transition.
3618
+     */
3619
+    protected function status_transition() {
3620
+        $status_transition = $this->status_transition;
3621 3621
 
3622
-		// Reset status transition variable.
3623
-		$this->status_transition = false;
3622
+        // Reset status transition variable.
3623
+        $this->status_transition = false;
3624 3624
 
3625
-		if ( $status_transition ) {
3626
-			try {
3625
+        if ( $status_transition ) {
3626
+            try {
3627 3627
 
3628
-				// Fire a hook for the status change.
3629
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3628
+                // Fire a hook for the status change.
3629
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3630 3630
 
3631
-				// @deprecated this is deprecated and will be removed in the future.
3632
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3631
+                // @deprecated this is deprecated and will be removed in the future.
3632
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3633 3633
 
3634
-				if ( ! empty( $status_transition['from'] ) ) {
3634
+                if ( ! empty( $status_transition['from'] ) ) {
3635 3635
 
3636
-					/* translators: 1: old invoice status 2: new invoice status */
3637
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3636
+                    /* translators: 1: old invoice status 2: new invoice status */
3637
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3638 3638
 
3639
-					// Fire another hook.
3640
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3639
+                    // Fire another hook.
3640
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3642 3642
 
3643
-					// @deprecated this is deprecated and will be removed in the future.
3644
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3643
+                    // @deprecated this is deprecated and will be removed in the future.
3644
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3645 3645
 
3646
-					// Note the transition occurred.
3647
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3646
+                    // Note the transition occurred.
3647
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3648 3648
 
3649
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3650
-					if (
3651
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3652
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3653
-					) {
3654
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3655
-					}
3656
-				} else {
3657
-					/* translators: %s: new invoice status */
3658
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3649
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3650
+                    if (
3651
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3652
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3653
+                    ) {
3654
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3655
+                    }
3656
+                } else {
3657
+                    /* translators: %s: new invoice status */
3658
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3659 3659
 
3660
-					// Note the transition occurred.
3661
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3660
+                    // Note the transition occurred.
3661
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3662 3662
 
3663
-				}
3664
-			} catch ( Exception $e ) {
3665
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3666
-			}
3667
-		}
3668
-	}
3663
+                }
3664
+            } catch ( Exception $e ) {
3665
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3666
+            }
3667
+        }
3668
+    }
3669 3669
 
3670
-	/**
3671
-	 * Updates an invoice status.
3672
-	 */
3673
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3670
+    /**
3671
+     * Updates an invoice status.
3672
+     */
3673
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3674 3674
 
3675
-		// Fires before updating a status.
3676
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3675
+        // Fires before updating a status.
3676
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3677 3677
 
3678
-		// Update the status.
3679
-		$this->set_status( $new_status, $note, $manual );
3678
+        // Update the status.
3679
+        $this->set_status( $new_status, $note, $manual );
3680 3680
 
3681
-		// Save the order.
3682
-		return $this->save();
3681
+        // Save the order.
3682
+        return $this->save();
3683 3683
 
3684
-	}
3684
+    }
3685 3685
 
3686
-	/**
3687
-	 * @deprecated
3688
-	 */
3689
-	public function refresh_item_ids() {
3686
+    /**
3687
+     * @deprecated
3688
+     */
3689
+    public function refresh_item_ids() {
3690 3690
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3691 3691
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3692
-	}
3692
+    }
3693 3693
 
3694
-	/**
3695
-	 * @deprecated
3696
-	 */
3697
-	public function update_items( $temp = false ) {
3694
+    /**
3695
+     * @deprecated
3696
+     */
3697
+    public function update_items( $temp = false ) {
3698 3698
 
3699
-		$this->set_items( $this->get_items() );
3699
+        $this->set_items( $this->get_items() );
3700 3700
 
3701
-		if ( ! $temp ) {
3702
-			$this->save();
3703
-		}
3701
+        if ( ! $temp ) {
3702
+            $this->save();
3703
+        }
3704 3704
 
3705 3705
         return $this;
3706
-	}
3706
+    }
3707 3707
 
3708
-	/**
3709
-	 * @deprecated
3710
-	 */
3708
+    /**
3709
+     * @deprecated
3710
+     */
3711 3711
     public function validate_discount() {
3712 3712
 
3713 3713
         $discount_code = $this->get_discount_code();
@@ -3723,97 +3723,97 @@  discard block
 block discarded – undo
3723 3723
 
3724 3724
     }
3725 3725
 
3726
-	/**
3727
-	 * Refunds an invoice.
3728
-	 */
3726
+    /**
3727
+     * Refunds an invoice.
3728
+     */
3729 3729
     public function refund() {
3730
-		$this->set_status( 'wpi-refunded' );
3730
+        $this->set_status( 'wpi-refunded' );
3731 3731
         $this->save();
3732
-	}
3732
+    }
3733 3733
 
3734
-	/**
3735
-	 * Marks an invoice as paid.
3736
-	 * 
3737
-	 * @param string $transaction_id
3738
-	 */
3734
+    /**
3735
+     * Marks an invoice as paid.
3736
+     * 
3737
+     * @param string $transaction_id
3738
+     */
3739 3739
     public function mark_paid( $transaction_id = null, $note = '' ) {
3740 3740
 
3741
-		// Set the transaction id.
3742
-		if ( empty( $transaction_id ) ) {
3743
-			$transaction_id = $this->generate_key('trans_');
3744
-		}
3741
+        // Set the transaction id.
3742
+        if ( empty( $transaction_id ) ) {
3743
+            $transaction_id = $this->generate_key('trans_');
3744
+        }
3745 3745
 
3746
-		if ( ! $this->get_transaction_id() ) {
3747
-			$this->set_transaction_id( $transaction_id );
3748
-		}
3746
+        if ( ! $this->get_transaction_id() ) {
3747
+            $this->set_transaction_id( $transaction_id );
3748
+        }
3749 3749
 
3750
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3751
-			return $this->save();
3752
-		}
3750
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3751
+            return $this->save();
3752
+        }
3753 3753
 
3754
-		// Set the completed date.
3755
-		$this->set_date_completed( current_time( 'mysql' ) );
3754
+        // Set the completed date.
3755
+        $this->set_date_completed( current_time( 'mysql' ) );
3756 3756
 
3757
-		// Set the new status.
3758
-		if ( $this->is_renewal() ) {
3757
+        // Set the new status.
3758
+        if ( $this->is_renewal() ) {
3759 3759
 
3760
-			$_note = sprintf(
3761
-				__( 'Renewed via %s', 'invoicing' ),
3762
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3763
-			);
3760
+            $_note = sprintf(
3761
+                __( 'Renewed via %s', 'invoicing' ),
3762
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3763
+            );
3764 3764
 
3765
-			if ( 'none' == $this->get_gateway() ) {
3766
-				$_note = $note;
3767
-			}
3765
+            if ( 'none' == $this->get_gateway() ) {
3766
+                $_note = $note;
3767
+            }
3768 3768
 
3769
-			$this->set_status( 'wpi-renewal', $_note );
3769
+            $this->set_status( 'wpi-renewal', $_note );
3770 3770
 
3771
-		} else {
3771
+        } else {
3772 3772
 
3773
-			$_note = sprintf(
3774
-				__( 'Paid via %s', 'invoicing' ),
3775
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3776
-			);
3773
+            $_note = sprintf(
3774
+                __( 'Paid via %s', 'invoicing' ),
3775
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3776
+            );
3777 3777
 
3778
-			if ( 'none' == $this->get_gateway() ) {
3779
-				$_note = $note;
3780
-			}
3778
+            if ( 'none' == $this->get_gateway() ) {
3779
+                $_note = $note;
3780
+            }
3781 3781
 
3782
-			$this->set_status( 'publish',$_note );
3782
+            $this->set_status( 'publish',$_note );
3783 3783
 
3784
-		}
3784
+        }
3785 3785
 
3786
-		// Set checkout mode.
3787
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3788
-		$this->set_mode( $mode );
3786
+        // Set checkout mode.
3787
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3788
+        $this->set_mode( $mode );
3789 3789
 
3790
-		// Save the invoice.
3790
+        // Save the invoice.
3791 3791
         $this->save();
3792
-	}
3793
-
3794
-
3795
-	/**
3796
-	 * Save data to the database.
3797
-	 *
3798
-	 * @since 1.0.19
3799
-	 * @return int invoice ID
3800
-	 */
3801
-	public function save() {
3802
-		$this->maybe_set_date_paid();
3803
-		$this->maybe_set_key();
3804
-		parent::save();
3805
-		$this->clear_cache();
3806
-		$this->status_transition();
3807
-		return $this->get_id();
3808
-	}
3809
-
3810
-	/**
3792
+    }
3793
+
3794
+
3795
+    /**
3796
+     * Save data to the database.
3797
+     *
3798
+     * @since 1.0.19
3799
+     * @return int invoice ID
3800
+     */
3801
+    public function save() {
3802
+        $this->maybe_set_date_paid();
3803
+        $this->maybe_set_key();
3804
+        parent::save();
3805
+        $this->clear_cache();
3806
+        $this->status_transition();
3807
+        return $this->get_id();
3808
+    }
3809
+
3810
+    /**
3811 3811
      * Clears the subscription's cache.
3812 3812
      */
3813 3813
     public function clear_cache() {
3814
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3815
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3816
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3817
-	}
3814
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3815
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3816
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3817
+    }
3818 3818
 
3819 3819
 }
Please login to merge, or discard this patch.
Spacing   +759 added lines, -759 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136 136
 	 */
137
-    public function __construct( $invoice = false ) {
137
+    public function __construct($invoice = false) {
138 138
 
139
-        parent::__construct( $invoice );
139
+        parent::__construct($invoice);
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
141
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
142
+			$this->set_id($invoice);
143
+		} elseif ($invoice instanceof self) {
144
+			$this->set_id($invoice->get_id());
145
+		} elseif (!empty($invoice->ID)) {
146
+			$this->set_id($invoice->ID);
147
+		} elseif (is_array($invoice)) {
148
+			$this->set_props($invoice);
149 149
 
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
150
+			if (isset($invoice['ID'])) {
151
+				$this->set_id($invoice['ID']);
152 152
 			}
153 153
 
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
154
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
155
+			$this->set_id($invoice_id);
156
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
157
+			$this->set_id($invoice_id);
158
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
159
+			$this->set_id($invoice_id);
160
+		} else {
161
+			$this->set_object_read(true);
162 162
 		}
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
166 166
 
167
-		if ( $this->get_id() > 0 ) {
168
-            $this->post = get_post( $this->get_id() );
167
+		if ($this->get_id() > 0) {
168
+            $this->post = get_post($this->get_id());
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+			$this->data_store->read($this);
171 171
         }
172 172
 
173 173
     }
@@ -182,38 +182,38 @@  discard block
 block discarded – undo
182 182
 	 * @since 1.0.15
183 183
 	 * @return int
184 184
 	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185
+	public static function get_invoice_id_by_field($value, $field = 'key') {
186 186
         global $wpdb;
187 187
 
188 188
 		// Trim the value.
189
-		$value = trim( $value );
189
+		$value = trim($value);
190 190
 
191
-		if ( empty( $value ) ) {
191
+		if (empty($value)) {
192 192
 			return 0;
193 193
 		}
194 194
 
195 195
         // Valid fields.
196
-        $fields = array( 'key', 'number', 'transaction_id' );
196
+        $fields = array('key', 'number', 'transaction_id');
197 197
 
198 198
 		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+		if (empty($field) || !in_array($field, $fields)) {
200 200
 			return 0;
201 201
 		}
202 202
 
203 203
 		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
204
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
205
+		if (false !== $invoice_id) {
206 206
 			return $invoice_id;
207 207
 		}
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
211 211
         $invoice_id  = (int) $wpdb->get_var(
212
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
213 213
         );
214 214
 
215 215
 		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
217 217
 
218 218
 		return $invoice_id;
219 219
     }
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Checks if an invoice key is set.
223 223
      */
224
-    public function _isset( $key ) {
225
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
224
+    public function _isset($key) {
225
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
226 226
     }
227 227
 
228 228
     /*
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param  string $context View or edit context.
248 248
 	 * @return int
249 249
 	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
250
+	public function get_parent_id($context = 'view') {
251
+		return (int) $this->get_prop('parent_id', $context);
252 252
     }
253 253
 
254 254
     /**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260 260
     public function get_parent_payment() {
261
-        return new WPInv_Invoice( $this->get_parent_id() );
261
+        return new WPInv_Invoice($this->get_parent_id());
262 262
     }
263 263
 
264 264
     /**
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param  string $context View or edit context.
279 279
 	 * @return string
280 280
 	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
281
+	public function get_status($context = 'view') {
282
+		return $this->get_prop('status', $context);
283 283
 	}
284 284
 	
285 285
 	/**
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function get_all_statuses() {
292 292
 
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
293
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
294 294
 
295 295
 		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
296
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298 298
 		}
299 299
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
     public function get_status_nicename() {
310 310
 		$statuses = $this->get_all_statuses();
311 311
 
312
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
312
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
313 313
 
314
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
314
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
315 315
     }
316 316
 
317 317
 	/**
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+		$status_label = sanitize_text_field($this->get_status_nicename());
326
+		$status       = sanitize_html_class($this->get_status());
327 327
 
328 328
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329 329
 	}
@@ -335,23 +335,23 @@  discard block
 block discarded – undo
335 335
 	 * @param  string $context View or edit context.
336 336
 	 * @return string
337 337
 	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
338
+	public function get_version($context = 'view') {
339
+		return $this->get_prop('version', $context);
340 340
 	}
341 341
 
342 342
 	/**
343 343
 	 * @deprecated
344 344
 	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
345
+	public function get_invoice_date($format = true) {
346
+		$date      = getpaid_format_date($this->get_date_completed());
347
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
348
+		$formatted = getpaid_format_date($date);
349 349
 
350
-		if ( $format ) {
350
+		if ($format) {
351 351
 			return $formatted;
352 352
 		}
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+		return empty($formatted) ? '' : $date;
355 355
 
356 356
     }
357 357
 
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	 * @param  string $context View or edit context.
363 363
 	 * @return string
364 364
 	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
365
+	public function get_date_created($context = 'view') {
366
+		return $this->get_prop('date_created', $context);
367 367
 	}
368 368
 	
369 369
 	/**
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param  string $context View or edit context.
374 374
 	 * @return string
375 375
 	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
376
+	public function get_created_date($context = 'view') {
377
+		return $this->get_date_created($context);
378 378
     }
379 379
 
380 380
     /**
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	 * @param  string $context View or edit context.
385 385
 	 * @return string
386 386
 	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
388
-        $date = $this->get_date_created( $context );
387
+	public function get_date_created_gmt($context = 'view') {
388
+        $date = $this->get_date_created($context);
389 389
 
390
-        if ( $date ) {
391
-            $date = get_gmt_from_date( $date );
390
+        if ($date) {
391
+            $date = get_gmt_from_date($date);
392 392
         }
393 393
 		return $date;
394 394
     }
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
403
+	public function get_date_modified($context = 'view') {
404
+		return $this->get_prop('date_modified', $context);
405 405
 	}
406 406
 
407 407
 	/**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @param  string $context View or edit context.
412 412
 	 * @return string
413 413
 	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
414
+	public function get_modified_date($context = 'view') {
415
+		return $this->get_date_modified($context);
416 416
     }
417 417
 
418 418
     /**
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	 * @param  string $context View or edit context.
423 423
 	 * @return string
424 424
 	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
426
-        $date = $this->get_date_modified( $context );
425
+	public function get_date_modified_gmt($context = 'view') {
426
+        $date = $this->get_date_modified($context);
427 427
 
428
-        if ( $date ) {
429
-            $date = get_gmt_from_date( $date );
428
+        if ($date) {
429
+            $date = get_gmt_from_date($date);
430 430
         }
431 431
 		return $date;
432 432
     }
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return string
440 440
 	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
441
+	public function get_due_date($context = 'view') {
442
+		return $this->get_prop('due_date', $context);
443 443
     }
444 444
 
445 445
     /**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return string
451 451
 	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
452
+	public function get_date_due($context = 'view') {
453
+		return $this->get_due_date($context);
454 454
     }
455 455
 
456 456
     /**
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	 * @param  string $context View or edit context.
461 461
 	 * @return string
462 462
 	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
464
-        $date = $this->get_due_date( $context );
463
+	public function get_due_date_gmt($context = 'view') {
464
+        $date = $this->get_due_date($context);
465 465
 
466
-        if ( $date ) {
467
-            $date = get_gmt_from_date( $date );
466
+        if ($date) {
467
+            $date = get_gmt_from_date($date);
468 468
         }
469 469
 		return $date;
470 470
     }
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	 * @param  string $context View or edit context.
477 477
 	 * @return string
478 478
 	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
479
+	public function get_gmt_date_due($context = 'view') {
480
+		return $this->get_due_date_gmt($context);
481 481
     }
482 482
 
483 483
     /**
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 	 * @param  string $context View or edit context.
488 488
 	 * @return string
489 489
 	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
490
+	public function get_completed_date($context = 'view') {
491
+		return $this->get_prop('completed_date', $context);
492 492
     }
493 493
 
494 494
     /**
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 	 * @param  string $context View or edit context.
499 499
 	 * @return string
500 500
 	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
501
+	public function get_date_completed($context = 'view') {
502
+		return $this->get_completed_date($context);
503 503
     }
504 504
 
505 505
     /**
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 	 * @param  string $context View or edit context.
510 510
 	 * @return string
511 511
 	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
513
-        $date = $this->get_completed_date( $context );
512
+	public function get_completed_date_gmt($context = 'view') {
513
+        $date = $this->get_completed_date($context);
514 514
 
515
-        if ( $date ) {
516
-            $date = get_gmt_from_date( $date );
515
+        if ($date) {
516
+            $date = get_gmt_from_date($date);
517 517
         }
518 518
 		return $date;
519 519
     }
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
 	 * @param  string $context View or edit context.
526 526
 	 * @return string
527 527
 	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
528
+	public function get_gmt_completed_date($context = 'view') {
529
+		return $this->get_completed_date_gmt($context);
530 530
     }
531 531
 
532 532
     /**
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
 	 * @param  string $context View or edit context.
537 537
 	 * @return string
538 538
 	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
539
+	public function get_number($context = 'view') {
540
+		$number = $this->get_prop('number', $context);
541 541
 
542
-		if ( empty( $number ) ) {
542
+		if (empty($number)) {
543 543
 			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
544
+			$this->set_number($this->generate_number());
545 545
 		}
546 546
 
547 547
 		return $number;
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 	public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558
-        if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
558
+        if (empty($number) || $this->get_id() == $number) {
559
+			$this->set_number($this->generate_number());
560 560
         }
561 561
 
562 562
 	}
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	 * @param  string $context View or edit context.
569 569
 	 * @return string
570 570
 	 */
571
-	public function get_key( $context = 'view' ) {
572
-        return $this->get_prop( 'key', $context );
571
+	public function get_key($context = 'view') {
572
+        return $this->get_prop('key', $context);
573 573
 	}
574 574
 
575 575
 	/**
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 	public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583
-        if ( empty( $key ) ) {
584
-            $key = $this->generate_key( $this->get_type() . '_' );
585
-            $this->set_key( $key );
583
+        if (empty($key)) {
584
+            $key = $this->generate_key($this->get_type() . '_');
585
+            $this->set_key($key);
586 586
         }
587 587
 
588 588
     }
@@ -594,15 +594,15 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context View or edit context.
595 595
 	 * @return string
596 596
 	 */
597
-	public function get_type( $context = 'view' ) {
598
-        return $this->get_prop( 'type', $context );
597
+	public function get_type($context = 'view') {
598
+        return $this->get_prop('type', $context);
599 599
 	}
600 600
 
601 601
 	/**
602 602
 	 * @deprecated
603 603
 	 */
604 604
 	public function get_invoice_quote_type() {
605
-        ucfirst( $this->get_type() );
605
+        ucfirst($this->get_type());
606 606
     }
607 607
 
608 608
     /**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @param  string $context View or edit context.
613 613
 	 * @return string
614 614
 	 */
615
-	public function get_post_type( $context = 'view' ) {
616
-        return $this->get_prop( 'post_type', $context );
615
+	public function get_post_type($context = 'view') {
616
+        return $this->get_prop('post_type', $context);
617 617
     }
618 618
 
619 619
     /**
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 	 * @param  string $context View or edit context.
624 624
 	 * @return string
625 625
 	 */
626
-	public function get_mode( $context = 'view' ) {
627
-        return $this->get_prop( 'mode', $context );
626
+	public function get_mode($context = 'view') {
627
+        return $this->get_prop('mode', $context);
628 628
     }
629 629
 
630 630
     /**
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 	 * @param  string $context View or edit context.
635 635
 	 * @return string
636 636
 	 */
637
-	public function get_path( $context = 'view' ) {
638
-        $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
637
+	public function get_path($context = 'view') {
638
+        $path = $this->get_prop('path', $context);
639
+		$prefix = wpinv_post_name_prefix($this->get_post_type());
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
641
+		if (0 !== strpos($path, $prefix)) {
642
+			$path = sanitize_title($prefix . $this->get_id());
643
+			$this->set_path($path);
644 644
 		}
645 645
 
646 646
 		return $path;
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param  string $context View or edit context.
654 654
 	 * @return string
655 655
 	 */
656
-	public function get_name( $context = 'view' ) {
657
-        return $this->get_prop( 'title', $context );
656
+	public function get_name($context = 'view') {
657
+        return $this->get_prop('title', $context);
658 658
     }
659 659
 
660 660
     /**
@@ -664,8 +664,8 @@  discard block
 block discarded – undo
664 664
 	 * @param  string $context View or edit context.
665 665
 	 * @return string
666 666
 	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
667
+	public function get_title($context = 'view') {
668
+		return $this->get_name($context);
669 669
     }
670 670
 
671 671
     /**
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 	 * @param  string $context View or edit context.
676 676
 	 * @return string
677 677
 	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
678
+	public function get_description($context = 'view') {
679
+		return $this->get_prop('description', $context);
680 680
     }
681 681
 
682 682
     /**
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 	 * @param  string $context View or edit context.
687 687
 	 * @return string
688 688
 	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
689
+	public function get_excerpt($context = 'view') {
690
+		return $this->get_description($context);
691 691
     }
692 692
 
693 693
     /**
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	 * @param  string $context View or edit context.
698 698
 	 * @return string
699 699
 	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
700
+	public function get_summary($context = 'view') {
701
+		return $this->get_description($context);
702 702
     }
703 703
 
704 704
     /**
@@ -708,25 +708,25 @@  discard block
 block discarded – undo
708 708
      * @param  string $context View or edit context.
709 709
 	 * @return array
710 710
 	 */
711
-    public function get_user_info( $context = 'view' ) {
711
+    public function get_user_info($context = 'view') {
712 712
 
713 713
         $user_info = array(
714
-            'user_id'    => $this->get_user_id( $context ),
715
-            'email'      => $this->get_email( $context ),
716
-            'first_name' => $this->get_first_name( $context ),
717
-            'last_name'  => $this->get_last_name( $context ),
718
-            'address'    => $this->get_address( $context ),
719
-            'phone'      => $this->get_phone( $context ),
720
-            'city'       => $this->get_city( $context ),
721
-            'country'    => $this->get_country( $context ),
722
-            'state'      => $this->get_state( $context ),
723
-            'zip'        => $this->get_zip( $context ),
724
-            'company'    => $this->get_company( $context ),
725
-            'vat_number' => $this->get_vat_number( $context ),
726
-            'discount'   => $this->get_discount_code( $context ),
714
+            'user_id'    => $this->get_user_id($context),
715
+            'email'      => $this->get_email($context),
716
+            'first_name' => $this->get_first_name($context),
717
+            'last_name'  => $this->get_last_name($context),
718
+            'address'    => $this->get_address($context),
719
+            'phone'      => $this->get_phone($context),
720
+            'city'       => $this->get_city($context),
721
+            'country'    => $this->get_country($context),
722
+            'state'      => $this->get_state($context),
723
+            'zip'        => $this->get_zip($context),
724
+            'company'    => $this->get_company($context),
725
+            'vat_number' => $this->get_vat_number($context),
726
+            'discount'   => $this->get_discount_code($context),
727 727
 		);
728 728
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
729
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
730 730
 
731 731
     }
732 732
 
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param  string $context View or edit context.
738 738
 	 * @return int
739 739
 	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
740
+	public function get_author($context = 'view') {
741
+		return (int) $this->get_prop('author', $context);
742 742
     }
743 743
 
744 744
     /**
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @param  string $context View or edit context.
749 749
 	 * @return int
750 750
 	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
751
+	public function get_user_id($context = 'view') {
752
+		return $this->get_author($context);
753 753
     }
754 754
 
755 755
      /**
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	 * @param  string $context View or edit context.
760 760
 	 * @return int
761 761
 	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
762
+	public function get_customer_id($context = 'view') {
763
+		return $this->get_author($context);
764 764
     }
765 765
 
766 766
     /**
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 	 * @param  string $context View or edit context.
771 771
 	 * @return string
772 772
 	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
773
+	public function get_ip($context = 'view') {
774
+		return $this->get_prop('user_ip', $context);
775 775
     }
776 776
 
777 777
     /**
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	 * @param  string $context View or edit context.
782 782
 	 * @return string
783 783
 	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
784
+	public function get_user_ip($context = 'view') {
785
+		return $this->get_ip($context);
786 786
     }
787 787
 
788 788
      /**
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 	 * @param  string $context View or edit context.
793 793
 	 * @return string
794 794
 	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
795
+	public function get_customer_ip($context = 'view') {
796
+		return $this->get_ip($context);
797 797
     }
798 798
 
799 799
     /**
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	 * @param  string $context View or edit context.
804 804
 	 * @return string
805 805
 	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
806
+	public function get_first_name($context = 'view') {
807
+		return $this->get_prop('first_name', $context);
808 808
     }
809 809
 
810 810
     /**
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
 	 * @param  string $context View or edit context.
815 815
 	 * @return int
816 816
 	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
817
+	public function get_user_first_name($context = 'view') {
818
+		return $this->get_first_name($context);
819 819
     }
820 820
 
821 821
      /**
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 	 * @param  string $context View or edit context.
826 826
 	 * @return int
827 827
 	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
828
+	public function get_customer_first_name($context = 'view') {
829
+		return $this->get_first_name($context);
830 830
     }
831 831
 
832 832
     /**
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	 * @param  string $context View or edit context.
837 837
 	 * @return string
838 838
 	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
839
+	public function get_last_name($context = 'view') {
840
+		return $this->get_prop('last_name', $context);
841 841
     }
842 842
 
843 843
     /**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 * @param  string $context View or edit context.
848 848
 	 * @return int
849 849
 	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
850
+	public function get_user_last_name($context = 'view') {
851
+		return $this->get_last_name($context);
852 852
     }
853 853
 
854 854
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param  string $context View or edit context.
859 859
 	 * @return int
860 860
 	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
861
+	public function get_customer_last_name($context = 'view') {
862
+		return $this->get_last_name($context);
863 863
     }
864 864
 
865 865
     /**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param  string $context View or edit context.
870 870
 	 * @return string
871 871
 	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
872
+	public function get_full_name($context = 'view') {
873
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
874 874
     }
875 875
 
876 876
     /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param  string $context View or edit context.
881 881
 	 * @return int
882 882
 	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
883
+	public function get_user_full_name($context = 'view') {
884
+		return $this->get_full_name($context);
885 885
     }
886 886
 
887 887
     /**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 * @param  string $context View or edit context.
892 892
 	 * @return int
893 893
 	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
894
+	public function get_customer_full_name($context = 'view') {
895
+		return $this->get_full_name($context);
896 896
     }
897 897
 
898 898
     /**
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 	 * @param  string $context View or edit context.
903 903
 	 * @return string
904 904
 	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
905
+	public function get_phone($context = 'view') {
906
+		return $this->get_prop('phone', $context);
907 907
     }
908 908
 
909 909
     /**
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
 	 * @param  string $context View or edit context.
914 914
 	 * @return int
915 915
 	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
916
+	public function get_phone_number($context = 'view') {
917
+		return $this->get_phone($context);
918 918
     }
919 919
 
920 920
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @param  string $context View or edit context.
925 925
 	 * @return int
926 926
 	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
927
+	public function get_user_phone($context = 'view') {
928
+		return $this->get_phone($context);
929 929
     }
930 930
 
931 931
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @param  string $context View or edit context.
936 936
 	 * @return int
937 937
 	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
938
+	public function get_customer_phone($context = 'view') {
939
+		return $this->get_phone($context);
940 940
     }
941 941
 
942 942
     /**
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @param  string $context View or edit context.
947 947
 	 * @return string
948 948
 	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
949
+	public function get_email($context = 'view') {
950
+		return $this->get_prop('email', $context);
951 951
     }
952 952
 
953 953
     /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 	 * @param  string $context View or edit context.
958 958
 	 * @return string
959 959
 	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
960
+	public function get_email_address($context = 'view') {
961
+		return $this->get_email($context);
962 962
     }
963 963
 
964 964
     /**
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	 * @param  string $context View or edit context.
969 969
 	 * @return int
970 970
 	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
971
+	public function get_user_email($context = 'view') {
972
+		return $this->get_email($context);
973 973
     }
974 974
 
975 975
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @param  string $context View or edit context.
980 980
 	 * @return int
981 981
 	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
982
+	public function get_customer_email($context = 'view') {
983
+		return $this->get_email($context);
984 984
     }
985 985
 
986 986
     /**
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
 	 * @param  string $context View or edit context.
991 991
 	 * @return string
992 992
 	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
993
+	public function get_country($context = 'view') {
994
+		$country = $this->get_prop('country', $context);
995
+		return empty($country) ? wpinv_get_default_country() : $country;
996 996
     }
997 997
 
998 998
     /**
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 	 * @param  string $context View or edit context.
1003 1003
 	 * @return int
1004 1004
 	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
1005
+	public function get_user_country($context = 'view') {
1006
+		return $this->get_country($context);
1007 1007
     }
1008 1008
 
1009 1009
     /**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	 * @param  string $context View or edit context.
1014 1014
 	 * @return int
1015 1015
 	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1016
+	public function get_customer_country($context = 'view') {
1017
+		return $this->get_country($context);
1018 1018
     }
1019 1019
 
1020 1020
     /**
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  string $context View or edit context.
1025 1025
 	 * @return string
1026 1026
 	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1027
+	public function get_state($context = 'view') {
1028
+		$state = $this->get_prop('state', $context);
1029
+		return empty($state) ? wpinv_get_default_state() : $state;
1030 1030
     }
1031 1031
 
1032 1032
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @param  string $context View or edit context.
1037 1037
 	 * @return int
1038 1038
 	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1039
+	public function get_user_state($context = 'view') {
1040
+		return $this->get_state($context);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @param  string $context View or edit context.
1048 1048
 	 * @return int
1049 1049
 	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1050
+	public function get_customer_state($context = 'view') {
1051
+		return $this->get_state($context);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
 	 * @param  string $context View or edit context.
1059 1059
 	 * @return string
1060 1060
 	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1061
+	public function get_city($context = 'view') {
1062
+		return $this->get_prop('city', $context);
1063 1063
     }
1064 1064
 
1065 1065
     /**
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	 * @param  string $context View or edit context.
1070 1070
 	 * @return string
1071 1071
 	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1072
+	public function get_user_city($context = 'view') {
1073
+		return $this->get_city($context);
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	 * @param  string $context View or edit context.
1081 1081
 	 * @return string
1082 1082
 	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1083
+	public function get_customer_city($context = 'view') {
1084
+		return $this->get_city($context);
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 	 * @param  string $context View or edit context.
1092 1092
 	 * @return string
1093 1093
 	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1094
+	public function get_zip($context = 'view') {
1095
+		return $this->get_prop('zip', $context);
1096 1096
     }
1097 1097
 
1098 1098
     /**
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 	 * @param  string $context View or edit context.
1103 1103
 	 * @return string
1104 1104
 	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1105
+	public function get_user_zip($context = 'view') {
1106
+		return $this->get_zip($context);
1107 1107
     }
1108 1108
 
1109 1109
     /**
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 	 * @param  string $context View or edit context.
1114 1114
 	 * @return string
1115 1115
 	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1116
+	public function get_customer_zip($context = 'view') {
1117
+		return $this->get_zip($context);
1118 1118
     }
1119 1119
 
1120 1120
     /**
@@ -1124,8 +1124,8 @@  discard block
 block discarded – undo
1124 1124
 	 * @param  string $context View or edit context.
1125 1125
 	 * @return string
1126 1126
 	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1127
+	public function get_company($context = 'view') {
1128
+		return $this->get_prop('company', $context);
1129 1129
     }
1130 1130
 
1131 1131
     /**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param  string $context View or edit context.
1136 1136
 	 * @return string
1137 1137
 	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1138
+	public function get_user_company($context = 'view') {
1139
+		return $this->get_company($context);
1140 1140
     }
1141 1141
 
1142 1142
     /**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param  string $context View or edit context.
1147 1147
 	 * @return string
1148 1148
 	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1149
+	public function get_customer_company($context = 'view') {
1150
+		return $this->get_company($context);
1151 1151
     }
1152 1152
 
1153 1153
     /**
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	 * @param  string $context View or edit context.
1158 1158
 	 * @return string
1159 1159
 	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1160
+	public function get_vat_number($context = 'view') {
1161
+		return $this->get_prop('vat_number', $context);
1162 1162
     }
1163 1163
 
1164 1164
     /**
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 	 * @param  string $context View or edit context.
1169 1169
 	 * @return string
1170 1170
 	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1171
+	public function get_user_vat_number($context = 'view') {
1172
+		return $this->get_vat_number($context);
1173 1173
     }
1174 1174
 
1175 1175
     /**
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 * @param  string $context View or edit context.
1180 1180
 	 * @return string
1181 1181
 	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1182
+	public function get_customer_vat_number($context = 'view') {
1183
+		return $this->get_vat_number($context);
1184 1184
     }
1185 1185
 
1186 1186
     /**
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 	 * @param  string $context View or edit context.
1191 1191
 	 * @return string
1192 1192
 	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1193
+	public function get_vat_rate($context = 'view') {
1194
+		return $this->get_prop('vat_rate', $context);
1195 1195
     }
1196 1196
 
1197 1197
     /**
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
 	 * @param  string $context View or edit context.
1202 1202
 	 * @return string
1203 1203
 	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1204
+	public function get_user_vat_rate($context = 'view') {
1205
+		return $this->get_vat_rate($context);
1206 1206
     }
1207 1207
 
1208 1208
     /**
@@ -1212,8 +1212,8 @@  discard block
 block discarded – undo
1212 1212
 	 * @param  string $context View or edit context.
1213 1213
 	 * @return string
1214 1214
 	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1215
+	public function get_customer_vat_rate($context = 'view') {
1216
+		return $this->get_vat_rate($context);
1217 1217
     }
1218 1218
 
1219 1219
     /**
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	 * @param  string $context View or edit context.
1224 1224
 	 * @return string
1225 1225
 	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1226
+	public function get_address($context = 'view') {
1227
+		return $this->get_prop('address', $context);
1228 1228
     }
1229 1229
 
1230 1230
     /**
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 	 * @param  string $context View or edit context.
1235 1235
 	 * @return string
1236 1236
 	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1237
+	public function get_user_address($context = 'view') {
1238
+		return $this->get_address($context);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $context View or edit context.
1246 1246
 	 * @return string
1247 1247
 	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1248
+	public function get_customer_address($context = 'view') {
1249
+		return $this->get_address($context);
1250 1250
     }
1251 1251
 
1252 1252
     /**
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 	 * @param  string $context View or edit context.
1257 1257
 	 * @return bool
1258 1258
 	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1259
+	public function get_is_viewed($context = 'view') {
1260
+		return (bool) $this->get_prop('is_viewed', $context);
1261 1261
 	}
1262 1262
 
1263 1263
 	/**
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	 * @param  string $context View or edit context.
1268 1268
 	 * @return bool
1269 1269
 	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1270
+	public function get_email_cc($context = 'view') {
1271
+		return $this->get_prop('email_cc', $context);
1272 1272
 	}
1273 1273
 
1274 1274
 	/**
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 	 * @param  string $context View or edit context.
1279 1279
 	 * @return bool
1280 1280
 	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1281
+	public function get_template($context = 'view') {
1282
+		return $this->get_prop('template', $context);
1283 1283
 	}
1284 1284
 
1285 1285
 	/**
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
 	 * @param  string $context View or edit context.
1290 1290
 	 * @return bool
1291 1291
 	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1292
+	public function get_address_confirmed($context = 'view') {
1293
+		return (bool) $this->get_prop('address_confirmed', $context);
1294 1294
     }
1295 1295
 
1296 1296
     /**
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
 	 * @param  string $context View or edit context.
1301 1301
 	 * @return bool
1302 1302
 	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1303
+	public function get_user_address_confirmed($context = 'view') {
1304
+		return $this->get_address_confirmed($context);
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1311,8 +1311,8 @@  discard block
 block discarded – undo
1311 1311
 	 * @param  string $context View or edit context.
1312 1312
 	 * @return bool
1313 1313
 	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1314
+	public function get_customer_address_confirmed($context = 'view') {
1315
+		return $this->get_address_confirmed($context);
1316 1316
     }
1317 1317
 
1318 1318
     /**
@@ -1322,12 +1322,12 @@  discard block
 block discarded – undo
1322 1322
 	 * @param  string $context View or edit context.
1323 1323
 	 * @return float
1324 1324
 	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1326
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1325
+	public function get_subtotal($context = 'view') {
1326
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1327 1327
 
1328 1328
         // Backwards compatibility.
1329
-        if ( is_bool( $context ) && $context ) {
1330
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1329
+        if (is_bool($context) && $context) {
1330
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1331 1331
         }
1332 1332
 
1333 1333
         return $subtotal;
@@ -1340,8 +1340,8 @@  discard block
 block discarded – undo
1340 1340
 	 * @param  string $context View or edit context.
1341 1341
 	 * @return float
1342 1342
 	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1343
+	public function get_total_discount($context = 'view') {
1344
+		return (float) $this->get_prop('total_discount', $context);
1345 1345
     }
1346 1346
 
1347 1347
     /**
@@ -1351,18 +1351,18 @@  discard block
 block discarded – undo
1351 1351
 	 * @param  string $context View or edit context.
1352 1352
 	 * @return float
1353 1353
 	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1354
+	public function get_total_tax($context = 'view') {
1355
+		return (float) $this->get_prop('total_tax', $context);
1356 1356
 	}
1357 1357
 
1358 1358
 	/**
1359 1359
 	 * @deprecated
1360 1360
 	 */
1361
-	public function get_final_tax( $currency = false ) {
1361
+	public function get_final_tax($currency = false) {
1362 1362
 		$tax = $this->get_total_tax();
1363 1363
 
1364
-        if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1364
+        if ($currency) {
1365
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
 	 * @param  string $context View or edit context.
1376 1376
 	 * @return float
1377 1377
 	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1378
+	public function get_total_fees($context = 'view') {
1379
+		return (float) $this->get_prop('total_fees', $context);
1380 1380
     }
1381 1381
 
1382 1382
     /**
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 	 * @param  string $context View or edit context.
1387 1387
 	 * @return float
1388 1388
 	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1389
+	public function get_fees_total($context = 'view') {
1390
+		return $this->get_total_fees($context);
1391 1391
     }
1392 1392
 
1393 1393
     /**
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	 */
1399 1399
 	public function get_total() {
1400 1400
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1401
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1402 1402
 	}
1403 1403
 	
1404 1404
 	/**
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 	 */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1423
+		if (empty($this->totals)) {
1424 1424
 			$this->recalculate_total();
1425 1425
 		}
1426 1426
 
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		$subtotal = $this->totals['subtotal']['initial'];
1431 1431
 		$total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1433
+		if (0 > $total) {
1434 1434
 			$total = 0;
1435 1435
 		}
1436 1436
 
1437
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1437
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1438 1438
 	}
1439 1439
 
1440 1440
 	/**
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 	 */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1449
+		if (empty($this->totals)) {
1450 1450
 			$this->recalculate_total();
1451 1451
 		}
1452 1452
 
@@ -1456,11 +1456,11 @@  discard block
 block discarded – undo
1456 1456
 		$subtotal = $this->totals['subtotal']['recurring'];
1457 1457
 		$total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1459
+		if (0 > $total) {
1460 1460
 			$total = 0;
1461 1461
 		}
1462 1462
 
1463
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1463
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1464 1464
 	}
1465 1465
 
1466 1466
 	/**
@@ -1471,10 +1471,10 @@  discard block
 block discarded – undo
1471 1471
 	 * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473 1473
 	 */
1474
-    public function get_recurring_details( $field = '', $currency = false ) {
1474
+    public function get_recurring_details($field = '', $currency = false) {
1475 1475
 
1476 1476
 		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1477
+		if (empty($this->totals)) {
1478 1478
 			$this->recalculate_total();
1479 1479
 		}
1480 1480
 
@@ -1494,8 +1494,8 @@  discard block
 block discarded – undo
1494 1494
 			$currency
1495 1495
 		);
1496 1496
 
1497
-        if ( isset( $data[$field] ) ) {
1498
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1497
+        if (isset($data[$field])) {
1498
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1499 1499
         }
1500 1500
 
1501 1501
         return $data;
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
 	 * @param  string $context View or edit context.
1509 1509
 	 * @return array
1510 1510
 	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1511
+	public function get_fees($context = 'view') {
1512
+		return wpinv_parse_list($this->get_prop('fees', $context));
1513 1513
     }
1514 1514
 
1515 1515
     /**
@@ -1519,8 +1519,8 @@  discard block
 block discarded – undo
1519 1519
 	 * @param  string $context View or edit context.
1520 1520
 	 * @return array
1521 1521
 	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1522
+	public function get_discounts($context = 'view') {
1523
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1524 1524
     }
1525 1525
 
1526 1526
     /**
@@ -1530,8 +1530,8 @@  discard block
 block discarded – undo
1530 1530
 	 * @param  string $context View or edit context.
1531 1531
 	 * @return array
1532 1532
 	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1533
+	public function get_taxes($context = 'view') {
1534
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1535 1535
     }
1536 1536
 
1537 1537
     /**
@@ -1541,8 +1541,8 @@  discard block
 block discarded – undo
1541 1541
 	 * @param  string $context View or edit context.
1542 1542
 	 * @return GetPaid_Form_Item[]
1543 1543
 	 */
1544
-	public function get_items( $context = 'view' ) {
1545
-        return $this->get_prop( 'items', $context );
1544
+	public function get_items($context = 'view') {
1545
+        return $this->get_prop('items', $context);
1546 1546
     }
1547 1547
 
1548 1548
     /**
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
 	 * @param  string $context View or edit context.
1553 1553
 	 * @return int
1554 1554
 	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1555
+	public function get_payment_form($context = 'view') {
1556
+		return intval($this->get_prop('payment_form', $context));
1557 1557
     }
1558 1558
 
1559 1559
     /**
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	 * @param  string $context View or edit context.
1564 1564
 	 * @return string
1565 1565
 	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1566
+	public function get_submission_id($context = 'view') {
1567
+		return $this->get_prop('submission_id', $context);
1568 1568
     }
1569 1569
 
1570 1570
     /**
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 	 * @param  string $context View or edit context.
1575 1575
 	 * @return string
1576 1576
 	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1577
+	public function get_discount_code($context = 'view') {
1578
+		return $this->get_prop('discount_code', $context);
1579 1579
     }
1580 1580
 
1581 1581
     /**
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
 	 * @param  string $context View or edit context.
1586 1586
 	 * @return string
1587 1587
 	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1588
+	public function get_gateway($context = 'view') {
1589
+		return $this->get_prop('gateway', $context);
1590 1590
     }
1591 1591
 
1592 1592
     /**
@@ -1596,8 +1596,8 @@  discard block
 block discarded – undo
1596 1596
 	 * @return string
1597 1597
 	 */
1598 1598
     public function get_gateway_title() {
1599
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1599
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1600
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1601 1601
     }
1602 1602
 
1603 1603
     /**
@@ -1607,8 +1607,8 @@  discard block
 block discarded – undo
1607 1607
 	 * @param  string $context View or edit context.
1608 1608
 	 * @return string
1609 1609
 	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1610
+	public function get_transaction_id($context = 'view') {
1611
+		return $this->get_prop('transaction_id', $context);
1612 1612
     }
1613 1613
 
1614 1614
     /**
@@ -1618,9 +1618,9 @@  discard block
 block discarded – undo
1618 1618
 	 * @param  string $context View or edit context.
1619 1619
 	 * @return string
1620 1620
 	 */
1621
-	public function get_currency( $context = 'view' ) {
1622
-        $currency = $this->get_prop( 'currency', $context );
1623
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1621
+	public function get_currency($context = 'view') {
1622
+        $currency = $this->get_prop('currency', $context);
1623
+        return empty($currency) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 	 * @param  string $context View or edit context.
1631 1631
 	 * @return bool
1632 1632
 	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1634
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1633
+	public function get_disable_taxes($context = 'view') {
1634
+        return (bool) $this->get_prop('disable_taxes', $context);
1635 1635
     }
1636 1636
 
1637 1637
     /**
@@ -1641,8 +1641,8 @@  discard block
 block discarded – undo
1641 1641
 	 * @param  string $context View or edit context.
1642 1642
 	 * @return int
1643 1643
 	 */
1644
-    public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1644
+    public function get_subscription_id($context = 'view') {
1645
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1646 1646
 	}
1647 1647
 
1648 1648
 	/**
@@ -1652,12 +1652,12 @@  discard block
 block discarded – undo
1652 1652
 	 * @param  string $context View or edit context.
1653 1653
 	 * @return int
1654 1654
 	 */
1655
-    public function get_remote_subscription_id( $context = 'view' ) {
1656
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1655
+    public function get_remote_subscription_id($context = 'view') {
1656
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1657 1657
 
1658
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1658
+        if (empty($subscription_id) && $this->is_renewal()) {
1659 1659
             $parent = $this->get_parent();
1660
-            return $parent->get_subscription_id( $context );
1660
+            return $parent->get_subscription_id($context);
1661 1661
         }
1662 1662
 
1663 1663
         return $subscription_id;
@@ -1670,20 +1670,20 @@  discard block
 block discarded – undo
1670 1670
 	 * @param  string $context View or edit context.
1671 1671
 	 * @return array
1672 1672
 	 */
1673
-    public function get_payment_meta( $context = 'view' ) {
1673
+    public function get_payment_meta($context = 'view') {
1674 1674
 
1675 1675
         return array(
1676
-            'price'        => $this->get_total( $context ),
1677
-            'date'         => $this->get_date_created( $context ),
1678
-            'user_email'   => $this->get_email( $context ),
1679
-            'invoice_key'  => $this->get_key( $context ),
1680
-            'currency'     => $this->get_currency( $context ),
1681
-            'items'        => $this->get_items( $context ),
1682
-            'user_info'    => $this->get_user_info( $context ),
1676
+            'price'        => $this->get_total($context),
1677
+            'date'         => $this->get_date_created($context),
1678
+            'user_email'   => $this->get_email($context),
1679
+            'invoice_key'  => $this->get_key($context),
1680
+            'currency'     => $this->get_currency($context),
1681
+            'items'        => $this->get_items($context),
1682
+            'user_info'    => $this->get_user_info($context),
1683 1683
             'cart_details' => $this->get_cart_details(),
1684
-            'status'       => $this->get_status( $context ),
1685
-            'fees'         => $this->get_fees( $context ),
1686
-            'taxes'        => $this->get_taxes( $context ),
1684
+            'status'       => $this->get_status($context),
1685
+            'fees'         => $this->get_fees($context),
1686
+            'taxes'        => $this->get_taxes($context),
1687 1687
         );
1688 1688
 
1689 1689
     }
@@ -1698,9 +1698,9 @@  discard block
 block discarded – undo
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701
-        foreach ( $items as $item_id => $item ) {
1701
+        foreach ($items as $item_id => $item) {
1702 1702
 			$item->invoice_id = $this->get_id();
1703
-            $cart_details[]   = $item->prepare_data_for_saving();
1703
+            $cart_details[] = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
@@ -1711,11 +1711,11 @@  discard block
 block discarded – undo
1711 1711
 	 *
1712 1712
 	 * @return null|GetPaid_Form_Item|int
1713 1713
 	 */
1714
-	public function get_recurring( $object = false ) {
1714
+	public function get_recurring($object = false) {
1715 1715
 
1716 1716
 		// Are we returning an object?
1717
-        if ( $object ) {
1718
-            return $this->get_item( $this->recurring_item );
1717
+        if ($object) {
1718
+            return $this->get_item($this->recurring_item);
1719 1719
         }
1720 1720
 
1721 1721
         return $this->recurring_item;
@@ -1730,15 +1730,15 @@  discard block
 block discarded – undo
1730 1730
 	public function get_subscription_name() {
1731 1731
 
1732 1732
 		// Retrieve the recurring name
1733
-        $item = $this->get_recurring( true );
1733
+        $item = $this->get_recurring(true);
1734 1734
 
1735 1735
 		// Abort if it does not exist.
1736
-        if ( empty( $item ) ) {
1736
+        if (empty($item)) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740 1740
 		// Return the item name.
1741
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1741
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1742 1742
 	}
1743 1743
 
1744 1744
 	/**
@@ -1748,9 +1748,9 @@  discard block
 block discarded – undo
1748 1748
 	 * @return string
1749 1749
 	 */
1750 1750
 	public function get_view_url() {
1751
-        $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1751
+        $invoice_url = get_permalink($this->get_id());
1752
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1753
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1754 1754
 	}
1755 1755
 
1756 1756
 	/**
@@ -1759,25 +1759,25 @@  discard block
 block discarded – undo
1759 1759
 	 * @since 1.0.19
1760 1760
 	 * @return string
1761 1761
 	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1762
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1763 1763
 
1764 1764
 		// Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767 1767
 		// Maybe force ssl.
1768
-        if ( is_ssl() ) {
1769
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1768
+        if (is_ssl()) {
1769
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1770 1770
         }
1771 1771
 
1772 1772
 		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1773
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1774 1774
 
1775 1775
 		// (Maybe?) add a secret
1776
-        if ( $secret ) {
1777
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1776
+        if ($secret) {
1777
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1778 1778
         }
1779 1779
 
1780
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1780
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1781 1781
 	}
1782 1782
 	
1783 1783
 	/**
@@ -1792,14 +1792,14 @@  discard block
 block discarded – undo
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794 1794
 		// Maybe force ssl.
1795
-        if ( is_ssl() ) {
1796
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1795
+        if (is_ssl()) {
1796
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1797 1797
         }
1798 1798
 
1799 1799
 		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1800
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1801 1801
 
1802
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1802
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1803 1803
     }
1804 1804
 
1805 1805
     /**
@@ -1812,8 +1812,8 @@  discard block
 block discarded – undo
1812 1812
 	 * @param  string $context View or edit context.
1813 1813
 	 * @return mixed Value of the given invoice property (if set).
1814 1814
 	 */
1815
-	public function get( $key, $context = 'view' ) {
1816
-        return $this->get_prop( $key, $context );
1815
+	public function get($key, $context = 'view') {
1816
+        return $this->get_prop($key, $context);
1817 1817
 	}
1818 1818
 
1819 1819
     /*
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 	 * @param  mixed $value new value.
1837 1837
 	 * @return mixed Value of the given invoice property (if set).
1838 1838
 	 */
1839
-	public function set( $key, $value ) {
1839
+	public function set($key, $value) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842
-        if ( is_callable( array( $this, $setter ) ) ) {
1843
-            $this->{$setter}( $value );
1842
+        if (is_callable(array($this, $setter))) {
1843
+            $this->{$setter}($value);
1844 1844
         }
1845 1845
 
1846 1846
 	}
@@ -1854,47 +1854,47 @@  discard block
 block discarded – undo
1854 1854
 	 * @param bool   $manual_update Is this a manual status change?.
1855 1855
 	 * @return array details of change.
1856 1856
 	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1857
+	public function set_status($new_status, $note = '', $manual_update = false) {
1858 1858
 		$old_status = $this->get_status();
1859 1859
 
1860 1860
 		$statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1862
+		if (isset($statuses['draft'])) {
1863
+			unset($statuses['draft']);
1864 1864
 		}
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+		$this->set_prop('status', $new_status);
1867 1867
 
1868 1868
 		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1869
+		if (true === $this->object_read) {
1870 1870
 
1871 1871
 			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1872
+			if (!array_key_exists($new_status, $statuses)) {
1873 1873
 				$new_status = 'wpi-pending';
1874 1874
 			}
1875 1875
 
1876 1876
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1877
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1878 1878
 				$old_status = 'wpi-pending';
1879 1879
 			}
1880 1880
 
1881 1881
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1882
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1883 1883
 				$old_status = 'wpi-pending';
1884 1884
 			}
1885 1885
 
1886 1886
 		}
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1888
+		if (true === $this->object_read && $old_status !== $new_status) {
1889 1889
 			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1890
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1891 1891
 				'to'     => $new_status,
1892 1892
 				'note'   => $note,
1893 1893
 				'manual' => (bool) $manual_update,
1894 1894
 			);
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1896
+			if ($manual_update) {
1897
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1898 1898
 			}
1899 1899
 
1900 1900
 			$this->maybe_set_date_paid();
@@ -1917,8 +1917,8 @@  discard block
 block discarded – undo
1917 1917
 	 */
1918 1918
 	public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1920
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1921
+			$this->set_date_completed(current_time('mysql'));
1922 1922
 		}
1923 1923
 	}
1924 1924
 
@@ -1927,11 +1927,11 @@  discard block
 block discarded – undo
1927 1927
 	 *
1928 1928
 	 * @since 1.0.19
1929 1929
 	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1930
+	public function set_parent_id($value) {
1931
+		if ($value && ($value === $this->get_id())) {
1932 1932
 			return;
1933 1933
 		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1934
+		$this->set_prop('parent_id', absint($value));
1935 1935
     }
1936 1936
 
1937 1937
     /**
@@ -1939,8 +1939,8 @@  discard block
 block discarded – undo
1939 1939
 	 *
1940 1940
 	 * @since 1.0.19
1941 1941
 	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1942
+	public function set_version($value) {
1943
+		$this->set_prop('version', $value);
1944 1944
     }
1945 1945
 
1946 1946
     /**
@@ -1950,15 +1950,15 @@  discard block
 block discarded – undo
1950 1950
 	 * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952 1952
 	 */
1953
-	public function set_date_created( $value ) {
1954
-        $date = strtotime( $value );
1953
+	public function set_date_created($value) {
1954
+        $date = strtotime($value);
1955 1955
 
1956
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1957
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1956
+        if ($date && $value !== '0000-00-00 00:00:00') {
1957
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1958 1958
             return true;
1959 1959
         }
1960 1960
 
1961
-        return $this->set_prop( 'date_created', '' );
1961
+        return $this->set_prop('date_created', '');
1962 1962
 
1963 1963
     }
1964 1964
 
@@ -1969,15 +1969,15 @@  discard block
 block discarded – undo
1969 1969
 	 * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971 1971
 	 */
1972
-	public function set_due_date( $value ) {
1973
-        $date = strtotime( $value );
1972
+	public function set_due_date($value) {
1973
+        $date = strtotime($value);
1974 1974
 
1975
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1976
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1975
+        if ($date && $value !== '0000-00-00 00:00:00') {
1976
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+		$this->set_prop('due_date', '');
1981 1981
         return false;
1982 1982
 
1983 1983
     }
@@ -1988,8 +1988,8 @@  discard block
 block discarded – undo
1988 1988
 	 * @since 1.0.19
1989 1989
 	 * @param  string $value New name.
1990 1990
 	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1991
+	public function set_date_due($value) {
1992
+		$this->set_due_date($value);
1993 1993
     }
1994 1994
 
1995 1995
     /**
@@ -1999,15 +1999,15 @@  discard block
 block discarded – undo
1999 1999
 	 * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001 2001
 	 */
2002
-	public function set_completed_date( $value ) {
2003
-        $date = strtotime( $value );
2002
+	public function set_completed_date($value) {
2003
+        $date = strtotime($value);
2004 2004
 
2005
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2006
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2005
+        if ($date && $value !== '0000-00-00 00:00:00') {
2006
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+		$this->set_prop('completed_date', '');
2011 2011
         return false;
2012 2012
 
2013 2013
     }
@@ -2018,8 +2018,8 @@  discard block
 block discarded – undo
2018 2018
 	 * @since 1.0.19
2019 2019
 	 * @param  string $value New name.
2020 2020
 	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2021
+	public function set_date_completed($value) {
2022
+		$this->set_completed_date($value);
2023 2023
     }
2024 2024
 
2025 2025
     /**
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
 	 * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031 2031
 	 */
2032
-	public function set_date_modified( $value ) {
2033
-        $date = strtotime( $value );
2032
+	public function set_date_modified($value) {
2033
+        $date = strtotime($value);
2034 2034
 
2035
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2036
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2035
+        if ($date && $value !== '0000-00-00 00:00:00') {
2036
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+		$this->set_prop('date_modified', '');
2041 2041
         return false;
2042 2042
 
2043 2043
     }
@@ -2048,9 +2048,9 @@  discard block
 block discarded – undo
2048 2048
 	 * @since 1.0.19
2049 2049
 	 * @param  string $value New number.
2050 2050
 	 */
2051
-	public function set_number( $value ) {
2052
-        $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2051
+	public function set_number($value) {
2052
+        $number = sanitize_text_field($value);
2053
+		$this->set_prop('number', $number);
2054 2054
     }
2055 2055
 
2056 2056
     /**
@@ -2059,9 +2059,9 @@  discard block
 block discarded – undo
2059 2059
 	 * @since 1.0.19
2060 2060
 	 * @param  string $value Type.
2061 2061
 	 */
2062
-	public function set_type( $value ) {
2063
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2062
+	public function set_type($value) {
2063
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2064
+		$this->set_prop('type', $type);
2065 2065
 	}
2066 2066
 
2067 2067
     /**
@@ -2070,10 +2070,10 @@  discard block
 block discarded – undo
2070 2070
 	 * @since 1.0.19
2071 2071
 	 * @param  string $value Post type.
2072 2072
 	 */
2073
-	public function set_post_type( $value ) {
2074
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2076
-            $this->set_prop( 'post_type', $value );
2073
+	public function set_post_type($value) {
2074
+        if (getpaid_is_invoice_post_type($value)) {
2075
+			$this->set_type($value);
2076
+            $this->set_prop('post_type', $value);
2077 2077
         }
2078 2078
     }
2079 2079
 
@@ -2083,9 +2083,9 @@  discard block
 block discarded – undo
2083 2083
 	 * @since 1.0.19
2084 2084
 	 * @param  string $value New key.
2085 2085
 	 */
2086
-	public function set_key( $value ) {
2087
-        $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2086
+	public function set_key($value) {
2087
+        $key = sanitize_text_field($value);
2088
+		$this->set_prop('key', $key);
2089 2089
     }
2090 2090
 
2091 2091
     /**
@@ -2094,9 +2094,9 @@  discard block
 block discarded – undo
2094 2094
 	 * @since 1.0.19
2095 2095
 	 * @param  string $value mode.
2096 2096
 	 */
2097
-	public function set_mode( $value ) {
2098
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099
-            $this->set_prop( 'value', $value );
2097
+	public function set_mode($value) {
2098
+        if (!in_array($value, array('live', 'test'))) {
2099
+            $this->set_prop('value', $value);
2100 2100
         }
2101 2101
     }
2102 2102
 
@@ -2106,8 +2106,8 @@  discard block
 block discarded – undo
2106 2106
 	 * @since 1.0.19
2107 2107
 	 * @param  string $value path.
2108 2108
 	 */
2109
-	public function set_path( $value ) {
2110
-        $this->set_prop( 'path', $value );
2109
+	public function set_path($value) {
2110
+        $this->set_prop('path', $value);
2111 2111
     }
2112 2112
 
2113 2113
     /**
@@ -2116,9 +2116,9 @@  discard block
 block discarded – undo
2116 2116
 	 * @since 1.0.19
2117 2117
 	 * @param  string $value New name.
2118 2118
 	 */
2119
-	public function set_name( $value ) {
2120
-        $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2119
+	public function set_name($value) {
2120
+        $name = sanitize_text_field($value);
2121
+		$this->set_prop('name', $name);
2122 2122
     }
2123 2123
 
2124 2124
     /**
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
 	 * @since 1.0.19
2128 2128
 	 * @param  string $value New name.
2129 2129
 	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2130
+	public function set_title($value) {
2131
+		$this->set_name($value);
2132 2132
     }
2133 2133
 
2134 2134
     /**
@@ -2137,9 +2137,9 @@  discard block
 block discarded – undo
2137 2137
 	 * @since 1.0.19
2138 2138
 	 * @param  string $value New description.
2139 2139
 	 */
2140
-	public function set_description( $value ) {
2141
-        $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2140
+	public function set_description($value) {
2141
+        $description = wp_kses_post($value);
2142
+		return $this->set_prop('description', $description);
2143 2143
     }
2144 2144
 
2145 2145
     /**
@@ -2148,8 +2148,8 @@  discard block
 block discarded – undo
2148 2148
 	 * @since 1.0.19
2149 2149
 	 * @param  string $value New description.
2150 2150
 	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2151
+	public function set_excerpt($value) {
2152
+		$this->set_description($value);
2153 2153
     }
2154 2154
 
2155 2155
     /**
@@ -2158,8 +2158,8 @@  discard block
 block discarded – undo
2158 2158
 	 * @since 1.0.19
2159 2159
 	 * @param  string $value New description.
2160 2160
 	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2161
+	public function set_summary($value) {
2162
+		$this->set_description($value);
2163 2163
     }
2164 2164
 
2165 2165
     /**
@@ -2168,12 +2168,12 @@  discard block
 block discarded – undo
2168 2168
 	 * @since 1.0.19
2169 2169
 	 * @param  int $value New author.
2170 2170
 	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2171
+	public function set_author($value) {
2172
+		$user = get_user_by('id', (int) $value);
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2174
+		if ($user && $user->ID) {
2175
+			$this->set_prop('author', $user->ID);
2176
+			$this->set_prop('email', $user->user_email);
2177 2177
 		}
2178 2178
 		
2179 2179
     }
@@ -2184,8 +2184,8 @@  discard block
 block discarded – undo
2184 2184
 	 * @since 1.0.19
2185 2185
 	 * @param  int $value New user id.
2186 2186
 	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2187
+	public function set_user_id($value) {
2188
+		$this->set_author($value);
2189 2189
     }
2190 2190
 
2191 2191
     /**
@@ -2194,8 +2194,8 @@  discard block
 block discarded – undo
2194 2194
 	 * @since 1.0.19
2195 2195
 	 * @param  int $value New user id.
2196 2196
 	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2197
+	public function set_customer_id($value) {
2198
+		$this->set_author($value);
2199 2199
     }
2200 2200
 
2201 2201
     /**
@@ -2204,8 +2204,8 @@  discard block
 block discarded – undo
2204 2204
 	 * @since 1.0.19
2205 2205
 	 * @param  string $value ip address.
2206 2206
 	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2207
+	public function set_ip($value) {
2208
+		$this->set_prop('ip', $value);
2209 2209
     }
2210 2210
 
2211 2211
     /**
@@ -2214,8 +2214,8 @@  discard block
 block discarded – undo
2214 2214
 	 * @since 1.0.19
2215 2215
 	 * @param  string $value ip address.
2216 2216
 	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2217
+	public function set_user_ip($value) {
2218
+		$this->set_ip($value);
2219 2219
     }
2220 2220
 
2221 2221
     /**
@@ -2224,8 +2224,8 @@  discard block
 block discarded – undo
2224 2224
 	 * @since 1.0.19
2225 2225
 	 * @param  string $value first name.
2226 2226
 	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2227
+	public function set_first_name($value) {
2228
+		$this->set_prop('first_name', $value);
2229 2229
     }
2230 2230
 
2231 2231
     /**
@@ -2234,8 +2234,8 @@  discard block
 block discarded – undo
2234 2234
 	 * @since 1.0.19
2235 2235
 	 * @param  string $value first name.
2236 2236
 	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2237
+	public function set_user_first_name($value) {
2238
+		$this->set_first_name($value);
2239 2239
     }
2240 2240
 
2241 2241
     /**
@@ -2244,8 +2244,8 @@  discard block
 block discarded – undo
2244 2244
 	 * @since 1.0.19
2245 2245
 	 * @param  string $value first name.
2246 2246
 	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2247
+	public function set_customer_first_name($value) {
2248
+		$this->set_first_name($value);
2249 2249
     }
2250 2250
 
2251 2251
     /**
@@ -2254,8 +2254,8 @@  discard block
 block discarded – undo
2254 2254
 	 * @since 1.0.19
2255 2255
 	 * @param  string $value last name.
2256 2256
 	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2257
+	public function set_last_name($value) {
2258
+		$this->set_prop('last_name', $value);
2259 2259
     }
2260 2260
 
2261 2261
     /**
@@ -2264,8 +2264,8 @@  discard block
 block discarded – undo
2264 2264
 	 * @since 1.0.19
2265 2265
 	 * @param  string $value last name.
2266 2266
 	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2267
+	public function set_user_last_name($value) {
2268
+		$this->set_last_name($value);
2269 2269
     }
2270 2270
 
2271 2271
     /**
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @since 1.0.19
2275 2275
 	 * @param  string $value last name.
2276 2276
 	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2277
+	public function set_customer_last_name($value) {
2278
+		$this->set_last_name($value);
2279 2279
     }
2280 2280
 
2281 2281
     /**
@@ -2284,8 +2284,8 @@  discard block
 block discarded – undo
2284 2284
 	 * @since 1.0.19
2285 2285
 	 * @param  string $value phone.
2286 2286
 	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2287
+	public function set_phone($value) {
2288
+		$this->set_prop('phone', $value);
2289 2289
     }
2290 2290
 
2291 2291
     /**
@@ -2294,8 +2294,8 @@  discard block
 block discarded – undo
2294 2294
 	 * @since 1.0.19
2295 2295
 	 * @param  string $value phone.
2296 2296
 	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2297
+	public function set_user_phone($value) {
2298
+		$this->set_phone($value);
2299 2299
     }
2300 2300
 
2301 2301
     /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
 	 * @since 1.0.19
2305 2305
 	 * @param  string $value phone.
2306 2306
 	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2307
+	public function set_customer_phone($value) {
2308
+		$this->set_phone($value);
2309 2309
     }
2310 2310
 
2311 2311
     /**
@@ -2314,8 +2314,8 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  string $value phone.
2316 2316
 	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2317
+	public function set_phone_number($value) {
2318
+		$this->set_phone($value);
2319 2319
     }
2320 2320
 
2321 2321
     /**
@@ -2324,8 +2324,8 @@  discard block
 block discarded – undo
2324 2324
 	 * @since 1.0.19
2325 2325
 	 * @param  string $value email address.
2326 2326
 	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2327
+	public function set_email($value) {
2328
+		$this->set_prop('email', $value);
2329 2329
     }
2330 2330
 
2331 2331
     /**
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	 * @since 1.0.19
2335 2335
 	 * @param  string $value email address.
2336 2336
 	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2337
+	public function set_user_email($value) {
2338
+		$this->set_email($value);
2339 2339
     }
2340 2340
 
2341 2341
     /**
@@ -2344,8 +2344,8 @@  discard block
 block discarded – undo
2344 2344
 	 * @since 1.0.19
2345 2345
 	 * @param  string $value email address.
2346 2346
 	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2347
+	public function set_email_address($value) {
2348
+		$this->set_email($value);
2349 2349
     }
2350 2350
 
2351 2351
     /**
@@ -2354,8 +2354,8 @@  discard block
 block discarded – undo
2354 2354
 	 * @since 1.0.19
2355 2355
 	 * @param  string $value email address.
2356 2356
 	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2357
+	public function set_customer_email($value) {
2358
+		$this->set_email($value);
2359 2359
     }
2360 2360
 
2361 2361
     /**
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 	 * @since 1.0.19
2365 2365
 	 * @param  string $value country.
2366 2366
 	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2367
+	public function set_country($value) {
2368
+		$this->set_prop('country', $value);
2369 2369
     }
2370 2370
 
2371 2371
     /**
@@ -2374,8 +2374,8 @@  discard block
 block discarded – undo
2374 2374
 	 * @since 1.0.19
2375 2375
 	 * @param  string $value country.
2376 2376
 	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2377
+	public function set_user_country($value) {
2378
+		$this->set_country($value);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2384,8 +2384,8 @@  discard block
 block discarded – undo
2384 2384
 	 * @since 1.0.19
2385 2385
 	 * @param  string $value country.
2386 2386
 	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2387
+	public function set_customer_country($value) {
2388
+		$this->set_country($value);
2389 2389
     }
2390 2390
 
2391 2391
     /**
@@ -2394,8 +2394,8 @@  discard block
 block discarded – undo
2394 2394
 	 * @since 1.0.19
2395 2395
 	 * @param  string $value state.
2396 2396
 	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2397
+	public function set_state($value) {
2398
+		$this->set_prop('state', $value);
2399 2399
     }
2400 2400
 
2401 2401
     /**
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 	 * @since 1.0.19
2405 2405
 	 * @param  string $value state.
2406 2406
 	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2407
+	public function set_user_state($value) {
2408
+		$this->set_state($value);
2409 2409
     }
2410 2410
 
2411 2411
     /**
@@ -2414,8 +2414,8 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 1.0.19
2415 2415
 	 * @param  string $value state.
2416 2416
 	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2417
+	public function set_customer_state($value) {
2418
+		$this->set_state($value);
2419 2419
     }
2420 2420
 
2421 2421
     /**
@@ -2424,8 +2424,8 @@  discard block
 block discarded – undo
2424 2424
 	 * @since 1.0.19
2425 2425
 	 * @param  string $value city.
2426 2426
 	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2427
+	public function set_city($value) {
2428
+		$this->set_prop('city', $value);
2429 2429
     }
2430 2430
 
2431 2431
     /**
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * @since 1.0.19
2435 2435
 	 * @param  string $value city.
2436 2436
 	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2437
+	public function set_user_city($value) {
2438
+		$this->set_city($value);
2439 2439
     }
2440 2440
 
2441 2441
     /**
@@ -2444,8 +2444,8 @@  discard block
 block discarded – undo
2444 2444
 	 * @since 1.0.19
2445 2445
 	 * @param  string $value city.
2446 2446
 	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2447
+	public function set_customer_city($value) {
2448
+		$this->set_city($value);
2449 2449
     }
2450 2450
 
2451 2451
     /**
@@ -2454,8 +2454,8 @@  discard block
 block discarded – undo
2454 2454
 	 * @since 1.0.19
2455 2455
 	 * @param  string $value zip.
2456 2456
 	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2457
+	public function set_zip($value) {
2458
+		$this->set_prop('zip', $value);
2459 2459
     }
2460 2460
 
2461 2461
     /**
@@ -2464,8 +2464,8 @@  discard block
 block discarded – undo
2464 2464
 	 * @since 1.0.19
2465 2465
 	 * @param  string $value zip.
2466 2466
 	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2467
+	public function set_user_zip($value) {
2468
+		$this->set_zip($value);
2469 2469
     }
2470 2470
 
2471 2471
     /**
@@ -2474,8 +2474,8 @@  discard block
 block discarded – undo
2474 2474
 	 * @since 1.0.19
2475 2475
 	 * @param  string $value zip.
2476 2476
 	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2477
+	public function set_customer_zip($value) {
2478
+		$this->set_zip($value);
2479 2479
     }
2480 2480
 
2481 2481
     /**
@@ -2484,8 +2484,8 @@  discard block
 block discarded – undo
2484 2484
 	 * @since 1.0.19
2485 2485
 	 * @param  string $value company.
2486 2486
 	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2487
+	public function set_company($value) {
2488
+		$this->set_prop('company', $value);
2489 2489
     }
2490 2490
 
2491 2491
     /**
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @since 1.0.19
2495 2495
 	 * @param  string $value company.
2496 2496
 	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2497
+	public function set_user_company($value) {
2498
+		$this->set_company($value);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2504,8 +2504,8 @@  discard block
 block discarded – undo
2504 2504
 	 * @since 1.0.19
2505 2505
 	 * @param  string $value company.
2506 2506
 	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2507
+	public function set_customer_company($value) {
2508
+		$this->set_company($value);
2509 2509
     }
2510 2510
 
2511 2511
     /**
@@ -2514,8 +2514,8 @@  discard block
 block discarded – undo
2514 2514
 	 * @since 1.0.19
2515 2515
 	 * @param  string $value var number.
2516 2516
 	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2517
+	public function set_vat_number($value) {
2518
+		$this->set_prop('vat_number', $value);
2519 2519
     }
2520 2520
 
2521 2521
     /**
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
 	 * @since 1.0.19
2525 2525
 	 * @param  string $value var number.
2526 2526
 	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2527
+	public function set_user_vat_number($value) {
2528
+		$this->set_vat_number($value);
2529 2529
     }
2530 2530
 
2531 2531
     /**
@@ -2534,8 +2534,8 @@  discard block
 block discarded – undo
2534 2534
 	 * @since 1.0.19
2535 2535
 	 * @param  string $value var number.
2536 2536
 	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2537
+	public function set_customer_vat_number($value) {
2538
+		$this->set_vat_number($value);
2539 2539
     }
2540 2540
 
2541 2541
     /**
@@ -2544,8 +2544,8 @@  discard block
 block discarded – undo
2544 2544
 	 * @since 1.0.19
2545 2545
 	 * @param  string $value var rate.
2546 2546
 	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2547
+	public function set_vat_rate($value) {
2548
+		$this->set_prop('vat_rate', $value);
2549 2549
     }
2550 2550
 
2551 2551
     /**
@@ -2554,8 +2554,8 @@  discard block
 block discarded – undo
2554 2554
 	 * @since 1.0.19
2555 2555
 	 * @param  string $value var number.
2556 2556
 	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2557
+	public function set_user_vat_rate($value) {
2558
+		$this->set_vat_rate($value);
2559 2559
     }
2560 2560
 
2561 2561
     /**
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 	 * @since 1.0.19
2565 2565
 	 * @param  string $value var number.
2566 2566
 	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2567
+	public function set_customer_vat_rate($value) {
2568
+		$this->set_vat_rate($value);
2569 2569
     }
2570 2570
 
2571 2571
     /**
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 	 * @since 1.0.19
2575 2575
 	 * @param  string $value address.
2576 2576
 	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2577
+	public function set_address($value) {
2578
+		$this->set_prop('address', $value);
2579 2579
     }
2580 2580
 
2581 2581
     /**
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 	 * @since 1.0.19
2585 2585
 	 * @param  string $value address.
2586 2586
 	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2587
+	public function set_user_address($value) {
2588
+		$this->set_address($value);
2589 2589
     }
2590 2590
 
2591 2591
     /**
@@ -2594,8 +2594,8 @@  discard block
 block discarded – undo
2594 2594
 	 * @since 1.0.19
2595 2595
 	 * @param  string $value address.
2596 2596
 	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2597
+	public function set_customer_address($value) {
2598
+		$this->set_address($value);
2599 2599
     }
2600 2600
 
2601 2601
     /**
@@ -2604,8 +2604,8 @@  discard block
 block discarded – undo
2604 2604
 	 * @since 1.0.19
2605 2605
 	 * @param  int|bool $value confirmed.
2606 2606
 	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2607
+	public function set_is_viewed($value) {
2608
+		$this->set_prop('is_viewed', $value);
2609 2609
 	}
2610 2610
 
2611 2611
 	/**
@@ -2614,8 +2614,8 @@  discard block
 block discarded – undo
2614 2614
 	 * @since 1.0.19
2615 2615
 	 * @param  string $value email recipients.
2616 2616
 	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2617
+	public function set_email_cc($value) {
2618
+		$this->set_prop('email_cc', $value);
2619 2619
 	}
2620 2620
 
2621 2621
 	/**
@@ -2624,9 +2624,9 @@  discard block
 block discarded – undo
2624 2624
 	 * @since 1.0.19
2625 2625
 	 * @param  string $value email recipients.
2626 2626
 	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2627
+	public function set_template($value) {
2628
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2629
+			$this->set_prop('template', $value);
2630 2630
 		}
2631 2631
 	}
2632 2632
 
@@ -2636,8 +2636,8 @@  discard block
 block discarded – undo
2636 2636
 	 * @since 1.0.19
2637 2637
 	 * @param  int|bool $value confirmed.
2638 2638
 	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2639
+	public function set_address_confirmed($value) {
2640
+		$this->set_prop('address_confirmed', $value);
2641 2641
     }
2642 2642
 
2643 2643
     /**
@@ -2646,8 +2646,8 @@  discard block
 block discarded – undo
2646 2646
 	 * @since 1.0.19
2647 2647
 	 * @param  int|bool $value confirmed.
2648 2648
 	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2649
+	public function set_user_address_confirmed($value) {
2650
+		$this->set_address_confirmed($value);
2651 2651
     }
2652 2652
 
2653 2653
     /**
@@ -2656,8 +2656,8 @@  discard block
 block discarded – undo
2656 2656
 	 * @since 1.0.19
2657 2657
 	 * @param  int|bool $value confirmed.
2658 2658
 	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2659
+	public function set_customer_address_confirmed($value) {
2660
+		$this->set_address_confirmed($value);
2661 2661
     }
2662 2662
 
2663 2663
     /**
@@ -2666,8 +2666,8 @@  discard block
 block discarded – undo
2666 2666
 	 * @since 1.0.19
2667 2667
 	 * @param  float $value sub total.
2668 2668
 	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2669
+	public function set_subtotal($value) {
2670
+		$this->set_prop('subtotal', $value);
2671 2671
     }
2672 2672
 
2673 2673
     /**
@@ -2676,8 +2676,8 @@  discard block
 block discarded – undo
2676 2676
 	 * @since 1.0.19
2677 2677
 	 * @param  float $value discount total.
2678 2678
 	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2679
+	public function set_total_discount($value) {
2680
+		$this->set_prop('total_discount', $value);
2681 2681
     }
2682 2682
 
2683 2683
     /**
@@ -2686,8 +2686,8 @@  discard block
 block discarded – undo
2686 2686
 	 * @since 1.0.19
2687 2687
 	 * @param  float $value discount total.
2688 2688
 	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2689
+	public function set_discount($value) {
2690
+		$this->set_total_discount($value);
2691 2691
     }
2692 2692
 
2693 2693
     /**
@@ -2696,8 +2696,8 @@  discard block
 block discarded – undo
2696 2696
 	 * @since 1.0.19
2697 2697
 	 * @param  float $value tax total.
2698 2698
 	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2699
+	public function set_total_tax($value) {
2700
+		$this->set_prop('total_tax', $value);
2701 2701
     }
2702 2702
 
2703 2703
     /**
@@ -2706,8 +2706,8 @@  discard block
 block discarded – undo
2706 2706
 	 * @since 1.0.19
2707 2707
 	 * @param  float $value tax total.
2708 2708
 	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2709
+	public function set_tax_total($value) {
2710
+		$this->set_total_tax($value);
2711 2711
     }
2712 2712
 
2713 2713
     /**
@@ -2716,8 +2716,8 @@  discard block
 block discarded – undo
2716 2716
 	 * @since 1.0.19
2717 2717
 	 * @param  float $value fees total.
2718 2718
 	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2719
+	public function set_total_fees($value) {
2720
+		$this->set_prop('total_fees', $value);
2721 2721
     }
2722 2722
 
2723 2723
     /**
@@ -2726,8 +2726,8 @@  discard block
 block discarded – undo
2726 2726
 	 * @since 1.0.19
2727 2727
 	 * @param  float $value fees total.
2728 2728
 	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2729
+	public function set_fees_total($value) {
2730
+		$this->set_total_fees($value);
2731 2731
     }
2732 2732
 
2733 2733
     /**
@@ -2736,18 +2736,18 @@  discard block
 block discarded – undo
2736 2736
 	 * @since 1.0.19
2737 2737
 	 * @param  array $value fees.
2738 2738
 	 */
2739
-	public function set_fees( $value ) {
2739
+	public function set_fees($value) {
2740 2740
 
2741
-        $this->set_prop( 'fees', array() );
2741
+        $this->set_prop('fees', array());
2742 2742
 
2743 2743
         // Ensure that we have an array.
2744
-        if ( ! is_array( $value ) ) {
2744
+        if (!is_array($value)) {
2745 2745
             return;
2746 2746
         }
2747 2747
 
2748
-        foreach ( $value as $name => $data ) {
2749
-            if ( isset( $data['amount'] ) ) {
2750
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2748
+        foreach ($value as $name => $data) {
2749
+            if (isset($data['amount'])) {
2750
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2751 2751
             }
2752 2752
         }
2753 2753
 
@@ -2759,8 +2759,8 @@  discard block
 block discarded – undo
2759 2759
 	 * @since 1.0.19
2760 2760
 	 * @param  array $value taxes.
2761 2761
 	 */
2762
-	public function set_taxes( $value ) {
2763
-		$this->set_prop( 'taxes', $value );
2762
+	public function set_taxes($value) {
2763
+		$this->set_prop('taxes', $value);
2764 2764
     }
2765 2765
 
2766 2766
     /**
@@ -2769,17 +2769,17 @@  discard block
 block discarded – undo
2769 2769
 	 * @since 1.0.19
2770 2770
 	 * @param  array $value discounts.
2771 2771
 	 */
2772
-	public function set_discounts( $value ) {
2773
-		$this->set_prop( 'discounts', array() );
2772
+	public function set_discounts($value) {
2773
+		$this->set_prop('discounts', array());
2774 2774
 
2775 2775
         // Ensure that we have an array.
2776
-        if ( ! is_array( $value ) ) {
2776
+        if (!is_array($value)) {
2777 2777
             return;
2778 2778
         }
2779 2779
 
2780
-        foreach ( $value as $name => $data ) {
2781
-            if ( isset( $data['amount'] ) ) {
2782
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2780
+        foreach ($value as $name => $data) {
2781
+            if (isset($data['amount'])) {
2782
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2783 2783
             }
2784 2784
         }
2785 2785
     }
@@ -2790,18 +2790,18 @@  discard block
 block discarded – undo
2790 2790
 	 * @since 1.0.19
2791 2791
 	 * @param  GetPaid_Form_Item[] $value items.
2792 2792
 	 */
2793
-	public function set_items( $value ) {
2793
+	public function set_items($value) {
2794 2794
 
2795 2795
         // Remove existing items.
2796
-        $this->set_prop( 'items', array() );
2796
+        $this->set_prop('items', array());
2797 2797
 
2798 2798
         // Ensure that we have an array.
2799
-        if ( ! is_array( $value ) ) {
2799
+        if (!is_array($value)) {
2800 2800
             return;
2801 2801
         }
2802 2802
 
2803
-        foreach ( $value as $item ) {
2804
-            $this->add_item( $item );
2803
+        foreach ($value as $item) {
2804
+            $this->add_item($item);
2805 2805
         }
2806 2806
 
2807 2807
     }
@@ -2812,8 +2812,8 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  int $value payment form.
2814 2814
 	 */
2815
-	public function set_payment_form( $value ) {
2816
-		$this->set_prop( 'payment_form', $value );
2815
+	public function set_payment_form($value) {
2816
+		$this->set_prop('payment_form', $value);
2817 2817
     }
2818 2818
 
2819 2819
     /**
@@ -2822,8 +2822,8 @@  discard block
 block discarded – undo
2822 2822
 	 * @since 1.0.19
2823 2823
 	 * @param  string $value submission id.
2824 2824
 	 */
2825
-	public function set_submission_id( $value ) {
2826
-		$this->set_prop( 'submission_id', $value );
2825
+	public function set_submission_id($value) {
2826
+		$this->set_prop('submission_id', $value);
2827 2827
     }
2828 2828
 
2829 2829
     /**
@@ -2832,8 +2832,8 @@  discard block
 block discarded – undo
2832 2832
 	 * @since 1.0.19
2833 2833
 	 * @param  string $value discount code.
2834 2834
 	 */
2835
-	public function set_discount_code( $value ) {
2836
-		$this->set_prop( 'discount_code', $value );
2835
+	public function set_discount_code($value) {
2836
+		$this->set_prop('discount_code', $value);
2837 2837
     }
2838 2838
 
2839 2839
     /**
@@ -2842,8 +2842,8 @@  discard block
 block discarded – undo
2842 2842
 	 * @since 1.0.19
2843 2843
 	 * @param  string $value gateway.
2844 2844
 	 */
2845
-	public function set_gateway( $value ) {
2846
-		$this->set_prop( 'gateway', $value );
2845
+	public function set_gateway($value) {
2846
+		$this->set_prop('gateway', $value);
2847 2847
     }
2848 2848
 
2849 2849
     /**
@@ -2852,9 +2852,9 @@  discard block
 block discarded – undo
2852 2852
 	 * @since 1.0.19
2853 2853
 	 * @param  string $value transaction id.
2854 2854
 	 */
2855
-	public function set_transaction_id( $value ) {
2856
-		if ( ! empty( $value ) ) {
2857
-			$this->set_prop( 'transaction_id', $value );
2855
+	public function set_transaction_id($value) {
2856
+		if (!empty($value)) {
2857
+			$this->set_prop('transaction_id', $value);
2858 2858
 		}
2859 2859
     }
2860 2860
 
@@ -2864,8 +2864,8 @@  discard block
 block discarded – undo
2864 2864
 	 * @since 1.0.19
2865 2865
 	 * @param  string $value currency id.
2866 2866
 	 */
2867
-	public function set_currency( $value ) {
2868
-		$this->set_prop( 'currency', $value );
2867
+	public function set_currency($value) {
2868
+		$this->set_prop('currency', $value);
2869 2869
     }
2870 2870
 
2871 2871
 	/**
@@ -2874,8 +2874,8 @@  discard block
 block discarded – undo
2874 2874
 	 * @since 1.0.19
2875 2875
 	 * @param  bool $value value.
2876 2876
 	 */
2877
-	public function set_disable_taxes( $value ) {
2878
-		$this->set_prop( 'disable_taxes', (bool) $value );
2877
+	public function set_disable_taxes($value) {
2878
+		$this->set_prop('disable_taxes', (bool) $value);
2879 2879
 	}
2880 2880
 
2881 2881
     /**
@@ -2884,8 +2884,8 @@  discard block
 block discarded – undo
2884 2884
 	 * @since 1.0.19
2885 2885
 	 * @param  string $value subscription id.
2886 2886
 	 */
2887
-	public function set_subscription_id( $value ) {
2888
-		$this->set_prop( 'subscription_id', $value );
2887
+	public function set_subscription_id($value) {
2888
+		$this->set_prop('subscription_id', $value);
2889 2889
 	}
2890 2890
 	
2891 2891
 	/**
@@ -2894,8 +2894,8 @@  discard block
 block discarded – undo
2894 2894
 	 * @since 1.0.19
2895 2895
 	 * @param  string $value subscription id.
2896 2896
 	 */
2897
-	public function set_remote_subscription_id( $value ) {
2898
-		$this->set_prop( 'remote_subscription_id', $value );
2897
+	public function set_remote_subscription_id($value) {
2898
+		$this->set_prop('remote_subscription_id', $value);
2899 2899
     }
2900 2900
 
2901 2901
     /*
@@ -2912,28 +2912,28 @@  discard block
 block discarded – undo
2912 2912
      */
2913 2913
     public function is_parent() {
2914 2914
         $parent = $this->get_parent_id();
2915
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2915
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919 2919
      * Checks if this is a renewal invoice.
2920 2920
      */
2921 2921
     public function is_renewal() {
2922
-        return ! $this->is_parent();
2922
+        return !$this->is_parent();
2923 2923
     }
2924 2924
 
2925 2925
     /**
2926 2926
      * Checks if this is a recurring invoice.
2927 2927
      */
2928 2928
     public function is_recurring() {
2929
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2929
+        return $this->is_renewal() || !empty($this->recurring_item);
2930 2930
     }
2931 2931
 
2932 2932
     /**
2933 2933
      * Checks if this is a taxable invoice.
2934 2934
      */
2935 2935
     public function is_taxable() {
2936
-        return ! $this->get_disable_taxes();
2936
+        return !$this->get_disable_taxes();
2937 2937
 	}
2938 2938
 
2939 2939
 	/**
@@ -2944,57 +2944,57 @@  discard block
 block discarded – undo
2944 2944
 
2945 2945
         $requires_vat = false;
2946 2946
 
2947
-        if ( $this->country ) {
2947
+        if ($this->country) {
2948 2948
             $wpi_country        = $this->country;
2949
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2949
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2950 2950
         }
2951 2951
 
2952
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2952
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2953 2953
 	}
2954 2954
 
2955 2955
 	/**
2956 2956
 	 * Checks to see if the invoice requires payment.
2957 2957
 	 */
2958 2958
 	public function is_free() {
2959
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2959
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2960 2960
 
2961
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2961
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2962 2962
 			$is_free = false;
2963 2963
 		}
2964 2964
 
2965
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2965
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2966 2966
     }
2967 2967
 
2968 2968
     /**
2969 2969
      * Checks if the invoice is paid.
2970 2970
      */
2971 2971
     public function is_paid() {
2972
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2973
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2972
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2973
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2974 2974
 	}
2975 2975
 
2976 2976
 	/**
2977 2977
      * Checks if the invoice needs payment.
2978 2978
      */
2979 2979
 	public function needs_payment() {
2980
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2981
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2980
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2981
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2982 2982
     }
2983 2983
 
2984 2984
 	/**
2985 2985
      * Checks if the invoice is refunded.
2986 2986
      */
2987 2987
 	public function is_refunded() {
2988
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2989
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2988
+        $is_refunded = $this->has_status('wpi-refunded');
2989
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2990 2990
 	}
2991 2991
 
2992 2992
 	/**
2993 2993
      * Checks if the invoice is held.
2994 2994
      */
2995 2995
 	public function is_held() {
2996
-        $is_held = $this->has_status( 'wpi-onhold' );
2997
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2996
+        $is_held = $this->has_status('wpi-onhold');
2997
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2998 2998
 	}
2999 2999
 
3000 3000
 	/**
@@ -3002,30 +3002,30 @@  discard block
 block discarded – undo
3002 3002
      */
3003 3003
 	public function is_due() {
3004 3004
 		$due_date = $this->get_due_date();
3005
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3005
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3006 3006
 	}
3007 3007
 
3008 3008
 	/**
3009 3009
      * Checks if the invoice is draft.
3010 3010
      */
3011 3011
 	public function is_draft() {
3012
-        return $this->has_status( 'draft, auto-draft' );
3012
+        return $this->has_status('draft, auto-draft');
3013 3013
 	}
3014 3014
 
3015 3015
     /**
3016 3016
      * Checks if the invoice has a given status.
3017 3017
      */
3018
-    public function has_status( $status ) {
3019
-        $status = wpinv_parse_list( $status );
3020
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3018
+    public function has_status($status) {
3019
+        $status = wpinv_parse_list($status);
3020
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3021 3021
 	}
3022 3022
 
3023 3023
 	/**
3024 3024
      * Checks if the invoice is of a given type.
3025 3025
      */
3026
-    public function is_type( $type ) {
3027
-        $type = wpinv_parse_list( $type );
3028
-        return in_array( $this->get_type(), $type );
3026
+    public function is_type($type) {
3027
+        $type = wpinv_parse_list($type);
3028
+        return in_array($this->get_type(), $type);
3029 3029
     }
3030 3030
 
3031 3031
     /**
@@ -3057,8 +3057,8 @@  discard block
 block discarded – undo
3057 3057
      *
3058 3058
      */
3059 3059
 	public function is_initial_free() {
3060
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3061
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3060
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3061
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3062 3062
     }
3063 3063
 	
3064 3064
 	/**
@@ -3068,11 +3068,11 @@  discard block
 block discarded – undo
3068 3068
     public function item_has_free_trial() {
3069 3069
 
3070 3070
         // Ensure we have a recurring item.
3071
-        if ( ! $this->is_recurring() ) {
3071
+        if (!$this->is_recurring()) {
3072 3072
             return false;
3073 3073
         }
3074 3074
 
3075
-        $item = $this->get_recurring( true );
3075
+        $item = $this->get_recurring(true);
3076 3076
         return $item->has_free_trial();
3077 3077
 	}
3078 3078
 
@@ -3080,7 +3080,7 @@  discard block
 block discarded – undo
3080 3080
      * Check if the free trial is a result of a discount.
3081 3081
      */
3082 3082
     public function is_free_trial_from_discount() {
3083
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3083
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3084 3084
 	}
3085 3085
 	
3086 3086
 	/**
@@ -3089,17 +3089,17 @@  discard block
 block discarded – undo
3089 3089
     public function discount_first_payment_only() {
3090 3090
 
3091 3091
 		$discount_code = $this->get_discount_code();
3092
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3092
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3093 3093
             return true;
3094 3094
         }
3095 3095
 
3096
-        $discount = wpinv_get_discount_obj( $discount_code );
3096
+        $discount = wpinv_get_discount_obj($discount_code);
3097 3097
 
3098
-        if ( ! $discount || ! $discount->exists() ) {
3098
+        if (!$discount || !$discount->exists()) {
3099 3099
             return true;
3100 3100
         }
3101 3101
 
3102
-        return ! $discount->get_is_recurring();
3102
+        return !$discount->get_is_recurring();
3103 3103
     }
3104 3104
 
3105 3105
     /*
@@ -3117,27 +3117,27 @@  discard block
 block discarded – undo
3117 3117
      * @param GetPaid_Form_Item|array $item
3118 3118
      * @return WP_Error|Bool
3119 3119
      */
3120
-    public function add_item( $item ) {
3120
+    public function add_item($item) {
3121 3121
 
3122
-		if ( is_array( $item ) ) {
3123
-			$item = $this->process_array_item( $item );
3122
+		if (is_array($item)) {
3123
+			$item = $this->process_array_item($item);
3124 3124
 		}
3125 3125
 
3126
-		if ( is_numeric( $item ) ) {
3127
-			$item = new GetPaid_Form_Item( $item );
3126
+		if (is_numeric($item)) {
3127
+			$item = new GetPaid_Form_Item($item);
3128 3128
 		}
3129 3129
 
3130 3130
         // Make sure that it is available for purchase.
3131
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3132
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3131
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3132
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3133 3133
         }
3134 3134
 
3135 3135
         // Do we have a recurring item?
3136
-		if ( $item->is_recurring() ) {
3136
+		if ($item->is_recurring()) {
3137 3137
 
3138 3138
 			// An invoice can only contain one recurring item.
3139
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3140
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3139
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3140
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3141 3141
 			}
3142 3142
 
3143 3143
 			$this->recurring_item = $item->get_id();
@@ -3148,9 +3148,9 @@  discard block
 block discarded – undo
3148 3148
 
3149 3149
         // Retrieve all items.
3150 3150
         $items = $this->get_items();
3151
-        $items[ (int) $item->get_id() ] = $item;
3151
+        $items[(int) $item->get_id()] = $item;
3152 3152
 
3153
-        $this->set_prop( 'items', $items );
3153
+        $this->set_prop('items', $items);
3154 3154
 		return true;
3155 3155
 	}
3156 3156
 	
@@ -3160,26 +3160,26 @@  discard block
 block discarded – undo
3160 3160
 	 * @since 1.0.19
3161 3161
 	 * @return GetPaid_Form_Item
3162 3162
 	 */
3163
-	protected function process_array_item( $array ) {
3163
+	protected function process_array_item($array) {
3164 3164
 
3165
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3166
-		$item    = new GetPaid_Form_Item( $item_id );
3165
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3166
+		$item    = new GetPaid_Form_Item($item_id);
3167 3167
 
3168 3168
 		// Set item data.
3169
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3170
-			if ( isset( $array[ "item_$key" ] ) ) {
3169
+		foreach (array('name', 'price', 'description') as $key) {
3170
+			if (isset($array["item_$key"])) {
3171 3171
 				$method = "set_$key";
3172
-				$item->$method( $array[ "item_$key" ] );
3172
+				$item->$method($array["item_$key"]);
3173 3173
 			}
3174 3174
 		}
3175 3175
 
3176
-		if ( isset( $array['quantity'] ) ) {
3177
-			$item->set_quantity( $array['quantity'] );
3176
+		if (isset($array['quantity'])) {
3177
+			$item->set_quantity($array['quantity']);
3178 3178
 		}
3179 3179
 
3180 3180
 		// Set item meta.
3181
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3182
-			$item->set_item_meta( $array['meta'] );
3181
+		if (isset($array['meta']) && is_array($array['meta'])) {
3182
+			$item->set_item_meta($array['meta']);
3183 3183
 		}
3184 3184
 
3185 3185
 		return $item;
@@ -3191,10 +3191,10 @@  discard block
 block discarded – undo
3191 3191
 	 *
3192 3192
 	 * @since 1.0.19
3193 3193
 	 */
3194
-	public function get_item( $item_id ) {
3194
+	public function get_item($item_id) {
3195 3195
 		$items   = $this->get_items();
3196 3196
 		$item_id = (int) $item_id;
3197
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3197
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3198 3198
     }
3199 3199
 
3200 3200
     /**
@@ -3202,17 +3202,17 @@  discard block
 block discarded – undo
3202 3202
 	 *
3203 3203
 	 * @since 1.0.19
3204 3204
 	 */
3205
-	public function remove_item( $item_id ) {
3205
+	public function remove_item($item_id) {
3206 3206
 		$items   = $this->get_items();
3207 3207
 		$item_id = (int) $item_id;
3208 3208
 
3209
-        if ( $item_id == $this->recurring_item ) {
3209
+        if ($item_id == $this->recurring_item) {
3210 3210
             $this->recurring_item = null;
3211 3211
         }
3212 3212
 
3213
-        if ( isset( $items[ $item_id ] ) ) {
3214
-            unset( $items[ $item_id ] );
3215
-            $this->set_prop( 'items', $items );
3213
+        if (isset($items[$item_id])) {
3214
+            unset($items[$item_id]);
3215
+            $this->set_prop('items', $items);
3216 3216
         }
3217 3217
     }
3218 3218
 
@@ -3223,27 +3223,27 @@  discard block
 block discarded – undo
3223 3223
      * @param float $value
3224 3224
      * @return WP_Error|Bool
3225 3225
      */
3226
-    public function add_fee( $fee, $value, $recurring = false ) {
3226
+    public function add_fee($fee, $value, $recurring = false) {
3227 3227
 
3228
-        $amount = wpinv_sanitize_amount( $value );
3228
+        $amount = wpinv_sanitize_amount($value);
3229 3229
         $fees   = $this->get_fees();
3230 3230
 
3231
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3231
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3232 3232
 
3233
-            $amount = $fees[ $fee ]['amount'] += $amount;
3234
-			$fees[ $fee ] = array(
3233
+            $amount = $fees[$fee]['amount'] += $amount;
3234
+			$fees[$fee] = array(
3235 3235
 				'amount'    => $amount,
3236 3236
                 'recurring' => (bool) $recurring,
3237 3237
             );
3238 3238
 
3239 3239
 		} else {
3240
-			$fees[ $fee ] = array(
3240
+			$fees[$fee] = array(
3241 3241
                 'amount'    => $amount,
3242 3242
                 'recurring' => (bool) $recurring,
3243 3243
             );
3244 3244
 		}
3245 3245
 
3246
-        $this->set_prop( 'fees', $fee );
3246
+        $this->set_prop('fees', $fee);
3247 3247
 
3248 3248
     }
3249 3249
 
@@ -3252,9 +3252,9 @@  discard block
 block discarded – undo
3252 3252
 	 *
3253 3253
 	 * @since 1.0.19
3254 3254
 	 */
3255
-	public function get_fee( $fee ) {
3255
+	public function get_fee($fee) {
3256 3256
         $fees = $this->get_fees();
3257
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3257
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3258 3258
     }
3259 3259
 
3260 3260
     /**
@@ -3262,11 +3262,11 @@  discard block
 block discarded – undo
3262 3262
 	 *
3263 3263
 	 * @since 1.0.19
3264 3264
 	 */
3265
-	public function remove_fee( $fee ) {
3265
+	public function remove_fee($fee) {
3266 3266
         $fees = $this->get_fees();
3267
-        if ( isset( $fees[ $fee ] ) ) {
3268
-            unset( $fees[ $fee ] );
3269
-            $this->set_prop( 'fees', $fees );
3267
+        if (isset($fees[$fee])) {
3268
+            unset($fees[$fee]);
3269
+            $this->set_prop('fees', $fees);
3270 3270
         }
3271 3271
     }
3272 3272
 
@@ -3277,27 +3277,27 @@  discard block
 block discarded – undo
3277 3277
      * @param float $value
3278 3278
      * @return WP_Error|Bool
3279 3279
      */
3280
-    public function add_discount( $discount, $value, $recurring = false ) {
3280
+    public function add_discount($discount, $value, $recurring = false) {
3281 3281
 
3282
-        $amount    = wpinv_sanitize_amount( $value );
3282
+        $amount    = wpinv_sanitize_amount($value);
3283 3283
         $discounts = $this->get_discounts();
3284 3284
 
3285
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3285
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3286 3286
 
3287
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3288
-			$discounts[ $discount ] = array(
3287
+            $amount = $discounts[$discount]['amount'] += $amount;
3288
+			$discounts[$discount] = array(
3289 3289
                 'amount'    => $amount,
3290 3290
                 'recurring' => (bool) $recurring,
3291 3291
             );
3292 3292
 
3293 3293
 		} else {
3294
-			$discounts[ $discount ] = array(
3294
+			$discounts[$discount] = array(
3295 3295
                 'amount'    => $amount,
3296 3296
                 'recurring' => (bool) $recurring,
3297 3297
             );
3298 3298
 		}
3299 3299
 
3300
-        $this->set_prop( 'discounts', $discount );
3300
+        $this->set_prop('discounts', $discount);
3301 3301
 
3302 3302
     }
3303 3303
 
@@ -3306,15 +3306,15 @@  discard block
 block discarded – undo
3306 3306
 	 *
3307 3307
 	 * @since 1.0.19
3308 3308
 	 */
3309
-	public function get_discount( $discount = false ) {
3309
+	public function get_discount($discount = false) {
3310 3310
 
3311 3311
 		// Backwards compatibilty.
3312
-		if ( empty( $discount ) ) {
3312
+		if (empty($discount)) {
3313 3313
 			return $this->get_total_discount();
3314 3314
 		}
3315 3315
 
3316 3316
         $discounts = $this->get_discounts();
3317
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3317
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3318 3318
     }
3319 3319
 
3320 3320
     /**
@@ -3322,11 +3322,11 @@  discard block
 block discarded – undo
3322 3322
 	 *
3323 3323
 	 * @since 1.0.19
3324 3324
 	 */
3325
-	public function remove_discount( $discount ) {
3325
+	public function remove_discount($discount) {
3326 3326
         $discounts = $this->get_discounts();
3327
-        if ( isset( $discounts[ $discount ] ) ) {
3328
-            unset( $discounts[ $discount ] );
3329
-            $this->set_prop( 'discounts', $discounts );
3327
+        if (isset($discounts[$discount])) {
3328
+            unset($discounts[$discount]);
3329
+            $this->set_prop('discounts', $discounts);
3330 3330
         }
3331 3331
     }
3332 3332
 
@@ -3336,31 +3336,31 @@  discard block
 block discarded – undo
3336 3336
      * @param string $tax
3337 3337
      * @param float $value
3338 3338
      */
3339
-    public function add_tax( $tax, $value, $recurring = true ) {
3339
+    public function add_tax($tax, $value, $recurring = true) {
3340 3340
 
3341
-        if ( ! $this->is_taxable() ) {
3341
+        if (!$this->is_taxable()) {
3342 3342
             return;
3343 3343
         }
3344 3344
 
3345
-        $amount    = wpinv_sanitize_amount( $value );
3345
+        $amount    = wpinv_sanitize_amount($value);
3346 3346
         $taxes     = $this->get_taxes();
3347 3347
 
3348
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3348
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3349 3349
 
3350
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3351
-			$taxes[ $tax ] = array(
3350
+            $amount = $taxes[$tax]['amount'] += $amount;
3351
+			$taxes[$tax] = array(
3352 3352
                 'amount'    => $amount,
3353 3353
                 'recurring' => (bool) $recurring,
3354 3354
             );
3355 3355
 
3356 3356
 		} else {
3357
-			$taxes[ $tax ] = array(
3357
+			$taxes[$tax] = array(
3358 3358
                 'amount'    => $amount,
3359 3359
                 'recurring' => (bool) $recurring,
3360 3360
             );
3361 3361
 		}
3362 3362
 
3363
-        $this->set_prop( 'taxes', $tax );
3363
+        $this->set_prop('taxes', $tax);
3364 3364
 
3365 3365
     }
3366 3366
 
@@ -3369,15 +3369,15 @@  discard block
 block discarded – undo
3369 3369
 	 *
3370 3370
 	 * @since 1.0.19
3371 3371
 	 */
3372
-	public function get_tax( $tax = null ) {
3372
+	public function get_tax($tax = null) {
3373 3373
 
3374 3374
 		// Backwards compatility.
3375
-		if ( empty( $tax ) ) {
3375
+		if (empty($tax)) {
3376 3376
 			return $this->get_total_tax();
3377 3377
 		}
3378 3378
 
3379 3379
         $taxes = $this->get_taxes();
3380
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3380
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3381 3381
     }
3382 3382
 
3383 3383
     /**
@@ -3385,11 +3385,11 @@  discard block
 block discarded – undo
3385 3385
 	 *
3386 3386
 	 * @since 1.0.19
3387 3387
 	 */
3388
-	public function remove_tax( $tax ) {
3388
+	public function remove_tax($tax) {
3389 3389
         $taxes = $this->get_discounts();
3390
-        if ( isset( $taxes[ $tax ] ) ) {
3391
-            unset( $taxes[ $tax ] );
3392
-            $this->set_prop( 'taxes', $taxes );
3390
+        if (isset($taxes[$tax])) {
3391
+            unset($taxes[$tax]);
3392
+            $this->set_prop('taxes', $taxes);
3393 3393
         }
3394 3394
     }
3395 3395
 
@@ -3400,19 +3400,19 @@  discard block
 block discarded – undo
3400 3400
 	 * @return float The recalculated subtotal
3401 3401
 	 */
3402 3402
 	public function recalculate_subtotal() {
3403
-        $items     = $this->get_items();
3403
+        $items = $this->get_items();
3404 3404
 		$subtotal  = 0;
3405 3405
 		$recurring = 0;
3406 3406
 
3407
-        foreach ( $items as $item ) {
3407
+        foreach ($items as $item) {
3408 3408
 			$subtotal  += $item->get_sub_total();
3409 3409
 			$recurring += $item->get_recurring_sub_total();
3410 3410
         }
3411 3411
 
3412
-		if ( $this->is_renewal() ) {
3413
-			$this->set_subtotal( $recurring );
3412
+		if ($this->is_renewal()) {
3413
+			$this->set_subtotal($recurring);
3414 3414
 		} else {
3415
-			$this->set_subtotal( $subtotal );
3415
+			$this->set_subtotal($subtotal);
3416 3416
 		}
3417 3417
 
3418 3418
 		$this->totals['subtotal'] = array(
@@ -3434,9 +3434,9 @@  discard block
 block discarded – undo
3434 3434
 		$discount  = 0;
3435 3435
 		$recurring = 0;
3436 3436
 
3437
-        foreach ( $discounts as $data ) {
3437
+        foreach ($discounts as $data) {
3438 3438
 
3439
-			if ( $data['recurring'] ) {
3439
+			if ($data['recurring']) {
3440 3440
 				$recurring += $data['amount'];
3441 3441
 			} else {
3442 3442
 				$discount += $data['amount'];
@@ -3444,10 +3444,10 @@  discard block
 block discarded – undo
3444 3444
 
3445 3445
 		}
3446 3446
 
3447
-		if ( $this->is_renewal() ) {
3448
-			$this->set_total_discount( $recurring );
3447
+		if ($this->is_renewal()) {
3448
+			$this->set_total_discount($recurring);
3449 3449
 		} else {
3450
-			$this->set_total_discount( $discount );
3450
+			$this->set_total_discount($discount);
3451 3451
 		}
3452 3452
 
3453 3453
 		$this->totals['discount'] = array(
@@ -3466,13 +3466,13 @@  discard block
 block discarded – undo
3466 3466
 	 * @return float The recalculated tax
3467 3467
 	 */
3468 3468
 	public function recalculate_total_tax() {
3469
-        $taxes     = $this->get_taxes();
3469
+        $taxes = $this->get_taxes();
3470 3470
 		$tax       = 0;
3471 3471
 		$recurring = 0;
3472 3472
 
3473
-        foreach ( $taxes as $data ) {
3473
+        foreach ($taxes as $data) {
3474 3474
 
3475
-			if ( $data['recurring'] ) {
3475
+			if ($data['recurring']) {
3476 3476
 				$recurring += $data['amount'];
3477 3477
 			} else {
3478 3478
 				$tax += $data['amount'];
@@ -3480,10 +3480,10 @@  discard block
 block discarded – undo
3480 3480
 
3481 3481
 		}
3482 3482
 
3483
-		if ( $this->is_renewal() ) {
3484
-			$this->set_total_tax( $recurring );
3483
+		if ($this->is_renewal()) {
3484
+			$this->set_total_tax($recurring);
3485 3485
 		} else {
3486
-			$this->set_total_tax( $tax );
3486
+			$this->set_total_tax($tax);
3487 3487
 		}
3488 3488
 
3489 3489
 		$this->totals['tax'] = array(
@@ -3506,9 +3506,9 @@  discard block
 block discarded – undo
3506 3506
 		$fee       = 0;
3507 3507
 		$recurring = 0;
3508 3508
 
3509
-        foreach ( $fees as $data ) {
3509
+        foreach ($fees as $data) {
3510 3510
 
3511
-			if ( $data['recurring'] ) {
3511
+			if ($data['recurring']) {
3512 3512
 				$recurring += $data['amount'];
3513 3513
 			} else {
3514 3514
 				$fee += $data['amount'];
@@ -3516,10 +3516,10 @@  discard block
 block discarded – undo
3516 3516
 
3517 3517
 		}
3518 3518
 
3519
-        if ( $this->is_renewal() ) {
3520
-			$this->set_total_fees( $recurring );
3519
+        if ($this->is_renewal()) {
3520
+			$this->set_total_fees($recurring);
3521 3521
 		} else {
3522
-			$this->set_total_fees( $fee );
3522
+			$this->set_total_fees($fee);
3523 3523
 		}
3524 3524
 
3525 3525
 		$this->totals['fee'] = array(
@@ -3527,7 +3527,7 @@  discard block
 block discarded – undo
3527 3527
 			'recurring' => $recurring,
3528 3528
 		);
3529 3529
 
3530
-        $this->set_total_fees( $fee );
3530
+        $this->set_total_fees($fee);
3531 3531
         return $this->is_renewal() ? $recurring : $fee;
3532 3532
     }
3533 3533
 
@@ -3548,9 +3548,9 @@  discard block
 block discarded – undo
3548 3548
 	/**
3549 3549
 	 * @deprecated
3550 3550
 	 */
3551
-    public function recalculate_totals( $temp = false ) {
3552
-        $this->update_items( $temp );
3553
-        $this->save( true );
3551
+    public function recalculate_totals($temp = false) {
3552
+        $this->update_items($temp);
3553
+        $this->save(true);
3554 3554
         return $this;
3555 3555
     }
3556 3556
 
@@ -3568,10 +3568,10 @@  discard block
 block discarded – undo
3568 3568
 	 * @return int|false The new note's ID on success, false on failure.
3569 3569
      *
3570 3570
      */
3571
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3571
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3572 3572
 
3573 3573
         // Bail if no note specified or this invoice is not yet saved.
3574
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3574
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3575 3575
             return false;
3576 3576
         }
3577 3577
 
@@ -3579,23 +3579,23 @@  discard block
 block discarded – undo
3579 3579
 		$author_email = '[email protected]';
3580 3580
 
3581 3581
 		// If this is an admin comment or it has been added by the user.
3582
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3583
-			$user         = get_user_by( 'id', get_current_user_id() );
3582
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3583
+			$user = get_user_by('id', get_current_user_id());
3584 3584
             $author       = $user->display_name;
3585 3585
             $author_email = $user->user_email;
3586 3586
 		}
3587 3587
 
3588
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3588
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3589 3589
 
3590 3590
 	}
3591 3591
 
3592 3592
 	/**
3593 3593
      * Generates a unique key for the invoice.
3594 3594
      */
3595
-    public function generate_key( $string = '' ) {
3596
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3595
+    public function generate_key($string = '') {
3596
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3597 3597
         return strtolower(
3598
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3598
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3599 3599
         );
3600 3600
     }
3601 3601
 
@@ -3605,11 +3605,11 @@  discard block
 block discarded – undo
3605 3605
     public function generate_number() {
3606 3606
         $number = $this->get_id();
3607 3607
 
3608
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3609
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3608
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3609
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3610 3610
         }
3611 3611
 
3612
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3612
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3613 3613
 
3614 3614
 	}
3615 3615
 
@@ -3622,47 +3622,47 @@  discard block
 block discarded – undo
3622 3622
 		// Reset status transition variable.
3623 3623
 		$this->status_transition = false;
3624 3624
 
3625
-		if ( $status_transition ) {
3625
+		if ($status_transition) {
3626 3626
 			try {
3627 3627
 
3628 3628
 				// Fire a hook for the status change.
3629
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3629
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3630 3630
 
3631 3631
 				// @deprecated this is deprecated and will be removed in the future.
3632
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3632
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3633 3633
 
3634
-				if ( ! empty( $status_transition['from'] ) ) {
3634
+				if (!empty($status_transition['from'])) {
3635 3635
 
3636 3636
 					/* translators: 1: old invoice status 2: new invoice status */
3637
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3637
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3638 3638
 
3639 3639
 					// Fire another hook.
3640
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3641
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3640
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3641
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3642 3642
 
3643 3643
 					// @deprecated this is deprecated and will be removed in the future.
3644
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3644
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3645 3645
 
3646 3646
 					// Note the transition occurred.
3647
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3647
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3648 3648
 
3649 3649
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3650 3650
 					if (
3651
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3652
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3651
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3652
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3653 3653
 					) {
3654
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3654
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3655 3655
 					}
3656 3656
 				} else {
3657 3657
 					/* translators: %s: new invoice status */
3658
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3658
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3659 3659
 
3660 3660
 					// Note the transition occurred.
3661
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3661
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3662 3662
 
3663 3663
 				}
3664
-			} catch ( Exception $e ) {
3665
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3664
+			} catch (Exception $e) {
3665
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3666 3666
 			}
3667 3667
 		}
3668 3668
 	}
@@ -3670,13 +3670,13 @@  discard block
 block discarded – undo
3670 3670
 	/**
3671 3671
 	 * Updates an invoice status.
3672 3672
 	 */
3673
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3673
+	public function update_status($new_status = false, $note = '', $manual = false) {
3674 3674
 
3675 3675
 		// Fires before updating a status.
3676
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3676
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3677 3677
 
3678 3678
 		// Update the status.
3679
-		$this->set_status( $new_status, $note, $manual );
3679
+		$this->set_status($new_status, $note, $manual);
3680 3680
 
3681 3681
 		// Save the order.
3682 3682
 		return $this->save();
@@ -3687,18 +3687,18 @@  discard block
 block discarded – undo
3687 3687
 	 * @deprecated
3688 3688
 	 */
3689 3689
 	public function refresh_item_ids() {
3690
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3691
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3690
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3691
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3692 3692
 	}
3693 3693
 
3694 3694
 	/**
3695 3695
 	 * @deprecated
3696 3696
 	 */
3697
-	public function update_items( $temp = false ) {
3697
+	public function update_items($temp = false) {
3698 3698
 
3699
-		$this->set_items( $this->get_items() );
3699
+		$this->set_items($this->get_items());
3700 3700
 
3701
-		if ( ! $temp ) {
3701
+		if (!$temp) {
3702 3702
 			$this->save();
3703 3703
 		}
3704 3704
 
@@ -3712,11 +3712,11 @@  discard block
 block discarded – undo
3712 3712
 
3713 3713
         $discount_code = $this->get_discount_code();
3714 3714
 
3715
-        if ( empty( $discount_code ) ) {
3715
+        if (empty($discount_code)) {
3716 3716
             return false;
3717 3717
         }
3718 3718
 
3719
-        $discount = wpinv_get_discount_obj( $discount_code );
3719
+        $discount = wpinv_get_discount_obj($discount_code);
3720 3720
 
3721 3721
         // Ensure it is active.
3722 3722
         return $discount->exists();
@@ -3727,7 +3727,7 @@  discard block
 block discarded – undo
3727 3727
 	 * Refunds an invoice.
3728 3728
 	 */
3729 3729
     public function refund() {
3730
-		$this->set_status( 'wpi-refunded' );
3730
+		$this->set_status('wpi-refunded');
3731 3731
         $this->save();
3732 3732
 	}
3733 3733
 
@@ -3736,56 +3736,56 @@  discard block
 block discarded – undo
3736 3736
 	 * 
3737 3737
 	 * @param string $transaction_id
3738 3738
 	 */
3739
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3739
+    public function mark_paid($transaction_id = null, $note = '') {
3740 3740
 
3741 3741
 		// Set the transaction id.
3742
-		if ( empty( $transaction_id ) ) {
3742
+		if (empty($transaction_id)) {
3743 3743
 			$transaction_id = $this->generate_key('trans_');
3744 3744
 		}
3745 3745
 
3746
-		if ( ! $this->get_transaction_id() ) {
3747
-			$this->set_transaction_id( $transaction_id );
3746
+		if (!$this->get_transaction_id()) {
3747
+			$this->set_transaction_id($transaction_id);
3748 3748
 		}
3749 3749
 
3750
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3750
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3751 3751
 			return $this->save();
3752 3752
 		}
3753 3753
 
3754 3754
 		// Set the completed date.
3755
-		$this->set_date_completed( current_time( 'mysql' ) );
3755
+		$this->set_date_completed(current_time('mysql'));
3756 3756
 
3757 3757
 		// Set the new status.
3758
-		if ( $this->is_renewal() ) {
3758
+		if ($this->is_renewal()) {
3759 3759
 
3760 3760
 			$_note = sprintf(
3761
-				__( 'Renewed via %s', 'invoicing' ),
3762
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3761
+				__('Renewed via %s', 'invoicing'),
3762
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3763 3763
 			);
3764 3764
 
3765
-			if ( 'none' == $this->get_gateway() ) {
3765
+			if ('none' == $this->get_gateway()) {
3766 3766
 				$_note = $note;
3767 3767
 			}
3768 3768
 
3769
-			$this->set_status( 'wpi-renewal', $_note );
3769
+			$this->set_status('wpi-renewal', $_note);
3770 3770
 
3771 3771
 		} else {
3772 3772
 
3773 3773
 			$_note = sprintf(
3774
-				__( 'Paid via %s', 'invoicing' ),
3775
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3774
+				__('Paid via %s', 'invoicing'),
3775
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3776 3776
 			);
3777 3777
 
3778
-			if ( 'none' == $this->get_gateway() ) {
3778
+			if ('none' == $this->get_gateway()) {
3779 3779
 				$_note = $note;
3780 3780
 			}
3781 3781
 
3782
-			$this->set_status( 'publish',$_note );
3782
+			$this->set_status('publish', $_note);
3783 3783
 
3784 3784
 		}
3785 3785
 
3786 3786
 		// Set checkout mode.
3787
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3788
-		$this->set_mode( $mode );
3787
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3788
+		$this->set_mode($mode);
3789 3789
 
3790 3790
 		// Save the invoice.
3791 3791
         $this->save();
@@ -3811,9 +3811,9 @@  discard block
 block discarded – undo
3811 3811
      * Clears the subscription's cache.
3812 3812
      */
3813 3813
     public function clear_cache() {
3814
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3815
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3816
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3814
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3815
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3816
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3817 3817
 	}
3818 3818
 
3819 3819
 }
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains gateway functions.
4 4
  *
5 5
  */
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Returns an array of payment gateways.
@@ -11,141 +11,141 @@  discard block
 block discarded – undo
11 11
  * @return array
12 12
  */
13 13
 function wpinv_get_payment_gateways() {
14
-    return apply_filters( 'wpinv_payment_gateways', array() );
14
+    return apply_filters('wpinv_payment_gateways', array());
15 15
 }
16 16
 
17
-function wpinv_payment_gateway_titles( $all_gateways ) {
17
+function wpinv_payment_gateway_titles($all_gateways) {
18 18
     global $wpinv_options;
19 19
 
20 20
     $gateways = array();
21
-    foreach ( $all_gateways as $key => $gateway ) {
22
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
23
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
21
+    foreach ($all_gateways as $key => $gateway) {
22
+        if (!empty($wpinv_options[$key . '_title'])) {
23
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
24 24
         }
25 25
 
26
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
26
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
27 27
     }
28 28
 
29
-    asort( $gateways );
29
+    asort($gateways);
30 30
 
31
-    foreach ( $gateways as $gateway => $key ) {
31
+    foreach ($gateways as $gateway => $key) {
32 32
         $gateways[$gateway] = $all_gateways[$gateway];
33 33
     }
34 34
 
35 35
     return $gateways;
36 36
 }
37
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
37
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
38 38
 
39
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
39
+function wpinv_get_enabled_payment_gateways($sort = false) {
40 40
     $gateways = wpinv_get_payment_gateways();
41
-    $enabled  = wpinv_get_option( 'gateways', false );
41
+    $enabled  = wpinv_get_option('gateways', false);
42 42
 
43 43
     $gateway_list = array();
44 44
 
45
-    foreach ( $gateways as $key => $gateway ) {
46
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
47
-            $gateway_list[ $key ] = $gateway;
45
+    foreach ($gateways as $key => $gateway) {
46
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
47
+            $gateway_list[$key] = $gateway;
48 48
         }
49 49
     }
50 50
 
51
-    if ( true === $sort ) {
52
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
51
+    if (true === $sort) {
52
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
53 53
         
54 54
         // Reorder our gateways so the default is first
55 55
         $default_gateway_id = wpinv_get_default_gateway();
56 56
 
57
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
58
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
59
-            unset( $gateway_list[ $default_gateway_id ] );
57
+        if (wpinv_is_gateway_active($default_gateway_id)) {
58
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
59
+            unset($gateway_list[$default_gateway_id]);
60 60
 
61
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
61
+            $gateway_list = array_merge($default_gateway, $gateway_list);
62 62
         }
63 63
     }
64 64
 
65
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
65
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
66 66
 }
67 67
 
68
-function wpinv_sort_gateway_order( $a, $b ) {
68
+function wpinv_sort_gateway_order($a, $b) {
69 69
     return $a['ordering'] - $b['ordering'];
70 70
 }
71 71
 
72
-function wpinv_is_gateway_active( $gateway ) {
72
+function wpinv_is_gateway_active($gateway) {
73 73
     $gateways = wpinv_get_enabled_payment_gateways();
74 74
 
75
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
75
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
76 76
 
77
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
77
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
78 78
 }
79 79
 
80 80
 function wpinv_get_default_gateway() {
81
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
81
+    $default = wpinv_get_option('default_gateway', 'paypal');
82 82
 
83
-    if ( !wpinv_is_gateway_active( $default ) ) {
83
+    if (!wpinv_is_gateway_active($default)) {
84 84
         $gateways = wpinv_get_enabled_payment_gateways();
85
-        $gateways = array_keys( $gateways );
86
-        $default  = reset( $gateways );
85
+        $gateways = array_keys($gateways);
86
+        $default  = reset($gateways);
87 87
     }
88 88
 
89
-    return apply_filters( 'wpinv_default_gateway', $default );
89
+    return apply_filters('wpinv_default_gateway', $default);
90 90
 }
91 91
 
92
-function wpinv_get_gateway_admin_label( $gateway ) {
92
+function wpinv_get_gateway_admin_label($gateway) {
93 93
     $gateways = wpinv_get_payment_gateways();
94
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
95
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
94
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
95
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
96 96
 
97
-    if( $gateway == 'manual' && $payment ) {
98
-        if( !( (float)wpinv_payment_total( $payment ) > 0 ) ) {
99
-            $label = __( 'Free Purchase', 'invoicing' );
97
+    if ($gateway == 'manual' && $payment) {
98
+        if (!((float) wpinv_payment_total($payment) > 0)) {
99
+            $label = __('Free Purchase', 'invoicing');
100 100
         }
101 101
     }
102 102
 
103
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
103
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
104 104
 }
105 105
 
106
-function wpinv_get_gateway_description( $gateway ) {
106
+function wpinv_get_gateway_description($gateway) {
107 107
     global $wpinv_options;
108 108
 
109
-    $description = ! empty( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
109
+    $description = !empty($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
110 110
 
111
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
111
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
112 112
 }
113 113
 
114
-function wpinv_get_gateway_button_label( $gateway ) {
115
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
114
+function wpinv_get_gateway_button_label($gateway) {
115
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
116 116
 }
117 117
 
118
-function wpinv_get_gateway_checkout_label( $gateway ) {
118
+function wpinv_get_gateway_checkout_label($gateway) {
119 119
     $gateways = wpinv_get_payment_gateways();
120
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
120
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
121 121
 
122
-    if ( $gateway == 'none' ) {
123
-        $label = __( 'None', 'invoicing' );
122
+    if ($gateway == 'none') {
123
+        $label = __('None', 'invoicing');
124 124
     }
125 125
 
126
-    return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway );
126
+    return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway);
127 127
 }
128 128
 
129
-function wpinv_settings_sections_gateways( $settings ) {
129
+function wpinv_settings_sections_gateways($settings) {
130 130
     $gateways = wpinv_get_payment_gateways();
131 131
     
132 132
     if (!empty($gateways)) {
133
-        foreach  ($gateways as $key => $gateway) {
133
+        foreach ($gateways as $key => $gateway) {
134 134
             $settings[$key] = $gateway['admin_label'];
135 135
         }
136 136
     }
137 137
     
138 138
     return $settings;    
139 139
 }
140
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
140
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
141 141
 
142 142
 /**
143 143
  * Adds GateWay settings.
144 144
  */
145
-function wpinv_settings_gateways( $settings ) {
145
+function wpinv_settings_gateways($settings) {
146 146
 
147 147
     // Loop through each gateway.
148
-    foreach  ( wpinv_get_payment_gateways() as $key => $gateway ) {
148
+    foreach (wpinv_get_payment_gateways() as $key => $gateway) {
149 149
 
150 150
         $gateway_settings = array(
151 151
 
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
             "{$key}_header" => array(
154 154
 
155 155
                 'id'     => "{$key}_gateway_header",
156
-                'name'   => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
156
+                'name'   => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
157 157
                 'custom' => $key,
158 158
                 'type'   => 'gateway_header',
159 159
 
@@ -162,56 +162,56 @@  discard block
 block discarded – undo
162 162
             // Activate/Deactivate a gateway.
163 163
             "{$key}_active" => array(
164 164
                 'id'   => $key . '_active',
165
-                'name' => __( 'Activate', 'invoicing' ),
166
-                'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
165
+                'name' => __('Activate', 'invoicing'),
166
+                'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
167 167
                 'type' => 'checkbox',
168 168
             ),
169 169
 
170 170
             // Activate/Deactivate sandbox.
171 171
             "{$key}_sandbox" => array(
172 172
                 'id'   => $key . '_sandbox',
173
-                'name' => __( 'Sandbox', 'invoicing' ),
174
-                'desc' => __( 'Enable sandbox to test payments', 'invoicing' ),
173
+                'name' => __('Sandbox', 'invoicing'),
174
+                'desc' => __('Enable sandbox to test payments', 'invoicing'),
175 175
                 'type' => 'checkbox',
176 176
             ),
177 177
 
178 178
             // Checkout title.
179 179
             "{$key}_title" => array(
180 180
                 'id'   => $key . '_title',
181
-                'name' => __( 'Checkout Title', 'invoicing' ),
182
-                'std'  => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '',
181
+                'name' => __('Checkout Title', 'invoicing'),
182
+                'std'  => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '',
183 183
                 'type' => 'text',
184 184
             ),
185 185
 
186 186
             // Checkout description.
187 187
             "{$key}_desc" => array(
188 188
                 'id'   => $key . '_desc',
189
-                'name' => __( 'Checkout Description', 'invoicing' ),
190
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
189
+                'name' => __('Checkout Description', 'invoicing'),
190
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
191 191
                 'type' => 'text',
192 192
             ),
193 193
 
194 194
             // Checkout order.
195 195
             "{$key}_ordering" => array(
196 196
                 'id'   => $key . '_ordering',
197
-                'name' => __( 'Priority', 'invoicing' ),
198
-                'std'  => apply_filters( "getpaid_default_{$key}_checkout_description", '' ),
197
+                'name' => __('Priority', 'invoicing'),
198
+                'std'  => apply_filters("getpaid_default_{$key}_checkout_description", ''),
199 199
                 'type' => 'number',
200 200
                 'step' => '1',
201 201
                 'min'  => '-100000',
202 202
                 'max'  => '100000',
203
-                'std'  => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10',
203
+                'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
204 204
             ),
205 205
 
206 206
         );
207 207
 
208 208
         // Maybe remove the sandbox.
209
-        if ( ! apply_filters( "wpinv_{$key}_supports_sandbox", false ) ) {
210
-            unset( $gateway_settings["{$key}_sandbox"] );
209
+        if (!apply_filters("wpinv_{$key}_supports_sandbox", false)) {
210
+            unset($gateway_settings["{$key}_sandbox"]);
211 211
         }
212 212
   
213
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway );
214
-        $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway );
213
+        $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway);
214
+        $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway);
215 215
         
216 216
         $settings[$key] = $gateway_settings;
217 217
     }
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
     return $settings;
220 220
 
221 221
 }
222
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
222
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
223 223
 
224
-function wpinv_gateway_header_callback( $args ) {
225
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
224
+function wpinv_gateway_header_callback($args) {
225
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
226 226
 }
227 227
 
228
-function wpinv_get_gateway_supports( $gateway ) {
228
+function wpinv_get_gateway_supports($gateway) {
229 229
     $gateways = wpinv_get_enabled_payment_gateways();
230
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
231
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
230
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
231
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
232 232
 }
233 233
 
234
-function wpinv_gateway_supports_buy_now( $gateway ) {
235
-    $supports = wpinv_get_gateway_supports( $gateway );
236
-    $ret = in_array( 'buy_now', $supports );
237
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
234
+function wpinv_gateway_supports_buy_now($gateway) {
235
+    $supports = wpinv_get_gateway_supports($gateway);
236
+    $ret = in_array('buy_now', $supports);
237
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
238 238
 }
239 239
 
240 240
 function wpinv_shop_supports_buy_now() {
241 241
     $gateways = wpinv_get_enabled_payment_gateways();
242 242
     $ret      = false;
243 243
 
244
-    if ( !wpinv_use_taxes()  && $gateways ) {
245
-        foreach ( $gateways as $gateway_id => $gateway ) {
246
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
244
+    if (!wpinv_use_taxes() && $gateways) {
245
+        foreach ($gateways as $gateway_id => $gateway) {
246
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
247 247
                 $ret = true;
248 248
                 break;
249 249
             }
250 250
         }
251 251
     }
252 252
 
253
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
253
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
254 254
 }
255 255
 
256 256
 
@@ -258,61 +258,61 @@  discard block
 block discarded – undo
258 258
     $gateways = wpinv_get_enabled_payment_gateways();
259 259
     $show_gateways = false;
260 260
 
261
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
261
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
262 262
 
263
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
263
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
264 264
         $show_gateways = true;
265
-        if ( wpinv_get_cart_total() <= 0 ) {
265
+        if (wpinv_get_cart_total() <= 0) {
266 266
             $show_gateways = false;
267 267
         }
268 268
     }
269 269
     
270
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
270
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
271 271
         $show_gateways = true;
272 272
     }
273 273
 
274
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
274
+    return apply_filters('wpinv_show_gateways', $show_gateways);
275 275
 }
276 276
 
277
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
278
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
277
+function wpinv_get_chosen_gateway($invoice_id = 0) {
278
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
279 279
 
280 280
     $chosen = false;
281
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
281
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
282 282
         $chosen = $invoice->get_gateway();
283 283
     }
284 284
 
285
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
285
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
286 286
 
287
-	if ( false !== $chosen ) {
288
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
287
+	if (false !== $chosen) {
288
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
289 289
 	}
290 290
 
291
-	if ( ! empty ( $chosen ) ) {
292
-		$enabled_gateway = urldecode( $chosen );
293
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
291
+	if (!empty ($chosen)) {
292
+		$enabled_gateway = urldecode($chosen);
293
+	} else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) {
294 294
 		$enabled_gateway = 'manual';
295 295
 	} else {
296 296
 		$enabled_gateway = wpinv_get_default_gateway();
297 297
 	}
298 298
     
299
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
300
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
299
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
300
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
301 301
             $enabled_gateway = wpinv_get_default_gateway();
302
-        }else{
302
+        } else {
303 303
             $enabled_gateway = $gateways[0];
304 304
         }
305 305
 
306 306
     }
307 307
 
308
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
308
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
309 309
 }
310 310
 
311
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
312
-    return wpinv_error_log( $message, $title );
311
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
312
+    return wpinv_error_log($message, $title);
313 313
 }
314 314
 
315
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
315
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
316 316
 	$ret  = 0;
317 317
 	$args = array(
318 318
 		'meta_key'    => '_wpinv_gateway',
@@ -323,48 +323,48 @@  discard block
 block discarded – undo
323 323
 		'fields'      => 'ids'
324 324
 	);
325 325
 
326
-	$payments = new WP_Query( $args );
326
+	$payments = new WP_Query($args);
327 327
 
328
-	if( $payments )
328
+	if ($payments)
329 329
 		$ret = $payments->post_count;
330 330
 	return $ret;
331 331
 }
332 332
 
333
-function wpinv_settings_update_gateways( $input ) {
333
+function wpinv_settings_update_gateways($input) {
334 334
     global $wpinv_options;
335 335
     
336
-    if ( !empty( $input['save_gateway'] ) ) {
337
-        $gateways = wpinv_get_option( 'gateways', false );
336
+    if (!empty($input['save_gateway'])) {
337
+        $gateways = wpinv_get_option('gateways', false);
338 338
         $gateways = !empty($gateways) ? $gateways : array();
339 339
         $gateway = $input['save_gateway'];
340 340
         
341
-        if ( !empty( $input[$gateway . '_active'] ) ) {
341
+        if (!empty($input[$gateway . '_active'])) {
342 342
             $gateways[$gateway] = 1;
343 343
         } else {
344
-            if ( isset( $gateways[$gateway] ) ) {
345
-                unset( $gateways[$gateway] );
344
+            if (isset($gateways[$gateway])) {
345
+                unset($gateways[$gateway]);
346 346
             }
347 347
         }
348 348
         
349 349
         $input['gateways'] = $gateways;
350 350
     }
351 351
     
352
-    if ( !empty( $input['default_gateway'] ) ) {
352
+    if (!empty($input['default_gateway'])) {
353 353
         $gateways = wpinv_get_payment_gateways();
354 354
         
355
-        foreach ( $gateways as $key => $gateway ) {
356
-            $active   = 0;
357
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
355
+        foreach ($gateways as $key => $gateway) {
356
+            $active = 0;
357
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
358 358
                 $active = 1;
359 359
             }
360 360
             
361 361
             $input[$key . '_active'] = $active;
362 362
             
363
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
363
+            if (empty($wpinv_options[$key . '_title'])) {
364 364
                 $input[$key . '_title'] = $gateway['checkout_label'];
365 365
             }
366 366
             
367
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
367
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
368 368
                 $input[$key . '_ordering'] = $gateway['ordering'];
369 369
             }
370 370
         }
@@ -372,27 +372,27 @@  discard block
 block discarded – undo
372 372
     
373 373
     return $input;
374 374
 }
375
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
375
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
376 376
 
377 377
 // PayPal Standard settings
378
-function wpinv_gateway_settings_paypal( $setting ) {    
379
-    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __( '( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing' );
380
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
378
+function wpinv_gateway_settings_paypal($setting) {    
379
+    $setting['paypal_active']['desc'] = $setting['paypal_active']['desc'] . ' ' . __('( Supported Currencies: AUD, BRL, CAD, CZK, DKK, EUR, HKD, HUF, ILS, JPY, MYR, MXN, NOK, NZD, PHP, PLN, GBP, SGD, SEK, CHF, TWD, THB, USD )', 'invoicing');
380
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
381 381
     
382 382
     $setting['paypal_sandbox'] = array(
383 383
             'type' => 'checkbox',
384 384
             'id'   => 'paypal_sandbox',
385
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
386
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
385
+            'name' => __('PayPal Sandbox', 'invoicing'),
386
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
387 387
             'std'  => 1
388 388
         );
389 389
         
390 390
     $setting['paypal_email'] = array(
391 391
             'type' => 'text',
392 392
             'id'   => 'paypal_email',
393
-            'name' => __( 'PayPal Email', 'invoicing' ),
394
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
395
-            'std' => __( '[email protected]', 'invoicing' ),
393
+            'name' => __('PayPal Email', 'invoicing'),
394
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
395
+            'std' => __('[email protected]', 'invoicing'),
396 396
         );
397 397
     /*
398 398
     $setting['paypal_ipn_url'] = array(
@@ -406,18 +406,18 @@  discard block
 block discarded – undo
406 406
         
407 407
     return $setting;
408 408
 }
409
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
409
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
410 410
 
411 411
 /**
412 412
  * Displays the ipn url field.
413 413
  */
414
-function wpinv_ipn_url_callback( $args ) {
415
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
414
+function wpinv_ipn_url_callback($args) {
415
+    $sanitize_id = wpinv_sanitize_key($args['id']);
416 416
     
417 417
     $attrs = $args['readonly'] ? ' readonly' : '';
418 418
 
419
-    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
420
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
419
+    $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">';
420
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
421 421
 
422 422
     echo $html;
423 423
 }
@@ -429,9 +429,9 @@  discard block
 block discarded – undo
429 429
  * 
430 430
  * @return bool
431 431
  */
432
-function wpinv_is_test_mode( $gateway = '' ) {
433
-    $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", false );
434
-    return apply_filters( 'wpinv_is_test_mode', $sandbox, $gateway );
432
+function wpinv_is_test_mode($gateway = '') {
433
+    $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", false);
434
+    return apply_filters('wpinv_is_test_mode', $sandbox, $gateway);
435 435
 }
436 436
 
437 437
 /**
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
  * 
443 443
  * @return string
444 444
  */
445
-function wpinv_get_ipn_url( $gateway = false, $args = array() ) {
445
+function wpinv_get_ipn_url($gateway = false, $args = array()) {
446 446
     $args = wp_parse_args(
447 447
         array(
448 448
             'wpi-listener' => 'IPN',
@@ -451,36 +451,36 @@  discard block
 block discarded – undo
451 451
         $args
452 452
     );
453 453
 
454
-    return apply_filters( 'wpinv_ipn_url', add_query_arg( $args,  home_url( 'index.php' ) ), $gateway, $args );
454
+    return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args);
455 455
 
456 456
 }
457 457
 
458 458
 /**
459 459
  * Retrieves request data with slashes removed slashes.
460 460
  */
461
-function wpinv_get_post_data( $method = 'request' ) {
461
+function wpinv_get_post_data($method = 'request') {
462 462
 
463
-    if ( $method == 'post' ) {
464
-        return wp_unslash( $_POST );
463
+    if ($method == 'post') {
464
+        return wp_unslash($_POST);
465 465
     }
466 466
 
467
-    if ( $method == 'get' ) {
468
-        return wp_unslash( $_GET );
467
+    if ($method == 'get') {
468
+        return wp_unslash($_GET);
469 469
     }
470 470
 
471
-    return wp_unslash( $_REQUEST );
471
+    return wp_unslash($_REQUEST);
472 472
   
473 473
 }
474 474
 
475 475
 /**
476 476
  * Checks if a given gateway supports subscription payments.
477 477
  */
478
-function wpinv_gateway_support_subscription( $gateway ) {
478
+function wpinv_gateway_support_subscription($gateway) {
479 479
     $supports = false;
480 480
 
481
-    if ( wpinv_is_gateway_active( $gateway ) ) {
482
-        $supports = apply_filters( 'wpinv_' . $gateway . '_support_subscription', $supports );
483
-        $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $gateway );
481
+    if (wpinv_is_gateway_active($gateway)) {
482
+        $supports = apply_filters('wpinv_' . $gateway . '_support_subscription', $supports);
483
+        $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $gateway);
484 484
     }
485 485
 
486 486
     return $supports;
@@ -492,14 +492,14 @@  discard block
 block discarded – undo
492 492
  * @param array $gateways an array of gateways.
493 493
  * @param GetPaid_Payment_Form $form payment form.
494 494
  */
495
-function wpinv_payment_gateways_on_cart( $gateways, $form ) {
495
+function wpinv_payment_gateways_on_cart($gateways, $form) {
496 496
 
497
-    if ( $form->is_recurring() ) {
497
+    if ($form->is_recurring()) {
498 498
 
499
-        foreach ( array_keys( $gateways ) as $gateway ) {
499
+        foreach (array_keys($gateways) as $gateway) {
500 500
 
501
-            if ( ! wpinv_gateway_support_subscription( $gateway ) ) {
502
-                unset( $gateways[$gateway] );
501
+            if (!wpinv_gateway_support_subscription($gateway)) {
502
+                unset($gateways[$gateway]);
503 503
             }
504 504
 
505 505
         }
@@ -508,24 +508,24 @@  discard block
 block discarded – undo
508 508
 
509 509
     return $gateways;
510 510
 }
511
-add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 );
511
+add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2);
512 512
 
513 513
 /**
514 514
  * Validates checkout fields.
515 515
  *
516 516
  * @param GetPaid_Payment_Form_Submission $submission
517 517
  */
518
-function wpinv_checkout_validate_gateway( $submission ) {
518
+function wpinv_checkout_validate_gateway($submission) {
519 519
 
520 520
     $data = $submission->get_data();
521 521
 
522 522
     // Non-recurring gateways should not be allowed to process recurring invoices.
523
-    if ( $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
524
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway does not support subscription payment.', 'invoicing' ) );
523
+    if ($submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
524
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway does not support subscription payment.', 'invoicing'));
525 525
     }
526 526
 
527
-    if ( ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
528
-        wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
527
+    if (!wpinv_is_gateway_active($data['wpi-gateway'])) {
528
+        wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
529 529
     }
530 530
 
531 531
 }
@@ -533,84 +533,84 @@  discard block
 block discarded – undo
533 533
 /**
534 534
  * Validates a zip code.
535 535
  */
536
-function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) {
536
+function wpinv_checkout_validate_cc_zip($zip = 0, $country_code = '') {
537 537
 
538
-    if ( empty( $zip ) || empty( $country_code ) ){
538
+    if (empty($zip) || empty($country_code)) {
539 539
         return false;
540 540
     }
541 541
 
542 542
     // Prepare the country code.
543
-    $country_code = strtoupper( trim( $country_code ) );
543
+    $country_code = strtoupper(trim($country_code));
544 544
 
545 545
     // Fetch the regexes.
546
-    $zip_regex = wpinv_get_data( 'zip-regexes' );
546
+    $zip_regex = wpinv_get_data('zip-regexes');
547 547
 
548 548
     // Check if it is valid.
549
-    $is_valid = ! isset ( $zip_regex[ $country_code ] ) || preg_match( "/" . $zip_regex[ $country_code ] . "/i", $zip );
549
+    $is_valid = !isset ($zip_regex[$country_code]) || preg_match("/" . $zip_regex[$country_code] . "/i", $zip);
550 550
 
551
-    return apply_filters( 'wpinv_is_zip_valid', $is_valid, $zip, $country_code );
551
+    return apply_filters('wpinv_is_zip_valid', $is_valid, $zip, $country_code);
552 552
 }
553 553
 
554 554
 function wpinv_checkout_validate_agree_to_terms() {
555 555
     // Validate agree to terms
556
-    if ( ! isset( $_POST['wpi_agree_to_terms'] ) || $_POST['wpi_agree_to_terms'] != 1 ) {
556
+    if (!isset($_POST['wpi_agree_to_terms']) || $_POST['wpi_agree_to_terms'] != 1) {
557 557
         // User did not agree
558
-        wpinv_set_error( 'agree_to_terms', apply_filters( 'wpinv_agree_to_terms_text', __( 'You must agree to the terms of use', 'invoicing' ) ) );
558
+        wpinv_set_error('agree_to_terms', apply_filters('wpinv_agree_to_terms_text', __('You must agree to the terms of use', 'invoicing')));
559 559
     }
560 560
 }
561 561
 
562 562
 function wpinv_checkout_validate_invoice_user() {
563 563
     global $wpi_cart, $user_ID;
564 564
 
565
-    if(empty($wpi_cart)){
565
+    if (empty($wpi_cart)) {
566 566
         $wpi_cart = wpinv_get_invoice_cart();
567 567
     }
568 568
 
569
-    $invoice_user = (int)$wpi_cart->get_user_id();
569
+    $invoice_user = (int) $wpi_cart->get_user_id();
570 570
     $valid_user_data = array(
571 571
         'user_id' => $invoice_user
572 572
     );
573 573
 
574 574
     // If guest checkout allowed
575
-    if ( !wpinv_require_login_to_checkout() ) {
575
+    if (!wpinv_require_login_to_checkout()) {
576 576
         return $valid_user_data;
577 577
     }
578 578
     
579 579
     // Verify there is a user_ID
580
-    if ( $user_ID == $invoice_user ) {
580
+    if ($user_ID == $invoice_user) {
581 581
         // Get the logged in user data
582
-        $user_data = get_userdata( $user_ID );
583
-        $required_fields  = wpinv_checkout_required_fields();
582
+        $user_data = get_userdata($user_ID);
583
+        $required_fields = wpinv_checkout_required_fields();
584 584
 
585 585
         // Loop through required fields and show error messages
586
-         if ( !empty( $required_fields ) ) {
587
-            foreach ( $required_fields as $field_name => $value ) {
588
-                if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
589
-                    wpinv_set_error( $value['error_id'], $value['error_message'] );
586
+         if (!empty($required_fields)) {
587
+            foreach ($required_fields as $field_name => $value) {
588
+                if (in_array($value, $required_fields) && empty($_POST['wpinv_' . $field_name])) {
589
+                    wpinv_set_error($value['error_id'], $value['error_message']);
590 590
                 }
591 591
             }
592 592
         }
593 593
 
594 594
         // Verify data
595
-        if ( $user_data ) {
595
+        if ($user_data) {
596 596
             // Collected logged in user data
597 597
             $valid_user_data = array(
598 598
                 'user_id'     => $user_ID,
599
-                'email'       => isset( $_POST['wpinv_email'] ) ? sanitize_email( $_POST['wpinv_email'] ) : $user_data->user_email,
600
-                'first_name'  => isset( $_POST['wpinv_first_name'] ) && ! empty( $_POST['wpinv_first_name'] ) ? sanitize_text_field( $_POST['wpinv_first_name'] ) : $user_data->first_name,
601
-                'last_name'   => isset( $_POST['wpinv_last_name'] ) && ! empty( $_POST['wpinv_last_name']  ) ? sanitize_text_field( $_POST['wpinv_last_name']  ) : $user_data->last_name,
599
+                'email'       => isset($_POST['wpinv_email']) ? sanitize_email($_POST['wpinv_email']) : $user_data->user_email,
600
+                'first_name'  => isset($_POST['wpinv_first_name']) && !empty($_POST['wpinv_first_name']) ? sanitize_text_field($_POST['wpinv_first_name']) : $user_data->first_name,
601
+                'last_name'   => isset($_POST['wpinv_last_name']) && !empty($_POST['wpinv_last_name']) ? sanitize_text_field($_POST['wpinv_last_name']) : $user_data->last_name,
602 602
             );
603 603
 
604
-            if ( !empty( $_POST[ 'wpinv_email' ] ) && !is_email( $_POST[ 'wpinv_email' ] ) ) {
605
-                wpinv_set_error( 'invalid_email', __( 'Please enter a valid email address', 'invoicing' ) );
604
+            if (!empty($_POST['wpinv_email']) && !is_email($_POST['wpinv_email'])) {
605
+                wpinv_set_error('invalid_email', __('Please enter a valid email address', 'invoicing'));
606 606
             }
607 607
         } else {
608 608
             // Set invalid user error
609
-            wpinv_set_error( 'invalid_user', __( 'The user billing information is invalid', 'invoicing' ) );
609
+            wpinv_set_error('invalid_user', __('The user billing information is invalid', 'invoicing'));
610 610
         }
611 611
     } else {
612 612
         // Set invalid user error
613
-        wpinv_set_error( 'invalid_user_id', __( 'The invalid invoice user id', 'invoicing' ) );
613
+        wpinv_set_error('invalid_user_id', __('The invalid invoice user id', 'invoicing'));
614 614
     }
615 615
 
616 616
     // Return user data
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
 
623 623
     $data = array();
624 624
     
625
-    if ( is_user_logged_in() ) {
626
-        if ( !wpinv_require_login_to_checkout() || ( wpinv_require_login_to_checkout() && (int)$wpi_cart->get_user_id() === (int)get_current_user_id() ) ) {
627
-            $data['user_id'] = (int)get_current_user_id();
625
+    if (is_user_logged_in()) {
626
+        if (!wpinv_require_login_to_checkout() || (wpinv_require_login_to_checkout() && (int) $wpi_cart->get_user_id() === (int) get_current_user_id())) {
627
+            $data['user_id'] = (int) get_current_user_id();
628 628
         } else {
629
-            wpinv_set_error( 'logged_in_only', __( 'You are not allowed to pay for this invoice', 'invoicing' ) );
629
+            wpinv_set_error('logged_in_only', __('You are not allowed to pay for this invoice', 'invoicing'));
630 630
         }
631 631
     } else {
632 632
         // If guest checkout allowed
633
-        if ( !wpinv_require_login_to_checkout() ) {
633
+        if (!wpinv_require_login_to_checkout()) {
634 634
             $data['user_id'] = 0;
635 635
         } else {
636
-            wpinv_set_error( 'logged_in_only', __( 'You must be logged in to pay for this invoice', 'invoicing' ) );
636
+            wpinv_set_error('logged_in_only', __('You must be logged in to pay for this invoice', 'invoicing'));
637 637
         }
638 638
     }
639 639
 
@@ -647,41 +647,41 @@  discard block
 block discarded – undo
647 647
  * @param WPInv_Invoice $invoice
648 648
  * @param GetPaid_Payment_Form_Submission $submission
649 649
  */
650
-function wpinv_process_checkout( $invoice, $submission ) {
650
+function wpinv_process_checkout($invoice, $submission) {
651 651
 
652 652
     // No need to send free invoices to the gateway.
653
-    if ( $invoice->is_free() ) {
654
-        $invoice->set_gateway( 'none' );
655
-        $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
653
+    if ($invoice->is_free()) {
654
+        $invoice->set_gateway('none');
655
+        $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
656 656
         $invoice->mark_paid();
657
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
657
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
658 658
     }
659 659
 
660 660
     // Clear an checkout errors.
661 661
     wpinv_clear_errors();
662 662
 
663 663
     // Fires before sending to the gateway.
664
-    do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
664
+    do_action('getpaid_checkout_before_gateway', $invoice, $submission);
665 665
 
666 666
     // Allow the sumission data to be modified before it is sent to the gateway.
667 667
     $submission_data    = $submission->get_data();
668
-    $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice );
669
-    $submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
668
+    $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $submission_data['wpi-gateway'], $submission, $invoice);
669
+    $submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
670 670
 
671 671
     // Validate the currency.
672
-    if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
673
-        wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) );
672
+    if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
673
+        wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing'));
674 674
     }
675 675
 
676 676
     // Check to see if we have any errors.
677
-    if ( wpinv_get_errors() ) {
677
+    if (wpinv_get_errors()) {
678 678
         wpinv_send_back_to_checkout();
679 679
     }
680 680
 
681 681
     // Send info to the gateway for payment processing
682
-    do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
682
+    do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
683 683
 
684 684
     // Backwards compatibility.
685
-    wpinv_send_to_gateway( $submission_gateway, $invoice->get_payment_meta() );
685
+    wpinv_send_to_gateway($submission_gateway, $invoice->get_payment_meta());
686 686
 
687 687
 }
Please login to merge, or discard this patch.
includes/class-getpaid-invoice-notification-emails.php 2 patches
Indentation   +371 added lines, -371 removed lines patch added patch discarded remove patch
@@ -12,423 +12,423 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Notification_Emails {
14 14
 
15
-	/**
16
-	 * The array of invoice email actions.
17
-	 *
18
-	 * @param array
19
-	 */
20
-	public $invoice_actions;
21
-
22
-	/**
23
-	 * Class constructor
24
-	 *
25
-	 */
26
-	public function __construct() {
27
-
28
-		$this->invoice_actions = apply_filters(
29
-			'getpaid_notification_email_invoice_triggers',
30
-			array(
31
-				'getpaid_new_invoice'                   => 'new_invoice',
32
-				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
-				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
-				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
-				'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
-				'getpaid_invoice_status_publish'        => 'completed_invoice',
37
-				'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
-				'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
-				'getpaid_new_invoice'                   => 'user_invoice',
40
-				'getpaid_new_customer_note'             => 'user_note',
41
-				'getpaid_daily_maintenance'             => 'overdue',
42
-
43
-			)
44
-		);
45
-
46
-		$this->init_hooks();
47
-
48
-	}
49
-
50
-	/**
51
-	 * Registers email hooks.
52
-	 */
53
-	public function init_hooks() {
54
-
55
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
56
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
57
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
58
-
59
-			$email = new GetPaid_Notification_Email( $email_type );
60
-
61
-			if ( ! $email->is_active() ) {
62
-				continue;
63
-			}
64
-
65
-			if ( method_exists( $this, $email_type ) ) {
66
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
67
-				continue;
68
-			}
69
-
70
-			do_action( 'getpaid_invoice_notification_email_register_hook', $email );
71
-
72
-		}
73
-
74
-	}
75
-
76
-	/**
77
-	 * Filters invoice merge tags.
78
-	 *
79
-	 * @param array $merge_tags
80
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
81
-	 */
82
-	public function invoice_merge_tags( $merge_tags, $object ) {
83
-
84
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
85
-			return array_merge(
86
-				$merge_tags,
87
-				$this->get_invoice_merge_tags( $object )
88
-			);
89
-		}
90
-
91
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
92
-			return array_merge(
93
-				$merge_tags,
94
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
95
-			);
96
-		}
97
-
98
-		return $merge_tags;
99
-
100
-	}
101
-
102
-	/**
103
-	 * Generates invoice merge tags.
104
-	 *
105
-	 * @param WPInv_Invoice $invoice
106
-	 * @return array
107
-	 */
108
-	public function get_invoice_merge_tags( $invoice ) {
109
-
110
-		// Abort if it does not exist.
111
-		if ( ! $invoice->get_id() ) {
112
-			return array();
113
-		}
114
-
115
-		return array(
116
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
117
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
118
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
119
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
120
-			'{email}'               => sanitize_email( $invoice->get_email() ),
121
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
122
-			'{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
123
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
124
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
125
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
126
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
127
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
128
-			'{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
129
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
130
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
131
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
132
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
133
-		);
134
-
135
-	}
136
-
137
-	/**
138
-	 * Helper function to send an email.
139
-	 *
140
-	 * @param WPInv_Invoice $invoice
141
-	 * @param GetPaid_Notification_Email $email
142
-	 * @param string $type
143
-	 * @param string|array $recipients
144
-	 * @param array $extra_args Extra template args.
145
-	 */
146
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
147
-
148
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
149
-
150
-		$mailer     = new GetPaid_Notification_Email_Sender();
151
-		$merge_tags = $email->get_merge_tags();
152
-
153
-		$result = $mailer->send(
154
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
155
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
156
-			$email->get_content( $merge_tags, $extra_args ),
157
-			$email->get_attachments()
158
-		);
159
-
160
-		// Maybe send a copy to the admin.
161
-		if ( $email->include_admin_bcc() ) {
162
-			$mailer->send(
163
-				wpinv_get_admin_email(),
164
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
165
-				$email->get_content( $merge_tags ),
166
-				$email->get_attachments()
167
-			);
168
-		}
169
-
170
-		if ( ! $result ) {
171
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
172
-		}
173
-
174
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
175
-
176
-		return $result;
177
-	}
178
-
179
-	/**
180
-	 * Also send emails to any cc users.
181
-	 *
182
-	 * @param array $recipients
183
-	 * @param GetPaid_Notification_Email $email
184
-	 */
185
-	public function filter_email_recipients( $recipients, $email ) {
186
-
187
-		if ( ! $email->is_admin_email() ) {
188
-			$cc = $email->object->get_email_cc();
189
-
190
-			if ( ! empty( $cc ) ) {
191
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
192
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
193
-			}
194
-
195
-		}
196
-
197
-		return $recipients;
198
-
199
-	}
200
-
201
-	/**
202
-	 * Sends a new invoice notification.
203
-	 *
204
-	 * @param WPInv_Invoice $invoice
205
-	 */
206
-	public function new_invoice( $invoice ) {
207
-
208
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
209
-		$recipient = wpinv_get_admin_email();
210
-
211
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
212
-
213
-	}
214
-
215
-	/**
216
-	 * Sends a cancelled invoice notification.
217
-	 *
218
-	 * @param WPInv_Invoice $invoice
219
-	 */
220
-	public function cancelled_invoice( $invoice ) {
221
-
222
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
223
-		$recipient = wpinv_get_admin_email();
15
+    /**
16
+     * The array of invoice email actions.
17
+     *
18
+     * @param array
19
+     */
20
+    public $invoice_actions;
21
+
22
+    /**
23
+     * Class constructor
24
+     *
25
+     */
26
+    public function __construct() {
27
+
28
+        $this->invoice_actions = apply_filters(
29
+            'getpaid_notification_email_invoice_triggers',
30
+            array(
31
+                'getpaid_new_invoice'                   => 'new_invoice',
32
+                'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
33
+                'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
34
+                'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
35
+                'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
36
+                'getpaid_invoice_status_publish'        => 'completed_invoice',
37
+                'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
38
+                'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
39
+                'getpaid_new_invoice'                   => 'user_invoice',
40
+                'getpaid_new_customer_note'             => 'user_note',
41
+                'getpaid_daily_maintenance'             => 'overdue',
42
+
43
+            )
44
+        );
45
+
46
+        $this->init_hooks();
47
+
48
+    }
49
+
50
+    /**
51
+     * Registers email hooks.
52
+     */
53
+    public function init_hooks() {
54
+
55
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
56
+        add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
57
+        foreach ( $this->invoice_actions as $hook => $email_type ) {
58
+
59
+            $email = new GetPaid_Notification_Email( $email_type );
60
+
61
+            if ( ! $email->is_active() ) {
62
+                continue;
63
+            }
64
+
65
+            if ( method_exists( $this, $email_type ) ) {
66
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
67
+                continue;
68
+            }
69
+
70
+            do_action( 'getpaid_invoice_notification_email_register_hook', $email );
71
+
72
+        }
73
+
74
+    }
75
+
76
+    /**
77
+     * Filters invoice merge tags.
78
+     *
79
+     * @param array $merge_tags
80
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
81
+     */
82
+    public function invoice_merge_tags( $merge_tags, $object ) {
83
+
84
+        if ( is_a( $object, 'WPInv_Invoice' ) ) {
85
+            return array_merge(
86
+                $merge_tags,
87
+                $this->get_invoice_merge_tags( $object )
88
+            );
89
+        }
90
+
91
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
92
+            return array_merge(
93
+                $merge_tags,
94
+                $this->get_invoice_merge_tags( $object->get_parent_payment() )
95
+            );
96
+        }
97
+
98
+        return $merge_tags;
99
+
100
+    }
101
+
102
+    /**
103
+     * Generates invoice merge tags.
104
+     *
105
+     * @param WPInv_Invoice $invoice
106
+     * @return array
107
+     */
108
+    public function get_invoice_merge_tags( $invoice ) {
109
+
110
+        // Abort if it does not exist.
111
+        if ( ! $invoice->get_id() ) {
112
+            return array();
113
+        }
114
+
115
+        return array(
116
+            '{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
117
+            '{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
118
+            '{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
119
+            '{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
120
+            '{email}'               => sanitize_email( $invoice->get_email() ),
121
+            '{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
122
+            '{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
123
+            '{invoice_link}'        => esc_url( $invoice->get_view_url() ),
124
+            '{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
125
+            '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
126
+            '{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
127
+            '{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
128
+            '{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
129
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
130
+            '{invoice_description}' => wp_kses_post( $invoice->get_description() ),
131
+            '{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
132
+            '{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
133
+        );
134
+
135
+    }
136
+
137
+    /**
138
+     * Helper function to send an email.
139
+     *
140
+     * @param WPInv_Invoice $invoice
141
+     * @param GetPaid_Notification_Email $email
142
+     * @param string $type
143
+     * @param string|array $recipients
144
+     * @param array $extra_args Extra template args.
145
+     */
146
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
147
+
148
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
149
+
150
+        $mailer     = new GetPaid_Notification_Email_Sender();
151
+        $merge_tags = $email->get_merge_tags();
152
+
153
+        $result = $mailer->send(
154
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
155
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
156
+            $email->get_content( $merge_tags, $extra_args ),
157
+            $email->get_attachments()
158
+        );
159
+
160
+        // Maybe send a copy to the admin.
161
+        if ( $email->include_admin_bcc() ) {
162
+            $mailer->send(
163
+                wpinv_get_admin_email(),
164
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
165
+                $email->get_content( $merge_tags ),
166
+                $email->get_attachments()
167
+            );
168
+        }
169
+
170
+        if ( ! $result ) {
171
+            $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
172
+        }
173
+
174
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
175
+
176
+        return $result;
177
+    }
178
+
179
+    /**
180
+     * Also send emails to any cc users.
181
+     *
182
+     * @param array $recipients
183
+     * @param GetPaid_Notification_Email $email
184
+     */
185
+    public function filter_email_recipients( $recipients, $email ) {
186
+
187
+        if ( ! $email->is_admin_email() ) {
188
+            $cc = $email->object->get_email_cc();
189
+
190
+            if ( ! empty( $cc ) ) {
191
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
192
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
193
+            }
194
+
195
+        }
196
+
197
+        return $recipients;
198
+
199
+    }
200
+
201
+    /**
202
+     * Sends a new invoice notification.
203
+     *
204
+     * @param WPInv_Invoice $invoice
205
+     */
206
+    public function new_invoice( $invoice ) {
207
+
208
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
209
+        $recipient = wpinv_get_admin_email();
210
+
211
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
212
+
213
+    }
214
+
215
+    /**
216
+     * Sends a cancelled invoice notification.
217
+     *
218
+     * @param WPInv_Invoice $invoice
219
+     */
220
+    public function cancelled_invoice( $invoice ) {
221
+
222
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
223
+        $recipient = wpinv_get_admin_email();
224 224
 
225
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
225
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
226 226
 
227
-	}
227
+    }
228 228
 
229
-	/**
230
-	 * Sends a failed invoice notification.
231
-	 *
232
-	 * @param WPInv_Invoice $invoice
233
-	 */
234
-	public function failed_invoice( $invoice ) {
229
+    /**
230
+     * Sends a failed invoice notification.
231
+     *
232
+     * @param WPInv_Invoice $invoice
233
+     */
234
+    public function failed_invoice( $invoice ) {
235 235
 
236
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
237
-		$recipient = wpinv_get_admin_email();
238
-
239
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
236
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
237
+        $recipient = wpinv_get_admin_email();
238
+
239
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
240 240
 
241
-	}
241
+    }
242 242
 
243
-	/**
244
-	 * Sends a notification whenever an invoice is put on hold.
245
-	 *
246
-	 * @param WPInv_Invoice $invoice
247
-	 */
248
-	public function onhold_invoice( $invoice ) {
243
+    /**
244
+     * Sends a notification whenever an invoice is put on hold.
245
+     *
246
+     * @param WPInv_Invoice $invoice
247
+     */
248
+    public function onhold_invoice( $invoice ) {
249 249
 
250
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
251
-		$recipient = $invoice->get_email();
250
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
251
+        $recipient = $invoice->get_email();
252 252
 
253
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
253
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
254 254
 
255
-	}
255
+    }
256 256
 
257
-	/**
258
-	 * Sends a notification whenever an invoice is marked as processing payment.
259
-	 *
260
-	 * @param WPInv_Invoice $invoice
261
-	 */
262
-	public function processing_invoice( $invoice ) {
257
+    /**
258
+     * Sends a notification whenever an invoice is marked as processing payment.
259
+     *
260
+     * @param WPInv_Invoice $invoice
261
+     */
262
+    public function processing_invoice( $invoice ) {
263 263
 
264
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
265
-		$recipient = $invoice->get_email();
264
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
265
+        $recipient = $invoice->get_email();
266 266
 
267
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
267
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
268 268
 
269
-	}
269
+    }
270 270
 
271
-	/**
272
-	 * Sends a notification whenever an invoice is paid.
273
-	 *
274
-	 * @param WPInv_Invoice $invoice
275
-	 */
276
-	public function completed_invoice( $invoice ) {
271
+    /**
272
+     * Sends a notification whenever an invoice is paid.
273
+     *
274
+     * @param WPInv_Invoice $invoice
275
+     */
276
+    public function completed_invoice( $invoice ) {
277 277
 
278
-		// (Maybe) abort if it is a renewal invoice.
279
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
280
-			return;
281
-		}
278
+        // (Maybe) abort if it is a renewal invoice.
279
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
280
+            return;
281
+        }
282 282
 
283
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
284
-		$recipient = $invoice->get_email();
283
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
284
+        $recipient = $invoice->get_email();
285 285
 
286
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
286
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
287 287
 
288
-	}
288
+    }
289 289
 
290
-	/**
291
-	 * Sends a notification whenever an invoice is refunded.
292
-	 *
293
-	 * @param WPInv_Invoice $invoice
294
-	 */
295
-	public function refunded_invoice( $invoice ) {
290
+    /**
291
+     * Sends a notification whenever an invoice is refunded.
292
+     *
293
+     * @param WPInv_Invoice $invoice
294
+     */
295
+    public function refunded_invoice( $invoice ) {
296 296
 
297
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
298
-		$recipient = $invoice->get_email();
297
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
298
+        $recipient = $invoice->get_email();
299 299
 
300
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
300
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
301 301
 
302
-	}
302
+    }
303 303
 
304
-	/**
305
-	 * Notifies a user about new invoices
306
-	 *
307
-	 * @param WPInv_Invoice $invoice
308
-	 */
309
-	public function user_invoice( $invoice ) {
304
+    /**
305
+     * Notifies a user about new invoices
306
+     *
307
+     * @param WPInv_Invoice $invoice
308
+     */
309
+    public function user_invoice( $invoice ) {
310 310
 
311
-		// Only send this email for invoices created via the admin page.
312
-		if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
313
-			return;
314
-		}
311
+        // Only send this email for invoices created via the admin page.
312
+        if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
313
+            return;
314
+        }
315 315
 
316
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
317
-		$recipient = $invoice->get_email();
316
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
317
+        $recipient = $invoice->get_email();
318 318
 
319
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
319
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
320 320
 
321
-	}
321
+    }
322 322
 
323
-	/**
324
-	 * Checks if an invoice is a payment form invoice.
325
-	 *
326
-	 * @param int $invoice
327
-	 * @return bool
328
-	 */
329
-	public function is_payment_form_invoice( $invoice ) {
330
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
331
-	}
323
+    /**
324
+     * Checks if an invoice is a payment form invoice.
325
+     *
326
+     * @param int $invoice
327
+     * @return bool
328
+     */
329
+    public function is_payment_form_invoice( $invoice ) {
330
+        return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
331
+    }
332 332
 
333
-	/**
334
-	 * Notifies admin about new invoice notes
335
-	 *
336
-	 * @param WPInv_Invoice $invoice
337
-	 * @param string $note
338
-	 */
339
-	public function user_note( $invoice, $note ) {
333
+    /**
334
+     * Notifies admin about new invoice notes
335
+     *
336
+     * @param WPInv_Invoice $invoice
337
+     * @param string $note
338
+     */
339
+    public function user_note( $invoice, $note ) {
340 340
 
341
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
342
-		$recipient = $invoice->get_email();
343
-
344
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
345
-
346
-	}
341
+        $email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
342
+        $recipient = $invoice->get_email();
343
+
344
+        return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
345
+
346
+    }
347 347
 
348
-	/**
349
-	 * (Force) Sends overdue notices.
350
-	 *
351
-	 * @param WPInv_Invoice $invoice
352
-	 */
353
-	public function force_send_overdue_notice( $invoice ) {
354
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
355
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
356
-	}
357
-
358
-	/**
359
-	 * Sends overdue notices.
360
-	 *
361
-	 * @TODO: Create an invoices query class.
362
-	 */
363
-	public function overdue() {
364
-		global $wpdb;
365
-
366
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
367
-
368
-		// Fetch reminder days.
369
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
370
-
371
-		// Abort if non is set.
372
-		if ( empty( $reminder_days ) ) {
373
-			return;
374
-		}
375
-
376
-		// Retrieve date query.
377
-		$date_query = $this->get_date_query( $reminder_days );
378
-
379
-		// Invoices table.
380
-		$table = $wpdb->prefix . 'getpaid_invoices';
381
-
382
-		// Fetch invoices.
383
-		$invoices  = $wpdb->get_col(
384
-			"SELECT posts.ID FROM $wpdb->posts as posts
348
+    /**
349
+     * (Force) Sends overdue notices.
350
+     *
351
+     * @param WPInv_Invoice $invoice
352
+     */
353
+    public function force_send_overdue_notice( $invoice ) {
354
+        $email = new GetPaid_Notification_Email( 'overdue', $invoice );
355
+        return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
356
+    }
357
+
358
+    /**
359
+     * Sends overdue notices.
360
+     *
361
+     * @TODO: Create an invoices query class.
362
+     */
363
+    public function overdue() {
364
+        global $wpdb;
365
+
366
+        $email = new GetPaid_Notification_Email( __FUNCTION__ );
367
+
368
+        // Fetch reminder days.
369
+        $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
370
+
371
+        // Abort if non is set.
372
+        if ( empty( $reminder_days ) ) {
373
+            return;
374
+        }
375
+
376
+        // Retrieve date query.
377
+        $date_query = $this->get_date_query( $reminder_days );
378
+
379
+        // Invoices table.
380
+        $table = $wpdb->prefix . 'getpaid_invoices';
381
+
382
+        // Fetch invoices.
383
+        $invoices  = $wpdb->get_col(
384
+            "SELECT posts.ID FROM $wpdb->posts as posts
385 385
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
386 386
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
387 387
 
388
-		foreach ( $invoices as $invoice ) {
388
+        foreach ( $invoices as $invoice ) {
389 389
 
390
-			// Only send this email for invoices created via the admin page.
391
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
392
-				$invoice       = new WPInv_Invoice( $invoice );
393
-				$email->object = $invoice;
390
+            // Only send this email for invoices created via the admin page.
391
+            if ( ! $this->is_payment_form_invoice( $invoice ) ) {
392
+                $invoice       = new WPInv_Invoice( $invoice );
393
+                $email->object = $invoice;
394 394
 
395
-				if ( $invoice->needs_payment() ) {
396
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
397
-				}
395
+                if ( $invoice->needs_payment() ) {
396
+                    $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
397
+                }
398 398
 
399
-			}
399
+            }
400 400
 
401
-		}
401
+        }
402 402
 
403
-	}
403
+    }
404 404
 
405
-	/**
406
-	 * Calculates the date query for an invoices query
407
-	 *
408
-	 * @param array $reminder_days
409
-	 * @return string
410
-	 */
411
-	public function get_date_query( $reminder_days ) {
405
+    /**
406
+     * Calculates the date query for an invoices query
407
+     *
408
+     * @param array $reminder_days
409
+     * @return string
410
+     */
411
+    public function get_date_query( $reminder_days ) {
412 412
 
413
-		$date_query = array(
414
-			'relation'  => 'OR'
415
-		);
413
+        $date_query = array(
414
+            'relation'  => 'OR'
415
+        );
416 416
 
417
-		foreach ( $reminder_days as $days ) {
418
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
417
+        foreach ( $reminder_days as $days ) {
418
+            $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
419 419
 
420
-			$date_query[] = array(
421
-				'year'  => $date['year'],
422
-				'month' => $date['month'],
423
-				'day'   => $date['day'],
424
-			);
420
+            $date_query[] = array(
421
+                'year'  => $date['year'],
422
+                'month' => $date['month'],
423
+                'day'   => $date['day'],
424
+            );
425 425
 
426
-		}
426
+        }
427 427
 
428
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
428
+        $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
429 429
 
430
-		return $date_query->get_sql();
430
+        return $date_query->get_sql();
431 431
 
432
-	}
432
+    }
433 433
 
434 434
 }
Please login to merge, or discard this patch.
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * This class handles invoice notificaiton emails.
@@ -52,22 +52,22 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function init_hooks() {
54 54
 
55
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 );
56
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
57
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
55
+		add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2);
56
+		add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2);
57
+		foreach ($this->invoice_actions as $hook => $email_type) {
58 58
 
59
-			$email = new GetPaid_Notification_Email( $email_type );
59
+			$email = new GetPaid_Notification_Email($email_type);
60 60
 
61
-			if ( ! $email->is_active() ) {
61
+			if (!$email->is_active()) {
62 62
 				continue;
63 63
 			}
64 64
 
65
-			if ( method_exists( $this, $email_type ) ) {
66
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
65
+			if (method_exists($this, $email_type)) {
66
+				add_action($hook, array($this, $email_type), 100, 2);
67 67
 				continue;
68 68
 			}
69 69
 
70
-			do_action( 'getpaid_invoice_notification_email_register_hook', $email );
70
+			do_action('getpaid_invoice_notification_email_register_hook', $email);
71 71
 
72 72
 		}
73 73
 
@@ -79,19 +79,19 @@  discard block
 block discarded – undo
79 79
 	 * @param array $merge_tags
80 80
 	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
81 81
 	 */
82
-	public function invoice_merge_tags( $merge_tags, $object ) {
82
+	public function invoice_merge_tags($merge_tags, $object) {
83 83
 
84
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
84
+		if (is_a($object, 'WPInv_Invoice')) {
85 85
 			return array_merge(
86 86
 				$merge_tags,
87
-				$this->get_invoice_merge_tags( $object )
87
+				$this->get_invoice_merge_tags($object)
88 88
 			);
89 89
 		}
90 90
 
91
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
91
+		if (is_a($object, 'WPInv_Subscription')) {
92 92
 			return array_merge(
93 93
 				$merge_tags,
94
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
94
+				$this->get_invoice_merge_tags($object->get_parent_payment())
95 95
 			);
96 96
 		}
97 97
 
@@ -105,31 +105,31 @@  discard block
 block discarded – undo
105 105
 	 * @param WPInv_Invoice $invoice
106 106
 	 * @return array
107 107
 	 */
108
-	public function get_invoice_merge_tags( $invoice ) {
108
+	public function get_invoice_merge_tags($invoice) {
109 109
 
110 110
 		// Abort if it does not exist.
111
-		if ( ! $invoice->get_id() ) {
111
+		if (!$invoice->get_id()) {
112 112
 			return array();
113 113
 		}
114 114
 
115 115
 		return array(
116
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
117
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
118
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
119
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
120
-			'{email}'               => sanitize_email( $invoice->get_email() ),
121
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
122
-			'{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
123
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
124
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
125
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
126
-			'{invoice_date}'        => getpaid_format_date_value( $invoice->get_date_created() ),
127
-			'{invoice_due_date}'    => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ),
128
-			'{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
129
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
130
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
131
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
132
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
116
+			'{name}'                => sanitize_text_field($invoice->get_user_full_name()),
117
+			'{full_name}'           => sanitize_text_field($invoice->get_user_full_name()),
118
+			'{first_name}'          => sanitize_text_field($invoice->get_first_name()),
119
+			'{last_name}'           => sanitize_text_field($invoice->get_last_name()),
120
+			'{email}'               => sanitize_email($invoice->get_email()),
121
+			'{invoice_number}'      => sanitize_text_field($invoice->get_number()),
122
+			'{invoice_total}'       => wpinv_price(wpinv_format_amount($invoice->get_total())),
123
+			'{invoice_link}'        => esc_url($invoice->get_view_url()),
124
+			'{invoice_pay_link}'    => esc_url($invoice->get_checkout_payment_url()),
125
+			'{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()),
126
+			'{invoice_date}'        => getpaid_format_date_value($invoice->get_date_created()),
127
+			'{invoice_due_date}'    => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')),
128
+			'{invoice_quote}'       => sanitize_text_field($invoice->get_type()),
129
+			'{invoice_label}'       => sanitize_text_field(ucfirst($invoice->get_type())),
130
+			'{invoice_description}' => wp_kses_post($invoice->get_description()),
131
+			'{subscription_name}'   => wp_kses_post($invoice->get_subscription_name()),
132
+			'{is_was}'              => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'),
133 133
 		);
134 134
 
135 135
 	}
@@ -143,35 +143,35 @@  discard block
 block discarded – undo
143 143
 	 * @param string|array $recipients
144 144
 	 * @param array $extra_args Extra template args.
145 145
 	 */
146
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
146
+	public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) {
147 147
 
148
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
148
+		do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email);
149 149
 
150 150
 		$mailer     = new GetPaid_Notification_Email_Sender();
151 151
 		$merge_tags = $email->get_merge_tags();
152 152
 
153 153
 		$result = $mailer->send(
154
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
155
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
156
-			$email->get_content( $merge_tags, $extra_args ),
154
+			apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email),
155
+			$email->add_merge_tags($email->get_subject(), $merge_tags),
156
+			$email->get_content($merge_tags, $extra_args),
157 157
 			$email->get_attachments()
158 158
 		);
159 159
 
160 160
 		// Maybe send a copy to the admin.
161
-		if ( $email->include_admin_bcc() ) {
161
+		if ($email->include_admin_bcc()) {
162 162
 			$mailer->send(
163 163
 				wpinv_get_admin_email(),
164
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
165
-				$email->get_content( $merge_tags ),
164
+				$email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags),
165
+				$email->get_content($merge_tags),
166 166
 				$email->get_attachments()
167 167
 			);
168 168
 		}
169 169
 
170
-		if ( ! $result ) {
171
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
170
+		if (!$result) {
171
+			$invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true);
172 172
 		}
173 173
 
174
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
174
+		do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email);
175 175
 
176 176
 		return $result;
177 177
 	}
@@ -182,14 +182,14 @@  discard block
 block discarded – undo
182 182
 	 * @param array $recipients
183 183
 	 * @param GetPaid_Notification_Email $email
184 184
 	 */
185
-	public function filter_email_recipients( $recipients, $email ) {
185
+	public function filter_email_recipients($recipients, $email) {
186 186
 
187
-		if ( ! $email->is_admin_email() ) {
187
+		if (!$email->is_admin_email()) {
188 188
 			$cc = $email->object->get_email_cc();
189 189
 
190
-			if ( ! empty( $cc ) ) {
191
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
192
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
190
+			if (!empty($cc)) {
191
+				$cc = array_map('sanitize_email', wpinv_parse_list($cc));
192
+				$recipients = array_filter(array_unique(array_merge($recipients, $cc)));
193 193
 			}
194 194
 
195 195
 		}
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
 	 *
204 204
 	 * @param WPInv_Invoice $invoice
205 205
 	 */
206
-	public function new_invoice( $invoice ) {
206
+	public function new_invoice($invoice) {
207 207
 
208
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
208
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
209 209
 		$recipient = wpinv_get_admin_email();
210 210
 
211
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
211
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
212 212
 
213 213
 	}
214 214
 
@@ -217,12 +217,12 @@  discard block
 block discarded – undo
217 217
 	 *
218 218
 	 * @param WPInv_Invoice $invoice
219 219
 	 */
220
-	public function cancelled_invoice( $invoice ) {
220
+	public function cancelled_invoice($invoice) {
221 221
 
222
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
222
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
223 223
 		$recipient = wpinv_get_admin_email();
224 224
 
225
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
225
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
226 226
 
227 227
 	}
228 228
 
@@ -231,12 +231,12 @@  discard block
 block discarded – undo
231 231
 	 *
232 232
 	 * @param WPInv_Invoice $invoice
233 233
 	 */
234
-	public function failed_invoice( $invoice ) {
234
+	public function failed_invoice($invoice) {
235 235
 
236
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
236
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
237 237
 		$recipient = wpinv_get_admin_email();
238 238
 
239
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
239
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
240 240
 
241 241
 	}
242 242
 
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 	 *
246 246
 	 * @param WPInv_Invoice $invoice
247 247
 	 */
248
-	public function onhold_invoice( $invoice ) {
248
+	public function onhold_invoice($invoice) {
249 249
 
250
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
250
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
251 251
 		$recipient = $invoice->get_email();
252 252
 
253
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
253
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
254 254
 
255 255
 	}
256 256
 
@@ -259,12 +259,12 @@  discard block
 block discarded – undo
259 259
 	 *
260 260
 	 * @param WPInv_Invoice $invoice
261 261
 	 */
262
-	public function processing_invoice( $invoice ) {
262
+	public function processing_invoice($invoice) {
263 263
 
264
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
264
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
265 265
 		$recipient = $invoice->get_email();
266 266
 
267
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
267
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
268 268
 
269 269
 	}
270 270
 
@@ -273,17 +273,17 @@  discard block
 block discarded – undo
273 273
 	 *
274 274
 	 * @param WPInv_Invoice $invoice
275 275
 	 */
276
-	public function completed_invoice( $invoice ) {
276
+	public function completed_invoice($invoice) {
277 277
 
278 278
 		// (Maybe) abort if it is a renewal invoice.
279
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
279
+		if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) {
280 280
 			return;
281 281
 		}
282 282
 
283
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
283
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
284 284
 		$recipient = $invoice->get_email();
285 285
 
286
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
286
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
287 287
 
288 288
 	}
289 289
 
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
 	 *
293 293
 	 * @param WPInv_Invoice $invoice
294 294
 	 */
295
-	public function refunded_invoice( $invoice ) {
295
+	public function refunded_invoice($invoice) {
296 296
 
297
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
297
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
298 298
 		$recipient = $invoice->get_email();
299 299
 
300
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
300
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
301 301
 
302 302
 	}
303 303
 
@@ -306,17 +306,17 @@  discard block
 block discarded – undo
306 306
 	 *
307 307
 	 * @param WPInv_Invoice $invoice
308 308
 	 */
309
-	public function user_invoice( $invoice ) {
309
+	public function user_invoice($invoice) {
310 310
 
311 311
 		// Only send this email for invoices created via the admin page.
312
-		if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) {
312
+		if ($this->is_payment_form_invoice($invoice->get_id())) {
313 313
 			return;
314 314
 		}
315 315
 
316
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
316
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
317 317
 		$recipient = $invoice->get_email();
318 318
 
319
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient );
319
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient);
320 320
 
321 321
 	}
322 322
 
@@ -326,8 +326,8 @@  discard block
 block discarded – undo
326 326
 	 * @param int $invoice
327 327
 	 * @return bool
328 328
 	 */
329
-	public function is_payment_form_invoice( $invoice ) {
330
-		return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true );
329
+	public function is_payment_form_invoice($invoice) {
330
+		return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true);
331 331
 	}
332 332
 
333 333
 	/**
@@ -336,12 +336,12 @@  discard block
 block discarded – undo
336 336
 	 * @param WPInv_Invoice $invoice
337 337
 	 * @param string $note
338 338
 	 */
339
-	public function user_note( $invoice, $note ) {
339
+	public function user_note($invoice, $note) {
340 340
 
341
-		$email     = new GetPaid_Notification_Email( __FUNCTION__, $invoice );
341
+		$email     = new GetPaid_Notification_Email(__FUNCTION__, $invoice);
342 342
 		$recipient = $invoice->get_email();
343 343
 
344
-		return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) );
344
+		return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note));
345 345
 
346 346
 	}
347 347
 
@@ -350,9 +350,9 @@  discard block
 block discarded – undo
350 350
 	 *
351 351
 	 * @param WPInv_Invoice $invoice
352 352
 	 */
353
-	public function force_send_overdue_notice( $invoice ) {
354
-		$email = new GetPaid_Notification_Email( 'overdue', $invoice );
355
-		return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() );
353
+	public function force_send_overdue_notice($invoice) {
354
+		$email = new GetPaid_Notification_Email('overdue', $invoice);
355
+		return $this->send_email($invoice, $email, 'overdue', $invoice->get_email());
356 356
 	}
357 357
 
358 358
 	/**
@@ -363,37 +363,37 @@  discard block
 block discarded – undo
363 363
 	public function overdue() {
364 364
 		global $wpdb;
365 365
 
366
-		$email = new GetPaid_Notification_Email( __FUNCTION__ );
366
+		$email = new GetPaid_Notification_Email(__FUNCTION__);
367 367
 
368 368
 		// Fetch reminder days.
369
-		$reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) );
369
+		$reminder_days = array_unique(wp_parse_id_list($email->get_option('days')));
370 370
 
371 371
 		// Abort if non is set.
372
-		if ( empty( $reminder_days ) ) {
372
+		if (empty($reminder_days)) {
373 373
 			return;
374 374
 		}
375 375
 
376 376
 		// Retrieve date query.
377
-		$date_query = $this->get_date_query( $reminder_days );
377
+		$date_query = $this->get_date_query($reminder_days);
378 378
 
379 379
 		// Invoices table.
380 380
 		$table = $wpdb->prefix . 'getpaid_invoices';
381 381
 
382 382
 		// Fetch invoices.
383
-		$invoices  = $wpdb->get_col(
383
+		$invoices = $wpdb->get_col(
384 384
 			"SELECT posts.ID FROM $wpdb->posts as posts
385 385
 			LEFT JOIN $table as invoices ON invoices.post_id = posts.ID
386 386
 			WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query");
387 387
 
388
-		foreach ( $invoices as $invoice ) {
388
+		foreach ($invoices as $invoice) {
389 389
 
390 390
 			// Only send this email for invoices created via the admin page.
391
-			if ( ! $this->is_payment_form_invoice( $invoice ) ) {
392
-				$invoice       = new WPInv_Invoice( $invoice );
391
+			if (!$this->is_payment_form_invoice($invoice)) {
392
+				$invoice       = new WPInv_Invoice($invoice);
393 393
 				$email->object = $invoice;
394 394
 
395
-				if ( $invoice->needs_payment() ) {
396
-					$this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() );
395
+				if ($invoice->needs_payment()) {
396
+					$this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email());
397 397
 				}
398 398
 
399 399
 			}
@@ -408,14 +408,14 @@  discard block
 block discarded – undo
408 408
 	 * @param array $reminder_days
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_date_query( $reminder_days ) {
411
+	public function get_date_query($reminder_days) {
412 412
 
413 413
 		$date_query = array(
414 414
 			'relation'  => 'OR'
415 415
 		);
416 416
 
417
-		foreach ( $reminder_days as $days ) {
418
-			$date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) );
417
+		foreach ($reminder_days as $days) {
418
+			$date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp'))));
419 419
 
420 420
 			$date_query[] = array(
421 421
 				'year'  => $date['year'],
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
 
426 426
 		}
427 427
 
428
-		$date_query = new WP_Date_Query( $date_query, 'invoices.due_date' );
428
+		$date_query = new WP_Date_Query($date_query, 'invoices.due_date');
429 429
 
430 430
 		return $date_query->get_sql();
431 431
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 3 patches
Indentation   +986 added lines, -986 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,996 +11,996 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Input {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function input($args = array()){
22
-		$defaults = array(
23
-			'type'       => 'text',
24
-			'name'       => '',
25
-			'class'      => '',
26
-			'id'         => '',
27
-			'placeholder'=> '',
28
-			'title'      => '',
29
-			'value'      => '',
30
-			'required'   => false,
31
-			'label'      => '',
32
-			'label_after'=> false,
33
-			'label_class'=> '',
34
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
-			'help_text'  => '',
36
-			'validation_text'   => '',
37
-			'validation_pattern' => '',
38
-			'no_wrap'    => false,
39
-			'input_group_right' => '',
40
-			'input_group_left' => '',
41
-			'input_group_right_inside' => false, // forces the input group inside the input
42
-			'input_group_left_inside' => false, // forces the input group inside the input
43
-			'step'       => '',
44
-			'switch'     => false, // to show checkbox as a switch
45
-			'checked'   => false, // set a checkbox or radio as selected
46
-			'password_toggle' => true, // toggle view/hide password
47
-			'element_require'   => '', // [%element_id%] == "1"
48
-			'extra_attributes'  => array() // an array of extra attributes
49
-		);
50
-
51
-		/**
52
-		 * Parse incoming $args into an array and merge it with $defaults
53
-		 */
54
-		$args   = wp_parse_args( $args, $defaults );
55
-		$output = '';
56
-		if ( ! empty( $args['type'] ) ) {
57
-			// hidden label option needs to be empty
58
-			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59
-
60
-			$type = sanitize_html_class( $args['type'] );
61
-
62
-			$help_text = '';
63
-			$label = '';
64
-			$label_after = $args['label_after'];
65
-			$label_args = array(
66
-				'title'=> $args['label'],
67
-				'for'=> $args['id'],
68
-				'class' => $args['label_class']." ",
69
-				'label_type' => $args['label_type']
70
-			);
71
-
72
-			// floating labels need label after
73
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
-				$label_after = true;
75
-				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76
-			}
77
-
78
-			// Some special sauce for files
79
-			if($type=='file' ){
80
-				$label_after = true; // if type file we need the label after
81
-				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
83
-				$label_after = true; // if type file we need the label after
84
-				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
86
-				$type = 'text';
87
-				//$args['class'] .= ' aui-flatpickr bg-initial ';
88
-				$args['class'] .= ' bg-initial ';
89
-
90
-				$args['extra_attributes']['data-aui-init'] = 'flatpickr';
91
-				// enqueue the script
92
-				$aui_settings = AyeCode_UI_Settings::instance();
93
-				$aui_settings->enqueue_flatpickr();
94
-			}
95
-
96
-
97
-			// open/type
98
-			$output .= '<input type="' . $type . '" ';
99
-
100
-			// name
101
-			if(!empty($args['name'])){
102
-				$output .= ' name="'.esc_attr($args['name']).'" ';
103
-			}
104
-
105
-			// id
106
-			if(!empty($args['id'])){
107
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
108
-			}
109
-
110
-			// placeholder
111
-			if(!empty($args['placeholder'])){
112
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
113
-			}
114
-
115
-			// title
116
-			if(!empty($args['title'])){
117
-				$output .= ' title="'.esc_attr($args['title']).'" ';
118
-			}
119
-
120
-			// value
121
-			if(!empty($args['value'])){
122
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
123
-			}
124
-
125
-			// checked, for radio and checkboxes
126
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
-				$output .= ' checked ';
128
-			}
129
-
130
-			// validation text
131
-			if(!empty($args['validation_text'])){
132
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
133
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134
-			}
135
-
136
-			// validation_pattern
137
-			if(!empty($args['validation_pattern'])){
138
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
139
-			}
140
-
141
-			// step (for numbers)
142
-			if(!empty($args['step'])){
143
-				$output .= ' step="'.$args['step'].'" ';
144
-			}
145
-
146
-			// required
147
-			if(!empty($args['required'])){
148
-				$output .= ' required ';
149
-			}
150
-
151
-			// class
152
-			$class = !empty($args['class']) ? $args['class'] : '';
153
-			$output .= ' class="form-control '.$class.'" ';
154
-
155
-			// data-attributes
156
-			$output .= AUI_Component_Helper::data_attributes($args);
157
-
158
-			// extra attributes
159
-			if(!empty($args['extra_attributes'])){
160
-				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161
-			}
162
-
163
-			// close
164
-			$output .= ' >';
165
-
166
-
167
-			// label
168
-			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
-				$label = self::label( $label_args, $type );
172
-			}
173
-
174
-			// help text
175
-			if(!empty($args['help_text'])){
176
-				$help_text = AUI_Component_Helper::help_text($args['help_text']);
177
-			}
178
-
179
-
180
-			// set help text in the correct possition
181
-			if($label_after){
182
-				$output .= $label . $help_text;
183
-			}
184
-
185
-			// some input types need a separate wrap
186
-			if($type == 'file') {
187
-				$output = self::wrap( array(
188
-					'content' => $output,
189
-					'class'   => 'form-group custom-file'
190
-				) );
191
-			}elseif($type == 'checkbox'){
192
-				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
-				$output = self::wrap( array(
194
-					'content' => $output,
195
-					'class'   => 'custom-control '.$wrap_class
196
-				) );
197
-
198
-				if($args['label_type']=='horizontal'){
199
-					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200
-				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
-
203
-
204
-				// allow password field to toggle view
205
-				$args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function input($args = array()){
22
+        $defaults = array(
23
+            'type'       => 'text',
24
+            'name'       => '',
25
+            'class'      => '',
26
+            'id'         => '',
27
+            'placeholder'=> '',
28
+            'title'      => '',
29
+            'value'      => '',
30
+            'required'   => false,
31
+            'label'      => '',
32
+            'label_after'=> false,
33
+            'label_class'=> '',
34
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
35
+            'help_text'  => '',
36
+            'validation_text'   => '',
37
+            'validation_pattern' => '',
38
+            'no_wrap'    => false,
39
+            'input_group_right' => '',
40
+            'input_group_left' => '',
41
+            'input_group_right_inside' => false, // forces the input group inside the input
42
+            'input_group_left_inside' => false, // forces the input group inside the input
43
+            'step'       => '',
44
+            'switch'     => false, // to show checkbox as a switch
45
+            'checked'   => false, // set a checkbox or radio as selected
46
+            'password_toggle' => true, // toggle view/hide password
47
+            'element_require'   => '', // [%element_id%] == "1"
48
+            'extra_attributes'  => array() // an array of extra attributes
49
+        );
50
+
51
+        /**
52
+         * Parse incoming $args into an array and merge it with $defaults
53
+         */
54
+        $args   = wp_parse_args( $args, $defaults );
55
+        $output = '';
56
+        if ( ! empty( $args['type'] ) ) {
57
+            // hidden label option needs to be empty
58
+            $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59
+
60
+            $type = sanitize_html_class( $args['type'] );
61
+
62
+            $help_text = '';
63
+            $label = '';
64
+            $label_after = $args['label_after'];
65
+            $label_args = array(
66
+                'title'=> $args['label'],
67
+                'for'=> $args['id'],
68
+                'class' => $args['label_class']." ",
69
+                'label_type' => $args['label_type']
70
+            );
71
+
72
+            // floating labels need label after
73
+            if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
+                $label_after = true;
75
+                $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76
+            }
77
+
78
+            // Some special sauce for files
79
+            if($type=='file' ){
80
+                $label_after = true; // if type file we need the label after
81
+                $args['class'] .= ' custom-file-input ';
82
+            }elseif($type=='checkbox'){
83
+                $label_after = true; // if type file we need the label after
84
+                $args['class'] .= ' custom-control-input ';
85
+            }elseif($type=='datepicker' || $type=='timepicker'){
86
+                $type = 'text';
87
+                //$args['class'] .= ' aui-flatpickr bg-initial ';
88
+                $args['class'] .= ' bg-initial ';
89
+
90
+                $args['extra_attributes']['data-aui-init'] = 'flatpickr';
91
+                // enqueue the script
92
+                $aui_settings = AyeCode_UI_Settings::instance();
93
+                $aui_settings->enqueue_flatpickr();
94
+            }
95
+
96
+
97
+            // open/type
98
+            $output .= '<input type="' . $type . '" ';
99
+
100
+            // name
101
+            if(!empty($args['name'])){
102
+                $output .= ' name="'.esc_attr($args['name']).'" ';
103
+            }
104
+
105
+            // id
106
+            if(!empty($args['id'])){
107
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
108
+            }
109
+
110
+            // placeholder
111
+            if(!empty($args['placeholder'])){
112
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
113
+            }
114
+
115
+            // title
116
+            if(!empty($args['title'])){
117
+                $output .= ' title="'.esc_attr($args['title']).'" ';
118
+            }
119
+
120
+            // value
121
+            if(!empty($args['value'])){
122
+                $output .= ' value="'.sanitize_text_field($args['value']).'" ';
123
+            }
124
+
125
+            // checked, for radio and checkboxes
126
+            if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
+                $output .= ' checked ';
128
+            }
129
+
130
+            // validation text
131
+            if(!empty($args['validation_text'])){
132
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
133
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134
+            }
135
+
136
+            // validation_pattern
137
+            if(!empty($args['validation_pattern'])){
138
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
139
+            }
140
+
141
+            // step (for numbers)
142
+            if(!empty($args['step'])){
143
+                $output .= ' step="'.$args['step'].'" ';
144
+            }
145
+
146
+            // required
147
+            if(!empty($args['required'])){
148
+                $output .= ' required ';
149
+            }
150
+
151
+            // class
152
+            $class = !empty($args['class']) ? $args['class'] : '';
153
+            $output .= ' class="form-control '.$class.'" ';
154
+
155
+            // data-attributes
156
+            $output .= AUI_Component_Helper::data_attributes($args);
157
+
158
+            // extra attributes
159
+            if(!empty($args['extra_attributes'])){
160
+                $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161
+            }
162
+
163
+            // close
164
+            $output .= ' >';
165
+
166
+
167
+            // label
168
+            if(!empty($args['label'])){
169
+                if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
+                elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
+                $label = self::label( $label_args, $type );
172
+            }
173
+
174
+            // help text
175
+            if(!empty($args['help_text'])){
176
+                $help_text = AUI_Component_Helper::help_text($args['help_text']);
177
+            }
178
+
179
+
180
+            // set help text in the correct possition
181
+            if($label_after){
182
+                $output .= $label . $help_text;
183
+            }
184
+
185
+            // some input types need a separate wrap
186
+            if($type == 'file') {
187
+                $output = self::wrap( array(
188
+                    'content' => $output,
189
+                    'class'   => 'form-group custom-file'
190
+                ) );
191
+            }elseif($type == 'checkbox'){
192
+                $wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
+                $output = self::wrap( array(
194
+                    'content' => $output,
195
+                    'class'   => 'custom-control '.$wrap_class
196
+                ) );
197
+
198
+                if($args['label_type']=='horizontal'){
199
+                    $output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200
+                }
201
+            }elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
+
203
+
204
+                // allow password field to toggle view
205
+                $args['input_group_right'] = '<span class="input-group-text c-pointer px-3" 
206 206
 onclick="var $el = jQuery(this).find(\'i\');$el.toggleClass(\'fa-eye fa-eye-slash\');
207 207
 var $eli = jQuery(this).parent().parent().find(\'input\');
208 208
 if($el.hasClass(\'fa-eye\'))
209 209
 {$eli.attr(\'type\',\'text\');}
210 210
 else{$eli.attr(\'type\',\'password\');}"
211 211
 ><i class="far fa-fw fa-eye-slash"></i></span>';
212
-			}
213
-
214
-			// input group wraps
215
-			if($args['input_group_left'] || $args['input_group_right']){
216
-				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
-				if($args['input_group_left']){
218
-					$output = self::wrap( array(
219
-						'content' => $output,
220
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
-						'input_group_left' => $args['input_group_left'],
222
-						'input_group_left_inside'    => $args['input_group_left_inside']
223
-					) );
224
-				}
225
-				if($args['input_group_right']){
226
-					$output = self::wrap( array(
227
-						'content' => $output,
228
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
-						'input_group_right' => $args['input_group_right'],
230
-						'input_group_right_inside'    => $args['input_group_right_inside']
231
-					) );
232
-				}
233
-
234
-			}
235
-
236
-			if(!$label_after){
237
-				$output .= $help_text;
238
-			}
239
-
240
-
241
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
-				$output = self::wrap( array(
243
-					'content' => $output,
244
-					'class'   => 'col-sm-10',
245
-				) );
246
-			}
247
-
248
-			if(!$label_after){
249
-				$output = $label . $output;
250
-			}
251
-
252
-			// wrap
253
-			if(!$args['no_wrap']){
254
-
255
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
257
-				$output = self::wrap(array(
258
-					'content' => $output,
259
-					'class'   => $wrap_class,
260
-					'element_require'   => $args['element_require'],
261
-					'argument_id'  => $args['id']
262
-				));
263
-			}
264
-
265
-
266
-
267
-		}
268
-
269
-		return $output;
270
-	}
271
-
272
-	/**
273
-	 * Build the component.
274
-	 *
275
-	 * @param array $args
276
-	 *
277
-	 * @return string The rendered component.
278
-	 */
279
-	public static function textarea($args = array()){
280
-		$defaults = array(
281
-			'name'       => '',
282
-			'class'      => '',
283
-			'id'         => '',
284
-			'placeholder'=> '',
285
-			'title'      => '',
286
-			'value'      => '',
287
-			'required'   => false,
288
-			'label'      => '',
289
-			'label_after'=> false,
290
-			'label_class'      => '',
291
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
292
-			'help_text'  => '',
293
-			'validation_text'   => '',
294
-			'validation_pattern' => '',
295
-			'no_wrap'    => false,
296
-			'rows'      => '',
297
-			'wysiwyg'   => false,
298
-			'element_require'   => '', // [%element_id%] == "1"
299
-		);
300
-
301
-		/**
302
-		 * Parse incoming $args into an array and merge it with $defaults
303
-		 */
304
-		$args   = wp_parse_args( $args, $defaults );
305
-		$output = '';
306
-
307
-		// hidden label option needs to be empty
308
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309
-
310
-		// floating labels don't work with wysiwyg so set it as top
311
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
312
-			$args['label_type'] = 'top';
313
-		}
314
-
315
-		$label_after = $args['label_after'];
316
-
317
-		// floating labels need label after
318
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
319
-			$label_after = true;
320
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321
-		}
322
-
323
-		// label
324
-		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
326
-			$label_args = array(
327
-				'title'=> $args['label'],
328
-				'for'=> $args['id'],
329
-				'class' => $args['label_class']." ",
330
-				'label_type' => $args['label_type']
331
-			);
332
-			$output .= self::label( $label_args );
333
-		}
334
-
335
-		// maybe horizontal label
336
-		if($args['label_type']=='horizontal'){
337
-			$output .= '<div class="col-sm-10">';
338
-		}
339
-
340
-		if(!empty($args['wysiwyg'])){
341
-			ob_start();
342
-			$content = $args['value'];
343
-			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
344
-			$settings = array(
345
-				'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
346
-				'quicktags'     => false,
347
-				'media_buttons' => false,
348
-				'editor_class'  => 'form-control',
349
-				'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
350
-				'teeny'         => true,
351
-			);
352
-
353
-			// maybe set settings if array
354
-			if(is_array($args['wysiwyg'])){
355
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
356
-			}
357
-
358
-			wp_editor( $content, $editor_id, $settings );
359
-			$output .= ob_get_clean();
360
-		}else{
361
-
362
-			// open
363
-			$output .= '<textarea ';
364
-
365
-			// name
366
-			if(!empty($args['name'])){
367
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
368
-			}
369
-
370
-			// id
371
-			if(!empty($args['id'])){
372
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
373
-			}
374
-
375
-			// placeholder
376
-			if(!empty($args['placeholder'])){
377
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
378
-			}
379
-
380
-			// title
381
-			if(!empty($args['title'])){
382
-				$output .= ' title="'.esc_attr($args['title']).'" ';
383
-			}
384
-
385
-			// validation text
386
-			if(!empty($args['validation_text'])){
387
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
388
-				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389
-			}
390
-
391
-			// validation_pattern
392
-			if(!empty($args['validation_pattern'])){
393
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
394
-			}
395
-
396
-			// required
397
-			if(!empty($args['required'])){
398
-				$output .= ' required ';
399
-			}
400
-
401
-			// rows
402
-			if(!empty($args['rows'])){
403
-				$output .= ' rows="'.absint($args['rows']).'" ';
404
-			}
405
-
406
-
407
-			// class
408
-			$class = !empty($args['class']) ? $args['class'] : '';
409
-			$output .= ' class="form-control '.$class.'" ';
410
-
411
-
412
-			// close tag
413
-			$output .= ' >';
414
-
415
-			// value
416
-			if(!empty($args['value'])){
417
-				$output .= sanitize_textarea_field($args['value']);
418
-			}
419
-
420
-			// closing tag
421
-			$output .= '</textarea>';
422
-
423
-		}
424
-
425
-		if(!empty($args['label']) && $label_after){
426
-			$label_args = array(
427
-				'title'=> $args['label'],
428
-				'for'=> $args['id'],
429
-				'class' => $args['label_class']." ",
430
-				'label_type' => $args['label_type']
431
-			);
432
-			$output .= self::label( $label_args );
433
-		}
434
-
435
-		// help text
436
-		if(!empty($args['help_text'])){
437
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
438
-		}
439
-
440
-		// maybe horizontal label
441
-		if($args['label_type']=='horizontal'){
442
-			$output .= '</div>';
443
-		}
444
-
445
-
446
-		// wrap
447
-		if(!$args['no_wrap']){
448
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
450
-			$output = self::wrap(array(
451
-				'content' => $output,
452
-				'class'   => $wrap_class,
453
-				'element_require'   => $args['element_require'],
454
-				'argument_id'  => $args['id']
455
-			));
456
-		}
457
-
458
-
459
-		return $output;
460
-	}
461
-
462
-	public static function label($args = array(), $type = ''){
463
-		//<label for="exampleInputEmail1">Email address</label>
464
-		$defaults = array(
465
-			'title'       => 'div',
466
-			'for'      => '',
467
-			'class'      => '',
468
-			'label_type'    => '', // empty = hidden, top, horizontal
469
-		);
470
-
471
-		/**
472
-		 * Parse incoming $args into an array and merge it with $defaults
473
-		 */
474
-		$args   = wp_parse_args( $args, $defaults );
475
-		$output = '';
476
-
477
-		if($args['title']){
478
-
479
-			// maybe hide labels //@todo set a global option for visibility class
480
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481
-				$class = $args['class'];
482
-			}else{
483
-				$class = 'sr-only '.$args['class'];
484
-			}
485
-
486
-			// maybe horizontal
487
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
488
-				$class .= ' col-sm-2 col-form-label';
489
-			}
490
-
491
-			// open
492
-			$output .= '<label ';
493
-
494
-			// for
495
-			if(!empty($args['for'])){
496
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
497
-			}
498
-
499
-			// class
500
-			$output .= ' class="'.$class.'" ';
501
-
502
-			// close
503
-			$output .= '>';
504
-
505
-
506
-			// title, don't escape fully as can contain html
507
-			if(!empty($args['title'])){
508
-				$output .= wp_kses_post($args['title']);
509
-			}
510
-
511
-			// close wrap
512
-			$output .= '</label>';
513
-
514
-
515
-		}
516
-
517
-
518
-		return $output;
519
-	}
520
-
521
-	public static function wrap($args = array()){
522
-		$defaults = array(
523
-			'type'       => 'div',
524
-			'class'      => 'form-group',
525
-			'content'   => '',
526
-			'input_group_left' => '',
527
-			'input_group_right' => '',
528
-			'input_group_left_inside' => false,
529
-			'input_group_right_inside' => false,
530
-			'element_require'   => '',
531
-			'argument_id'   => '',
532
-		);
533
-
534
-		/**
535
-		 * Parse incoming $args into an array and merge it with $defaults
536
-		 */
537
-		$args   = wp_parse_args( $args, $defaults );
538
-		$output = '';
539
-		if($args['type']){
540
-
541
-			// open
542
-			$output .= '<'.sanitize_html_class($args['type']);
543
-
544
-			// element require
545
-			if(!empty($args['element_require'])){
546
-				$output .= AUI_Component_Helper::element_require($args['element_require']);
547
-				$args['class'] .= " aui-conditional-field";
548
-			}
549
-
550
-			// argument_id
551
-			if( !empty($args['argument_id']) ){
552
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
553
-			}
554
-
555
-			// class
556
-			$class = !empty($args['class']) ? $args['class'] : '';
557
-			$output .= ' class="'.$class.'" ';
558
-
559
-			// close wrap
560
-			$output .= ' >';
561
-
562
-
563
-			// Input group left
564
-			if(!empty($args['input_group_left'])){
565
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
568
-			}
569
-
570
-			// content
571
-			$output .= $args['content'];
572
-
573
-			// Input group right
574
-			if(!empty($args['input_group_right'])){
575
-				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
578
-			}
579
-
580
-
581
-			// close wrap
582
-			$output .= '</'.sanitize_html_class($args['type']).'>';
583
-
584
-
585
-		}else{
586
-			$output = $args['content'];
587
-		}
588
-
589
-		return $output;
590
-	}
591
-
592
-	/**
593
-	 * Build the component.
594
-	 *
595
-	 * @param array $args
596
-	 *
597
-	 * @return string The rendered component.
598
-	 */
599
-	public static function select($args = array()){
600
-		$defaults = array(
601
-			'class'      => '',
602
-			'id'         => '',
603
-			'title'      => '',
604
-			'value'      => '', // can be an array or a string
605
-			'required'   => false,
606
-			'label'      => '',
607
-			'label_after'=> false,
608
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
609
-			'label_class'      => '',
610
-			'help_text'  => '',
611
-			'placeholder'=> '',
612
-			'options'    => array(), // array or string
613
-			'icon'       => '',
614
-			'multiple'   => false,
615
-			'select2'    => false,
616
-			'no_wrap'    => false,
617
-			'element_require'   => '', // [%element_id%] == "1"
618
-			'extra_attributes'  => array(), // an array of extra attributes
619
-		);
620
-
621
-		/**
622
-		 * Parse incoming $args into an array and merge it with $defaults
623
-		 */
624
-		$args   = wp_parse_args( $args, $defaults );
625
-		$output = '';
626
-
627
-		// for now lets hide floating labels
628
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
629
-
630
-		// hidden label option needs to be empty
631
-		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
632
-
633
-
634
-		$label_after = $args['label_after'];
635
-
636
-		// floating labels need label after
637
-		if( $args['label_type'] == 'floating' ){
638
-			$label_after = true;
639
-			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640
-		}
641
-
642
-		// Maybe setup select2
643
-		$is_select2 = false;
644
-		if(!empty($args['select2'])){
645
-			$args['class'] .= ' aui-select2';
646
-			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
648
-			$is_select2 = true;
649
-		}
650
-
651
-		// select2 tags
652
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
653
-			$args['data-tags'] = 'true';
654
-			$args['data-token-separators'] = "[',']";
655
-			$args['multiple'] = true;
656
-		}
657
-
658
-		// select2 placeholder
659
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
660
-			$args['data-placeholder'] = esc_attr($args['placeholder']);
661
-			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662
-		}
663
-
664
-		// label
665
-		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
667
-			$label_args = array(
668
-				'title'=> $args['label'],
669
-				'for'=> $args['id'],
670
-				'class' => $args['label_class']." ",
671
-				'label_type' => $args['label_type']
672
-			);
673
-			$output .= self::label($label_args);
674
-		}
675
-
676
-		// maybe horizontal label
677
-		if($args['label_type']=='horizontal'){
678
-			$output .= '<div class="col-sm-10">';
679
-		}
680
-
681
-		// open/type
682
-		$output .= '<select ';
683
-
684
-		// style
685
-		if($is_select2){
686
-			$output .= " style='width:100%;' ";
687
-		}
688
-
689
-		// element require
690
-		if(!empty($args['element_require'])){
691
-			$output .= AUI_Component_Helper::element_require($args['element_require']);
692
-			$args['class'] .= " aui-conditional-field";
693
-		}
694
-
695
-		// class
696
-		$class = !empty($args['class']) ? $args['class'] : '';
697
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
698
-
699
-		// name
700
-		if(!empty($args['name'])){
701
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
702
-		}
703
-
704
-		// id
705
-		if(!empty($args['id'])){
706
-			$output .= AUI_Component_Helper::id($args['id']);
707
-		}
708
-
709
-		// title
710
-		if(!empty($args['title'])){
711
-			$output .= AUI_Component_Helper::title($args['title']);
712
-		}
713
-
714
-		// data-attributes
715
-		$output .= AUI_Component_Helper::data_attributes($args);
716
-
717
-		// aria-attributes
718
-		$output .= AUI_Component_Helper::aria_attributes($args);
719
-
720
-		// extra attributes
721
-		if(!empty($args['extra_attributes'])){
722
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723
-		}
724
-
725
-		// required
726
-		if(!empty($args['required'])){
727
-			$output .= ' required ';
728
-		}
729
-
730
-		// multiple
731
-		if(!empty($args['multiple'])){
732
-			$output .= ' multiple ';
733
-		}
734
-
735
-		// close opening tag
736
-		$output .= ' >';
737
-
738
-		// placeholder
739
-		if(!empty($args['placeholder']) && !$is_select2){
740
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
742
-			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743
-		}
744
-
745
-		// Options
746
-		if(!empty($args['options'])){
747
-
748
-			if(!is_array($args['options'])){
749
-				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
751
-				foreach($args['options'] as $val => $name){
752
-					$selected = '';
753
-					if(is_array($name)){
754
-						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755
-							$option_label = isset($name['label']) ? $name['label'] : '';
756
-
757
-							$output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
758
-						} else {
759
-							$option_label = isset($name['label']) ? $name['label'] : '';
760
-							$option_value = isset($name['value']) ? $name['value'] : '';
761
-							if(!empty($args['multiple']) && !empty($args['value'])){
762
-								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
-							} elseif(!empty($args['value'])) {
764
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
765
-							}
766
-
767
-							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768
-						}
769
-					}else{
770
-						if(!empty($args['value'])){
771
-							if(is_array($args['value'])){
772
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
-							} elseif(!empty($args['value'])) {
774
-								$selected = selected( $args['value'], $val, false);
775
-							}
776
-						}
777
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
778
-					}
779
-				}
780
-			}
781
-
782
-		}
783
-
784
-		// closing tag
785
-		$output .= '</select>';
786
-
787
-		if(!empty($args['label']) && $label_after){
788
-			$label_args = array(
789
-				'title'=> $args['label'],
790
-				'for'=> $args['id'],
791
-				'class' => $args['label_class']." ",
792
-				'label_type' => $args['label_type']
793
-			);
794
-			$output .= self::label($label_args);
795
-		}
796
-
797
-		// help text
798
-		if(!empty($args['help_text'])){
799
-			$output .= AUI_Component_Helper::help_text($args['help_text']);
800
-		}
801
-
802
-		// maybe horizontal label
803
-		if($args['label_type']=='horizontal'){
804
-			$output .= '</div>';
805
-		}
806
-
807
-
808
-		// wrap
809
-		if(!$args['no_wrap']){
810
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
811
-			$output = self::wrap(array(
812
-				'content' => $output,
813
-				'class'   => $wrap_class,
814
-				'element_require'   => $args['element_require'],
815
-				'argument_id'  => $args['id']
816
-			));
817
-		}
818
-
819
-
820
-		return $output;
821
-	}
822
-
823
-	/**
824
-	 * Build the component.
825
-	 *
826
-	 * @param array $args
827
-	 *
828
-	 * @return string The rendered component.
829
-	 */
830
-	public static function radio($args = array()){
831
-		$defaults = array(
832
-			'class'      => '',
833
-			'id'         => '',
834
-			'title'      => '',
835
-			'horizontal' => false, // sets the lable horizontal
836
-			'value'      => '',
837
-			'label'      => '',
838
-			'label_class'=> '',
839
-			'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
840
-			'inline'     => true,
841
-			'required'   => false,
842
-			'options'    => array(),
843
-			'icon'       => '',
844
-			'no_wrap'    => false,
845
-			'element_require'   => '', // [%element_id%] == "1"
846
-			'extra_attributes'  => array() // an array of extra attributes
847
-		);
848
-
849
-		/**
850
-		 * Parse incoming $args into an array and merge it with $defaults
851
-		 */
852
-		$args   = wp_parse_args( $args, $defaults );
853
-
854
-		// for now lets use horizontal for floating
855
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
856
-
857
-		$label_args = array(
858
-			'title'=> $args['label'],
859
-			'class' => $args['label_class']." pt-0 ",
860
-			'label_type' => $args['label_type']
861
-		);
862
-
863
-		$output = '';
864
-
865
-
866
-
867
-		// label before
868
-		if(!empty($args['label'])){
869
-			$output .= self::label( $label_args, 'radio' );
870
-		}
871
-
872
-		// maybe horizontal label
873
-		if($args['label_type']=='horizontal'){
874
-			$output .= '<div class="col-sm-10">';
875
-		}
876
-
877
-		if(!empty($args['options'])){
878
-			$count = 0;
879
-			foreach($args['options'] as $value => $label){
880
-				$option_args = $args;
881
-				$option_args['value'] = $value;
882
-				$option_args['label'] = $label;
883
-				$option_args['checked'] = $value == $args['value'] ? true : false;
884
-				$output .= self::radio_option($option_args,$count);
885
-				$count++;
886
-			}
887
-		}
888
-
889
-		// maybe horizontal label
890
-		if($args['label_type']=='horizontal'){
891
-			$output .= '</div>';
892
-		}
893
-
894
-
895
-		// wrap
896
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
897
-		$output = self::wrap(array(
898
-			'content' => $output,
899
-			'class'   => $wrap_class,
900
-			'element_require'   => $args['element_require'],
901
-			'argument_id'  => $args['id']
902
-		));
903
-
904
-
905
-		return $output;
906
-	}
907
-
908
-	/**
909
-	 * Build the component.
910
-	 *
911
-	 * @param array $args
912
-	 *
913
-	 * @return string The rendered component.
914
-	 */
915
-	public static function radio_option($args = array(),$count = ''){
916
-		$defaults = array(
917
-			'class'      => '',
918
-			'id'         => '',
919
-			'title'      => '',
920
-			'value'      => '',
921
-			'required'   => false,
922
-			'inline'     => true,
923
-			'label'      => '',
924
-			'options'    => array(),
925
-			'icon'       => '',
926
-			'no_wrap'    => false,
927
-			'extra_attributes'  => array() // an array of extra attributes
928
-		);
929
-
930
-		/**
931
-		 * Parse incoming $args into an array and merge it with $defaults
932
-		 */
933
-		$args   = wp_parse_args( $args, $defaults );
934
-
935
-		$output = '';
936
-
937
-		// open/type
938
-		$output .= '<input type="radio"';
939
-
940
-		// class
941
-		$output .= ' class="form-check-input" ';
942
-
943
-		// name
944
-		if(!empty($args['name'])){
945
-			$output .= AUI_Component_Helper::name($args['name']);
946
-		}
947
-
948
-		// id
949
-		if(!empty($args['id'])){
950
-			$output .= AUI_Component_Helper::id($args['id'].$count);
951
-		}
952
-
953
-		// title
954
-		if(!empty($args['title'])){
955
-			$output .= AUI_Component_Helper::title($args['title']);
956
-		}
957
-
958
-		// value
959
-		if(isset($args['value'])){
960
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
961
-		}
962
-
963
-		// checked, for radio and checkboxes
964
-		if( $args['checked'] ){
965
-			$output .= ' checked ';
966
-		}
967
-
968
-		// data-attributes
969
-		$output .= AUI_Component_Helper::data_attributes($args);
970
-
971
-		// aria-attributes
972
-		$output .= AUI_Component_Helper::aria_attributes($args);
973
-
974
-		// extra attributes
975
-		if(!empty($args['extra_attributes'])){
976
-			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977
-		}
978
-
979
-		// required
980
-		if(!empty($args['required'])){
981
-			$output .= ' required ';
982
-		}
983
-
984
-		// close opening tag
985
-		$output .= ' >';
986
-
987
-		// label
988
-		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
990
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991
-		}
992
-
993
-		// wrap
994
-		if(!$args['no_wrap']){
995
-			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996
-			$output = self::wrap(array(
997
-				'content' => $output,
998
-				'class' => $wrap_class
999
-			));
1000
-		}
1001
-
1002
-
1003
-		return $output;
1004
-	}
212
+            }
213
+
214
+            // input group wraps
215
+            if($args['input_group_left'] || $args['input_group_right']){
216
+                $w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
+                if($args['input_group_left']){
218
+                    $output = self::wrap( array(
219
+                        'content' => $output,
220
+                        'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
+                        'input_group_left' => $args['input_group_left'],
222
+                        'input_group_left_inside'    => $args['input_group_left_inside']
223
+                    ) );
224
+                }
225
+                if($args['input_group_right']){
226
+                    $output = self::wrap( array(
227
+                        'content' => $output,
228
+                        'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
+                        'input_group_right' => $args['input_group_right'],
230
+                        'input_group_right_inside'    => $args['input_group_right_inside']
231
+                    ) );
232
+                }
233
+
234
+            }
235
+
236
+            if(!$label_after){
237
+                $output .= $help_text;
238
+            }
239
+
240
+
241
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
+                $output = self::wrap( array(
243
+                    'content' => $output,
244
+                    'class'   => 'col-sm-10',
245
+                ) );
246
+            }
247
+
248
+            if(!$label_after){
249
+                $output = $label . $output;
250
+            }
251
+
252
+            // wrap
253
+            if(!$args['no_wrap']){
254
+
255
+                $form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
+                $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
257
+                $output = self::wrap(array(
258
+                    'content' => $output,
259
+                    'class'   => $wrap_class,
260
+                    'element_require'   => $args['element_require'],
261
+                    'argument_id'  => $args['id']
262
+                ));
263
+            }
264
+
265
+
266
+
267
+        }
268
+
269
+        return $output;
270
+    }
271
+
272
+    /**
273
+     * Build the component.
274
+     *
275
+     * @param array $args
276
+     *
277
+     * @return string The rendered component.
278
+     */
279
+    public static function textarea($args = array()){
280
+        $defaults = array(
281
+            'name'       => '',
282
+            'class'      => '',
283
+            'id'         => '',
284
+            'placeholder'=> '',
285
+            'title'      => '',
286
+            'value'      => '',
287
+            'required'   => false,
288
+            'label'      => '',
289
+            'label_after'=> false,
290
+            'label_class'      => '',
291
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
292
+            'help_text'  => '',
293
+            'validation_text'   => '',
294
+            'validation_pattern' => '',
295
+            'no_wrap'    => false,
296
+            'rows'      => '',
297
+            'wysiwyg'   => false,
298
+            'element_require'   => '', // [%element_id%] == "1"
299
+        );
300
+
301
+        /**
302
+         * Parse incoming $args into an array and merge it with $defaults
303
+         */
304
+        $args   = wp_parse_args( $args, $defaults );
305
+        $output = '';
306
+
307
+        // hidden label option needs to be empty
308
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309
+
310
+        // floating labels don't work with wysiwyg so set it as top
311
+        if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
312
+            $args['label_type'] = 'top';
313
+        }
314
+
315
+        $label_after = $args['label_after'];
316
+
317
+        // floating labels need label after
318
+        if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
319
+            $label_after = true;
320
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321
+        }
322
+
323
+        // label
324
+        if(!empty($args['label']) && is_array($args['label'])){
325
+        }elseif(!empty($args['label']) && !$label_after){
326
+            $label_args = array(
327
+                'title'=> $args['label'],
328
+                'for'=> $args['id'],
329
+                'class' => $args['label_class']." ",
330
+                'label_type' => $args['label_type']
331
+            );
332
+            $output .= self::label( $label_args );
333
+        }
334
+
335
+        // maybe horizontal label
336
+        if($args['label_type']=='horizontal'){
337
+            $output .= '<div class="col-sm-10">';
338
+        }
339
+
340
+        if(!empty($args['wysiwyg'])){
341
+            ob_start();
342
+            $content = $args['value'];
343
+            $editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
344
+            $settings = array(
345
+                'textarea_rows' => !empty(absint($args['rows'])) ? absint($args['rows']) : 4,
346
+                'quicktags'     => false,
347
+                'media_buttons' => false,
348
+                'editor_class'  => 'form-control',
349
+                'textarea_name' => !empty($args['name']) ? sanitize_html_class($args['name']) : sanitize_html_class($args['id']),
350
+                'teeny'         => true,
351
+            );
352
+
353
+            // maybe set settings if array
354
+            if(is_array($args['wysiwyg'])){
355
+                $settings  = wp_parse_args( $args['wysiwyg'], $settings );
356
+            }
357
+
358
+            wp_editor( $content, $editor_id, $settings );
359
+            $output .= ob_get_clean();
360
+        }else{
361
+
362
+            // open
363
+            $output .= '<textarea ';
364
+
365
+            // name
366
+            if(!empty($args['name'])){
367
+                $output .= ' name="'.sanitize_html_class($args['name']).'" ';
368
+            }
369
+
370
+            // id
371
+            if(!empty($args['id'])){
372
+                $output .= ' id="'.sanitize_html_class($args['id']).'" ';
373
+            }
374
+
375
+            // placeholder
376
+            if(!empty($args['placeholder'])){
377
+                $output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
378
+            }
379
+
380
+            // title
381
+            if(!empty($args['title'])){
382
+                $output .= ' title="'.esc_attr($args['title']).'" ';
383
+            }
384
+
385
+            // validation text
386
+            if(!empty($args['validation_text'])){
387
+                $output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
388
+                $output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389
+            }
390
+
391
+            // validation_pattern
392
+            if(!empty($args['validation_pattern'])){
393
+                $output .= ' pattern="'.$args['validation_pattern'].'" ';
394
+            }
395
+
396
+            // required
397
+            if(!empty($args['required'])){
398
+                $output .= ' required ';
399
+            }
400
+
401
+            // rows
402
+            if(!empty($args['rows'])){
403
+                $output .= ' rows="'.absint($args['rows']).'" ';
404
+            }
405
+
406
+
407
+            // class
408
+            $class = !empty($args['class']) ? $args['class'] : '';
409
+            $output .= ' class="form-control '.$class.'" ';
410
+
411
+
412
+            // close tag
413
+            $output .= ' >';
414
+
415
+            // value
416
+            if(!empty($args['value'])){
417
+                $output .= sanitize_textarea_field($args['value']);
418
+            }
419
+
420
+            // closing tag
421
+            $output .= '</textarea>';
422
+
423
+        }
424
+
425
+        if(!empty($args['label']) && $label_after){
426
+            $label_args = array(
427
+                'title'=> $args['label'],
428
+                'for'=> $args['id'],
429
+                'class' => $args['label_class']." ",
430
+                'label_type' => $args['label_type']
431
+            );
432
+            $output .= self::label( $label_args );
433
+        }
434
+
435
+        // help text
436
+        if(!empty($args['help_text'])){
437
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
438
+        }
439
+
440
+        // maybe horizontal label
441
+        if($args['label_type']=='horizontal'){
442
+            $output .= '</div>';
443
+        }
444
+
445
+
446
+        // wrap
447
+        if(!$args['no_wrap']){
448
+            $form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
+            $wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
450
+            $output = self::wrap(array(
451
+                'content' => $output,
452
+                'class'   => $wrap_class,
453
+                'element_require'   => $args['element_require'],
454
+                'argument_id'  => $args['id']
455
+            ));
456
+        }
457
+
458
+
459
+        return $output;
460
+    }
461
+
462
+    public static function label($args = array(), $type = ''){
463
+        //<label for="exampleInputEmail1">Email address</label>
464
+        $defaults = array(
465
+            'title'       => 'div',
466
+            'for'      => '',
467
+            'class'      => '',
468
+            'label_type'    => '', // empty = hidden, top, horizontal
469
+        );
470
+
471
+        /**
472
+         * Parse incoming $args into an array and merge it with $defaults
473
+         */
474
+        $args   = wp_parse_args( $args, $defaults );
475
+        $output = '';
476
+
477
+        if($args['title']){
478
+
479
+            // maybe hide labels //@todo set a global option for visibility class
480
+            if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481
+                $class = $args['class'];
482
+            }else{
483
+                $class = 'sr-only '.$args['class'];
484
+            }
485
+
486
+            // maybe horizontal
487
+            if($args['label_type']=='horizontal' && $type != 'checkbox'){
488
+                $class .= ' col-sm-2 col-form-label';
489
+            }
490
+
491
+            // open
492
+            $output .= '<label ';
493
+
494
+            // for
495
+            if(!empty($args['for'])){
496
+                $output .= ' for="'.sanitize_text_field($args['for']).'" ';
497
+            }
498
+
499
+            // class
500
+            $output .= ' class="'.$class.'" ';
501
+
502
+            // close
503
+            $output .= '>';
504
+
505
+
506
+            // title, don't escape fully as can contain html
507
+            if(!empty($args['title'])){
508
+                $output .= wp_kses_post($args['title']);
509
+            }
510
+
511
+            // close wrap
512
+            $output .= '</label>';
513
+
514
+
515
+        }
516
+
517
+
518
+        return $output;
519
+    }
520
+
521
+    public static function wrap($args = array()){
522
+        $defaults = array(
523
+            'type'       => 'div',
524
+            'class'      => 'form-group',
525
+            'content'   => '',
526
+            'input_group_left' => '',
527
+            'input_group_right' => '',
528
+            'input_group_left_inside' => false,
529
+            'input_group_right_inside' => false,
530
+            'element_require'   => '',
531
+            'argument_id'   => '',
532
+        );
533
+
534
+        /**
535
+         * Parse incoming $args into an array and merge it with $defaults
536
+         */
537
+        $args   = wp_parse_args( $args, $defaults );
538
+        $output = '';
539
+        if($args['type']){
540
+
541
+            // open
542
+            $output .= '<'.sanitize_html_class($args['type']);
543
+
544
+            // element require
545
+            if(!empty($args['element_require'])){
546
+                $output .= AUI_Component_Helper::element_require($args['element_require']);
547
+                $args['class'] .= " aui-conditional-field";
548
+            }
549
+
550
+            // argument_id
551
+            if( !empty($args['argument_id']) ){
552
+                $output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
553
+            }
554
+
555
+            // class
556
+            $class = !empty($args['class']) ? $args['class'] : '';
557
+            $output .= ' class="'.$class.'" ';
558
+
559
+            // close wrap
560
+            $output .= ' >';
561
+
562
+
563
+            // Input group left
564
+            if(!empty($args['input_group_left'])){
565
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
+                $input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
+                $output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
568
+            }
569
+
570
+            // content
571
+            $output .= $args['content'];
572
+
573
+            // Input group right
574
+            if(!empty($args['input_group_right'])){
575
+                $position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
+                $input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
+                $output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
578
+            }
579
+
580
+
581
+            // close wrap
582
+            $output .= '</'.sanitize_html_class($args['type']).'>';
583
+
584
+
585
+        }else{
586
+            $output = $args['content'];
587
+        }
588
+
589
+        return $output;
590
+    }
591
+
592
+    /**
593
+     * Build the component.
594
+     *
595
+     * @param array $args
596
+     *
597
+     * @return string The rendered component.
598
+     */
599
+    public static function select($args = array()){
600
+        $defaults = array(
601
+            'class'      => '',
602
+            'id'         => '',
603
+            'title'      => '',
604
+            'value'      => '', // can be an array or a string
605
+            'required'   => false,
606
+            'label'      => '',
607
+            'label_after'=> false,
608
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
609
+            'label_class'      => '',
610
+            'help_text'  => '',
611
+            'placeholder'=> '',
612
+            'options'    => array(), // array or string
613
+            'icon'       => '',
614
+            'multiple'   => false,
615
+            'select2'    => false,
616
+            'no_wrap'    => false,
617
+            'element_require'   => '', // [%element_id%] == "1"
618
+            'extra_attributes'  => array(), // an array of extra attributes
619
+        );
620
+
621
+        /**
622
+         * Parse incoming $args into an array and merge it with $defaults
623
+         */
624
+        $args   = wp_parse_args( $args, $defaults );
625
+        $output = '';
626
+
627
+        // for now lets hide floating labels
628
+        if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
629
+
630
+        // hidden label option needs to be empty
631
+        $args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
632
+
633
+
634
+        $label_after = $args['label_after'];
635
+
636
+        // floating labels need label after
637
+        if( $args['label_type'] == 'floating' ){
638
+            $label_after = true;
639
+            $args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640
+        }
641
+
642
+        // Maybe setup select2
643
+        $is_select2 = false;
644
+        if(!empty($args['select2'])){
645
+            $args['class'] .= ' aui-select2';
646
+            $is_select2 = true;
647
+        }elseif( strpos($args['class'], 'aui-select2') !== false){
648
+            $is_select2 = true;
649
+        }
650
+
651
+        // select2 tags
652
+        if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
653
+            $args['data-tags'] = 'true';
654
+            $args['data-token-separators'] = "[',']";
655
+            $args['multiple'] = true;
656
+        }
657
+
658
+        // select2 placeholder
659
+        if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
660
+            $args['data-placeholder'] = esc_attr($args['placeholder']);
661
+            $args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662
+        }
663
+
664
+        // label
665
+        if(!empty($args['label']) && is_array($args['label'])){
666
+        }elseif(!empty($args['label']) && !$label_after){
667
+            $label_args = array(
668
+                'title'=> $args['label'],
669
+                'for'=> $args['id'],
670
+                'class' => $args['label_class']." ",
671
+                'label_type' => $args['label_type']
672
+            );
673
+            $output .= self::label($label_args);
674
+        }
675
+
676
+        // maybe horizontal label
677
+        if($args['label_type']=='horizontal'){
678
+            $output .= '<div class="col-sm-10">';
679
+        }
680
+
681
+        // open/type
682
+        $output .= '<select ';
683
+
684
+        // style
685
+        if($is_select2){
686
+            $output .= " style='width:100%;' ";
687
+        }
688
+
689
+        // element require
690
+        if(!empty($args['element_require'])){
691
+            $output .= AUI_Component_Helper::element_require($args['element_require']);
692
+            $args['class'] .= " aui-conditional-field";
693
+        }
694
+
695
+        // class
696
+        $class = !empty($args['class']) ? $args['class'] : '';
697
+        $output .= AUI_Component_Helper::class_attr('custom-select '.$class);
698
+
699
+        // name
700
+        if(!empty($args['name'])){
701
+            $output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
702
+        }
703
+
704
+        // id
705
+        if(!empty($args['id'])){
706
+            $output .= AUI_Component_Helper::id($args['id']);
707
+        }
708
+
709
+        // title
710
+        if(!empty($args['title'])){
711
+            $output .= AUI_Component_Helper::title($args['title']);
712
+        }
713
+
714
+        // data-attributes
715
+        $output .= AUI_Component_Helper::data_attributes($args);
716
+
717
+        // aria-attributes
718
+        $output .= AUI_Component_Helper::aria_attributes($args);
719
+
720
+        // extra attributes
721
+        if(!empty($args['extra_attributes'])){
722
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723
+        }
724
+
725
+        // required
726
+        if(!empty($args['required'])){
727
+            $output .= ' required ';
728
+        }
729
+
730
+        // multiple
731
+        if(!empty($args['multiple'])){
732
+            $output .= ' multiple ';
733
+        }
734
+
735
+        // close opening tag
736
+        $output .= ' >';
737
+
738
+        // placeholder
739
+        if(!empty($args['placeholder']) && !$is_select2){
740
+            $output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
+        }elseif($is_select2 && !empty($args['placeholder'])){
742
+            $output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743
+        }
744
+
745
+        // Options
746
+        if(!empty($args['options'])){
747
+
748
+            if(!is_array($args['options'])){
749
+                $output .= $args['options']; // not the preferred way but an option
750
+            }else{
751
+                foreach($args['options'] as $val => $name){
752
+                    $selected = '';
753
+                    if(is_array($name)){
754
+                        if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755
+                            $option_label = isset($name['label']) ? $name['label'] : '';
756
+
757
+                            $output .= $name['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>';
758
+                        } else {
759
+                            $option_label = isset($name['label']) ? $name['label'] : '';
760
+                            $option_value = isset($name['value']) ? $name['value'] : '';
761
+                            if(!empty($args['multiple']) && !empty($args['value'])){
762
+                                $selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
+                            } elseif(!empty($args['value'])) {
764
+                                $selected = selected($option_value,stripslashes_deep($args['value']), false);
765
+                            }
766
+
767
+                            $output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768
+                        }
769
+                    }else{
770
+                        if(!empty($args['value'])){
771
+                            if(is_array($args['value'])){
772
+                                $selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
+                            } elseif(!empty($args['value'])) {
774
+                                $selected = selected( $args['value'], $val, false);
775
+                            }
776
+                        }
777
+                        $output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
778
+                    }
779
+                }
780
+            }
781
+
782
+        }
783
+
784
+        // closing tag
785
+        $output .= '</select>';
786
+
787
+        if(!empty($args['label']) && $label_after){
788
+            $label_args = array(
789
+                'title'=> $args['label'],
790
+                'for'=> $args['id'],
791
+                'class' => $args['label_class']." ",
792
+                'label_type' => $args['label_type']
793
+            );
794
+            $output .= self::label($label_args);
795
+        }
796
+
797
+        // help text
798
+        if(!empty($args['help_text'])){
799
+            $output .= AUI_Component_Helper::help_text($args['help_text']);
800
+        }
801
+
802
+        // maybe horizontal label
803
+        if($args['label_type']=='horizontal'){
804
+            $output .= '</div>';
805
+        }
806
+
807
+
808
+        // wrap
809
+        if(!$args['no_wrap']){
810
+            $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
811
+            $output = self::wrap(array(
812
+                'content' => $output,
813
+                'class'   => $wrap_class,
814
+                'element_require'   => $args['element_require'],
815
+                'argument_id'  => $args['id']
816
+            ));
817
+        }
818
+
819
+
820
+        return $output;
821
+    }
822
+
823
+    /**
824
+     * Build the component.
825
+     *
826
+     * @param array $args
827
+     *
828
+     * @return string The rendered component.
829
+     */
830
+    public static function radio($args = array()){
831
+        $defaults = array(
832
+            'class'      => '',
833
+            'id'         => '',
834
+            'title'      => '',
835
+            'horizontal' => false, // sets the lable horizontal
836
+            'value'      => '',
837
+            'label'      => '',
838
+            'label_class'=> '',
839
+            'label_type' => '', // sets the label type, default: hidden. Options: hidden, top, horizontal, floating
840
+            'inline'     => true,
841
+            'required'   => false,
842
+            'options'    => array(),
843
+            'icon'       => '',
844
+            'no_wrap'    => false,
845
+            'element_require'   => '', // [%element_id%] == "1"
846
+            'extra_attributes'  => array() // an array of extra attributes
847
+        );
848
+
849
+        /**
850
+         * Parse incoming $args into an array and merge it with $defaults
851
+         */
852
+        $args   = wp_parse_args( $args, $defaults );
853
+
854
+        // for now lets use horizontal for floating
855
+        if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
856
+
857
+        $label_args = array(
858
+            'title'=> $args['label'],
859
+            'class' => $args['label_class']." pt-0 ",
860
+            'label_type' => $args['label_type']
861
+        );
862
+
863
+        $output = '';
864
+
865
+
866
+
867
+        // label before
868
+        if(!empty($args['label'])){
869
+            $output .= self::label( $label_args, 'radio' );
870
+        }
871
+
872
+        // maybe horizontal label
873
+        if($args['label_type']=='horizontal'){
874
+            $output .= '<div class="col-sm-10">';
875
+        }
876
+
877
+        if(!empty($args['options'])){
878
+            $count = 0;
879
+            foreach($args['options'] as $value => $label){
880
+                $option_args = $args;
881
+                $option_args['value'] = $value;
882
+                $option_args['label'] = $label;
883
+                $option_args['checked'] = $value == $args['value'] ? true : false;
884
+                $output .= self::radio_option($option_args,$count);
885
+                $count++;
886
+            }
887
+        }
888
+
889
+        // maybe horizontal label
890
+        if($args['label_type']=='horizontal'){
891
+            $output .= '</div>';
892
+        }
893
+
894
+
895
+        // wrap
896
+        $wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
897
+        $output = self::wrap(array(
898
+            'content' => $output,
899
+            'class'   => $wrap_class,
900
+            'element_require'   => $args['element_require'],
901
+            'argument_id'  => $args['id']
902
+        ));
903
+
904
+
905
+        return $output;
906
+    }
907
+
908
+    /**
909
+     * Build the component.
910
+     *
911
+     * @param array $args
912
+     *
913
+     * @return string The rendered component.
914
+     */
915
+    public static function radio_option($args = array(),$count = ''){
916
+        $defaults = array(
917
+            'class'      => '',
918
+            'id'         => '',
919
+            'title'      => '',
920
+            'value'      => '',
921
+            'required'   => false,
922
+            'inline'     => true,
923
+            'label'      => '',
924
+            'options'    => array(),
925
+            'icon'       => '',
926
+            'no_wrap'    => false,
927
+            'extra_attributes'  => array() // an array of extra attributes
928
+        );
929
+
930
+        /**
931
+         * Parse incoming $args into an array and merge it with $defaults
932
+         */
933
+        $args   = wp_parse_args( $args, $defaults );
934
+
935
+        $output = '';
936
+
937
+        // open/type
938
+        $output .= '<input type="radio"';
939
+
940
+        // class
941
+        $output .= ' class="form-check-input" ';
942
+
943
+        // name
944
+        if(!empty($args['name'])){
945
+            $output .= AUI_Component_Helper::name($args['name']);
946
+        }
947
+
948
+        // id
949
+        if(!empty($args['id'])){
950
+            $output .= AUI_Component_Helper::id($args['id'].$count);
951
+        }
952
+
953
+        // title
954
+        if(!empty($args['title'])){
955
+            $output .= AUI_Component_Helper::title($args['title']);
956
+        }
957
+
958
+        // value
959
+        if(isset($args['value'])){
960
+            $output .= ' value="'.sanitize_text_field($args['value']).'" ';
961
+        }
962
+
963
+        // checked, for radio and checkboxes
964
+        if( $args['checked'] ){
965
+            $output .= ' checked ';
966
+        }
967
+
968
+        // data-attributes
969
+        $output .= AUI_Component_Helper::data_attributes($args);
970
+
971
+        // aria-attributes
972
+        $output .= AUI_Component_Helper::aria_attributes($args);
973
+
974
+        // extra attributes
975
+        if(!empty($args['extra_attributes'])){
976
+            $output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977
+        }
978
+
979
+        // required
980
+        if(!empty($args['required'])){
981
+            $output .= ' required ';
982
+        }
983
+
984
+        // close opening tag
985
+        $output .= ' >';
986
+
987
+        // label
988
+        if(!empty($args['label']) && is_array($args['label'])){
989
+        }elseif(!empty($args['label'])){
990
+            $output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991
+        }
992
+
993
+        // wrap
994
+        if(!$args['no_wrap']){
995
+            $wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996
+            $output = self::wrap(array(
997
+                'content' => $output,
998
+                'class' => $wrap_class
999
+            ));
1000
+        }
1001
+
1002
+
1003
+        return $output;
1004
+    }
1005 1005
 
1006 1006
 }
1007 1007
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +201 added lines, -201 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input($args = array()){
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'text',
24 24
 			'name'       => '',
@@ -51,13 +51,13 @@  discard block
 block discarded – undo
51 51
 		/**
52 52
 		 * Parse incoming $args into an array and merge it with $defaults
53 53
 		 */
54
-		$args   = wp_parse_args( $args, $defaults );
54
+		$args   = wp_parse_args($args, $defaults);
55 55
 		$output = '';
56
-		if ( ! empty( $args['type'] ) ) {
56
+		if (!empty($args['type'])) {
57 57
 			// hidden label option needs to be empty
58 58
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
59 59
 
60
-			$type = sanitize_html_class( $args['type'] );
60
+			$type = sanitize_html_class($args['type']);
61 61
 
62 62
 			$help_text = '';
63 63
 			$label = '';
@@ -65,24 +65,24 @@  discard block
 block discarded – undo
65 65
 			$label_args = array(
66 66
 				'title'=> $args['label'],
67 67
 				'for'=> $args['id'],
68
-				'class' => $args['label_class']." ",
68
+				'class' => $args['label_class'] . " ",
69 69
 				'label_type' => $args['label_type']
70 70
 			);
71 71
 
72 72
 			// floating labels need label after
73
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
73
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
74 74
 				$label_after = true;
75 75
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
76 76
 			}
77 77
 
78 78
 			// Some special sauce for files
79
-			if($type=='file' ){
79
+			if ($type == 'file') {
80 80
 				$label_after = true; // if type file we need the label after
81 81
 				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
82
+			}elseif ($type == 'checkbox') {
83 83
 				$label_after = true; // if type file we need the label after
84 84
 				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
85
+			}elseif ($type == 'datepicker' || $type == 'timepicker') {
86 86
 				$type = 'text';
87 87
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
88 88
 				$args['class'] .= ' bg-initial ';
@@ -98,65 +98,65 @@  discard block
 block discarded – undo
98 98
 			$output .= '<input type="' . $type . '" ';
99 99
 
100 100
 			// name
101
-			if(!empty($args['name'])){
102
-				$output .= ' name="'.esc_attr($args['name']).'" ';
101
+			if (!empty($args['name'])) {
102
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
103 103
 			}
104 104
 
105 105
 			// id
106
-			if(!empty($args['id'])){
107
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
106
+			if (!empty($args['id'])) {
107
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
108 108
 			}
109 109
 
110 110
 			// placeholder
111
-			if(!empty($args['placeholder'])){
112
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
111
+			if (!empty($args['placeholder'])) {
112
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
113 113
 			}
114 114
 
115 115
 			// title
116
-			if(!empty($args['title'])){
117
-				$output .= ' title="'.esc_attr($args['title']).'" ';
116
+			if (!empty($args['title'])) {
117
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
118 118
 			}
119 119
 
120 120
 			// value
121
-			if(!empty($args['value'])){
122
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
121
+			if (!empty($args['value'])) {
122
+				$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
123 123
 			}
124 124
 
125 125
 			// checked, for radio and checkboxes
126
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
126
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
127 127
 				$output .= ' checked ';
128 128
 			}
129 129
 
130 130
 			// validation text
131
-			if(!empty($args['validation_text'])){
132
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
131
+			if (!empty($args['validation_text'])) {
132
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
133 133
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
134 134
 			}
135 135
 
136 136
 			// validation_pattern
137
-			if(!empty($args['validation_pattern'])){
138
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
137
+			if (!empty($args['validation_pattern'])) {
138
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
139 139
 			}
140 140
 
141 141
 			// step (for numbers)
142
-			if(!empty($args['step'])){
143
-				$output .= ' step="'.$args['step'].'" ';
142
+			if (!empty($args['step'])) {
143
+				$output .= ' step="' . $args['step'] . '" ';
144 144
 			}
145 145
 
146 146
 			// required
147
-			if(!empty($args['required'])){
147
+			if (!empty($args['required'])) {
148 148
 				$output .= ' required ';
149 149
 			}
150 150
 
151 151
 			// class
152 152
 			$class = !empty($args['class']) ? $args['class'] : '';
153
-			$output .= ' class="form-control '.$class.'" ';
153
+			$output .= ' class="form-control ' . $class . '" ';
154 154
 
155 155
 			// data-attributes
156 156
 			$output .= AUI_Component_Helper::data_attributes($args);
157 157
 
158 158
 			// extra attributes
159
-			if(!empty($args['extra_attributes'])){
159
+			if (!empty($args['extra_attributes'])) {
160 160
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
161 161
 			}
162 162
 
@@ -165,40 +165,40 @@  discard block
 block discarded – undo
165 165
 
166 166
 
167 167
 			// label
168
-			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171
-				$label = self::label( $label_args, $type );
168
+			if (!empty($args['label'])) {
169
+				if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; }
170
+				elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; }
171
+				$label = self::label($label_args, $type);
172 172
 			}
173 173
 
174 174
 			// help text
175
-			if(!empty($args['help_text'])){
175
+			if (!empty($args['help_text'])) {
176 176
 				$help_text = AUI_Component_Helper::help_text($args['help_text']);
177 177
 			}
178 178
 
179 179
 
180 180
 			// set help text in the correct possition
181
-			if($label_after){
181
+			if ($label_after) {
182 182
 				$output .= $label . $help_text;
183 183
 			}
184 184
 
185 185
 			// some input types need a separate wrap
186
-			if($type == 'file') {
187
-				$output = self::wrap( array(
186
+			if ($type == 'file') {
187
+				$output = self::wrap(array(
188 188
 					'content' => $output,
189 189
 					'class'   => 'form-group custom-file'
190
-				) );
191
-			}elseif($type == 'checkbox'){
190
+				));
191
+			}elseif ($type == 'checkbox') {
192 192
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193
-				$output = self::wrap( array(
193
+				$output = self::wrap(array(
194 194
 					'content' => $output,
195
-					'class'   => 'custom-control '.$wrap_class
196
-				) );
195
+					'class'   => 'custom-control ' . $wrap_class
196
+				));
197 197
 
198
-				if($args['label_type']=='horizontal'){
198
+				if ($args['label_type'] == 'horizontal') {
199 199
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200 200
 				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
201
+			}elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
202 202
 
203 203
 
204 204
 				// allow password field to toggle view
@@ -212,48 +212,48 @@  discard block
 block discarded – undo
212 212
 			}
213 213
 
214 214
 			// input group wraps
215
-			if($args['input_group_left'] || $args['input_group_right']){
215
+			if ($args['input_group_left'] || $args['input_group_right']) {
216 216
 				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
217
-				if($args['input_group_left']){
218
-					$output = self::wrap( array(
217
+				if ($args['input_group_left']) {
218
+					$output = self::wrap(array(
219 219
 						'content' => $output,
220
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
220
+						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
221 221
 						'input_group_left' => $args['input_group_left'],
222 222
 						'input_group_left_inside'    => $args['input_group_left_inside']
223
-					) );
223
+					));
224 224
 				}
225
-				if($args['input_group_right']){
226
-					$output = self::wrap( array(
225
+				if ($args['input_group_right']) {
226
+					$output = self::wrap(array(
227 227
 						'content' => $output,
228
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
228
+						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
229 229
 						'input_group_right' => $args['input_group_right'],
230 230
 						'input_group_right_inside'    => $args['input_group_right_inside']
231
-					) );
231
+					));
232 232
 				}
233 233
 
234 234
 			}
235 235
 
236
-			if(!$label_after){
236
+			if (!$label_after) {
237 237
 				$output .= $help_text;
238 238
 			}
239 239
 
240 240
 
241
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
242
-				$output = self::wrap( array(
241
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
242
+				$output = self::wrap(array(
243 243
 					'content' => $output,
244 244
 					'class'   => 'col-sm-10',
245
-				) );
245
+				));
246 246
 			}
247 247
 
248
-			if(!$label_after){
248
+			if (!$label_after) {
249 249
 				$output = $label . $output;
250 250
 			}
251 251
 
252 252
 			// wrap
253
-			if(!$args['no_wrap']){
253
+			if (!$args['no_wrap']) {
254 254
 
255
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
255
+				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
256
+				$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
257 257
 				$output = self::wrap(array(
258 258
 					'content' => $output,
259 259
 					'class'   => $wrap_class,
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 *
277 277
 	 * @return string The rendered component.
278 278
 	 */
279
-	public static function textarea($args = array()){
279
+	public static function textarea($args = array()) {
280 280
 		$defaults = array(
281 281
 			'name'       => '',
282 282
 			'class'      => '',
@@ -301,43 +301,43 @@  discard block
 block discarded – undo
301 301
 		/**
302 302
 		 * Parse incoming $args into an array and merge it with $defaults
303 303
 		 */
304
-		$args   = wp_parse_args( $args, $defaults );
304
+		$args   = wp_parse_args($args, $defaults);
305 305
 		$output = '';
306 306
 
307 307
 		// hidden label option needs to be empty
308 308
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
309 309
 
310 310
 		// floating labels don't work with wysiwyg so set it as top
311
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
311
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
312 312
 			$args['label_type'] = 'top';
313 313
 		}
314 314
 
315 315
 		$label_after = $args['label_after'];
316 316
 
317 317
 		// floating labels need label after
318
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
318
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
319 319
 			$label_after = true;
320 320
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
321 321
 		}
322 322
 
323 323
 		// label
324
-		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
324
+		if (!empty($args['label']) && is_array($args['label'])) {
325
+		}elseif (!empty($args['label']) && !$label_after) {
326 326
 			$label_args = array(
327 327
 				'title'=> $args['label'],
328 328
 				'for'=> $args['id'],
329
-				'class' => $args['label_class']." ",
329
+				'class' => $args['label_class'] . " ",
330 330
 				'label_type' => $args['label_type']
331 331
 			);
332
-			$output .= self::label( $label_args );
332
+			$output .= self::label($label_args);
333 333
 		}
334 334
 
335 335
 		// maybe horizontal label
336
-		if($args['label_type']=='horizontal'){
336
+		if ($args['label_type'] == 'horizontal') {
337 337
 			$output .= '<div class="col-sm-10">';
338 338
 		}
339 339
 
340
-		if(!empty($args['wysiwyg'])){
340
+		if (!empty($args['wysiwyg'])) {
341 341
 			ob_start();
342 342
 			$content = $args['value'];
343 343
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -351,69 +351,69 @@  discard block
 block discarded – undo
351 351
 			);
352 352
 
353 353
 			// maybe set settings if array
354
-			if(is_array($args['wysiwyg'])){
355
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
354
+			if (is_array($args['wysiwyg'])) {
355
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
356 356
 			}
357 357
 
358
-			wp_editor( $content, $editor_id, $settings );
358
+			wp_editor($content, $editor_id, $settings);
359 359
 			$output .= ob_get_clean();
360
-		}else{
360
+		} else {
361 361
 
362 362
 			// open
363 363
 			$output .= '<textarea ';
364 364
 
365 365
 			// name
366
-			if(!empty($args['name'])){
367
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
366
+			if (!empty($args['name'])) {
367
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
368 368
 			}
369 369
 
370 370
 			// id
371
-			if(!empty($args['id'])){
372
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
371
+			if (!empty($args['id'])) {
372
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
373 373
 			}
374 374
 
375 375
 			// placeholder
376
-			if(!empty($args['placeholder'])){
377
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
376
+			if (!empty($args['placeholder'])) {
377
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
378 378
 			}
379 379
 
380 380
 			// title
381
-			if(!empty($args['title'])){
382
-				$output .= ' title="'.esc_attr($args['title']).'" ';
381
+			if (!empty($args['title'])) {
382
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
383 383
 			}
384 384
 
385 385
 			// validation text
386
-			if(!empty($args['validation_text'])){
387
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
386
+			if (!empty($args['validation_text'])) {
387
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
388 388
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
389 389
 			}
390 390
 
391 391
 			// validation_pattern
392
-			if(!empty($args['validation_pattern'])){
393
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
392
+			if (!empty($args['validation_pattern'])) {
393
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
394 394
 			}
395 395
 
396 396
 			// required
397
-			if(!empty($args['required'])){
397
+			if (!empty($args['required'])) {
398 398
 				$output .= ' required ';
399 399
 			}
400 400
 
401 401
 			// rows
402
-			if(!empty($args['rows'])){
403
-				$output .= ' rows="'.absint($args['rows']).'" ';
402
+			if (!empty($args['rows'])) {
403
+				$output .= ' rows="' . absint($args['rows']) . '" ';
404 404
 			}
405 405
 
406 406
 
407 407
 			// class
408 408
 			$class = !empty($args['class']) ? $args['class'] : '';
409
-			$output .= ' class="form-control '.$class.'" ';
409
+			$output .= ' class="form-control ' . $class . '" ';
410 410
 
411 411
 
412 412
 			// close tag
413 413
 			$output .= ' >';
414 414
 
415 415
 			// value
416
-			if(!empty($args['value'])){
416
+			if (!empty($args['value'])) {
417 417
 				$output .= sanitize_textarea_field($args['value']);
418 418
 			}
419 419
 
@@ -422,31 +422,31 @@  discard block
 block discarded – undo
422 422
 
423 423
 		}
424 424
 
425
-		if(!empty($args['label']) && $label_after){
425
+		if (!empty($args['label']) && $label_after) {
426 426
 			$label_args = array(
427 427
 				'title'=> $args['label'],
428 428
 				'for'=> $args['id'],
429
-				'class' => $args['label_class']." ",
429
+				'class' => $args['label_class'] . " ",
430 430
 				'label_type' => $args['label_type']
431 431
 			);
432
-			$output .= self::label( $label_args );
432
+			$output .= self::label($label_args);
433 433
 		}
434 434
 
435 435
 		// help text
436
-		if(!empty($args['help_text'])){
436
+		if (!empty($args['help_text'])) {
437 437
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
438 438
 		}
439 439
 
440 440
 		// maybe horizontal label
441
-		if($args['label_type']=='horizontal'){
441
+		if ($args['label_type'] == 'horizontal') {
442 442
 			$output .= '</div>';
443 443
 		}
444 444
 
445 445
 
446 446
 		// wrap
447
-		if(!$args['no_wrap']){
448
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
449
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
447
+		if (!$args['no_wrap']) {
448
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
449
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
450 450
 			$output = self::wrap(array(
451 451
 				'content' => $output,
452 452
 				'class'   => $wrap_class,
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 		return $output;
460 460
 	}
461 461
 
462
-	public static function label($args = array(), $type = ''){
462
+	public static function label($args = array(), $type = '') {
463 463
 		//<label for="exampleInputEmail1">Email address</label>
464 464
 		$defaults = array(
465 465
 			'title'       => 'div',
@@ -471,20 +471,20 @@  discard block
 block discarded – undo
471 471
 		/**
472 472
 		 * Parse incoming $args into an array and merge it with $defaults
473 473
 		 */
474
-		$args   = wp_parse_args( $args, $defaults );
474
+		$args   = wp_parse_args($args, $defaults);
475 475
 		$output = '';
476 476
 
477
-		if($args['title']){
477
+		if ($args['title']) {
478 478
 
479 479
 			// maybe hide labels //@todo set a global option for visibility class
480
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
480
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
481 481
 				$class = $args['class'];
482
-			}else{
483
-				$class = 'sr-only '.$args['class'];
482
+			} else {
483
+				$class = 'sr-only ' . $args['class'];
484 484
 			}
485 485
 
486 486
 			// maybe horizontal
487
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
487
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
488 488
 				$class .= ' col-sm-2 col-form-label';
489 489
 			}
490 490
 
@@ -492,19 +492,19 @@  discard block
 block discarded – undo
492 492
 			$output .= '<label ';
493 493
 
494 494
 			// for
495
-			if(!empty($args['for'])){
496
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
495
+			if (!empty($args['for'])) {
496
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
497 497
 			}
498 498
 
499 499
 			// class
500
-			$output .= ' class="'.$class.'" ';
500
+			$output .= ' class="' . $class . '" ';
501 501
 
502 502
 			// close
503 503
 			$output .= '>';
504 504
 
505 505
 
506 506
 			// title, don't escape fully as can contain html
507
-			if(!empty($args['title'])){
507
+			if (!empty($args['title'])) {
508 508
 				$output .= wp_kses_post($args['title']);
509 509
 			}
510 510
 
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 		return $output;
519 519
 	}
520 520
 
521
-	public static function wrap($args = array()){
521
+	public static function wrap($args = array()) {
522 522
 		$defaults = array(
523 523
 			'type'       => 'div',
524 524
 			'class'      => 'form-group',
@@ -534,55 +534,55 @@  discard block
 block discarded – undo
534 534
 		/**
535 535
 		 * Parse incoming $args into an array and merge it with $defaults
536 536
 		 */
537
-		$args   = wp_parse_args( $args, $defaults );
537
+		$args   = wp_parse_args($args, $defaults);
538 538
 		$output = '';
539
-		if($args['type']){
539
+		if ($args['type']) {
540 540
 
541 541
 			// open
542
-			$output .= '<'.sanitize_html_class($args['type']);
542
+			$output .= '<' . sanitize_html_class($args['type']);
543 543
 
544 544
 			// element require
545
-			if(!empty($args['element_require'])){
545
+			if (!empty($args['element_require'])) {
546 546
 				$output .= AUI_Component_Helper::element_require($args['element_require']);
547 547
 				$args['class'] .= " aui-conditional-field";
548 548
 			}
549 549
 
550 550
 			// argument_id
551
-			if( !empty($args['argument_id']) ){
552
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
551
+			if (!empty($args['argument_id'])) {
552
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
553 553
 			}
554 554
 
555 555
 			// class
556 556
 			$class = !empty($args['class']) ? $args['class'] : '';
557
-			$output .= ' class="'.$class.'" ';
557
+			$output .= ' class="' . $class . '" ';
558 558
 
559 559
 			// close wrap
560 560
 			$output .= ' >';
561 561
 
562 562
 
563 563
 			// Input group left
564
-			if(!empty($args['input_group_left'])){
564
+			if (!empty($args['input_group_left'])) {
565 565
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
566
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
567
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
566
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
567
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
568 568
 			}
569 569
 
570 570
 			// content
571 571
 			$output .= $args['content'];
572 572
 
573 573
 			// Input group right
574
-			if(!empty($args['input_group_right'])){
574
+			if (!empty($args['input_group_right'])) {
575 575
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
576
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
577
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
576
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
577
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
578 578
 			}
579 579
 
580 580
 
581 581
 			// close wrap
582
-			$output .= '</'.sanitize_html_class($args['type']).'>';
582
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
583 583
 
584 584
 
585
-		}else{
585
+		} else {
586 586
 			$output = $args['content'];
587 587
 		}
588 588
 
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 	 *
597 597
 	 * @return string The rendered component.
598 598
 	 */
599
-	public static function select($args = array()){
599
+	public static function select($args = array()) {
600 600
 		$defaults = array(
601 601
 			'class'      => '',
602 602
 			'id'         => '',
@@ -621,11 +621,11 @@  discard block
 block discarded – undo
621 621
 		/**
622 622
 		 * Parse incoming $args into an array and merge it with $defaults
623 623
 		 */
624
-		$args   = wp_parse_args( $args, $defaults );
624
+		$args   = wp_parse_args($args, $defaults);
625 625
 		$output = '';
626 626
 
627 627
 		// for now lets hide floating labels
628
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
628
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
629 629
 
630 630
 		// hidden label option needs to be empty
631 631
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -634,47 +634,47 @@  discard block
 block discarded – undo
634 634
 		$label_after = $args['label_after'];
635 635
 
636 636
 		// floating labels need label after
637
-		if( $args['label_type'] == 'floating' ){
637
+		if ($args['label_type'] == 'floating') {
638 638
 			$label_after = true;
639 639
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
640 640
 		}
641 641
 
642 642
 		// Maybe setup select2
643 643
 		$is_select2 = false;
644
-		if(!empty($args['select2'])){
644
+		if (!empty($args['select2'])) {
645 645
 			$args['class'] .= ' aui-select2';
646 646
 			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
647
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
648 648
 			$is_select2 = true;
649 649
 		}
650 650
 
651 651
 		// select2 tags
652
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
652
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
653 653
 			$args['data-tags'] = 'true';
654 654
 			$args['data-token-separators'] = "[',']";
655 655
 			$args['multiple'] = true;
656 656
 		}
657 657
 
658 658
 		// select2 placeholder
659
-		if($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])){
659
+		if ($is_select2 && !empty($args['placeholder']) && empty($args['data-placeholder'])) {
660 660
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
661 661
 			$args['data-allow-clear'] = empty($args['data-allow-clear']) ? true : esc_attr($args['data-allow-clear']);
662 662
 		}
663 663
 
664 664
 		// label
665
-		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
665
+		if (!empty($args['label']) && is_array($args['label'])) {
666
+		}elseif (!empty($args['label']) && !$label_after) {
667 667
 			$label_args = array(
668 668
 				'title'=> $args['label'],
669 669
 				'for'=> $args['id'],
670
-				'class' => $args['label_class']." ",
670
+				'class' => $args['label_class'] . " ",
671 671
 				'label_type' => $args['label_type']
672 672
 			);
673 673
 			$output .= self::label($label_args);
674 674
 		}
675 675
 
676 676
 		// maybe horizontal label
677
-		if($args['label_type']=='horizontal'){
677
+		if ($args['label_type'] == 'horizontal') {
678 678
 			$output .= '<div class="col-sm-10">';
679 679
 		}
680 680
 
@@ -682,32 +682,32 @@  discard block
 block discarded – undo
682 682
 		$output .= '<select ';
683 683
 
684 684
 		// style
685
-		if($is_select2){
685
+		if ($is_select2) {
686 686
 			$output .= " style='width:100%;' ";
687 687
 		}
688 688
 
689 689
 		// element require
690
-		if(!empty($args['element_require'])){
690
+		if (!empty($args['element_require'])) {
691 691
 			$output .= AUI_Component_Helper::element_require($args['element_require']);
692 692
 			$args['class'] .= " aui-conditional-field";
693 693
 		}
694 694
 
695 695
 		// class
696 696
 		$class = !empty($args['class']) ? $args['class'] : '';
697
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
697
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
698 698
 
699 699
 		// name
700
-		if(!empty($args['name'])){
701
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
700
+		if (!empty($args['name'])) {
701
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
702 702
 		}
703 703
 
704 704
 		// id
705
-		if(!empty($args['id'])){
705
+		if (!empty($args['id'])) {
706 706
 			$output .= AUI_Component_Helper::id($args['id']);
707 707
 		}
708 708
 
709 709
 		// title
710
-		if(!empty($args['title'])){
710
+		if (!empty($args['title'])) {
711 711
 			$output .= AUI_Component_Helper::title($args['title']);
712 712
 		}
713 713
 
@@ -718,17 +718,17 @@  discard block
 block discarded – undo
718 718
 		$output .= AUI_Component_Helper::aria_attributes($args);
719 719
 
720 720
 		// extra attributes
721
-		if(!empty($args['extra_attributes'])){
721
+		if (!empty($args['extra_attributes'])) {
722 722
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
723 723
 		}
724 724
 
725 725
 		// required
726
-		if(!empty($args['required'])){
726
+		if (!empty($args['required'])) {
727 727
 			$output .= ' required ';
728 728
 		}
729 729
 
730 730
 		// multiple
731
-		if(!empty($args['multiple'])){
731
+		if (!empty($args['multiple'])) {
732 732
 			$output .= ' multiple ';
733 733
 		}
734 734
 
@@ -736,21 +736,21 @@  discard block
 block discarded – undo
736 736
 		$output .= ' >';
737 737
 
738 738
 		// placeholder
739
-		if(!empty($args['placeholder']) && !$is_select2){
740
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
739
+		if (!empty($args['placeholder']) && !$is_select2) {
740
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
741
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
742 742
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743 743
 		}
744 744
 
745 745
 		// Options
746
-		if(!empty($args['options'])){
746
+		if (!empty($args['options'])) {
747 747
 
748
-			if(!is_array($args['options'])){
748
+			if (!is_array($args['options'])) {
749 749
 				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
751
-				foreach($args['options'] as $val => $name){
750
+			} else {
751
+				foreach ($args['options'] as $val => $name) {
752 752
 					$selected = '';
753
-					if(is_array($name)){
753
+					if (is_array($name)) {
754 754
 						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
755 755
 							$option_label = isset($name['label']) ? $name['label'] : '';
756 756
 
@@ -758,23 +758,23 @@  discard block
 block discarded – undo
758 758
 						} else {
759 759
 							$option_label = isset($name['label']) ? $name['label'] : '';
760 760
 							$option_value = isset($name['value']) ? $name['value'] : '';
761
-							if(!empty($args['multiple']) && !empty($args['value'])){
761
+							if (!empty($args['multiple']) && !empty($args['value'])) {
762 762
 								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
763
-							} elseif(!empty($args['value'])) {
764
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
763
+							} elseif (!empty($args['value'])) {
764
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
765 765
 							}
766 766
 
767 767
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768 768
 						}
769
-					}else{
770
-						if(!empty($args['value'])){
771
-							if(is_array($args['value'])){
772
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
773
-							} elseif(!empty($args['value'])) {
774
-								$selected = selected( $args['value'], $val, false);
769
+					} else {
770
+						if (!empty($args['value'])) {
771
+							if (is_array($args['value'])) {
772
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
773
+							} elseif (!empty($args['value'])) {
774
+								$selected = selected($args['value'], $val, false);
775 775
 							}
776 776
 						}
777
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
777
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
778 778
 					}
779 779
 				}
780 780
 			}
@@ -784,30 +784,30 @@  discard block
 block discarded – undo
784 784
 		// closing tag
785 785
 		$output .= '</select>';
786 786
 
787
-		if(!empty($args['label']) && $label_after){
787
+		if (!empty($args['label']) && $label_after) {
788 788
 			$label_args = array(
789 789
 				'title'=> $args['label'],
790 790
 				'for'=> $args['id'],
791
-				'class' => $args['label_class']." ",
791
+				'class' => $args['label_class'] . " ",
792 792
 				'label_type' => $args['label_type']
793 793
 			);
794 794
 			$output .= self::label($label_args);
795 795
 		}
796 796
 
797 797
 		// help text
798
-		if(!empty($args['help_text'])){
798
+		if (!empty($args['help_text'])) {
799 799
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
800 800
 		}
801 801
 
802 802
 		// maybe horizontal label
803
-		if($args['label_type']=='horizontal'){
803
+		if ($args['label_type'] == 'horizontal') {
804 804
 			$output .= '</div>';
805 805
 		}
806 806
 
807 807
 
808 808
 		// wrap
809
-		if(!$args['no_wrap']){
810
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
809
+		if (!$args['no_wrap']) {
810
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
811 811
 			$output = self::wrap(array(
812 812
 				'content' => $output,
813 813
 				'class'   => $wrap_class,
@@ -827,7 +827,7 @@  discard block
 block discarded – undo
827 827
 	 *
828 828
 	 * @return string The rendered component.
829 829
 	 */
830
-	public static function radio($args = array()){
830
+	public static function radio($args = array()) {
831 831
 		$defaults = array(
832 832
 			'class'      => '',
833 833
 			'id'         => '',
@@ -849,14 +849,14 @@  discard block
 block discarded – undo
849 849
 		/**
850 850
 		 * Parse incoming $args into an array and merge it with $defaults
851 851
 		 */
852
-		$args   = wp_parse_args( $args, $defaults );
852
+		$args = wp_parse_args($args, $defaults);
853 853
 
854 854
 		// for now lets use horizontal for floating
855
-		if( $args['label_type'] != 'hidden' ){$args['label_type'] = 'horizontal';}
855
+		if ($args['label_type'] != 'hidden') {$args['label_type'] = 'horizontal'; }
856 856
 
857 857
 		$label_args = array(
858 858
 			'title'=> $args['label'],
859
-			'class' => $args['label_class']." pt-0 ",
859
+			'class' => $args['label_class'] . " pt-0 ",
860 860
 			'label_type' => $args['label_type']
861 861
 		);
862 862
 
@@ -865,35 +865,35 @@  discard block
 block discarded – undo
865 865
 
866 866
 
867 867
 		// label before
868
-		if(!empty($args['label'])){
869
-			$output .= self::label( $label_args, 'radio' );
868
+		if (!empty($args['label'])) {
869
+			$output .= self::label($label_args, 'radio');
870 870
 		}
871 871
 
872 872
 		// maybe horizontal label
873
-		if($args['label_type']=='horizontal'){
873
+		if ($args['label_type'] == 'horizontal') {
874 874
 			$output .= '<div class="col-sm-10">';
875 875
 		}
876 876
 
877
-		if(!empty($args['options'])){
877
+		if (!empty($args['options'])) {
878 878
 			$count = 0;
879
-			foreach($args['options'] as $value => $label){
879
+			foreach ($args['options'] as $value => $label) {
880 880
 				$option_args = $args;
881 881
 				$option_args['value'] = $value;
882 882
 				$option_args['label'] = $label;
883 883
 				$option_args['checked'] = $value == $args['value'] ? true : false;
884
-				$output .= self::radio_option($option_args,$count);
884
+				$output .= self::radio_option($option_args, $count);
885 885
 				$count++;
886 886
 			}
887 887
 		}
888 888
 
889 889
 		// maybe horizontal label
890
-		if($args['label_type']=='horizontal'){
890
+		if ($args['label_type'] == 'horizontal') {
891 891
 			$output .= '</div>';
892 892
 		}
893 893
 
894 894
 
895 895
 		// wrap
896
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
896
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
897 897
 		$output = self::wrap(array(
898 898
 			'content' => $output,
899 899
 			'class'   => $wrap_class,
@@ -912,7 +912,7 @@  discard block
 block discarded – undo
912 912
 	 *
913 913
 	 * @return string The rendered component.
914 914
 	 */
915
-	public static function radio_option($args = array(),$count = ''){
915
+	public static function radio_option($args = array(), $count = '') {
916 916
 		$defaults = array(
917 917
 			'class'      => '',
918 918
 			'id'         => '',
@@ -930,7 +930,7 @@  discard block
 block discarded – undo
930 930
 		/**
931 931
 		 * Parse incoming $args into an array and merge it with $defaults
932 932
 		 */
933
-		$args   = wp_parse_args( $args, $defaults );
933
+		$args   = wp_parse_args($args, $defaults);
934 934
 
935 935
 		$output = '';
936 936
 
@@ -941,27 +941,27 @@  discard block
 block discarded – undo
941 941
 		$output .= ' class="form-check-input" ';
942 942
 
943 943
 		// name
944
-		if(!empty($args['name'])){
944
+		if (!empty($args['name'])) {
945 945
 			$output .= AUI_Component_Helper::name($args['name']);
946 946
 		}
947 947
 
948 948
 		// id
949
-		if(!empty($args['id'])){
950
-			$output .= AUI_Component_Helper::id($args['id'].$count);
949
+		if (!empty($args['id'])) {
950
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
951 951
 		}
952 952
 
953 953
 		// title
954
-		if(!empty($args['title'])){
954
+		if (!empty($args['title'])) {
955 955
 			$output .= AUI_Component_Helper::title($args['title']);
956 956
 		}
957 957
 
958 958
 		// value
959
-		if(isset($args['value'])){
960
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
959
+		if (isset($args['value'])) {
960
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
961 961
 		}
962 962
 
963 963
 		// checked, for radio and checkboxes
964
-		if( $args['checked'] ){
964
+		if ($args['checked']) {
965 965
 			$output .= ' checked ';
966 966
 		}
967 967
 
@@ -972,12 +972,12 @@  discard block
 block discarded – undo
972 972
 		$output .= AUI_Component_Helper::aria_attributes($args);
973 973
 
974 974
 		// extra attributes
975
-		if(!empty($args['extra_attributes'])){
975
+		if (!empty($args['extra_attributes'])) {
976 976
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
977 977
 		}
978 978
 
979 979
 		// required
980
-		if(!empty($args['required'])){
980
+		if (!empty($args['required'])) {
981 981
 			$output .= ' required ';
982 982
 		}
983 983
 
@@ -985,13 +985,13 @@  discard block
 block discarded – undo
985 985
 		$output .= ' >';
986 986
 
987 987
 		// label
988
-		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
990
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
988
+		if (!empty($args['label']) && is_array($args['label'])) {
989
+		}elseif (!empty($args['label'])) {
990
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
991 991
 		}
992 992
 
993 993
 		// wrap
994
-		if(!$args['no_wrap']){
994
+		if (!$args['no_wrap']) {
995 995
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
996 996
 			$output = self::wrap(array(
997 997
 				'content' => $output,
Please login to merge, or discard this patch.
Braces   +15 added lines, -16 removed lines patch added patch discarded remove patch
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 			if($type=='file' ){
80 80
 				$label_after = true; // if type file we need the label after
81 81
 				$args['class'] .= ' custom-file-input ';
82
-			}elseif($type=='checkbox'){
82
+			} elseif($type=='checkbox'){
83 83
 				$label_after = true; // if type file we need the label after
84 84
 				$args['class'] .= ' custom-control-input ';
85
-			}elseif($type=='datepicker' || $type=='timepicker'){
85
+			} elseif($type=='datepicker' || $type=='timepicker'){
86 86
 				$type = 'text';
87 87
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
88 88
 				$args['class'] .= ' bg-initial ';
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
 			// label
168 168
 			if(!empty($args['label'])){
169
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
170
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
169
+				if($type == 'file'){$label_args['class'] .= 'custom-file-label';} elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
171 170
 				$label = self::label( $label_args, $type );
172 171
 			}
173 172
 
@@ -188,7 +187,7 @@  discard block
 block discarded – undo
188 187
 					'content' => $output,
189 188
 					'class'   => 'form-group custom-file'
190 189
 				) );
191
-			}elseif($type == 'checkbox'){
190
+			} elseif($type == 'checkbox'){
192 191
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
193 192
 				$output = self::wrap( array(
194 193
 					'content' => $output,
@@ -198,7 +197,7 @@  discard block
 block discarded – undo
198 197
 				if($args['label_type']=='horizontal'){
199 198
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
200 199
 				}
201
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
200
+			} elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202 201
 
203 202
 
204 203
 				// allow password field to toggle view
@@ -322,7 +321,7 @@  discard block
 block discarded – undo
322 321
 
323 322
 		// label
324 323
 		if(!empty($args['label']) && is_array($args['label'])){
325
-		}elseif(!empty($args['label']) && !$label_after){
324
+		} elseif(!empty($args['label']) && !$label_after){
326 325
 			$label_args = array(
327 326
 				'title'=> $args['label'],
328 327
 				'for'=> $args['id'],
@@ -357,7 +356,7 @@  discard block
 block discarded – undo
357 356
 
358 357
 			wp_editor( $content, $editor_id, $settings );
359 358
 			$output .= ob_get_clean();
360
-		}else{
359
+		} else{
361 360
 
362 361
 			// open
363 362
 			$output .= '<textarea ';
@@ -479,7 +478,7 @@  discard block
 block discarded – undo
479 478
 			// maybe hide labels //@todo set a global option for visibility class
480 479
 			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
481 480
 				$class = $args['class'];
482
-			}else{
481
+			} else{
483 482
 				$class = 'sr-only '.$args['class'];
484 483
 			}
485 484
 
@@ -582,7 +581,7 @@  discard block
 block discarded – undo
582 581
 			$output .= '</'.sanitize_html_class($args['type']).'>';
583 582
 
584 583
 
585
-		}else{
584
+		} else{
586 585
 			$output = $args['content'];
587 586
 		}
588 587
 
@@ -644,7 +643,7 @@  discard block
 block discarded – undo
644 643
 		if(!empty($args['select2'])){
645 644
 			$args['class'] .= ' aui-select2';
646 645
 			$is_select2 = true;
647
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
646
+		} elseif( strpos($args['class'], 'aui-select2') !== false){
648 647
 			$is_select2 = true;
649 648
 		}
650 649
 
@@ -663,7 +662,7 @@  discard block
 block discarded – undo
663 662
 
664 663
 		// label
665 664
 		if(!empty($args['label']) && is_array($args['label'])){
666
-		}elseif(!empty($args['label']) && !$label_after){
665
+		} elseif(!empty($args['label']) && !$label_after){
667 666
 			$label_args = array(
668 667
 				'title'=> $args['label'],
669 668
 				'for'=> $args['id'],
@@ -738,7 +737,7 @@  discard block
 block discarded – undo
738 737
 		// placeholder
739 738
 		if(!empty($args['placeholder']) && !$is_select2){
740 739
 			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
741
-		}elseif($is_select2 && !empty($args['placeholder'])){
740
+		} elseif($is_select2 && !empty($args['placeholder'])){
742 741
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
743 742
 		}
744 743
 
@@ -747,7 +746,7 @@  discard block
 block discarded – undo
747 746
 
748 747
 			if(!is_array($args['options'])){
749 748
 				$output .= $args['options']; // not the preferred way but an option
750
-			}else{
749
+			} else{
751 750
 				foreach($args['options'] as $val => $name){
752 751
 					$selected = '';
753 752
 					if(is_array($name)){
@@ -766,7 +765,7 @@  discard block
 block discarded – undo
766 765
 
767 766
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
768 767
 						}
769
-					}else{
768
+					} else{
770 769
 						if(!empty($args['value'])){
771 770
 							if(is_array($args['value'])){
772 771
 								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
@@ -986,7 +985,7 @@  discard block
 block discarded – undo
986 985
 
987 986
 		// label
988 987
 		if(!empty($args['label']) && is_array($args['label'])){
989
-		}elseif(!empty($args['label'])){
988
+		} elseif(!empty($args['label'])){
990 989
 			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
991 990
 		}
992 991
 
Please login to merge, or discard this patch.
wp-ayecode-ui/includes/components/class-aui-component-pagination.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit; // Exit if accessed directly
4
+    exit; // Exit if accessed directly
5 5
 }
6 6
 
7 7
 /**
@@ -11,77 +11,77 @@  discard block
 block discarded – undo
11 11
  */
12 12
 class AUI_Component_Pagination {
13 13
 
14
-	/**
15
-	 * Build the component.
16
-	 *
17
-	 * @param array $args
18
-	 *
19
-	 * @return string The rendered component.
20
-	 */
21
-	public static function get( $args = array() ) {
22
-		global $wp_query;
23
-
24
-		$defaults = array(
25
-			'class'              => '',
26
-			'mid_size'           => 2,
27
-			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
-			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation' ),
30
-			'before_paging' => '',
31
-			'after_paging'  => '',
32
-			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
-			'links'              => array() // an array of links if using custom links, this includes the a tag.
35
-		);
36
-
37
-		/**
38
-		 * Parse incoming $args into an array and merge it with $defaults
39
-		 */
40
-		$args = wp_parse_args( $args, $defaults );
41
-
42
-		$output = '';
43
-
44
-		// Don't print empty markup if there's only one page.
45
-		if ( $args['total'] > 1 ) {
46
-
47
-			// Set up paginated links.
48
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
49
-
50
-			$class = !empty($args['class']) ? $args['class'] : '';
51
-
52
-			// make the output bootstrap ready
53
-			$links_html = "<ul class='pagination m-0 p-0 $class'>";
54
-			if ( ! empty( $links ) ) {
55
-				foreach ( $links as $link ) {
56
-					$active = strpos( $link, 'current' ) !== false ? 'active' : '';
57
-					$links_html .= "<li class='page-item $active'>";
58
-					$links_html .= str_replace( "page-numbers", "page-link", $link );
59
-					$links_html .= "</li>";
60
-				}
61
-			}
62
-			$links_html .= "</ul>";
63
-
64
-			if ( $links ) {
65
-				$output .= '<section class="px-0 py-2 w-100">';
66
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
67
-				$output .= '</section>';
68
-			}
69
-
70
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
72
-		}
73
-
74
-		if ( $output ) {
75
-			if ( ! empty( $args['before_paging'] ) ) {
76
-				$output = $args['before_paging'] . $output;
77
-			}
78
-
79
-			if ( ! empty( $args['after_paging'] ) ) {
80
-				$output = $output . $args['after_paging'];
81
-			}
82
-		}
83
-
84
-		return $output;
85
-	}
14
+    /**
15
+     * Build the component.
16
+     *
17
+     * @param array $args
18
+     *
19
+     * @return string The rendered component.
20
+     */
21
+    public static function get( $args = array() ) {
22
+        global $wp_query;
23
+
24
+        $defaults = array(
25
+            'class'              => '',
26
+            'mid_size'           => 2,
27
+            'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28
+            'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
+            'screen_reader_text' => __( 'Posts navigation' ),
30
+            'before_paging' => '',
31
+            'after_paging'  => '',
32
+            'type'               => 'array',
33
+            'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
34
+            'links'              => array() // an array of links if using custom links, this includes the a tag.
35
+        );
36
+
37
+        /**
38
+         * Parse incoming $args into an array and merge it with $defaults
39
+         */
40
+        $args = wp_parse_args( $args, $defaults );
41
+
42
+        $output = '';
43
+
44
+        // Don't print empty markup if there's only one page.
45
+        if ( $args['total'] > 1 ) {
46
+
47
+            // Set up paginated links.
48
+            $links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
49
+
50
+            $class = !empty($args['class']) ? $args['class'] : '';
51
+
52
+            // make the output bootstrap ready
53
+            $links_html = "<ul class='pagination m-0 p-0 $class'>";
54
+            if ( ! empty( $links ) ) {
55
+                foreach ( $links as $link ) {
56
+                    $active = strpos( $link, 'current' ) !== false ? 'active' : '';
57
+                    $links_html .= "<li class='page-item $active'>";
58
+                    $links_html .= str_replace( "page-numbers", "page-link", $link );
59
+                    $links_html .= "</li>";
60
+                }
61
+            }
62
+            $links_html .= "</ul>";
63
+
64
+            if ( $links ) {
65
+                $output .= '<section class="px-0 py-2 w-100">';
66
+                $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
67
+                $output .= '</section>';
68
+            }
69
+
70
+            $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
+            $output = str_replace( "nav-links", "aui-nav-links", $output );
72
+        }
73
+
74
+        if ( $output ) {
75
+            if ( ! empty( $args['before_paging'] ) ) {
76
+                $output = $args['before_paging'] . $output;
77
+            }
78
+
79
+            if ( ! empty( $args['after_paging'] ) ) {
80
+                $output = $output . $args['after_paging'];
81
+            }
82
+        }
83
+
84
+        return $output;
85
+    }
86 86
 
87 87
 }
88 88
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function get( $args = array() ) {
21
+	public static function get($args = array()) {
22 22
 		global $wp_query;
23 23
 
24 24
 		$defaults = array(
@@ -26,57 +26,57 @@  discard block
 block discarded – undo
26 26
 			'mid_size'           => 2,
27 27
 			'prev_text'          => '<i class="fas fa-chevron-left"></i>',
28 28
 			'next_text'          => '<i class="fas fa-chevron-right"></i>',
29
-			'screen_reader_text' => __( 'Posts navigation' ),
29
+			'screen_reader_text' => __('Posts navigation'),
30 30
 			'before_paging' => '',
31 31
 			'after_paging'  => '',
32 32
 			'type'               => 'array',
33
-			'total'              => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1,
33
+			'total'              => isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1,
34 34
 			'links'              => array() // an array of links if using custom links, this includes the a tag.
35 35
 		);
36 36
 
37 37
 		/**
38 38
 		 * Parse incoming $args into an array and merge it with $defaults
39 39
 		 */
40
-		$args = wp_parse_args( $args, $defaults );
40
+		$args = wp_parse_args($args, $defaults);
41 41
 
42 42
 		$output = '';
43 43
 
44 44
 		// Don't print empty markup if there's only one page.
45
-		if ( $args['total'] > 1 ) {
45
+		if ($args['total'] > 1) {
46 46
 
47 47
 			// Set up paginated links.
48
-			$links = !empty(  $args['links'] ) ? $args['links'] :  paginate_links( $args );
48
+			$links = !empty($args['links']) ? $args['links'] : paginate_links($args);
49 49
 
50 50
 			$class = !empty($args['class']) ? $args['class'] : '';
51 51
 
52 52
 			// make the output bootstrap ready
53 53
 			$links_html = "<ul class='pagination m-0 p-0 $class'>";
54
-			if ( ! empty( $links ) ) {
55
-				foreach ( $links as $link ) {
56
-					$active = strpos( $link, 'current' ) !== false ? 'active' : '';
54
+			if (!empty($links)) {
55
+				foreach ($links as $link) {
56
+					$active = strpos($link, 'current') !== false ? 'active' : '';
57 57
 					$links_html .= "<li class='page-item $active'>";
58
-					$links_html .= str_replace( "page-numbers", "page-link", $link );
58
+					$links_html .= str_replace("page-numbers", "page-link", $link);
59 59
 					$links_html .= "</li>";
60 60
 				}
61 61
 			}
62 62
 			$links_html .= "</ul>";
63 63
 
64
-			if ( $links ) {
64
+			if ($links) {
65 65
 				$output .= '<section class="px-0 py-2 w-100">';
66
-				$output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] );
66
+				$output .= _navigation_markup($links_html, 'aui-pagination', $args['screen_reader_text']);
67 67
 				$output .= '</section>';
68 68
 			}
69 69
 
70
-			$output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output );
71
-			$output = str_replace( "nav-links", "aui-nav-links", $output );
70
+			$output = str_replace("screen-reader-text", "screen-reader-text sr-only", $output);
71
+			$output = str_replace("nav-links", "aui-nav-links", $output);
72 72
 		}
73 73
 
74
-		if ( $output ) {
75
-			if ( ! empty( $args['before_paging'] ) ) {
74
+		if ($output) {
75
+			if (!empty($args['before_paging'])) {
76 76
 				$output = $args['before_paging'] . $output;
77 77
 			}
78 78
 
79
-			if ( ! empty( $args['after_paging'] ) ) {
79
+			if (!empty($args['after_paging'])) {
80 80
 				$output = $output . $args['after_paging'];
81 81
 			}
82 82
 		}
Please login to merge, or discard this patch.